/** * 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::update() */ public function update() { if (!isset($this->parameters['data']['lastChangeTime'])) { $this->parameters['data']['lastChangeTime'] = TIME_NOW; } parent::update(); }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { // check if showOrder needs to be recalculated if (count($this->objects) == 1 && isset($this->parameters['data']['parentCategoryID']) && isset($this->parameters['data']['showOrder'])) { if ($this->objects[0]->parentCategoryID != $this->parameters['data']['parentCategoryID'] || $this->objects[0]->showOrder != $this->parameters['data']['showOrder']) { $this->parameters['data']['showOrder'] = $this->objects[0]->updateShowOrder($this->parameters['data']['parentCategoryID'], $this->parameters['data']['showOrder']); } } parent::update(); if (isset($this->parameters['data']['parentCategoryID'])) { $objectType = null; $parentUpdates = array(); foreach ($this->objects as $category) { if ($objectType === null) { $objectType = $category->getObjectType(); } if ($category->parentCategoryID != $this->parameters['data']['parentCategoryID']) { $parentUpdates[$category->categoryID] = array('oldParentCategoryID' => $category->parentCategoryID, 'newParentCategoryID' => $this->parameters['data']['parentCategoryID']); } } if (!empty($parentUpdates)) { $objectType->getProcessor()->changedParentCategories($parentUpdates); } } }
/** * @see \wcf\data\AbstractDatabaseObjectAction::delete() */ public function delete() { parent::delete(); if (!empty($this->objects)) { // identify i18n labels $languageVariables = array(); foreach ($this->objects as $object) { if (preg_match('~wcf.acp.label.label\\d+~', $object->label)) { $languageVariables[] = $object->label; } } // remove language variables if (!empty($languageVariables)) { $conditions = new PreparedStatementConditionBuilder(); $conditions->add("languageItem IN (?)", array($languageVariables)); $sql = "SELECT\tlanguageItemID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_language_item\n\t\t\t\t\t" . $conditions; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); $languageItemIDs = array(); while ($row = $statement->fetchArray()) { $languageItemIDs[] = $row['languageItemID']; } $objectAction = new LanguageItemAction($languageItemIDs, 'delete'); $objectAction->executeAction(); } } }
/** * @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; }
/** * @see \wcf\data\AbstractDatabaseObjectAction::delete() */ public function delete() { $count = parent::delete(); foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.label.objectType') as $objectType) { $objectType->getProcessor()->save(); } return $count; }
/** * @see \wcf\data\IDeleteAction::delete() */ public function delete() { // delete news update parent::delete(); foreach ($this->objects as $newsUpdate) { $news = new News($newsUpdate->newsID); $news->updateNewsUpdates(); } }
/** * @see \wcf\data\IDeleteAction::delete() */ public function delete() { // delete news update parent::delete(); foreach ($this->objects as $entryUpdate) { $entry = new Entry($entryUpdate->entryID); $entry->updateEntryUpdates(); } }
/** * @see \wcf\data\AbstractDatabaseObjectAction::validateDelete() */ public function validateDelete() { parent::validateDelete(); foreach ($this->objects as $userOption) { if (!$userOption->canDelete()) { throw new PermissionDeniedException(); } } }
/** * @see wcf\data\AbstractDatabaseObjectAction::delete() */ public function delete() { $returnValue = parent::delete(); // call category types foreach ($this->objects as $categoryEditor) { $categoryEditor->getCategoryType()->afterDeletion($categoryEditor); } return $returnValue; }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { parent::update(); // read current poll $pollEditor = reset($this->objects); // get current options $optionList = new PollOptionList(); $optionList->getConditionBuilder()->add("poll_option.pollID = ?", array($pollEditor->pollID)); $optionList->sqlOrderBy = "poll_option.showOrder ASC"; $optionList->readObjects(); $options = $optionList->getObjects(); $newOptions = $updateOptions = array(); foreach ($this->parameters['options'] as $showOrder => $option) { // check if editing an existing option if ($option['optionID']) { // check if an update is required if ($options[$option['optionID']]->showOrder != $showOrder || $options[$option['optionID']]->optionValue != $option['optionValue']) { $updateOptions[$option['optionID']] = array('optionValue' => $option['optionValue'], 'showOrder' => $showOrder); } // remove option unset($options[$option['optionID']]); } else { $newOptions[] = array('optionValue' => $option['optionValue'], 'showOrder' => $showOrder); } } if (!empty($newOptions) || !empty($updateOptions) || !empty($options)) { WCF::getDB()->beginTransaction(); // check if new options should be created if (!empty($newOptions)) { $sql = "INSERT INTO\twcf" . WCF_N . "_poll_option\n\t\t\t\t\t\t\t(pollID, optionValue, showOrder)\n\t\t\t\t\tVALUES\t\t(?, ?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($newOptions as $option) { $statement->execute(array($pollEditor->pollID, $option['optionValue'], $option['showOrder'])); } } // check if existing options should be updated if (!empty($updateOptions)) { $sql = "UPDATE\twcf" . WCF_N . "_poll_option\n\t\t\t\t\tSET\toptionValue = ?,\n\t\t\t\t\t\tshowOrder = ?\n\t\t\t\t\tWHERE\toptionID = ?"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($updateOptions as $optionID => $option) { $statement->execute(array($option['optionValue'], $option['showOrder'], $optionID)); } } // check if options should be removed if (!empty($options)) { $sql = "DELETE FROM\twcf" . WCF_N . "_poll_option\n\t\t\t\t\tWHERE\t\toptionID = ?"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($options as $option) { $statement->execute(array($option->optionID)); } } // force recalculation of poll stats $pollEditor->calculateVotes(); WCF::getDB()->commitTransaction(); } }
/** * @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; }
/** * @see \wcf\data\AbstractDatabaseObjectAction::validateDelete() */ public function validateDelete() { parent::validateDelete(); if (count($this->objects) != 1) { throw new UserInputException('objectID'); } $label = current($this->objects); if ($label->userID != WCF::getUser()->userID) { throw new PermissionDeniedException(); } }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { if (empty($this->objects)) { $this->readObjects(); } if (count($this->objects) == 1 && !empty($this->parameters['fileLocation'])) { $smiley = reset($this->objects); $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); $this->parameters['data']['smileyPath'] = 'images/smilies/' . $smileyFilename; } parent::update(); }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { parent::update(); foreach ($this->objects as $template) { // rename file $templateName = isset($this->parameters['data']['templateName']) ? $this->parameters['data']['templateName'] : $template->templateName; $templateGroupID = isset($this->parameters['data']['templateGroupID']) ? $this->parameters['data']['templateGroupID'] : $template->templateGroupID; if ($templateName != $template->templateName || $templateGroupID != $template->templateGroupID) { $template->rename($templateName, $templateGroupID); } // update source if (isset($this->parameters['source'])) { $template->setSource($this->parameters['source']); } } }
/** * 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(); }
/** * @see \wcf\data\IToggleAction::validateToggle() */ public function validateToggle() { parent::validateUpdate(); foreach ($this->objects as $style) { if ($style->isDefault) { throw new UserInputException('objectIDs'); } } }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { if (isset($this->parameters['data'])) { parent::update(); if (isset($this->parameters['data']['languageID'])) { foreach ($this->objects as $object) { if ($object->userID == WCF::getUser()->userID) { if ($this->parameters['data']['languageID'] != WCF::getUser()->languageID) { WCF::setLanguage($this->parameters['data']['languageID']); } break; } } } } else { if (empty($this->objects)) { $this->readObjects(); } } $groupIDs = isset($this->parameters['groups']) ? $this->parameters['groups'] : array(); $languageIDs = isset($this->parameters['languageIDs']) ? $this->parameters['languageIDs'] : array(); $removeGroups = isset($this->parameters['removeGroups']) ? $this->parameters['removeGroups'] : array(); $userOptions = isset($this->parameters['options']) ? $this->parameters['options'] : array(); if (!empty($groupIDs)) { $action = new UserAction($this->objects, 'addToGroups', array('groups' => $groupIDs, 'addDefaultGroups' => false)); $action->executeAction(); } if (!empty($removeGroups)) { $action = new UserAction($this->objects, 'removeFromGroups', array('groups' => $removeGroups)); $action->executeAction(); } foreach ($this->objects as $userEditor) { if (!empty($userOptions)) { $userEditor->updateUserOptions($userOptions); } if (!empty($languageIDs)) { $userEditor->addToLanguages($languageIDs); } } // handle user rename if (count($this->objects) == 1 && !empty($this->parameters['data']['username'])) { if ($this->objects[0]->username != $this->parameters['data']['username']) { $userID = $this->objects[0]->userID; $username = $this->parameters['data']['username']; WCF::getDB()->beginTransaction(); // update comments $sql = "UPDATE\twcf" . WCF_N . "_comment\n\t\t\t\t\tSET\tusername = ?\n\t\t\t\t\tWHERE\tuserID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($username, $userID)); $sql = "UPDATE\twcf" . WCF_N . "_comment_response\n\t\t\t\t\tSET\tusername = ?\n\t\t\t\t\tWHERE\tuserID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($username, $userID)); // modification log $sql = "UPDATE\twcf" . WCF_N . "_modification_log\n\t\t\t\t\tSET\tusername = ?\n\t\t\t\t\tWHERE\tuserID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($username, $userID)); WCF::getDB()->commitTransaction(); // fire event to handle other database tables EventHandler::getInstance()->fireAction($this, 'rename'); } } }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { // set default values for last editor if (!isset($this->parameters['data']['lastEditorID'])) { $this->parameters['data']['lastEditorID'] = WCF::getUser()->userID; $this->parameters['data']['lastEditorName'] = WCF::getUser()->username; } // set default value for last edit time if (!isset($this->parameters['data']['lastEditTime'])) { $this->parameters['data']['lastEditTime'] = TIME_NOW; } // perform update parent::update(); $pageIDs = $publishedPageIDs = array(); foreach ($this->objects as $pageEditor) { $pageIDs[] = $pageEditor->pageID; // update stylesheets if (isset($this->parameters['stylesheetIDs'])) { $pageEditor->updateStylesheetIDs($this->parameters['stylesheetIDs']); } if (!$pageEditor->isPublished) { $publishedPageIDs[] = $pageEditor->pageID; } } // delete subscriptions if subscribing isn't allowed anymore if (isset($this->parameters['data']['allowSubscribing']) && !$this->parameters['data']['allowSubscribing']) { UserObjectWatchHandler::getInstance()->deleteObjects('de.codequake.cms.page', $pageIDs); } // trigger new publications if (isset($this->parameters['data']['isPublished']) && $this->parameters['data']['isPublished'] == 1 && !empty($publishedPageIDs)) { $action = new PageAction($publishedPageIDs, 'triggerPublication'); $action->executeAction(); } }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { parent::update(); // set new position if needed if (count($this->objects) == 1 && isset($this->parameters['data']['position'])) { if ($this->objects[0]->position != $this->parameters['data']['position']) { $this->objects[0]->setPosition($this->parameters['data']['position']); } } }
/** * @see \wcf\data\IToggleAction::validateToggle() */ public function validateToggle() { parent::validateUpdate(); }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { // serialize content data if (isset($this->parameters['data']['contentData']) && is_array($this->parameters['data']['contentData'])) { $this->parameters['data']['contentData'] = serialize($this->parameters['data']['contentData']); } parent::update(); }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { if (!isset($this->parameters['participants'])) { $this->parameters['participants'] = array(); } if (!isset($this->parameters['invisibleParticipants'])) { $this->parameters['invisibleParticipants'] = array(); } // count participants if (!empty($this->parameters['participants'])) { $this->parameters['data']['participants'] = count($this->parameters['participants']); } parent::update(); foreach ($this->objects as $conversation) { // partipants if (!empty($this->parameters['participants']) || !empty($this->parameters['invisibleParticipants'])) { // get current participants $participantIDs = $conversation->getParticipantIDs(); $conversation->updateParticipants(!empty($this->parameters['participants']) ? $this->parameters['participants'] : array(), !empty($this->parameters['invisibleParticipants']) ? $this->parameters['invisibleParticipants'] : array()); $conversation->updateParticipantSummary(); // check if new participants have been added $newParticipantIDs = array_diff(array_merge($this->parameters['participants'], $this->parameters['invisibleParticipants']), $participantIDs); if (!empty($newParticipantIDs)) { // update conversation count UserStorageHandler::getInstance()->reset($newParticipantIDs, 'unreadConversationCount'); UserStorageHandler::getInstance()->reset($newParticipantIDs, 'conversationCount'); // fire notification event UserNotificationHandler::getInstance()->fireEvent('conversation', 'com.woltlab.wcf.conversation.notification', new ConversationUserNotificationObject($conversation->getDecoratedObject()), $newParticipantIDs); } } // draft status if (isset($this->parameters['data']['isDraft'])) { if ($conversation->isDraft && !$this->parameters['data']['isDraft']) { // add author $conversation->updateParticipants(array($conversation->userID)); // update conversation count UserStorageHandler::getInstance()->reset($conversation->getParticipantIDs(), 'unreadConversationCount'); UserStorageHandler::getInstance()->reset($conversation->getParticipantIDs(), 'conversationCount'); } } } }
/** * Validates permissions and parameters. */ public function validateUpdateAll() { parent::validateCreate(); }
/** * Validates permissions and parameters */ public function validateExecute() { parent::validateUpdate(); }
/** * Validates the 'execute' action. */ public function validateExecute() { // TODO: Fix this: We need update permissions for executing? parent::validateUpdate(); }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { // count attachments if (isset($this->parameters['attachmentHandler']) && $this->parameters['attachmentHandler'] !== null) { $this->parameters['data']['attachments'] = count($this->parameters['attachmentHandler']); if ($this->parameters['data']['attachments']) { $attachments = $this->parameters['attachmentHandler']->getAttachmentList()->getObjects(); $attachment = reset($attachments); $this->parameters['data']['coverID'] = $attachment->attachmentID; } } parent::update(); // get ids $objectIDs = array(); foreach ($this->objects as $entry) { $objectIDs[] = $entry->entryID; } // delete old search index entries if (!empty($objectIDs)) { SearchIndexManager::getInstance()->delete('de.incendium.filebase.entry', $objectIDs); } foreach ($this->objects as $entry) { // handle categories if (isset($this->parameters['categoryIDs'])) { $entry->updateCategoryIDs($this->parameters['categoryIDs']); } // update tags if (!empty($this->parameters['tags'])) { // set language id (cannot be zero) $languageID = !isset($this->parameters['data']['languageID']) || $this->parameters['data']['languageID'] === null ? LanguageFactory::getInstance()->getDefaultLanguageID() : $this->parameters['data']['languageID']; TagEngine::getInstance()->addObjectTags('de.incendium.filebase.entry', $entry->entryID, $this->parameters['tags'], $languageID); } // create new search index entry SearchIndexManager::getInstance()->add('de.incendium.filebase.entry', $entry->entryID, isset($this->parameters['data']['message']) ? $this->parameters['data']['message'] : $entry->message, isset($this->parameters['data']['subject']) ? $this->parameters['data']['subject'] : $entry->subject, $entry->time, $entry->userID, $entry->username, $entry->languageID); } }
/** * @see wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { if (isset($this->parameters['data'])) { parent::update(); if (isset($this->parameters['data']['languageID'])) { foreach ($this->objects as $object) { if ($object->userID == WCF::getUser()->userID) { if ($this->parameters['data']['languageID'] != WCF::getUser()->languageID) { WCF::setLanguage($this->parameters['data']['languageID']); } break; } } } } else { if (!count($this->objects)) { $this->readObjects(); } } $groupIDs = isset($this->parameters['groups']) ? $this->parameters['groups'] : array(); $languageIDs = isset($this->parameters['languageIDs']) ? $this->parameters['languageIDs'] : array(); $removeGroups = isset($this->parameters['removeGroups']) ? $this->parameters['removeGroups'] : array(); $userOptions = isset($this->parameters['options']) ? $this->parameters['options'] : array(); foreach ($this->objects as $userEditor) { if (!empty($groupIDs)) { $userEditor->addToGroups($groupIDs); } if (!empty($removeGroups)) { $userEditor->removeFromGroups($removeGroups); } if (!empty($userOptions)) { $userEditor->updateUserOptions($userOptions); } if (!empty($languageIDs)) { $userEditor->addToLanguages($languageIDs); } } }
/** * {@inheritdoc} */ public function delete() { //get classes $baseClass = $this->className; $articleClass = $baseClass::getBaseClass(); $attachedNewsIDs = array(); foreach ($this->objects as $article) { $this->objectIDs[] = $article->{$baseClass::getDatabaseTableIndexName()}; if ($article->attachments != 0) { $attachedObjectIDs[] = $article->{$baseClass::getDatabaseTableIndexName()}; } } // remove attachments if (0 !== count($attachedObjectIDs)) { AttachmentHandler::removeAttachments($articleClass::$objectType, $attachedObjectIDs); } return parent::delete(); }
/** * @see \wcf\data\AbstractDatabaseObjectAction::update() */ public function update() { $showOrder = 0; if (isset($this->parameters['data']['showOrder'])) { $showOrder = $this->parameters['data']['showOrder']; unset($this->parameters['data']['showOrder']); } parent::update(); foreach ($this->getObjects() as $object) { $object->setShowOrder($showOrder); $type = $object->getType(); $sql = "UPDATE wcf" . WCF_N . "_jcoins_shop_item_parameter SET value = ? WHERE itemID = ? AND parameterID = ?"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($type->getParameters() as $parameter) { if (isset($this->parameters['parameters'][$parameter['parameterID']])) { $statement->execute(array($this->parameters['parameters'][$parameter['parameterID']], $object->getObjectID(), $parameter['parameterID'])); } } } }