if (empty($is_member)) { $failure_msg = 'Please join this group to perform any activity'; } else { $return_variable = create_forum_topic($_form); $failure_msg = $return_variable['msg']['failure_msg']; $succss_msg = $return_variable['msg']['success_msg']; } $redirect_url = "forum_home.php"; $query_str = "?gid=" . $parent_id; } if ($_form['opertion'] == 'edit') { $gid = (int) $_form['gid']; $mid = (int) $_form['mid']; $group_data = ContentCollection::load_collection((int) $gid, $login_uid); $cat_obj = new MessageBoard(); $edit_data = $cat_obj->get_by_id($mid); $params['action'] = 'edit_forum'; $params['group_owner'] = $group_data->author_id; $params['forum_owner'] = $edit_data['user_id']; if (!user_can($params)) { $failure_msg = 'You are not authorized to edit forum'; } else { $return_variable = edit_forum_topic($_form); $failure_msg = $return_variable['msg']['failure_msg']; $succss_msg = $return_variable['msg']['success_msg']; } $redirect_url = "forum_messages.php"; $query_str = "?mid={$mid}&ccid=" . $parent_id; } // Here we call the function $msg_array = array();
/** This function is used for loading the information from the get variables Usage:on forum page for message board **/ function load_info() { $request_info = array(); if (!empty($_REQUEST['gid'])) { $request_info['parent_id'] = $_REQUEST['gid']; $request_info['parent_name_hidden'] = 'gid'; $request_info['parent_type'] = PARENT_TYPE_COLLECTION; $obj = new Group(); $obj->load($_REQUEST['gid']); $request_info['header_title'] = stripslashes($obj->title); } else { if (!empty($_REQUEST['mid'])) { $request_info['parent_id'] = $_REQUEST['mid']; $request_info['parent_name_hidden'] = 'mid'; $request_info['parent_type'] = PARENT_TYPE_MESSAGE; $obj = new MessageBoard(); $data = $obj->get_by_id($_REQUEST['mid']); $request_info['header_title'] = stripslashes($data['title']); } else { if (!empty($_REQUEST['cid'])) { $content = Content::load_content((int) $_REQUEST['cid'], (int) PA::$login_uid); $ccid = $content->parent_collection_id; if ($ccid != 0 && $ccid != -1) { //here parent collection 0 is for deleted content and -1 is for home page routed thus checking that its not a group id $content_collection = ContentCollection::load_collection((int) $ccid, PA::$login_uid); if ($content_collection->type == GROUP_COLLECTION_TYPE) { $request_info['parent_id'] = $ccid; $request_info['parent_name_hidden'] = 'gid'; $request_info['parent_type'] = PARENT_TYPE_COLLECTION; } } } else { return false; } } } return $request_info; }
MessageBoard::delete_all_in_parent($mid, PARENT_TYPE_MESSAGE); } catch (Exception $e) { // catch if delete is fail } $location = $_SERVER['HTTP_REFERER']; header("Location: {$location}"); exit; } } else { // When User wants to delete repllies of forum $mid = $_GET['mid']; $params['action'] = 'delete_rep'; // fiding the parent for the replly $request_info = load_info(); $msg = new MessageBoard(); $rep_details = $msg->get_by_id($_REQUEST['mid']); $cond_array = array('boardmessage_id' => $request_info['parent_id']); $forum_detail = MessageBoard::get_forums($cond_array); $owner = Group::get_admin_id($_REQUEST['ccid']); $params['forum_owner'] = $forum_detail[0]->user_id; $params['rep_owner'] = $rep_details['user_id']; $params['group_owner'] = $owner['user_id']; if (user_can($params)) { try { MessageBoard::delete($mid); } catch (Exception $e) { // catch if delete is fail } $location = $_SERVER['HTTP_REFERER']; header("Location: {$location}"); exit;