Exemplo n.º 1
0
 /**
  * Determines whether or not the user can inline edit.
  *
  * @return boolean;
  */
 function user_can_inline_edit()
 {
     if (!isset($this->_user_can_inline_edit)) {
         $this->_user_can_inline_edit = reason_check_access_to_site($this->site_id);
     }
     return $this->_user_can_inline_edit;
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
 /**
  * Determines whether or not the user can inline edit. Only admin users may 
  * perform inline editing for the page title.
  *
  * @return boolean;
  */
 function user_can_inline_edit()
 {
     if (!isset($this->_user_can_inline_edit)) {
         // Additionally, check to see if the user has editing privileges for the 'name' field
         $page_entity = new entity($this->page_id);
         if ($netid = reason_check_authentication()) {
             if ($user_id = get_user_id($netid)) {
                 $user = new entity($user_id);
                 $field_check = $page_entity->user_can_edit_field('name', $user);
             }
         }
         $this->_user_can_inline_edit = $netid && reason_check_access_to_site($this->site_id) && $field_check;
     }
     return $this->_user_can_inline_edit;
 }
Exemplo n.º 4
0
/**
 * check if the currently logged in user has access to the site - do not force login
 * @deprecated use reason_check_access_to_site
 */
function user_has_access_to_site($site_id, $force_refresh = false)
{
	return reason_check_access_to_site($site_id, $force_refresh);
}
Exemplo n.º 5
0
		/**
		 * Determines whether or not the user can inline edit.
		 *
		 * Returns true in two cases:
		 *
		 * 1. User is a site administrator of the page the story belongs to.
		 * 2. User is the author of the post.
		 *
		 * @return boolean;
		 */
		function user_can_inline_edit()
		{
			if (!isset($this->_user_can_inline_edit))
			{
				if (!empty($this->current_item_id))
				{
					$story_id = $this->current_item_id;
					$story = new entity($story_id);
					if (reason_is_entity($story, 'news'))
					{
						$owner = get_owner_site_id($story_id);
						$this->_user_can_inline_edit = (!empty($owner) && reason_check_authentication() && ((reason_check_access_to_site($owner) || $this->user_is_author())));
					}
					else $this->_user_can_inline_edit = false;
				}
				else
				{
					$this->_user_can_inline_edit = false;
				}
			}
			return $this->_user_can_inline_edit;
		}
Exemplo n.º 6
0
 /**
  * @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);
 }
Exemplo n.º 7
0
		/**
		 * Determines whether or not the user can inline edit. Only admin users and the 
		 * policy maintaner may perform inline editing for policies.
		 *
		 * @return boolean;
		 */
		function user_can_inline_edit()
		{
			if (!isset($this->_user_can_inline_edit))
			{
				$this->_user_can_inline_edit = false;
				if($cur_user = reason_check_authentication())
				{
					if (isset($this->policy))
					{
						$owner = $this->policy->get_owner();
						if($owner && reason_check_access_to_site($owner->id()))
						{
							$this->_user_can_inline_edit = true;
						}
						else
						{
							$departments = $this->policy->get_left_relationship( 'policy_to_responsible_department' );
							if(!empty($departments))
							{
								foreach($departments as $department)
								{
									if($department->get_value('policy_maintainer') == $cur_user)
									{
										$this->_user_can_inline_edit = true;
										break;
									}
								}
							}
						}
					}
				}
			}
			return $this->_user_can_inline_edit;
		}		
Exemplo n.º 8
0
	/**
	 * Can the current user inline edit a particular event?
	 *
	 * @param integer $event_id
	 * @return boolean;
	 */
	function user_can_inline_edit_event($event_id)
	{
		if ($this->event && $event_id == $this->event->id())
			$owner_site = $this->event->get_owner();
		elseif (isset($this->events[$event_id]))
			$owner_site = $this->events[$event_id]->get_owner();
		else
			return false;
			
		if (!isset($this->_user_can_inline_edit_sites[$owner_site->id()]))
		{
			$this->_user_can_inline_edit_sites[$owner_site->id()] = reason_check_access_to_site($owner_site->id());
		}
		return $this->_user_can_inline_edit_sites[$owner_site->id()];
	}