/**
  * @see DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     $sql = "SELECT\t\t" . (!empty($this->sqlSelects) ? $this->sqlSelects . ',' : '') . "\n\t\t\t\t\tavatar_table.*, \n\t\t\t\t\tcontest_sponsor.*,\n\t\t\t\t\tuser_table.username, \n\t\t\t\t\tgroup_table.groupName\n\t\t\tFROM\t\twcf" . WCF_N . "_contest_sponsor contest_sponsor\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table\n\t\t\tON\t\t(user_table.userID = contest_sponsor.userID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_avatar avatar_table\n\t\t\tON\t\t(avatar_table.avatarID = user_table.avatarID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_group group_table\n\t\t\tON\t\t(group_table.groupID = contest_sponsor.groupID)\n\t\t\t" . $this->sqlJoins . "\n\n\t\t\tWHERE (" . ContestSponsor::getStateConditions() . ")\n\t\t\t" . (!empty($this->sqlConditions) ? "AND " . $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)) {
         $this->sponsors[] = new ViewableContestSponsor(null, $row);
     }
 }
 /**
  * @see Form::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     // display branding
     require_once WCF_DIR . 'lib/util/ContestUtil.class.php';
     ContestUtil::assignVariablesBranding();
     // display branding
     require_once WCF_DIR . 'lib/util/ContestUtil.class.php';
     ContestUtil::assignVariablesBranding();
     // save invitations
     if ($this->entry->isOwner()) {
         require_once WCF_DIR . 'lib/form/ContestSponsorInviteForm.class.php';
         new ContestSponsorInviteForm($this->entry);
     }
     // init form
     if ($this->action == 'edit') {
         require_once WCF_DIR . 'lib/form/ContestSponsorEditForm.class.php';
         new ContestSponsorEditForm($this->entry);
     } else {
         if ($this->entry->isSponsorable()) {
             require_once WCF_DIR . 'lib/form/ContestSponsorAddForm.class.php';
             new ContestSponsorAddForm($this->entry);
         }
     }
     if ($this->entry->enableSponsorCheck && !$this->entry->isSponsor()) {
         WCF::getTPL()->append('additionalContentBecomeSponsor', '<p class="info">' . WCF::getLanguage()->get('wcf.contest.enableSponsorCheck.info') . '</p>');
     }
     if ($this->entry->isEnabledJury() && $this->entry->state == 'closed') {
         WCF::getTPL()->append('userMessages', '<p class="info">' . WCF::getLanguage()->get('wcf.contest.jury.closed.info') . '</p>');
         // init todo list
         require_once WCF_DIR . 'lib/data/contest/sponsor/todo/ContestSponsorTodoList.class.php';
         $this->todoList = new ContestSponsorTodoList();
         $this->todoList->sqlConditions .= 'contest_sponsor.contestID = ' . $this->contestID;
         $this->todoList->readObjects();
     }
     $this->sidebar->assignVariables();
     WCF::getTPL()->assign(array('entry' => $this->entry, 'isSponsor' => $this->isSponsor, 'contestID' => $this->contestID, 'userID' => $this->entry->userID, 'sponsors' => $this->sponsorList->getObjects(), 'todos' => $this->todoList ? $this->todoList->getObjects() : array(), 'templateName' => $this->templateName, 'allowSpidersToIndexThisPage' => true, 'contestmenu' => ContestMenu::getInstance()));
 }
 /**
  * @see DatabaseObject::handleData()
  */
 protected function handleData($data)
 {
     parent::handleData($data);
     $this->owner = new ContestOwner($data, $this->userID, $this->groupID);
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     if ($this->sponsorID) {
         $sponsor = new ContestSponsor($this->sponsorID);
     } else {
         $sponsor = ContestSponsor::find($this->contest->contestID, $this->userID, $this->groupID);
     }
     if ($sponsor === null) {
         require_once WCF_DIR . 'lib/data/contest/sponsor/ContestSponsorEditor.class.php';
         $state = $this->contest->enableSponsorCheck ? 'applied' : 'accepted';
         $sponsor = ContestSponsorEditor::create($this->contest->contestID, $this->userID, $this->groupID, $state);
     }
     // save price
     $price = ContestPriceEditor::create($this->contest->contestID, $sponsor->sponsorID, $this->subject, $this->text, $this->secretMessage, $this->attachmentListEditor);
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestPrice&contestID=' . $this->contest->contestID . '&priceID=' . $price->priceID . SID_ARG_2ND_NOT_ENCODED . '#priceObj' . $price->priceID);
     exit;
 }
 /**
  * @see DatabaseObjectList::countObjects()
  */
 public function countObjects()
 {
     $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_contest_sponsor contest_sponsor\n\n\t\t\tWHERE (" . ContestSponsor::getStateConditions() . ")\n\t\t\t" . (!empty($this->sqlConditions) ? "AND " . $this->sqlConditions : '');
     $row = WCF::getDB()->getFirstRow($sql);
     return $row['count'];
 }