<commit_before><?php
    /**
     * @class  forumAdminView
     * @author dan (<EMAIL>)
     * @brief  forum module admin view class
     **/

    class forumAdminView extends forum {

        /**
         * @brief Initialization
         *
         * forum Module is divided into general use and administrative purpose
         **/
        function init() {
            // checks if there are preexisting modules with the current module_srl
            $module_srl = Context::get('module_srl');
            if(!$module_srl && $this->module_srl) {
                $module_srl = $this->module_srl;
                Context::set('module_srl', $module_srl);
            }

            // module creating model object
            $oModuleModel = &getModel('module');

            // setting the information in advance, in order to save the module
            if($module_srl) {
                $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
                if(!$module_info) {
                    Context::set('module_srl','');
                    $this->act = 'list';
                } else {
                    ModuleModel::syncModuleToSite($module_info);
                    $this->module_info = $module_info;
                    Context::set('module_info',$module_info);
                }
            }
			// check if we are in the right kind of module
            if($module_info && $module_info->module != 'forum') return $this->stop("msg_invalid_request");

            // Set module categories to populate admin list
            $module_category = $oModuleModel->getModuleCategories();
            Context::set('module_category', $module_category);

            // Set template path for admin view pages
            $template_path = sprintf("%stpl/",$this->module_path);
            $this->setTemplatePath($template_path);

            // set order target
            foreach($this->order_target as $key) $order_target[$key] = Context::getLang($key);
            $order_target['list_order'] = Context::getLang('document_srl');
            $order_target['update_order'] = Context::getLang('last_update');
            Context::set('order_target', $order_target);
        }

        /**
         * @brief Display forum admin content
         **/
        function dispForumAdminContent() {
            $output = executeQueryArray('forum.getForumList',$args);
            $display=Context::get('display');
            ModuleModel::syncModuleToSite($output->data);
            	//if there is only one forum go directly to it's dashboard , else go to forum list
	            if($output->total_count !=1 || $display) {
	            $this->displayForumAdminContentList();
	            }
	            else {
	            	$oModuleModel = &getModel('module');
	            	$module_srl=$output->data[1]->module_srl;
	            	$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
	            	ModuleModel::syncModuleToSite($module_info);
	                $this->module_info = $module_info;
	                Context::set('module_info',$module_info);
	                Context::set('module_srl',$module_srl);
	                Context::set('act','dispForumAdminDashboard');
	            	$this->dispForumAdminDashboard();
	            }
        }
        /**
         * @brief Display forum admin dashboard
         **/
        function dispForumAdminDashboard() {

        	 $module_info=Context::get('module_info');
        	 $oDocumentModel = &getModel('document');
        	 $oCommentModel=&getModel('comment');

        	 $obj->list_count=$oDocumentModel->getDocumentCount($module_info->module_srl);
        	 $obj->mid=$module_info->mid;
        	 $obj->module_srl=$module_info->module_srl;
        	 //seting the right format for time parameters
        	 $time = time();
        	 $end_date=date("Ymd",$time);
        	 $time-=60*60*24*7;
             $start_date = date("Ymd",$time);

        	 $document_list=$oDocumentModel->getDocumentList($obj);
        	 $lastweek_document_count=0;

                 if($document_list->data)
        	 foreach($document_list->data as $document) {
        	 	$member_list[]=$document->variables['nick_name'];
        	 	$uploaded_count[]=$document->variables['uploaded_count'];
        	 	if((substr($document->variables['last_update'],0,8) <= $end_date) && (substr($document->variables['last_update'],0,8) >= $start_date) ){
        	 		$lastweek_document_count++;
        	 		$lastweek_member_list[]=$document->variables['nick_name'];
        	 		$lastweek_uploaded_count[]=$document->variables['uploaded_count'];
        	 	}
        	 }

        	 $obj->list_count=$oCommentModel->getCommentAllCount($module_info->module_srl);
        	 $comment_list=$oCommentModel->getTotalCommentList($obj);
        	 $lastweek_comment_count=0;

                 if($comment_list->data)
        	 foreach ($comment_list->data as $comment){
        	 	$member_list[]=$comment->variables['nick_name'];
        	 	$uploaded_count[]=$comment->variables['uploaded_count'];
        	 	if((substr($comment->variables['last_update'],0,8) <= $end_date) && (substr($comment->variables['last_update'],0,8) >= $start_date) ){
        	 		$lastweek_comment_count++;
        	 		$lastweek_member_list[]=$comment->variables['nick_name'];
        	 		$lastweek_uploaded_count[]=$comment->variables['uploaded_count'];
        	 	}
        	 }
        	 If(is_array($member_list)){
        	 	 $member_list=array_unique($member_list);
	        	 $lastweek_member_list=array_unique($lastweek_member_list);
	        	 $uploaded_count=array_sum($uploaded_count);
	        	 $lastweek_uploaded_count=array_sum($lastweek_uploaded_count);
        	 }
        	 if(!$uploaded_count) $uploaded_count=0;
        	 if(!$lastweek_uploaded_count) $lastweek_uploaded_count=0;

        	 $total_comments=$oCommentModel->getCommentAllCount($module_info->module_srl);

        	 $obj->list_count=5;
        	 $newest_comments=$oCommentModel->getNewestCommentList($obj);
        	 if(isset($newest_comments)){
	        	 foreach($newest_comments as $comment){
	        	 	$comment->content=trim(cut_str($comment->content,50,"..."));
	        	 	$comment->document_content=$oDocumentModel->getDocument($comment->document_srl)->variables['title'];
	        	 }
        	 }
        	 $module_info->list_count=5;
        	 $newest_documents= executeQuery('forum.getNewestDocumentList', $module_info);
        	 if(count($newest_documents->data)==1) $newest_docs[] = $newest_documents->data;
        	 	else $newest_docs = $newest_documents->data; 
        	 //setting last week variables for the dashboard template
          	 Context::set('lastweek_total_count',$lastweek_document_count);
          	 Context::set('lastweek_total_comments',$lastweek_comment_count);
          	 Context::set('lastweek_total_users',count($lastweek_member_list));
          	 Context::set('lastweek_total_attachements',$lastweek_uploaded_count);
          	 //setting total variables for the dashboard template
        	 Context::set('total_count',$document_list->total_count);
        	 Context::set('total_comments',$total_comments);
        	 Context::set('total_users',count($member_list));
        	 Context::set('total_attachements',$uploaded_count);
        	 //setting the documents and comments list for the dashboard template
        	 Context::set('newest_documents',$newest_docs);<commit_msg>Issue 132 on google code forum project<commit_after><?php
    /**
     * @class  forumAdminView
     * @author dan (<EMAIL>)
     * @brief  forum module admin view class
     **/

    class forumAdminView extends forum {

        /**
         * @brief Initialization
         *
         * forum Module is divided into general use and administrative purpose
         **/
        function init() {
            // checks if there are preexisting modules with the current module_srl
            $module_srl = Context::get('module_srl');
            if(!$module_srl && $this->module_srl) {
                $module_srl = $this->module_srl;
                Context::set('module_srl', $module_srl);
            }

            // module creating model object
            $oModuleModel = &getModel('module');

            // setting the information in advance, in order to save the module
            if($module_srl) {
                $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
                if(!$module_info) {
                    Context::set('module_srl','');
                    $this->act = 'list';
                } else {
                    ModuleModel::syncModuleToSite($module_info);
                    $this->module_info = $module_info;
                    Context::set('module_info',$module_info);
                }
            }
			// check if we are in the right kind of module
            if($module_info && $module_info->module != 'forum') return $this->stop("msg_invalid_request");

            // Set module categories to populate admin list
            $module_category = $oModuleModel->getModuleCategories();
            Context::set('module_category', $module_category);

            // Set template path for admin view pages
            $template_path = sprintf("%stpl/",$this->module_path);
            $this->setTemplatePath($template_path);

            // set order target
            foreach($this->order_target as $key) $order_target[$key] = Context::getLang($key);
            $order_target['list_order'] = Context::getLang('document_srl');
            $order_target['update_order'] = Context::getLang('last_update');
            Context::set('order_target', $order_target);
        }

        /**
         * @brief Display forum admin content
         **/
        function dispForumAdminContent() {
            $output = executeQueryArray('forum.getForumList',$args);
            $display=Context::get('display');
            ModuleModel::syncModuleToSite($output->data);
            	//if there is only one forum go directly to it's dashboard , else go to forum list
	            if($output->total_count !=1 || $display) {
	            $this->displayForumAdminContentList();
	            }
	            else {
	            	$oModuleModel = &getModel('module');
	            	$module_srl=$output->data[1]->module_srl;
	            	$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
	            	ModuleModel::syncModuleToSite($module_info);
	                $this->module_info = $module_info;
	                Context::set('module_info',$module_info);
	                Context::set('module_srl',$module_srl);
	                Context::set('act','dispForumAdminDashboard');
	            	$this->dispForumAdminDashboard();
	            }
        }
        /**
         * @brief Display forum admin dashboard
         **/
        function dispForumAdminDashboard() {

        	 $module_info=Context::get('module_info');
        	 $oDocumentModel = &getModel('document');
        	 $oCommentModel=&getModel('comment');

        	 $obj->list_count=$oDocumentModel->getDocumentCount($module_info->module_srl);
        	 $obj->mid=$module_info->mid;
        	 $obj->module_srl=$module_info->module_srl;
        	 //seting the right format for time parameters
        	 $time = time();
        	 $end_date=date("Ymd",$time);
        	 $time-=60*60*24*7;
             $start_date = date("Ymd",$time);

        	 $document_list=$oDocumentModel->getDocumentList($obj);
        	 $lastweek_document_count=0;

                 if($document_list->data)
        	 foreach($document_list->data as $document) {
        	 	$member_list[]=$document->variables['nick_name'];
        	 	$uploaded_count[]=$document->variables['uploaded_count'];
        	 	if((substr($document->variables['last_update'],0,8) <= $end_date) && (substr($document->variables['last_update'],0,8) >= $start_date) ){
        	 		$lastweek_document_count++;
        	 		$lastweek_member_list[]=$document->variables['nick_name'];
        	 		$lastweek_uploaded_count[]=$document->variables['uploaded_count'];
        	 	}
        	 }

        	 $obj->list_count=$oCommentModel->getCommentAllCount($module_info->module_srl);
        	 $comment_list=$oCommentModel->getTotalCommentList($obj);
        	 $lastweek_comment_count=0;

                 if($comment_list->data)
        	 foreach ($comment_list->data as $comment){
        	 	$member_list[]=$comment->variables['nick_name'];
        	 	$uploaded_count[]=$comment->variables['uploaded_count'];
        	 	if((substr($comment->variables['last_update'],0,8) <= $end_date) && (substr($comment->variables['last_update'],0,8) >= $start_date) ){
        	 		$lastweek_comment_count++;
        	 		$lastweek_member_list[]=$comment->variables['nick_name'];
        	 		$lastweek_uploaded_count[]=$comment->variables['uploaded_count'];
        	 	}
        	 }
        	 if(is_array($member_list)) $member_list=array_unique($member_list);
        	 if(is_array($lastweek_member_list)) $lastweek_member_list=array_unique($lastweek_member_list);
	         if(is_array($uploaded_count)) $uploaded_count=array_sum($uploaded_count);
	         if(is_array($lastweek_uploaded_count)) $lastweek_uploaded_count=array_sum($lastweek_uploaded_count);
	         
        	 if(!$uploaded_count) $uploaded_count=0;
        	 if(!$lastweek_uploaded_count) $lastweek_uploaded_count=0;

        	 $total_comments=$oCommentModel->getCommentAllCount($module_info->module_srl);

        	 $obj->list_count=5;
        	 $newest_comments=$oCommentModel->getNewestCommentList($obj);
        	 if(isset($newest_comments)){
	        	 foreach($newest_comments as $comment){
	        	 	$comment->content=trim(cut_str($comment->content,50,"..."));
	        	 	$comment->document_content=$oDocumentModel->getDocument($comment->document_srl)->variables['title'];
	        	 }
        	 }
        	 $module_info->list_count=5;
        	 $newest_documents= executeQuery('forum.getNewestDocumentList', $module_info);
        	 if(count($newest_documents->data)==1) $newest_docs[] = $newest_documents->data;
        	 	else $newest_docs = $newest_documents->data; 
        	 //setting last week variables for the dashboard template
          	 Context::set('lastweek_total_count',$lastweek_document_count);
          	 Context::set('lastweek_total_comments',$lastweek_comment_count);
          	 Context::set('lastweek_total_users',count($lastweek_member_list));
          	 Context::set('lastweek_total_attachements',$lastweek_uploaded_count);
          	 //setting total variables for the dashboard template
        	 Context::set('total_count',$document_list->total_count);
        	 Context::set('total_comments',$total_comments);
        	 Context::set('total_users',count($member_list));
        	 Context::set('total_attachements',$uploaded_count);
        	 //setting the documents and comments list for the dashboard template
        	 Context::set('newest_documents',$newest_docs);
{'fraction_non_alphanumeric': 0.133525199116525, 'fraction_numerical': 0.0036811458403052002, 'mean_word_length': 2.546641348207928, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '768483', 'n_tokens_mistral': 4398, 'n_tokens_neox': 4232, 'n_words': 592}