/**
  * Checks if the users with the given ids should be assigned to new user
  * groups.
  * 
  * Note: This method uses the user ids as a parameter instead of user objects
  * on purpose to make sure the latest data of the users are fetched.
  * 
  * @param	array<integer>		$userIDs
  */
 public function checkUsers(array $userIDs)
 {
     if (empty($userIDs)) {
         return;
     }
     $userList = new UserList();
     $userList->getConditionBuilder()->add('user_table.userID IN (?)', array($userIDs));
     $userList->readObjects();
     $assignments = UserGroupAssignmentCacheBuilder::getInstance()->getData();
     foreach ($userList as $user) {
         $groupIDs = $user->getGroupIDs();
         $newGroupIDs = array();
         foreach ($assignments as $assignment) {
             if (in_array($assignment->groupID, $groupIDs) || in_array($assignment->groupID, $newGroupIDs)) {
                 continue;
             }
             $checkFailed = false;
             $conditions = $assignment->getConditions();
             foreach ($conditions as $condition) {
                 if (!$condition->getObjectType()->getProcessor()->checkUser($condition, $user)) {
                     $checkFailed = true;
                     break;
                 }
             }
             if (!$checkFailed) {
                 $newGroupIDs[] = $assignment->groupID;
             }
         }
         if (!empty($newGroupIDs)) {
             $userAction = new UserAction(array($user), 'addToGroups', array('addDefaultGroups' => false, 'deleteOldGroups' => false, 'groups' => $newGroupIDs));
             $userAction->executeAction();
         }
     }
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     $assignments = UserGroupAssignmentCacheBuilder::getInstance()->getData();
     $usersToGroup = array();
     foreach ($assignments as $assignment) {
         if (!isset($usersToGroup[$assignment->groupID])) {
             $usersToGroup[$assignment->groupID] = array();
         }
         $usersToGroup[$assignment->groupID] = array_merge($usersToGroup[$assignment->groupID], UserGroupAssignmentHandler::getInstance()->getUsers($assignment));
     }
     foreach ($usersToGroup as $groupID => $users) {
         $userAction = new UserAction(array_unique($users), 'addToGroups', array('addDefaultGroups' => false, 'deleteOldGroups' => false, 'groups' => array($groupID)));
         $userAction->executeAction();
     }
 }
 /**
  * @see	\wcf\data\IEditableCachedObject::resetCache()
  */
 public static function resetCache()
 {
     UserGroupAssignmentCacheBuilder::getInstance()->reset();
     ConditionCacheBuilder::getInstance()->reset(array('definitionID' => ObjectTypeCache::getInstance()->getDefinitionByName('com.woltlab.wcf.condition.userGroupAssignment')->definitionID));
 }