function __construct()
 {
     parent::__construct();
     $this->AddImageDir('images');
     $this->categories_table_name = cms_db_prefix() . 'module_cgcalendar_categories';
     $this->events_to_categories_table_name = cms_db_prefix() . 'module_cgcalendar_events_to_categories';
     $this->events_table_name = cms_db_prefix() . 'module_cgcalendar_events';
     $this->event_field_values_table_name = cms_db_prefix() . 'module_cgcalendar_event_field_values';
     $this->fields_table_name = cms_db_prefix() . 'module_cgcalendar_fields';
     $this->admin_tools_loaded = false;
 }
 function DoAction($action, $id, $params, $returnid = -1)
 {
     $smarty = cmsms()->GetSmarty();
     $smarty->assign('feuactionid', $id);
     $smarty->assign('feuactionparams', $params);
     $smarty->assign('mod', $this);
     $smarty->assign($this->GetName(), $this);
     switch ($action) {
         case 'changesettings_url':
             break;
         case 'changesettings':
             $params['form'] = $action;
             $this->_DoUserAction($id, $params, $returnid);
             break;
         case 'lostusername':
         case 'forgotpw':
             $params['form'] = $action;
             $this->_DoUserAction($id, $params, $returnid);
             break;
         case "default":
             $this->_DoUserAction($id, $params, $returnid);
             break;
         case 'do_setchangesettingstemplate':
             if ($this->_HasSufficientPermissions('templates')) {
                 $this->_DoSetChangeSettingsTemplate($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'do_setforgotpwtemplate':
             if ($this->_HasSufficientPermissions('templates')) {
                 $this->_DoSetForgotPWTemplate($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'do_setlogintemplate':
             if ($this->_HasSufficientPermissions('templates')) {
                 $this->_DoSetLoginTemplate($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'do_setlogouttemplate':
             if ($this->_HasSufficientPermissions('templates')) {
                 $this->_DoSetLogoutTemplate($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'edituser':
             if ($this->_HasSufficientPermissions('editusers')) {
                 $this->_DisplayAdminEditUserStep1Page($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'admin_bulkactions':
         case 'admin_importgroup':
         case 'admin_exportgroup':
         case 'admin_logout':
         case 'admin_setviewuser_template':
         case 'admin_setlostun_template':
         case 'addgroup':
         case 'adduser':
         case 'addprop':
         case 'defaultadmin':
         case 'do_deleteprop':
         case 'do_deletegroup':
         case 'do_login':
         case 'do_adduser1':
         case 'do_adduser3':
         case 'do_deleteuser':
         case 'do_addgroup':
         case 'do_edituser3':
         case 'do_userchangesettings':
         case 'do_forgotpw':
         case 'do_setprefs':
         case 'do_edituser1':
         case 'do_admintasks':
         case 'do_lostusername':
         case 'do_verifycode':
         case 'logout':
         case 'userhistory':
         case 'verifycode':
         case 'viewuser':
         case 'do_edituser2':
         case 'do_adduser2':
         default:
             parent::DoAction($action, $id, $params, $returnid);
             break;
     }
 }
 /**
  * The constructor.
  * This method does numerous things, including setup an extended autoloader,
  * create defines for the module itself.  i.e: MOD_CGEXTENSIONS, or MOD_FRONTENDUSERS.
  * sets up a built in cache driver for temporarily caching data.
  * and register numerous smarty plugins (see the documentation for those).
  */
 public function __construct()
 {
     spl_autoload_register(array($this, 'autoload'));
     parent::__construct();
     global $CMS_INSTALL_PAGE, $CMS_PHAR_INSTALL;
     if (isset($CMS_INSTALL_PAGE) || isset($CMS_PHAR_INSTALL)) {
         return;
     }
     $class = get_class($this);
     if (!defined('MOD_' . strtoupper($class))) {
         /**
          * @ignore
          */
         define('MOD_' . strtoupper($class), $class);
     }
     if (self::$_initialized || $class != 'CGExtensions') {
         return;
     }
     self::$_initialized = TRUE;
     // from here down only happens once per request (for CGExtensions only)
     // setup caching
     if ($class == MOD_CGEXTENSIONS && !is_object(cms_cache_handler::get_instance()->get_driver())) {
         $lifetime = (int) $this->GetPreference('cache_lifetime', 300);
         $filelock = (int) $this->GetPreference('cache_filelock', 1);
         $autoclean = (int) $this->GetPreference('cache_autoclean', 1);
         if ($autoclean) {
             // autoclean is enabled... but we don't want to search through the directory for files to delete
             // on each request... so we just do that once per interval.
             $tmp = $this->GetPreference('cache_autoclean_last', 0);
             if (time() - $tmp < $lifetime) {
                 $autoclean = 0;
             } else {
                 $autoclean = 1;
                 $this->SetPreference('cache_autoclean_last', time());
             }
         }
         $driver = new cms_filecache_driver(array('cache_dir' => TMP_CACHE_LOCATION, 'lifetime' => $lifetime, 'locking' => $filelock, 'auto_cleaning' => $autoclean));
         cms_cache_handler::get_instance()->set_driver($driver);
     }
     $smarty = CmsApp::get_instance()->GetSmarty();
     if (!$smarty) {
         return;
     }
     $smarty->register_function('cge_yesno_options', 'cge_smarty_plugins::smarty_function_cge_yesno_options');
     $smarty->register_function('cge_have_module', array('cge_smarty_plugins', 'plugin_have_module'));
     $smarty->register_block('cgerror', array('cge_smarty_plugins', 'blockDisplayError'));
     $smarty->register_block('jsmin', array('cge_smarty_plugins', 'jsmin'));
     $smarty->register_function('cge_cached_url', array('cge_smarty_plugins', 'cge_cached_url'));
     $smarty->register_function('cgimage', array('cge_smarty_plugins', 'smarty_function_cgimage'));
     $smarty->register_function('cge_helptag', array('cge_smarty_plugins', 'smarty_function_helptag'));
     $smarty->register_function('cge_helphandler', array('cge_smarty_plugins', 'smarty_function_helphandler'));
     $smarty->register_function('cge_helpcontent', array('cge_smarty_plugins', 'smarty_function_helpcontent'));
     $smarty->register_function('cge_state_options', array('cge_smarty_plugins', 'smarty_function_cge_state_options'));
     $smarty->register_function('cge_country_options', array('cge_smarty_plugins', 'smarty_function_cge_country_options'));
     $smarty->register_function('cge_textarea', array('cge_smarty_plugins', 'smarty_function_cge_textarea'));
     $smarty->register_function('get_current_url', array('cge_smarty_plugins', 'smarty_function_get_current_url'));
     $smarty->register_function('cge_str_to_assoc', array('cge_smarty_plugins', 'smarty_function_str_to_assoc'));
     $smarty->register_modifier('rfc_date', array('cge_smarty_plugins', 'smarty_modifier_rfc_date'));
     $smarty->register_modifier('time_fmt', array('cge_smarty_plugins', 'smarty_modifier_time_fmt'));
     $smarty->register_modifier('cge_entity_decode', array('cge_smarty_plugins', 'smarty_modifier_cge_entity_decode'));
     $smarty->register_compiler_function('cge_cache', array('cge_smarty_plugins', 'cache_start'));
     $smarty->register_compiler_function('cge_cacheclose', array('cge_smarty_plugins', 'cache_end'));
     $smarty->register_function('cge_module_hint', array('cge_smarty_plugins', 'cge_module_hint'));
     $smarty->register_function('cge_file_list', array('cge_smarty_plugins', 'cge_file_list'));
     $smarty->register_function('cge_image_list', array('cge_smarty_plugins', 'cge_image_list'));
     $smarty->register_function('cge_array_set', array('cge_smarty_plugins', 'cge_array_set'));
     $smarty->register_function('cge_array_erase', array('cge_smarty_plugins', 'cge_array_erase'));
     $smarty->register_function('cge_array_get', array('cge_smarty_plugins', 'cge_array_get'));
     $smarty->register_function('cge_array_getall', array('cge_smarty_plugins', 'cge_array_getall'));
     $smarty->register_function('cge_admin_error', array('cge_smarty_plugins', 'cge_admin_error'));
     $smarty->register_function('cge_wysiwyg', array('cge_smarty_plugins', 'cge_wysiwyg'));
     $smarty->register_modifier('cge_createurl', array('cge_smarty_plugins', 'smarty_modifier_createurl'));
     $smarty->register_function('cge_setlist', array('cge_smarty_plugins', 'cge_setlist'));
     $smarty->register_function('cge_unsetlist', array('cge_smarty_plugins', 'cge_unsetlist'));
     $smarty->register_function('cge_message', array('cge_smarty_plugins', 'cge_message'));
     $smarty->register_function('cge_isbot', array('cge_smarty_plugins', 'cge_isbot'));
     $smarty->register_function('cge_is_smartphone', array('cge_smarty_plugins', 'cge_is_smartphone'));
     $smarty->register_function('cge_getbrowser', array('cge_smarty_plugins', 'cge_get_browser'));
     $smarty->register_function('cge_isie', array('cge_smarty_plugins', 'cge_isie'));
     $smarty->register_function('cge_content_type', array('cge_smarty_plugins', 'cge_content_type'));
     $smarty->register_function('cge_start_tabs', array('cge_smarty_plugins', 'cge_start_tabs'));
     $smarty->register_function('cge_end_tabs', array('cge_smarty_plugins', 'cge_end_tabs'));
     $smarty->register_function('cge_tabheader', array('cge_smarty_plugins', 'cge_tabheader'));
     $smarty->register_function('cge_tabcontent_start', array('cge_smarty_plugins', 'cge_tabcontent_start'));
     $smarty->register_function('cge_tabcontent_end', array('cge_smarty_plugins', 'cge_tabcontent_end'));
     $smarty->register_function('cgjs_render', array('cge_smarty_plugins', 'cgjs_render'));
     $smarty->register_function('cgjs_require', array('cge_smarty_plugins', 'cgjs_require'));
     $smarty->register_block('cgjs_add', array('cge_smarty_plugins', 'cgjs_add'));
     $smarty->register_block('cgcss_add', array('cge_smarty_plugins', 'cgcss_add'));
     // should be admin only
     $smarty->register_function('cge_pageoptions', array('cge_smarty_plugins', 'cge_pageoptions'));
     $db = cms_utils::get_db();
     if (is_object($db)) {
         $query = 'SET @CG_ZEROTIME = NOW() - INTERVAL 150 YEAR,@CG_FUTURETIME = NOW() + INTERVAL 5 YEAR';
         $db->Execute($query);
     }
 }
 function __construct()
 {
     parent::__construct();
     $this->_ops_obj = null;
 }
 public function InitializeFrontend()
 {
     parent::SetParameters();
     $this->RestrictUnknownParams();
     // operational params (what to do, with what...)
     $this->SetParameterType('noautoscale', CLEAN_INT);
     $this->SetParameterType('nobcache', CLEAN_INT);
     $this->SetParameterType('noembed', CLEAN_INT);
     $this->SetParameterType('noauto', CLEAN_INT);
     $this->SetParameterType('norotate', CLEAN_INT);
     $this->SetParameterType('notag', CLEAN_INT);
     $this->SetParameterType('noresponsive', CLEAN_INT);
     $this->SetParameterType('noremote', CLEAN_INT);
     $this->SetParameterType('src', CLEAN_STRING);
     $this->SetParameterType('overwrite', CLEAN_INT);
     $this->SetParameterType('force_ext', CLEAN_INT);
     $this->SetParameterType('force_type', CLEAN_STRING);
     $this->SetParameterType('progressive', CLEAN_INT);
     $this->SetParameterType('autoscale_op', CLEAN_STRING);
     // params for the output tag (if outputting an img tag)
     $this->SetParameterType('id', CLEAN_STRING);
     $this->SetParameterType('class', CLEAN_STRING);
     $this->SetParameterType('style', CLEAN_STRING);
     $this->SetParameterType('title', CLEAN_STRING);
     $this->SetParameterType('alt', CLEAN_STRING);
     $this->SetParameterType('name', CLEAN_STRING);
     $this->SetParameterType('height', CLEAN_INT);
     $this->SetParameterType('width', CLEAN_INT);
     $this->SetParameterType('max_height', CLEAN_INT);
     $this->SetParameterType('max_width', CLEAN_INT);
     $this->SetParameterType('quality', CLEAN_INT);
     $this->SetParameterType('rel', CLEAN_STRING);
     $this->SetParameterType(CLEAN_REGEXP . '/src\\d*/', CLEAN_STRING);
     $this->SetParameterType(CLEAN_REGEXP . '/alias\\d*/', CLEAN_STRING);
     $this->SetParameterType(CLEAN_REGEXP . '/filter_\\w*/', CLEAN_STRING);
     $this->SetParameterType('silent', CLEAN_INT);
     // more smarty plugins
     $smarty = cmsms()->GetSmarty();
     $smarty->register_block('cgsi_convert', array('cgsi_utils', 'cgsi_convert'));
     $smarty->register_block('cgsi_getimages', array('cgsi_extended', 'cgsi_getimages'));
 }
 function DoAction($action, $id, $params, $returnid = -1)
 {
     global $gCms;
     $smarty = $gCms->GetSmarty();
     $smarty->assign('selfregactionid', $id);
     $smarty->assign('selfregparams', $params);
     $smarty->assign('mod', $this);
     $smarty->assign($this->GetName(), $this);
     switch ($action) {
         case 'deletetempuser':
             if ($this->CheckPermission('Manage Registering Users')) {
                 $this->_DoDeleteUser($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'do_deleteusersbulk':
             if ($this->CheckPermission('Manage Registering Users')) {
                 $this->_DoDeleteBulkUsers($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'sendanotheremail':
             $this->_SendAnotherRegEmail($id, $params, $returnid);
             break;
         case 'set_reg1template':
             if ($this->CheckPermission('Modify Templates')) {
                 $this->_SetAdminReg1Template($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'set_reg2template':
             if ($this->CheckPermission('Modify Templates')) {
                 $this->_SetAdminReg2Template($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'set_emailconfirm_template':
             if ($this->CheckPermission('Modify Templates')) {
                 $this->_SetAdminEmailConfirmTemplate($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'set_emailuseredited_template':
             if ($this->CheckPermission('Modify Templates')) {
                 $this->_SetAdminEmailUserEditedTemplate($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'set_finalmessage_template':
             if ($this->CheckPermission('Modify Templates')) {
                 $this->_SetAdminFinalMessageTemplate($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
         case 'set_sendanotheremail_template':
             if ($this->CheckPermission('Modify Templates')) {
                 $this->_SetAdminSendAnotherEmailTemplate($id, $params, $returnid);
             } else {
                 $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('accessdenied'));
             }
             break;
             //       case 'default':
             //       case 'defaultadmin':
             //       case 'do_edituser':
             //       case 'edittempuser':
             //       case 'reguser':
             //       case 'setprefs':
             //       case 'verifyuser':
         //       case 'default':
         //       case 'defaultadmin':
         //       case 'do_edituser':
         //       case 'edittempuser':
         //       case 'reguser':
         //       case 'setprefs':
         //       case 'verifyuser':
         default:
             return parent::DoAction($action, $id, $params, $returnid);
             break;
     }
 }
 public function DoAction($action, $id, $params, $returnid = -1)
 {
     switch ($action) {
         case 'do_deletecategory':
             // check permissions again
             if ($this->CheckPermission('Manage Uploads')) {
                 $delete_dir = false;
                 if (!isset($params['category_id'])) {
                     $this->SetError($this->Lang('error_missing_invalid', 'category_id'));
                     $this->RedirectToTab($id, 'categories');
                 }
                 if (isset($params['input_deletedirectory']) && $params['input_deletedirectory']) {
                     $delete_dir = true;
                 }
                 $msg = $this->_AdminDoDeleteCategory($params['category_id'], $delete_dir);
                 if ($msg) {
                     $this->SetError($msg);
                 }
                 $this->RedirectToTab($id, 'categories');
             }
             break;
         case 'do_deleteupload':
             // check permissions again
             if ($this->CheckPermission('Manage Uploads') || $this->CheckPermission('Upload Files to Uploads')) {
                 if (!isset($params['upload_id'])) {
                     $module->_DisplayErrorPage($id, $params, $returnid, $module->Lang('error_insufficientparams', 'upload_id'));
                     return;
                 }
                 $msg = $this->_AdminDoDeleteUpload($params['upload_id'], true);
                 if ($msg) {
                     $this->SetError($msg);
                 }
                 $this->RedirectToTab($id, 'files', array('input_category' => $uploadrow['upload_category_id']));
             }
             break;
         case 'updateemailtemplate':
             // check permissions again
             if ($this->CheckPermission('Modify Templates')) {
                 if (isset($params['defaultbutton'])) {
                     $fn = dirname(__FILE__) . '/templates/orig_emailnotify_template.tpl';
                     if (file_exists($fn)) {
                         $template = @file_get_contents($fn);
                         $this->SetTemplate('upload_emailtemplate', $template);
                     }
                 } else {
                     $this->SetTemplate('upload_emailtemplate', $params['templatecontent']);
                 }
                 $this->RedirectToTab($id, 'email_template', '', 'admin_templates');
             }
         case 'updatesendfileemail':
             // check permissions again
             if ($this->CheckPermission('Modify Templates')) {
                 if (isset($params['defaultbutton'])) {
                     // template used for sendfile email
                     $fn = dirname(__FILE__) . '/templates/orig_sendfilerpt_template.tpl';
                     if (file_exists($fn)) {
                         $template = @file_get_contents($fn);
                         $this->SetTemplate('upload_sendfilerpt', $template);
                     }
                 } else {
                     $this->SetTemplate('upload_sendfilerpt', $params['templatecontent']);
                 }
                 $this->RedirectToTab($id, 'email_template', '', 'admin_templates');
             }
         default:
             parent::DoAction($action, $id, $params, $returnid);
             break;
     }
 }