/** * Constructor * * @param DatabaseDriver $database A database connector object * * @since 1.0 */ public function __construct(DatabaseDriver $database) { parent::__construct('#__tracker_labels', 'label_id', $database); }
/** * Constructor. * * @param DatabaseDriver $database A database connector object. * * @since 1.0 */ public function __construct(DatabaseDriver $database) { parent::__construct('#__users', 'id', $database); }
/** * 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) { if (!$this->created_date || $this->created_date == $this->db->getNullDate()) { // New item - set an (arbitrary) created date.. $this->created_date = (new \DateTime())->format('Y-m-d H:i:s'); } // Render markdown $this->text = $this->getGitHub()->markdown->render($this->text_md); return parent::store($updateNulls); }
/** * Method to delete a row from the database table by primary key value. * * @param mixed $pKey An optional primary key value to delete. If not set the instance property value is used. * * @return AbstractDatabaseTable * * @since 1.0 * @throws \UnexpectedValueException */ public function delete($pKey = null) { parent::delete($pKey); // Delete the entries in the map table. $this->db->setQuery($this->db->getQuery(true)->delete($this->db->quoteName('#__user_accessgroup_map'))->where($this->db->quoteName('group_id') . ' = ' . (int) $this->group_id))->execute(); return $this; }
/** * Constructor * * @param DatabaseDriver $database A database connector object. * * @since 1.0 */ public function __construct(DatabaseDriver $database) { parent::__construct('#__issues_categories', 'id', $database); }
/** * 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 ActivitiesTable * * @since 1.0 */ public function store($updateNulls = false) { if (!$this->activities_id) { // New item if (!$this->created_date) { $date = new \DateTime(); $this->created_date = $date->format('Y-m-d H:i:s'); } } return parent::store($updateNulls); }
/** * 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 * @throws \RuntimeException */ public function store($updateNulls = false) { $isNew = $this->id < 1; $date = new Date(); $date = $date->format($this->db->getDateFormat()); if (!$isNew) { // Existing item $this->modified_date = $date; } else { // New item if (!(int) $this->opened_date) { $this->opened_date = $date; } } // Execute the parent store method parent::store($updateNulls); /* * Post-Save Actions */ // Add a record to the activity table if a new item if ($isNew) { $data = array(); $data['event'] = 'open'; $data['created_date'] = $this->opened_date; $data['user'] = $this->opened_by; $data['issue_number'] = (int) $this->issue_number; $data['project_id'] = (int) $this->project_id; $table = new ActivitiesTable($this->db); $table->save($data); } if ($this->oldObject) { // Add a record to the activities table including the changes made to an item. $this->processChanges(); } if ($this->fieldValues) { // If we have extra fields, process them. $this->processFields(); } return $this; }
/** * 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 * @throws \RuntimeException */ public function store($updateNulls = false) { $isNew = $this->id < 1; $date = new Date(); $date = $date->format($this->db->getDateFormat()); if (!$isNew) { // Existing item /* * This has been commented because we should get the modified_date *always* from GitHub * for projects managed there, otherwise the date should be provided. */ // $this->modified_date = $date; } else { // New item if (!(int) $this->opened_date) { $this->opened_date = $date; } } // Execute the parent store method parent::store($updateNulls); /* * Post-Save Actions */ // Add a record to the activity table if a new item if ($isNew) { $data = array(); $data['event'] = 'open'; $data['created_date'] = $this->opened_date; $data['user'] = $this->opened_by; $data['issue_number'] = (int) $this->issue_number; $data['project_id'] = (int) $this->project_id; $table = new ActivitiesTable($this->db); $table->save($data); } if ($this->oldObject) { // Add a record to the activities table including the changes made to an item. $this->processChanges(); } return $this; }
/** * Constructor * * @param DatabaseDriver $database A database connector object * * @since 1.0 */ public function __construct(DatabaseDriver $database) { parent::__construct('#__tracker_milestones', 'milestone_id', $database); }
/** * 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; }