/**
  * {@inheritdoc}
  */
 public function create()
 {
     $data = $this->parameters['data'];
     //count attachments
     if (isset($this->parameters['attachmentHandler']) && $this->parameters['attachementHandler'] !== null) {
         $data['attachments'] = count($this->parameters['attachmentHandler']);
     }
     //get classes
     $baseClass = $this->className;
     $articleClass = $baseClass::getBaseClass();
     //create object
     $article = parent::create();
     $editor = new $baseClass($article);
     //update attachments
     if (isset($this->parameters['attachmentHandler']) && $this->parameters['attachmentHandler'] !== null) {
         $this->parameters['attachmentHandler']->updateObjectID($article->{$baseClass::getDatabaseTableIndexName()});
     }
     //handle categories
     $editor->updateCategoryIDs($this->parameters['categoryIDs']);
     $editor->setCategoryIDs($this->parameters['categoryIDs']);
     //handle languageID
     $languageID = !isset($data['languageID']) || $data['languageID'] === null ? LanguageFactory::getInstance()->getDefaultLanguageID() : $data['languageID'];
     //handle tags
     if (!empty($this->parameters['tags'])) {
         TagEngine::getInstance()->addObjectTags($articleClass::$objectType, $article->{$baseClass::getDatabaseTableIndexName()}, $this->parameters['tags'], $languageID);
     }
     // reset storage
     // todo: check for isDisabled?!
     UserStorageHandler::getInstance()->resetAll(self::$userStorageIdentifier);
     return $article;
 }
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     if (!isset($this->parameters['data']['lastChangeTime'])) {
         $this->parameters['data']['lastChangeTime'] = TIME_NOW;
     }
     return parent::create();
 }
Пример #3
0
 /**
  * Creates a new group.
  * 
  * @return	UserGroup
  */
 public function create()
 {
     $group = parent::create();
     $groupEditor = new UserGroupEditor($group);
     $groupEditor->updateGroupOptions($this->parameters['options']);
     return $group;
 }
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $this->parameters['data']['subscriptionID'] = $this->parameters['subscription']->subscriptionID;
     $this->parameters['data']['userID'] = $this->parameters['user']->userID;
     if (!isset($this->parameters['data']['startDate'])) {
         $this->parameters['data']['startDate'] = TIME_NOW;
     }
     if (!isset($this->parameters['data']['endDate'])) {
         if (!$this->parameters['subscription']->subscriptionLength) {
             $this->parameters['data']['endDate'] = 0;
         } else {
             $d = DateUtil::getDateTimeByTimestamp($this->parameters['data']['startDate']);
             $d->add($this->parameters['subscription']->getDateInterval());
             $this->parameters['data']['endDate'] = $d->getTimestamp();
         }
     }
     if (!isset($this->parameters['data']['isActive'])) {
         $this->parameters['data']['isActive'] = 1;
     }
     $subscriptionUser = parent::create();
     // update group memberships
     $action = new PaidSubscriptionUserAction(array($subscriptionUser), 'addGroupMemberships');
     $action->executeAction();
     return $subscriptionUser;
 }
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $notification = parent::create();
     $sql = "INSERT INTO\twcf" . WCF_N . "_user_notification_to_user\n\t\t\t\t\t(notificationID, userID)\n\t\t\tVALUES\t\t(?, ?)";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($notification->notificationID, $notification->userID));
     return $notification;
 }
Пример #6
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $template = parent::create();
     if (isset($this->parameters['source'])) {
         $editor = new TemplateEditor($template);
         $editor->setSource($this->parameters['source']);
     }
     return $template;
 }
Пример #7
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $style = parent::create();
     // add variables
     $this->updateVariables($style);
     // handle style preview image
     $this->updateStylePreviewImage($style);
     return $style;
 }
 /**
  * @see	wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $statement = parent::create();
     if (isset($this->parameters['changeBalance']) && $this->parameters['changeBalance']) {
         $user = new User($this->parameters['data']['userID']);
         $userEditor = new UserEditor($user);
         $userEditor->updateCounters(array('jCoinsBalance' => $statement->sum));
     }
     return $statement;
 }
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create();
  */
 public function create()
 {
     $event = parent::create();
     if ($event->preset) {
         $sql = "INSERT INTO\twcf" . WCF_N . "_user_notification_event_to_user\n\t\t\t\t\t\t(userID, eventID, mailNotificationType)\n\t\t\t\tSELECT\t\tuserID, " . $event->eventID . ", '" . WCF::getDB()->escapeString($event->presetMailNotificationType) . "'\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute();
     }
     return $event;
 }
Пример #10
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $smiley = parent::create();
     if (!empty($this->parameters['fileLocation'])) {
         $smileyFilename = 'smiley' . $smiley->smileyID . '.' . mb_strtolower(mb_substr($this->parameters['fileLocation'], mb_strrpos($this->parameters['fileLocation'], '.') + 1));
         @rename($this->parameters['fileLocation'], WCF_DIR . 'images/smilies/' . $smileyFilename);
         $smileyEditor = new SmileyEditor($smiley);
         $smileyEditor->update(array('smileyPath' => 'images/smilies/' . $smileyFilename));
         $smiley = new Smiley($smiley->smileyID);
     }
     return $smiley;
 }
Пример #11
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $showOrder = 0;
     if (isset($this->parameters['data']['showOrder'])) {
         $showOrder = $this->parameters['data']['showOrder'];
         unset($this->parameters['data']['showOrder']);
     }
     $ad = parent::create();
     $adEditor = new AdEditor($ad);
     $adEditor->setShowOrder($showOrder);
     return new Ad($ad->adID);
 }
Пример #12
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $showOrder = 0;
     if (isset($this->parameters['data']['showOrder'])) {
         $showOrder = $this->parameters['data']['showOrder'];
         unset($this->parameters['data']['showOrder']);
     }
     $notice = parent::create();
     $noticeEditor = new NoticeEditor($notice);
     $noticeEditor->setShowOrder($showOrder);
     return new Notice($notice->noticeID);
 }
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $showOrder = 0;
     if (isset($this->parameters['data']['showOrder'])) {
         $showOrder = $this->parameters['data']['showOrder'];
         unset($this->parameters['data']['showOrder']);
     }
     $subscription = parent::create();
     $editor = new PaidSubscriptionEditor($subscription);
     $editor->setShowOrder($showOrder);
     return new PaidSubscription($subscription->subscriptionID);
 }
Пример #14
0
	/**
	 * @see wcf\data\IDatabaseObjectAction::create()
	 */
	public function create() {
		if (!isset($this->parameters['data']['packageID'])) {
			$this->parameters['data']['packageID'] = PACKAGE_ID;
		}
		
		$menuItem = parent::create();
		
		if ($menuItem->menuPosition == 'header') {
			PageMenuItemEditor::updateLandingPage();
		}
		
		return $menuItem;
	}
Пример #15
0
 /**
  * @see	\wcf\data\IDatabaseObjectAction::create()
  */
 public function create()
 {
     if (!isset($this->parameters['data']['packageID'])) {
         $this->parameters['data']['packageID'] = PACKAGE_ID;
     }
     // calculate show order
     $this->parameters['data']['showOrder'] = PageMenuItemEditor::getShowOrder($this->parameters['data']['showOrder'], $this->parameters['data']['menuPosition'], $this->parameters['data']['parentMenuItem']);
     $menuItem = parent::create();
     if ($menuItem->menuPosition == 'header') {
         PageMenuItemEditor::updateLandingPage();
     }
     return $menuItem;
 }
Пример #16
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     if (!isset($this->parameters['data']['time'])) {
         $this->parameters['data']['time'] = TIME_NOW;
     }
     // create poll
     $poll = parent::create();
     // create options
     $sql = "INSERT INTO\twcf" . WCF_N . "_poll_option\n\t\t\t\t\t(pollID, optionValue, showOrder)\n\t\t\tVALUES\t\t(?, ?, ?)";
     $statement = WCF::getDB()->prepareStatement($sql);
     WCF::getDB()->beginTransaction();
     foreach ($this->parameters['options'] as $showOrder => $option) {
         $statement->execute(array($poll->pollID, $option['optionValue'], $showOrder));
     }
     WCF::getDB()->commitTransaction();
     return $poll;
 }
Пример #17
0
 /**
  * Attention: This method does not always return a new object, in case a matching virtual session
  * already exists, the existing session will be returned rather than a new session being created.
  * 
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     // try to find an existing virtual session
     $baseClass = call_user_func(array($this->className, 'getBaseClass'));
     $virtualSession = call_user_func(array($baseClass, 'getExistingSession'), $this->parameters['data']['sessionID']);
     if ($virtualSession !== null) {
         return $virtualSession;
     }
     if (!isset($this->parameters['data']['lastActivityTime'])) {
         $this->parameters['data']['lastActivityTime'] = TIME_NOW;
     }
     if (!isset($this->parameters['data']['ipAddress'])) {
         $this->parameters['data']['ipAddress'] = UserUtil::getIpAddress();
     }
     if (!isset($this->parameters['data']['userAgent'])) {
         $this->parameters['data']['userAgent'] = UserUtil::getUserAgent();
     }
     return parent::create();
 }
Пример #18
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $bbCode = parent::create();
     // add bbcode to BBCodeSelect user group options
     $sql = "SELECT\toptionID\n\t\t\tFROM\twcf" . WCF_N . "_user_group_option\n\t\t\tWHERE\toptionType = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array('BBCodeSelect'));
     $optionIDs = array();
     while ($optionID = $statement->fetchColumn()) {
         $optionIDs[] = $optionID;
     }
     if (!empty($optionIDs)) {
         $conditionBuilder = new PreparedStatementConditionBuilder();
         $conditionBuilder->add("optionID IN (?)", array($optionIDs));
         $conditionBuilder->add("groupID IN (?)", array(UserGroup::getGroupIDsByType(array(UserGroup::EVERYONE))));
         $conditionBuilder->add("optionValue <> ?", array('all'));
         $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_user_group_option_value\n\t\t\t\t" . $conditionBuilder;
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditionBuilder->getParameters());
         $sql = "UPDATE\twcf" . WCF_N . "_user_group_option_value\n\t\t\t\tSET\toptionValue = ?\n\t\t\t\tWHERE\toptionID = ?\n\t\t\t\t\tAND groupID = ?";
         $updateStatement = WCF::getDB()->prepareStatement($sql);
         WCF::getDB()->beginTransaction();
         while ($row = $statement->fetchArray()) {
             if (!empty($row['optionValue'])) {
                 $row['optionValue'] .= ',' . $bbCode->bbcodeTag;
             } else {
                 $row['optionValue'] = $bbCode->bbcodeTag;
             }
             $updateStatement->execute(array($row['optionValue'], $row['optionID'], $row['groupID']));
         }
         WCF::getDB()->commitTransaction();
         // clear user group option cache
         UserGroupEditor::resetCache();
     }
     return $bbCode;
 }
Пример #19
0
 /**
  * Creates a new user.
  * 
  * @return	User
  */
 public function create()
 {
     $user = parent::create();
     $userEditor = new UserEditor($user);
     // updates user options
     if (isset($this->parameters['options'])) {
         $userEditor->updateUserOptions($this->parameters['options']);
     }
     // insert user groups
     $addDefaultGroups = isset($this->parameters['addDefaultGroups']) ? $this->parameters['addDefaultGroups'] : true;
     $groupIDs = isset($this->parameters['groups']) ? $this->parameters['groups'] : array();
     $userEditor->addToGroups($groupIDs, false, $addDefaultGroups);
     // insert visible languages
     $languageIDs = isset($this->parameters['languages']) ? $this->parameters['languages'] : array();
     $userEditor->addToLanguages($languageIDs);
     return $user;
 }
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     // count attachments
     if (isset($this->parameters['attachmentHandler']) && $this->parameters['attachmentHandler'] !== null) {
         $this->parameters['data']['attachments'] = count($this->parameters['attachmentHandler']);
     }
     if (LOG_IP_ADDRESS) {
         // add ip address
         if (!isset($this->parameters['data']['ipAddress'])) {
             $this->parameters['data']['ipAddress'] = WCF::getSession()->ipAddress;
         }
     } else {
         // do not track ip address
         if (isset($this->parameters['data']['ipAddress'])) {
             unset($this->parameters['data']['ipAddress']);
         }
     }
     // create message
     $message = parent::create();
     $messageEditor = new ConversationMessageEditor($message);
     // get conversation
     $conversation = isset($this->parameters['converation']) ? $this->parameters['converation'] : new Conversation($message->conversationID);
     $conversationEditor = new ConversationEditor($conversation);
     if (empty($this->parameters['isFirstPost'])) {
         // update last message
         $conversationEditor->addMessage($message);
         // fire notification event
         if (!$conversation->isDraft) {
             $notificationRecipients = array_diff($conversation->getParticipantIDs(true), array($message->userID));
             // don't notify message author
             if (!empty($notificationRecipients)) {
                 UserNotificationHandler::getInstance()->fireEvent('conversationMessage', 'com.woltlab.wcf.conversation.message.notification', new ConversationMessageUserNotificationObject($message), $notificationRecipients);
             }
         }
         $userConversation = Conversation::getUserConversation($conversation->conversationID, $message->userID);
         if ($userConversation !== null && $userConversation->isInvisible) {
             // make invisible participant visible
             $sql = "UPDATE\twcf" . WCF_N . "_conversation_to_user\n\t\t\t\t\tSET\tisInvisible = 0\n\t\t\t\t\tWHERE\tparticipantID = ?\n\t\t\t\t\t\tAND conversationID = ?";
             $statement = WCF::getDB()->prepareStatement($sql);
             $statement->execute(array($message->userID, $conversation->conversationID));
             $conversationEditor->updateParticipantSummary();
             $conversationEditor->updateParticipantCount();
         }
         // reset visibility if it was hidden but not left
         $sql = "UPDATE\twcf" . WCF_N . "_conversation_to_user\n\t\t\t\tSET\thideConversation = ?\n\t\t\t\tWHERE\tconversationID = ?\n\t\t\t\t\tAND hideConversation = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array(Conversation::STATE_DEFAULT, $conversation->conversationID, Conversation::STATE_HIDDEN));
     }
     // reset storage
     UserStorageHandler::getInstance()->reset($conversation->getParticipantIDs(), 'unreadConversationCount');
     // update search index
     SearchIndexManager::getInstance()->add('com.woltlab.wcf.conversation.message', $message->messageID, $message->message, !empty($this->parameters['isFirstPost']) ? $conversation->subject : '', $message->time, $message->userID, $message->username);
     // update attachments
     if (isset($this->parameters['attachmentHandler']) && $this->parameters['attachmentHandler'] !== null) {
         $this->parameters['attachmentHandler']->updateObjectID($message->messageID);
     }
     // save embedded objects
     if (MessageEmbeddedObjectManager::getInstance()->registerObjects('com.woltlab.wcf.conversation.message', $message->messageID, $message->message)) {
         $messageEditor->update(array('hasEmbeddedObjects' => 1));
     }
     // clear quotes
     if (isset($this->parameters['removeQuoteIDs']) && !empty($this->parameters['removeQuoteIDs'])) {
         MessageQuoteManager::getInstance()->markQuotesForRemoval($this->parameters['removeQuoteIDs']);
     }
     MessageQuoteManager::getInstance()->removeMarkedQuotes();
     // return new message
     return $message;
 }
Пример #21
0
 /**
  * Creates a new user.
  * 
  * @return	User
  */
 public function create()
 {
     if (!isset($this->parameters['data']['socialNetworkPrivacySettings'])) {
         $this->parameters['data']['socialNetworkPrivacySettings'] = '';
     }
     $user = parent::create();
     $userEditor = new UserEditor($user);
     // updates user options
     if (isset($this->parameters['options'])) {
         $userEditor->updateUserOptions($this->parameters['options']);
     }
     // insert user groups
     $addDefaultGroups = isset($this->parameters['addDefaultGroups']) ? $this->parameters['addDefaultGroups'] : true;
     $groupIDs = isset($this->parameters['groups']) ? $this->parameters['groups'] : array();
     $userEditor->addToGroups($groupIDs, false, $addDefaultGroups);
     // insert visible languages
     if (!isset($this->parameters['languageIDs'])) {
         // using the 'languages' key is deprecated since WCF 2.1, please use 'languageIDs' instead
         $this->parameters['languageIDs'] = !empty($this->parameters['languages']) ? $this->parameters['languages'] : array();
     }
     $userEditor->addToLanguages($this->parameters['languageIDs'], false);
     if (PACKAGE_ID) {
         // set default notifications
         $sql = "INSERT INTO\twcf" . WCF_N . "_user_notification_event_to_user\n\t\t\t\t\t\t(userID, eventID, mailNotificationType)\n\t\t\t\tSELECT\t\t?, eventID, presetMailNotificationType\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user_notification_event\n\t\t\t\tWHERE\t\tpreset = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($user->userID, 1));
         // update user rank
         if (MODULE_USER_RANK) {
             $action = new UserProfileAction(array($userEditor), 'updateUserRank');
             $action->executeAction();
         }
         // update user online marking
         $action = new UserProfileAction(array($userEditor), 'updateUserOnlineMarking');
         $action->executeAction();
     }
     return $user;
 }
Пример #22
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     // set default values for author and last editor
     if (!isset($this->parameters['data']['authorID'])) {
         $this->parameters['data']['authorID'] = WCF::getUser()->userID;
         $this->parameters['data']['authorName'] = WCF::getUser()->username;
     }
     if (!isset($this->parameters['data']['lastEditorID'])) {
         $this->parameters['data']['lastEditorID'] = $this->parameters['data']['authorID'];
         $this->parameters['data']['lastEditorName'] = $this->parameters['data']['authorName'];
     }
     // set default values for creation- and last edit time
     if (!isset($this->parameters['data']['creationTime'])) {
         $this->parameters['data']['creationTime'] = TIME_NOW;
     }
     if (!isset($this->parameters['data']['lastEditTime'])) {
         $this->parameters['data']['lastEditTime'] = $this->parameters['data']['creationTime'];
     }
     // create page itself
     $page = parent::create();
     $pageEditor = new PageEditor($page);
     // handle stylesheets
     if (isset($this->parameters['stylesheetIDs']) && !empty($this->parameters['stylesheetIDs'])) {
         $pageEditor->updateStylesheetIDs($this->parameters['stylesheetIDs']);
     }
     // check if first page
     if (PageCache::getInstance()->getHomePage() === null) {
         $pageEditor->setAsHome();
     }
     // trigger publication
     if (!$page->isDisabled && $page->isPublished) {
         $action = new PageAction(array($pageEditor), 'triggerPublication');
         $action->executeAction();
     }
     return $page;
 }
Пример #23
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     $showOrder = 0;
     if (isset($this->parameters['data']['showOrder'])) {
         $showOrder = $this->parameters['data']['showOrder'];
         unset($this->parameters['data']['showOrder']);
     }
     $item = parent::create();
     $itemEditor = new JCoinsShopItemEditor($item);
     $itemEditor->setShowOrder($showOrder);
     $type = $item->getType();
     $sql = "INSERT INTO wcf" . WCF_N . "_jcoins_shop_item_parameter (itemID, parameterID, value) VALUES (?, ?, ?)";
     $statement = WCF::getDB()->prepareStatement($sql);
     foreach ($type->getParameters() as $parameter) {
         if (!isset($this->parameters['parameters'][$parameter['parameterID']])) {
             $this->parameters['parameters'][$parameter['parameterID']] = '';
         }
         $statement->execute(array($item->getObjectID(), $parameter['parameterID'], $this->parameters['parameters'][$parameter['parameterID']]));
     }
     return new JCoinsShopItem($item->getObjectID());
 }
Пример #24
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     // prevent the position from being set raw...
     $position = 0;
     if (isset($this->parameters['data']['position'])) {
         $position = $this->parameters['data']['position'];
         unset($this->parameters['data']['position']);
     }
     // ...we have our own method for that
     $project = parent::create();
     $projectEditor = new ProjectEditor($project);
     $projectEditor->setPosition($position);
     return $project;
 }
Пример #25
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::create()
  */
 public function create()
 {
     // serialize content data
     if (isset($this->parameters['data']['contentData']) && is_array($this->parameters['data']['contentData'])) {
         $this->parameters['data']['contentData'] = serialize($this->parameters['data']['contentData']);
     }
     return parent::create();
 }