/**
  * @see MultipleLinkPage::countItems()
  */
 public function countItems()
 {
     parent::countItems();
     $sql = "SELECT\tCOUNT(*) AS count\r\n\t\t\tFROM\tbash" . BASH_N . "_favorite\r\n\t\t\tWHERE\tuserID = " . BASHCore::getUser()->userID;
     $row = WCF::getDB()->getFirstRow($sql);
     return $row['count'];
 }
 public function save()
 {
     parent::save();
     if ($this->server == null) {
         $this->server = new Server($this->serverID);
     }
     $comment = ServerCommentEditor::create($this->server->serverID, BASHCore::getUser()->userID, $this->username, $this->text, TIME_NOW, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes, BASHCore::getUser()->userID > 0 ? false : true);
     if (MODULE_USER_RANK and BASHCore::getUser()->userID > 0) {
         require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php';
         UserRank::updateActivityPoints(SERVER_COMMENT_USER_ACTIVITY_POINTS);
     }
     HeaderUtil::redirect('index.php?page=ServerDetail&serverID=' . $comment->serverID . SID_ARG_2ND_NOT_ENCODED . '#comment' . $comment->commentID);
 }
 public function execute()
 {
     parent::execute();
     $entry = new NewsEntryEditor($this->entryID);
     if ($entry->entryID == 0) {
         throw new IllegalLinkException();
     }
     if (!BASHCore::getUser()->getPermission('mod.bash.canDeleteNewsEntries') and BASHCore::getUser()->userID != $entry->authorID) {
         throw new PermissionDeniedException();
     }
     NewsEntryEditor::remove($entry->entryID);
     HeaderUtil::redirect('index.php?page=Index' . SID_ARG_2ND_NOT_ENCODED);
 }
 public function execute()
 {
     parent::execute();
     $comment = new ServerCommentEditor($this->commentID);
     if ($comment->commentID == 0) {
         throw new IllegalLinkException();
     }
     if (!BASHCore::getUser()->getPermission('mod.comment.moderatorPermissions') and $comment->authorID != BASHCore::getUser()->userID) {
         throw new PermissionDeniedException();
     }
     ServerCommentEditor::remove($comment->commentID);
     HeaderUtil::redirect(BASHCore::getSession()->lastRequestURI, false);
 }
 public function execute()
 {
     parent::execute();
     $entry = new BashEntryEditor($this->entryID);
     if ($entry->entryID == 0) {
         throw new IllegalLinkException();
     }
     if (!BASHCore::getUser()->getPermission('mod.bash.moderatorPermissions')) {
         throw new PermissionDeniedException();
     }
     $entry->isDisabled = 0;
     $entry->update();
     HeaderUtil::redirect(BASHCore::getSession()->lastRequestURI, false);
 }
 /**
  * @see	Action::execute()
  */
 public function execute()
 {
     parent::execute();
     $entry = new BashEntryEditor($this->entryID);
     if ($entry->entryID == 0) {
         throw new IllegalLinkException();
     }
     if (!$entry->isFavorite()) {
         $entry->favorite();
     }
     if (!isset($_REQUEST['ajax'])) {
         HeaderUtil::redirect(BASHCore::getSession()->lastRequestURI, false);
     }
 }
 public function show()
 {
     // check for permissions
     if (!BASHCore::getUser()->userID) {
         throw new PermissionDeniedException();
     }
     if (!BASHCore::getUser()->getPermission('mod.comment.moderatorPermissions') and !BASHCore::getUser()->getPermission('mod.bash.moderatorPermissions')) {
         throw new PermissionDeniedException();
     }
     // activate usercpmenu
     require_once WCF_DIR . 'lib/page/util/menu/UserCPMenu.class.php';
     UserCPMenu::getInstance()->setActiveMenuItem('wcf.user.usercp.menu.link.modcp.overview');
     parent::show();
 }
 public function readData()
 {
     parent::readData();
     $sql = "SELECT\r\n\t\t\t    \t*\r\n\t\t\t\tFROM\r\n\t\t\t   \t\t`bash" . BASH_N . "_entry`" . ((BASHCore::getUser()->userID == 0 or !BASHCore::getUser()->isModerator()) ? ' WHERE `isDisabled` = 0 ' : '') . "\r\n\t\t\t\tORDER BY\r\n\t\t\t    \tRAND()\r\n\t\t\t    LIMIT 10";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->entries[] = new ViewableBashEntry(null, $row);
     }
     // init sidebars
     $this->sidebarFactory = new MessageSidebarFactory($this);
     foreach ($this->entries as $entry) {
         $this->sidebarFactory->create($entry);
     }
     $this->sidebarFactory->init();
 }
 /**
  * @see	Page::readData()
  */
 public function readData()
 {
     parent::readData();
     $sql = "SELECT\r\n\t\t\t    \t*\r\n\t\t\t\tFROM\r\n\t\t\t   \t\t`bash" . BASH_N . "_entry`" . (BASHCore::getUser()->isModerator() ? '' : 'WHERE `isDisabled` = 0 ') . "\r\n\t\t\t\tORDER BY\r\n\t\t\t    \ttimestamp DESC";
     $result = WCF::getDB()->sendQuery($sql, $this->itemsPerPage, ($this->pageNo - 1) * $this->itemsPerPage);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->entries[] = new ViewableBashEntry(null, $row);
     }
     // init sidebars
     $this->sidebarFactory = new MessageSidebarFactory($this);
     foreach ($this->entries as $entry) {
         $this->sidebarFactory->create($entry);
     }
     $this->sidebarFactory->init();
 }
 public function readData()
 {
     parent::readData();
     $sql = "SELECT\r\n\t\t\t    \t`bash" . BASH_N . "_entry`.*\r\n\t\t\t\tFROM\r\n\t\t\t   \t\t`bash" . BASH_N . "_entry`\r\n\t\t\t   \tWHERE\r\n\t\t\t   \t\t`bash" . BASH_N . "_entry`.authorID = " . $this->frame->getUserID() . (!BASHCore::getUser()->getPermission('mod.bash.moderatorPermissions') ? ' AND bash' . BASH_N . '_entry.isDisabled = 0' : '') . "\r\n\t\t\t\tORDER BY\r\n\t\t\t    \t`bash" . BASH_N . "_entry`.`timestamp` DESC";
     $result = WCF::getDB()->sendQuery($sql, $this->itemsPerPage, ($this->pageNo - 1) * $this->itemsPerPage);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->entries[] = new ViewableBashEntry(null, $row);
     }
     // init sidebars
     $this->sidebarFactory = new MessageSidebarFactory($this);
     foreach ($this->entries as $entry) {
         $this->sidebarFactory->create($entry);
     }
     $this->sidebarFactory->init();
 }
 /**
  * @see	Action::execute()
  */
 public function execute()
 {
     parent::execute();
     $entry = new BashEntryEditor($this->entryID);
     if ($entry->entryID == 0) {
         throw new IllegalLinkException();
     }
     if (!BASHCore::getUser()->getPermission('mod.bash.moderatorPermissions') and BASHCore::getUser()->userID != $entry->authorID) {
         throw new PermissionDeniedException();
     }
     BashEntryEditor::remove($entry->entryID);
     if (!isset($_REQUEST['ajax'])) {
         HeaderUtil::redirect(BASHCore::getSession()->lastRequestURI, false);
     }
 }
 /**
  * Returnes a count of all outstanding moderations
  */
 public function getOutstandingModerations()
 {
     $count = 0;
     if (BASHCore::getUser()->getPermission('mod.bash.moderatorPermissions')) {
         $sql = "SELECT\n\t\t\t\t\t\tCOUNT(*) AS count\n\t\t\t\t\tFROM\n\t\t\t\t\t\tbash" . BASH_N . "_entry\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tisDisabled = 1";
         $result = WCF::getDB()->getFirstRow($sql);
         $count = $count + intval($result['count']);
     }
     if (BASHCore::getUser()->getPermission('mod.comment.moderatorPermissions')) {
         $sql = "SELECT\n\t\t\t\t\t\tCOUNT(*) AS count\n\t\t\t\t\tFROM\n\t\t\t\t\t\tbash" . BASH_N . "_server_comment\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tisDisabled = 1";
         $result = WCF::getDB()->getFirstRow($sql);
         $count = $count + intval($result['count']);
     }
     return $count;
 }
 /**
  * If the user has already voted for this entry this should return true
  * @param	integer	$userID
  */
 public function hasVoted($userID = null)
 {
     if ($userID == null) {
         $userID = BASHCore::getUser()->userID;
     }
     $sql = "SELECT\r\n\t\t\t\t\tCOUNT(*) AS count\r\n\t\t\t\tFROM\r\n\t\t\t\t\tbash" . BASH_N . "_vote\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tentryID = " . $this->entryID . "\r\n\t\t\t\tAND\r\n\t\t\t\t\tuserID = " . $userID;
     $count = WCF::getDB()->getFirstRow($sql);
     if ($count['count'] != 0) {
         return true;
     }
     return false;
 }
 /**
  * @see	Form:.save()
  */
 public function save()
 {
     parent::save();
     $entry = BashEntryEditor::create(BASHCore::getUser()->userID, $this->username, $this->serverID, $this->serverName, $this->text, TIME_NOW, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes);
     if (MODULE_USER_RANK and BASHCore::getUser()->userID > 0) {
         require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php';
         UserRank::updateActivityPoints(BASH_USER_ACTIVITY_POINTS);
     }
     if (WCF::getUser()->userID > 0) {
         HeaderUtil::redirect('index.php?page=BashEntry&entryID=' . $entry->entryID . SID_ARG_2ND_NOT_ENCODED);
     } else {
         // redirect to index
         WCF::getTPL()->assign(array('url' => 'index.php' . SID_ARG_1ST, 'message' => WCF::getLanguage()->get('bash.page.bashEntryAdd.guestRedirect'), 'wait' => 10));
         WCF::getTPL()->display('redirect');
         exit;
     }
     // call event
     $this->saved();
 }
 /**
  * @see WCF::initSession()
  */
 protected function initSession()
 {
     require_once BASH_DIR . 'lib/system/session/BASHSessionFactory.class.php';
     $factory = new BASHSessionFactory();
     self::$sessionObj = $factory->get();
     self::$userObj = self::getSession()->getUser();
 }
 /**
  * Deletes the bash entry from users favorite list
  * @param	integer	$userID
  */
 public function unfavorite($userID = null)
 {
     if ($userID == null) {
         $userID = BASHCore::getUser()->userID;
     }
     $sql = "DELETE FROM\r\n\t\t\t\t\tbash" . BASH_N . "_favorite\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tentryID = " . $this->entryID . "\r\n\t\t\t\tAND\r\n\t\t\t\t\tuserID = " . $userID;
     WCF::getDB()->sendQuery($sql);
 }