Beispiel #1
0
 /**
  * Change all date formatting columns to show full years again
  * @return void
  */
 private function _date_format_years()
 {
     // Update members' date formats
     ee()->db->update('members', array('date_format' => '%n/%j/%Y'), array('date_format' => '%n/%j/%y'));
     ee()->db->update('members', array('date_format' => '%j/%n/%Y'), array('date_format' => '%j-%n-%y'));
     // Update the site preferences
     $sites = ee()->db->select('site_id')->get('sites');
     $msm_config = new MSM_Config();
     if ($sites->num_rows() > 0) {
         foreach ($sites->result_array() as $row) {
             $msm_config->site_prefs('', $row['site_id']);
             $localization_preferences = array();
             if ($msm_config->item('date_format') == '%n/%j/%y') {
                 $localization_preferences['date_format'] = '%n/%j/%Y';
             } elseif ($msm_config->item('date_format') == '%j-%n-%y') {
                 $localization_preferences['date_format'] = '%j/%n/%Y';
             }
             if (!empty($localization_preferences)) {
                 $msm_config->update_site_prefs($localization_preferences, $row['site_id']);
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Set output
  * Loads the "container" view file and sets the content
  * @param string $view  The name of the view to load
  * @param array  $template_variables Associative array to pass to view
  * @return void
  */
 private function set_output($view, $template_variables = array())
 {
     ee()->load->library('view');
     if (IS_CORE) {
         $this->title = str_replace('ExpressionEngine', 'ExpressionEngine Core', $this->title);
     }
     // If we're dealing with an error, change the title to indicate that
     if ($view == "error") {
         $this->title = $this->is_installed ? sprintf(lang('error_updating'), $this->installed_version, $this->version) : sprintf(lang('error_installing'), $this->version);
         $this->subtitle = lang('stopped');
     }
     // Only show steps during upgrades
     if ($this->is_installed) {
         $suffix = sprintf(lang('subtitle_step'), $this->current_step, $this->steps);
         $this->subtitle .= empty($this->subtitle) ? $suffix : ' <span class="faded">|</span> ' . $suffix;
     }
     $javascript_basepath = $this->set_path('themes/ee/asset/javascript/');
     $javascript_dir = is_dir($javascript_basepath . 'src/') ? 'src/' : 'compressed/';
     $version = explode('.', $this->version, 2);
     $data = array('title' => $this->title, 'header' => $this->header, 'subtitle' => $this->subtitle, 'refresh' => $this->refresh, 'refresh_url' => $this->refresh_url, 'ajax_progress' => ee()->input->get('ajax_progress') == 'yes', 'image_path' => $this->image_path, 'javascript_path' => $javascript_basepath . $javascript_dir, 'version' => $this->version, 'version_major' => $version[0], 'version_minor' => $version[1], 'installed_version' => $this->installed_version, 'next_version' => substr($this->next_update, 0, 1) . '.' . substr($this->next_update, 1, 1) . '.' . substr($this->next_update, 2, 1), 'languages' => $this->languages, 'theme_url' => $this->set_path('themes'), 'is_core' => IS_CORE ? 'Core' : '', 'action' => '', 'method' => 'post');
     if ($this->is_installed) {
         // for some reason 'charset' is not set in this context and will throw a PHP warning
         $msm_config = new MSM_Config();
         $msm_config->default_ini['charset'] = 'UTF-8';
         $msm_config->site_prefs('');
         $data['theme_url'] = $msm_config->item('theme_folder_url');
         $data['javascript_path'] = $data['theme_url'] . 'ee/asset/javascript/' . $javascript_dir;
     }
     $data = array_merge($data, $template_variables);
     ee()->load->helper('language');
     ee()->load->view('container', array_merge(array('content' => ee()->load->view($view, $data, TRUE)), $data));
 }
Beispiel #3
0
 /**
  * Combines all CAPTCHA settings into one on/off switch; if a site has
  * CAPTCHA turned on for any form, we'll turn CAPTCHA on for the whole site
  *
  * @return void
  */
 private function _centralize_captcha_settings()
 {
     // Prevent this from running again
     if (!ee()->db->field_exists('comment_use_captcha', 'channels') || !ee()->db->field_exists('require_captcha', 'channel_form_settings')) {
         return;
     }
     // First, let's see which sites have CAPTCHA turned on for Channel Forms
     // or comments, and mark those sites as needing CAPTCHA required
     $site_ids_query = ee()->db->select('channels.site_id')->distinct()->where('channels.comment_use_captcha', 'y')->or_where('channel_form_settings.require_captcha', 'y')->join('channel_form_settings', 'channels.channel_id = channel_form_settings.channel_id', 'left')->get('channels')->result();
     $sites_require_captcha = array();
     foreach ($site_ids_query as $site) {
         $sites_require_captcha[] = $site->site_id;
     }
     // Get all site IDs; this is for eventually comparing against the site
     // IDs we have collected to see which sites should have CAPTCHA turned
     // OFF, but we also need to loop through each site to see if any other
     // forms have CAPTCHA turned on
     $all_site_ids_query = ee()->db->select('site_id')->get('sites')->result();
     $all_site_ids = array();
     foreach ($all_site_ids_query as $site) {
         $all_site_ids[] = $site->site_id;
     }
     $msm_config = new MSM_Config();
     foreach ($all_site_ids as $site_id) {
         // Skip sites we're already requiring CAPTCHA on
         if (in_array($site_id, $sites_require_captcha)) {
             continue;
         }
         $msm_config->site_prefs('', $site_id);
         if ($msm_config->item('use_membership_captcha') == 'y' or $msm_config->item('email_module_captchas') == 'y') {
             $sites_require_captcha[] = $site_id;
         }
     }
     // Diff all site IDs against the ones we're requiring CAPTCHA for
     // to get a list of sites we're NOT requiring CAPTCHA for
     $sites_do_not_require_captcha = array_diff($all_site_ids, $sites_require_captcha);
     // Add the new preferences
     // These sites require CAPTCHA
     if (!empty($sites_require_captcha)) {
         ee()->config->update_site_prefs(array('require_captcha' => 'y'), $sites_require_captcha);
     }
     // These sites do NOT require CAPTCHA
     if (!empty($sites_do_not_require_captcha)) {
         ee()->config->update_site_prefs(array('require_captcha' => 'n'), $sites_do_not_require_captcha);
     }
     // And finally, drop the old columns and remove old config items
     ee()->smartforge->drop_column('channels', 'comment_use_captcha');
     ee()->smartforge->drop_column('channel_form_settings', 'require_captcha');
     $msm_config->remove_config_item(array('use_membership_captcha', 'email_module_captchas'));
 }