/** * Override paren't store method so we can do some checking with the watermarks. * * @return bool True on success. **/ public function store($updateNulls = false) { if (!$this->id) { $this->ordering = parent::getNextOrder(); } parent::store(); }
/** * Override paren't store method so we can do some checking with the watermarks. * * @return bool True on success. **/ public function store() { if (!$this->id) { $this->ordering = parent::getNextOrder(); } parent::store(); }
/** * Prepare and sanitise the table data prior to saving. * * @param JTable $table A JTable object. * * @return void * * @since 1.6 */ protected function prepareTable($table) { // Set the publish date to now $db = $this->getDbo(); if ($table->state == 1 && (int) $table->publish_up == 0) { $table->publish_up = JFactory::getDate()->toSql(); } if ($table->state == 1 && intval($table->publish_down) == 0) { $table->publish_down = $db->getNullDate(); } // Increment the content version number. $table->version++; // Reorder the articles within the category so the new article is first if (empty($table->id)) { $table->ordering = $table->getNextOrder('catid = ' . (int) $table->catid . ' AND state >= 0'); } }
/** * Test the getNextOrder method. * * @return void * * @since 12.3 */ public function testGetNextOrder() { $this->assertEquals(3, $this->object->getNextOrder()); }
/** * onBeforeSave method. Hook for chidlren model to prepare the data. * * @param array $data The data to be saved. * @param JTable $table The table object. * * @return boolean */ protected function onBeforeSave(&$data, $table) { // Get database $db = $this->getDBO(); // User $user = JFactory::getUser(); // Permissions check if (!$user->authorise('k2.extrafields.manage')) { $this->setError(JText::_('K2_YOU_ARE_NOT_AUTHORIZED_TO_PERFORM_THIS_OPERATION')); return false; } // Ordering if (!$table->id) { $data['ordering'] = $table->getNextOrder($db->quoteName('group') . ' = ' . (int) $data['group']); } return true; }
/** * Overwrites JTable's getNextOrder function by expecting an array of columns and values or SocialSql object * * @since 1.0 * @access public * @param string/array/SocialSql The filter clause to pass to JTable getNextOrder function * @return int **/ public function getNextOrder($where = '') { $string = ''; if (is_string($where)) { $string = $where; } if (is_array($where)) { $db = FD::db(); $string = array(); foreach ($where as $k => $v) { $string[] = $db->nameQuote($k) . ' = ' . $db->quote($v); } $string = implode(' AND ', $string); } if (is_object($where) && get_class($where) === 'SocialSql') { $string = $where->getConditionSql(); } return parent::getNextOrder($string); }