Ejemplo n.º 1
0
 /**
  * Method to get venue data.
  *
  * @param integer	The id of the venue.
  * @return mixed item data object on success, false on failure.
  */
 public function getItem($itemId = null)
 {
     $jemsettings = JEMHelper::config();
     // Initialise variables.
     $itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('venue.id');
     // Get a row instance.
     $table = $this->getTable();
     // Attempt to load the row.
     $return = $table->load($itemId);
     // Check for a table object error.
     if ($return === false && $table->getError()) {
         $this->setError($table->getError());
         return false;
     }
     $properties = $table->getProperties(1);
     $value = JArrayHelper::toObject($properties, 'JObject');
     // Convert attrib field to Registry.
     //$registry = new JRegistry();
     //$registry->loadString($value->attribs);
     $globalsettings = JemHelper::globalattribs();
     $globalregistry = new JRegistry();
     $globalregistry->loadString($globalsettings);
     $value->params = clone $globalregistry;
     //$value->params->merge($registry);
     // Compute selected asset permissions.
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $asset = 'com_jem.venue.' . $value->id;
     // Check general edit permission first.
     if ($user->authorise('core.edit', $asset)) {
         $value->params->set('access-edit', true);
     } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) {
         // Check for a valid user and that they are the owner.
         if ($userId == $value->created_by) {
             $value->params->set('access-edit', true);
         }
     }
     // Check edit state permission.
     if ($itemId) {
         // Existing item
         $value->params->set('access-change', $user->authorise('core.edit.state', $asset));
     } else {
         $value->params->set('access-change', $user->authorise('core.edit.state', 'com_jem'));
     }
     $value->author_ip = $jemsettings->storeip ? JemHelper::retrieveIP() : false;
     $files = JemAttachment::getAttachments('venue' . $itemId);
     $value->attachments = $files;
     if (empty($itemId)) {
         $value->country = $jemsettings->defaultCountry;
     }
     if (!empty($value->locimage)) {
         if (strpos($value->locimage, 'images/') !== false) {
             # the image selected contains the images path
         } else {
             # the image selected doesn't have the /images/ path
             # we're looking at the locimage so we'll append the venues folder
             $value->locimage = 'images/jem/venues/' . $value->locimage;
         }
     }
     return $value;
 }
Ejemplo n.º 2
0
	/**
	 * Method to get venue data.
	 *
	 * @param integer	The id of the venue.
	 * @return mixed item data object on success, false on failure.
	 */
	public function getItem($itemId = null)
	{
		$jemsettings = JEMHelper::config();

		// Initialise variables.
		$itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('venue.id');

		// Get a row instance.
		$table = $this->getTable();

		// Attempt to load the row.
		$return = $table->load($itemId);

		// Check for a table object error.
		if ($return === false && $table->getError()) {
			$this->setError($table->getError());
			return false;
		}

		$properties = $table->getProperties(1);
		$value = JArrayHelper::toObject($properties, 'JObject');

		// Convert attrib field to Registry.
		//$registry = new JRegistry();
		//$registry->loadString($value->attribs);

		$globalregistry = JemHelper::globalattribs();

		$value->params = clone $globalregistry;
		//$value->params->merge($registry);

		// Compute selected asset permissions.
		$user = JemFactory::getUser();

		// Check edit permission.
		$value->params->set('access-edit', $user->can('edit', 'venue', $value->id, $value->created_by));

		// Check edit state permission.
		$value->params->set('access-change', $user->can('publish', 'venue', $value->id, $value->created_by));

		$value->author_ip = $jemsettings->storeip ? JemHelper::retrieveIP() : false;

		$files = JemAttachment::getAttachments('venue' . $itemId);
		$value->attachments = $files;

		if (empty($itemId)) {
			$value->country = $jemsettings->defaultCountry;
		}

		return $value;
	}