?
Path : /home/admin/public_html/old/administrator/components/com_xijc/controllers/ |
Current File : /home/admin/public_html/old/administrator/components/com_xijc/controllers/whitelist.php |
<?php // no direct access defined('_JEXEC') or die('Restricted access'); class XiJCControllerWhitelist extends JController { function __construct($config = array()) { parent::__construct($config); } function display() { parent::display(); } function edit() { $id = JRequest::getVar('editId', 0 , 'GET'); $viewName = JRequest::getCmd( 'view' , 'whitelist' ); // Get the document object $document =& JFactory::getDocument(); // Get the view type $viewType = $document->getType(); $view =& $this->getView( $viewName , $viewType ); $layout = JRequest::getCmd( 'layout' , 'whitelist.edit' ); $view->setLayout( $layout ); echo $view->edit($id); } function save() { global $mainframe; // Check for request forgeries JRequest::checkToken() or jexit( 'Invalid Token' ); $post = JRequest::get('post'); //$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); //$post['id'] = (int) $cid[0]; $user =& JFactory::getUser(); if ( $user->get('guest')) { JError::raiseError( 403, JText::_('ACCESS FORBIDDEN') ); return; } $urlparamstring = XiJCManager::getParamsInArray(); /* * Insert the data in #__xijc_whitelist. */ JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $row =& JTable::getInstance( 'whitelist' , 'XiJCTable' ); $row->load( $post['id'] ); $row->rulename = JRequest::getVar('rulename','','POST'); $row->option = JRequest::getVar('selectedoption','','POST'); $row->enable = JRequest::getVar('enable',0,'POST'); $row->params = $urlparamstring; if($storedId = $row->store()) $msg = JText::_('WHITELIST SAVED'); else $msg = JText::_('UNABLE TO SAVE WHITELIST'); $link = JRoute::_('index.php?option=com_xijc&view=whitelist&task=display', false); $mainframe->redirect($link, $msg); } function remove() { global $mainframe; // Check for request forgeries JRequest::checkToken() or jexit( 'Invalid Token' ); $ids = JRequest::getVar( 'cid', array(0), 'post', 'array' ); //$post['id'] = (int) $cid[0]; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $row =& JTable::getInstance( 'whitelist' , 'XiJCTable' ); $i = 1; if(!empty($ids)) { foreach( $ids as $id ) { $row->load( $id ); //Delete the record from #__xijc_whitelist table. if(!$row->delete( $id )) { // If there are any error when deleting, we just stop and redirect user with error. $message = JText::_('ERROR IN REMOVING WHITELIST'); $mainframe->redirect( 'index.php?option=com_xijc&view=whitelist' , $message); exit; } $i++; } } $count = $i - 1; $cache = & JFactory::getCache('com_content'); $cache->clean(); $message = $count.' '.JText::_('WHITELIST REMOVED'); $link = JRoute::_('index.php?option=com_xijc&view=whitelist', false); $mainframe->redirect($link, $message); } function publish() { global $mainframe; // Check for request forgeries JRequest::checkToken() or jexit( 'Invalid Token' ); // Initialize variables $ids = JRequest::getVar( 'cid', array(0), 'post', 'array' ); $total = count( $ids ); if (empty( $ids )) { return JError::raiseWarning( 500, JText::_( 'NO ITEMS SELECTED' ) ); } $wModel = XiJCFactory::getModel( 'whitelist' ); $counter = 0; foreach($ids as $id){ $success = $wModel->updateEnable($id,1); if($success) $counter++; } $msg = sprintf(JText::_('ITEMS ENABLED'),$counter); $link = JRoute::_('index.php?option=com_xijc&view=whitelist', false); $mainframe->redirect($link, $msg); } function unpublish() { global $mainframe; // Check for request forgeries JRequest::checkToken() or jexit( 'Invalid Token' ); // Initialize variables $ids = JRequest::getVar( 'cid', array(0), 'post', 'array' ); $total = count( $ids ); if (empty( $ids )) { return JError::raiseWarning( 500, JText::_( 'NO ITEMS SELECTED' ) ); } $wModel = XiJCFactory::getModel( 'whitelist' ); $counter = 0; foreach($ids as $id){ $success = $wModel->updateEnable($id,0); if($success) $counter++; } $msg = sprintf(JText::_('ITEMS DISABLED'),$counter); $link = JRoute::_('index.php?option=com_xijc&view=whitelist', false); $mainframe->redirect($link, $msg); } }