uid; } if ($op == 'update' || $op == 'delete') { if (user_access('edit own blog') && ($user->uid == $node->uid)) { return TRUE; } } } function yxsidebar_perm() { return array('view style', 'edit style'); } function yxsidebar_block($op='list', $delta=0) { global $user; if ($op == "list") { $block[0]["info"] = t('yxsidebar'); return $block; } else if ($op == 'view') { $block['subject'] = ''; $styles->template=''; if(((arg(0)=='blog'||arg(0)=='node')&&is_numeric(arg(1)))) { if(arg(0)=='node') { //if this node type is a blog ? and who owner this blog? $sqlstr="select uid from node where nid=".arg(1)." and type='blog'"; $node= db_fetch_object(db_query($sqlstr)); $uid=$node->uid; } else if(arg(0)=='blog') { $uid=arg(1); } if(is_numeric($uid)) { $styles= db_fetch_object(db_query('SELECT * from blogstyle where uid='.$uid.' limit 1;')); if($styles) { $block['content'] .="\r\n".''."\r\n"; $block['content'] .="\r\n
\r\n"; } } } if (user_access('edit style')) { $block['subject'] = ''; if(arg(2)=='') $block['content'] .= '修改模版'; if(arg(2)=='edit') { $styles= db_fetch_object(db_query('SELECT * from blogstyle where uid='.$user->uid.' limit 1;')); $formcode=' '; $block['content'] .=$formcode; } else if(arg(2)=='save') { $info=$_POST['userstyles']; $cssname=$_POST['cssname']; if( db_fetch_object(db_query('SELECT * from blogstyle where uid='.$user->uid.' limit 1;'))) { $r=db_query("update blogstyle set template='%s',cssname='%s' where uid=%d", $info, $cssname,$user->uid); } else { $r=db_query("INSERT INTO blogstyle (uid,template,cssname) VALUES (%d, '%s', '%s')", $user->uid, $info, $cssname); } if($r==1) $result='保存成功'; else $result='保存失败'; $block['content'] .="