芝麻web文件管理V1.00
编辑当前文件:/home/asmplong/www/ancien-site-2019/site/administrator/components/com_users/controllers/users.php
registerTask('block', 'changeBlock'); $this->registerTask('unblock', 'changeBlock'); } /** * Proxy for getModel. * * @since 1.6 */ public function getModel($name = 'User', $prefix = 'UsersModel', $config = array('ignore_request' => true)) { return parent::getModel($name, $prefix, $config); } /** * Method to remove a record. * * @since 1.6 */ public function changeBlock() { // Check for request forgeries. JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $ids = JRequest::getVar('cid', array(), '', 'array'); $values = array('block' => 1, 'unblock' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); if (empty($ids)) { JError::raiseWarning(500, JText::_('COM_USERS_USERS_NO_ITEM_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Change the state of the records. if (!$model->block($ids, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1){ $this->setMessage(JText::plural('COM_USERS_N_USERS_BLOCKED', count($ids))); } else if ($value == 0){ $this->setMessage(JText::plural('COM_USERS_N_USERS_UNBLOCKED', count($ids))); } } } $this->setRedirect('index.php?option=com_users&view=users'); } /** * Method to remove a record. * * @since 1.6 */ public function activate() { // Check for request forgeries. JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $ids = JRequest::getVar('cid', array(), '', 'array'); if (empty($ids)) { JError::raiseWarning(500, JText::_('COM_USERS_USERS_NO_ITEM_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Change the state of the records. if (!$model->activate($ids)) { JError::raiseWarning(500, $model->getError()); } else { $this->setMessage(JText::plural('COM_USERS_N_USERS_ACTIVATED', count($ids))); } } $this->setRedirect('index.php?option=com_users&view=users'); } /** * Method to run batch opterations. * * @return void * @since 1.6 */ function batch() { // Check for request forgeries. JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $app = JFactory::getApplication(); $model = $this->getModel('User'); $vars = JRequest::getVar('batch', array(), 'post', 'array'); $cid = JRequest::getVar('cid', array(), 'post', 'array'); // Sanitize user ids. $cid = array_unique($cid); JArrayHelper::toInteger($cid); // Remove any values of zero. if (array_search(0, $cid, true)) { unset($cid[array_search(0, $cid, true)]); } // Attempt to run the batch operation. if (!$model->batch($vars, $cid)) { // Batch operation failed, go back to the users list and display a notice. $message = JText::sprintf('COM_USERS_USER_BATCH_FAILED', $model->getError()); $this->setRedirect('index.php?option=com_users&view=users', $message, 'error'); return false; } $message = JText::_('COM_USERS_USER_BATCH_SUCCESS'); $this->setRedirect('index.php?option=com_users&view=users', $message); return true; } }