/**
  * Return the current site id if
  *
  * - site_id is valid and refers to a reason site entity
  * - the logged in user has access to the site
  * - the logged in user has "edit" privs
  * @return int site_id
  */
 function _get_validated_site_id()
 {
     $apparent_site_id = (int) $this->admin_page->site_id;
     if ($apparent_site_id) {
         $apparent_site = new entity($apparent_site_id);
         if (reason_is_entity($apparent_site, 'site') && reason_check_access_to_site($apparent_site_id) && reason_check_privs('edit')) {
             return $apparent_site_id;
         }
     }
     return false;
 }
Exemple #2
0
 /**
  * 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'));
	}
 /**
  * @return boolean
  */
 function has_admin_edit_privs()
 {
     return reason_check_privs('pose_as_other_user') || reason_check_privs('edit') && reason_check_access_to_site($this->site_id);
 }
        }
        return isset($cache_id) ? $cache_id : false;
    }
}
// instantiate relevant classes
$head_items = new HeadItems();
$frwh = new FindReplaceWizardHelper();
// add needed head items
$head_items->add_head_item('meta', array('http-equiv' => 'Content-Type', 'content' => 'text/html; charset=UTF-8'));
$head_items->add_head_item('title', array(), 'Find / Replace Wizard', true);
$head_items->add_stylesheet(REASON_HTTP_BASE_PATH . 'css/forms/form_data.css');
$html = '<!DOCTYPE html>' . "\n";
$html .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">' . "\n";
$html .= '<head>' . "\n";
$html .= $head_items->get_head_item_markup();
$html .= '</head>' . "\n";
$html .= '<body>' . "\n";
reason_require_authentication();
if (!reason_check_privs('db_maintenance')) {
    $html .= '<h3>Unauthorized</h3><p>You must have database maintenance privileges to use this tool.</p>';
} else {
    $frwh->init();
    $form =& $frwh->get_form();
    ob_start();
    $form->run();
    $html .= ob_get_contents();
    ob_end_clean();
}
$html .= '</body>';
$html .= '</html>';
echo $html;
 * -- Updated 5/20/09 integration with table admin, report on #s, reduced false positives, uses entity selector API
 *
 * @author Nathan White 
 * @package reason
 * @subpackage scripts
 */
/**
 * include dependencies
 */
include_once 'reason_header.php';
reason_include_once('classes/entity_selector.php');
reason_include_once('function_libraries/user_functions.php');
reason_include_once('minisite_templates/page_types.php');
reason_include_once('classes/page_types.php');
include_once CARL_UTIL_INC . 'db/table_admin.php';
if (reason_require_authentication() && !reason_check_privs('view_sensitive_data')) {
    die('<h1>Sorry.</h1><p>You do not have permission to view page types.</p></body></html>');
}
echo '<!DOCTYPE html>' . "\n";
echo '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
echo '<head>' . "\n";
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n";
echo '<title>Reason Page Types</title>' . "\n";
echo '<link rel="stylesheet" type="text/css" href="' . REASON_HTTP_BASE_PATH . 'css/forms/form_data.css" />' . "\n";
echo '</head>' . "\n";
echo '<body>' . "\n";
echo '<h2>Page Type Information</h2>';
echo '<p>This table shows information about each page type defined in the Reason instance. For each page type that is assigned to a live page,
         a random url is generated. This module can help you verify that page types are working properly, or to identify page types that are
         not being used and should perhaps be deleted.</p>';
$es = new entity_selector();
 /**
  * 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;
 }