예제 #1
0
 public function controlAdapterAccess()
 {
     //instance application
     $app =& JFactory::getApplication();
     //get component
     $option = JRequest::getCMD('option');
     //instance adapters lib
     $adapterControl = new Adapters();
     //get name of application
     $applicationName = $app->getName();
     $this->redirectAdminComUsers();
     //verify if access a component
     if (!empty($option)) {
         //geting a Adapter
         $myAdapter = $adapterControl->getAdapter($option);
         $this->executeAdapterPlugin($myAdapter);
         if ($applicationName == 'site') {
             //get Itemid
             $Itemid = JRequest::getInt('Itemid');
             if ($Itemid > 0) {
                 $myAdapter = $adapterControl->getAdapter('com_menus');
                 $this->executeAdapterPlugin($myAdapter);
             }
         }
     }
     //get all adapters
     $listAdapters = $adapterControl->listAdapters();
     if (!empty($listAdapters)) {
         foreach ($listAdapters as $adapterObject) {
             if (array_key_exists("pluginExecution", $adapterObject->xmlData) && $adapterObject->xmlData["pluginExecution"] == 'independent') {
                 $this->executeAdapterPlugin($adapterObject, false);
             }
         }
     }
 }
예제 #2
0
 /**
  * Saves the record
  */
 function save()
 {
     global $mainframe;
     /**
      * Check for request forgeries
      */
     JRequest::checkToken() or jexit('Invalid Token');
     $option = JRequest::getCmd('option');
     /**
      * Initialize some variables
      */
     $me =& JFactory::getUser();
     $db = JFactory::getDBO();
     $acl =& JFactory::getACL();
     $post = JRequest::get('post');
     $groupID = JRequest::getInt('id', 0, 'post', 'int');
     $parentID = JRequest::getInt('parent_id', 30, 'post', 'int');
     $groupName = JRequest::getVar('name');
     /**
      * Creating a new group
      */
     if ($groupID == 0) {
         /**
          * Add New Group
          */
         $acl->add_group($groupName, $groupName, $parentID);
     } else {
         /**
          * Get Group Name By ID
          */
         $queryGetGorupName = "SELECT name FROM #__core_acl_aro_groups WHERE id =" . $groupID;
         $db->setQuery($queryGetGorupName);
         $oldGroupName = $db->loadResult();
         /**
          * Edit a Group
          */
         $acl->edit_group($groupID, $groupName, $groupName, $parentID);
     }
     /**
      * Instance Adapter Helper
      */
     $adaptersControl = new Adapters();
     /**
      * Get a List of Adapters
      */
     $adaptersList = $adaptersControl->listAdapters();
     /**
      * Gets Total
      */
     $totalAdapters = count($adaptersList);
     if ($totalAdapters > 0) {
         foreach ($adaptersList as $adapters) {
             /**
              * Include Adapters Controller
              */
             include $adapters->xmlData["pathController"];
             /**
              * Get Instance of Adapter Controller
              */
             $adapterController = new $adapters->xmlData["controller"]();
             /**
              * Call Save Method in Adapter Controller
              */
             if (isset($oldGroupName)) {
                 $adapterController->delete($oldGroupName);
             }
             $adapterController->save($groupName);
             unset($adapterController);
         }
     }
     /**
      * Redirect by task
      */
     switch ($this->getTask()) {
         case 'apply':
             $msg = JText::sprintf('NOIXACL_GROUPS_APPLY_SUCCESS') . " " . $groupName;
             $this->setRedirect("index.php?option={$option}&view=group&task=edit&cid[]=" . $groupID, $msg);
             break;
         case 'save':
         default:
             $msg = JText::sprintf('NOIXACL_GROUPS_SAVE_SUCCESS', $groupName);
             $this->setRedirect("index.php?option={$option}", $msg);
             break;
     }
 }