Esempio n. 1
0
	function alter_feed()
	{
		// Start with defaults
 		$this->do_default_field_mapping();

		// Then change only the link field
		$this->feed->set_item_field_map('link', 'id');
		$this->feed->set_item_field_handler('link', 'make_link', true);
		$this->feed->set_item_field_map('enclosure', 'id');
		
		// Modify entity selector
		$num = !empty($_REQUEST['num']) ? turn_into_int($_REQUEST['num']) : '0';
		$start = !empty($_REQUEST['start']) ? turn_into_int($_REQUEST['start']) : '0';
		if( !empty($_REQUEST['q']) )
		{
			$this->feed->es->add_relation('(entity.name LIKE "%'.addslashes($_REQUEST['q']) . '%"' .
						      ' OR meta.description LIKE "%' . addslashes($_REQUEST['q']) . '%"'.
							  ' OR meta.keywords LIKE "%' . addslashes($_REQUEST['q']) . '%"'.
							  ' OR chunk.content LIKE "%' . addslashes($_REQUEST['q']) . '%"'.
							  ')');
		}
		$this->feed->es->set_num( $num );
		$this->feed->es->set_start( $start );
		$this->feed->es->set_order( 'entity.last_modified DESC, dated.datetime DESC, entity.name ASC' );
	}
 function process()
 {
     //prep site
     $this->helper->ensure_type_is_on_site(id_of('publication_type'));
     $this->helper->ensure_type_is_on_site(id_of('group_type'));
     $this->helper->ensure_nobody_group_is_on_site();
     // gather core information
     $pub_type_id = id_of('publication_type');
     $name = trim(strip_tags($this->get_value('pub_name')));
     // populate values array
     $values['new'] = 0;
     $values['description'] = trim(get_safer_html($this->get_value('pub_description')));
     $values['unique_name'] = trim(strip_tags($this->get_value('pub_unique_name')));
     $values['state'] = 'Live';
     $values['hold_comments_for_review'] = 'no';
     $values['posts_per_page'] = turn_into_int($this->get_value('pub_posts_per_page'));
     $values['blog_feed_string'] = trim(strip_tags($this->get_value('pub_rss_feed_url')));
     $values['publication_type'] = 'Newsletter';
     $values['has_issues'] = 'no';
     $values['has_sections'] = 'no';
     $values['date_format'] = $this->get_value('date_format');
     // create the publication
     $pub_id = reason_create_entity($this->site_id, $pub_type_id, $this->user_id, $name, $values);
     // associate with nobody posting and commenting groups
     create_relationship($pub_id, id_of('nobody_group'), relationship_id_of('publication_to_authorized_posting_group'));
     create_relationship($pub_id, id_of('nobody_group'), relationship_id_of('publication_to_authorized_commenting_group'));
 }
Esempio n. 3
0
 function set_event($event)
 {
     if (!is_object($event)) {
         $event_id = turn_into_int($event);
         $event = new entity($event_id);
     }
     if ($event->get_values() && $event->get_value('type') == id_of('event_type')) {
         $this->event = $event;
     } else {
         trigger_error('Entity passed to reasonEvent object that is not an event');
         $this->event = NULL;
     }
 }
Esempio n. 4
0
 /**
  * initialize request
  *
  * @param int $site_id id of the site from where the request originates
  * @param int $al_relationship_id the id of the allowable relationship
  * @param int $left_entity_id the id of the entity on the a site of the relationship
  * @param int $entity_id the id of the entity that is moving up or down
  * @param int $row_id the row number of the entity that is moving up or down
  * @param string $direction which direction the entity is moving
  * @param string $user_netID the netid of the user initiating the request
  * @param string $background set to 'yes' if the request comes via xmlhttp, 'no' if not
  */
 function init($site_id, $al_relationship_id, $left_entity_id, $entity_id, $row_id, $direction, $user_netID, $background)
 {
     $this->user_netID = check_against_regexp($user_netID, array('alphanumeric'));
     $this->direction = check_against_array($direction, array('moveup', 'movedown'));
     $this->left_entity_id = turn_into_int($left_entity_id);
     $this->entity_id = turn_into_int($entity_id);
     $this->row_id = turn_into_int($row_id);
     $this->al_relationship_id = turn_into_int($al_relationship_id);
     $this->site_id = turn_into_int($site_id);
     //$this->type_id = turn_into_int($type_id);
     $this->background = check_against_array($background, array('yes', 'no'));
     // consider passing this in earlier, or just use
 }
Esempio n. 5
0
 /** 
  * Set myself up.
  */
 function __construct()
 {
     $type = turn_into_string($_GET['type']);
     $site_id = turn_into_int($_GET['site_id']);
     $this->type(id_of('image'));
     $this->site_id($site_id);
     $last_mod = isset($_GET['lastmod']) ? $_GET['lastmod'] : false;
     $num = !empty($_REQUEST['num']) ? turn_into_int($_REQUEST['num']) : '500';
     $offset = !empty($_REQUEST['offset']) ? turn_into_int($_REQUEST['offset']) : '0';
     $this->num($num);
     $this->offset($offset);
     $this->last_mod($last_mod);
     $this->caching(isset($_GET['caching']) ? turn_into_boolean($_GET['caching']) : true);
 }
function populate_viewed_quote_ids($x)
{
    $quote_ids = explode(",", $x);
    if (!empty($quote_ids)) {
        foreach ($quote_ids as $k => $id) {
            $clean_id = turn_into_int($id);
            if (!empty($clean_id)) {
                $clean_quote_ids[$k] = $clean_id;
            }
        }
    }
    if (!empty($clean_quote_ids)) {
        return $clean_quote_ids;
    }
}
Esempio n. 7
0
	/**
	 * Create a new allowable relationship
	 *
	 * Checks to make sure we are not duplicating an existing allowable relationship before creating new one.
	 * 
	 * Checks include: 
	 * 1. the type ids must be the ids of existing reason types
	 * 2. the name must be a nonempty string containing only numbers, letters, and underscores that does not already exist in the allowable relationship table (exception: borrows and owns)
	 * 3. for borrows or owns relationships, the type must not already have an allowable relationship of that type
	 *
	 * @param integer $a_side_type_id The id of the type on the left side of the relationship
	 * @param integer $b_side_type_id The id of the type on the right side of the relationship
	 * @param string $name The unique name of the allowable relationship (or "owns" or "borrows")
	 * @param array $other_data Additional data to be stored in the allowable_relationship table, keyed by field name
	 * @return mixed id of newly created relationship if successful; false if failure
	 *
	 * @todo update to do verification and handling of new "type" field
	 */
	function create_allowable_relationship($a_side_type_id,$b_side_type_id,$name,$other_data = array())
	{
		// validate data
		
		$a_side_type_id = turn_into_int($a_side_type_id);
		$b_side_type_id = turn_into_int($b_side_type_id);
		$name = turn_into_string($name);
		
		if(empty($a_side_type_id))
		{
			trigger_error('$a_side_type_id must be a nonzero integer in create_allowable_relationship()');
			return false;
		}
		$a_ent = new entity($a_side_type_id);
		if(!empty($a_ent))
		{
			if($a_ent->get_value('type') != id_of('type'))
			{
				trigger_error('$a_side_type_id must be the ID of a Reason type entity');
				return false;
			}
		}
		else
		{
			trigger_error('$a_side_type_id is not the ID of a Reason entity');
			return false;
		}
		if(empty($b_side_type_id))
		{
			trigger_error('$b_side_type_id must be a nonzero integer in create_allowable_relationship()');
			return false;
		}
		$b_ent = new entity($b_side_type_id);
		if(!empty($b_ent))
		{
			if($b_ent->get_value('type') != id_of('type'))
			{
				trigger_error('$b_side_type_id must be the ID of a Reason type entity');
				return false;
			}
		}
		else
		{
			trigger_error('$b_side_type_id is not the ID of a Reason entity');
			return false;
		}
		if(empty($name))
		{
			trigger_error('$name must be a string in create_allowable_relationship()');
			return false;
		}
		if( !preg_match( "|^[0-9a-z_]*$|i" , $name ) )
		{
			trigger_error('$name must only contain numbers, letters, and underscores');
			return false;
		}
		
		if (!reason_relationship_names_are_unique())
		{
			$repeatable_names = array('borrows','owns');
			if( !in_array($name,$repeatable_names) && reason_relationship_name_exists($name, false) )
			{
				trigger_error('Unable to create allowable relationship named '.$name.' because there is already an allowable relationship with that name in Reason');
				return false;
			}
			if(in_array($name,$repeatable_names))
			{
				if($a_side_type_id != id_of('site'))
				{
					trigger_error('The a_side_type_id of borrows and owns relationships must be the id of the site type');
					return false;
				}
				// check to see if an owns/borrows relationship already exists for this type
				if ( (($name == 'owns') && get_owns_relationship_id($b_side_type_id)) ||
					 (($name == 'borrows') && get_borrows_relationship_id($b_side_type_id)) )
				{
					trigger_error($name.' relationship already exists between '.$a_side_type_id.' and '.$b_side_type_id.'.');
					return false;
				}
			}
		}
		else
		{
			if (reason_relationship_name_exists($name, false))
			{
				trigger_error('Unable to create allowable relationship named '.$name.' because there is already an allowable relationship with that name in Reason');
				return false;
			}
			if (isset($other_data['type']) && ( ($other_data['type'] == 'owns') || ($other_data['type'] == 'borrows') ) )
			{
				if ($a_side_type_id != id_of('site'))
				{
					trigger_error('The a_side_type_id of borrows and owns relationships must be the id of the site type');
					return false;
				}
				// enforce our naming convention
				$owns_name_should_be = $a_ent->get_value('unique_name') . '_owns_' . $b_ent->get_value('unique_name');
				$borrows_name_should_be = $a_ent->get_value('unique_name') . '_borrows_' . $b_ent->get_value('unique_name');
				if ( ($other_data['type'] == 'owns') && ($name != $owns_name_should_be) )
				{
					trigger_error('A new allowable relationship of type owns must follow the naming convention a_side_unique_name_owns_b_side_entity_unique_name');
					return false;
				}
				elseif ( ($other_data['type'] == 'borrows') && ($name != $borrows_name_should_be) )
				{
					trigger_error('A new allowable relationship of type borrows must follow the naming convention a_side_unique_name_borrows_b_side_entity_unique_name');
					return false;
				}
			}
			if (isset($other_data['type']) && ($other_data['type'] == 'archive'))
			{
				if ($a_side_type_id != $b_side_type_id)
				{
					trigger_error('The a_side_type_id and b_side_type_id of archive relationships must be the same.');
					return false;
				}
				$archive_name_should_be = $a_ent->get_value('unique_name') . '_archive';
				if ($name != $archive_name_should_be)
				{
					trigger_error('A new allowable relationship of type archive must follow the naming convention type_unique_name_archive');
					return false;
				}
			}
		}
		
		// do the creation of the allowable relationship
		
		$default_values = array(
								'directionality'=>'unidirectional',
								'is_sortable'=>'no',
								'connections'=>'many_to_many',
								'required'=>'no',
		);
		if (reason_relationship_names_are_unique()) $default_values['type'] = 'association';
		$values = array_merge($default_values,$other_data);
		$values['relationship_a'] = $a_side_type_id;
		$values['relationship_b'] = $b_side_type_id;
		$values['name'] = $name;
		
		$sqler = new SQLER();
		if($sqler->insert('allowable_relationship',$values))
		{
			$insert_id = mysql_insert_id();
			reason_refresh_relationship_names();
			return $insert_id;
		}
		else
		{
			return false;
		}
	}
Esempio n. 8
0
/** @access private */
function _get_disco_async_upload_hidden_fields($upload_sid)
{
    if ($GLOBALS['_disco_upload_session_sent']) {
        return '';
    }
    $session =& get_reason_session();
    $user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : 0;
    // IMPORTANT NOTE: Keep this list of fields in sync with the list in
    // _get_disco_async_upload_internal_field_names() above.
    $fields = array('user_session' => $session->get_id(), 'transfer_session' => $upload_sid, 'receiver' => reason_get_async_upload_script_uri('receive'), 'remover' => reason_get_async_upload_script_uri('destroy'), 'user_id' => turn_into_int($user_id));
    $html = array();
    foreach ($fields as $name => $value) {
        $html[] = '<input type="hidden" name="_reason_upload_' . $name . '" ' . 'value="' . $value . '" />';
    }
    $GLOBALS['_disco_upload_session_sent'] = true;
    return implode("\n", $html);
}
Esempio n. 9
0
             }
             $i++;
         }
     }
 }
 $d->close();
 $out[] = '<h2>Entered asset deletion phase</h2>';
 $i = 1;
 $d = dir(ASSET_PATH);
 while (false !== ($entry = $d->read())) {
     if ($i > $limit) {
         break;
     }
     if (!in_array($entry, $ignore)) {
         $parts = explode('.', $entry);
         $id = turn_into_int($parts[0]);
         $es = new entity_selector();
         $es->add_relation('entity.id = ' . $id);
         $es->set_num(1);
         $assets = $es->run_one(id_of('asset'));
         if (empty($assets)) {
             if ($test_mode) {
                 $out[] = 'Would have deleted ' . $entry . ' (id: ' . $id . ')';
             } else {
                 unlink(ASSET_PATH . $entry);
                 $out[] = 'Deleted ' . $entry . ' (id: ' . $id . ')';
             }
             $i++;
         }
     }
 }
Esempio n. 10
0
</head>
<?php 
$audiences = array('students' => array('name' => 'Students', 'unique_name' => 'students_audience', 'directory_service_value' => 'student'), 'faculty' => array('name' => 'Faculty', 'unique_name' => 'faculty_audience', 'directory_service_value' => 'faculty'), 'staff' => array('name' => 'Staff', 'unique_name' => 'staff_audience', 'directory_service_value' => 'staff'), 'alumni' => array('name' => 'Alumni', 'unique_name' => 'alumni_audience', 'directory_service_value' => 'alum'), 'public' => array('name' => 'General Public', 'unique_name' => 'public_audience', 'directory_service_value' => 'public'), 'families' => array('name' => 'Families', 'unique_name' => 'families_audience', 'directory_service_value' => 'family'), 'prospective_students' => array('name' => 'Prospective Students', 'unique_name' => 'prospective_students_audience', 'directory_service_value' => 'prospect', 'directory_service' => 'ldap_carleton_prospects'), 'new_students' => array('name' => 'New Students', 'unique_name' => 'new_students_audience', 'directory_service_value' => 'new_student', 'directory_service' => 'ldap_carleton,ldap_carleton_prospects', 'audience_filter' => '(|(ds_affiliation=student)(&(ds_affiliation=prospect)(|(carlProspectStatus=Deferred*)(carlProspectStatus=Deposit*))))'));
$out = array();
?>
<body>
<?php 
if (empty($_REQUEST['do_it']) && empty($_REQUEST['step_2'])) {
    echo '<form>';
    echo 'Number to run: <input type="text" name="num" value="100"/><br />';
    echo '<input type="submit" name="do_it" value="Do it" />';
    echo '</form>';
} elseif (!empty($_REQUEST['do_it'])) {
    $out[] = 'Starting';
    if (!empty($_REQUEST['num'])) {
        $num = turn_into_int($_REQUEST['num']);
    } else {
        $num = 100;
    }
    $audience_type_id = id_of('audience_type');
    if (empty($audience_type_id)) {
        $out[] = 'Audience type doesn\'t exist';
        $audience_type_id = reason_create_entity(id_of('master_admin'), id_of('type'), get_user_id('root'), 'Audience', array('plural_name' => 'Audiences', 'unique_name' => 'audience_type'));
        $out[] = 'Audience type created';
        $iq = 'INSERT INTO allowable_relationship (relationship_a,relationship_b,name) VALUES (' . id_of('site') . ',' . $audience_type_id . ',"owns")';
        db_query($iq, 'Unable to add new ownership relationship');
        $owns_id = mysql_insert_id();
        create_relationship(id_of('master_admin'), $audience_type_id, $owns_id);
        $out[] = 'Added owns relationship';
        // create the archive relationship
        $jq = 'INSERT INTO allowable_relationship (relationship_a,relationship_b,description,name,connections,required) VALUES (' . $audience_type_id . ',' . $audience_type_id . ',"' . ' Audience Archive Relationship","' . 'audience_type_archive","many_to_many","no")';
Esempio n. 11
0
 * @subpackage scripts
 */
/**
 * include dependencies
 */
$reason_session = false;
include_once 'reason_header.php';
reason_include_once('classes/entity_selector.php');
$start_time = get_microtime();
// clean up type id
if (!empty($_GET['type_id'])) {
    $type_id = turn_into_int($_GET['type_id']);
}
// clean up site id
if (!empty($_GET['site_id'])) {
    $site_id = turn_into_int($_GET['site_id']);
}
// clean up feed file name
if (!empty($_GET['feed'])) {
    // remove everything that might allow an arbitrary file to be requested
    // The file must be in reason's feeds directory and have not periods or spaces in its name
    // .php should not be included in the request
    $requested_file = str_replace(array('/', '\\', '.', ' '), '', $_GET['feed']);
}
if (!empty($type_id)) {
    $type = new entity($type_id);
    if (!empty($requested_file)) {
        $feed_file = $requested_file;
    } elseif ($type->get_value('custom_feed')) {
        $feed_file = str_replace('.php', '', $type->get_value('custom_feed'));
    } else {
Esempio n. 12
0
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . "\n";
echo '<meta name="robots" content="none" />' . "\n";
echo '</head>' . "\n";
echo '<body>' . "\n";
if (!reason_user_has_privs(get_user_id($current_user), 'update_urls')) {
    die('<h1>Sorry.</h1><p>You do not have permission to update urls.</p></body></html>');
}
$es = new entity_selector();
$es->add_type(id_of('site'));
$es->add_relation('site.base_url IS NOT NULL AND site.base_url != ""');
// order results by name so the site picker is easy to use
$es->set_order('entity.name');
$sites = $es->run_one();
$mode = !empty($_REQUEST['mode']) ? $_REQUEST['mode'] : '';
$id = !empty($_REQUEST['id']) ? $_REQUEST['id'] : '';
$id = turn_into_int($id);
echo '<a href="?mode=update">Update All Rewrites</a> | <a href="?mode=check">Check Site Dir Configuration</a> | ';
echo 'Update One Site <form style="display: inline"><input type="hidden" name="mode" value="update"/>';
echo '<select name="id">';
foreach ($sites as $site) {
    echo '<option value="' . $site->id() . '">' . $site->get_value('name') . '</option>';
}
echo '</select>';
echo '<input type="submit" value="Update"/>';
echo '</form> <br/><br/>';
echo 'This script will either update all URLs in this domain or test every site to see if it is properly configured. ' . 'If a site is not properly configured, this script will dump a list of commands that will bring the site to the ' . 'proper state.  Someone with shell access needs to run these commands and watch to see if they all work.<br /><br />' . "You can also update all URLS from the server's command line by typing into the shell:<br />" . 'curl -k -f https://' . htmlspecialchars($_SERVER['SERVER_NAME']) . REASON_HTTP_BASE_PATH . 'scripts/urls/update_urls_cli.php';
echo '<strong>';
if ($mode == 'check') {
    echo 'Checking Site Configuration - look at bottom of page to see what needs be done.';
} elseif ($mode == 'update') {
    if (empty($id)) {
Esempio n. 13
0
$es->limit_tables(array('page_node', 'url'));
$es->limit_fields('entity.name, page_node.custom_page, page_node.url_fragment, url.url');
$es->add_right_relationship_field('owns', 'entity', 'id', 'owner_id');
$es->add_right_relationship_field('owns', 'entity', 'name', 'site_name');
$es->add_left_relationship_field('minisite_page_parent', 'entity', 'id', 'parent_id');
// we add some relations so that we grab only valid pages with names that are not custom url pages
$es->add_relation('(entity.name != "") AND ((url.url = "") OR (url.url IS NULL))');
$result = $es->run_one();
$builder = new reasonPageURL();
$builder->provide_page_entities($result);
$request = carl_get_request();
$detail_mode = isset($request['detail']) ? $request['detail'] == 'true' : false;
$module_limiter = isset($request['limit']) ? conditional_stripslashes(turn_into_string($request['limit'])) : '';
$detail_limiter = isset($request['detail_limit']) ? conditional_stripslashes(turn_into_string($request['detail_limit'])) : '';
$core_local_limiter = isset($request['core_local_limit']) ? check_against_array($request['core_local_limit'], array('core', 'local')) : '';
$num = isset($request['num']) ? turn_into_int($request['num']) : 'All';
if (isset($request['reset'])) {
    header("Location: " . carl_make_redirect(array('limit' => '', 'core_local_limit' => '')));
    exit;
}
// Make an array with first dimension of page type name, second dimension of every page
// ID using the pt, third dimension 'true' for every page type returned by the query.
foreach ($result as $k => $mypage) {
    $page_type_value = $mypage->get_value('custom_page');
    if (empty($page_type_value)) {
        $page_type_value = 'default';
    }
    $reason_page_types[$page_type_value][$k] = 'true';
}
$rpts =& get_reason_page_types();
$all_page_types = $rpts->get_page_types();
Esempio n. 14
0
 /**
  * Adds a type to the entity selector.  Normally, this is only called once per ES.
  * If more than one type is set up in the $type array, then when run() is called
  * the ES will return an array of all the different types.  However, in practice it
  * is generally easier to just create a seperate entity_selector for each type.
  * @param int $id The id of the type you want to select
  */
 function add_type($id)
 {
     if (turn_into_int($id) == $id) {
         $this->type[] = $id;
     } else {
         trigger_error('entity_selector::add_type not passed an integer', EMERGENCY);
     }
 }
Esempio n. 15
0
        echo '<p>PREVENT_MINIMIZATION_OF_REASON_DB is currently set to <strong>false</strong>.  This means that this instance has been set up in a way that allows this script to be run. Remember to <em>only run this script on a <strong>copy</strong> of your real Reason instance</em>.</p>';
        echo '<p><label for="limit">Delete (or test delete): </label>' . $limit_sel . ' items per phase</p>';
        echo '<input type="submit" name="test_it" value="Test the script" />';
        echo '<input type="submit" name="do_it" value="Run the script" />';
    }
    ?>
</form>
<?php 
} else {
    $out = array();
    $test_mode = true;
    if (!PREVENT_MINIMIZATION_OF_REASON_DB && !empty($_POST['do_it'])) {
        $test_mode = false;
    }
    if (!empty($_POST['limit'])) {
        $limit = turn_into_int($_POST['limit']);
    } else {
        $limit = -1;
    }
    echo '<p><a href="?">Return to form</a></p>';
    // Delete Non_reason sites
    $out[] = '<h2>Started Non-Reason Sites</h2>';
    $es = new entity_selector();
    $es->set_num($limit);
    $non_reason_sites = $es->run_one(id_of('non_reason_site_type'));
    $pending_non_reason_sites = $es->run_one(id_of('non_reason_site_type'), 'Pending');
    if (!empty($pending_non_reason_sites)) {
        $non_reason_sites += $pending_non_reason_sites;
    }
    $deleted_non_reason_sites = $es->run_one(id_of('non_reason_site_type'), 'Deleted');
    if (!empty($deleted_non_reason_sites)) {
Esempio n. 16
0
    }
    $validated[$site_id][$page_id] = $site;
    return $site;
}
header("Content-Type: text/html; charset=UTF-8");
// Apache >=2.0.48 sets the REDIRECT REMOTE USER and not the REMOTE USER if an internal redirect
// is sent to an unauthenticated (no BASIC AUTH applied) page.  This gets around our code not
// being aware of the change.
if (empty($_SERVER['REMOTE_USER']) and !empty($_SERVER['REDIRECT_REMOTE_USER'])) {
    $_SERVER['REMOTE_USER'] = $_SERVER['REDIRECT_REMOTE_USER'];
}
$reason_session = false;
$s = get_microtime();
$site_id = !empty($_GET['site_id']) ? turn_into_int($_GET['site_id']) : '';
// force to int
$page_id = !empty($_GET['page_id']) ? turn_into_int($_GET['page_id']) : '';
// force to int
if (!empty($site_id) && !empty($page_id)) {
    // Since we are using mod_rewrite to handle all URLs for the minisites,
    // we have to do a little fancy footwork to get any variables passed
    // on the GET string.  Basically, the original REQUEST_URI has the
    // query string we are interested in, so we parse that URL and then
    // parse the query string.  Then, we merge the two query strings back
    // into the superglobal one.
    // ALSO - this needs to happen before caching so we have access to the REQUEST vars in the proper way
    $my_request = array();
    if (!empty($parts['query'])) {
        parse_str($parts['query'], $my_request);
    }
    // original request clobbers new request
    // GET global also merged so that we can differentiate between gets and posts
Esempio n. 17
0
 function set_cache_lifespan($seconds)
 {
     $ls = turn_into_int($seconds);
     $this->cache_lifespan = $seconds;
 }
Esempio n. 18
0
 function sitebar()
 {
     echo '<div class="sites">';
     if (!$this->id) {
         $sites = $this->get_sites();
         echo '<form action="?" name="siteSwitchSelect" class="jumpNavigation" method="get">' . "\n";
         echo 'Site: <select name="site_id" class="jumpDestination siteMenu">' . "\n";
         echo '<option value="">--</option>' . "\n";
         foreach (array_keys($sites) as $site_id) {
             echo '<option value="' . $site_id . '"';
             if ($site_id == $this->site_id) {
                 echo ' selected="selected"';
             }
             echo '>' . strip_tags($sites[$site_id]->get_value('name')) . '</option>' . "\n";
         }
         $this->show['sites'] = false;
         echo '</select>';
         if (isset($_GET['user_id']) && !empty($_GET['user_id'])) {
             $user_id = turn_into_int($_GET['user_id']);
             if (!empty($user_id)) {
                 echo '<input type="hidden" name="user_id" value="' . $user_id . '" />';
             }
         }
         echo '<input type="submit" class="jumpNavigationGo" value="go" />';
         $cur_site = $sites[$this->site_id];
         $cur_site_base_url = $cur_site->get_value('base_url');
         $cur_site_unique_name = $cur_site->get_value('unique_name');
         $user = new entity($this->user_id);
         $target = $user->get_value('site_window_pref') == 'Popup Window' ? 'target="_blank" ' : '';
         if (!empty($cur_site_base_url) && $cur_site_unique_name != 'master_admin') {
             echo '<a href="http://' . REASON_HOST . $cur_site_base_url . '" ' . $target . 'class="publicSiteLink">Go to public site</a>';
         }
         echo '</form>';
     } else {
         $site = new entity($this->site_id);
         if ($site->get_values()) {
             echo 'Site: <strong>' . $site->get_value('name') . '</strong>' . "\n";
             if ($this->type_id) {
                 $e = new entity($this->type_id);
                 echo '<strong> :: </strong>' . prettify_string($e->get_value('name'));
                 if ($this->id) {
                     $e = new entity($this->id);
                     echo '<strong> :: </strong>' . $e->get_value('name');
                 }
             }
         }
     }
     echo '</div>';
 }
 /**
  * Automatically fills in the name of the a/v item this file is being created within
  * This uses the request, which is probably not ideal, but I think at this point
  * no relationships have yet been created in the DB
  */
 function prefill_name()
 {
     if (!$this->manager->get_value('name') && !empty($this->manager->admin_page->request['__old_id'])) {
         $avid = turn_into_int($this->manager->admin_page->request['__old_id']);
         $av = new entity($avid);
         if ($av->get_value('name')) {
             $this->manager->set_value('name', $av->get_value('name'));
         }
     }
 }
 /**
  * Preps values for the database and and creates new entity
  * @todo the cleaning methods should be available to the view as well outside of save so that the view can filter
  *       the values in the same way for preview purposes (trim/strip tags in most cases)
  */
 function save_classified($values)
 {
     if ($user_netid = reason_check_authentication()) {
         $user = get_user_id($user_netid);
     }
     if (!isset($user) || !$user) {
         $user = get_user_id('classified_user');
     }
     $name = trim(strip_tags($values['name']));
     $category = turn_into_int($values['category']);
     $duration_days = $this->get_classified_duration_days();
     $requires_approval = $this->get_classified_requires_approval();
     if (!empty($values['classified_date_available'])) {
         $ts = get_unix_timestamp($values['classified_date_available']);
         if ($ts) {
             $clean_values['classified_date_available'] = get_mysql_datetime($ts);
         }
     }
     if (!empty($duration_days)) {
         $clean_values['classified_duration_days'] = $duration_days;
     }
     if (!empty($values['location'])) {
         $clean_values['location'] = trim(strip_tags($values['location']));
     }
     if (!empty($values['content'])) {
         $clean_values['content'] = trim(strip_tags($values['content']));
     }
     if (!empty($values['author'])) {
         $clean_values['author'] = trim(strip_tags($values['author']));
     }
     if (!empty($values['classified_contact_email'])) {
         $clean_values['classified_contact_email'] = trim(strip_tags($values['classified_contact_email']));
     }
     if (!empty($values['price'])) {
         $clean_values['price'] = turn_into_int($values['price']);
     }
     if (!empty($clean_values['content'])) {
         $clean_values['description'] = $this->string_summary($values['content']);
     }
     $clean_values['display_contact_info'] = turn_into_int($values['display_contact_info']);
     // always either 0 or 1
     $clean_values['datetime'] = get_mysql_datetime();
     $clean_values['state'] = $requires_approval ? 'Pending' : 'Live';
     $clean_values['new'] = 0;
     $entity_id = reason_create_entity($this->get_site_id(), id_of('classified_type'), $user, $name, $clean_values);
     create_relationship($entity_id, $category, relationship_id_of('classified_to_classified_category'));
     $this->set_classified_id($entity_id);
 }