Example #1
0
 public static function createNew($name, $content, $scope = null, $options = array())
 {
     $user_id = framework\Context::getUser() instanceof User ? framework\Context::getUser()->getID() : 0;
     $article = new Article();
     $article->setName($name);
     $article->setContent($content);
     if (!isset($options['noauthor'])) {
         $article->setAuthor($user_id);
     } else {
         $article->setAuthor(0);
     }
     if ($scope !== null) {
         $article->setScope($scope);
     }
     $article->doSave($options);
     return $article->getID();
 }
Example #2
0
 /**
  * Adds "notify once" settings for necessary articles
  *
  * @param \thebuggenie\modules\publish\entities\Article $article
  * @param array|\thebuggenie\core\entities\User $users
  */
 protected function _markArticleSent(Article $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();
         }
     }
 }