public static function createNew($name, $content, $published, $scope = null, $options = array()) { $user_id = TBGContext::getUser() instanceof TBGUser ? TBGContext::getUser()->getID() : 0; $article = new TBGWikiArticle(); $article->setName($name); $article->setContent($content); $article->setIsPublished($published); if (!isset($options['noauthor'])) { $article->setAuthor($user_id); } else { $article->setAuthor(0); } if ($scope !== null) { $article->setScope($scope); } $article->doSave($options); return $article->getID(); }
/** * Adds "notify once" settings for necessary articles * * @param TBGWikiArticle $article * @param array|TBGUser $users */ protected function _markArticleSent(TBGWikiArticle $article, $users) { foreach ($users as $user) { if ($user->getNotificationSetting(self::NOTIFY_ITEM_ONCE, false, 'mailing')->isOn()) { $user->setNotificationSetting(self::NOTIFY_ITEM_ONCE . '_article_' . $article->getID(), true, 'mailing')->save(); } } }