/** * Invokes the controller run method */ function run() { if (reason_maintenance_mode() && !reason_check_privs('db_maintenance')) { echo '<div id="form">'; echo '<p><em>This web site is currently in maintenance mode, so forms are temporarily disabled. Please try again later.</em></p>'; echo '</div>'; } else { if ($this->model_is_usable()) { $controller = $this->get_form_controller(); $controller->run(); } else { echo '<div id="form">'; echo '<p>This page should display a form, but is not set up correctly. Please try again later.</p>'; echo '</div>'; } } }
/** * Run the Controller * @access public * @return void */ function run() { if (reason_maintenance_mode() && !reason_check_privs('db_maintenance')) { echo '<div id="form">'; echo '<p><em>This web site is currently in maintenance mode, forms are temporarily disabled. Please try again later.</em></p>'; echo '</div>'; exit; } $this->determine_step(); if (empty($this->_request[$this->_step_var_name])) { if ($this->preserve_query_string) { $redirect = carl_make_redirect(array($this->_step_var_name => $this->_current_step)); header('Location: ' . $redirect); exit; } else { header('Location: ' . $this->_base_url . '?' . $this->_step_var_name . '=' . $this->_current_step); exit; } } elseif (!empty($this->_session_existed) and $this->_first_run) { // session timed out. we know this because the cookie or SID exists but PHP could not find a // session file. trigger_error('Session has expired', E_USER_NOTICE); $_SESSION['timeout_msg'] = true; //! This should be a little more descriptive if we're going to be timing out more often, don't you think? Maybe preserve cur_module? Or site_id if they exist? header('Location: ' . $this->_base_url . '?' . $this->_step_var_name . '=' . $this->_get_start_step()); exit; } elseif ($this->_request[$this->_step_var_name] != $this->_current_step) { // This error is no longer being triggered because it's not really an error. //trigger_error( 'Strange behavior: requested multipage form step not the same as the actual step being displayed. Probably due to session timeout. Client browser headered to start of form.',E_USER_NOTICE ); header('Location: ' . $this->_base_url . '?' . $this->_step_var_name . '=' . $this->_get_start_step()); exit; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // intercept posts, store in session, redirect to a new page, send disco the sessioned _POST /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $this->intercept_post(); $final_step = $this->_current_step == $this->_get_final_step(); // get the actual object that has already been instantiated. // we know current step is good since validate_step has run. $f =& $this->forms[$this->_current_step]; $f->set_request($this->_request); $actions = array(); if (!empty($this->transitions[$this->_current_step])) { $trans = $this->transitions[$this->_current_step]; if (!empty($trans['step_decision'])) { $trans_type = !empty($trans['step_decision']['type']) ? $trans['step_decision']['type'] : ''; switch ($trans_type) { case 'user': $next_steps = $trans['next_steps']; foreach ($next_steps as $action => $action_info) { if (!empty($action_info['label'])) { $label = $action_info['label']; } else { $label = $action; } $actions[$action] = $label; } break; case 'method': $actions['next'] = $this->default_next_text; break; default: trigger_error('Unknown transition step decision type. How is that for programmer jargon?'); break; } } else { $actions['next'] = $this->default_next_text; } } else { $actions['next'] = $this->default_next_text; } if ($this->show_back_button && !empty($this->_path)) { $s = $this->get_previous_step(); if (!empty($this->transitions[$s]['back_button_text'])) { $actions['back'] = $this->transitions[$s]['back_button_text']; } else { $actions['back'] = $this->default_back_text; } } if ($final_step) { if (!empty($this->transitions[$this->_current_step]['final_button_text'])) { $actions['next'] = $this->transitions[$this->_current_step]['final_button_text']; } else { $actions['next'] = $this->default_final_text; } } $f->actions = $actions; $f->run_load_phase(); if (!empty($f->chosen_action)) { if ($f->chosen_action == 'back') { $form_jump = $this->_remove_last_step_from_path(); } // Save the last action; otherwise, it's not available to forms. $this->session->set('chosen_action', $f->chosen_action); } if (empty($form_jump)) { $f->run_process_phase(); // $processed was added to FormStep to see if the form is done. // This will be false on first time or in error checking. We // don't want to load the form values into the session until // the form has passed error checking. if ($f->processed) { $this->update_session_form_vars(); // Save a value in the session to indicate that we've processed this step $this->set_form_data('controller_' . $this->_current_step . '_processed', true); $this->_add_step_to_path($this->_current_step); $form_jump = $this->_determine_next_step(); } } if (!empty($form_jump)) { $this->update_session_form_vars(); if ($this->preserve_query_string) { $redirect = carl_make_redirect(array($this->_step_var_name => $form_jump)); header('Location: ' . $redirect); exit; } else { header('Location: ' . $this->_base_url . '?' . $this->_step_var_name . '=' . $form_jump); exit; } } $timeout_msg = $this->session->get('timeout_msg'); if (!empty($timeout_msg)) { $this->session->set('timeout_msg', ''); echo $this->sess_timeout_msg; } $f->run_display_phase(); if ($final_step and $f->processed) { $final_where_to = $f->where_to(); if ($this->clear_form_data_on_finish && !$this->destroy_session_on_finish) { $this->destroy_form_data(); $this->reset_to_first_run(); } if ($this->destroy_session_on_finish) { $this->session->destroy(); } if (!empty($final_where_to)) { header('Location: ' . $final_where_to); } } }
function disabled_for_maintenance() { return (reason_maintenance_mode() && !reason_check_privs('db_maintenance')); }
/** * Returns the value of the constant REASON_ALLOWS_INLINE_EDITING or true if the constant is undefined. * * @return boolean */ function reason_allows_inline_editing() { if (!isset($this->_reason_allows_inline_editing)) { if (reason_maintenance_mode() && !reason_check_privs('db_maintenance')) { $this->_reason_allows_inline_editing = false; } elseif (defined('REASON_ALLOWS_INLINE_EDITING')) { $this->_reason_allows_inline_editing = REASON_ALLOWS_INLINE_EDITING; } else { $path_to_script = REASON_HTTP_BASE_PATH . '/scripts/upgrade/4.0b7_to_4.0b8/index.php'; trigger_error('REASON_ALLOWS_INLINE_EDITING not defined in reason_settings.php - reason_allows_inline_editing will return true (the default value) but please add the constant to remove this warning. For more information, see ' . $path_to_script . '.'); $this->_reason_allows_inline_editing = true; } } return $this->_reason_allows_inline_editing; }