/**
  * Standard Module init function
  * 
  * @return void
  */
 function init()
 {
     if (!empty($this->admin_page->id)) {
         $this->_event = new entity($this->admin_page->id);
     } else {
         $this->_should_run = false;
         $this->_no_run_msg = 'No event ID provided.';
         return;
     }
     if (!reason_user_has_privs($this->admin_page->user_id, 'add') || !reason_user_has_privs($this->admin_page->user_id, 'edit')) {
         $this->_should_run = false;
         $this->_no_run_msg = 'You do not have the privileges to duplicate an event.';
         return;
     }
     if (empty($this->_event) || !$this->_event->get_values() || $this->_event->get_value('type') != id_of('event_type')) {
         $this->_should_run = false;
         $this->_no_run_msg = 'The item you are trying to split up is not an event.';
         return;
     }
     $owner = $this->_event->get_owner();
     if ($owner->id() != $this->admin_page->site_id) {
         $this->_should_run = false;
         $this->_no_run_msg = 'The event you are trying to split up is not owned by the current site.';
         return;
     }
     $dates = $dates = $this->_get_dates_from_event($this->_event);
     if (count($dates) < 2) {
         $this->_should_run = false;
         $this->_no_run_msg = 'The event you are trying to split up only occurs on one date.';
         return;
     }
     $this->admin_page->title = 'Split Up Event: "' . $this->_event->get_value('name') . '"';
 }
 function run()
 {
     if (!reason_user_has_privs($this->admin_page->user_id, 'view_sensitive_data')) {
         echo '<p>Sorry; use of this module is restricted.</p>' . "\n";
         return;
     }
     if (!empty($this->admin_page->request['error_reporting_state'])) {
         switch ($this->admin_page->request['error_reporting_state']) {
             case 'on':
                 override_developer_status(true);
                 break;
             case 'off':
                 override_developer_status(false);
                 break;
         }
     }
     $status = is_developer();
     echo '<form method="post" action="' . htmlspecialchars(get_current_url()) . '">';
     if ($status) {
         echo '<h3>In-page error reporting is currently ON.</h3>' . "\n";
         echo '<input type="submit" value="Turn Error Reporting Off" /><input type="hidden" name="error_reporting_state" value="off" />';
     } else {
         echo '<h3>In-page error reporting is currently OFF.</h3>' . "\n";
         echo '<input type="submit" value="Turn Error Reporting On" /><input type="hidden" name="error_reporting_state" value="on" />';
     }
     echo '</form>';
     echo '<p>Note: changes made via this form only last for the duration of the current session.</p>';
 }
Example #3
0
 function init()
 {
     if (!empty($this->admin_page->id)) {
         $temp = new entity($this->admin_page->id, false);
         if ($temp->get_value('new') && $temp->get_value('state') == 'Pending' && !$temp->get_value('name') && reason_user_has_privs($this->admin_page->user_id, 'delete_pending')) {
             reason_expunge_entity($this->admin_page->id, $this->admin_page->user_id);
         }
     }
     if (!empty($this->admin_page->request[CM_VAR_PREFIX . 'type_id'])) {
         $old_vars = array();
         foreach ($this->admin_page->request as $key => $val) {
             if (substr($key, 0, strlen(CM_VAR_PREFIX)) == CM_VAR_PREFIX) {
                 $old_vars[substr($key, strlen(CM_VAR_PREFIX))] = $val;
                 $old_vars[$key] = '';
             }
         }
         foreach ($this->admin_page->default_args as $arg) {
             if (!isset($old_vars[$arg])) {
                 $old_vars[$arg] = '';
             }
         }
         $link = $this->admin_page->make_link($old_vars);
     } else {
         $link = $this->admin_page->make_link(array('id' => '', 'site_id' => $this->admin_page->site_id, 'type_id' => $this->admin_page->type_id, 'cur_module' => 'Lister'));
     }
     header('Location: ' . unhtmlentities($link));
     die;
 }
Example #4
0
function can_upload($session)
{
    if ($session['authenticator']) {
        $auth = $session['authenticator'];
        $reason_session =& get_reason_session();
        $username = $reason_session->get("username");
        if (isset($_REQUEST['user_id']) && !empty($_REQUEST['user_id'])) {
            $username = $reason_session->get('username');
            $param_cleanup_rules = array('user_id' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')));
            $cleanRequest = array_merge($_REQUEST, carl_clean_vars($_REQUEST, $param_cleanup_rules));
            $nametag = $cleanRequest['user_id'];
            $id = get_user_id($username);
            if (reason_user_has_privs($id, 'pose_as_other_user')) {
                $user = new Entity($nametag);
                $username = $user->get_value("name");
            }
        }
        if ($auth['file']) {
            require_once $auth['file'];
        }
        $args = array_merge(array($username), $auth['arguments']);
        if (!call_user_func_array($auth['callback'], $args)) {
            return false;
        }
    }
    return true;
}
Example #5
0
 function _produce_borrowing_nav()
 {
     $ret = '';
     $nes = new entity_selector();
     $nes->add_type(id_of('type'));
     $nes->add_right_relationship($this->admin_page->site_id, relationship_id_of('site_cannot_edit_type'));
     $nes->add_relation('`entity`.`id` = "' . addslashes($this->admin_page->type_id) . '"');
     $nes->set_num(1);
     $nes->limit_tables();
     $nes->limit_fields();
     $ns = $nes->run_one();
     $show_edit = reason_user_has_privs($this->admin_page->user_id, 'edit') && !$this->admin_page->is_second_level() && empty($ns) ? true : false;
     /* $type = new entity($this->admin_page->type_id);
     			$name = $type->get_value('plural_name') ? $type->get_value('plural_name') : $type->get_value('name');
     			if(function_exists('mb_strtolower'))
     				$name = mb_strtolower($name);
     			else
     				$name = strtolower($name); */
     $ret .= '<div class="borrowNav">' . "\n";
     $ret .= '<ul>';
     if ($show_edit) {
         $ret .= '<li><a href="' . $this->admin_page->get_owned_list_link($this->admin_page->type_id) . '"><img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/bullet_edit.png" alt="" /> Add &amp; edit</a></li>';
     }
     $ret .= '<li class="current"><strong><img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/car.png" alt="" /> Borrow</strong></li>';
     $ret .= '</ul>' . "\n";
     $ret .= '</div>' . "\n";
     // if(reason_user_has_privs($this->admin_page->user_id,'edit'))
     return $ret;
 }
 function run()
 {
     if (!reason_user_has_privs($this->admin_page->user_id, 'view_sensitive_data')) {
         echo '<p>Sorry; use of this module is restricted.</p>' . "\n";
         return;
     }
     if (!empty($this->admin_page->request['entity_id_test'])) {
         $id = $this->admin_page->request['entity_id_test'];
         settype($id, 'integer');
     }
     if (empty($id)) {
         $id = '';
     }
     echo '<form method="get" action="?"><label for="entity_id_test">Entity ID:</label> <input type="text" name="entity_id_test" id="entity_id_test" value="' . $id . '"/><input type="submit" value="submit" /><input type="hidden" name="cur_module" value="EntityInfo" /></form>';
     if (!empty($id)) {
         $entity = new entity($id);
         if ($entity->get_values()) {
             echo '<div class="EntityInfo">' . "\n";
             $this->show_entity_header($entity);
             $this->show_entity_data($entity);
             $this->show_pages($entity);
             $this->show_borrowing_sites($entity);
             $this->show_entity_relationships($entity);
             echo '</div>' . "\n";
         } else {
             echo '<p>The Reason ID ' . $id . ' does not belong to a real entity. It may have been deleted.</p>';
         }
     }
 }
Example #7
0
 function init()
 {
     $this->admin_page->set_show('leftbar', false);
     if (empty($this->admin_page->id)) {
         $this->_not_expungable_reason = 'no_id_provided';
         return false;
     }
     if (!reason_user_has_privs($this->admin_page->user_id, 'expunge')) {
         $this->_not_expungable_reason = 'insufficient_privileges';
         return false;
     }
     $item = new entity($this->admin_page->id);
     $user = new entity($this->admin_page->user_id);
     if (!$item->user_can_edit_field('state', $user)) {
         $this->_not_expungable_reason = 'state_field_locked';
         return false;
     }
     if ($item->get_value('state') != 'Deleted') {
         $this->_not_expungable_reason = 'not_deleted_yet';
         return false;
     }
     $this->expungable = $this->admin_page->is_deletable();
     if ($this->expungable) {
         $this->_set_up_form();
     } else {
         $this->_not_expungable_reason = 'dependencies';
         return false;
     }
 }
 /**
  * Standard Module init function
  *
  * @return void
  */
 function init()
 {
     parent::init();
     if (!reason_user_has_privs($this->admin_page->user_id, 'delete')) {
         $this->_ok_to_run = false;
         $this->_not_ok_message = 'Sorry; you don\'t have the privileges to delete items on this site.';
     } elseif (empty($this->admin_page->site_id)) {
         $this->_ok_to_run = false;
         $this->_not_ok_message = 'Sorry; you need to specify a site before batch deleting items.';
     } elseif (empty($this->admin_page->type_id)) {
         $this->_ok_to_run = false;
         $this->_not_ok_message = 'Sorry; you need to specify a type before batch deleting items.';
     }
     if ($this->_ok_to_run) {
         $this->_type = new entity($this->admin_page->type_id);
         $this->admin_page->title = 'Batch Delete ' . $this->_type->get_value('plural_name');
         $es = new entity_selector($this->admin_page->site_id);
         $es->add_type($this->admin_page->type_id);
         $es->set_sharing('owns');
         $es->set_order('entity.last_modified DESC');
         // pray($this->admin_page->request);
         if (isset($this->admin_page->request['state']) && $this->admin_page->request['state'] == 'pending') {
             $status = 'Pending';
         } else {
             $status = 'Live';
         }
         $this->_items = $es->run_one('', $status);
         foreach (array_keys($this->_items) as $id) {
             if (!$this->admin_page->is_deletable($id)) {
                 unset($this->_items[$id]);
             }
         }
     }
 }
 function has_access()
 {
     if (!isset($this->_has_access)) {
         $this->_has_access = !empty($this->admin_page->site_id) && reason_user_has_privs($this->admin_page->user_id, 'edit');
     }
     return $this->_has_access;
 }
Example #10
0
 function do_wysiwygs()
 {
     $editor_name = html_editor_name($this->site_info->id());
     $params = html_editor_params($this->site_info->id());
     if (function_exists('reason_user_has_privs') && strpos($editor_name, 'loki') === 0 && ($user_id = get_user_id($this->user_netID))) {
         $params['user_is_admin'] = reason_user_has_privs($user_id, 'edit_html');
     }
     $this->change_element_type('post_content', $editor_name, $params);
     $this->change_element_type('description', $editor_name, $params);
 }
Example #11
0
 /**
  * Lists the sites, the non-live list depending on admin role
  * 
  * @return void
  */
 function run()
 {
     echo '<h2>' . $this->ls_count . ' Live Sites</h2>' . "\n";
     $this->list_minisites($this->live_sites_list);
     /* Non-live sites are listed only if viewed by an admin */
     if (reason_user_has_privs($this->admin_page->user_id, 'view_sensitive_data')) {
         echo '<h2>' . $this->nls_count . ' Non-Live Sites</h2>' . "\n";
         $this->list_minisites($this->not_live_site_list);
     }
 }
Example #12
0
 function _cm_ok_to_run()
 {
     switch ($this->entity->get_value('state')) {
         case 'Live':
             return reason_user_has_privs($this->admin_page->user_id, 'edit');
         case 'Pending':
             return reason_user_has_privs($this->admin_page->user_id, 'edit_pending');
         default:
             return false;
     }
 }
Example #13
0
 /**
  * Run form if it is OK
  */
 function run()
 {
     if ($this->site_can_manage_images($this->admin_page->site_id)) {
         if (reason_user_has_privs($this->admin_page->user_id, 'add')) {
             $this->run_form();
         } else {
             echo 'Sorry. You do not have privileges to add images to this site.';
         }
     } else {
         echo '<p>Sorry; this site is not set up to manage images.</p>' . "\n";
     }
 }
Example #14
0
 function init()
 {
     if (!reason_user_has_privs($this->admin_page->user_id, 'borrow')) {
         die('You do not have privileges to borrow or unborrow items');
     }
     $this->set_borrowship_first_level();
     if ($this->admin_page->is_second_level()) {
         $this->add_relationship_second_level();
     }
     $link = unhtmlentities($this->admin_page->make_link(array('cur_module' => 'Sharing', 'id' => '')));
     header('Location: ' . $link);
     die;
 }
Example #15
0
 function run()
 {
     if (!reason_user_has_privs($this->admin_page->user_id, 'view_sensitive_data')) {
         echo 'Sorry; you do not have the rights to view this information.';
         return;
     }
     // get audiences in REason
     $es = new entity_selector();
     $es->add_type(id_of('audience_type'));
     $audiences = $es->run_one();
     $options = array();
     foreach ($audiences as $aud) {
         $options[$aud->get_value('directory_service_value')] = $aud->get_value('name');
     }
     $d = new disco();
     $d->add_element('active_since', 'textdatetime');
     $d->add_element('affiliations', 'checkboxgroup', array('options' => $options));
     $d->set_display_name('affiliations', 'Audiences');
     $d->add_comments('affiliations', form_comment('Leaving these checkboxes blank won\'t filter the results.'));
     $d->set_actions(array('run' => 'Run'));
     $d->run();
     if ($d->get_value('active_since')) {
         $user_ids = $this->_get_active_user_ids($d->get_value('active_since'));
         echo count($user_ids) . ' Reason users modified at least one item since ' . prettify_mysql_datetime($d->get_value('active_since')) . '<br />';
         if ($d->get_value('affiliations')) {
             $affiliations = array_values($d->get_value('affiliations'));
         } else {
             $affiliations = array();
         }
         $users = $this->_get_active_users_from_ids($user_ids, $affiliations);
         echo '<br />' . count($users) . ' of the above users currently have access to at least one site<br />';
         if (!empty($users)) {
             echo '<textarea rows="12">' . "\n";
             $usernames = array();
             foreach ($users as $user) {
                 $usernames[$user->id()] = $user->get_value('name');
             }
             echo implode(', ', $usernames);
             echo '</textarea>' . "\n";
         }
         $emails = $this->_get_email_addresses_from_users($users);
         echo '<br />' . count($emails) . ' of the users with site access have an email addresses in the directory<br />';
         if (!empty($emails)) {
             echo '<textarea rows="12">' . "\n";
             echo implode(', ', $emails);
             echo '</textarea>' . "\n";
         }
     }
 }
 /**
  * Ensure that the user is an admin with access to the master admin site.
  */
 function authenticate()
 {
     if (!isset($this->authenticated)) {
         if (!empty($this->admin_page->user_id)) {
             $user_id = $this->admin_page->user_id;
             $user = new entity($user_id);
             $user_netid = $user->get_value('name');
         } else {
             $user_netid = reason_require_authentication();
             $user_id = get_user_id($user_netid);
         }
         if (reason_user_has_privs($user_id, 'manage_allowable_relationships')) {
             $user_man = new User();
             $this->authenticated = $user_man->is_site_user($user_netid, id_of('master_admin'));
         }
     }
     return $this->authenticated;
 }
Example #17
0
 function run()
 {
     if (reason_user_has_privs($this->admin_page->user_id, 'duplicate')) {
         echo '<h3>Cloning</h3>' . "\n";
         if (!empty($this->admin_page->request['clone']) && $this->admin_page->request['clone'] == 'true') {
             $new_entity_id = duplicate_entity($this->admin_page->id, true, false, array('last_modified_by' => $this->admin_page->user_id, 'state' => 'Pending', 'new' => '1'));
             //echo '<p>new entity successfully cloned from this entity (id #'.$new_entity_id.')<p>';
             echo '<p>Again?</p>';
         } else {
             echo '<p>This will make a duplicate of the current entity.<p>' . "\n";
             echo '<p>Note that this will not duplicate anything on the filesystem, like images, assets, site folders, etc., and that it might duplicate relationships you might not want duplicated. Use this module with care!</p>' . "\n";
             echo '<p>Do you want to do that?</p>' . "\n";
         }
         echo '<ul><li><a href="' . $this->admin_page->make_link(array('clone' => 'true')) . '">Yes</a></li><li><a href="' . $this->admin_page->make_link(array('cur_module' => 'Editor')) . '">No</a></li></ul>' . "\n";
     } else {
         echo '<p>Sorry, you do not have cloning privileges</p>' . "\n";
     }
 }
 function show_admin_live($row, $options)
 {
     echo '<td>';
     if (reason_user_has_privs($this->admin_page->user_id, 'edit')) {
         echo '<strong>';
         $edit_link = $this->admin_page->make_link(array('cur_module' => 'Editor', 'id' => $row->id()));
         $preview_link = $this->admin_page->make_link(array('cur_module' => 'Preview', 'id' => $row->id()));
         $duplicate_link = $this->admin_page->make_link(array('cur_module' => 'Duplicate', 'id' => $row->id()));
         if (reason_site_can_edit_type($this->admin_page->site_id, $this->admin_page->type_id)) {
             echo '<a href="' . $preview_link . '">' . 'Preview</a> | <a href="' . $duplicate_link . '">Duplicate</a> | <a href="' . $edit_link . '">Edit</a>';
         } else {
             echo '<a href="' . $preview_link . '">' . 'Preview</a>';
         }
         echo '</strong>';
     } else {
         echo '&nbsp;';
     }
     echo '</td>' . "\n";
 }
Example #19
0
 /**
  * Get the appropriate parameters to pass to the plasmature element
  * @param integer $site_id The Reason id of the site in which this editor is being invoked
  * @param integer $user_id The Reason id of the current user (0 if user is anonymous or not in the Reason user store)
  * @return array plasmature parameters 
  */
 function get_plasmature_element_parameters($site_id, $user_id = 0)
 {
     $param['rows'] = 20;
     $param['external_css'][] = REASON_HTTP_BASE_PATH . 'tinymce/css/external.css';
     $param['init_options']['content_css'] = $this->get_content_css_path();
     $site = new entity($site_id);
     $loki_default = $site->get_value('loki_default');
     $config = !empty($loki_default) && in_array($loki_default, array_keys($this->get_configuration_options())) ? $loki_default : 'notables';
     $imagetoolbar = $this->reason_plugins_available($user_id) ? 'reasonimage' : 'image';
     /* these will need to change when the link plugin is available */
     $linkplugin = $this->reason_plugins_available($user_id) ? 'link' : 'link';
     $linktoolbar = $this->reason_plugins_available($user_id) ? 'reasonlink' : 'link';
     $blockformats = $config == 'default' || $config == 'notables_plus_pre' || $config == 'all' ? 'Paragraph=p;Header 1=h3;Header 2=h4;Pre=pre' : 'Paragraph=p;Header 1=h3;Header 2=h4';
     $tabletoolbar = $config == 'default' || $config == 'all' || $config == 'all_minus_pre' ? '|,table,' : '';
     $cutcopypaste = $config == 'default' || $config == 'all' || $config == 'all_minus_pre' ? '|,cut,copy,paste,' : '';
     /* load the basic reason image and link plug in options */
     if ($this->reason_plugins_available($user_id)) {
         $param['init_options']['reason_site_id'] = $site_id;
         $param['init_options']['reason_http_base_path'] = REASON_HTTP_BASE_PATH;
     }
     $param['init_options']['toolbar1'] = 'formatselect,|,bold,italic,|,hr,' . $cutcopypaste . '|,blockquote,|,numlist,bullist,|,' . $tabletoolbar . '|,' . $imagetoolbar . ',|,' . $linktoolbar . ',unlink,|,anchor,|,searchreplace';
     $param['init_options']['plugins'] = 'anchor,link,paste,advlist,searchreplace,lists,hr';
     if ($this->reason_plugins_available($user_id)) {
         $param['init_options']['external_plugins'] = '{ "reasonintegration": "' . REASON_HTTP_BASE_PATH . 'tinymce/plugins/reasonintegration/plugin.js" }';
     } else {
         $param['init_options']['plugins'] .= ',image';
     }
     $param['init_options']['block_formats'] = $blockformats;
     if (!empty($tabletoolbar)) {
         $param['init_options']['plugins'] = 'contextmenu,table,' . $param['init_options']['plugins'];
         $param['init_options']['contextmenu'] = 'inserttable | cell row column deletetable';
     }
     if (reason_user_has_privs($user_id, 'edit_html')) {
         $param['init_options']['toolbar1'] .= ',|,code';
         $param['init_options']['plugins'] .= ',code';
     }
     if ($config != 'default') {
         $param['init_options']['formats'] = '{ underline: {} }';
         // prevents underlines being entered with a keyboard shortcut
     }
     return $param;
 }
 function init()
 {
     if (!defined('REASON_ENTITY_LOCKS_ENABLED') || !REASON_ENTITY_LOCKS_ENABLED || !reason_user_has_privs($this->admin_page->user_id, 'manage_locks')) {
         $this->admin_page->title = 'Not Able to Edit Locks';
         return;
     }
     $this->head_items->add_javascript(JQUERY_URL, true);
     $this->head_items->add_javascript(WEB_JAVASCRIPT_PATH . 'manage_locks.js');
     $this->head_items->add_stylesheet(REASON_ADMIN_CSS_DIRECTORY . 'locks.css');
     $id = $this->admin_page->id;
     $this->_entity = $entity = new entity($id);
     $type = new entity($entity->get_value('type'));
     $this->admin_page->title = 'Editing Locks: "' . $entity->get_value('name') . '" (' . $type->get_value('name') . ')';
     $disco = new disco();
     $this->_add_field_lock_elements($disco, $entity);
     $this->_add_relationship_lock_elements($disco, $entity);
     $disco->add_callback(array(&$this, 'process_form'), 'process');
     $disco->add_callback(array(&$this, 'where_to'), 'where_to');
     $this->_form = $disco;
 }
Example #21
0
 function init()
 {
     $this->admin_page->set_show('leftbar', false);
     if (empty($this->admin_page->id)) {
         $this->_not_undeletable_reason = 'no_id_provided';
         return false;
     }
     if (!reason_user_has_privs($this->admin_page->user_id, 'publish')) {
         $this->_not_undeletable_reason = 'insufficient_privileges';
         return false;
     }
     $item = new entity($this->admin_page->id);
     $user = new entity($this->admin_page->user_id);
     if (!$item->user_can_edit_field('state', $user)) {
         $this->_not_undeletable_reason = 'state_field_locked';
         return false;
     }
     if ($item->get_value('state') != 'Deleted') {
         $this->_not_undeletable_reason = 'not_deleted_yet';
         return false;
     }
     reason_update_entity($this->admin_page->id, $this->admin_page->user_id, array('state' => 'Live'), false);
     if ($this->admin_page->type_id == id_of('minisite_page')) {
         // zap nav cache so it reappears.
         reason_include_once('classes/object_cache.php');
         $cache = new ReasonObjectCache($this->admin_page->site_id . '_navigation_cache');
         $cache->clear();
     }
     $manager_site_id = $this->admin_page->site_id;
     if ($item->get_value('type') == id_of('site')) {
         $manager_site_id = $item->id();
     }
     //Updates the rewrites to prevent infinite redirection loop.
     reason_include_once('classes/url_manager.php');
     $urlm = new url_manager($manager_site_id);
     $urlm->update_rewrites();
     $link = unhtmlentities($this->admin_page->make_link(array('cur_module' => 'Lister', 'id' => '', 'state' => 'deleted')));
     header('Location: ' . $link);
     die;
 }
Example #22
0
 function _produce_borrowing_nav()
 {
     $ret = '';
     if (reason_user_has_privs($this->admin_page->user_id, 'borrow')) {
         $sharables = $this->admin_page->get_sharable_relationships();
         if (isset($sharables[$this->admin_page->type_id])) {
             /* $type = new entity($this->admin_page->type_id);
             			$name = $type->get_value('plural_name') ? $type->get_value('plural_name') : $type->get_value('name');
             			if(function_exists('mb_strtolower'))
             				$name = mb_strtolower($name);
             			else
             				$name = strtolower($name); */
             $ret .= '<div class="borrowNav">' . "\n";
             $ret .= '<ul>';
             $ret .= '<li class="current addEdit"><strong><img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/bullet_edit.png" alt="" /> Add &amp; edit</strong></li>';
             $ret .= '<li class="borrow"><a href="' . $this->admin_page->get_borrowed_list_link($this->admin_page->type_id) . '"><img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/car.png" alt="" /> Borrow</a></li>';
             $ret .= '</ul>' . "\n";
             $ret .= '</div>' . "\n";
         }
     }
     return $ret;
 }
 function init()
 {
     $this->request = carl_get_request();
     // If obtained via post we need to manually decode the URL - all current uses of this pass it via get.
     if (isset($_POST['requested_url'])) {
         $this->request['requested_url'] = urldecode($this->request['requested_url']);
     }
     $this->admin_page->title = 'Access Denied';
     if ($requested_site_id = $this->get_requested_site_id()) {
         // lets double check whether the user has access
         if (user_can_edit_site($this->admin_page->user_id, $requested_site_id)) {
             header('Location: ' . $this->get_destination_url_with_user_id($this->admin_page->user_id));
             exit;
         } else {
             $this->can_pose_as_other_user = reason_user_has_privs($this->admin_page->user_id, 'pose_as_other_user');
             $this->has_master_admin_edit_access = user_can_edit_site($this->admin_page->user_id, id_of('master_admin'));
         }
     } else {
         $redirect = carl_make_redirect(array('cur_module' => '', 'requested_url' => '', 'site_id' => ''));
         header('Location: ' . $redirect);
         exit;
     }
 }
Example #24
0
                echo '<p>Unable to create asset_to_category allowable relationship</p>';
                echo '<p>You might try creating the relationship asset_to_category yourself in the reason administrative interface - it should include the following characteristics:</p>';
                pray($this->asset_to_category_details);
            }
        } else {
            echo '<p>Would have created asset_to_category allowable relationship.</p>' . "\n";
        }
    }
}
force_secure_if_available();
$user_netID = reason_require_authentication();
$reason_user_id = get_user_id($user_netID);
if (empty($reason_user_id)) {
    die('valid Reason user required');
}
if (!reason_user_has_privs($reason_user_id, 'upgrade')) {
    die('You must have Reason upgrade privileges to run this script');
}
?>
<h2>Reason: update assets for 4.0b6</h2>
<p>What will this update do?</p>
<ul>
<li>Change the page to asset relationship to bi-directional if it is not already.</li>
<li>Create an asset to category relationship if it does not exist.</li>
</ul>
<form method="post"><input type="submit" name="go" value="test" /><input type="submit" name="go" value="run" /></form>
<?php 
if (!empty($_POST['go']) && ($_POST['go'] == 'run' || $_POST['go'] == 'test')) {
    if ($_POST['go'] == 'run') {
        echo '<p>Running updater...</p>' . "\n";
    } else {
 * This script that will look through a thor database in a reason instance and do the following
 *
 * - Identify tables that have enum fields that match the problem case
 * - Alter the field in the appropriate table to allow "NULL" for all ENUM fields
 * - Preserve existing values and default value settings as reflected in thor XML
 * - Ensure data is the same before and after alter table operations - trigger fatal error if not
 *
 * @author Nathan White
 */

$user_netid = reason_require_authentication();
if($user_netid)
{
	$reason_user_id = get_user_id($user_netid);
}
if (!empty($reason_user_id) && reason_user_has_privs( $reason_user_id, 'upgrade' ) )
{
	if (isset($_REQUEST['do_it']) && ($_REQUEST['do_it'] == 1))
	{
		echo '<h3>Performing operations</h3>';
		$test_mode = false;
	}
	else
	{
		$test_mode = true;
		echo '<h3>Reporting on what I will do</h3>';
		echo '<a href="?do_it=1">Do it Now!</a>';
	}
	$thor_db_update = new ThorDatabaseUpdate;
	$thor_db_update->init();
	$thor_db_update->set_test_mode($test_mode);
Example #26
0
 function run()
 {
     if (!$this->should_run()) {
         echo '<p>There is a problem with the link to this page. Please try to get to this page in another way.</p>';
         return;
     }
     if (!empty($this->admin_page->request['error_message'])) {
         $e_mess = array(1 => 'This is a required relationship, You must first choose an item of this type to go with your entity');
         echo '<span class="words_error">' . $e_mess[$this->admin_page->request['error_message']] . '</span><br />';
     }
     if ($this->_locked) {
         echo '<div class="lockNotice"><img class="lockIndicator" src="' . REASON_HTTP_BASE_PATH . 'ui_images/lock_12px.png" alt="locked" width="12" height="12" /> This relationship is locked. If you need to attach or detach items, please contact an administrator.</div>';
     } elseif ($this->_show_lock_info) {
         echo '<div class="lockNotice"><img class="lockIndicator" src="' . REASON_HTTP_BASE_PATH . 'ui_images/lock_12px_grey_trans.png" alt="locked" width="12" height="12" /> Note: this relationship is locked for some users.</div>';
     }
     $colspan = count($this->viewer->columns) + 1;
     echo '<table border="0"><tr><td>';
     // use plural type name
     echo $this->get_select_jump_link();
     $this->viewer->show_associated_items();
     echo '</td></tr>' . "\n";
     if ($this->_locked) {
         echo '</table>' . "\n";
         return;
     }
     echo '<tr><td>&nbsp;';
     echo '</td></tr>';
     echo '<tr><td>';
     echo $this->get_selected_jump_link();
     echo '</td></tr><tr><td class="assocHead" colspan="' . $colspan . '">';
     echo '&nbsp;&nbsp;Not Selected<br /><br /></td></tr><tr><td colspan="' . $colspan . '"><table><tr>';
     $list_mod = new ListerModule($this->admin_page);
     $list_mod->filter =& $this->filter;
     $list_mod->show_filters();
     echo '</tr></table></td></tr>';
     if (empty($this->admin_page->request[CM_VAR_PREFIX . 'type_id']) && $this->admin_page->cur_module == 'Associator' && reason_user_has_privs($this->admin_page->user_id, 'add')) {
         echo '<tr><td>';
         $this->do_add_link();
         echo '</td></tr>' . "\n";
     }
     $assoc_ok = !$this->admin_page->is_second_level() && $this->admin_page->cur_module == 'Associator' && $this->some_site_shares_type();
     $sharing_ok = $this->admin_page->is_second_level() && $this->admin_page->cur_module == 'Sharing';
     if (reason_user_has_privs($this->admin_page->user_id, 'borrow') && ($assoc_ok || $sharing_ok)) {
         echo '<tr><td>';
         $this->do_sharing_link();
         echo '</td></tr>' . "\n";
     }
     echo '<tr><td>';
     $this->viewer->do_display();
     echo '</td></tr>' . "\n";
     echo '</table>' . "\n";
 }
Example #27
0
<?php 
if (defined('UNIVERSAL_CSS_PATH') && UNIVERSAL_CSS_PATH != '') {
    echo '<link rel="stylesheet" type="text/css" href="' . UNIVERSAL_CSS_PATH . '" />' . "\n";
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="robots" content="none" />
</head>
<body>

<h3>Reason Stats</h3>
<?php 
reason_include_once('function_libraries/user_functions.php');
force_secure_if_available();
$current_user = check_authentication();
if (!reason_user_has_privs(get_user_id($current_user), 'view_sensitive_data')) {
    die('<p>You do not have permission to view Reason stats.</p><p>Only Reason users who have sensitive data viewing privileges may do that.</p></body></html>');
}
if (!THIS_IS_A_DEVELOPMENT_REASON_INSTANCE && (!isset($_REQUEST['run_anyway']) || $_REQUEST['run_anyway'] != 1)) {
    echo '<h4>Before we do this...</h4><p>This script is really intensive, and should really only be run on a development instance so that it doesn\'t disrupt a production instance of Reason.</p>';
    echo '<p>If your Reason database is large, you should import your database to a development instance of Reason and run the script there. If your instance of Reason ';
    echo 'is small, it is probably safe to ignore this warning.</p>';
    echo '<a href="?run_anyway=1">Run this script despite the warning.</a></p>';
    die;
}
connectDB(REASON_DB);
// counts of things
$single_res_queries = array(array('q' => 'SELECT MAX(id) AS max_id FROM entity', 'name' => 'Entity Auto Increment ID', 'var' => 'max_id'), array('q' => 'SELECT COUNT(*) AS count FROM entity', 'name' => 'Number of Entities', 'var' => 'count'), array('q' => 'SELECT MAX(id) AS max_id FROM relationship', 'name' => 'Relationship Auto Increment ID', 'var' => 'max_id'), array('q' => 'SELECT COUNT(*) AS count FROM relationship', 'name' => 'Number of Relationships', 'var' => 'count'));
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : 5;
reset($single_res_queries);
while (list(, $info) = each($single_res_queries)) {
 *
 * Note: This scipt is not finding any duplicates.  I'm not currently sure if this is because there aren't any, or because there is something "off" about it.
 * In any case, this script should probably be considered experimental until we have it figured out.
 * --Matt Ryan, 2006-06-20
 *
 * @package reason
 * @subpackage scripts
 */


include_once( 'reason_header.php' );

reason_include_once( 'function_libraries/user_functions.php' );
force_secure_if_available();
$current_user = check_authentication();
if (!reason_user_has_privs( get_user_id ( $current_user ), 'db_maintenance' ) )
{
	die('<html><head><title>Reason: Delete Duplicate Relationships</title></head><body><h1>Sorry.</h1><p>You do not have permission to delete duplicate relationships.</p><p>Only Reason users who have database maintenance privileges may do that.</p></body></html>');
}

?>
<html>
<head>
<title>Reason: Remove Duplicates</title>
</head>
<body>
<h1>Remove Duplicates</h1>
<?php
if(empty($_POST['do_it']))
{
?>
Example #29
0
 function run()
 {
     echo '<div class="oldBrowserAlert">Notice: Reason works with all browsers.  However, it will look and feel quite a lot nicer if you can use it with a modern, standards-based browser such as Internet Explorer 6+, Mozilla 1.5+, Firefox, Netscape 7, Safari, or Opera.</div>' . "\n";
     if (!HTTPS_AVAILABLE && reason_user_has_privs($this->admin_page->user_id, 'upgrade')) {
         echo '<div id="securityWarning">' . "\n";
         echo '<h3>Security Notice</h3>' . "\n";
         echo '<p>This instance of Reason is running <strong>without</strong> https/ssl. This means that credentials and other potentially sensitive information are being sent in the clear. To run Reason with greater security -- and to make this notice go away -- 1) make sure your server is set up to run https and 2) change the setting HTTPS_AVAILABLE to true in settings/package_settings.php.</p>' . "\n";
         echo '</div>' . "\n";
     }
     if ((!defined('REASON_DISABLE_AUTO_UPDATE_CHECK') || !REASON_DISABLE_AUTO_UPDATE_CHECK) && reason_user_has_privs($this->admin_page->user_id, 'upgrade')) {
         reason_include_once('classes/version_check.php');
         $vc = new reasonVersionCheck();
         $resp = $vc->check();
         switch ($resp['code']) {
             case 'version_out_of_date':
                 echo '<div class="versionUpdateNotice">' . htmlspecialchars($resp['message'], ENT_QUOTES);
                 if (!empty($resp['url'])) {
                     echo ' <a href="' . htmlspecialchars($resp['url'], ENT_QUOTES) . '">Link</a>';
                 }
                 echo '</div>' . "\n";
                 break;
             case 'no_version_provided':
             case 'version_not_recognized':
                 trigger_error('Error checking version: ' . $resp['message']);
                 break;
         }
     }
     if (reason_unique_name_exists('whats_new_in_reason_blurb')) {
         $intro = new entity(id_of('whats_new_in_reason_blurb'));
         echo "\n" . '<div id="whatsNew">' . "\n";
         echo '<h3>' . $intro->get_value('name') . '</h3>' . "\n";
         echo '<p><em>Updated ' . prettify_mysql_timestamp($intro->get_value('last_modified'), 'j F Y') . '</em></p>' . "\n";
         echo $intro->get_value('content');
         echo '</div>' . "\n";
     }
 }
<title>Reason Upgrade: Miscellaneous 4.0b3 to 4.0b4 Updates</title>
</head>

<body>
<?php 
force_secure_if_available();
$GLOBALS['__cur_username__hack__'] = reason_require_authentication();
$usr = new user();
$user = $usr->get_user($GLOBALS['__cur_username__hack__']);
if ($user) {
    $GLOBALS['__cur_user_id_hack__'] = $user->id();
} else {
    echo 'You must be a valid reason user to run this script';
    die;
}
if (!reason_user_has_privs($GLOBALS['__cur_user_id_hack__'], 'upgrade')) {
    die('You must have upgrade privileges to run this script');
}
echo '<h2>Reason: Miscellaneous 4.0b3 to 4.0b4 Updates</h2>';
if (!isset($_POST['verify'])) {
    echo '<p>This script does a variety of minor updates to your Reason instance, including:</p>';
    echo '<ul>';
    echo '<li>Setting up a new content manager for themes</li>';
    echo '<li>Adding new themes:';
    echo '<ul>';
    foreach (get_themes_to_add_b3_to_b4() as $theme_uname => $theme_info) {
        if (!empty($theme_info['name'])) {
            $name = $theme_info['name'];
        } else {
            $name = prettify_string($theme_uname);
        }