/** * Dissolve recurrence sets where deleted event is referred to as first. * * @param string The context for the content passed to the plugin. * @param object The data relating to the content that was deleted. * @since 1.9.6 */ public function onContentAfterDelete($context, $data) { // Skip plugin if we are deleting something other than events if (($context != 'com_jem.event') || empty($data->id)) { return; } // event maybe first of recurrence set -> dissolve complete set JemHelper::dissolve_recurrence($data->id); return; }
/** * Method to save the form data. * * @param $data array */ public function save($data) { // Variables $date = JFactory::getDate(); $app = JFactory::getApplication(); $jinput = $app->input; $jemsettings = JEMHelper::config(); $fileFilter = new JInput($_FILES); $table = $this->getTable(); // Check if we're in the front or back $backend = (bool)$app->isAdmin(); $new = (bool)empty($data['id']); // Variables $cats = $jinput->get('cid', array(), 'array'); $recurrencenumber = $jinput->get('recurrence_number', '', 'int'); $recurrencebyday = $jinput->get('recurrence_byday', '', 'string'); $metakeywords = $jinput->get('meta_keywords', '', ''); $metadescription = $jinput->get('meta_description', '', ''); $task = $jinput->get('task', '', 'cmd'); // event maybe first of recurrence set -> dissolve complete set if (JemHelper::dissolve_recurrence($data['id'])) { $this->cleanCache(); } if ($data['dates'] == null || $data['recurrence_type'] == '0') { $data['recurrence_number'] = ''; $data['recurrence_byday'] = ''; $data['recurrence_counter'] = ''; $data['recurrence_type'] = ''; $data['recurrence_limit'] = ''; $data['recurrence_limit_date'] = ''; $data['recurrence_first_id'] = ''; } else { if (!$new) { // edited event maybe part of a recurrence set // -> drop event from set $data['recurrence_first_id'] = ''; $data['recurrence_counter'] = ''; } $data['recurrence_number'] = $recurrencenumber; $data['recurrence_byday'] = $recurrencebyday; } $data['meta_keywords'] = $metakeywords; $data['meta_description'] = $metadescription; // Store IP of author only. if ($new) { $author_ip = $jinput->get('author_ip', '', 'string'); $data['author_ip'] = $author_ip; } // Store as copy - reset creation date, modification fields, hit counter, version if ($task == 'save2copy') { unset($data['created']); unset($data['modified']); unset($data['modified_by']); unset($data['version']); unset($data['hits']); } // Save the event $saved = parent::save($data); if ($saved) { // At this point we do have an id. $pk = $this->getState($this->getName() . '.id'); if (isset($data['featured'])) { $this->featured($pk, $data['featured']); } // attachments, new ones first $attachments = array(); $attachments = $fileFilter->get('attach', array(), 'array'); $attachments['customname'] = $jinput->post->get('attach-name', array(), 'array'); $attachments['description'] = $jinput->post->get('attach-desc', array(), 'array'); $attachments['access'] = $jinput->post->get('attach-access', array(), 'array'); JEMAttachment::postUpload($attachments, 'event' . $pk); // and update old ones $old = array(); $old['id'] = $jinput->post->get('attached-id', array(), 'array'); $old['name'] = $jinput->post->get('attached-name', array(), 'array'); $old['description'] = $jinput->post->get('attached-desc', array(), 'array'); $old['access'] = $jinput->post->get('attached-access', array(), 'array'); foreach ($old['id'] as $k => $id) { $attach = array(); $attach['id'] = $id; $attach['name'] = $old['name'][$k]; $attach['description'] = $old['description'][$k]; $attach['access'] = $old['access'][$k]; JEMAttachment::update($attach); } // Store cats $saved |= $this->_storeCategoriesSelected($pk, $cats, !$backend, $new); // check for recurrence // when filled it will perform the cleanup function $table->load($pk); if (($table->recurrence_number > 0) && ($table->dates != null)) { JEMHelper::cleanup(2); // 2 = force on save, needs special attention } } return $saved; }