/** * 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 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 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; }
/** * 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 */ 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; }