예제 #1
0
 /**
  * Get the parent asset id for the record
  *
  * @return	int
  */
 protected function _getAssetParentId()
 {
     // Initialise variables.
     $assetId = null;
     // This is a category under a category.
     if ($this->parent_id > 1) {
         // Build the query to get the asset id for the parent category.
         $query = new JQuery();
         $query->select('asset_id');
         $query->from('#__categories');
         $query->where('id = ' . (int) $this->parent_id);
         // Get the asset id from the database.
         $this->_db->setQuery($query);
         if ($result = $this->_db->loadResult()) {
             $assetId = (int) $result;
         }
     } elseif ($assetId === null) {
         // Build the query to get the asset id for the parent category.
         $query = new JQuery();
         $query->select('id');
         $query->from('#__assets');
         $query->where('name = ' . $this->_db->quote($this->extension));
         // Get the asset id from the database.
         $this->_db->setQuery($query);
         if ($result = $this->_db->loadResult()) {
             $assetId = (int) $result;
         }
     }
     // Return the asset id.
     if ($assetId) {
         return $assetId;
     } else {
         return parent::_getAssetParentId();
     }
 }
예제 #2
0
 /**
  * Get the parent asset id for the record
  *
  * @param   JTable   $table  A JTable object for the asset parent.
  * @param   integer  $id     The id for the asset
  *
  * @return  integer  The id of the asset's parent
  *
  * @since   11.1
  */
 protected function _getAssetParentId(JTable $table = null, $id = null)
 {
     $assetId = null;
     // This is a category under a category.
     if ($this->parent_id > 1) {
         // Build the query to get the asset id for the parent category.
         $query = $this->_db->getQuery(true)->select($this->_db->quoteName('asset_id'))->from($this->_db->quoteName('#__categories'))->where($this->_db->quoteName('id') . ' = ' . $this->parent_id);
         // Get the asset id from the database.
         $this->_db->setQuery($query);
         if ($result = $this->_db->loadResult()) {
             $assetId = (int) $result;
         }
     } elseif ($assetId === null) {
         // Build the query to get the asset id for the parent category.
         $query = $this->_db->getQuery(true)->select($this->_db->quoteName('id'))->from($this->_db->quoteName('#__assets'))->where($this->_db->quoteName('name') . ' = ' . $this->_db->quote($this->extension));
         // Get the asset id from the database.
         $this->_db->setQuery($query);
         if ($result = $this->_db->loadResult()) {
             $assetId = (int) $result;
         }
     }
     // Return the asset id.
     if ($assetId) {
         return $assetId;
     } else {
         return parent::_getAssetParentId($table, $id);
     }
 }
예제 #3
0
 protected function _getAssetParentId(JTable $table = null, $id = null)
 {
     $assetId = null;
     if ($this->parent_id > 0) {
         $query = $this->_db->getQuery(true);
         $query->select($this->_db->quoteName('asset_id'));
         $query->from($this->_db->quoteName('#__judownload_categories'));
         $query->where($this->_db->quoteName('id') . ' = ' . $this->parent_id);
         $this->_db->setQuery($query);
         if ($result = $this->_db->loadResult()) {
             $assetId = (int) $result;
         }
     }
     if (!$assetId) {
         $query = $this->_db->getQuery(true);
         $query->select($this->_db->quoteName('id'));
         $query->from($this->_db->quoteName('#__assets'));
         $query->where($this->_db->quoteName('name') . ' = ' . $this->_db->quote('com_judownload'));
         $this->_db->setQuery($query);
         if ($result = $this->_db->loadResult()) {
             $assetId = (int) $result;
         }
     }
     if ($assetId) {
         return $assetId;
     } else {
         return parent::_getAssetParentId($table, $id);
     }
 }