芝麻web文件管理V1.00
编辑当前文件:/home/asmplong/www/ancien-site-2019/site/administrator/components/com_akeeba/models/profiles.php
getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit')); $limitstart = $app->getUserStateFromRequest(JRequest::getCmd('option','com_akeeba').'profileslimitstart','limitstart',0); // Set the page pagination variables $this->setState('limit',$limit); $this->setState('limitstart',$limitstart); // Get the ID from the request $cid = JRequest::getVar('cid', false); if($cid) { $cid = JRequest::getVar('cid', false, 'DEFAULT', 'array'); if(!empty($cid)) { $this->id_list = array(); foreach($cid as $id) { $this->id_list[] = $id; } } $id = $cid[0]; } else { $id = JRequest::getInt('id', 0); $this->id_list = array($id); } $this->setId($id); } /** * Sets a Profile ID and resets internal data * * @param int $id Profile ID */ public function setId($id=0) { $this->_id = $id; $this->_profile = null; } /** * Returns the currently set profile ID * @return int */ public function getId() { return $this->_id; } public function getAllIds() { return $this->id_list; } /** * Returns the entry for the profile whose ID is loaded in the model * * @return stdClass An object representing the profile */ public function &getProfile() { if(empty($this->_profile)) { $db =& $this->getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__ak_profiles')." WHERE ". $db->nameQuote('id')." = ".$this->_id; $db->setQuery($query); $this->_profile = $db->loadObject(); } return $this->_profile; } /** * Gets a list of all the profiles as an array of objects * * @param bool $overrideLimits If set, it will list all entries, without applying limits * @return array List of profiles */ public function getProfilesList($overrideLimits = false) { if( empty($this->_list) ) { $db =& $this->getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__ak_profiles'); $query .= ' ORDER BY '.$db->nameQuote('id').' ASC'; $limitstart = $this->getState('limitstart'); $limit = $this->getState('limit'); if(!$overrideLimits) $this->_list = $this->_getList($query, $limitstart, $limit); else $this->_list = $this->_getList($query); } return $this->_list; } /** * Saves a profile * * @param object|array $data The data to be bound and saved * @return bool True on success */ public function save($data) { // Get the table $this->_table =& $this->getTable('Profile'); // Try to save the data if(!$this->_table->save($data)) { // Oops... Something wrong happened $this->setError($this->_table->getError()); return false; } else { return true; } } /** * Returns the last saved table * * @return JTable */ public function &getSavedTable() { return $this->_table; } /** * Attempts to delete the record whose ID is set in the model. Fails upon detecting * an attempt to delete the default profile. * * @return bool True on success */ public function delete() { // Do not delete the default profile if($this->_id == 1) { $this->setError(JText::_('PROFILE_CANNOT_DELETE_DEFAULT')); return false; } // Check for invalid id's (not numeric, or <= 0) elseif( (!is_numeric($this->_id)) || ($this->_id <= 0) ) { $this->setError(JText::_('PROFILE_INVALID_ID')); return false; } $db =& $this->getDBO(); // Delete the profile itself $sql = 'DELETE FROM '.$db->nameQuote('#__ak_profiles').' WHERE '. $db->nameQuote('id').' = '.$this->_id; $db->setQuery($sql); if(!$db->query()) { $this->setError($db->getError()); return false; } return true; } /** * Tries to copy the profile whose ID is set in the model to a new record * * @return bool True on success */ public function copy() { // Check for invalid id's (not numeric, or <= 0) if( (!is_numeric($this->_id)) || ($this->_id <= 0) ) { $this->setError(JText::_('PROFILE_INVALID_ID')); return false; } $db =& $this->getDBO(); // 1. Copy the profile itself // -- Load the profile using the TableProfile class $profileTable = $this->getTable('profile'); if(!$profileTable->load($this->_id)) { $this->setError($profileTable->getError()); return false; } // Force creating a new record $profileTable->id = 0; // Try to save the new record if($profileTable->check()) { if(!$profileTable->store(true)) { $this->setError($profileTable->getError()); return false; } } else { $this->setError($profileTable->getError()); return false; } // Get the new Profile ID $newProfileID = $profileTable->id; $this->setId($newProfileID); return true; } /** * Ensures that the user passed on a valid ID. * * @return bool True if the ID belongs to a valid profile, false otherwise */ public function checkID() { // Check for invalid id's (not numeric, or <= 0) if( (!is_numeric($this->_id)) || ($this->_id <= 0) ) return false; // Check for existing ID, or return false $myProfile =& $this->getProfile(); return is_object($myProfile); } /** * Get a pagination object * * @access public * @return JPagination * */ public function getPagination() { if( empty($this->_pagination) ) { // Import the pagination library jimport('joomla.html.pagination'); // Prepare pagination values $total = $this->getTotal(); $limitstart = $this->getState('limitstart'); $limit = $this->getState('limit'); // Create the pagination object $this->_pagination = new JPagination($total, $limitstart, $limit); } return $this->_pagination; } /** * Get number of profile items * * @access public * @return integer */ public function getTotal() { if( empty($this->_total) ) { $db =& $this->getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__ak_profiles'); $this->_total = $this->_getListCount($query); } return $this->_total; } public function getPostProcessingEnginePerProfile() { // Cache the current profile $session =& JFactory::getSession(); $currentProfileID = $session->get('profile', null, 'akeeba'); $db =& $this->getDBO(); $query = "SELECT id FROM ".$db->nameQuote('#__ak_profiles'); $db->setQuery($query); $profiles = $db->loadResultArray(); $engines = array(); foreach($profiles as $profileID) { AEPlatform::load_configuration($profileID); $pConf = AEFactory::getConfiguration(); $engines[$profileID] = $pConf->get('akeeba.advanced.proc_engine'); } AEPlatform::load_configuration($currentProfileID); return $engines; } }