예제 #1
0
 /**
  * Overrides JTable::store to set modified data and user id.
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  boolean  True on success.
  *
  * @since   11.1
  */
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if ($this->id) {
         // Existing item
         $this->modified = $date->toSql();
         $this->modified_by = $user->get('id');
     } else {
         // New article. An article created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!(int) $this->created) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     // Verify that the alias is unique
     $table = JTable::getInstance('Content', 'JTable');
     if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_ARTICLE_UNIQUE_ALIAS'));
         return false;
     }
     $this->tagsHelper->typeAlias = 'com_content.article';
     $this->tagsHelper->preStoreProcess($this);
     $result = parent::store($updateNulls);
     return $result && $this->tagsHelper->postStoreProcess($this);
 }
예제 #2
0
파일: product.php 프로젝트: whiteof/comcar
 /**
  * Overriden JTable::store to set modified data.
  *
  * @param   boolean	True to update fields even if they are null.
  * @return  boolean  True on success.
  * @since   1.6
  */
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if ($this->id) {
         // Existing item
         $this->modified = $date->toSql();
         $this->modified_by = $user->get('id');
     } else {
         // New newsfeed. A feed created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!(int) $this->created) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     /*
     // Verify that the alias is unique
     $table = JTable::getInstance('Product', 'WcatalogTable');
     if ($table->load(array('category_id' => $this->category_id)) && ($table->id != $this->id || $this->id == 0))
     {
     	$this->setError(JText::_('COM_WCATALOG_ERROR_UNIQUE_ALIAS'));
     	return false;
     }
     */
     $this->tagsHelper->typeAlias = 'com_wcatalog.product';
     $this->tagsHelper->preStoreProcess($this);
     $result = parent::store($updateNulls);
     return $result && $this->tagsHelper->postStoreProcess($this);
 }
예제 #3
0
파일: category.php 프로젝트: whiteof/comcar
 /**
  * Overriden JTable::store to set modified data.
  *
  * @param   boolean	True to update fields even if they are null.
  * @return  boolean  True on success.
  * @since   1.6
  */
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if ($this->id) {
         // Existing item
         $this->modified = $date->toSql();
         $this->modified_by = $user->get('id');
     } else {
         // New newsfeed. A feed created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!(int) $this->created) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     // Verify that the alias is unique
     $table = JTable::getInstance('Category', 'WcatalogTable');
     $this->tagsHelper->typeAlias = 'com_wcatalog.category';
     $this->tagsHelper->preStoreProcess($this);
     $result = parent::store($updateNulls);
     return $result && $this->tagsHelper->postStoreProcess($this);
 }
예제 #4
0
파일: Tags.php 프로젝트: akeeba/fof
 /**
  * The event which runs after binding data to the table
  *
  * @param   DataModel    &$model  The model which calls this event
  *
  * @return  void
  *
  * @throws  \Exception  Error message if failed to store tags
  */
 public function onAfterSave(&$model)
 {
     $tagField = $model->getBehaviorParam('tagFieldName', 'tags');
     // Avoid to update on other method (e.g. publish, ...)
     if (!in_array($model->getContainer()->input->getCmd('task'), array('apply', 'save', 'savenew'))) {
         return;
     }
     $oldTags = $this->tagsHelper->getTagIds($model->getId(), $model->getContentType());
     $newTags = $model->{$tagField} ? implode(',', $model->{$tagField}) : null;
     // If no changes, we stop here
     if ($oldTags == $newTags) {
         return;
     }
     // Check if the content type exists, and create it if it does not
     $model->checkContentType();
     $this->tagsHelper->typeAlias = $model->getContentType();
     if (!$this->tagsHelper->postStoreProcess($model, $model->{$tagField})) {
         throw new \Exception('Error storing tags');
     }
 }
예제 #5
0
 /**
  * Stores a contact
  *
  * @param   boolean	True to update fields even if they are null.
  *
  * @return  boolean  True on success, false on failure.
  *
  * @since   1.6
  */
 public function store($updateNulls = false)
 {
     // Transform the params field
     if (is_array($this->params)) {
         $registry = new JRegistry();
         $registry->loadArray($this->params);
         $this->params = (string) $registry;
     }
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if ($this->id) {
         // Existing item
         $this->modified = $date->toSql();
         $this->modified_by = $user->get('id');
     } else {
         // New contact. A contact created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!(int) $this->created) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     // Set publish_up to null date if not set
     if (!$this->publish_up) {
         $this->publish_up = $this->_db->getNullDate();
     }
     // Set publish_down to null date if not set
     if (!$this->publish_down) {
         $this->publish_down = $this->_db->getNullDate();
     }
     // Set xreference to empty string if not set
     if (!$this->xreference) {
         $this->xreference = '';
     }
     // Verify that the alias is unique
     $table = JTable::getInstance('Contact', 'ContactTable');
     if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('COM_CONTACT_ERROR_UNIQUE_ALIAS'));
         return false;
     }
     $this->tagsHelper->preStoreProcess($this);
     $result = parent::store($updateNulls);
     return $result && $this->tagsHelper->postStoreProcess($this);
 }
예제 #6
0
파일: Tags.php 프로젝트: Joal01/fof
 /**
  * The event which runs after binding data to the table
  *
  * @param   DataModel    &$model  The model which calls this event
  * @param   object|array &$src    The data to bind
  *
  * @return  boolean  True on success
  */
 public function onAfterBind(&$model, &$src)
 {
     // Bind tags
     if ($model->hasTags()) {
         if (!empty($src['tags']) && $src['tags'][0] != '') {
             $model->newTags = $src['tags'];
         }
         // Check if the content type exists, and create it if it does not
         $model->checkContentType();
         $tagsTable = clone $model;
         $tagsHelper = new \JHelperTags();
         $tagsHelper->typeAlias = $model->getContentType();
         if (!$tagsHelper->postStoreProcess($tagsTable)) {
             throw new \Exception('Error storing tags');
         }
     }
     return true;
 }
예제 #7
0
 /**
  * The event which runs after binding data to the table
  *
  * @param   FOFTable  		&$table  	The table which calls this event
  * @param   object|array  	&$src  		The data to bind
  * @param  	array 			$options 	The options of the table
  *
  * @return  boolean  True on success
  */
 public function onAfterBind(&$table, &$src, $options = array())
 {
     // Bind tags
     if ($table->hasTags()) {
         if (!empty($src['tags']) && $src['tags'][0] != '') {
             $table->newTags = $src['tags'];
         }
         // Check if the content type exists, and create it if it does not
         $table->checkContentType();
         $tagsTable = clone $table;
         $tagsHelper = new JHelperTags();
         $tagsHelper->typeAlias = $table->getContentType();
         // TODO: This little guy here fails because JHelperTags
         // need a JTable object to work, while our is FOFTable
         // Need probably to write our own FOFHelperTags
         // Thank you com_tags
         if (!$tagsHelper->postStoreProcess($tagsTable)) {
             $table->setError('Error storing tags');
             return false;
         }
     }
     return true;
 }
예제 #8
0
 /**
  * Overridden JTable::store to set created/modified and user id.
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  boolean  True on success.
  *
  * @since   11.1
  */
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if ($this->id) {
         // Existing category
         $this->modified_time = $date->toSql();
         $this->modified_user_id = $user->get('id');
     } else {
         // New category
         $this->created_time = $date->toSql();
         $this->created_user_id = $user->get('id');
     }
     // Verify that the alias is unique
     $table = JTable::getInstance('Category', 'JTable', array('dbo' => $this->getDbo()));
     if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'extension' => $this->extension)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
         return false;
     }
     $this->tagsHelper->typeAlias = $this->extension . '.category';
     $this->tagsHelper->preStoreProcess($this);
     $result = parent::store($updateNulls);
     return $result && $this->tagsHelper->postStoreProcess($this);
 }
예제 #9
0
 /**
  * Overload the store method for the Weblinks table.
  *
  * @param   boolean	Toggle whether null values should be updated.
  * @return  boolean  True on success, false on failure.
  * @since   1.6
  */
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     if ($this->id) {
         // Existing item
         $this->modified = $date->toSql();
         $this->modified_by = $user->get('id');
     } else {
         // New weblink. A weblink created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!(int) $this->created) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     // Set publish_up to null date if not set
     if (!$this->publish_up) {
         $this->publish_up = $this->_db->getNullDate();
     }
     // Set publish_down to null date if not set
     if (!$this->publish_down) {
         $this->publish_down = $this->_db->getNullDate();
     }
     // Verify that the alias is unique
     $table = JTable::getInstance('Weblink', 'WeblinksTable');
     if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS'));
         return false;
     }
     $this->tagsHelper->preStoreProcess($this);
     $result = parent::store($updateNulls);
     return $result && $this->tagsHelper->postStoreProcess($this);
 }
예제 #10
0
파일: tags.php 프로젝트: fur81/zofaxiopeu
 /**
  * Sets the new tags to be added/replaced to the table row
  *
  * @param   array    $newTags      New tags to be added or replaced
  * @param   boolean  $replaceTags  Replace tags (true) or add them (false)
  *
  * @return  boolean
  */
 public function setNewTags($newTags, $replaceTags)
 {
     $this->parseTypeAlias();
     return $this->tagsHelper->postStoreProcess($this->table, $newTags, $replaceTags);
 }
예제 #11
0
파일: tags.php 프로젝트: q0821/esportshop
 function saveUCM($type, $element, $tags = array())
 {
     if (!isset($this->structure[$type]) || !$this->_isCompatible) {
         return false;
     }
     $structure = $this->structure[$type];
     $component = 'hikashop';
     if (!empty($structure['component'])) {
         $component = $structure['component'];
     }
     $alias = 'com_' . $component . '.' . $structure['table'];
     $tagsHelper = new JHelperTags();
     $tagsHelper->typeAlias = $alias;
     $tagsTable = new JHikaShopTagTable($structure, $element);
     $tagsHelper->preStoreProcess($tagsTable);
     $ret = $tagsHelper->postStoreProcess($tagsTable, $tags);
 }