/** * Method to get item data. * * @param integer $pk The id of the item. * * @return mixed $item Item data object on success, false on failure. */ public function getItem($pk = null) { // Get the record from the parent class method $item = parent::getItem($pk); if ($item === false) { return false; } // Compute selected asset permissions. $user = JFactory::getUser(); $uid = $user->get('id'); $access = PFrepoHelper::getActions('file', $item->id); $view_access = true; if ($item->access && !$user->authorise('core.admin')) { $view_access = in_array($item->access, $user->getAuthorisedViewLevels()); } $item->params->set('access-view', $view_access); if (!$view_access) { $item->params->set('access-edit', false); $item->params->set('access-change', false); } else { // Check general edit permission first. if ($access->get('core.edit')) { $item->params->set('access-edit', true); } elseif (!empty($uid) && $access->get('core.edit.own')) { // Check for a valid user and that they are the owner. if ($uid == $item->created_by) { $item->params->set('access-edit', true); } } // Check edit state permission. $item->params->set('access-change', $access->get('core.edit.state')); } return $item; }
/** * Method to get a single record. * * @param integer The id of the primary key. * @return mixed Object on success, false on failure. */ public function getItem($pk = null) { if ($item = parent::getItem($pk)) { // Convert the params field to an array. $registry = new JRegistry(); $registry->loadString($item->attribs); $item->attribs = $registry->toArray(); } return $item; }