/** * Save a collection * * @return string */ private function _savecollection() { // Check for request forgeries Request::checkToken(); if (User::isGuest()) { return $this->_login(); } if (!$this->params->get('access-edit-collection') || !$this->params->get('access-create-collection')) { $this->setError(Lang::txt('PLG_GROUPS_COLLECTIONS_NOT_AUTH')); return $this->_collections(); } // Incoming $fields = Request::getVar('fields', array(), 'post', 'none', 2); $fields['id'] = intval($fields['id']); // Bind new content $row = new \Components\Collections\Models\Collection(); if (!$row->bind($fields)) { $this->setError($row->getError()); return $this->_editcollection($row); } // Store new content if (!$row->store()) { $this->setError($row->getError()); return $this->_editcollection($row); } $row->item()->tag(trim(Request::getVar('tags', ''))); // Redirect to collection App::redirect(Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=' . $this->_name . '&scope=' . $row->get('alias'))); }
/** * Save a collection * * @return string */ private function _savecollection() { // Check for request forgeries Request::checkToken(); // Login check if (User::isGuest()) { return $this->_login(); } // Access check if (!$this->params->get('access-edit-collection') || !$this->params->get('access-create-collection')) { $this->setError(Lang::txt('PLG_MEMBERS_' . strtoupper($this->_name) . '_NOT_AUTHORIZED')); return $this->_collections(); } // Incoming $fields = Request::getVar('fields', array(), 'post', 'none', 2); $fields['id'] = intval($fields['id']); // Bind new content $row = new \Components\Collections\Models\Collection(); if (!$row->bind($fields)) { $this->setError($row->getError()); return $this->_editcollection($row); } if ($row->get('access') != 0 && $row->get('access') != 4) { $row->set('access', 0); } // Store new content if (!$row->store()) { $this->setError($row->getError()); return $this->_editcollection($row); } // Redirect to collection App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name . '&task=all')); }
/** * Save a collection * * @return string */ private function _savecollection() { // Check for request forgeries Request::checkToken(); if (User::isGuest()) { return $this->_login(); } if (!$this->params->get('access-edit-collection') || !$this->params->get('access-create-collection')) { $this->setError(Lang::txt('PLG_GROUPS_COLLECTIONS_NOT_AUTH')); return $this->_collections(); } // Incoming $fields = Request::getVar('fields', array(), 'post', 'none', 2); $fields['id'] = intval($fields['id']); // Bind new content $collection = new \Components\Collections\Models\Collection(); if (!$collection->bind($fields)) { $this->setError($collection->getError()); return $this->_editcollection($collection); } if ($collection->get('access') != 0 && $collection->get('access') != 4) { $collection->set('access', 0); } // Store new content if (!$collection->store()) { $this->setError($collection->getError()); return $this->_editcollection($collection); } $url = Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=' . $this->_name . '&scope=' . $collection->get('alias')); // Record the activity $recipients = array(['group', $this->group->get('gidNumber')], ['collection', $collection->get('id')], ['user', $collection->get('created_by')]); $recipients[] = ['user', $collection->get('created_by')]; foreach ($this->group->get('managers') as $recipient) { $recipients[] = ['user', $recipient]; } Event::trigger('system.logActivity', ['activity' => ['action' => $fields['id'] ? 'updated' : 'created', 'scope' => 'collections.collection', 'scope_id' => $collection->get('id'), 'description' => Lang::txt('PLG_GROUPS_COLLECTIONS_ACTIVITY_COLLECTION_' . ($fields['id'] ? 'UPDATED' : 'CREATED'), '<a href="' . $url . '">' . $collection->get('title') . '</a>'), 'details' => array('title' => $collection->get('title'), 'id' => $collection->get('id'), 'url' => $url)], 'recipients' => $recipients]); // Redirect to collection App::redirect($url); }
/** * Save a collection * * @return string */ private function _savecollection() { // Check for request forgeries Request::checkToken(); // Login check if (User::isGuest()) { return $this->_login(); } // Access check if (!$this->params->get('access-edit-collection') || !$this->params->get('access-create-collection')) { $this->setError(Lang::txt('PLG_MEMBERS_' . strtoupper($this->_name) . '_NOT_AUTHORIZED')); return $this->_collections(); } // Incoming $fields = Request::getVar('fields', array(), 'post', 'none', 2); $fields['id'] = intval($fields['id']); // Bind new content $collection = new \Components\Collections\Models\Collection(); if (!$collection->bind($fields)) { $this->setError($collection->getError()); return $this->_editcollection($collection); } if ($collection->get('access') != 0 && $collection->get('access') != 4) { $collection->set('access', 0); } // Store new content if (!$collection->store()) { $this->setError($collection->getError()); return $this->_editcollection($collection); } $url = Route::url($this->member->link() . '&active=' . $this->_name . '&task=all'); // Record the activity Event::trigger('system.logActivity', ['activity' => ['action' => $fields['id'] ? 'updated' : 'created', 'scope' => 'collections.collection', 'scope_id' => $collection->get('id'), 'description' => Lang::txt('PLG_MEMBERS_COLLECTIONS_ACTIVITY_COLLECTION_' . ($fields['id'] ? 'UPDATED' : 'CREATED'), '<a href="' . $url . '">' . $collection->get('title') . '</a>'), 'details' => array('title' => $collection->get('title'), 'id' => $collection->get('id'), 'url' => $url)], 'recipients' => [['collection', $collection->get('id')], ['user', $collection->get('created_by')]]]); // Redirect to collection App::redirect($url); }