You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

142 lines
3.4 KiB

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class General_Moderation_Settings extends MY_Controller
{
public function __construct() {
$this->my_parent_controller();
$this->clear_cache();
$this->load->model('event_moderation_model');
$this->load->model('event_model');
$this->initCurrentSettings();
}
/**
*
* @method initialize current settings
* @param string purpose, 'save' or 'validation'
* @access protected
* @return array
*
*/
protected function initCurrentSettings($purpose = 'save')
{
try {
if ($purpose == 'save') {
$get_actual_settings = 1;
} else {
$get_actual_settings = 0;
}
/*get current active settings that are either used or unused*/
$this->_current_settings = $this->getLatestModSettings(3, $get_actual_settings);
/*get current active settings from the settings view*/
$this->_current_view_settings = $this->getLatestModSettings(3, 0);
if (isset($this->_current_settings['gm_id'])) {
$this->_current_sub_settings = $this->event_moderation_model->getSubModSettings($this->_current_settings['gm_id'], $get_actual_settings);
} else {
$this->_current_sub_settings = array();
}
} catch (\Exception $e) {
throw new Exception("Cannot get old settings");
}
}
/**
*
* @method get old settings
* @access public
* @param int used(1) | unused(0) | either (3)
* @param int get from view or actual table 1:get from view. 0: get from actual table
* @return array
*
*/
private function getLatestModSettings(int $is_used, int $get_actual = 1)
{
try {
return $this->event_moderation_model->getLatestModSettings($is_used, $get_actual);
} catch (\Exception $e) {
throw new Exception('No settings detected');
}
}
/**
*
* @method get old settings for BO
* @access public
* @param int used(1) | unused(0) | either (3)
* @param int for validation 1 | 0
* @param int get array form or output to json format
* @return array
*
*/
public function getLatestModerationSettings(int $is_used, int $for_validation = 0, $get_array = 0)
{
try {
if ($for_validation) {
$this->initCurrentSettings('validation');
}
$settings = $this->_current_settings;
if (count($settings) >0 ) {
$sub_settings = $this->_current_sub_settings;
$all_settings = array(
"main_settings" => $settings,
"sub_settings" => $sub_settings,
);
if ($get_array) {
return $all_settings;
}
output_to_json($this, $all_settings);
} else {
$all_settings = array(
"main_settings" => array(
"gm_mod_stat" => 0,
"noshow_psub_stat" => 0,
"res_psub_stat" => 0,
"event_cat_stat" => 0,
"event_loc_stat" => 0,
"event_month_stat" => 0,
"flex_mod_stat" => 0,
),
"sub_settings" => array(
"max_noshow" => null,
"nshow_period" => null,
"max_res" => null,
"res_period_type" => null,
"event_cats" => null,
"locations" => null,
"months" => null,
"hrs_bef_event_closes" => null,
"places_volume" => null
)
);
if ($get_array) {
return $all_settings;
}
output_to_json($this, $all_settings);
}
} catch (\Exception $e) {
throw new Exception('No settings detected');
}
}
public function getModerationGeneralSettings(){
$mod_sett = $this->getLatestModerationSettings(3, 1, 1);
$mod_sett_sub = $mod_sett['sub_settings'];
return output_to_json($this, $mod_sett_sub);
}
}