Exemplo n.º 1
0
 /**
  * Prepare and sanitise the table data prior to saving.
  *
  * @param   JTable  $table  A JTable object.
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function prepareTable($table)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if (isset($table->name)) {
         $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
     }
     if (isset($table->alias) && empty($table->alias)) {
         $table->generateAlias();
     }
     if (empty($table->id)) {
         $table->created = $date->toSql();
         // set the user
         if ($table->created_by == 0 || empty($table->created_by)) {
             $table->created_by = $user->id;
         }
         // Set ordering to the last item if not set
         if (empty($table->ordering)) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true)->select('MAX(ordering)')->from($db->quoteName('#__demo_look'));
             $db->setQuery($query);
             $max = $db->loadResult();
             $table->ordering = $max + 1;
         }
     } else {
         $table->modified = $date->toSql();
         $table->modified_by = $user->id;
     }
     if (!empty($table->id)) {
         // Increment the items version number.
         $table->version++;
     }
 }
Exemplo n.º 2
0
 /**
  * Prepare and sanitise the table prior to saving.
  *
  * @param   JTable  $table  The JTable object
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function prepareTable($table)
 {
     $date = JFactory::getDate()->toSql();
     $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
     $table->generateAlias();
     if (empty($table->id)) {
         // Set the values
         $table->created = $date;
         // Set ordering to the last item if not set
         if (empty($table->ordering)) {
             $db = $this->getDbo();
             $query = $db->getQuery(true)->select('MAX(ordering)')->from($db->quoteName('#__contact_details'));
             $db->setQuery($query);
             $max = $db->loadResult();
             $table->ordering = $max + 1;
         }
     } else {
         // Set the values
         $table->modified = $date;
         $table->modified_by = JFactory::getUser()->id;
     }
     // Increment the content version number.
     $table->version++;
 }