/** * @see \wcf\form\IForm::validate() */ public function validate() { AbstractForm::validate(); if (empty($this->masterPassword)) { throw new UserInputException('masterPassword'); } // check password security if (mb_strlen($this->masterPassword) < 12) { throw new UserInputException('masterPassword', 'notSecure'); } // digits if (!Regex::compile('\\d')->match($this->masterPassword)) { throw new UserInputException('masterPassword', 'notSecure'); } // latin characters (lower-case) if (!Regex::compile('[a-z]')->match($this->masterPassword)) { throw new UserInputException('masterPassword', 'notSecure'); } // latin characters (upper-case) if (!Regex::compile('[A-Z]')->match($this->masterPassword)) { throw new UserInputException('masterPassword', 'notSecure'); } // password equals username if ($this->masterPassword == WCF::getUser()->username) { throw new UserInputException('masterPassword', 'notSecure'); } // confirm master password if (empty($this->confirmMasterPassword)) { throw new UserInputException('confirmMasterPassword'); } if ($this->confirmMasterPassword != $this->masterPassword) { throw new UserInputException('confirmMasterPassword', 'notEqual'); } }
/** * Creates a new ViewableUserActivityEventList object. */ public function __construct() { parent::__construct(); if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) { $this->getConditionBuilder()->add('(user_activity_event.languageID IN (?) OR user_activity_event.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs())); } }
/** * Adds a new user activity point event. * * @param string $objectType * @param integer $objectID * @param integer $userID * @param array<mixed> $additionalData */ public function fireEvent($objectType, $objectID, $userID = null, array $additionalData = array()) { $objectTypeObj = $this->getObjectTypeByName($objectType); if ($objectTypeObj === null) { throw new SystemException("Object type '" . $objectType . "' is not valid for object type definition 'com.woltlab.wcf.user.activityPointEvent'"); } if ($userID === null) { $userID = WCF::getUser()->userID; } if (!$userID) { throw new SystemException("Cannot fire user activity point events for guests"); } // update user_activity_point $sql = "INSERT INTO\t\twcf" . WCF_N . "_user_activity_point\n\t\t\t\t\t\t(userID, objectTypeID, activityPoints, items)\n\t\t\tVALUES\t\t\t(?, ?, ?, 1)\n\t\t\tON DUPLICATE KEY\n\t\t\tUPDATE\t\t\tactivityPoints = activityPoints + VALUES(activityPoints),\n\t\t\t\t\t\titems = items + 1"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($userID, $objectTypeObj->objectTypeID, $objectTypeObj->points)); $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tactivityPoints = activityPoints + ?\n\t\t\tWHERE\tuserID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($objectTypeObj->points, $userID)); // update user ranks $this->updateUserRanks(array($userID)); // check if the user will be automatically added to new user groups // because of the new activity points UserGroupAssignmentHandler::getInstance()->checkUsers(array($userID)); }
/** * @see \wcf\system\dashboard\box\IDashboardBox::init() */ public function init(DashboardBox $box, IPage $page) { parent::init($box, $page); if (WCF::getUser()->userID && MODULE_PAID_SUBSCRIPTION) { // get available subscriptions $this->subscriptions = PaidSubscriptionCacheBuilder::getInstance()->getData(); // get purchased subscriptions $userSubscriptionList = new PaidSubscriptionUserList(); $userSubscriptionList->getConditionBuilder()->add('userID = ?', array(WCF::getUser()->userID)); $userSubscriptionList->getConditionBuilder()->add('isActive = ?', array(1)); $userSubscriptionList->readObjects(); // remove purchased subscriptions foreach ($userSubscriptionList as $userSubscription) { if (isset($this->subscriptions[$userSubscription->subscriptionID])) { $userSubscription->setSubscription($this->subscriptions[$userSubscription->subscriptionID]); unset($this->subscriptions[$userSubscription->subscriptionID]); } } // remove excluded subscriptions foreach ($userSubscriptionList as $userSubscription) { if ($userSubscription->getSubscription()->excludedSubscriptionIDs) { foreach (explode(',', $userSubscription->getSubscription()->excludedSubscriptionIDs) as $subscriptionID) { if (isset($this->subscriptions[$subscriptionID])) { unset($this->subscriptions[$subscriptionID]); } } } } } $this->fetched(); }
/** * @see \wcf\system\event\listener\IParameterizedEventListener::execute() */ public function execute($eventObj, $className, $eventName, array &$parameters) { if (WCF::getUser()->userID && WCF::getSession()->getPermission('admin.general.canUseAcp') && !defined(get_class($eventObj) . '::DO_NOT_LOG')) { // try to find existing session log $sql = "SELECT\tsessionLogID\n\t\t\t\tFROM\twcf" . WCF_N . "_acp_session_log\n\t\t\t\tWHERE\tsessionID = ?\n\t\t\t\t\tAND lastActivityTime >= ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(WCF::getSession()->sessionID, TIME_NOW - SESSION_TIMEOUT)); $row = $statement->fetchArray(); if (!empty($row['sessionLogID'])) { $sessionLogID = $row['sessionLogID']; $sessionLogEditor = new ACPSessionLogEditor(new ACPSessionLog(null, array('sessionLogID' => $sessionLogID))); $sessionLogEditor->update(array('lastActivityTime' => TIME_NOW)); } else { // create new session log $sessionLog = ACPSessionLogEditor::create(array('sessionID' => WCF::getSession()->sessionID, 'userID' => WCF::getUser()->userID, 'ipAddress' => UserUtil::getIpAddress(), 'hostname' => @gethostbyaddr(WCF::getSession()->ipAddress), 'userAgent' => WCF::getSession()->userAgent, 'time' => TIME_NOW, 'lastActivityTime' => TIME_NOW)); $sessionLogID = $sessionLog->sessionLogID; } // format request uri $requestURI = WCF::getSession()->requestURI; // remove directories $URIComponents = explode('/', $requestURI); $requestURI = array_pop($URIComponents); // remove session url $requestURI = preg_replace('/(?:\\?|&)s=[a-f0-9]{40}/', '', $requestURI); // save access ACPSessionAccessLogEditor::create(array('sessionLogID' => $sessionLogID, 'ipAddress' => UserUtil::getIpAddress(), 'time' => TIME_NOW, 'requestURI' => $requestURI, 'requestMethod' => WCF::getSession()->requestMethod, 'className' => get_class($eventObj))); } }
/** * @see \wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (!WCF::getUser()->userID && isset($_POST['accept'])) { $this->accept = true; } }
/** * Returns the number of conversations for given user. * * @param integer $userID * @return integer */ public function getConversationCount($userID = null) { if ($userID === null) { $userID = WCF::getUser()->userID; } if (!isset($this->conversationCount[$userID])) { $this->conversationCount[$userID] = 0; // load storage data UserStorageHandler::getInstance()->loadStorage(array($userID)); // get ids $data = UserStorageHandler::getInstance()->getStorage(array($userID), 'conversationCount'); // cache does not exist or is outdated if ($data[$userID] === null) { $conditionBuilder1 = new PreparedStatementConditionBuilder(); $conditionBuilder1->add('conversation_to_user.participantID = ?', array($userID)); $conditionBuilder1->add('conversation_to_user.hideConversation IN (0,1)'); $conditionBuilder2 = new PreparedStatementConditionBuilder(); $conditionBuilder2->add('conversation.userID = ?', array($userID)); $conditionBuilder2->add('conversation.isDraft = 1'); $sql = "SELECT (SELECT\tCOUNT(*)\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_conversation_to_user conversation_to_user\n\t\t\t\t\t\t" . $conditionBuilder1->__toString() . ")\n\t\t\t\t\t\t+\n\t\t\t\t\t\t(SELECT\tCOUNT(*)\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_conversation conversation\n\t\t\t\t\t\t" . $conditionBuilder2->__toString() . ") AS count"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array_merge($conditionBuilder1->getParameters(), $conditionBuilder2->getParameters())); $row = $statement->fetchArray(); $this->conversationCount[$userID] = $row['count']; // update storage data UserStorageHandler::getInstance()->update($userID, 'conversationCount', serialize($this->conversationCount[$userID])); } else { $this->conversationCount[$userID] = unserialize($data[$userID]); } } return $this->conversationCount[$userID]; }
public function __construct() { parent::__construct(); // accessible news categories $accessibleCategoryIDs = NewsCategory::getAccessibleCategoryIDs(); if (!empty($accessibleCategoryIDs)) { $this->getConditionBuilder()->add('news.newsID IN (SELECT newsID FROM cms' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array($accessibleCategoryIDs)); } else { $this->getConditionBuilder()->add('1=0'); } //get default settings if (!WCF::getSession()->getPermission('mod.cms.news.canModerateNews')) { $this->getConditionBuilder()->add('news.isDisabled = 0'); } if (!WCF::getSession()->getPermission('mod.cms.news.canModerateNews')) { $this->getConditionBuilder()->add('news.isDeleted = 0'); } //can view delayed news if (!WCF::getSession()->getPermission('user.cms.news.canViewDelayedNews')) { $this->getConditionBuilder()->add('news.isDisabled = ?', array(0)); } // language Filter if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) { $this->getConditionBuilder()->add('(news.languageID IN (?) OR news.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs())); } }
/** * Does the user authentication. */ protected function initAuth() { // this is a work-around since neither RequestHandler // nor RouteHandler are populated right now $pathInfo = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : ''; if (empty($pathInfo) || !preg_match('~^/(ACPCaptcha|Login|Logout)/~', $pathInfo)) { if (WCF::getUser()->userID == 0) { // build redirect path $application = ApplicationHandler::getInstance()->getActiveApplication(); $path = $application->getPageURL() . 'acp/index.php/Login/' . SID_ARG_1ST; HeaderUtil::redirect($path); exit; } else { // work-around for AJAX-requests within ACP if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { try { WCF::getSession()->checkPermissions(array('admin.general.canUseAcp')); } catch (PermissionDeniedException $e) { throw new AJAXException(self::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS, $e->getTraceAsString()); } } else { WCF::getSession()->checkPermissions(array('admin.general.canUseAcp')); } } } }
/** * Creates a new UnreadNewsList object. */ public function __construct() { parent::__construct(); $this->getConditionBuilder()->add("news.time > ?", array(VisitTracker::getInstance()->getVisitTime('de.voolia.news.entry'))); $this->getConditionBuilder()->add("tracked_visit.visitTime IS NULL"); $this->sqlConditionJoins = "LEFT JOIN wcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.voolia.news.entry') . " AND tracked_visit.objectID = news.newsID AND tracked_visit.userID = " . WCF::getUser()->userID . ")"; }
/** * Handles uploaded files. */ public function upload() { // save files $files = $this->parameters['__files']->getFiles(); $file = $files[0]; try { if (!$file->getValidationErrorType()) { $data = array('userID' => WCF::getUser()->userID ?: null, 'filename' => $file->getFilename(), 'fileType' => $file->getMimeType(), 'fileHash' => sha1_file($file->getLocation()), 'filesize' => $file->getFilesize(), 'uploadTime' => TIME_NOW); // save file $upload = FileUploadEditor::create($data); // move uploaded file if (@copy($file->getLocation(), $upload->getLocation())) { @unlink($file->getLocation()); // return result return array('uploadID' => $upload->uploadID, 'filename' => $upload->filename, 'filesize' => $upload->filesize, 'formattedFilesize' => FileUtil::formatFilesize($upload->filesize)); } else { // moving failed; delete file $editor = new FileUploadEditor($upload); $editor->delete(); throw new UserInputException('fileUpload', 'uploadFailed'); } } } catch (UserInputException $e) { $file->setValidationErrorType($e->getType()); } return array('errorType' => $file->getValidationErrorType()); }
/** * @see \wcf\page\AbstractPage::readData() */ public function readData() { parent::readData(); // get available subscriptions $this->subscriptions = PaidSubscriptionCacheBuilder::getInstance()->getData(); // get user subscriptions $this->userSubscriptionList = new PaidSubscriptionUserList(); $this->userSubscriptionList->getConditionBuilder()->add('userID = ?', array(WCF::getUser()->userID)); $this->userSubscriptionList->getConditionBuilder()->add('isActive = ?', array(1)); $this->userSubscriptionList->readObjects(); foreach ($this->userSubscriptionList as $userSubscription) { if (isset($this->subscriptions[$userSubscription->subscriptionID])) { $userSubscription->setSubscription($this->subscriptions[$userSubscription->subscriptionID]); unset($this->subscriptions[$userSubscription->subscriptionID]); } } foreach ($this->userSubscriptionList as $userSubscription) { if ($userSubscription->getSubscription()->excludedSubscriptionIDs) { foreach (explode(',', $userSubscription->getSubscription()->excludedSubscriptionIDs) as $subscriptionID) { if (isset($this->subscriptions[$subscriptionID])) { unset($this->subscriptions[$subscriptionID]); } } } } }
/** * Creates the AccessibleNewsList object. */ public function __construct() { parent::__construct(); // accessible news categories $accessibleCategoryIDs = NewsCategory::getAccessibleCategoryIDs(); if (!empty($accessibleCategoryIDs)) { $this->getConditionBuilder()->add('news.newsID IN (SELECT newsID FROM news' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array($accessibleCategoryIDs)); } else { $this->getConditionBuilder()->add('1=0'); } // default conditions if (!WCF::getSession()->getPermission('mod.news.canReadDeactivatedNews')) { $this->getConditionBuilder()->add('news.isActive = 1'); } if (!WCF::getSession()->getPermission('mod.news.canReadDeletedNews')) { $this->getConditionBuilder()->add('news.isDeleted = 0'); } if (!WCF::getSession()->getPermission('mod.news.canReadFutureNews')) { if (WCF::getUser()->userID) { $this->getConditionBuilder()->add('(news.isPublished = 1 OR news.userID = ?)', array(WCF::getUser()->userID)); } else { $this->getConditionBuilder()->add('news.isPublished = 1'); } } // apply language filter if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) { $this->getConditionBuilder()->add('(news.languageID IN (?) OR news.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs())); } }
/** * @see \wcf\system\event\listener\IParameterizedEventListener::execute() */ public function execute($eventObj, $className, $eventName, array &$parameters) { if (!MODULE_CONVERSATION || !MODULE_JCOINS || JCOINS_RECEIVECOINS_ADDCONVERSATIONREPLY == 0) { return; } if ($eventObj->getActionName() != 'create' && $eventObj->getActionName() != 'quickReply') { return; } // catch 3rdparty plugins, which creates Conversations without an logged in user if (WCF::getUser()->userID == 0) { return; } $parameters = $eventObj->getParameters(); if (isset($parameters['isFirstPost'])) { return; } if ($eventObj->getActionName() == 'create') { $return = $eventObj->getReturnValues(); $conversation = $return['returnValues']->getConversation(); $this->statementAction = new UserJcoinsStatementAction(array(), 'create', array('data' => array('reason' => 'wcf.jcoins.statement.conversationreplyadd.recive', 'sum' => JCOINS_RECEIVECOINS_ADDCONVERSATIONREPLY, 'additionalData' => array('title' => $conversation->subject), 'link' => $return['returnValues']->getLink()), 'changeBalance' => 1)); $this->statementAction->validateAction(); $this->statementAction->executeAction(); } else { $conversation = new \wcf\data\conversation\Conversation(isset($parameters['objectID']) ? intval($parameters['objectID']) : 0); $this->statementAction = new UserJcoinsStatementAction(array(), 'create', array('data' => array('reason' => 'wcf.jcoins.statement.conversationadd.recive', 'sum' => JCOINS_RECEIVECOINS_CREATECONVERSATION, 'additionalData' => array('title' => $conversation->subject), 'link' => \wcf\system\request\LinkHandler::getInstance()->getLink('Conversation', array('object' => $conversation))), 'changeBalance' => 1)); $this->statementAction->validateAction(); $this->statementAction->executeAction(); } }
/** * Validates the access-token and performs the login. */ protected function checkAccessToken() { if (isset($_REQUEST['at'])) { list($userID, $token) = explode('-', StringUtil::trim($_REQUEST['at'])); if (WCF::getUser()->userID) { if ($userID == WCF::getUser()->userID && PasswordUtil::secureCompare(WCF::getUser()->accessToken, $token)) { // everything is fine, but we are already logged in return; } else { // token is invalid throw new IllegalLinkException(); } } else { $user = new User($userID); if (PasswordUtil::secureCompare($user->accessToken, $token)) { // token is valid -> change user SessionHandler::getInstance()->changeUser($user, true); } else { // token is invalid throw new IllegalLinkException(); } } } }
public function save() { MessageForm::save(); if ($this->time != '') { $dateTime = \DateTime::createFromFormat("Y-m-d H:i", $this->time, WCF::getUser()->getTimeZone()); } $data = array('subject' => $this->subject, 'message' => $this->text, 'teaser' => $this->teaser, 'time' => $this->time != '' ? $dateTime->getTimestamp() : TIME_NOW, 'enableBBCodes' => $this->enableBBCodes, 'showSignature' => $this->showSignature, 'enableHtml' => $this->enableHtml, 'imageID' => $this->imageID ?: null, 'enableSmilies' => $this->enableSmilies, 'lastChangeTime' => TIME_NOW, 'isDisabled' => $this->time != '' && $dateTime->getTimestamp() > TIME_NOW ? 1 : 0, 'lastEditor' => WCF::getUser()->username, 'lastEditorID' => WCF::getUser()->userID); $newsData = array('data' => $data, 'categoryIDs' => $this->categoryIDs, 'tags' => $this->tags, 'attachmentHandler' => $this->attachmentHandler); $action = new NewsAction(array($this->newsID), 'update', $newsData); $resultValues = $action->executeAction(); $this->saved(); // re-define after saving $this->news = new News($this->newsID); if (WCF::getSession()->getPermission('user.cms.news.canStartPoll') && MODULE_POLL) { $pollID = PollManager::getInstance()->save($this->news->newsID); if ($pollID && $pollID != $this->news->pollID) { $editor = new NewsEditor($this->news); $editor->update(array('pollID' => $pollID)); } else { if (!$pollID && $this->news->pollID) { $editor = new NewsEditor($this->news); $editor->update(array('pollID' => null)); } } } HeaderUtil::redirect(LinkHandler::getInstance()->getLink('News', array('application' => 'cms', 'object' => $this->news))); exit; }
/** * Creates a new ViewableNewsList object. */ public function __construct() { parent::__construct(); // get author avatar if (!empty($this->sqlSelects)) { $this->sqlSelects .= ', '; } $this->sqlSelects .= "user_avatar.*, user_avatar.width as avatarWidth, user_avatar.height as avatarHeight, user_avatar.fileHash as avatarFileHash, user_table.*"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user user_table ON (user_table.userID = news.userID)"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)"; // get news picture $this->sqlSelects .= ", news_picture.categoryID, news_picture.fileHash, news_picture.fileExtension"; $this->sqlJoins .= " LEFT JOIN news" . WCF_N . "_news_picture news_picture ON (news.pictureID = news_picture.pictureID)"; // get the news like status $this->sqlSelects .= ", like_object.likes, like_object.dislikes"; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_like_object like_object ON (like_object.objectTypeID = " . LikeHandler::getInstance()->getObjectType('de.voolia.news.likeableNews')->objectTypeID . " AND like_object.objectID = news.newsID)"; if (WCF::getUser()->userID != 0) { // last news visit time if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } $this->sqlSelects .= 'tracked_visit.visitTime'; $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.voolia.news.entry') . " AND tracked_visit.objectID = news.newsID AND tracked_visit.userID = " . WCF::getUser()->userID . ")"; } }
/** * Loads the news entries. */ protected function loadNews() { $this->news = array(); if (empty($this->newsIDs)) { return; } $this->newsIDs = array_unique($this->newsIDs); $categoryIDs = NewsCategory::getAccessibleCategoryIDs(); if (empty($categoryIDs)) { return; } $newsList = new NewsList(); $newsList->getConditionBuilder()->add('news.newsID IN (?)', array($this->newsIDs)); $newsList->getConditionBuilder()->add('news.newsID IN (SELECT newsID FROM news' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array($categoryIDs)); // default conditions if (!WCF::getSession()->getPermission('mod.news.canReadDeactivatedNews')) { $newsList->getConditionBuilder()->add('news.isActive = 1'); } if (!WCF::getSession()->getPermission('mod.news.canReadDeletedNews')) { $newsList->getConditionBuilder()->add('news.isDeleted = 0'); } if (!WCF::getSession()->getPermission('mod.news.canReadFutureNews')) { if (WCF::getUser()->userID) { $newsList->getConditionBuilder()->add('(news.isPublished = 1 OR news.userID = ?)', array(WCF::getUser()->userID)); } else { $newsList->getConditionBuilder()->add('news.isPublished = 1'); } } $newsList->readObjects(); $this->news = $newsList->getObjects(); }
/** * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); if (WCF::getUser()->userID || WCF::getSession()->getVar('recaptchaDone')) { $this->useCaptcha = false; } }
/** * Returns the acl options for the given category and for the given user. * If no user is given, the active user is used. * * @param wcf\data\category\Category $category * @param wcf\data\user\User $user */ public function getPermissions(Category $category, User $user = null) { if ($user === null) { $user = WCF::getUser(); } $permissions = array(); if (isset($this->categoryPermissions[$category->categoryID])) { if (isset($this->categoryPermissions[$category->categoryID]['group'])) { foreach ($user->getGroupIDs() as $groupID) { if (isset($this->categoryPermissions[$category->categoryID]['group'][$groupID])) { foreach ($this->categoryPermissions[$category->categoryID]['group'][$groupID] as $optionName => $optionValue) { if (isset($permissions[$optionName])) { $permissions[$optionName] = $permissions[$optionName] || $optionValue; } else { $permissions[$optionName] = $optionValue; } } } } } if (isset($this->categoryPermissions[$category->categoryID]['user']) && isset($this->categoryPermissions[$category->categoryID]['user'][$user->userID])) { foreach ($this->categoryPermissions[$category->categoryID]['user'][$user->userID] as $optionName => $optionValue) { $permissions[$optionName] = $optionValue; } } } return $permissions; }
/** * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); if (WCF::getUser()->userID) { $this->username = WCF::getUser()->username; } }
/** * @see \wcf\system\condition\IContentCondition::showContent() */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) { return false; } return $this->checkUser($condition, WCF::getUser()); }
/** * Creates a new LoginForm object. */ public function __run() { if (WCF::getUser()->userID) { throw new PermissionDeniedException(); } parent::__run(); }
/** * @see \wcf\data\like\object\ILikeObject::sendNotification() */ public function sendNotification(Like $like) { if ($this->object->userID != WCF::getUser()->userID) { $notificationObject = new LikeUserNotificationObject($like); UserNotificationHandler::getInstance()->fireEvent('like', 'de.incendium.cms.like.likeableNews.notification', $notificationObject, array($this->object->userID), array('objectID' => $this->object->entryID)); } }
/** * Creates a new NewsCategoryList object. * * @param array<integer> $categoryIDs */ public function __construct(array $categoryIDs) { ViewableEntryList::__construct(); // accessible news categories if (!empty($categoryIDs)) { $this->getConditionBuilder()->add('news_entry_to_category.categoryID IN (?)', array($categoryIDs)); $this->getConditionBuilder()->add('news_entry.entryID = news_entry_to_category.entryID'); } else { $this->getConditionBuilder()->add('1=0'); } // default conditions if (!WCF::getSession()->getPermission('mod.news.canModerateEntry')) { $this->getConditionBuilder()->add('news_entry.isDisabled = 0'); } if (!WCF::getSession()->getPermission('mod.news.canViewDeletedEntry')) { $this->getConditionBuilder()->add('news_entry.isDeleted = 0'); } if (WCF::getUser()->userID) { $this->getConditionBuilder()->add('(news_entry.isPublished = 1 OR news_entry.userID = ?)', array(WCF::getUser()->userID)); } else { $this->getConditionBuilder()->add('news_entry.isPublished = 1'); } // apply language filter if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) { $this->getConditionBuilder()->add('(news_entry.languageID IN (?) OR news_entry.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs())); } }
/** * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink() */ public function getLink() { $owner = WCF::getUser(); if ($this->additionalData['objectID'] != WCF::getUser()->userID) { $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']); } return LinkHandler::getInstance()->getLink('User', array('object' => $owner), '#wall'); }
/** * Returns true if current user can edit this moderation queue. * * @return boolean */ public function canEdit() { $sql = "SELECT\tisAffected\n\t\t\tFROM\twcf" . WCF_N . "_moderation_queue_to_user\n\t\t\tWHERE\tqueueID = ?\n\t\t\t\tAND userID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->queueID, WCF::getUser()->userID)); $row = $statement->fetchArray(); return $row !== false && $row['isAffected']; }
/** * Adds a new entry to modification log. * * @param string $objectType * @param integer $objectID * @param string $action * @param array $additionalData * @param integer $time * @param integer $userID * @param string $username * @return wcf\data\modification\log\ModificationLog */ protected function _add($objectType, $objectID, $action, array $additionalData = array(), $time = TIME_NOW, $userID = null, $username = null) { $objectType = $this->getObjectType($objectType); if ($objectType === null) { throw new SystemException("Object type '" . $objectType . "' not found within definition 'com.woltlab.wcf.modifiableContent'"); } return ModificationLogEditor::create(array('objectTypeID' => $objectType->objectTypeID, 'objectID' => $objectID, 'action' => $action, 'userID' => $userID === null ? WCF::getUser()->userID : $userID, 'username' => $username === null ? WCF::getUser()->username : $username, 'time' => $time, 'additionalData' => serialize($additionalData))); }
/** * Returns the number of pages in this conversation. * * @return integer */ public function getPages() { if (WCF::getUser()->conversationMessagesPerPage) { $messagesPerPage = WCF::getUser()->conversationMessagesPerPage; } else { $messagesPerPage = CONVERSATION_MESSAGES_PER_PAGE; } return intval(ceil(($this->replies + 1) / $messagesPerPage)); }
/** * Marks all news categories as read. */ public function markAllAsRead() { VisitTracker::getInstance()->trackTypeVisit('de.incendium.linklist.entry'); // reset the user storage data and delete notifications if (WCF::getUser()->userID) { // user storage data UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'linklistUnreadEntries'); } }