我在我的网站中为我的群组编写了以下代码..
public function set_group_id($group_id)
{
$db2 = & $this->network->db2;
/* if( $this->id ) {
return FALSE;
} */
if( ! $group_id ) {
return FALSE;
}
if( ! $g = $this->network->get_group_by_id($group_id) ) {
return FALSE;
}
if( !$g->is_public && $this->user->id>0 && !$this->user->is_network_admin ) {
$users = $this->network->get_group_invited_members($g->id);
if( !$users || !in_array(intval($this->user->id),$users) ) {
return FALSE;
}
}
$D->i_am_network_admin = ( $this->user->is_logged && $this->user->info->is_network_admin > 0 );
$D->i_am_admin = $D->i_am_network_admin;
if( !$D->i_am_network_admin ) {
$D->i_am_admin = $db->fetch('SELECT id FROM groups_admins WHERE group_id="'.$g->id.'" AND user_id="'.$this->user->id.'" LIMIT 1') ? TRUE : FALSE;
}
if( $g->mojaz && !$this->user->i_am_admin ) {
return FALSE;
}
$this->group = $g;
$this->to_user = FALSE;
return TRUE;
}
我在这一行的错误...
$D->i_am_admin = $db->fetch('SELECT id FROM groups_admins WHERE group_id="'.$g->id.'" AND user_id="'.$this->user->id.'" LIMIT 1') ? TRUE : FALSE;
我想为网站组创建限制器,如果用户是网站管理员,他可以发送帖子,或者如果用户是组管理员可以发送帖子,否则返回 false。