getObject(); /* @var $object kDBList */ switch ($event->Special) { case 'user': $user_id = $this->Application->GetVar('u_id'); if ( $user_id !== false ) { // show only groups, that user doesn't belong to $table_name = $this->Application->GetTempName(TABLE_PREFIX . 'UserGroupRelations', 'prefix:u'); $sql = 'SELECT GroupId FROM ' . $table_name . ' WHERE PortalUserId = ' . (int)$user_id; $group_ids = $this->Conn->GetCol($sql); // add system groups array_push($group_ids, $this->Application->ConfigValue('User_GuestGroup')); // Guest array_push($group_ids, $this->Application->ConfigValue('User_LoggedInGroup')); // Everyone $object->addFilter('already_member_filter', '%1$s.GroupId NOT IN (' . implode(',', $group_ids) . ')'); } break; } } /** * Refreshes left tree on save * * @param kEvent $event * @return void * @access protected */ protected function OnSave(&$event) { parent::OnSave($event); $this->Application->StoreVar('refresh_tree', 1); } }