Ejemplo n.º 1
0
 /**
  * Method to test whether a record can be deleted.
  *
  * @param   object  $record  A record object.
  *
  * @return  boolean  True if allowed to delete the record. Defaults to the permission set in the component.
  *
  * @since   3.5.6
  */
 protected function canDelete($record)
 {
     if (!empty($record->id)) {
         if ($record->state != -2) {
             return false;
         }
         $user = JFactory::getUser();
         if ($user->authorise('core.delete')) {
             icagendaCustomfields::deleteData($record->id, 2);
             icagendaCustomfields::cleanData(2);
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since	3.5.6
  */
 public function save($data)
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     //		if (empty($data['created'])) // not to be used, to leave created empty if before update to 3.5.7
     //		{
     //			$data['created'] = ( ! empty($data['modified'])) ? $data['modified'] : $date->toSql();
     //		}
     // Set registration creator
     if (empty($data['created_by'])) {
         $data['created_by'] = (int) $data['userid'];
     }
     // Set Params
     if (isset($data['params']) && is_array($data['params'])) {
         // Convert the params field to a string.
         $parameter = new JRegistry();
         $parameter->loadArray($data['params']);
         $data['params'] = (string) $parameter;
     }
     if ($input->get('task') == 'delete') {
         icagendaCustomfields::deleteData($data['custom_fields'], $data['id'], 1);
         $app->enqueueMessage('Test', 'warning');
     }
     // Get Registration ID from the result back to the Table after saving.
     $table = $this->getTable();
     if ($table->save($data) === true) {
         $data['id'] = $table->id;
     } else {
         $data['id'] = null;
     }
     if (parent::save($data)) {
         // Save Custom Fields to database
         if (isset($data['custom_fields']) && is_array($data['custom_fields'])) {
             icagendaCustomfields::saveToData($data['custom_fields'], $data['id'], 1);
         }
         return true;
     }
     return false;
 }