/**
  * forum_categories
  *
  * Function that handles all the Admin Functions for Forum Categories
  *
  * @param string $action - action to take within function
  * @param int/string
  * @param int/string
  *
  */
 public function forum_categories($action = null, $id = null, $id2 = null)
 {
     // Get data for users
     $data['current_page'] = $_SERVER['REQUEST_URI'];
     $data['title'] = "Forum Categories";
     // Check to see if there is an action
     if ($action != null && $id != null) {
         // Check to see if action is edit
         if ($action == 'CatMainEdit') {
             // Check to make sure admin is trying to update
             if (isset($_POST['submit'])) {
                 // Check to make sure the csrf token is good
                 if (Csrf::isTokenValid()) {
                     if ($_POST['action'] == "update_cat_main_title") {
                         // Catch password inputs using the Request helper
                         $new_forum_title = Request::post('forum_title');
                         $prev_forum_title = Request::post('prev_forum_title');
                         if ($this->forum->updateCatMainTitle($prev_forum_title, $new_forum_title)) {
                             // Success
                             \Helpers\SuccessHelper::push('You Have Successfully Updated Forum Main Category Title to <b>' . $new_forum_title . '</b>', 'AdminPanel-Forum-Categories');
                         } else {
                             // Fail
                             $error[] = "Edit Forum Main Category Failed";
                         }
                     }
                 }
             } else {
                 // Get data for CatMainEdit Form
                 $data['edit_cat_main'] = true;
                 $data['data_cat_main'] = $this->forum->getCatMain($id);
                 $data['welcome_message'] = "You are about to Edit Selected Forum Main Category.";
                 // Setup Breadcrumbs
                 $data['breadcrumbs'] = "\n            <li><a href='" . DIR . "AdminPanel'><i class='glyphicon glyphicon-cog'></i> Admin Panel</a></li>\n            <li><a href='" . DIR . "AdminPanel-Forum-Categories'><i class='glyphicon glyphicon-list'></i> " . $data['title'] . "</a></li>\n            <li class='active'><i class='glyphicon glyphicon-pencil'></i> Edit Main Category</li>\n          ";
             }
         } else {
             if ($action == "CatMainUp") {
                 if ($this->forum->moveUpCatMain($id)) {
                     // Success
                     \Helpers\SuccessHelper::push('You Have Successfully Moved Up Forum Main Category', 'AdminPanel-Forum-Categories');
                 } else {
                     // Fail
                     $error[] = "Move Up Forum Main Category Failed";
                 }
             } else {
                 if ($action == "CatMainDown") {
                     if ($this->forum->moveDownCatMain($id)) {
                         // Success
                         \Helpers\SuccessHelper::push('You Have Successfully Moved Down Forum Main Category', 'AdminPanel-Forum-Categories');
                     } else {
                         // Fail
                         $error[] = "Move Down Forum Main Category Failed";
                     }
                 } else {
                     if ($action == 'CatMainNew') {
                         // Check to make sure admin is trying to update
                         if (isset($_POST['submit'])) {
                             // Check to make sure the csrf token is good
                             if (Csrf::isTokenValid()) {
                                 // Add new cate main title to database
                                 if ($_POST['action'] == "new_cat_main_title") {
                                     // Catch inputs using the Request helper
                                     $forum_title = Request::post('forum_title');
                                     // Get last order title number from db
                                     $last_order_num = $this->forum->getLastCatMain();
                                     // Attempt to add new Main Category Title to DB
                                     if ($this->forum->newCatMainTitle($forum_title, 'forum', $last_order_num)) {
                                         // Success
                                         \Helpers\SuccessHelper::push('You Have Successfully Created New Forum Main Category Title <b>' . $new_forum_title . '</b>', 'AdminPanel-Forum-Categories');
                                     } else {
                                         // Fail
                                         $error[] = "New Forum Main Category Failed";
                                     }
                                 }
                             }
                         }
                     } else {
                         if ($action == "CatSubList") {
                             // Check to make sure admin is trying to update
                             if (isset($_POST['submit'])) {
                                 // Check to make sure the csrf token is good
                                 if (Csrf::isTokenValid()) {
                                     // Add new cate main title to database
                                     if ($_POST['action'] == "new_cat_sub") {
                                         // Catch inputs using the Request helper
                                         $forum_title = Request::post('forum_title');
                                         $forum_cat = Request::post('forum_cat');
                                         $forum_des = Request::post('forum_des');
                                         // Check to see if we are adding to a new main cat
                                         if ($this->forum->checkSubCat($forum_title)) {
                                             // Get last cat sub order id
                                             $last_cat_order_id = $this->forum->getLastCatSub($forum_title);
                                             // Get forum order title id
                                             $forum_order_title = $this->forum->getForumOrderTitle($forum_title);
                                             // Run insert for new sub cat
                                             $run_sub_cat = $this->forum->newSubCat($forum_title, $forum_cat, $forum_des, $last_cat_order_id, $forum_order_title);
                                         } else {
                                             // Run update for new main cat
                                             $run_sub_cat = $this->forum->updateSubCat($id, $forum_cat, $forum_des);
                                         }
                                         // Attempt to update/insert sub cat in db
                                         if ($run_sub_cat) {
                                             // Success
                                             \Helpers\SuccessHelper::push('You Have Successfully Created Forum Sub Category', 'AdminPanel-Forum-Categories/CatSubList/' . $id);
                                         } else {
                                             // Fail
                                             $error[] = "Create Forum Sub Category Failed";
                                         }
                                     }
                                 }
                             } else {
                                 // Set goods for Forum Sub Categories Listing
                                 $data['cat_sub_list'] = true;
                                 $data['cat_main_title'] = $this->forum->getCatMain($id);
                                 $data['cat_sub_titles'] = $this->forum->getCatSubs($data['cat_main_title']);
                                 $data['fourm_cat_sub_last'] = $this->forum->getLastCatSub($data['cat_main_title']);
                                 $data['welcome_message'] = "You are viewing a complete list of sub categories for requeted main category.";
                                 // Setup Breadcrumbs
                                 $data['breadcrumbs'] = "\n            <li><a href='" . DIR . "AdminPanel'><i class='glyphicon glyphicon-cog'></i> Admin Panel</a></li>\n            <li><a href='" . DIR . "AdminPanel-Forum-Categories'><i class='glyphicon glyphicon-list'></i> " . $data['title'] . "</a></li>\n            <li class='active'><i class='glyphicon glyphicon-pencil'></i> Sub Categories List</li>\n          ";
                             }
                         } else {
                             if ($action == "CatSubEdit") {
                                 // Check to make sure admin is trying to update
                                 if (isset($_POST['submit'])) {
                                     // Check to make sure the csrf token is good
                                     if (Csrf::isTokenValid()) {
                                         // Add new cate main title to database
                                         if ($_POST['action'] == "edit_cat_sub") {
                                             // Catch inputs using the Request helper
                                             $forum_cat = Request::post('forum_cat');
                                             $forum_des = Request::post('forum_des');
                                             // Attempt to update sub cat in db
                                             if ($this->forum->updateSubCat($id, $forum_cat, $forum_des)) {
                                                 // Success
                                                 \Helpers\SuccessHelper::push('You Have Successfully Updated Forum Sub Category', 'AdminPanel-Forum-Categories/CatSubList/' . $id);
                                             } else {
                                                 // Fail
                                                 $error[] = "Update Forum Sub Category Failed";
                                             }
                                         }
                                     }
                                 } else {
                                     // Display Edit Forum for Selected Sub Cat
                                     $data['cat_sub_edit'] = true;
                                     $data['cat_sub_data'] = $this->forum->getCatSubData($id);
                                     $data['welcome_message'] = "You are about to edit requeted sub category.";
                                     // Setup Breadcrumbs
                                     $data['breadcrumbs'] = "\n            <li><a href='" . DIR . "AdminPanel'><i class='glyphicon glyphicon-cog'></i> Admin Panel</a></li>\n            <li><a href='" . DIR . "AdminPanel-Forum-Categories'><i class='glyphicon glyphicon-list'></i> " . $data['title'] . "</a></li>\n            <li><a href='" . DIR . "AdminPanel-Forum-Categories/CatSubList/{$id}'><i class='glyphicon glyphicon-list'></i> Sub Categories List</a></li>\n            <li class='active'><i class='glyphicon glyphicon-pencil'></i> Edit Sub Category</li>\n          ";
                                 }
                             } else {
                                 if ($action == "DeleteSubCat") {
                                     // Check to make sure admin is trying to update
                                     if (isset($_POST['submit'])) {
                                         // Check to make sure the csrf token is good
                                         if (Csrf::isTokenValid()) {
                                             // Add new cate main title to database
                                             if ($_POST['action'] == "delete_cat_sub") {
                                                 // Catch inputs using the Request helper
                                                 $delete_cat_sub_action = Request::post('delete_cat_sub_action');
                                                 // Get title basted on forum_id
                                                 $forum_title = $this->forum->getCatMain($id);
                                                 // Get title basted on forum_cat
                                                 $forum_cat = $this->forum->getCatSub($id);
                                                 // Check to see what delete function admin has selected
                                                 if ($delete_cat_sub_action == "delete_all") {
                                                     // Admin wants to delete Sub Cat and Everything Within it
                                                     // First we delete all related topic Replies
                                                     if ($this->forum->deleteTopicsForumID($id)) {
                                                         $success_count = $success_count + 1;
                                                     }
                                                     // Second we delete all topics
                                                     if ($this->forum->deleteTopicRepliesForumID($id)) {
                                                         $success_count = $success_count + 1;
                                                     }
                                                     // Finally we delete the main cat and all related sub cats
                                                     if ($this->forum->deleteCatForumID($id)) {
                                                         $success_count = $success_count + 1;
                                                     }
                                                     // Check to see if everything was deleted Successfully
                                                     if ($success_count > 0) {
                                                         // Success
                                                         \Helpers\SuccessHelper::push('You Have Successfully Deleted Sub Category: <b>' . $forum_title . ' > ' . $forum_cat . '</b> and Everything Within it!', 'AdminPanel-Forum-Categories');
                                                     }
                                                 } else {
                                                     // Extract forum_id from move_to_# string
                                                     $forum_id = str_replace("move_to_", "", $delete_cat_sub_action);
                                                     if (!empty($forum_id)) {
                                                         // First Update Topic Replies forum_id
                                                         if ($this->forum->updateTopicRepliesForumID($id, $forum_id)) {
                                                             $success_count = $success_count + 1;
                                                         }
                                                         // Second Update Topics forum_id
                                                         if ($this->forum->updateTopicsForumID($id, $forum_id)) {
                                                             $success_count = $success_count + 1;
                                                         }
                                                         // Last delete the sub Category
                                                         if ($this->forum->deleteCatForumID($id)) {
                                                             $success_count = $success_count + 1;
                                                         }
                                                         // Check to see if anything was done
                                                         if ($success_count > 0) {
                                                             // Success
                                                             \Helpers\SuccessHelper::push('You Have Successfully Moved Main Category From <b>' . $old_forum_title . '</b> to <b>' . $new_forum_title . '</b>', 'AdminPanel-Forum-Categories/CatSubList/' . $forum_id);
                                                         }
                                                     } else {
                                                         // User has not selected to delete or move main cat
                                                         \Helpers\ErrorHelper::push('No Action Selected.  No actions executed.', 'AdminPanel-Forum-Categories/DeleteSubCat/' . $id);
                                                     }
                                                 }
                                             }
                                         }
                                     } else {
                                         // Display Delete Cat Sub Form
                                         $data['delete_cat_sub'] = true;
                                         // Get list of all sub cats except current
                                         $data['list_all_cat_sub'] = $this->forum->catSubListExceptSel($id);
                                         // Setup Breadcrumbs
                                         $data['breadcrumbs'] = "\n            <li><a href='" . DIR . "AdminPanel'><i class='glyphicon glyphicon-cog'></i> Admin Panel</a></li>\n            <li><a href='" . DIR . "AdminPanel-Forum-Categories'><i class='glyphicon glyphicon-list'></i> " . $data['title'] . "</a></li>\n            <li><a href='" . DIR . "AdminPanel-Forum-Categories/CatSubList/" . $id . "'><i class='glyphicon glyphicon-list'></i> Sub Categories List</a></li>\n            <li class='active'><i class='glyphicon glyphicon-pencil'></i> Delete Sub Category</li>\n          ";
                                     }
                                 } else {
                                     if ($action == "CatSubUp") {
                                         // Get forum_title for cat
                                         $data['cat_main_title'] = $this->forum->getCatMain($id);
                                         // Try to move up
                                         if ($this->forum->moveUpCatSub($data['cat_main_title'], $id2)) {
                                             // Success
                                             \Helpers\SuccessHelper::push('You Have Successfully Moved Up Forum Sub Category', 'AdminPanel-Forum-Categories/CatSubList/' . $id);
                                         } else {
                                             // Fail
                                             $error[] = "Move Up Forum Main Category Failed";
                                         }
                                     } else {
                                         if ($action == "CatSubDown") {
                                             // Get forum_title for cat
                                             $data['cat_main_title'] = $this->forum->getCatMain($id);
                                             // Try to move down
                                             if ($this->forum->moveDownCatSub($data['cat_main_title'], $id2)) {
                                                 // Success
                                                 \Helpers\SuccessHelper::push('You Have Successfully Moved Down Forum Sub Category', 'AdminPanel-Forum-Categories/CatSubList/' . $id);
                                             } else {
                                                 // Fail
                                                 $error[] = "Move Down Forum Main Category Failed";
                                             }
                                         } else {
                                             if ($action == "DeleteMainCat") {
                                                 // Check to make sure admin is trying to update
                                                 if (isset($_POST['submit'])) {
                                                     // Check to make sure the csrf token is good
                                                     if (Csrf::isTokenValid()) {
                                                         // Add new cate main title to database
                                                         if ($_POST['action'] == "delete_cat_main") {
                                                             // Catch inputs using the Request helper
                                                             $delete_cat_main_action = Request::post('delete_cat_main_action');
                                                             // Get title basted on forum_id
                                                             $forum_title = $this->forum->getCatMain($id);
                                                             // Check to see what delete function admin has selected
                                                             if ($delete_cat_main_action == "delete_all") {
                                                                 // Admin wants to delete Main Cat and Everything Within it
                                                                 // Get list of all forum_id's for this Main Cat
                                                                 $forum_id_all = $this->forum->getAllForumTitleIDs($forum_title);
                                                                 $success_count = "0";
                                                                 if (isset($forum_id_all)) {
                                                                     foreach ($forum_id_all as $row) {
                                                                         // First we delete all related topic Replies
                                                                         if ($this->forum->deleteTopicsForumID($row->forum_id)) {
                                                                             $success_count = $success_count + 1;
                                                                         }
                                                                         // Second we delete all topics
                                                                         if ($this->forum->deleteTopicRepliesForumID($row->forum_id)) {
                                                                             $success_count = $success_count + 1;
                                                                         }
                                                                         // Finally we delete the main cat and all related sub cats
                                                                         if ($this->forum->deleteCatForumID($row->forum_id)) {
                                                                             $success_count = $success_count + 1;
                                                                         }
                                                                     }
                                                                 }
                                                                 if ($success_count > 0) {
                                                                     // Success
                                                                     \Helpers\SuccessHelper::push('You Have Successfully Deleted Main Category: <b>' . $forum_title . '</b> and Everything Within it!', 'AdminPanel-Forum-Categories');
                                                                 }
                                                             } else {
                                                                 // Extract forum_id from move_to_# string
                                                                 $forum_id = str_replace("move_to_", "", $delete_cat_main_action);
                                                                 if (!empty($forum_id)) {
                                                                     // Get new and old forum titles
                                                                     $new_forum_title = $this->forum->getCatMain($forum_id);
                                                                     $old_forum_title = $this->forum->getCatMain($id);
                                                                     // Get forum_order_title id for forum_title we are moving to
                                                                     $new_forum_order_title = $this->forum->getForumOrderTitle($new_forum_title);
                                                                     // Get last order id for new forum_title we are moving to
                                                                     $new_forum_order_cat = $this->forum->getLastCatSub($new_forum_title);
                                                                     // Update with the new forum title from the old one
                                                                     if ($this->forum->moveForumSubCat($old_forum_title, $new_forum_title, $new_forum_order_title, $new_forum_order_cat)) {
                                                                         // Success
                                                                         \Helpers\SuccessHelper::push('You Have Successfully Moved Main Category From <b>' . $old_forum_title . '</b> to <b>' . $new_forum_title . '</b>', 'AdminPanel-Forum-Categories/CatSubList/' . $forum_id);
                                                                     }
                                                                 } else {
                                                                     // User has not selected to delete or move main cat
                                                                     \Helpers\ErrorHelper::push('No Action Selected.  No actions executed.', 'AdminPanel-Forum-Categories/DeleteMainCat/' . $id);
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 } else {
                                                     // Show delete options for main cat
                                                     $data['delete_cat_main'] = true;
                                                     $data['welcome_message'] = "You are about to delete requested main category.  Please proceed with caution.";
                                                     // Get title for main cat admin is about to delete
                                                     $data['delete_cat_main_title'] = $this->forum->getCatMain($id);
                                                     // Get all other main cat titles
                                                     $data['list_all_cat_main'] = $this->forum->catMainListExceptSel($data['delete_cat_main_title']);
                                                     // Setup Breadcrumbs
                                                     $data['breadcrumbs'] = "\n            <li><a href='" . DIR . "AdminPanel'><i class='glyphicon glyphicon-cog'></i> Admin Panel</a></li>\n            <li><a href='" . DIR . "AdminPanel-Forum-Categories'><i class='glyphicon glyphicon-list'></i> " . $data['title'] . "</a></li>\n            <li class='active'><i class='glyphicon glyphicon-pencil'></i> Delete Main Category</li>\n          ";
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         // Get data for main categories
         $data['cat_main'] = $this->forum->catMainList();
         // Welcome message
         $data['welcome_message'] = "You are viewing a complete list of main categories.";
         // Setup Breadcrumbs
         $data['breadcrumbs'] = "\n        <li><a href='" . DIR . "AdminPanel'><i class='glyphicon glyphicon-cog'></i> Admin Panel</a></li>\n        <li class='active'><i class='glyphicon glyphicon-list'></i> " . $data['title'] . "</li>\n      ";
     }
     // Get Last main cat order number
     $data['fourm_cat_main_last'] = $this->forum->getLastCatMain();
     // Setup CSRF token
     $data['csrf_token'] = Csrf::makeToken();
     View::renderModule('AdminPanel/views/header', $data);
     View::renderModule('AdminPanel/views/forum_categories', $data, $error, $success);
     View::renderModule('AdminPanel/views/footer', $data);
 }
Example #2
0
 public function newmessage($to_user = NULL)
 {
     // Check if user is logged in
     if ($this->auth->isLoggedIn()) {
         // Get Current User's ID
         $u_id = $this->auth->user_info();
     } else {
         Url::redirect();
     }
     // Check to see if user is over quota
     // Disable New Message Form is they are
     if ($this->model->checkMessageQuota($u_id)) {
         // user is over limit, disable new message form
         $data['hide_form'] = "true";
         $error[] = "<span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span>\n                  <b>Your Outbox is Full!</b>  You Can NOT send any messages!";
     }
     // Check to make sure user is trying to send new message
     if (isset($_POST['submit'])) {
         // Check to make sure the csrf token is good
         if (Csrf::isTokenValid()) {
             // Get data from post
             $to_username = Request::post('to_username');
             $subject = Request::post('subject');
             $content = Request::post('content');
             $reply = Request::post('reply');
             // Check to see if this is coming from a reply button
             if ($reply != "true") {
                 // Check to make sure user completed all required fields in form
                 if (empty($to_username)) {
                     // Username field is empty
                     $error[] = 'Username Field is Blank!';
                 }
                 if (empty($subject)) {
                     // Subject field is empty
                     $error[] = 'Subject Field is Blank!';
                 }
                 if (empty($content)) {
                     // Username field is empty
                     $error[] = 'Message Content Field is Blank!';
                 }
                 // Check for errors before sending message
                 if (count($error) == 0) {
                     // Get the userID of to username
                     $to_userID = $this->model->getUserIDFromUsername($to_username);
                     // Check to make sure user exists in Database
                     if (isset($to_userID)) {
                         // Check to see if to user's inbox is not full
                         if ($this->model->checkMessageQuotaToUser($to_userID)) {
                             // Run the Activation script
                             if ($this->model->sendmessage($to_userID, $u_id, $subject, $content)) {
                                 // Success
                                 SuccessHelper::push('You Have Successfully Sent a Private Message', 'Messages');
                                 $data['hide_form'] = "true";
                             } else {
                                 // Fail
                                 $error[] = 'Message Send Failed';
                             }
                         } else {
                             // To user's inbox is full.  Let sender know message was not sent
                             $error[] = '<b>${to_username}&#39;s Inbox is Full!</b>  Sorry, Message was NOT sent!';
                         }
                     } else {
                         // User does not exist
                         $error[] = 'Message Send Failed - To User Does Not Exist';
                     }
                 }
                 // End Form Complete Check
             } else {
                 // Get data from reply $_POST
                 $subject = Request::post('subject');
                 $content = Request::post('content');
                 $date_sent = Request::post('date_sent');
                 // Add Reply details to subject ex: RE:
                 $data['subject'] = "RE: " . $subject;
                 // Clean up content so it looks pretty
                 $content_reply = "&#10;&#10;&#10;&#10; ##########";
                 $content_reply .= "&#10; # PREVIOUS MESSAGE";
                 $content_reply .= "&#10; # From: {$to_username}";
                 $content_reply .= "&#10; # Sent: {$date_sent} ";
                 $content_reply .= "&#10; ########## &#10;&#10;";
                 $content_reply .= $content;
                 $content_reply = str_replace("<br />", " ", $content_reply);
                 $data['content'] = $content_reply;
             }
             // End Reply Check
         }
     }
     // Check to see if there were any errors, if so then auto load form data
     if (count($error) > 0) {
         // Auto Fill form to make things eaiser for user
         $data['subject'] = Request::post('subject');
         $data['content'] = Request::post('content');
     }
     // Collect Data for view
     $data['title'] = "My Private Message";
     $data['welcome_message'] = "Welcome to Your Private Message Creator";
     $data['csrf_token'] = Csrf::makeToken();
     // Check to see if username is in url or post
     if (isset($to_user)) {
         $data['to_username'] = $to_user;
     } else {
         $data['to_username'] = Request::post('to_username');
     }
     // Setup Breadcrumbs
     $data['breadcrumbs'] = "\n\t\t\t<li><a href='" . DIR . "'>Home</a></li>\n\t\t\t<li><a href='" . DIR . "Messages'>Private Messages</a></li>\n\t\t\t<li class='active'>" . $data['title'] . "</li>\n\t\t";
     // Get requested message data
     //$data['message'] = $this->model->getMessage($m_id);
     // Check for new messages in inbox
     $data['new_messages_inbox'] = $this->model->getUnreadMessages($u_id);
     // Send data to view
     View::renderTemplate('header', $data);
     View::renderModule('Messages/views/messages_sidebar', $data);
     View::renderModule('Messages/views/message_new', $data, $error, $success);
     View::renderTemplate('footer', $data);
 }
<?php

// Message New Displays form for user to create a new message to send
// Also works with message reply
use Core\Language, Helpers\ErrorHelper, Helpers\SuccessHelper, Core\Error, Helpers\Form;
?>

<div class='col-lg-8 col-md-8'>

  <?php 
// Display Success and Error Messages if any (TODO: Move to header file)
echo ErrorHelper::display();
echo SuccessHelper::display();
echo ErrorHelper::display_raw($error);
echo SuccessHelper::display_raw($success);
?>

	<div class='panel panel-default'>
		<div class='panel-heading'>
			<h3 class='jumbotron-heading'><?php 
echo $data['title'];
?>
</h3>
		</div>
		<div class='panel-body'>
			<p><?php 
echo $data['welcome_message'];
?>
</p>

<?php 
Example #4
0
 public function newtopic($id)
 {
     // Check if user is logged in
     if ($this->auth->isLoggedIn()) {
         // Get Current User's ID
         $u_id = $this->auth->user_info();
     } else {
         //Url::redirect();
     }
     // Output Current User's ID
     $data['current_userID'] = $u_id;
     // Get Requested Topic's Title and Description
     $data['forum_cat'] = $this->model->forum_cat($id);
     $data['forum_cat_des'] = $this->model->forum_cat_des($id);
     $data['forum_topics'] = $this->model->forum_topics($id);
     // Ouput Page Title
     $data['title'] = "New Topic for " . $data['forum_cat'];
     // Output Welcome Message
     $data['welcome_message'] = "Welcome to the new topic page.";
     // Check to see if current user is a new user
     $data['is_new_user'] = $this->auth->checkIsNewUser($u_id);
     // Check to see if user is submitting a new topic
     if (isset($_POST['submit'])) {
         // Check to make sure the csrf token is good
         if (Csrf::isTokenValid()) {
             // Get data from post
             $data['forum_title'] = strip_tags(Request::post('forum_title'));
             $data['forum_content'] = strip_tags(Request::post('forum_content'));
             // Check to make sure user completed all required fields in form
             if (empty($data['forum_title'])) {
                 // Username field is empty
                 $error[] = 'Topic Title Field is Blank!';
             }
             if (empty($data['forum_content'])) {
                 // Subject field is empty
                 $error[] = 'Topic Content Field is Blank!';
             }
             // Check for errors before sending message
             if (count($error) == 0) {
                 // No Errors, lets submit the new topic to db
                 $new_topic = $this->model->sendTopic($u_id, $id, $data['forum_title'], $data['forum_content']);
                 if ($new_topic) {
                     // New Topic Successfully Created Now Check if User is Uploading Image
                     // Check for image upload with this topic
                     $picture = file_exists($_FILES['forumImage']['tmp_name']) || is_uploaded_file($_FILES['forumImage']['tmp_name']) ? $_FILES['forumImage'] : array();
                     // Make sure image is being uploaded before going further
                     if (sizeof($picture) > 0 && $data['is_new_user'] != true) {
                         // Get image size
                         $check = getimagesize($picture['tmp_name']);
                         // Get file size for db
                         $file_size = $picture['size'];
                         // Make sure image size is not too large
                         if ($picture['size'] < 5000000 && $check && ($check['mime'] == "image/jpeg" || $check['mime'] == "image/png" || $check['mime'] == "image/gif")) {
                             if (!file_exists('images/forum-pics')) {
                                 mkdir('images/forum-pics', 0777, true);
                             }
                             // Upload the image to server
                             $image = new SimpleImage($picture['tmp_name']);
                             $new_image_name = "forum-image-topic-uid{$u_id}-fid{$id}-ftid{$new_topic}";
                             $dir = 'images/forum-pics/' . $new_image_name . '.gif';
                             $image->best_fit(400, 300)->save($dir);
                             $forumImage = $dir;
                             var_dump($forumImage);
                             // Make sure image was Successfull
                             if ($forumImage) {
                                 // Add new image to database
                                 if ($this->model->sendNewImage($u_id, $new_image_name, $dir, $file_size, $id, $new_topic)) {
                                     $img_success = "<br> Image Successfully Uploaded";
                                 } else {
                                     $img_success = "<br> No Image Uploaded";
                                 }
                             }
                         } else {
                             $img_success = "<br> Image was NOT uploaded because the file size was too large!";
                         }
                     }
                     // Success
                     SuccessHelper::push('You Have Successfully Created a New Topic' . $img_success, 'Topic/' . $new_topic);
                     $data['hide_form'] = "true";
                 } else {
                     // Fail
                     $error[] = 'New Topic Create Failed';
                 }
             }
             // End Form Complete Check
         }
     }
     // Get Recent Posts List for Sidebar
     $data['forum_recent_posts'] = $this->model->forum_recent_posts();
     // Setup Breadcrumbs
     $data['breadcrumbs'] = "\n  \t\t\t<li><a href='" . DIR . "'>Home</a></li>\n        <li><a href='" . DIR . "Forum'>" . $this->forum_title . "</a></li>\n        <li><a href='" . DIR . "Topics/{$id}'>" . $data['forum_cat'] . "</a>\n  \t\t\t<li class='active'>" . $data['title'] . "</li>\n  \t\t";
     // Ready the token!
     $data['csrf_token'] = Csrf::makeToken();
     // Send data to view
     View::renderTemplate('header', $data);
     View::renderModule('Forum/views/newtopic', $data, $error, $success);
     View::renderModule('Forum/views/forum_sidebar', $data);
     View::renderTemplate('footer', $data);
 }