public function get_module_preferences($refresh = FALSE)
    {
        // --------------------------------------------
        //  Prep Cache, Return if Set
        // --------------------------------------------
        $cache_name = __FUNCTION__;
        $cache_hash = $this->_imploder(func_get_args());
        if ($refresh !== TRUE) {
            if (isset($this->cached[$cache_name][$cache_hash])) {
                return $this->cached[$cache_name][$cache_hash];
            }
        } else {
            unset($this->cached[$cache_name]);
        }
        $this->cached[$cache_name][$cache_hash] = array();
        // --------------------------------------------
        //  Perform the Actual Work
        // --------------------------------------------
        if (!class_exists('Calendar_upd')) {
            require_once CALENDAR_PATH . 'upd.calendar' . EXT;
        }
        $prefs = Calendar_upd::_default_preferences();
        $data = unserialize($prefs);
        //--------------------------------------------
        //	This was too expensive to run on page load
        //--------------------------------------------
        if (ee()->db->table_exists('exp_calendar_preferences')) {
            $sql = 'SELECT 	cp.preferences
					FROM 	exp_calendar_preferences cp
					WHERE 	cp.site_id = "' . ee()->db->escape_str($this->get_site_id()) . '"';
            $query = ee()->db->query($sql);
            if ($query->num_rows() > 0) {
                $new_data = unserialize($query->row('preferences'));
                foreach ($new_data as $k => $v) {
                    $data[$k] = $v;
                }
            }
        }
        $this->cached[$cache_name][$cache_hash] = $data;
        // --------------------------------------------
        //  Return Data
        // --------------------------------------------
        return $this->cached[$cache_name][$cache_hash];
    }
Beispiel #2
0
 /**
  * Module Upgrading
  *
  * This function is not required by the 1.x branch of ExpressionEngine by default.  However,
  * as the install and deinstall ones are, we are just going to keep the habit and include it
  * anyhow.
  *		- Originally, the $current variable was going to be passed via parameter, but as there might
  *		  be a further use for such a variable throughout the module at a later date we made it
  *		  a class variable.
  *
  *
  * @access	public
  * @return	bool
  */
 public function calendar_module_update()
 {
     if (!isset($_POST['run_update']) or $_POST['run_update'] != 'y') {
         $this->add_crumb(lang('update_calendar'));
         $this->cached_vars['form_url'] = $this->base . '&method=calendar_module_update';
         $this->cached_vars['current_page'] = $this->view('update_module.html', NULL, TRUE);
         return $this->ee_cp_view('index.html');
     }
     if (!class_exists('Calendar_updater_base')) {
         require_once $this->addon_path . 'upd.calendar.php';
     }
     $U = new Calendar_upd();
     if ($U->update() !== TRUE) {
         ee()->functions->redirect($this->base . '&msg=update_failure');
     } else {
         ee()->functions->redirect($this->base . '&msg=update_successful');
     }
 }