/**
  * Saves subscription state.
  */
 public function saveSubscription()
 {
     // subscribe
     if ($this->parameters['subscribe']) {
         // newly subscribed
         if ($this->userObjectWatch === null) {
             UserObjectWatchEditor::create(array('notification' => $this->parameters['enableNotification'] ? 1 : 0, 'objectID' => $this->parameters['objectID'], 'objectTypeID' => $this->objectType->objectTypeID, 'userID' => WCF::getUser()->userID));
         } else {
             if ($this->userObjectWatch->notification != $this->parameters['enableNotification']) {
                 // update notification type
                 $editor = new UserObjectWatchEditor($this->userObjectWatch);
                 $editor->update(array('notification' => $this->parameters['enableNotification'] ? 1 : 0));
             }
         }
         // reset user storage
         $this->objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID));
     } else {
         if ($this->userObjectWatch !== null) {
             // unsubscribe
             $editor = new UserObjectWatchEditor($this->userObjectWatch);
             $editor->delete();
             // reset user storage
             $this->objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID));
         }
     }
     return array('objectID' => $this->parameters['objectID'], 'subscribe' => $this->parameters['subscribe']);
 }
 /**
  * Creates a new AttachmentHandler object.
  * 
  * @param	string		$objectType
  * @param	integer		$objectID
  * @param	string		$tmpHash
  */
 public function __construct($objectType, $objectID, $tmpHash = '', $parentObjectID = 0)
 {
     if (!$objectID && !$tmpHash) {
         throw new SystemException('objectID and tmpHash cannot be empty at the same time');
     }
     $this->objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $objectType);
     $this->processor = $this->objectType->getProcessor();
     $this->objectID = $objectID;
     $this->parentObjectID = $parentObjectID;
     $this->tmpHash = $tmpHash;
 }
 /**
  * @see	\wcf\system\faker\IFaker::fake()
  */
 public function fake()
 {
     $objectID = $this->getObjectID();
     $creationTime = $this->getCreationTime();
     $sql = "SELECT\t\tuserID, username, registrationDate\n\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\tORDER BY\tuserID ASC";
     $statement = \wcf\system\WCF::getDB()->prepareStatement($sql, 1, $this->generator->numberBetween(0, $this->userCount - 1));
     $statement->execute();
     $sender = $statement->fetchObject('\\wcf\\data\\user\\User');
     // create comment
     $comment = \wcf\data\comment\CommentEditor::create(array('objectTypeID' => $this->objectTypeID, 'objectID' => $objectID, 'time' => $this->generator->numberBetween(max($sender->registrationDate, $creationTime), TIME_NOW), 'userID' => $sender->userID, 'username' => $sender->username, 'message' => $this->generator->realText($this->generator->numberBetween(10, 5000)), 'responses' => 0, 'responseIDs' => serialize(array())));
     // update counter
     $this->objectType->getProcessor()->updateCounter($this->objectTypeID, 1);
 }
 /**
  * @see	\wcf\system\faker\AbstractFaker::__construct()
  */
 public function __construct(\Faker\Generator $generator, array $parameters)
 {
     parent::__construct($generator, $parameters);
     $sql = "SELECT\tCOUNT(*)\n\t\t\tFROM\twcf" . WCF_N . "_user";
     $statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
     $statement->execute();
     $this->userCount = $statement->fetchColumn();
     $this->objectType = \wcf\system\like\LikeHandler::getInstance()->getObjectType($this->objectTypeName);
     if ($this->objectType === null) {
         throw new UserInputException('objectType');
     }
     $this->objectTypeProvider = $this->objectType->getProcessor();
 }
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     $this->objectType = CategoryHandler::getInstance()->getObjectTypeByName($this->objectTypeName);
     if ($this->objectType === null) {
         throw new SystemException("Unknown category object type with name '" . $this->objectTypeName . "'");
     }
     // check permissions
     $this->checkCategoryPermissions();
     $this->readCategories();
     // note that the implementation of wcf\system\category\ICategoryType
     // needs to support a object type of the pseudo definition
     // 'com.woltlab.wcf.collapsibleContent.acp' which has to be registered
     // during package installation as a 'com.woltlab.wcf.collapsibleContent'
     // object type if you want to support collapsible categories in the
     // acp; the pseudo object type is used to distinguish between
     // collapsible categories in the frontend and the acp
     $collapsibleObjectTypeName = $this->objectType->getProcessor()->getObjectTypeName('com.woltlab.wcf.collapsibleContent.acp');
     if ($collapsibleObjectTypeName) {
         $this->collapsibleObjectTypeID = UserCollapsibleContentHandler::getInstance()->getObjectTypeID($collapsibleObjectTypeName);
         // get ids of collapsed category
         if ($this->collapsibleObjectTypeID !== null) {
             $this->collapsedCategoryIDs = UserCollapsibleContentHandler::getInstance()->getCollapsedContent($this->collapsibleObjectTypeID);
             $this->collapsedCategoryIDs = array_flip($this->collapsedCategoryIDs);
         }
     }
     parent::readData();
 }
示例#6
0
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     WCF::getTPL()->assign(array('tag' => $this->tag, 'tags' => $this->tagCloud->getTags(100), 'availableObjectTypes' => $this->availableObjectTypes, 'objectType' => $this->objectType->objectType, 'resultListTemplateName' => $this->objectType->getProcessor()->getTemplateName(), 'resultListApplication' => $this->objectType->getProcessor()->getApplication(), 'allowSpidersToIndexThisPage' => true));
     if (count($this->objectList) === 0) {
         @header('HTTP/1.0 404 Not Found');
     }
 }
示例#7
0
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['oldID'])) {
         $this->oldID = intval($_REQUEST['oldID']);
         $this->old = new EditHistoryEntry($this->oldID);
         if (!$this->old->entryID) {
             throw new IllegalLinkException();
         }
         if (isset($_REQUEST['newID']) && $_REQUEST['newID'] !== 'current') {
             $this->newID = intval($_REQUEST['newID']);
             $this->new = new EditHistoryEntry($this->newID);
             if (!$this->new->entryID) {
                 throw new IllegalLinkException();
             }
         }
         // if new version isn't 'current' check whether they are comparable
         if ($this->new) {
             // different objectTypes cannot be compared
             if ($this->old->objectTypeID != $this->new->objectTypeID) {
                 throw new IllegalLinkException();
             }
             // different items cannot be compared
             if ($this->old->objectID != $this->new->objectID) {
                 throw new IllegalLinkException();
             }
         }
         $this->objectID = $this->old->objectID;
         $this->objectType = ObjectTypeCache::getInstance()->getObjectType($this->old->objectTypeID);
     } else {
         if (isset($_REQUEST['objectID']) && isset($_REQUEST['objectType'])) {
             $this->objectID = intval($_REQUEST['objectID']);
             $this->objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.edit.historySavingObject', $_REQUEST['objectType']);
         } else {
             throw new IllegalLinkException();
         }
     }
     if (!$this->objectType) {
         throw new IllegalLinkException();
     }
     $processor = $this->objectType->getProcessor();
     $this->object = $processor->getObjectByID($this->objectID);
     if (!$this->object->getObjectID()) {
         throw new IllegalLinkException();
     }
     $processor->checkPermissions($this->object);
     $this->activeMenuItem = $processor->getActivePageMenuItem();
     $this->object->addBreadcrumbs();
     if (isset($_REQUEST['newID']) && !$this->new) {
         $this->new = $this->object;
         $this->newID = 'current';
     }
     if (!empty($_POST)) {
         HeaderUtil::redirect(LinkHandler::getInstance()->getLink('EditHistory', array('objectID' => $this->objectID, 'objectType' => $this->objectType->objectType, 'newID' => $this->newID, 'oldID' => $this->oldID)));
         exit;
     }
 }
 /**
  * @see	\wcf\system\faker\IFaker::fake()
  */
 public function fake()
 {
     $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_comment\n\t\t\tWHERE\t\tobjectTypeID = ?";
     $statement = \wcf\system\WCF::getDB()->prepareStatement($sql, 1, $this->generator->numberBetween(0, $this->commentCount - 1));
     $statement->execute(array($this->objectTypeID));
     $target = $statement->fetchObject('\\wcf\\data\\comment\\Comment');
     $sql = "SELECT\t\tuserID, username, registrationDate\n\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\tORDER BY\tuserID ASC";
     $statement = \wcf\system\WCF::getDB()->prepareStatement($sql, 1, $this->generator->numberBetween(0, $this->userCount - 1));
     $statement->execute();
     $sender = $statement->fetchObject('\\wcf\\data\\user\\User');
     // create response
     $response = \wcf\data\comment\response\CommentResponseEditor::create(array('commentID' => $target->commentID, 'time' => $this->generator->numberBetween(max($sender->registrationDate, $target->time), TIME_NOW), 'userID' => $sender->userID, 'username' => $sender->username, 'message' => $this->generator->realText($this->generator->numberBetween(10, 5000))));
     // update response data
     $responseIDs = $target->getResponseIDs();
     if (count($responseIDs) < 3) {
         $responseIDs[] = $response->responseID;
     }
     $responses = $target->responses + 1;
     // update comment
     $commentEditor = new \wcf\data\comment\CommentEditor($target);
     $commentEditor->update(array('responseIDs' => serialize($responseIDs), 'responses' => $responses));
     // update counter
     $this->objectType->getProcessor()->updateCounter($target->objectID, 1);
 }
 /**
  * Validates the parent category.
  */
 protected function validateParentCategory()
 {
     if ($this->parentCategoryID) {
         if (!$this->objectType->getProcessor()->getMaximumNestingLevel()) {
             $this->parentCategoryID = 0;
             return;
         }
         $category = CategoryHandler::getInstance()->getCategory($this->parentCategoryID);
         if ($category === null) {
             throw new UserInputException('parentCategoryID', 'notValid');
         }
         if ($this->objectType->getProcessor()->getMaximumNestingLevel() != -1) {
             if (count($category->getParentCategories()) + 1 > $this->objectType->getProcessor()->getMaximumNestingLevel()) {
                 throw new UserInputException('parentCategoryID', 'notValid');
             }
         }
     }
 }
示例#10
0
 /**
  * Validates permissions for given object.
  */
 protected function validateObjectParameters()
 {
     if (!MODULE_LIKE) {
         throw new PermissionDeniedException();
     }
     $this->readString('containerID', false, 'data');
     $this->readInteger('objectID', false, 'data');
     $this->readString('objectType', false, 'data');
     $this->objectType = LikeHandler::getInstance()->getObjectType($this->parameters['data']['objectType']);
     if ($this->objectType === null) {
         throw new UserInputException('objectType');
     }
     $this->objectTypeProvider = $this->objectType->getProcessor();
     $this->likeableObject = $this->objectTypeProvider->getObjectByID($this->parameters['data']['objectID']);
     $this->likeableObject->setObjectType($this->objectType);
     if (!$this->objectTypeProvider->checkPermissions($this->likeableObject)) {
         throw new PermissionDeniedException();
     }
 }
示例#11
0
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     parent::save();
     $data = array('title' => $this->title, 'pageID' => $this->pageID, 'parentID' => $this->parentID ?: null, 'cssClasses' => $this->cssClasses, 'showOrder' => $this->showOrder, 'position' => $this->position, 'contentData' => $this->contentData, 'contentTypeID' => $this->objectType->objectTypeID);
     $this->objectAction = new ContentAction(array(), 'create', array('data' => $data));
     $returnValues = $this->objectAction->executeAction();
     $contentID = $returnValues['returnValues']->contentID;
     $contentData = $returnValues['returnValues']->contentData;
     $update = array();
     // save polls
     if ($this->objectType->objectType == 'de.codequake.cms.content.type.poll') {
         $pollID = PollManager::getInstance()->save($returnValues['returnValues']->contentID);
         if ($pollID) {
             $contentData['pollID'] = $pollID;
         }
     }
     if (!I18nHandler::getInstance()->isPlainValue('title')) {
         I18nHandler::getInstance()->save('title', 'cms.content.title' . $contentID, 'cms.content', PACKAGE_ID);
         $update['title'] = 'cms.content.title' . $contentID;
     }
     foreach ($this->objectType->getProcessor()->multilingualFields as $field) {
         if (!I18nHandler::getInstance()->isPlainValue($field)) {
             I18nHandler::getInstance()->save($field, 'cms.content.' . $field . $contentID, 'cms.content', PACKAGE_ID);
             $contentData[$field] = 'cms.content.' . $field . $contentID;
         }
     }
     $update['contentData'] = serialize($contentData);
     if (!empty($update)) {
         $editor = new ContentEditor($returnValues['returnValues']);
         $editor->update($update);
     }
     // create revision
     $objectAction = new PageAction(array($this->pageID), 'createRevision', array('action' => 'content.create'));
     $objectAction->executeAction();
     // update search index
     $objectAction = new PageAction(array($returnValues['returnValues']->pageID), 'refreshSearchIndex');
     $objectAction->executeAction();
     $this->saved();
     HeaderUtil::redirect(LinkHandler::getInstance()->getLink('ContentList', array('application' => 'cms', 'pageID' => $this->pageID)));
 }
示例#12
0
 /**
  * Validates the captcha challenge.
  */
 protected function validateCaptcha()
 {
     if (WCF::getUser()->userID) {
         return;
     }
     if (CAPTCHA_TYPE) {
         $this->captchaObjectType = CaptchaHandler::getInstance()->getObjectTypeByName(CAPTCHA_TYPE);
         if ($this->captchaObjectType === null) {
             throw new SystemException("Unknown captcha object type with name '" . CAPTCHA_TYPE . "'");
         }
         if (!$this->captchaObjectType->getProcessor()->isAvailable()) {
             $this->captchaObjectType = null;
         }
     }
     if ($this->captchaObjectType === null) {
         return;
     }
     try {
         $this->captchaObjectType->getProcessor()->readFormParameters();
         $this->captchaObjectType->getProcessor()->validate();
     } catch (UserInputException $e) {
         $this->validationErrors = array_merge($this->validationErrors, array($e->getField() => $e->getType()));
     }
 }
 /**
  * Validates the captcha.
  */
 protected function validateCaptcha()
 {
     if ($this->captchaObjectType) {
         $this->captchaObjectType->getProcessor()->validate();
     }
 }
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     WCF::getTPL()->assign(array('availableObjectTypes' => ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.deletedContent'), 'objectType' => $this->objectType->objectType, 'resultListTemplateName' => $this->objectType->getProcessor()->getTemplateName(), 'resultListApplication' => $this->objectType->getProcessor()->getApplication()));
 }