/** * @see Action::execute() */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.user.infraction.canDeleteSuspension'); // revoke suspension if (!$this->userSuspension->revoked) { $object = Suspension::getSuspensionTypeObject($this->userSuspension->suspensionType); $object->revoke(new User($this->userSuspension->userID), $this->userSuspension, new Suspension($this->userSuspension->suspensionID)); Session::resetSessions($this->userSuspension->userID); } // delete suspension $this->userSuspension->delete(); $this->executed(); // forward to list page HeaderUtil::redirect('index.php?page=UserSuspensionList&deletedUserSuspensionID=' . $this->userSuspensionID . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED); exit; }
/** * Checks the warnings of a user and applies suspensions. * * @param integer $userID */ public static function checkWarnings($userID) { // get suspensions $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_user_infraction_suspension\n\t\t\tWHERE\t\tpackageID IN (\n\t\t\t\t\t\tSELECT\tdependency\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\n\t\t\t\t\t\tWHERE\tpackageID = " . PACKAGE_ID . "\n\t\t\t\t\t)\n\t\t\t\t\tAND points <= IFNULL((\n\t\t\t\t\t\tSELECT\tSUM(points)\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_infraction_warning_to_user\n\t\t\t\t\t\tWHERE\tuserID = " . $userID . "\n\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\texpires >= " . TIME_NOW . "\n\t\t\t\t\t\t\t\tOR expires = 0\n\t\t\t\t\t\t\t)\n\t\t\t\t\t), 0)\n\t\t\t\t\tAND suspensionID NOT IN (\n\t\t\t\t\t\tSELECT\tsuspensionID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_infraction_suspension_to_user\n\t\t\t\t\t\tWHERE\tuserID = " . $userID . "\n\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\texpires >= " . TIME_NOW . "\n\t\t\t\t\t\t\t\tOR expires = 0\n\t\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\tORDER BY \tpoints DESC"; $result = WCF::getDB()->sendQuery($sql); if (WCF::getDB()->countRows($result) > 0) { $user = new UserEditor($userID); while ($row = WCF::getDB()->fetchArray($result)) { // get suspension $suspension = new Suspension(null, $row); // create user suspension $userSuspension = UserSuspensionEditor::create($userID, $suspension->suspensionID, $suspension->expires != 0 ? TIME_NOW + $suspension->expires : 0); // get suspension type $suspensionTypeObject = Suspension::getSuspensionTypeObject($suspension->suspensionType); // apply suspension $suspensionTypeObject->apply($user, $userSuspension, $suspension); } // reset session Session::resetSessions($userID); } }
/** * @see Cronjob::execute() */ public function execute($data) { // require classes require_once WCF_DIR . 'lib/data/user/User.class.php'; require_once WCF_DIR . 'lib/data/user/infraction/suspension/Suspension.class.php'; require_once WCF_DIR . 'lib/data/user/infraction/suspension/UserSuspension.class.php'; // get user suspensions $userSuspensions = $users = $suspensions = $userIDArray = $suspensionIDArray = array(); $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_user_infraction_suspension_to_user\n\t\t\tWHERE\t\tpackageID IN (\n\t\t\t\t\t\tSELECT\tdependency\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\n\t\t\t\t\t\tWHERE\tpackageID = " . PACKAGE_ID . "\n\t\t\t\t\t)\n\t\t\t\t\tAND revoked = 0\n\t\t\t\t\tAND expires > 0\n\t\t\t\t\tAND expires < " . TIME_NOW . "\n\t\t\tORDER BY \texpires"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $userSuspensions[] = new UserSuspension(null, $row); $userIDArray[$row['userID']] = $row['userID']; $suspensionIDArray[$row['suspensionID']] = $row['suspensionID']; } // get unexpired suspensions of the affected users $unexpiredUserSuspensions = array(); if (count($userIDArray)) { $sql = "SELECT\t\tsuspension_to_user.*, suspension.suspensionType\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user_infraction_suspension_to_user suspension_to_user\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_infraction_suspension suspension\n\t\t\t\tON\t\t(suspension.suspensionID = suspension_to_user.suspensionID)\n\t\t\t\tWHERE\t\tsuspension_to_user.userID IN (" . implode(',', $userIDArray) . ")\n\t\t\t\t\t\tAND suspension_to_user.packageID IN (\n\t\t\t\t\t\t\tSELECT\tdependency\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\n\t\t\t\t\t\t\tWHERE\tpackageID = " . PACKAGE_ID . "\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND suspension_to_user.revoked = 0\n\t\t\t\t\t\tAND (suspension_to_user.expires = 0 OR suspension_to_user.expires >= " . TIME_NOW . ")\n\t\t\t\tORDER BY \tsuspension_to_user.expires"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!isset($unexpiredUserSuspensions[$row['userID']])) { $unexpiredUserSuspensions[$row['userID']] = array(); } $unexpiredUserSuspensions[$row['userID']][] = new UserSuspension(null, $row); } } // get users if (count($userIDArray)) { $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $userIDArray) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $users[$row['userID']] = new User(null, $row); } } // get suspensions if (count($suspensionIDArray)) { $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_user_infraction_suspension\n\t\t\t\tWHERE\tsuspensionID IN (" . implode(',', $suspensionIDArray) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $suspensions[$row['suspensionID']] = new Suspension(null, $row); } } // revoke suspensions $revokedIDArray = array(); foreach ($userSuspensions as $userSuspension) { if (isset($suspensions[$userSuspension->suspensionID]) && isset($users[$userSuspension->userID])) { $revokedIDArray[] = $userSuspension->userSuspensionID; $suspensionType = $suspensions[$userSuspension->suspensionID]->suspensionType; // check unexpired suspensions of this user if (isset($unexpiredUserSuspensions[$userSuspension->userID])) { foreach ($unexpiredUserSuspensions[$userSuspension->userID] as $unexpiredUserSuspension) { if ($unexpiredUserSuspension->suspensionType == $suspensionType) { continue 2; } } } // revoke suspension $object = Suspension::getSuspensionTypeObject($suspensionType); $object->revoke($users[$userSuspension->userID], $userSuspension, $suspensions[$userSuspension->suspensionID]); } } // flag revoked suspensions if (count($revokedIDArray)) { $sql = "UPDATE\twcf" . WCF_N . "_user_infraction_suspension_to_user\n\t\t\t\tSET\trevoked = 1\n\t\t\t\tWHERE\tuserSuspensionID IN (" . implode(',', $revokedIDArray) . ")"; WCF::getDB()->sendQuery($sql); } // reset sessions if (count($userIDArray)) { Session::resetSessions($userIDArray); } }