Commit affea57b authored by Mindiell's avatar Mindiell
Browse files

Conversion to Drupal 7

parent 6469a527
<?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}");
while ($data = db_fetch_object($result)) {
foreach ($result as $data) {
$blocks['timeline-' . $data->did]['info'] = t('Timeline of the dossier @dossier',
array('@dossier' =>$data->machine_name));
}
return $blocks;
}
/*
* Implements hook_block_view().
*
* This hook returns the content of block.
*/
function lqdn_dossiers_block_view($delta = '') {
global $language;
$block = array();
$query = "
SELECT d.`did`, d.`machine_name`, c.`name`, c.`language`
FROM {lqdn_dossiers} d
LEFT JOIN {lqdn_dossiers_contents} c
ON d.`did` = c.`did` AND c.`language` = '%s'
SELECT d.`did`, d.`machine_name`, c.`name`, c.`language`
FROM {lqdn_dossiers} d
LEFT JOIN {lqdn_dossiers_contents} c
ON d.`did` = c.`did` AND c.`language` = :lang
";
$result = db_query($query, $language->language);
while ($data = db_fetch_object($result)) {
if ($delta == 'timeline-' . $data->did) {
$block['subject'] = $data->name;
$block['content'] = _lqdn_timeline_block($data);
return $block;
}
$result = db_query($query, array(":lang"=>$language->language));
foreach ($result as $data) {
if ($delta == 'timeline-' . $data->did) {
$block['subject'] = $data->name;
$block['content'] = _lqdn_timeline_block($data);
return $block;
}
}
return $block;
}
function _lqdn_timeline_block($_dossier) {
$query = "SELECT * FROM {lqdn_timeline} WHERE `did`='%d' AND `language`='%s'";
$result = db_query($query, $_dossier->did, $_dossier->language);
$events = array();
while ($data = db_fetch_object($result))
$events[] = $data;
$events = array();
$result = db_query("SELECT * FROM {lqdn_timeline} WHERE `did`=:did and `language`=:lang",
array(":did"=>$_dossier->did, ":lang"=>$_dossier->language)
);
foreach ($result as $data) {
$events[] = $data;
}
return $events;
}
Markdown is supported
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