<?php
/**
 * View all forum created
 *
 * PHP version 5.0
 *
 * @category	###Anova###
 * @package		###Forum###
 * @author 		shankar_76ag08
 * @copyright	Copyright (c) 2009 {@link http://www.agriya.com Agriya Infoway}
 * @license		http://www.agriya.com Agriya Infoway Licence
 * @version		SVN: $Id:
 * @since 		2008-12-22
 **/
require_once('../../common/configs/config.inc.php');
$CFG['lang']['include_files'][] = 'languages/%s/'.$CFG['admin']['index']['forum_module'].'/admin/forums.php';
$CFG['lang']['include_files'][] = 'languages/%s/common/email_notify.inc.php';
$CFG['html']['header'] = 'admin/html_header.php';
$CFG['html']['footer'] = 'admin/html_footer.php';
$CFG['lang']['include_files'][] = 'languages/%s/lists_array/months_list_array.inc.php';
//$CFG['lang']['include_files'][] = 'common/configs/anova_configs/config_forums.inc.php';
$CFG['mods']['include_files'][] = 'common/classes/class_ListRecordsHandler.lib.php';
$CFG['mods']['include_files'][] = 'common/classes/class_AnovaHandler.lib.php';

if ($_POST)
	$CFG['mods']['include_files'][] = 'common/classes/swiftmailer/lib/EasySwift.php';
//compulsory
$CFG['site']['is_module_page']='forums';
$CFG['mods']['is_include_only']['html_header'] = false;
$CFG['html']['is_use_header'] = false;
/**
 * File to include the header file, database access file, session management file, help file and necessary functions
 */
require_once($CFG['site']['project_path'].'common/application_top.inc.php');
class ForumsFormHandler extends AnovaHandler
	{
		/**
		 * set the condition
		 *
		 * @access public
		 * @return void
		 **/
		public function buildConditionQuery($condition='')
			{
				$this->sql_condition = $condition;
			}

		/**
		 * To sort the query
		 *
		 * @access public
		 * @return void
		 **/
		public function buildSortQuery()
			{
				$this->sql_sort = $this->fields_arr['orderby_field'].' '.$this->fields_arr['orderby'];
			}

		/**
		 * To active all forum titles, forum topics, responses
		 *
		 * @access public
		 * @return void
		 **/
		public function activeForumTitles()
			{
				$forum_ids = $this->fields_arr['forum_ids'];
				$sql = 'UPDATE '.$this->CFG['db']['tbl']['forums'].' SET forum_status = \'Yes\' '.
						'WHERE forum_id IN ('.$forum_ids.') AND forum_status = \'No\'';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
					trigger_db_error($this->dbObj);

				return true;
			}

		/**
		 * To inactive all forum titles, forum topics, responses
		 *
		 * @access public
		 * @return void
		 **/
		public function inactiveForumTitles()
			{
				$forum_ids = $this->fields_arr['forum_ids'];
				$sql = 'UPDATE '.$this->CFG['db']['tbl']['forums'].' SET forum_status = \'No\' '.
						'WHERE forum_id IN ('.$forum_ids.') AND forum_status = \'Yes\'';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
			    	trigger_db_error($this->dbObj);

				return true;
			}

		/**
		 * To inactive all forum titles, forum topics, responses
		 *
		 * @access public
		 * @return void
		 **/
		public function publishForumTitles()
			{
				$forum_ids = $this->fields_arr['forum_ids'];
				$sql = 'SELECT '.$this->getUserTableField('display_name').
					' as display_name, '.$this->getUserTableField('email').' as email'.
					', f.forum_id, f.forum_title, f.seo_title, f.forum_description'.
					' FROM '.$this->CFG['db']['tbl']['forums'].
					' as f LEFT JOIN '.$this->CFG['db']['tbl']['users'].' AS u '.
					' ON f.forum_userid = u.'.$this->CFG['users']['user_id'].
					' WHERE forum_status=\'ToActivate\' AND forum_id IN('.$forum_ids.')';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
					trigger_db_error($this->dbObj);

				while($row = $rs->FetchRow())
					{
						$this->sendPublishedMailAlert($row['email'], $row['display_name'], $row['forum_title'], $row['seo_title'], $row['forum_description']);
					}
				$sql = 'UPDATE '.$this->CFG['db']['tbl']['forums'].' SET forum_status = \'Yes\' '.
						'WHERE forum_id IN ('.$forum_ids.') AND forum_status = \'ToActivate\'';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
					trigger_db_error($this->dbObj);

				return true;
			}

		/**
		 * ForumsFormHandler::sendPublishedMailAlert()
		 *
		 * @param mixed $toEmail
		 * @param mixed $reciever_name
		 * @param mixed $content
		 * @param mixed $content_seo
		 * @param mixed $content_description
		 * @return
		 */
		public function sendPublishedMailAlert($toEmail, $reciever_name, $content, $content_seo, $content_description)
			{
				$site_link = "<a target=\"_blank\" href=\"".URL($this->CFG['site']['url'])."\">".URL($this->CFG['site']['url'])."</a>";
				$url_link = getUrl('forumstopics', '?title='.$content_seo, $content_seo.'/', 'root');
				$forum_link = "<a target=\"_blank\" href=\"".$url_link."\"><strong>".$content."</strong></a>";
				$subject = $this->getMailContent($this->LANG['forum_publish_subject'], array('VAR_USERNAME'=>$reciever_name, 'VAR_SITENAME'=>$this->CFG['site']['name'], 'VAR_DESCRIPTION_OF_FORUM'=>$content_description, 'VAR_FORUM'=>$forum_link, 'VAR_LINK'=>$site_link));
				$content = $this->getMailContent($this->LANG['forum_publish_message'], array('VAR_USERNAME'=>$reciever_name, 'VAR_SITENAME'=>$this->CFG['site']['name'], 'VAR_DESCRIPTION_OF_FORUM'=>$content_description, 'VAR_FORUM'=>$forum_link, 'VAR_LINK'=>$site_link));
				$this->_sendMail($toEmail, $subject, $content, $this->CFG['site']['noreply_name'], $this->CFG['site']['noreply_email']);
			}

		/**
		 * ForumsFormHandler::_sendMail()
		 *
		 * @param mixed $to_email
		 * @param mixed $subject
		 * @param mixed $body
		 * @param mixed $sender_name
		 * @param mixed $sender_email
		 * @return
		 */
		private function _sendMail($to_email, $subject, $body, $sender_name, $sender_email)
			{
				$this->buildEmailTemplate($subject, $body, false, true);
				$EasySwift = new EasySwift($this->getSwiftConnection());
				$EasySwift->flush();
				$EasySwift->addPart($this->getEmailContent(), "text/html");
				$from_address = $sender_name.'<'.$sender_email.'>';
				return $EasySwift->send($to_email, $from_address, $this->getEmailSubject());
			}
		/**
		 * To delete all forum titles, forum topics, responses
		 *
		 * @access public
		 * @return void
		 **/
		public function deleteForumTitles()
			{
				$forum_ids = $this->fields_arr['forum_ids'];
				$this->deleteForumsTable($forum_ids); //
			}

		/**
		 * To delete from forum_response table
		 *
		 * @param integer $topic_id
		 * @access public
		 * @return void
		 **/
		public function deleteForumResponseTable($topic_ids)
			{
				$sql = 'DELETE FROM '.$this->CFG['db']['tbl']['forum_response'].' '.
						'WHERE topic_id IN ('.$topic_ids.') ';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
					trigger_db_error($this->dbObj);

				return true;
			}

		/**
		 * To delete from forum_topics table
		 *
		 * @param integer $forum_id
		 * @access public
		 * @return void
		 **/
		public function deleteForumTopicsTable($forum_ids)
			{
				$sql = 'SELECT topic_id '.
						'FROM '.$this->CFG['db']['tbl']['forum_topics'].' '.
						'WHERE forum_id IN ('.$forum_ids.') ';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
					trigger_db_error($this->dbObj);

				$topic_ids = 0;
				while($row = $rs->FetchRow())
					{
						 ($topic_ids)? $topic_ids = $topic_ids.', '.$row['topic_id'] : $topic_ids = $row['topic_id'];
					} // while
				if ($topic_ids)
					$this->deleteForumResponseTable($topic_ids);
				$sql = 'DELETE FROM '.$this->CFG['db']['tbl']['forum_topics'].' '.
						'WHERE forum_id IN ('.$forum_ids.') ';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
				        trigger_db_error($this->dbObj);

				return true;
			}
		/**
		 * To delete from groups_users table
		 *
		 * @param integer $group_id
		 * @access public
		 * @return void
		 **/
		public function deleteForumsTable($forum_ids)
			{
				$this->deleteForumTopicsTable($forum_ids);

				$sql = 'DELETE FROM '.$this->CFG['db']['tbl']['forums'].' '.
						'WHERE forum_id IN ('.$forum_ids.') ';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
				        trigger_db_error($this->dbObj);

				return true;
			}

		/**
		 * To get forum ids of given topic ids
		 *
		 * @param string $search_value
		 * @access public
		 * @return void
		 **/
		public function getForumIds($column_name, $search_value)
			{
				$sql = 'SELECT DISTINCT(forum_id) FROM '.$this->CFG['db']['tbl']['forum_topics'].' WHERE ';
				$condition = $column_name.' LIKE \'%'.addslashes($search_value).'%\'';
				if ($column_name == 'topic_id') {
				  	$condition = $column_name.' IN ('.$search_value.')';
				}
				$sql .= $condition;

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
					trigger_db_error($this->dbObj);

				$forum_ids = 0;
				while($row = $rs->FetchRow())
					{
						$forum_ids .= ', '.$row['forum_id'];
					}
				return $forum_ids;
			}

		/**
		 * To get forum ids of given topic ids
		 *
		 * @param string $search_value
		 * @access public
		 * @return void
		 **/
		public function getTopicIds($search_value)
			{
				$sql = 'SELECT DISTINCT(topic_id) AS topic_id FROM '.$this->CFG['db']['tbl']['forum_response'].' WHERE '.
						'forum_response LIKE \'%'.addslashes($search_value).'%\' ';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
				        trigger_db_error($this->dbObj);

				$topic_ids = 0;
				while($row = $rs->FetchRow())
					{
						$topic_ids .= ', '.$row['topic_id'];
					}
				return $topic_ids;
			}

		/**
		 * To display the forums titles
		 *
		 * @access public
		 * @return void
		 **/
		public function showForumTitles()
			{
				if(!$this->isResultsFound())
					{
						return ;
					}
				$showForumTitles_arr = array();
				$inc = 1;
				while($row = $this->fetchResultRecord())
					{
						$userDetails = $row;
						if($row['last_post_user_id'] != '')
							$userDetails['user_id'] = $row['last_post_user_id'];
						else
							$userDetails['user_id'] = $row['user_id'];
						$showForumTitles_arr[$inc]['record'] = $row;
						$showForumTitles_arr[$inc]['userDetails'] = $userDetails;
						$showForumTitles_arr[$inc]['checkbox_checked'] = '';
						if((is_array($this->fields_arr['forum_ids'])) && (in_array($row['forum_id'], $this->fields_arr['forum_ids'])))
							$showForumTitles_arr[$inc]['checkbox_checked'] = "CHECKED";
						$showForumTitles_arr[$inc]['row_forum_title_manual'] = wordWrapManual($row['forum_title'], 15);
						$showForumTitles_arr[$inc]['row_forum_description_manual'] = nl2br(wordWrapManual($row['forum_description'], 15));
						$showForumTitles_arr[$inc]['display_name_manual'] = stripString($userDetails['display_name'], $this->CFG['username']['short_length']);
						$inc++;
					}
				return $showForumTitles_arr;
			}
	}
//<<<<<<<--------------class ForumsFormHandler---------------//
//--------------------Code begins-------------->>>>>//
$forums = new ForumsFormHandler();
$forums->left_navigation_div = 'forumsForums';
$forums->setPageBlockNames(array('form_show_forums', 'form_search', 'form_confirm', 'form_search'));
$forums->setAllPageBlocksHide();
//default form fields and values...
$forums->setFormField('forum_ids', array());
$forums->setFormField('srch', '');
$forums->setFormField('numpg',0);
$forums->setFormField('start',0);
$forums->setFormField('action', '');
$forums->setFormField('srch_title', '');
$forums->setFormField('srch_topic', '');
$forums->setFormField('srch_topic_cnt', '');
$forums->setFormField('topic_condition', '');
$forums->setFormField('srch_response', '');
$forums->setFormField('srch_response_cnt', '');
$forums->setFormField('response_condition', '');
$forums->setFormField('srch_uname', '');
$forums->setFormField('srch_status', '');
$forums->setFormField('status_active', '');
$forums->setFormField('status_inactive', '');
$forums->setFormField('srch_date_added', '');
$forums->setFormField('srch_date', '');
$forums->setFormField('srch_month', '');
$forums->setFormField('srch_year', '');
$forums->setFormField('msg', '');
$condition_operators = array('equalto', 'greaterthan', 'greaterthanequal', 'lessthan', 'lessthanequal', 'notequal');
$operators_arr = array('equalto' => "=", 'greaterthan' => ">", 'greaterthanequal' => ">=", 'lessthan' => "<", 'lessthanequal' => "<=", 'notequal' => "!=");
$forums->populateConditionOperators_arr = array("equalto" => $LANG['forumsearch_equal_to'], "greaterthan" => $LANG['forumsearch_greater_than'],
											"greaterthanequal" => $LANG['forumsearch_greater_than_equal'], "lessthan" => $LANG['forumsearch_less_than'],
											"lessthanequal" => $LANG['forumsearch_less_than_equal'], "notequal" => $LANG['forumsearch_not_equal']);
$forums->setMonthsListArr($LANG_LIST_ARR['months']);
/***********set form field for navigation****/
$forums->setFormField('orderby_field', 'forum_title');
$forums->setFormField('orderby', 'ASC');
/*************Start navigation******/
//fetch number of records show in the result--numpg
$condition = '';
$forums->numpg = $CFG['data_tbl']['numpg'];
$forums->setFormField('start', 0);
$forums->setFormField('numpg', $CFG['data_tbl']['numpg']); //$CFG['data_tbl']['numpg']
$forums->setMinRecordSelectLimit($CFG['data_tbl']['min_record_select_limit']);
$forums->setMaxRecordSelectLimit($CFG['data_tbl']['max_record_select_limit']);
$forums->setNumPerPageListArr($CFG['data_tbl']['numperpage_list_arr']);
//Set tables and fields to return
$forums->setTableNames(array());
$forums->setReturnColumns(array());
/*************End navigation******/
$forums->sanitizeFormInputs($_REQUEST);

if ($forums->isFormGETed($_GET, 'msg'))
	{
		if($forums->getFormField('msg') == 'edit_success')
			{
				$forums->setPageBlockShow('block_msg_form_success');
				$forums->setCommonSuccessMsg($LANG['forums_edited_successfully']);
			}
		else
			{
				$forums->setPageBlockShow('block_msg_form_success');
				$forums->setCommonSuccessMsg($LANG['forums_addded_successfully']);
			}
	}
if ($forums->isFormGETed($_REQUEST))
	{
		$forums->getFormField('srch_topic_cnt')and
			$forums->chkIsNumeric('srch_topic_cnt', $LANG['forums_err_tip_enter_numbers']);
		$forums->getFormField('srch_response_cnt')and
			$forums->chkIsNumeric('srch_response_cnt', $LANG['forums_err_tip_enter_numbers']);
	}
if ($forums->isFormPOSTed($_POST, 'confirm_action'))
	{
		$forums->chkIsNotEmpty('forum_ids', $LANG['err_tip_compulsory'])or
		$forums->setCommonErrorMsg($LANG['forums_err_tip_select_titles']);
		$forums->chkIsNotEmpty('action', $LANG['err_tip_compulsory'])or
		$forums->setCommonErrorMsg($LANG['err_tip_select_action']);
		if ($forums->isValidFormInputs())
			{
			 	switch($forums->getFormField('action'))
					 {
				 		case 'Delete':
							$forums->deleteForumTitles();
							$forums->setCommonSuccessMsg($LANG['forums_success_delete_message']);
							break;

						case 'Active':
							$forums->activeForumTitles();
							$forums->setCommonSuccessMsg($LANG['forums_success_active_message']);
							break;

						case 'Inactive':
							$forums->inactiveForumTitles();
							$forums->setCommonSuccessMsg($LANG['forums_success_inactive_message']);
							break;

						case 'Publish':
							$forums->publishForumTitles();
							$forums->setCommonSuccessMsg($LANG['forums_success_published_message']);
							break;
				 	} // switch
				$forums->setFormField('forum_ids', array());
				$forums->setPageBlockShow('block_msg_form_success');
			}
		else //error in form inputs
			{
				$forums->setCommonErrorMsg($LANG['common_msg_error_sorry']);
				$forums->setPageBlockShow('block_msg_form_error');
			}
	}
elseif ($forums->isFormPOSTed($_POST, 'forums_cancel'))
	{
		$forums->setFormField('forum_ids', array());
	}
elseif ($forums->isFormPOSTed($_POST, 'forums_reset'))
	{
		$forums->setFormField('srch_title', '');
		$forums->setFormField('srch_topic', '');
		$forums->setFormField('srch_topic_cnt', '');
		$forums->setFormField('topic_condition', '');
		$forums->setFormField('srch_response', '');
		$forums->setFormField('srch_response_cnt', '');
		$forums->setFormField('response_condition', '');
		$forums->setFormField('srch_uname', '');
		$forums->setFormField('srch_status', '');
		$forums->setFormField('status_active', '');
		$forums->setFormField('status_inactive', '');
		$forums->setFormField('srch_date_added', '');
		$forums->setFormField('srch_date', '');
		$forums->setFormField('srch_month', '');
		$forums->setFormField('srch_year', '');
		$forums->setFormField('msg', '');
		Redirect2URL('forums.php');
	}
$search_condition = '';
$searchArr = array();
$searchArr[] = 'srch';
$queryStr = '';
if ($forums->getFormField('srch_title'))
	{
		$search_condition .= ' AND f.forum_title like \'%'.addslashes($forums->getFormField('srch_title')).'%\'';
		$searchArr[] = 'srch_title';
		$queryStr .= '&srch_title='.$forums->getFormField('srch_title');
    }
if ($forums->getFormField('srch_topic'))
	{
		$forum_ids = $forums->getForumIds('forum_topic', $forums->getFormField('srch_topic'));
		$search_condition .= ' AND f.forum_id IN ('.$forum_ids.')';
		$searchArr[] = 'srch_topic';
		$queryStr .= '&srch_topic='.$forums->getFormField('srch_topic');
    }
if ($forums->getFormField('srch_response'))
	{
		$topic_ids = $forums->getTopicIds($forums->getFormField('srch_response'));
		$forum_ids = $forums->getForumIds('topic_id', $topic_ids);
		$search_condition .= ' AND f.forum_id IN ('.$forum_ids.')';
		$searchArr[] = 'srch_response';
		$queryStr .= '&srch_response='.$forums->getFormField('srch_response');
    }
if ($forums->getFormField('srch_topic_cnt'))
	{
		$operator = '=';
		if (in_array($forums->getFormField('topic_condition'), $condition_operators))
			$operator = $operators_arr[$forums->getFormField('topic_condition')];
		$search_condition .= ' AND f.total_topics '.$operator.' \''.addslashes($forums->getFormField('srch_topic_cnt')).'\'';
		$searchArr[] = 'srch_topic_cnt';
		$searchArr[] = 'topic_condition';
		$queryStr .= '&srch_topic_cnt='.$forums->getFormField('srch_topic_cnt');
		$queryStr .= '&topic_condition='.$forums->getFormField('topic_condition');
    }
if ($forums->getFormField('srch_response_cnt'))
	{
		$operator = '=';
		if (in_array($forums->getFormField('response_condition'), $condition_operators))
			$operator = $operators_arr[$forums->getFormField('response_condition')] ;
		$search_condition .= ' AND f.total_response '.$operator.' \''.addslashes($forums->getFormField('srch_response_cnt')).'\'';
		$searchArr[] = 'srch_response_cnt';
		$searchArr[] = 'response_condition';
		$queryStr .= '&srch_response_cnt='.$forums->getFormField('srch_response_cnt');
		$queryStr .= '&response_condition='.$forums->getFormField('response_condition');
    }
if ($forums->getFormField('srch_uname'))
	{
		$search_condition .= ' AND u.'.$forums->getUserTableField('display_name').' like \'%'.addslashes($forums->getFormField('srch_uname')).'%\'';
		$searchArr[] = 'srch_uname';
		$queryStr .= '&srch_uname='.$forums->getFormField('srch_uname');
    }
$forum_status = array();
if ($forums->getFormField('status_active'))
	{
		$forum_status[] = '\'Yes\'';
		$searchArr[] = 'status_active'; $queryStr .= '&status_active='.$forums->getFormField('status_active');
	}
if ($forums->getFormField('status_inactive'))
	{
		$forum_status[] = '\'No\'';
		$searchArr[] = 'status_inactive'; $queryStr .= '&status_inactive='.$forums->getFormField('status_inactive');
	}
if ($forum_status)
	{
		$forum_statuses = implode(',', $forum_status);
		$search_condition .= ' AND f.forum_status IN ('.$forum_statuses.')';
	}
if ($forums->getFormField('srch_date_added'))
	{
		$search_condition .= ' AND f.date_added >= \''.$forums->getFormField('srch_date_added').'\'';
		$search_condition .= ' AND f.date_added <= DATE_ADD(\''.$forums->getFormField('srch_date_added').'\', INTERVAL 1 DAY)';
		$searchArr[] = 'srch_date'; $queryStr .= '&srch_date='.$forums->getFormField('srch_date');
		$searchArr[] = 'srch_month'; $queryStr .= '&srch_month='.$forums->getFormField('srch_month');
		$searchArr[] = 'srch_year'; $queryStr .= '&srch_year='.$forums->getFormField('srch_year');
    }
$forums->setFormField('queryStr', $queryStr);
/*************Start navigation******/
$forums->setTableNames(array($CFG['db']['tbl']['forums'].' as f LEFT JOIN '.$CFG['db']['tbl']['users'].' AS u on f.forum_userid = u.'.$forums->getUserTableField('user_id')));
$forums->setReturnColumns(array('f.forum_id', 'f.forum_title', 'f.forum_description', 'DATE_FORMAT(f.date_added, \''.$forums->CFG['format']['date'].'\') AS date_added', 'CASE WHEN f.forum_status = \'Yes\' THEN \''.$LANG['common_display_active'].'\' WHEN f.forum_status = \'ToActivate\' THEN \''.$LANG['common_unpublished'].'\' ELSE \''.$LANG['common_display_inactive'].'\' END AS forum_status', 'f.total_topics', 'f.total_response', 'f.last_post_date', 'f.last_post_user_id', 'f.last_post_user_id AS img_user_id', $forums->getUserTableFields(array('name', 'display_name', 'image_path', 'gender', 'user_id','t_height', 't_width','s_height', 's_width','photo_server_url', 'photo_ext'))));
//Condition of the query
$condition = '1';
if ($search_condition)
	{
		$condition .= $search_condition;
    }
$forums->buildSelectQuery();
$forums->buildConditionQuery($condition);
$forums->buildSortQuery();
$defaultClass = $topicsClass = $responseClass = '';
if ($forums->getFormField('srch') == 'mosttopics')
	{
		$forums->setFormField('orderby_field', 'f.total_topics');
		$forums->setFormField('orderby', 'DESC');
		$topicsClass = 'class="clsActivePhotoSubLink"';
    }
elseif ($forums->getFormField('srch') == 'mostresponses')
	{
		$forums->setFormField('orderby_field', 'f.total_response');
		$forums->setFormField('orderby', 'DESC');
		$responseClass = 'class="clsActivePhotoSubLink"';
	}
else
	{
		$defaultClass = 'class="clsActivePhotoSubLink"';
	}
$forums->buildSortQuery();
$forums->buildQuery();
$forums->executeQuery();
/*************End navigation******/
$forums->setPageBlockShow('form_show_forums');
$forums->setPageBlockShow('form_search');

//<<<<--------------------Code Ends----------------------//
$forums->hidden_arr =  array('orderby_field', 'orderby');
$forums->current_year = date('Y');
if ($forums->isShowPageBlock('form_search'))
	{
		$forums->form_search['hidden_arr'] = array('orderby_field', 'orderby');
	}
if ($forums->isShowPageBlock('form_show_forums'))
	{
		$forums->form_show_forums['showForumTitles_arr'] = $forums->showForumTitles();
		if ($forums->isResultsFound())
			{
				$forums->form_show_forums['action_arr'] = array("Active" => $LANG['common_display_active'],
					                        					"Inactive" => $LANG['common_display_inactive'], "Delete" => $LANG['common_delete'],
					                        					"Publish" => $LANG['common_publish']);
				$forums->form_show_forums['anchor'] = 'dAltMlti';
				$smartyObj->assign('smarty_paging_list', $forums->populatePageLinksGET($forums->getFormField('start')));
				$forums->form_show_forums['hidden_arr'] = array('start', 'srch', 'srch_title', 'srch_topic', 'srch_topic_cnt', 'topic_condition', 'srch_response', 'srch_response_cnt', 'response_condition', 'srch_uname', 'status_active', 'status_inactive', 'srch_date', 'srch_month', 'srch_year', 'orderby_field', 'orderby');
			}
	}
//--------------------Page block templates begins-------------------->>>>>//
//include the header file
$forums->includeHeader();
//include the content of the page
setTemplateFolder('admin/', $CFG['admin']['index']['forum_module']);
$smartyObj->display('forums.tpl');
?>
<script language="javascript" type="text/javascript">
	var block_arr= new Array('selMsgConfirm');
	var replace_url = '<?php echo $CFG['site']['url'];?>login.php';
	var please_select_action = '<?php echo $LANG['err_tip_select_action'];?>';
	var confirm_message = '';
	function getAction()
		{
			var act_value = document.selFormForums.action.value;
			if(act_value)
				{
					switch (act_value)
						{
							case 'Delete':
								confirm_message = '<?php echo $LANG['forums_delete_confirm_message'];?>';
								break;
							case 'Active':
								confirm_message = '<?php echo $LANG['forums_active_confirm_message'];?>';
								break;
							case 'Inactive':
								confirm_message = '<?php echo $LANG['forums_inactive_confirm_message'];?>';
								break;
							case 'Publish':
								confirm_message = '<?php echo $LANG['forums_publish_confirm_message'];?>';
								break;
						}
					$('confirmMessage').innerHTML = confirm_message;
					document.msgConfirmform.action.value = act_value;
					Confirmation('selMsgConfirm', 'msgConfirmform', Array('forum_ids'), Array(multiCheckValue), Array('value'),'selFormForums');
				}
				else
					alert_manual(please_select_action);
		}
</script>
<?php
//<<<<<<--------------------Page block templates Ends--------------------//
//<<<<<<<<<---------Page block template ends--------------------------//
$forums->includeFooter();
?>
