/**
  * @see DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     // get ids
     $userWarningIDArray = $objectIDArray = $objects = array();
     $sql = "SELECT\t\tuser_warning.userWarningID,\n\t\t\t\t\tuser_warning.objectID, user_warning.objectType\n\t\t\tFROM\t\twcf" . WCF_N . "_user_infraction_warning_to_user user_warning\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_infraction_warning warning\n\t\t\tON\t\t(warning.warningID = user_warning.warningID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table\n\t\t\tON\t\t(user_table.userID = user_warning.userID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user judge\n\t\t\tON\t\t(judge.userID = user_warning.judgeID)\n\t\t\t" . $this->sqlJoins . "\n\t\t\t" . (!empty($this->sqlConditions) ? "WHERE " . $this->sqlConditions : '') . "\n\t\t\t" . (!empty($this->sqlOrderBy) ? "ORDER BY " . $this->sqlOrderBy : '');
     $result = WCF::getDB()->sendQuery($sql, $this->sqlLimit, $this->sqlOffset);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $userWarningIDArray[] = $row['userWarningID'];
         if ($row['objectID'] != 0 && $row['objectType'] != '') {
             if (!isset($objectIDArray[$row['objectType']])) {
                 $objectIDArray[$row['objectType']] = array();
             }
             $objectIDArray[$row['objectType']][] = $row['objectID'];
         }
     }
     if (count($userWarningIDArray)) {
         // get warning objects
         foreach ($objectIDArray as $objectType => $idArray) {
             if (($result = Warning::getWarningObjectByID($objectType, $idArray)) !== null) {
                 $objects[$objectType] = $result;
             }
         }
         // get warnings
         $sql = "SELECT\t\t" . (!empty($this->sqlSelects) ? $this->sqlSelects . ',' : '') . "\n\t\t\t\t\t\tuser_table.username, judge.username AS judgeUsername,\n\t\t\t\t\t\twarning.*, user_warning.*\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user_infraction_warning_to_user user_warning\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_infraction_warning warning\n\t\t\t\tON\t\t(warning.warningID = user_warning.warningID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table\n\t\t\t\tON\t\t(user_table.userID = user_warning.userID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user judge\n\t\t\t\tON\t\t(judge.userID = user_warning.judgeID)\n\t\t\t\t" . $this->sqlJoins . "\n\t\t\t\tWHERE\t\tuser_warning.userWarningID IN (" . implode(',', $userWarningIDArray) . ")\n\t\t\t\t" . (!empty($this->sqlOrderBy) ? "ORDER BY " . $this->sqlOrderBy : '');
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             if (isset($objects[$row['objectType']]) && isset($objects[$row['objectType']][$row['objectID']])) {
                 $row['object'] = $objects[$row['objectType']][$row['objectID']];
             }
             $this->userWarnings[] = new UserWarning(null, $row);
         }
     }
 }
 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['userID'])) {
         $this->userID = intval($_REQUEST['userID']);
     }
     if (isset($_REQUEST['objectID'])) {
         $this->objectID = intval($_REQUEST['objectID']);
     }
     if (isset($_REQUEST['objectType'])) {
         $this->objectType = $_REQUEST['objectType'];
     }
     if ($this->objectID != 0 && $this->objectType != '') {
         $this->object = Warning::getWarningObjectByID($this->objectType, $this->objectID);
         if ($this->object === null) {
             throw new IllegalLinkException();
         }
     }
     // get user
     $this->user = new UserSession($this->userID);
     if (!$this->user->userID) {
         throw new IllegalLinkException();
     }
     if ($this->user->getPermission('admin.user.infraction.canNotBeWarned')) {
         throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.infraction.error.canNotBeWarned', array('user' => $this->user)));
     }
     if ($this->object !== null) {
         // search existing warning
         $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_user_infraction_warning_to_user\n\t\t\t\tWHERE\tpackageID = " . PACKAGE_ID . "\n\t\t\t\t\tAND objectID = " . $this->objectID . "\n\t\t\t\t\tAND objectType = '" . escapeString($this->objectType) . "'\n\t\t\t\t\tAND userID = " . $this->userID;
         $warning = new UserWarning(null, WCF::getDB()->getFirstRow($sql));
         if ($warning->warningID) {
             throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.infraction.error.alreadyReported', array('warning' => $warning)));
         }
     }
 }
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     // get predefined warnings
     $this->warnings = Warning::getWarnings();
     // get warning object
     if ($this->userWarning->objectID != 0 && $this->userWarning->objectType != '') {
         $this->object = Warning::getWarningObjectByID($this->userWarning->objectType, $this->userWarning->objectID);
     }
     // get default values
     if (!count($_POST)) {
         $this->warningID = $this->userWarning->warningID;
         $this->title = $this->userWarning->title;
         $this->points = $this->userWarning->points;
         $this->reason = $this->userWarning->reason;
         if ($this->userWarning->expires != 0) {
             $expires = DateUtil::getLocalTimestamp($this->userWarning->expires);
             $this->expiresDay = gmdate('j', $expires);
             $this->expiresMonth = gmdate('n', $expires);
             $this->expiresYear = gmdate('Y', $expires);
             $this->expiresHour = gmdate('G', $expires);
             $this->expiresMinute = gmdate('i', $expires);
             $this->expiresMinute -= $this->expiresMinute % 5;
         }
     }
 }