public static function save_suggestion($cid, $uid, $title, $body, $track, $tags, $ccid = 0, $is_active = 1, $display_on = 0, $is_default_content = FALSE)
 {
     // global var $path_prefix has been removed - please, use PA::$path static variable
     $errors = array();
     // ensure integers here
     $cid = (int) $cid;
     $uid = (int) $uid;
     $ccid = (int) $ccid;
     // if a new post, make one, otherwise load the existing one
     if ($cid) {
         $post = Content::load_content($cid, $uid);
         // ignore $ccid passed to function if the post already exists
         // - we don't allow users to move posts between
         // ContentCollections.
         $ccid = (int) $post->parent_collection_id;
     } else {
         $post = new Suggestion();
         $post->author_id = $uid;
         if ($ccid) {
             $post->parent_collection_id = $ccid;
         }
     }
     if ($ccid && $ccid != -1) {
         $g = ContentCollection::load_collection($ccid, $uid);
         $g->assert_user_access($uid);
     } else {
         $g = NULL;
     }
     $post->title = $title;
     $post->body = $body;
     $post->allow_comments = 1;
     $post->is_active = $is_active;
     $post->display_on = $display_on;
     $post->trackbacks = '';
     if ($track) {
         $post->trackbacks = implode(",", $track);
     }
     $post->is_default_content = $is_default_content;
     $post->save();
     //if ($tags) {
     Tag::add_tags_to_content($post->content_id, $tags);
     //}
     if ($track) {
         foreach ($track as $t) {
             if (!$post->send_trackback($t)) {
                 $errors[] = array("code" => "trackback_failed", "msg" => "Failed to send trackback", "url" => $t);
             }
         }
     }
     if ($g && !$cid) {
         // new post - post it to the group as well
         $g->post_content($post->content_id, $uid);
     }
     if (!$cid) {
         // add to suggestion queue automatically if not editing
         ModerationQueue::moderate_suggestion($post->content_id);
     }
     return array("cid" => (int) $post->content_id, "moderation_required" => $g ? $g->is_moderated == 1 && $g->author_id != $uid : FALSE, "errors" => $errors);
 }
 /**
  * function to delete user content
  */
 public static function delete_user_content($user_id)
 {
     Logger::log("Enter: Content::delete_user_content()");
     $sql = 'UPDATE {contents} SET is_active = ? WHERE author_id = ?';
     $data = array(DELETED, $user_id);
     Dal::query($sql, $data);
     ModerationQueue::remove_content_from_user($user_id);
     Logger::log("Exit: Content::delete_user_content()");
 }
 /**
  * check for content in moderation queue.
  * @access private
  * @param int $content_id, $collection_id
  * if collection_id is not set then it is -1
  * which indicates that content is not part of any collection
  * @param string type ie user/content
  */
 public static function item_exists_in_moderation($content_id, $collection_id, $type = 'content')
 {
     Logger::log("Enter: Network::item_exists_in_moderation() | Args: \$item_id = {$content_id}, \$type = {$type}");
     $return_val = ModerationQueue::content_exists($content_id, $collection_id);
     Logger::log("Exit: Network::item_exists_in_moderation() | Return: " . ($return_val ? 'TRUE' : 'FALSE'));
     return $return_val;
 }
Example #4
0
 /**
  * check for item in moderation queue.
  * @access private
  * @param int $item_id
  */
 public static function item_exists_in_moderation($item_id, $type = 'user')
 {
     Logger::log("Enter: Group::item_exists_in_moderation() | Args: \$item_id = {$item_id}, \$type = {$type}");
     $return_val = ModerationQueue::user_exists($item_id);
     Logger::log("Exit: Group::item_exists_in_moderation() | Return: " . ($return_val ? 'TRUE' : 'FALSE'));
     return $return_val;
 }