Example #1
0
 /**
  * Method to test whether a record can be created or edited.
  *
  * @param   int  $itemId  Item ID/
  * @param   int  $userId  User ID.
  *
  * @return  boolean  True if allowed to change the state of the record. Defaults to the permission for the component.
  *
  * @since   12.2
  */
 public function canEditOwn($itemId, $userId)
 {
     $user = JFactory::getUser();
     if (!$user->authorise('core.edit.own', 'com_userideas')) {
         return false;
     }
     // Validate item owner.
     $itemValidator = new Userideas\Validator\Item\Owner(JFactory::getDbo(), $itemId, $userId);
     if (!$itemValidator->isValid()) {
         return false;
     }
     return true;
 }
Example #2
0
 /**
  * Method override to check if you can edit an existing record.
  *
  * @param   array  $data An array of input data.
  * @param   string $key  The name of the key for the primary key; default is id.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 protected function allowEdit($data = array(), $key = 'id')
 {
     $user = JFactory::getUser();
     // Validate action role.
     if (!$user->authorise('core.edit.own', 'com_userideas')) {
         return false;
     }
     // Validate item owner.
     $itemId = Joomla\Utilities\ArrayHelper::getValue($data, $key);
     $userId = $user->get('id');
     // Validate item owner.
     $itemValidator = new Userideas\Validator\Item\Owner(JFactory::getDbo(), $itemId, $userId);
     if (!$itemValidator->isValid()) {
         return false;
     }
     return true;
 }