$uid));
}
$rolliParing = db_query("SELECT ur.uid FROM {users_roles} ur WHERE ur.rid = 6 AND ur.uid=%d", $uid);
$rolliParinguVastus = db_fetch_object($rolliParing);
if($uid==$rolliParinguVastus->uid){
$block_content .= '
';
$raamatuIdParing = db_query(("SELECT n.nid, n.uid, n.created FROM {node} n WHERE n.status = 1 AND n.type = 'raamat' AND n.uid = %d ORDER BY n.changed DESC LIMIT 5"), $uid);
if(mysql_num_rows($raamatuIdParing)!=0){
$block_content .= '
';
while($raamatuId = db_fetch_object($raamatuIdParing)){
//SIIN ON VAJA MIDAGI TEHA
$raamatuYhendusParing = db_query("SELECT tn.nid, tn.tid FROM {term_node} tn WHERE ".$raamatuId->nid."=tn.nid ORDER BY tn.tid");
//$a=0;
$raamatuYhendusId=0;
$last = mysql_num_rows($raamatuYhendusParing);
while ($raamatuYhendus = db_fetch_object($raamatuYhendusParing)){
if($raamatuYhendusId<$raamatuYhendus->tid){
$raamatuYhendusId = $raamatuYhendus->tid;
}
/*$a++;
if($a==$last){
$raamatuYhendusId = $raamatuYhendus->tid;
}*/
}
$raamatuNimi = db_query("SELECT td.tid, td.name FROM {term_data} td WHERE td.tid=%d ORDER BY td.tid", $raamatuYhendusId);
$raamatuNimiVastus = db_fetch_object($raamatuNimi);
$nameAlone = $raamatuNimiVastus->name;
$nameLength = strlen($nameAlone);
if($nameLength<=10){
$newName=$nameAlone;
} else {
$newName = substr($nameAlone, 0, 10);
$newName .= '...';
}
if($raamatuNimiVastus->name!=""){
$block_content .= '-
'.$newName.'
['.date('d.m.Y', $raamatuId->created).']';
}
}
$block_content .= '
';
} else {
$block_content .= 'Raamatud puuduvad.';
}
$block_content .= '
';
}
// the block view
if ($block_content == '') {
// no content
$block['subject'] = 'Viimased raamatud';
$block['content'] = '';
return $block;
}
// set up the block
$block['subject'] = 'viimased raamatud';
$block['content'] = $block_content;
return $block;
}
}