Commit affea57b authored by Mindiell's avatar Mindiell
Browse files

Conversion to Drupal 7

parent 6469a527
<?php <?php
function lqdn_dossiers_block_list_alter(&$blocks) { /*
* Implements hook_block_info().
*
* This hook lists blocks to add/use.
*/
function lqdn_dossiers_block_info() {
$blocks = array();
$result = db_query("SELECT `did`, `machine_name` FROM {lqdn_dossiers}"); $result = db_query("SELECT `did`, `machine_name` FROM {lqdn_dossiers}");
while ($data = db_fetch_object($result)) { foreach ($result as $data) {
$blocks['timeline-' . $data->did]['info'] = t('Timeline of the dossier @dossier', $blocks['timeline-' . $data->did]['info'] = t('Timeline of the dossier @dossier',
array('@dossier' =>$data->machine_name)); array('@dossier' =>$data->machine_name));
} }
return $blocks;
} }
/*
* Implements hook_block_view().
*
* This hook returns the content of block.
*/
function lqdn_dossiers_block_view($delta = '') { function lqdn_dossiers_block_view($delta = '') {
global $language; $block = array();
$query = " $query = "
SELECT d.`did`, d.`machine_name`, c.`name`, c.`language` SELECT d.`did`, d.`machine_name`, c.`name`, c.`language`
FROM {lqdn_dossiers} d FROM {lqdn_dossiers} d
LEFT JOIN {lqdn_dossiers_contents} c LEFT JOIN {lqdn_dossiers_contents} c
ON d.`did` = c.`did` AND c.`language` = '%s' ON d.`did` = c.`did` AND c.`language` = :lang
"; ";
$result = db_query($query, $language->language); $result = db_query($query, array(":lang"=>$language->language));
while ($data = db_fetch_object($result)) { foreach ($result as $data) {
if ($delta == 'timeline-' . $data->did) { if ($delta == 'timeline-' . $data->did) {
$block['subject'] = $data->name; $block['subject'] = $data->name;
$block['content'] = _lqdn_timeline_block($data); $block['content'] = _lqdn_timeline_block($data);
return $block; return $block;
} }
} }
return $block;
} }
function _lqdn_timeline_block($_dossier) { function _lqdn_timeline_block($_dossier) {
$query = "SELECT * FROM {lqdn_timeline} WHERE `did`='%d' AND `language`='%s'"; $events = array();
$result = db_query($query, $_dossier->did, $_dossier->language); $result = db_query("SELECT * FROM {lqdn_timeline} WHERE `did`=:did and `language`=:lang",
$events = array(); array(":did"=>$_dossier->did, ":lang"=>$_dossier->language)
while ($data = db_fetch_object($result)) );
$events[] = $data; foreach ($result as $data) {
$events[] = $data;
}
return $events;
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment