示例#1
0
function create_forum_topic($_form)
{
    $request_info = load_info();
    $parent_id = $request_info['parent_id'];
    $parent_type = $request_info['parent_type'];
    global $login_uid;
    filter_all_post($_form);
    $error = FALSE;
    $msg = array();
    $title = trim($_form['forum_title']);
    $body = trim($_form['forum_contents']);
    if (empty($title)) {
        $error = TRUE;
        $msg[] = 'Please specify a title for the forum topic';
    }
    if (empty($body)) {
        $error = TRUE;
        $msg[] = 'Please enter small description of the topic';
    }
    if (!$error) {
        $cat_obj = new MessageBoard();
        $cat_obj->set_parent($parent_id, $parent_type);
        $cat_obj->title = $title;
        $cat_obj->body = $body;
        $cat_obj->user_id = $login_uid;
        // Now Here we are saving the name of author and the email for Optimzing query when we retrive the data
        $cat_obj->user_name = $login_name;
        $cat_obj->email = $email;
        if (!$_form['chk_allow_anonymous']) {
            $cat_obj->allow_anonymous = 0;
        } else {
            $cat_obj->allow_anonymous = 1;
        }
        try {
            $mid = $cat_obj->save();
        } catch (PAException $e) {
            $msg[] = 'Error occured in saving data';
            $error = TRUE;
        }
    }
    $msg_array = array();
    $msg_array['failure_msg'] = $msg;
    $msg_array['success_msg'] = NULL;
    $return_array = array('msg' => $msg_array);
    return $return_array;
}
 function render()
 {
     $thread_obj = new MessageBoard();
     $request_info = load_info();
     $this->parent_id = $request_info['parent_id'];
     $this->parent_name_hidden = $request_info['parent_name_hidden'];
     $this->parent_type = $request_info['parent_type'];
     $this->header_title = $request_info['header_title'];
     $thread_obj->set_parent($this->parent_id, $this->parent_type);
     $this->Paging["count"] = $thread_obj->get($count = TRUE);
     $this->forum_details = $thread_obj->get($count = FALSE, $this->Paging["show"], $this->Paging["page"], 'changed', 'ASC');
     // Here we finding the ID of group owner
     $group_owner = Group::get_admin_id($_GET['ccid']);
     $this->group_owner_id = $group_owner['user_id'];
     $this->inner_HTML = $this->generate_inner_html();
     $content = parent::render();
     return $content;
 }
 function render()
 {
     global $paging;
     $request_info = load_info();
     $this->parent_id = $request_info['parent_id'];
     $this->parent_type = $request_info['parent_type'];
     $this->parent_name_hidden = $request_info['parent_name_hidden'];
     $this->header_title = $request_info['header_title'];
     $thread_obj = new MessageBoard();
     $thread_obj->set_parent($this->parent_id, $this->parent_type);
     $this->Paging["count"] = $thread_obj->get($count = TRUE);
     $this->Paging['show'] = $paging['show'];
     $this->Paging['page'] = $paging['page'];
     $this->forum_details = $thread_obj->get($count = FALSE, $this->Paging["show"], $this->Paging["page"]);
     $group_data = Group::load_group_by_id((int) $_GET['gid']);
     $this->group_name = $group_data->title;
     $this->topic_count = $this->Paging["count"];
     $this->inner_HTML = $this->generate_inner_html();
     $content = parent::render();
     return $content;
 }
 function get_forum_links()
 {
     global $paging, $base_url;
     $request_info = load_info();
     $this->parent_id = $request_info['parent_id'];
     $this->parent_type = $request_info['parent_type'];
     $this->parent_name_hidden = $request_info['parent_name_hidden'];
     $this->header_title = $request_info['header_title'];
     $thread_obj = new MessageBoard();
     $thread_obj->set_parent($this->parent_id, $this->parent_type);
     $this->Paging["count"] = $thread_obj->get($count = TRUE);
     $forum_details = $thread_obj->get($count = FALSE, $this->Paging["show"], $this->Paging["page"]);
     $cnt = count($forum_details);
     if ($cnt > 0) {
         for ($i = 1; $i <= $cnt; $i++) {
             $forum_details[$i]['hyper_link'] = $base_url . '/forum_messages.php?mid=' . $forum_details[$i]['boardmessage_id'] . '&amp;ccid=' . $_GET['gid'];
             $forum_details[$i]['edit_link'] = $base_url . '/edit_forum.php?mid=' . $forum_details[$i]['boardmessage_id'] . '&amp;gid=' . $_GET['gid'];
             $forum_details[$i]['delete_link'] = $base_url . '/deleteforumbyadmin.php?mid=' . $forum_details[$i]['boardmessage_id'] . '&amp;ccid=' . $_GET['gid'] . '" onclick="javascript:return confirm(\'Are you sure you want to delete this forum ? \');"';
         }
     }
     return $forum_details;
 }
示例#5
0
 filter_all_post($_POST);
 $error = FALSE;
 $msg = '';
 $title = trim($_POST['title_form']);
 $body = trim($_POST['body']);
 if ($title == '') {
     $error = TRUE;
     $msg .= "<br><font color=\"red\">Please specify title</font>";
 }
 if ($body == '') {
     $error = TRUE;
     $msg .= "<br><font color=\"red\">Please enter contents</font>";
 }
 if (!$error) {
     $cat_obj = new MessageBoard();
     $cat_obj->set_parent($parent_id, $parent_type);
     $cat_obj->title = $title;
     $cat_obj->body = $body;
     $cat_obj->user_id = $uid;
     if (!$_POST['chk_allow_anonymous']) {
         $cat_obj->allow_anonymous = 0;
     } else {
         $cat_obj->allow_anonymous = 1;
     }
     try {
         $mid = $cat_obj->save();
     } catch (PAException $e) {
         $msg = "Error occured in saving thread\n";
         $msg .= "<br><center><font color=\"red\">" . $e->message . "</font></center>";
         $error = TRUE;
     }
function peopleaggregator_newBoardMessage($args)
{
    if ($args['authToken']) {
        $user = User::from_auth_token($args['authToken']);
    } else {
        $user = NULL;
    }
    $context = $args['context'];
    $title = $args['title'];
    $body = $args['content'];
    $allow_anon = $args['allowAnonymous'];
    if (preg_match("/^group:(\\d+)\$/", $context, $m)) {
        // posting a new topic to a group
        $parent_id = $m[1];
        $parent_type = "collection";
        //FIXME: check that we can access the group.  or does MessageBoard do this?
    } else {
        if (preg_match("/^msg:(\\d+)\$/", $context, $m)) {
            // replying to an existing topic
            $parent_id = $m[1];
            $parent_type = "message";
            //FIXME: load parent, make sure it is a topic
            //FIXME: check if we are allowed to access this group
        } else {
            throw new PAException(INVALID_ID, "You can only post a message to a group or a topic.  Parent ID '{$context}' is not allowed.");
        }
    }
    // create topic
    $cat_obj = new MessageBoard();
    $cat_obj->set_parent($parent_id, $parent_type);
    $cat_obj->title = $title;
    $cat_obj->body = $body;
    $cat_obj->user_id = $user ? $user->user_id : NULL;
    $cat_obj->allow_anonymous = $allow_anon ? 1 : 0;
    $mid = $cat_obj->save($cat_obj->user_id);
    return array('success' => TRUE, 'id' => "msg:" . $mid);
}