Exemple #1
0
	/**
	 * Initialize the module
	 */
	function init( $args = array() )
	{
		parent::init( $args );
		
		if(!empty($this->params['list_type']))
		{
			if('verbose' == $this->params['list_type'] && '' == $this->params['list_item_markup'])
			{
				$this->params['list_item_markup'] = 'minisite_templates/modules/events_markup/verbose/verbose_events_list_item.php';
				trigger_error('Events module: list_type parameter is deprecated and will stop working in Reason 4.6. Please specify "list_item_markup" => "'.$this->params['list_item_markup'].'" instead.');
			}
			elseif('schedule' == $this->params['list_type'] && '' == $this->params['list_markup'])
			{
				$this->params['list_markup'] = 'minisite_templates/modules/events_markup/schedule/schedule_events_list.php';
				$this->params['list_item_markup'] = 'minisite_templates/modules/events_markup/schedule/schedule_events_list_item.php';
				trigger_error('Events module: list_type parameter is deprecated and will stop working in Reason 4.6. Please specify "list_markup" => "'.$this->params['list_markup'].'", "list_item_markup" => "'.$this->params['list_item_markup'].'" instead.');
			}
		}
		
		$this->validate_inputs();
		
		$this->register_passables();
		
		$this->handle_jump();
				
		if(empty($this->request['event_id']))
		{
			$this->init_list();
		}
		else
			$this->init_event();		
		$inline_edit =& get_reason_inline_editing($this->page_id);
		$inline_edit->register_module($this, $this->user_can_inline_edit());
		if ($inline_edit->active_for_module($this))
		{
			$user = reason_get_current_user_entity();
			$event_id = $this->request['event_id'];
			/* Event adding is currently not functional
			if( !($event_id = $this->request['event_id'] ) )
			{
				if(reason_user_has_privs($user->id(), 'add' ))
				{
					if ($event_id = create_entity( $this->site_id, id_of('event_type'), $user->id(), '', array( 'entity' => array( 'state' => 'Pending' ) ) ))
					{					
						// We have to do a few things to trick the module into
						// recognizing a new event
						$this->request['event_id'] = $event_id;
						$this->init_event();
						$this->_ok_to_show[$event_id] = true;
					}
				}
			}*/
			
			if ($user && $event = new entity($event_id))
			{
				reason_include_once('classes/admin/admin_page.php');
				reason_include_once('classes/admin/modules/editor.php');
				$site = $event->get_owner();
				
				// Create a new admin page object and set some values to make it
				// think it's running in the admin context.
				$admin_page = new AdminPage();
				$admin_page->id = $event->id();
				$admin_page->site_id = $site->id();
				$admin_page->type_id = id_of('event_type');
				$admin_page->user_id = $user->id(); 
				$admin_page->request = array();
				$admin_page->head_items =& $this->get_head_items();
	
				// Create a new editor with the admin page. This will pick the 
				// appropriate editor class and set up the disco form.
				$this->edit_handler = new EditorModule( $admin_page );
				$this->edit_handler->head_items =& $this->get_head_items();
				$this->edit_handler->init();
				
				$this->edit_handler->disco_item->actions = array('finish' => 'Save');
				$this->edit_handler->disco_item->add_callback(array($this,'editor_where_to'),'where_to');
			}
		}
		if(!empty($this->params['wrapper_id']))
			$this->div_id = $this->params['wrapper_id'];
		
		// get_run_output() should be the very last thing done before the end of init()
		// This is done to allow the markup classes to add head items
		$this->get_run_output();
	}
Exemple #2
0
 function _blurb_is_editable($blurb)
 {
     $user = reason_get_current_user_entity();
     if (!empty($user) && get_owner_site_id($blurb->id()) == $this->site_id && $blurb->user_can_edit_field('content', $user)) {
         return true;
     }
     return false;
 }
Exemple #3
0
	/**
	 * Determines whether or not the user can inline edit.
	 *
	 * Returns true in two cases:
	 *
	 * 1. User is a site administrator of the page.
	 * 2. A site user entity attached to the page has the username of the logged in user.
	 *
	 * @return boolean;
	 */
	function user_can_inline_edit()
	{
		if (!isset($this->_user_can_inline_edit))
		{
			$user = reason_get_current_user_entity();
			$this->_user_can_inline_edit = false;
			if( !empty($user) && $this->cur_page->user_can_edit_field('content',$user) )
			{
				$this->_user_can_inline_edit = true;
			}
			elseif( $this->get_site_user() && $this->cur_page->role_could_edit_field('content', 'editor_user_role') )
			{
				$this->_user_can_inline_edit = true;
			}
		}
		return $this->_user_can_inline_edit;
	}