Example #1
0
		function _redirect_from_old_url($request)
		{
			foreach( $this->request as $key => $vals)
			{
				
				if( $key == 'filters')
				{
					foreach($vals as $filter_key => $filter)
					$redirect_params['filter'.$filter_key] = $filter['type'].'-'.$filter['id'];
				} 
				else
				{
					$redirect_params[$key] = $vals;
				}
				
			}
			$redirect_link = carl_construct_redirect($redirect_params);
			header('Location: ' . $redirect_link);
			exit;
		}
Example #2
0
 function load_params()
 {
     $param_cleanup_rules = array('site_id' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')), 'type_id' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')), 'user_id' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')), 'id' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')), 'rel_id' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')), 'cur_module' => array('function' => 'check_against_regexp', 'extra_args' => array('safechars')), 'viewer_id' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')), 'entity_a' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')), 'entity_b' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')), 'new_entity' => array('function' => 'check_against_array', 'extra_args' => array(0, 1)), 'debugging' => array('function' => 'check_against_array', 'extra_args' => array('true', 'false')), 'state' => array('function' => 'check_against_array', 'extra_args' => array('deleted', 'pending', 'live')));
     $params_to_localize = array('site_id', 'user_id', 'type_id', 'id', 'rel_id', 'cur_module', 'viewer_id', 'entity_a', 'entity_b', 'debugging');
     $request = carl_get_request();
     $this->request = array_merge($request, carl_clean_vars($request, $param_cleanup_rules));
     foreach ($params_to_localize as $v) {
         if (isset($this->request[$v])) {
             $this->{$v} = $this->request[$v];
         }
     }
     // verify that id corresponds to an entity
     if ($this->id > 0) {
         $e = new entity($this->id);
         $values = $e->get_values();
         if (empty($values)) {
             trigger_error('Malformed request from ' . $_SERVER['HTTP_REFERER'] . ' (ID given does not correspond to an entity)');
             $this->id = '';
         }
     }
     if (isset($this->request['PHPSESSID'])) {
         unset($this->request['PHPSESSID']);
     }
     $old_id = !empty($this->request[CM_VAR_PREFIX . 'id']) ? $this->request[CM_VAR_PREFIX . 'id'] : false;
     $id = !empty($this->request['id']) ? $this->request['id'] : false;
     if ($old_id && $id && $id == $old_id) {
         $new_link = carl_construct_redirect($this->get_default_args());
         header('Location: ' . $new_link);
         echo '<p>Attempted to redirect to <a href=' . htmlspecialchars($new_link, ENT_QUOTES) . '>here</a>, but seem to have failed.</p>';
         die;
     }
     $this->select_user();
 }
Example #3
0
	function process()
	{	
		$description = trim(tidy($this->get_value('description')));
		$content = trim(get_safer_html(tidy($this->get_value('post_content'))));
		if(carl_empty_html($description))
		{
			$words = explode(' ', $content, 31);
			unset($words[count($words)-1]);
			$description = implode(' ', $words).'…';
			$description = trim(tidy($description)); // we're tidying it twice so that if we chop off a closing tag tidy will stitch it back up again
		}
		
		if(!empty($this->user_netID))
		{
			$user_id = make_sure_username_is_user($this->user_netID, $this->site_info->id());
		}
		else
		{
			$user_id = $this->site_info->id();
		}
		
		if($this->hold_posts_for_review)
		{
			$status = 'pending';
		}
		else
		{
			$status = 'published';
		}

		$values = array (
			'status' => $status,
			'release_title' => trim(strip_tags($this->get_value('title'))),
			'author' => trim(strip_tags($this->get_value('author'))),
			'content' => $content,
			'description' => $description,
			'datetime' => date('Y-m-d H:i:s', time()),
			'keywords' => implode(', ', array(strip_tags($this->get_value('title')), date('Y'), date('F'))),
			'show_hide' => 'show',
			'new' => 0
		);
				
		$this->new_post_id = reason_create_entity( 
			$this->site_info->id(), 
			id_of('news'), 
			$user_id, 
			$values['release_title'], 
			$values
		);
		
		create_relationship(
			$this->new_post_id,
			$this->publication->id(),
			relationship_id_of('news_to_publication')
		);

		if ($this->successfully_submitted())
		{
			
			if($this->hold_posts_for_review)
			{
				echo '<p>Posts are being held for review on this publication. Please check back later to see if your post has been published.</p>';
				echo '<a href="?">Back to main page</a>';
			
			}
			else
			{
				echo '<p>Your post has been published.</p>';
				echo '<a href="'.carl_construct_redirect(array('story_id'=>$this->new_post_id)).'">View it.</a>';
			}
		}
		
		if($this->get_value('issue'))
		{
			create_relationship($this->new_post_id, $this->get_value('issue'), relationship_id_of('news_to_issue'));
		}
		
		if($this->get_value('section'))
		{
			create_relationship($this->new_post_id, $this->get_value('section'), relationship_id_of('news_to_news_section'));
		}
		
		if($this->get_value('categories'))
		{
			foreach($this->get_value('categories') as $category_id)
			{
				// Check to make sure ids posted actually belong to categories in the site
				if(array_key_exists($category_id, $this->categories))
				{
					create_relationship(
						$this->new_post_id,
						$category_id,
						relationship_id_of('news_to_category')
					);
				}
			}
		}
		
		$this->show_form = false;

		$this->do_notifications();
	}
Example #4
0
/**
 * Deprecated -- use carl_construct_redirect()
 * @deprecated
 */
function construct_redirect($new_request_vars = array(''), $preserve_request_var = array(''), $base_path = '')
{
    $call_info = array_shift(debug_backtrace());
    $code_line = $call_info['line'];
    $file = array_pop(explode('/', $call_info['file']));
    trigger_error('construct_redirect called by ' . $file . ' on line ' . $code_line . ' - use carl_construct_redirect instead', WARNING);
    return carl_construct_redirect($new_request_vars, $preserve_request_var, $base_path);
}