Exemplo n.º 1
0
    /**
     * Upgrades to 2.6.0-alpha1 (2.5.60)
     *
     * @return bool|string
     */
    protected function upgradeTo_260_alpha1()
    {
        switch ($this->version) {
            case '2.5.0':
            case '2.5.1':
            case '2.5.2':
            case '2.5.3':
            case '2.5.4':
            case '2.5.5':
            case '2.5.6':
            case '2.5.50':
                foreach (array('main', 'admin') as $siteType) {
                    $layout = new Layout($siteType . '-default');
                    $sc = $layout->getControllers('SC');
                    $sc = array_shift($sc);
                    $layout->detachController($sc['id']);
                    $layout->save();
                    // Create the new FPSC (FrontPage Sector Content) layout
                    $layout = new Layout('fpsc-' . $siteType);
                    $layout->addController('SC', $sc, $sc['id']);
                    $layout->save();
                }
            case '2.5.51':
                $this->sqlFile('2.6.0-alpha1/2.5.52.sql');
            case '2.5.52':
                $this->sqlFile('2.6.0-alpha1/2.5.53.sql');
            case '2.5.53':
                $this->_config_sql->add('media/wm_position', 'bl');
            case '2.5.54':
                /**
                 * Update the ACL resources for the page changes (#247)
                 */
                $this->sqlFile('2.6.0-alpha1/2.5.55.sql');
                $addRoles = $editRoles = $manageRoles = array();
                foreach ($this->_acl->getAllRoles() as $role) {
                    if ($this->_acl->check('page_delete', $role['id'])) {
                        $editRoles[] = $role['name'];
                        $manageRoles[] = $role['name'];
                    } else {
                        if ($this->_acl->check('page_edit', $role['id'])) {
                            $editRoles[] = $role['name'];
                        }
                    }
                    if ($this->_acl->check('page_add', $role['id'])) {
                        $addRoles[] = $role['name'];
                    }
                }
                // Add in the new resources
                $query = $this->_sql->query('SELECT SUBSTRING(name, 11) AS pid FROM {PREFIX}acl_resources
													WHERE name LIKE "page-view_%"');
                foreach ($query->fetchAll(PDO::FETCH_COLUMN) as $pid) {
                    $this->_acl->allowOnly('page-edit_' . $pid, $editRoles);
                    $this->_acl->allowOnly('page-manage_' . $pid, $manageRoles);
                }
                $this->_acl->deleteResource(array('page_add', 'page_edit', 'page_delete'));
                $this->_acl->allowOnly('page_manage', $addRoles);
            case '2.5.55':
                $this->sqlFile('2.6.0-alpha1/2.5.56.sql');
            case '2.5.56':
            default:
                return '2.5.60';
        }
    }
Exemplo n.º 2
0
 /**
  * Attempts to detach/remove a controller from the sector map for the
  * correct site type. Done by controller ID. If the site type does not
  * exist then it will not attempt to detach the controller.
  *
  * @return bool
  */
 protected function detachCntrlr()
 {
     try {
         $layout = new Layout($this->_input->post('content_layout_name'));
         $resources = array();
         $delCount = 0;
         foreach ($this->_input->post('controller_ids') as $cntrlrId) {
             try {
                 $layout->detachController($cntrlrId);
                 ++$delCount;
                 // Store resource IDs to delete
                 $resources[] = 'layout_controller_' . $cntrlrId;
             } catch (Layout_ControllerNoExist $e) {
                 $this->_event->error(sprintf(t('Unable to detach module ID "%d" as it does not exist'), $cntrlrId));
             }
         }
         if ($layout->save()) {
             // Remove ACL resources if needed
             if (!empty($resources)) {
                 foreach ($resources as $tmpResource) {
                     try {
                         $this->_acl->deleteResource($tmpResource);
                     } catch (Acl_ResourceNoExist $e) {
                         $this->_log->message('Content layout unable to remove ACL Resource "' . $tmpResource . '"', Log::L_INFO);
                     }
                 }
             }
             if ($delCount > 0) {
                 $this->_event->success(t('Detached selected modules'));
             }
         } else {
             $this->_event->error(t('Unable to save layout, ensure file is writable'));
         }
     } catch (Input_KeyNoExist $e) {
         $this->_event->error(t('No modules selected'));
     }
 }