Example #1
0
 /**
  * Assert that the nested set data is valid.
  *
  * @return  boolean  True if the instance is sane and able to be stored in the database.
  *
  * @since   11.1
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     $this->parent_id = (int) $this->parent_id;
     if (empty($this->rules)) {
         $this->rules = '{}';
     }
     // JTableNested does not allow parent_id = 0, override this.
     if ($this->parent_id > 0) {
         // Get the JDatabaseQuery object
         $query = $this->_db->getQuery(true)->select('COUNT(id)')->from($this->_db->quoteName($this->_tbl))->where($this->_db->quoteName('id') . ' = ' . $this->parent_id);
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             return true;
         } else {
             $this->setError('Invalid Parent ID');
             return false;
         }
     }
     return true;
 }
Example #2
0
 public function __construct($table, $key = 'id', $alias = null, $db = null)
 {
     $this->_alias = $alias;
     if (!isset($db)) {
         $db = JFactory::getDbo();
     }
     parent::__construct($table, $key, $db);
 }
Example #3
0
 function mosCategory(&$db)
 {
     ///parent::__construct( $db );
     // for 1.6
     JTableNested::__construct('#__booklibrary_legacy_categories', 'id', $db);
     $this->access = (int) JFactory::getConfig()->get('access');
     // --
 }
 /**
  * Delete category record
  *
  * @author RickG
  * @return boolean True on success
  * @todo Add check for store and products assinged to category before allowing delete
  */
 public function delete($pk = null, $children = true)
 {
     if (parent::delete($pk, $children)) {
         return true;
     } else {
         return false;
     }
 }
Example #5
0
 /**
  * Overloaded bind function
  *
  * @param	array $hash		named array
  * @return	mixed			null is operation was satisfactory, otherwise returns an error
  * @see		JTable:bind
  * @since	1.5
  */
 public function bind($array, $ignore = '')
 {
     if (is_array($array['params'])) {
         $registry = new JRegistry();
         $registry->loadArray($array['params']);
         $array['params'] = $registry->toString();
     }
     return parent::bind($array, $ignore);
 }
Example #6
0
 public function getTree($pk = null, $diagnostic = false)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     if (!isset(self::$getTree[$pk][(int) $diagnostic])) {
         self::$getTree[$pk][(int) $diagnostic] = parent::getTree($pk, $diagnostic);
     }
     return self::$getTree[$pk][(int) $diagnostic];
 }
Example #7
0
 public function store($updateNulls = false)
 {
     // Verify that the alias is unique
     $table = JTable::getInstance('Category', 'Table', array('dbo' => $this->getDbo()));
     if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
         return false;
     }
     return parent::store($updateNulls);
 }
Example #8
0
 public function delete($pk = null, $children = true)
 {
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables');
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('id');
     $query->from('#__judirectory_template_styles');
     $query->where('template_id =' . $pk);
     $db->setQuery($query);
     $styleIds = $db->loadColumn();
     if ($styleIds) {
         $styleTable = JTable::getInstance("Style", "JUDirectoryTable");
         foreach ($styleIds as $styleId) {
             if (!$styleTable->delete($styleId)) {
                 return false;
             }
         }
     }
     return parent::delete($pk);
 }
Example #9
0
 /**
  * Overloaded store function
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  mixed    False on failure, positive integer on success.
  *
  * @see     JTable::store
  * @since   11.1
  */
 public function store($updateNulls = false)
 {
     $updated = parent::store($updateNulls);
     // Verify that the alias is unique
     $table = JTable::getInstance('Addon', 'oseMscTable');
     $table->load($this->getRootId());
     $table->rebuild($this->getRootId(), $table->lft, $table->level);
     return $updated;
     /*if($this->id != $this->getRootId())
     		{
     			$table->load($this->parent_id);
     			// Rebuild the paths of the category's children:
     			//oseExit($table);
     			if (!$table->rebuild($table->id, $table->lft, $table->level) && $updated) {
     				return false;
     			}
     		}
     		return $updated;*/
     //$table->load($table->getRootId());
     // Use new path for partial rebuild of table
     // Rebuild will return positive integer on success, false on failure
     //return ($table->rebuild());
     //return ($this->rebuild($this->{$this->_tbl_key}, $this->lft, $this->level) > 0);
 }
Example #10
0
 /**
  * Constructor
  *
  * @param   JDatabaseDriver  $db  Database driver object.
  *
  * @since   11.1
  */
 public function __construct($db)
 {
     parent::__construct('#__assets', 'id', $db);
 }
Example #11
0
 /**
  * Validate that the primary key has been set.
  *
  * @return  boolean  True if the primary key(s) have been set.
  *
  * @since   1.5.2
  */
 public function hasPrimaryKey()
 {
     // For Joomla 3.2+ a native method has been provided
     if (method_exists(get_parent_class(), 'hasPrimaryKey')) {
         return parent::hasPrimaryKey();
     }
     // Otherwise, it checks if the only key field compatible for older Joomla versions is set or not
     if (isset($this->_tbl_key) && !empty($this->_tbl_key) && empty($this->{$this->_tbl_key})) {
         return false;
     }
     return true;
 }
 /**
  * Overloaded store function
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  mixed  False on failure, positive integer on success.
  *
  * @see     JTable::store()
  * @since   11.1
  */
 public function store($updateNulls = false)
 {
     $db = JFactory::getDbo();
     // Verify that the alias is unique
     $table = JTable::getInstance('Menu', 'JTable', array('dbo' => $this->getDbo()));
     if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'client_id' => (int) $this->client_id, 'language' => $this->language)) && ($table->id != $this->id || $this->id == 0)) {
         if ($this->menutype == $table->menutype) {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS'));
         } else {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS_ROOT'));
         }
         return false;
     }
     // Verify that the home page for this language is unique
     if ($this->home == '1') {
         $table = JTable::getInstance('Menu', 'JTable', array('dbo' => $this->getDbo()));
         if ($table->load(array('home' => '1', 'language' => $this->language))) {
             if ($table->checked_out && $table->checked_out != $this->checked_out) {
                 $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_DEFAULT_CHECKIN_USER_MISMATCH'));
                 return false;
             }
             $table->home = 0;
             $table->checked_out = 0;
             $table->checked_out_time = $db->getNullDate();
             $table->store();
         }
         // Verify that the home page for this menu is unique.
         if ($table->load(array('home' => '1', 'menutype' => $this->menutype)) && ($table->id != $this->id || $this->id == 0)) {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_UNIQUE_IN_MENU'));
             return false;
         }
     }
     if (!parent::store($updateNulls)) {
         return false;
     }
     // Get the new path in case the node was moved
     $pathNodes = $this->getPath();
     $segments = array();
     foreach ($pathNodes as $node) {
         // Don't include root in path
         if ($node->alias != 'root') {
             $segments[] = $node->alias;
         }
     }
     $newPath = trim(implode('/', $segments), ' /\\');
     // Use new path for partial rebuild of table
     // Rebuild will return positive integer on success, false on failure
     return $this->rebuild($this->{$this->_tbl_key}, $this->lft, $this->level, $newPath) > 0;
 }
Example #13
0
 function __construct(&$db)
 {
     parent::__construct('ins_level', 'id', $db);
 }
Example #14
0
 /**
  * Method to store a node in the database table.
  *
  * @param   boolean  $updateNulls  True to update null values as well.
  *
  * @return  boolean  True on success.
  */
 public function store($updateNulls = false)
 {
     // Before store
     if (!$this->beforeStore($updateNulls)) {
         return false;
     }
     // Store
     if (!parent::store($updateNulls)) {
         return false;
     }
     // After store
     if (!$this->afterStore($updateNulls)) {
         return false;
     }
     return true;
 }
Example #15
0
 /**
  * Overloaded store function
  *
  * @param   boolean   $updateNulls  True to update null values as well.
  * @return  boolean   True on success, false otherwise
  * @since   1.5.7
  */
 public function store($updateNulls = false)
 {
     if (!parent::store($updateNulls)) {
         return false;
     }
     // If there aren't any sub categories there isn't anything to do anymore
     $cats = JoomHelper::getAllSubCategories($this->cid, false, true, true, false);
     if (!count($cats)) {
         return true;
     }
     // Set state of all sub-categories
     // according to the settings of this category
     $query = $this->_db->getQuery(true)->update(_JOOM_TABLE_CATEGORIES)->set('published = ' . (int) $this->published)->where('cid IN (' . implode(',', $cats) . ')');
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Set 'in_hidden' of all sub-categories
     // according to hidden state of this category
     // (but only if there was a change of this state)
     if ($this->_hidden != $this->hidden && !$this->in_hidden || $this->_in_hidden != $this->in_hidden) {
         if ($this->hidden == 0 && $this->in_hidden == 0) {
             // If 'hidden' is 0 only the categories
             // which aren't set to hidden must be changed
             // because they form a hidden group themselves
             // anyway and have to stay hidden
             $cats = JoomHelper::getAllSubCategories($this->cid, false, true, true, true);
         }
         $query = $this->_db->getQuery(true)->update(_JOOM_TABLE_CATEGORIES)->set('in_hidden = ' . (int) ($this->hidden || $this->in_hidden))->where('cid IN (' . implode(',', $cats) . ')');
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     }
     return true;
 }
Example #16
0
 /**
  * Overloaded store function
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  mixed  False on failure, positive integer on success.
  *
  * @see     JTable::store()
  * @since   11.1
  */
 public function store($updateNulls = false)
 {
     $db = JFactory::getDbo();
     // Verify that the alias is unique
     $table = JTable::getInstance('Menu', 'JTable', array('dbo' => $this->getDbo()));
     $originalAlias = trim($this->alias);
     $this->alias = !$originalAlias ? $this->title : $originalAlias;
     $this->alias = JApplicationHelper::stringURLSafe(trim($this->alias), $this->language);
     // If alias still empty (for instance, new menu item with chinese characters with no unicode alias setting).
     if (empty($this->alias)) {
         $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
     } else {
         $itemSearch = array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'client_id' => (int) $this->client_id);
         $errorType = '';
         // Check if the alias already exists. For multilingual site.
         if (JLanguageMultilang::isEnabled()) {
             // If not exists a menu item at the same level with the same alias (in the All or the same language).
             if ($table->load(array_replace($itemSearch, array('language' => '*'))) && ($table->id != $this->id || $this->id == 0) || $table->load(array_replace($itemSearch, array('language' => $this->language))) && ($table->id != $this->id || $this->id == 0) || $this->language == '*' && $table->load($itemSearch) && ($table->id != $this->id || $this->id == 0)) {
                 $errorType = 'MULTILINGUAL';
             }
         } else {
             // If not exists a menu item at the same level with the same alias (in any language).
             if ($table->load($itemSearch) && ($table->id != $this->id || $this->id == 0)) {
                 $errorType = 'MONOLINGUAL';
             }
         }
         // The alias already exists. Send an error message.
         if ($errorType) {
             $message = JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS' . ($this->menutype != $table->menutype ? '_ROOT' : ''));
             $this->setError($message);
             return false;
         }
     }
     if ($this->home == '1') {
         // Verify that the home page for this menu is unique.
         if ($table->load(array('menutype' => $this->menutype, 'client_id' => (int) $this->client_id, 'home' => '1')) && $table->language != $this->language) {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_UNIQUE_IN_MENU'));
             return false;
         }
         // Verify that the home page for this language is unique
         if ($table->load(array('home' => '1', 'language' => $this->language))) {
             if ($table->checked_out && $table->checked_out != $this->checked_out) {
                 $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_DEFAULT_CHECKIN_USER_MISMATCH'));
                 return false;
             }
             $table->home = 0;
             $table->checked_out = 0;
             $table->checked_out_time = $db->getNullDate();
             $table->store();
         }
     }
     if (!parent::store($updateNulls)) {
         return false;
     }
     // Get the new path in case the node was moved
     $pathNodes = $this->getPath();
     $segments = array();
     foreach ($pathNodes as $node) {
         // Don't include root in path
         if ($node->alias != 'root') {
             $segments[] = $node->alias;
         }
     }
     $newPath = trim(implode('/', $segments), ' /\\');
     // Use new path for partial rebuild of table
     // Rebuild will return positive integer on success, false on failure
     return $this->rebuild($this->{$this->_tbl_key}, $this->lft, $this->level, $newPath) > 0;
 }
Example #17
0
 /**
  * Overriden JTable::store to set created/modified and user id.
  *
  * @param   boolean  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->toMySQL();
         $this->modified_user_id = $user->get('id');
     } else {
         // New category
         $this->created_time = $date->toMySQL();
         $this->created_user_id = $user->get('id');
     }
     // Verify that the alias is unique
     $table = JTable::getInstance('Category', 'JTable');
     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;
     }
     return parent::store($updateNulls);
 }
Example #18
0
 /**
  * Method to delete a node and, optionally, its child nodes from the table.
  *
  * @param   integer  $pk        The primary key of the node to delete.
  * @param   boolean  $children  True to delete child nodes, false to move them up a level.
  *
  * @return  boolean  True on success.
  *
  * @since   3.1
  */
 public function delete($pk = null, $children = false)
 {
     $return = parent::delete($pk, $children);
     if ($return) {
         $helper = new JHelperTags();
         $helper->tagDeleteInstances($pk);
     }
     return $return;
 }
Example #19
0
 public function delete($pk = null)
 {
     $db = JFactory::getDbo();
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     $this->load($pk);
     if ($this->home == 1 || $this->default == 1) {
         $this->setError(JText::_('COM_JUDIRECTORY_CAN_NOT_DELETE_DEFAULT_TEMPLATE_STYLE'));
         return false;
     }
     $defaultStyleObject = JUDirectoryFrontHelperTemplate::getDefaultTemplateStyle();
     $query = $db->getQuery(true);
     $query->update('#__judirectory_categories');
     $query->set('style_id = -2');
     if ($defaultStyleObject->template_id != $this->template_id) {
         $query->set('template_params = ""');
     }
     $query->where('parent_id = 0');
     $query->where('style_id = ' . $pk);
     $db->setQuery($query);
     $db->execute();
     $query = $db->getQuery(true);
     $query->select('id');
     $query->from('#__judirectory_categories');
     $query->where('style_id = ' . $pk);
     $db->setQuery($query);
     $categoryArrayAssignedToStyle = $db->loadColumn();
     $query = $db->getQuery(true);
     $query->update('#__judirectory_categories');
     $query->set('style_id = -1');
     $query->where('parent_id != 0');
     $query->where('style_id = ' . $pk);
     $db->setQuery($query);
     $db->execute();
     foreach ($categoryArrayAssignedToStyle as $categoryIdAssignedToStyle) {
         $styleObjectOfCategory = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($categoryIdAssignedToStyle);
         if ($styleObjectOfCategory->template_id != $this->template_id) {
             $query = $db->getQuery(true);
             $query->update('#__judirectory_categories');
             $query->set('template_params = ""');
             $query->where('id = ' . $categoryIdAssignedToStyle);
             $db->setQuery($query);
             $db->execute();
             $query = $db->getQuery(true);
             $query->update('#__judirectory_listings AS listing');
             $query->set('listing.template_params = ""');
             $query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1');
             $query->where('listing.style_id = -1');
             $query->where('listingxref.cat_id = ' . $categoryIdAssignedToStyle);
             $db->setQuery($query);
             $db->execute();
             JUDirectoryFrontHelperTemplate::removeTemplateParamsOfInheritedStyleCatListing($categoryIdAssignedToStyle);
         }
     }
     $query = $db->getQuery(true);
     $query->select('listing.id');
     $query->select('listingxref.cat_id AS cat_id');
     $query->from('#__judirectory_listings AS listing');
     $query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1');
     $query->where('listing.style_id = ' . $pk);
     $db->setQuery($query);
     $listingObjectListAssignedToStyle = $db->loadObjectList();
     $catArrayResetTemplateParams = array();
     foreach ($listingObjectListAssignedToStyle as $listingObject) {
         $styleObjectOfCategory = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($listingObject->cat_id);
         if ($styleObjectOfCategory->template_id != $this->template_id) {
             $catArrayResetTemplateParams[] = $listingObject->cat_id;
         }
     }
     $catArrayResetTemplateParams = array_unique($catArrayResetTemplateParams);
     if (is_array($catArrayResetTemplateParams) && count($catArrayResetTemplateParams)) {
         $query = $db->getQuery(true);
         $query->update('#__judirectory_listings AS listing');
         $query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1');
         $query->set('listing.template_params = ""');
         $query->set('listing.style_id = -1');
         $query->where('listingxref.cat_id IN (' . implode(',', $catArrayResetTemplateParams) . ')');
         $query->where('listing.style_id = ' . $pk);
         $db->setQuery($query);
         $db->execute();
     }
     return parent::delete($pk);
 }
Example #20
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);
 }
Example #21
0
 public function store($updateNulls = false)
 {
     $app = JFactory::getApplication();
     if ($app->isSite()) {
         if ($this->_comment_latest) {
             $timeNow = strtotime($this->created);
             $waiting = $this->_comment_latest + $this->_comment_interval - $timeNow;
             if ($waiting > 0) {
                 $this->setError($this->getErrorForIntervalComment($waiting));
                 return false;
             }
         }
         if ($this->_comment_latest_same_listing > 0) {
             $timeNow = strtotime($this->created);
             $waiting = $this->_comment_latest_same_listing + $this->_comment_interval_same_listing - $timeNow;
             if ($waiting > 0) {
                 $this->setError($this->getErrorForIntervalComment($waiting));
                 return false;
             }
         }
     }
     if (!parent::store($updateNulls)) {
         $this->setError(JText::_('COM_JUDIRECTORY_COMMENT_FAILED'));
         return false;
     }
     return true;
 }
Example #22
0
 /**
  * Constructor
  *
  * @param JDatabaseDriver $db Database driver object.
  *
  * @since   11.1
  */
 public function __construct(JDatabaseDriver $db)
 {
     parent::__construct('#__assets', 'id', $db);
 }
Example #23
0
 function __construct(&$db)
 {
     parent::__construct('cb_captochuc', 'id', &$db);
 }
Example #24
0
 public function rebuild($parentId = null, $leftId = 0, $level = 0, $path = '')
 {
     return parent::rebuild($parentId, $leftId, $level, $path);
 }
Example #25
0
 /**
  * Constructor
  *
  * @param   JDatabaseDriver  $db  Database driver object.
  *
  * @since   12.1
  */
 public function __construct($db)
 {
     parent::__construct('#__categories', 'id', $db);
 }
Example #26
0
 function __construct(&$db)
 {
     parent::__construct('cb_goichucvu', 'id', $db);
 }
Example #27
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();
     $this->modified_time = $date->toSql();
     if ($this->id) {
         // Existing category
         $this->modified_user_id = $user->get('id');
     } else {
         // New category. A category created_time and created_user_id field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!(int) $this->created_time) {
             $this->created_time = $date->toSql();
         }
         if (empty($this->created_user_id)) {
             $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' => (int) $this->parent_id, 'extension' => $this->extension)) && ($table->id != $this->id || $this->id == 0)) {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
         return false;
     }
     return parent::store($updateNulls);
 }
Example #28
0
 /**
  * Gets the ID of the root item in the tree
  *
  * @return  mixed  The primary id of the root row, or false if not found and the internal error is set.
  *
  * @since   11.1
  */
 public function getRootId()
 {
     if ((int) self::$root_id > 0) {
         return self::$root_id;
     }
     // Get the root item.
     $k = $this->_tbl_key;
     // Test for a unique record with parent_id = 0
     $query = $this->_db->getQuery(true)->select($k)->from($this->_tbl)->where('parent_id = 0');
     $result = $this->_db->setQuery($query)->loadColumn();
     if (count($result) == 1) {
         self::$root_id = $result[0];
         return self::$root_id;
     }
     // Test for a unique record with lft = 0
     $query->clear()->select($k)->from($this->_tbl)->where('lft = 0');
     $result = $this->_db->setQuery($query)->loadColumn();
     if (count($result) == 1) {
         self::$root_id = $result[0];
         return self::$root_id;
     }
     $fields = $this->getFields();
     if (array_key_exists('alias', $fields)) {
         // Test for a unique record alias = root
         $query->clear()->select($k)->from($this->_tbl)->where('alias = ' . $this->_db->quote('root'));
         $result = $this->_db->setQuery($query)->loadColumn();
         if (count($result) == 1) {
             self::$root_id = $result[0];
             return self::$root_id;
         }
     }
     $e = new UnexpectedValueException(sprintf('%s::getRootId', get_class($this)));
     $this->setError($e);
     self::$root_id = false;
     return false;
 }
Example #29
0
 /**
  * Method to store a node in the database table.
  *
  * @param   boolean  $updateNulls  True to update null values as well.
  *
  * @return  boolean  True on success.
  */
 public function store($updateNulls = false)
 {
     $dispatcher = RFactory::getDispatcher();
     // Import plugin types
     if ($this->_eventBeforeStore || $this->_eventAfterStore) {
         foreach ($this->_pluginTypesToImport as $type) {
             JPluginHelper::importPlugin($type);
         }
     }
     // Trigger before store
     if ($this->_eventBeforeStore) {
         $results = $dispatcher->trigger($this->_eventBeforeStore, array($this, $updateNulls));
         if (count($results) && in_array(false, $results, true)) {
             return false;
         }
     }
     // Store
     if (!parent::store($updateNulls)) {
         return false;
     }
     // Trigger after store
     if ($this->_eventAfterStore) {
         $results = $dispatcher->trigger($this->_eventAfterStore, array($this, $updateNulls));
         if (count($results) && in_array(false, $results, true)) {
             return false;
         }
     }
     return true;
 }
Example #30
0
 function __construct(&$db)
 {
     parent::__construct('ins_dept_loaihinh', 'id', $db);
 }