/** * Execute the controller. * * @return string * * @since 1.0 */ public function execute() { $table = new GroupsTable($this->getContainer()->get('db')); $table->load($this->getContainer()->get('app')->input->getInt('group_id'))->delete(); $this->getContainer()->get('app')->enqueueMessage(g11n3t('The group has been deleted.'), 'success'); return parent::execute(); }
/** * Execute the controller. * * @return string The rendered view. * * @since 1.0 */ public function execute() { $group = $this->getContainer()->get('app')->input->get('group', array(), 'array'); $table = new GroupsTable($this->getContainer()->get('db')); $table->save($group); return parent::execute(); }
/** * Method to get a DatabaseQuery object for retrieving the data set from a database. * * @return DatabaseQuery A DatabaseQuery object to retrieve the data set. * * @since 1.0 */ protected function getListQuery() { $projectId = $this->getProject()->project_id; $db = $this->getDb(); $query = $db->getQuery(true); $table = new GroupsTable($db); $query->select('a.*')->from($db->quoteName($table->getTableName(), 'a'))->where($db->quoteName('project_id') . ' = ' . (int) $projectId); return $query; }
/** * Method to get a DatabaseQuery object for retrieving the data set from a database. * * @return DatabaseQuery A DatabaseQuery object to retrieve the data set. * * @since 1.0 */ public function getItem() { $table = new GroupsTable($this->getDb()); $groupId = $this->getGroupId(); return $groupId ? $table->load($groupId)->getIterator() : $table->getIterator(); }
/** * Method to store a row in the database from the AbstractDatabaseTable instance properties. * If a primary key value is set the row with that primary key value will be * updated with the instance property values. If no primary key value is set * a new row will be inserted into the database with the properties from the * AbstractDatabaseTable instance. * * @param boolean $updateNulls True to update fields even if they are null. * * @return $this Method allows chaining * * @since 1.0 */ public function store($updateNulls = false) { $oldId = $this->{$this->getKeyName()}; parent::store($updateNulls); if (!$oldId) { // New item - Create default access groups. $newId = $this->{$this->getKeyName()}; if ($newId) { $data = array(); $data['project_id'] = $newId; $data['title'] = 'Public'; $data['can_view'] = 1; $data['can_create'] = 0; $data['can_edit'] = 0; $data['can_manage'] = 0; $data['system'] = 1; $group = new GroupsTable($this->db); $group->save($data); $data['title'] = 'User'; $data['can_create'] = 1; $group = new GroupsTable($this->db); $group->save($data); } } return $this; }