public function testContestPage()
 {
     $user = $this->user;
     $contest = $this->contest;
     // save two jurytalk entries
     require_once WCF_DIR . 'lib/data/contest/jurytalk/ContestJurytalkEditor.class.php';
     $this->deleteArray[] = $jurytalk = ContestJurytalkEditor::create($contestID = $contest->contestID, $jurytalk = __METHOD__ . ' jurytalk #1', $userID = $user->userID, $username = $user->username);
     $this->deleteArray[] = $jurytalk = ContestJurytalkEditor::create($contestID = $contest->contestID, $jurytalk = __METHOD__ . ' jurytalk #2', $userID = $user->userID, $username = $user->username);
     $raised = false;
     try {
         $this->runHTTP('page=ContestJurytalk&contestID=' . $contest->contestID);
     } catch (Exception $e) {
         $raised = true;
     }
     $this->assertTrue($raised, "user should not be allowed to access a private contest");
     // now try with owner
     $this->setCurrentUser($user);
     $this->runHTTP('page=ContestJurytalk&contestID=' . $contest->contestID);
     $this->assertEquals(count(WCF::getTPL()->get('jurytalks')), 2);
     // now try with jury member who was invited
     $this->deleteArray[] = $juryuser = $this->createUser();
     require_once WCF_DIR . 'lib/data/contest/jury/ContestJuryEditor.class.php';
     $this->deleteArray[] = $jury = ContestJuryEditor::create($contestID = $contest->contestID, $userID = $juryuser->userID, $groupID = 0, $state = 'invited');
     $this->setCurrentUser($juryuser);
     $this->runHTTP('page=ContestJurytalk&contestID=' . $contest->contestID);
     // invited members should only see first entry
     $this->assertEquals(count(WCF::getTPL()->get('jurytalks')), 1);
     // accepted members should have 2 entries
     $jury->update($contestID, $userID, $groupID, 'accepted');
     $this->runHTTP('page=ContestJurytalk&contestID=' . $contest->contestID);
     $this->assertEquals(count(WCF::getTPL()->get('jurytalks')), 2);
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (MODULE_USER_INFRACTION == 1) {
         if ($eventName == 'init') {
             if (WCF::getUser()->getPermission('admin.user.infraction.canWarnUser') || USER_CAN_SEE_HIS_WARNINGS && WCF::getUser()->userID == $eventObj->userID) {
                 $eventObj->sqlSelects .= "(SELECT COUNT(*) FROM wcf" . WCF_N . "_user_infraction_warning_to_user WHERE userID = " . $eventObj->userID . ") AS warnings,";
             }
         } else {
             if ($eventName == 'assignVariables') {
                 if (!$eventObj->getUser()->warnings) {
                     // remove warning overview tab
                     foreach (UserProfileMenu::getInstance()->menuItems as $parentMenuItem => $items) {
                         foreach ($items as $key => $item) {
                             if ($item['menuItem'] == 'wcf.user.profile.menu.link.infraction') {
                                 unset(UserProfileMenu::getInstance()->menuItems[$parentMenuItem][$key]);
                             }
                         }
                     }
                 }
                 // add warn button
                 if (WCF::getUser()->getPermission('admin.user.infraction.canWarnUser')) {
                     WCF::getTPL()->append('additionalAdminOptions', '<li><a href="index.php?form=UserWarn&amp;userID=' . $eventObj->userID . SID_ARG_2ND . '">' . WCF::getLanguage()->get('wcf.user.infraction.button.warn') . '</a></li>');
                 }
             }
         }
     }
 }
 /**
  * @see OptionType::getData()
  */
 public function getData($optionData, $newValue)
 {
     $newValue = str_replace(' ', '', $newValue);
     $newValue = str_replace(WCF::getLanguage()->get('wcf.global.thousandsSeparator'), '', $newValue);
     $newValue = str_replace(WCF::getLanguage()->get('wcf.global.decimalPoint'), '.', $newValue);
     return floatval($newValue);
 }
 /**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     list($cache, $packageID, $languageIDs) = explode('-', $cacheResource['cache']);
     $data = array();
     // get all taggable types
     $sql = "SELECT\t\ttaggable.taggableID, taggable.name\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency,\n\t\t\t\t\twcf" . WCF_N . "_tag_taggable taggable\n\t\t\tWHERE \t\ttaggable.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . $packageID . "\n\t\t\tORDER BY\tpackage_dependency.priority";
     $result = WCF::getDB()->sendQuery($sql);
     $itemIDs = array();
     while ($row = WCF::getDB()->fetchArray($result)) {
         $itemIDs[$row['name']] = $row['taggableID'];
     }
     if (count($itemIDs) > 0) {
         // get tag ids
         $tagIDs = array();
         $sql = "SELECT\t\tCOUNT(*) AS counter, object.tagID\n\t\t\t\tFROM \t\twcf" . WCF_N . "_tag_to_object object\n\t\t\t\tWHERE \t\tobject.taggableID IN (" . implode(',', $itemIDs) . ")\n\t\t\t\t\t\tAND object.languageID IN (" . $languageIDs . ")\n\t\t\t\tGROUP BY \tobject.tagID\n\t\t\t\tORDER BY \tcounter DESC";
         $result = WCF::getDB()->sendQuery($sql, 500);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $tagIDs[$row['tagID']] = $row['counter'];
         }
         // get tags
         if (count($tagIDs)) {
             $sql = "SELECT\t\tname, tagID\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_tag\n\t\t\t\t\tWHERE\t\ttagID IN (" . implode(',', array_keys($tagIDs)) . ")";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $row['counter'] = $tagIDs[$row['tagID']];
                 $this->tags[StringUtil::toLowerCase($row['name'])] = new Tag(null, $row);
             }
             // sort by counter
             uasort($this->tags, array('self', 'compareTags'));
             $data = $this->tags;
         }
     }
     return $data;
 }
 /**
  * @see Form::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     // default settings
     $this->closeThread = $this->thread->isClosed;
     $this->subscription = $this->thread->subscribed;
     if (WCF::getUser()->userID) {
         // options
         $this->parseURL = WCF::getUser()->{$this->permissionType . 'ParseURL'};
         $this->enableSmilies = WCF::getUser()->{$this->permissionType . 'EnableSmilies'};
         $this->enableHtml = WCF::getUser()->{$this->permissionType . 'EnableHtml'};
         $this->enableBBCodes = WCF::getUser()->{$this->permissionType . 'EnableBBCodes'};
         if ($this->showSignatureSetting) {
             $this->showSignature = WCF::getUser()->{$this->permissionType . 'ShowSignature'};
         }
         if (!$this->subscription && WCF::getUser()->enableSubscription) {
             $this->subscription = 1;
         }
     } else {
         // options
         $this->parseURL = MESSAGE_FORM_DEFAULT_PARSE_URL;
         $this->enableSmilies = MESSAGE_FORM_DEFAULT_ENABLE_SMILIES;
         $this->enableHtml = MESSAGE_FORM_DEFAULT_ENABLE_HTML;
         $this->enableBBCodes = MESSAGE_FORM_DEFAULT_ENABLE_BBCODES;
     }
     $this->enableSmilies = intval($this->enableSmilies && WCF::getUser()->getPermission('user.' . $this->permissionType . '.canUseSmilies'));
     $this->enableHtml = intval($this->enableHtml && WCF::getUser()->getPermission('user.' . $this->permissionType . '.canUseHtml'));
     $this->enableBBCodes = intval($this->enableBBCodes && WCF::getUser()->getPermission('user.' . $this->permissionType . '.canUseBBCodes'));
 }
 /**
  * @see Cronjob::execute()
  */
 public function execute($data)
 {
     $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_group\n\t\t\tWHERE\tneededAge <> 0\n\t\t\t\tOR neededPoints <> 0";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $userIDArray = array();
         if ($row['neededAge'] > 0) {
             $sql = "SELECT\tuserID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t\t\tWHERE\tregistrationDate <= " . (TIME_NOW - 86400 * $row['neededAge']) . "\n\t\t\t\t\t\tAND userID NOT IN (\n\t\t\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\tWHERE\tgroupID = " . $row['groupID'] . "\n\t\t\t\t\t\t)";
             $result2 = WCF::getDB()->sendQuery($sql);
             while ($row2 = WCF::getDB()->fetchArray($result2)) {
                 $userIDArray[] = $row2['userID'];
             }
         }
         if ($row['neededPoints'] > 0) {
             $sql = "SELECT\tuserID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t\t\tWHERE\tactivityPoints >= " . $row['neededPoints'] . "\n\t\t\t\t\t\tAND userID NOT IN (\n\t\t\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\tWHERE\tgroupID = " . $row['groupID'] . "\n\t\t\t\t\t\t)";
             $result2 = WCF::getDB()->sendQuery($sql);
             while ($row2 = WCF::getDB()->fetchArray($result2)) {
                 $userIDArray[] = $row2['userID'];
             }
         }
         if (count($userIDArray)) {
             $userIDArray = array_unique($userIDArray);
             // assign to group
             $sql = "INSERT INTO\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\t(userID, groupID)\n\t\t\t\t\tSELECT\t\tuserID, " . $row['groupID'] . "\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\t\t\tWHERE\t\tuserID IN (" . implode(',', $userIDArray) . ")";
             WCF::getDB()->sendQuery($sql);
             // reset sesions
             Session::resetSessions($userIDArray);
         }
     }
 }
Exemplo n.º 7
0
 public function __construct($data, $boxname = "")
 {
     $this->BoxData['templatename'] = "wbb3addonsBox01";
     $this->getBoxStatus($data);
     $this->BoxData['boxID'] = $data['boxID'];
     if (!defined('WBB3ADDONSBOX01_TITLE')) {
         define('WBB3ADDONSBOX01_TITLE', '');
     }
     if (!defined('WBB3ADDONSBOX01_BOXOPENED')) {
         define('WBB3ADDONSBOX01_BOXOPENED', false);
     }
     if (!defined('WBB3ADDONSBOX01_VALUE')) {
         define('WBB3ADDONSBOX01_VALUE', '');
     }
     if (!defined('WBB3ADDONSBOX01_PHP')) {
         define('WBB3ADDONSBOX01_PHP', false);
     }
     if (WBB3ADDONSBOX01_BOXOPENED == true) {
         $this->BoxData['Status'] = 1;
     }
     // php?! *******************************************
     if (WBB3ADDONSBOX01_PHP) {
         ob_start();
         eval(WBB3ADDONSBOX01_VALUE);
         $val = ob_get_clean();
     } else {
         $val = WBB3ADDONSBOX01_VALUE;
     }
     WCF::getTPL()->assign(array('wbb3addonsBox01Title' => WBB3ADDONSBOX01_TITLE, 'wbb3addonsBox01Value' => $val, 'wbb3addonsBox01Opened' => WBB3ADDONSBOX01_BOXOPENED));
 }
Exemplo n.º 8
0
 /**
  * @see Cronjob::execute()
  */
 public function execute($data)
 {
     $sql = "DELETE FROM wcf" . WCF_N . "_user_guestbook" . "\n WHERE userID NOT IN (SELECT userID FROM wcf" . WCF_N . "_user)";
     WCF::getDB()->sendQuery($sql);
     $sql = "DELETE FROM wcf" . WCF_N . "_user_guestbook_header" . "\n WHERE userID NOT IN (SELECT userID FROM wcf" . WCF_N . "_user)";
     WCF::getDB()->sendQuery($sql);
 }
 /**
  * @see PostList::readPostIDs()
  */
 protected function readPostIDs()
 {
     $sql = "SELECT\t\tpostID, attachments, pollID\n\t\t\tFROM\t\twbb" . WBB_N . "_post post\n\t\t\t" . (!empty($this->sqlConditions) ? "WHERE " . $this->sqlConditions : "") . "\n\t\t\tORDER BY\t" . $this->sqlOrderBy;
     $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->offset);
     while ($row = WCF::getDB()->fetchArray($result)) {
         // post id
         if (!empty($this->postIDs)) {
             $this->postIDs .= ',';
         }
         $this->postIDs .= $row['postID'];
         // attachments
         if ($row['attachments'] != 0) {
             $this->attachmentPostIDArray[] = $row['postID'];
         }
         // polls
         if ($row['pollID'] != 0) {
             if ($this->pollIDs != '') {
                 $this->pollIDs .= ',';
             }
             $this->pollIDs .= $row['pollID'];
         }
     }
     $this->readAttachments();
     $this->readPolls();
 }
 protected function getTopOptionCategories($packageID)
 {
     // get all option categories and filter categories with low priority
     $sql = "SELECT\t\tcategoryName, categoryID \n\t\t\tFROM\t\twcf" . WCF_N . "_option_category option_category,\n\t\t\t\t\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tWHERE \t\toption_category.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . $packageID . "\n\t\t\tORDER BY\tpackage_dependency.priority";
     $result = WCF::getDB()->sendQuery($sql);
     $optionCategories = array();
     while ($row = WCF::getDB()->fetchArray($result)) {
         $optionCategories[$row['categoryName']] = $row['categoryID'];
     }
     $sql = "SELECT \t\tcategoryID, parentCategoryName, categoryName,\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT COUNT(*) FROM wcf" . WCF_N . "_option WHERE categoryName = category.categoryName AND packageID IN (\n\t\t\t\t\t\t\tSELECT dependency FROM wcf" . WCF_N . "_package_dependency WHERE packageID = " . $packageID . "\n\t\t\t\t\t\t)\n\t\t\t\t\t) AS count\n\t\t\tFROM\t\twcf" . WCF_N . "_option_category category\n\t\t\tWHERE\t\tcategoryID IN (" . implode(',', $optionCategories) . ")";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if (!isset($this->optionCategoryStructure[$row['parentCategoryName']])) {
             $this->optionCategoryStructure[$row['parentCategoryName']] = array();
         }
         $this->optionCategoryStructure[$row['parentCategoryName']][] = $row;
     }
     $topOptionCategories = array();
     foreach ($this->optionCategoryStructure[''] as $optionCategory) {
         $count = $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']);
         if ($count > 0) {
             $topOptionCategories[] = $optionCategory['categoryID'];
         }
     }
     return $topOptionCategories;
 }
 /**
  * Updates the data in our database table
  */
 public function update()
 {
     $updateSQL = '';
     if (!empty($this->serverID)) {
         if (!empty($updateSQL)) {
             $updateSQL .= ',';
         }
         $updateSQL .= '`serverID` = ' . $this->serverID;
     }
     if (!empty($updateSQL)) {
         $updateSQL .= ',';
     }
     $updateSQL .= '`authorID` = ' . $this->authorID;
     if (!empty($this->authorName)) {
         if (!empty($updateSQL)) {
             $updateSQL .= ',';
         }
         $updateSQL .= '`authorName` = \'' . escapeString($this->authorName) . '\'';
     }
     $updateSQL .= ',`message` = \'' . escapeString($this->message) . '\'';
     $updateSQL .= ",`timestamp` = " . $this->timestamp;
     $updateSQL .= ',`enableSmilies` = ' . ($this->enableSmilies ? '1' : '0');
     $updateSQL .= ',`enableHtml` = ' . ($this->enableHtml ? '1' : '0');
     $updateSQL .= ',`enableBBCodes` = ' . ($this->enableBBCodes ? '1' : '0');
     $updateSQL .= ",`isDisabled` = " . $this->isDisabled;
     $sql = "UPDATE bash" . BASH_N . "_server_comment\r\n\t\t\t\tSET\r\n\t\t\t\t\t" . $updateSQL . "\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tcommentID = " . $this->commentID;
     WCF::getDB()->sendQuery($sql);
 }
 /**
  * Renders the list of boards.
  */
 public function renderBoards()
 {
     // get unread threads
     $this->readUnreadThreads();
     // get boards
     $this->readBoards();
     // assign data
     WCF::getTPL()->assign('boards', $this->boards);
     WCF::getTPL()->assign('unreadThreadsCount', $this->unreadThreadsCount);
     // show newest posts
     if (BOARD_LIST_ENABLE_LAST_POST) {
         $lastPosts = WCF::getCache()->get('boardData', 'lastPosts');
         if (is_array($lastPosts)) {
             $visibleLanguages = false;
             if (count(WCF::getSession()->getVisibleLanguageIDArray())) {
                 $visibleLanguages = WCF::getSession()->getVisibleLanguageIDArray();
             }
             foreach ($lastPosts as $boardID => $languages) {
                 foreach ($languages as $languageID => $row) {
                     if (!$languageID || !$visibleLanguages || in_array($languageID, $visibleLanguages)) {
                         $this->lastPosts[$row['boardID']] = new DatabaseObject($row);
                         continue 2;
                     }
                 }
             }
         }
         WCF::getTPL()->assign('lastPosts', $this->lastPosts);
     }
     // stats
     if (BOARD_LIST_ENABLE_STATS) {
         WCF::getTPL()->assign('boardStats', WCF::getCache()->get('boardData', 'counts'));
     }
 }
 /**
  * @see Page::show()
  */
 public function show()
 {
     // check permission
     WCF::getUser()->checkPermission('user.guestbook.canViewList');
     HeaderMenu::setActiveMenuItem('wcf.header.menu.userGuestbook');
     parent::show();
 }
    /**
     * @see	EventListener::execute()
     */
    public function execute($eventObj, $className, $eventName)
    {
        WCF::getTPL()->append('additionalCSS', '
			<link rel="stylesheet" type="text/css" href="' . RELATIVE_WCF_DIR . 'style/containers.css" />
			<link rel="stylesheet" type="text/css" href="' . RELATIVE_WCF_DIR . 'style/forms.css" />
		');
    }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // count board
     $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_board";
     $row = WCF::getDB()->getFirstRow($sql);
     $count = $row['count'];
     // get board ids
     $boardIDs = '';
     $sql = "SELECT\t\tboardID\n\t\t\tFROM\t\twbb" . WBB_N . "_board\n\t\t\tORDER BY\tboardID";
     $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $boardIDs .= ',' . $row['boardID'];
         // update last post
         $board = new BoardEditor($row['boardID']);
         $board->setLastPosts();
     }
     if (empty($boardIDs)) {
         // clear board cache
         WCF::getCache()->clear(WBB_DIR . 'cache', 'cache.boardData.php');
         $this->calcProgress();
         $this->finish();
     }
     // update boards
     $sql = "UPDATE\twbb" . WBB_N . "_board board\n\t\t\tSET\tthreads = (\n\t\t\t\t\tSELECT\tCOUNT(*)\n\t\t\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\t\t\tWHERE\tboardID = board.boardID\n\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\t),\n\t\t\t\tposts = (\n\t\t\t\t\tSELECT\tIFNULL(SUM(replies), 0) + COUNT(*)\n\t\t\t\t\tFROM\twbb" . WBB_N . "_thread thread\n\t\t\t\t\tWHERE\tboardID = board.boardID\n\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\t)\n\t\t\tWHERE\tboard.boardID IN (0" . $boardIDs . ")";
     WCF::getDB()->sendQuery($sql);
     $this->executed();
     $this->calcProgress($this->limit * $this->loop, $count);
     $this->nextLoop();
 }
 protected function icsHolidayExporter($location)
 {
     $ret = '';
     $page = 'IcsHolidayExporter';
     $ret = '<a href="index.php?form=' . $page . '">' . WCF::getLanguage()->get($location['locationName']) . '</a>';
     return $ret;
 }
 /**
  * @see AbstractAction::execute()
  */
 public function execute()
 {
     parent::execute();
     $subscriber = new NewsletterSubscriber($this->subscriberID);
     //deletes user subscribers
     $sql = 'DELETE FROM wcf' . WCF_N . '_' . $this->activationTable . '
     		WHERE userID = ' . intval($subscriber->userID);
     WCF::getDB()->sendQuery($sql);
     //resets user setting
     $user = new UserEditor($subscriber->userID);
     $options = array('acceptNewsletter' => 0);
     $user->updateOptions($options);
     //deletes guest subscribers
     $sql = 'DELETE FROM wcf' . WCF_N . '_' . $this->guestActivationTable . '
     		WHERE subscriberID = ' . $this->subscriberID;
     WCF::getDB()->sendQuery($sql);
     //deletes unsubscribe tokens
     $sql = 'DELETE FROM wcf' . WCF_N . '_' . $this->unsubscriptionTable . '
             WHERE subscriberID = ' . $this->subscriberID;
     WCF::getDB()->sendQuery($sql);
     $sql = 'DELETE FROM wcf' . WCF_N . '_' . $this->subscriberTable . '
     		WHERE subscriberID = ' . $this->subscriberID;
     WCF::getDB()->sendQuery($sql);
     $this->executed();
     //clear cache
     $cacheName = 'newsletter-subscriber-' . PACKAGE_ID;
     WCF::getCache()->clear(WCF_DIR . 'cache/', 'cache.' . $cacheName . '.php');
     HeaderUtil::redirect('index.php?page=NewsletterSubscriberList&result=success&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
	/**
	 * @see EventListener::execute()
	 */
	public function execute($eventObj, $className, $eventName) {
		if (!WCF::getUser()->getPermission('user.ucstomUserPages.canViewPages'))
			return;
		
		switch ($className) {
			case 'UserProfileMenu':
				$items = UserCustomPage::getMenuItemsByUserID($eventObj->userID);
		
				foreach ($items as $name => $menuItem) {
					UserProfileMenu::getInstance()->menuItems[''][] = array(
						'menuItem' => $menuItem,
						'parentMenuItem' => '',
						'menuItemLink' => 'index.php?page=UserCustomPage&userID='.$eventObj->userID.'&pageName='.$name.SID_ARG_2ND_NOT_ENCODED,
						'menuItemIcon' => 'messageM.png',
						'permissions' => 'user.customUserPages.canViewPages'
					);
				}
				
				break;
			
			case 'UserProfileFrame':
				if (WCF::getUser()->userID == $eventObj->userID && $eventObj->getUser()->getPermission('user.customUserPages.canUse'))
					WCF::getTPL()->append('additionalUserCardOptions',
						WCF::getTPL()->display('customUserPagesUserCardOption')
					);
				
				break;
		}
	}
 /**
  * @see	Page::readData()
  */
 public function readData()
 {
     parent::readData();
     // create chart object
     $this->data = new OpenFlashChart(WCF::getLanguage()->get('cms.acp.statistics.chart.page.title'));
     // create element
     $element = new OpenFlashChartElement($this->type);
     // set special options
     $element->tip = WCF::getLanguage()->get('cms.acp.statistics.chart.page.tip');
     // read data from db
     $sql = "SELECT\n\t\t\t\t\tstats.requestCount AS requestCount,\n\t\t\t\t\tpage.title AS title\n\t\t\t\tFROM\n\t\t\t\t\tcms" . CMS_N . "_statistic_page stats\n\t\t\t\tLEFT JOIN\n\t\t\t\t\twcf" . WCF_N . "_page page\n\t\t\t\tON\n\t\t\t\t\tstats.pageID = page.pageID";
     $result = WCF::getDB()->sendQuery($sql);
     $items = array();
     // get available colours
     $colours = array();
     while ($row = WCF::getDB()->fetchArray($result)) {
         $colours[] = "#" . substr(sha1($row['title']), 0, 6);
         $items[] = $row;
     }
     // add colours to element
     $element->colours = $colours;
     // load data
     foreach ($items as $row) {
         switch ($this->type) {
             case 'pie':
                 $element->addValue(intval($row['requestCount']), $row['title']);
                 break;
         }
     }
     // add element to chart
     $this->data->addElement($element);
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if ($eventName == 'readFormParameters') {
         if (isset($_POST['showOnTeamOnlineBox'])) {
             $this->showOnTeamOnlineBox = intval($_POST['showOnTeamOnlineBox']);
         }
         if (isset($_POST['teamOnlineMarking'])) {
             $this->teamOnlineMarking = $_POST['teamOnlineMarking'];
         }
     } else {
         if ($eventName == 'save') {
             $eventObj->additionalFields['showOnTeamOnlineBox'] = $this->showOnTeamOnlineBox;
             $eventObj->additionalFields['teamOnlineMarking'] = $this->teamOnlineMarking;
             if (!$eventObj instanceof GroupEditForm) {
                 $this->showOnTeamOnlineBox = 0;
                 $this->teamOnlineMarking = '%s';
             }
         } else {
             if ($eventName == 'assignVariables') {
                 if (!count($_POST) && $eventObj instanceof GroupEditForm) {
                     $this->showOnTeamOnlineBox = $eventObj->group->showOnTeamOnlineBox;
                     $this->teamOnlineMarking = $eventObj->group->teamOnlineMarking;
                 }
                 WCF::getTPL()->assign(array('showOnTeamOnlineBox' => $this->showOnTeamOnlineBox, 'teamOnlineMarking' => $this->teamOnlineMarking));
                 WCF::getTPL()->append('additionalFields', WCF::getTPL()->fetch('groupTeamOnlineBox'));
             }
         }
     }
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     $this->board->markAsRead();
     WCF::getSession()->unregister('lastSubscriptionsStatusUpdateTime');
     $this->executed();
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // count posts
     $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_post";
     $row = WCF::getDB()->getFirstRow($sql);
     $count = $row['count'];
     // get postids
     $postIDs = '';
     $sql = "SELECT\t\tpostID\n\t\t\tFROM\t\twbb" . WBB_N . "_post\n\t\t\tORDER BY\tpostID";
     $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $postIDs .= ',' . $row['postID'];
     }
     if (empty($postIDs)) {
         $this->calcProgress();
         $this->finish();
     }
     // update posts
     $sql = "UPDATE\twbb" . WBB_N . "_post post\n\t\t\tSET\tattachments = IFNULL((\n\t\t\t\t\tSELECT\tCOUNT(*)\n\t\t\t\t\tFROM\twcf" . WCF_N . "_attachment attachment\n\t\t\t\t\tWHERE\tattachment.packageID = " . PACKAGE_ID . "\n\t\t\t\t\t\tAND attachment.containerID = post.postID\n\t\t\t\t\t\tAND attachment.containerType = 'post'\n\t\t\t\t), 0)\n\t\t\tWHERE\tpost.postID IN (0" . $postIDs . ")";
     WCF::getDB()->sendQuery($sql);
     $this->executed();
     $this->calcProgress($this->limit * $this->loop, $count);
     $this->nextLoop();
 }
 /**
  * @see Taggable::getObjectsByTagID()
  */
 public function getObjectsByTagID($tagID, $limit = 0, $offset = 0)
 {
     $accessibleBoardIDArray = Board::getAccessibleBoardIDArray();
     if (count($accessibleBoardIDArray) == 0) {
         return array();
     }
     $sqlThreadVisitSelect = $sqlThreadVisitJoin = $sqlSubscriptionSelect = $sqlSubscriptionJoin = $sqlOwnPostsSelect = $sqlOwnPostsJoin = '';
     if (WCF::getUser()->userID != 0) {
         $sqlThreadVisitSelect = ', thread_visit.lastVisitTime';
         $sqlThreadVisitJoin = " LEFT JOIN \twbb" . WBB_N . "_thread_visit thread_visit \n\t\t\t\t\t\tON \t\t(thread_visit.threadID = thread.threadID\n\t\t\t\t\t\t\t\tAND thread_visit.userID = " . WCF::getUser()->userID . ")";
         $sqlSubscriptionSelect = ', IF(thread_subscription.userID IS NOT NULL, 1, 0) AS subscribed';
         $sqlSubscriptionJoin = " LEFT JOIN \twbb" . WBB_N . "_thread_subscription thread_subscription \n\t\t\t\t\t\tON \t\t(thread_subscription.userID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\t\t\tAND thread_subscription.threadID = thread.threadID)";
         if (BOARD_THREADS_ENABLE_OWN_POSTS) {
             $sqlOwnPostsSelect = "DISTINCT post.userID AS ownPosts,";
             $sqlOwnPostsJoin = "\tLEFT JOIN\twbb" . WBB_N . "_post post\n\t\t\t\t\t\t\tON \t\t(post.threadID = thread.threadID\n\t\t\t\t\t\t\t\t\tAND post.userID = " . WCF::getUser()->userID . ")";
         }
     }
     $threads = array();
     $sql = "SELECT\t\t" . $sqlOwnPostsSelect . "\n\t\t\t\t\tthread.*,\n\t\t\t\t\tboard.boardID, board.title\n\t\t\t\t\t" . $sqlThreadVisitSelect . "\n\t\t\t\t\t" . $sqlSubscriptionSelect . "\n\t\t\tFROM\t\twcf" . WCF_N . "_tag_to_object tag_to_object\n\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\tON\t\t(thread.threadID = tag_to_object.objectID)\n\t\t\tLEFT JOIN \twbb" . WBB_N . "_board board\n\t\t\tON \t\t(board.boardID = thread.boardID)\n\t\t\t" . $sqlOwnPostsJoin . "\n\t\t\t" . $sqlThreadVisitJoin . "\n\t\t\t" . $sqlSubscriptionJoin . "\n\t\t\tWHERE\t\ttag_to_object.tagID = " . $tagID . "\n\t\t\t\t\tAND tag_to_object.taggableID = " . $this->getTaggableID() . "\n\t\t\t\t\tAND thread.boardID IN (" . implode(',', $accessibleBoardIDArray) . ")\n\t\t\t\t\tAND thread.isDeleted = 0\n\t\t\t\t\tAND thread.isDisabled = 0\n\t\t\tORDER BY\tthread.lastPostTime DESC";
     $result = WCF::getDB()->sendQuery($sql, $limit, $offset);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $row['taggable'] = $this;
         $threads[] = new TaggedThread(null, $row);
     }
     return $threads;
 }
 /**
  * @see AbstractLostAndFoundFileSystemItem::createVirtualIDSpace()
  */
 public static function createVirtualIDSpace()
 {
     $attachments = array();
     chdir(WCF_DIR . 'attachments');
     $dh = opendir(WCF_DIR . 'attachments');
     $attachmentIDs = array();
     while ($file = readdir($dh)) {
         if (preg_match("/^(attachment|thumbnail).*/", $file) && $file != '.' && $file != '..' && $file != '.htaccess' && !preg_match("/^.*\\.php\$/", $file)) {
             $attachmentID = (int) preg_replace("/.*\\-(\\d+)\$/", "\$1", $file);
             if ($attachmentID > 0) {
                 $attachmentIDs[] = $attachmentID;
             }
         }
     }
     if (count($attachmentIDs)) {
         $sql = "SELECT attachmentID FROM wcf" . WCF_N . "_attachment WHERE attachmentID IN (" . implode(',', $attachmentIDs) . ")";
         $result = WCF::getDB()->sendQuery($sql);
         $physicalAttachments = array_flip($attachmentIDs);
         while ($row = WCF::getDB()->fetchArray($result)) {
             unset($physicalAttachments[$row['attachmentID']]);
         }
         $physicalAttachments = array_keys($physicalAttachments);
         foreach ($physicalAttachments as $attachmentID) {
             $file = WCF_DIR . 'attachments/attachment-' . $attachmentID;
             $attachments[] = $file;
         }
     }
     closedir($dh);
     self::$virtualFileIDs['attachmentsFilesystem'] = $attachments;
     WCF::getSession()->register('virtualLostAndFoundIDs', self::$virtualFileIDs);
 }
 /**
  * @see MultipleLinkPage::countItems()
  */
 public function countItems()
 {
     parent::countItems();
     $sql = "SELECT\t\tCOUNT(*) AS count\n\t\t\tFROM \t\twcf" . WCF_N . "_user\n\t\t\tWHERE\t\tuserID IN (\n\t\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\tWHERE\tgroupID = " . $this->groupID . "\n\t\t\t\t\t)";
     $result = WCF::getDB()->getFirstRow($sql);
     return $result['count'];
 }
 /**
  * Creates a new ModerationMarkedThreadsPage object.
  */
 public function __construct()
 {
     if ($markedThreads = WCF::getSession()->getVar('markedThreads')) {
         $this->sqlConditions = 'thread.threadID IN (' . implode(',', $markedThreads) . ') AND movedThreadID = 0';
     }
     parent::__construct();
 }
 /**
  * {@inheritdoc}
  */
 public function readObjects()
 {
     //get classes
     $baseClass = $this->className;
     $classParts = explode('\\', get_called_class());
     $articleType = explode('.', $baseClass::$objectType);
     parent::readObjects();
     if ($this->categoryList) {
         if (0 !== count($this->objectIDs)) {
             $conditionBuilder = new PreparedStatementConditionBuilder();
             $conditionBuilder->add($this->getDatabaseTableIndexName() . ' IN (?)', array($this->objectIDs));
             $sql = '
                 SELECT *
                 FROM ' . $classParts[0] . WCF_N . '_' . $articleType . '_to_category
                 ' . $conditionBuilder;
             $statement = WCF::getDB()->prepareStatement($sql);
             $statement->execute($conditionBuilder->getParameters());
             while ($row = $statement->fetchArray()) {
                 if (isset($this->objects[$row[$this->getDatabaseTableIndexName()]])) {
                     $this->objects[$row[$this->getDatabaseTableIndexName()]]->setCategoryID($row['categoryID']);
                 }
             }
         }
     }
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     WCF::getUser()->checkPermission('admin.user.canDeleteUser');
     require_once WCF_DIR . 'lib/data/user/UserEditor.class.php';
     require_once WCF_DIR . 'lib/data/user/group/Group.class.php';
     if ($this->userID !== 0) {
         $this->userIDs[] = $this->userID;
     }
     // active user can't delete himself
     $activeUserID = WCF::getSession()->getUser()->userID;
     $this->userIDs = array_diff($this->userIDs, array($activeUserID));
     // check permission
     if (count($this->userIDs) > 0) {
         $sql = "SELECT\tDISTINCT groupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             if (!Group::isAccessibleGroup($row['groupID'])) {
                 throw new PermissionDeniedException();
             }
         }
     }
     $deletedUsers = UserEditor::deleteUsers($this->userIDs);
     $this->executed();
     if (!empty($this->url) && (strpos($this->url, 'searchID=0') !== false || strpos($this->url, 'searchID=') === false)) {
         HeaderUtil::redirect($this->url);
     } else {
         HeaderUtil::redirect('index.php?form=UserSearch&deletedUsers=' . $deletedUsers . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
     }
     exit;
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if ($eventName == 'readFormParameters') {
         if (isset($_POST['usedQuotes']) && is_array($_POST['usedQuotes'])) {
             $this->usedQuotes = $_POST['usedQuotes'];
         }
     } else {
         if ($eventName == 'saved') {
             if (count($this->usedQuotes) > 0) {
                 require_once WCF_DIR . 'lib/data/message/multiQuote/MultiQuoteManager.class.php';
                 foreach ($this->usedQuotes as $quoteID) {
                     MultiQuoteManager::removeQuote($quoteID);
                 }
                 MultiQuoteManager::saveStorage();
             }
         } else {
             if ($eventName == 'assignVariables') {
                 require_once WCF_DIR . 'lib/data/message/multiQuote/MultiQuoteManager.class.php';
                 $quotes = MultiQuoteManager::getStorage();
                 $usedQuotes = array_flip($this->usedQuotes);
                 foreach ($quotes as $quoteID => $quote) {
                     $quote['used'] = isset($usedQuotes[$quoteID]) ? 1 : 0;
                     $quotes[$quoteID] = $quote;
                 }
                 WCF::getTPL()->assign('quotes', $quotes);
                 WCF::getTPL()->append(array('additionalTabs' => '<li id="multiQuoteTab"><a onclick="tabbedPane.openTab(\'multiQuote\');"><span>' . WCF::getLanguage()->get('wcf.multiQuote.title') . '</span></a></li>', 'additionalSubTabs' => WCF::getTPL()->fetch('messageFormMultiQuote')));
             }
         }
     }
 }
Exemplo n.º 30
0
 /**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     $sql = "SELECT *\r\n\t\t\t\tFROM ugml_stat_type\r\n\t\t\t\tGROUP BY ugml_stat_type.statTypeID";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $sql = "SELECT DISTINCT `time`\r\n\t\t\t\t\tFROM ugml_stat_entry_archive\r\n\t\t\t\t\tWHERE statTypeID = " . $row['statTypeID'];
         $result2 = WCF::getDB()->sendQuery($sql);
         while ($row2 = WCF::getDB()->fetchArray($result2)) {
             $row['times'][] = $row2['time'];
         }
         // range
         $sql = "SELECT MAX(rank)\r\n\t\t\t\t\t\tAS max\r\n\t\t\t\t\tFROM ugml_stat_entry\r\n\t\t\t\t\tWHERE statTypeID = " . $row['statTypeID'];
         $row += WCF::getDB()->getFirstRow($sql);
         $this->data[$row['statTypeID']] = $row;
     }
     $this->data = array('byStatTypeID' => $this->data, 'byTypeName' => array());
     foreach ($this->data['byStatTypeID'] as $statTypeID => $row) {
         $name = StringUtil::firstCharToUpperCase($row['type']) . StringUtil::firstCharToUpperCase($row['name']);
         $this->data['byTypeName'][$name] = $row;
     }
     // get the names and the types
     $sql = "SELECT GROUP_CONCAT(DISTINCT type)\r\n\t\t\t\t\t\t\tAS types,\r\n\t\t\t\t\t\tGROUP_CONCAT(DISTINCT name)\r\n\t\t\t\t\t\t\tAS names\r\n\t\t\t\tFROM ugml_stat_type\r\n\t\t\t\tGROUP BY NULL";
     $row = WCF::getDB()->getFirstRow($sql);
     $this->data['types'] = explode(',', $row['types']);
     $this->data['names'] = explode(',', $row['names']);
     return $this->data;
 }