Esempio n. 1
0
 protected function indexAction()
 {
     if (\Simplify::request()->get('activate')) {
         \Amplify\Modules::activateModule(\Simplify::request()->get('module'));
         \Simplify::response()->redirect(\Simplify::request()->route());
     } elseif (\Simplify::request()->get('deactivate')) {
         \Amplify\Modules::deactivateModule(\Simplify::request()->get('module'));
         \Simplify::response()->redirect(\Simplify::request()->route());
     }
     try {
         $modules = \Amplify\Modules::getAllModules();
         $this->set('modules', $modules);
     } catch (AmplifyException $e) {
         //
     }
 }
Esempio n. 2
0
 public static function getAllModules()
 {
     $modules = array();
     $base = \Simplify::config()->get('app:dir') . 'modules';
     $path = '/';
     if (!is_dir($base . $path) && !mkdir($base . $path, 0655)) {
         throw new AmplifyException('Application modules dir not found and could not be created: ' . $base . $path);
     }
     $it = new \DirectoryIterator($base . $path);
     while ($it->valid()) {
         if (!$it->isDot()) {
             if ($it->isDir()) {
                 $filename = $path . $it->getFilename() . '/Module.php';
                 if (file_exists($base . $filename)) {
                     require_once $base . $filename;
                     $class = \Simplify\Inflector::camelize($it->getFilename()) . '\\Module';
                     if (class_exists($class) && is_subclass_of($class, '\\Amplify\\Module')) {
                         $modules[addslashes($class)] = new $class();
                         $modules[addslashes($class)]->active = \Amplify\Modules::isActive($class);
                     }
                 }
             }
             /*
              * elseif (strrpos($it->getFilename(), 'Module.php') !== false) {
              * $filename = $path . $it->getFilename();
              *
              * require_once ($base . $filename);
              *
              * $class = $it->getBasename('.php');
              *
              * if (class_exists($class) && is_subclass_of($class, '\Amplify\Module')) {
              * $modules[$filename] = new $class();
              * $modules[$filename]->active = \Amplify\Modules::isActive($filename);
              * }
              * }
              */
         }
         $it->next();
     }
     return $modules;
 }
Esempio n. 3
0
 /**
  *
  * @return \Simplify\Menu
  */
 protected function createMenu()
 {
     $this->menu = new \Simplify\Menu('amp');
     if (Account::validate('manage_accounts', true)) {
         $accountsMenu = new \Simplify\Menu('accounts', null, __('Usuários'));
         $_users = new \Simplify\MenuItem('users', __('Usuários'), null, new \Simplify\URL('route://admin_users'));
         $_add_user = new \Simplify\MenuItem('add_user', __('Adicionar usuário'), null, new \Simplify\URL('route://admin_users', array('formAction' => 'create')));
         $accountsMenu->addItem($_users);
         $accountsMenu->addItem($_add_user);
         $this->menu->addItem($accountsMenu);
         if (Account::validate('manage_groups', true)) {
             $_groups = new \Simplify\MenuItem('groups', 'Grupos', null, new \Simplify\URL('route://admin_groups'));
             $_add_group = new \Simplify\MenuItem('add_group', __('Criar grupo'), null, new \Simplify\URL('route://admin_groups', array('formAction' => 'create')));
             $groupsMenu = new \Simplify\Menu('groups', null, __('Grupos'));
             $groupsMenu->addItem($_groups);
             $groupsMenu->addItem($_add_group);
             $accountsMenu->addItem($groupsMenu);
         }
         if (Account::validate('manage_permissions', true)) {
             $_perms = new \Simplify\MenuItem('permissions', __('Permissões'), null, new \Simplify\URL('route://admin_permissions'));
             $_add_perm = new \Simplify\MenuItem('add_permission', __('Criar permissão'), null, new \Simplify\URL('route://admin_permissions', array('formAction' => 'create')));
             $permsMenu = new \Simplify\Menu('permissions', null, __('Permissões'));
             $permsMenu->addItem($_perms);
             $permsMenu->addItem($_add_perm);
             $accountsMenu->addItem($permsMenu);
         }
     }
     if (Account::validate('manage_options', true)) {
         $optionsMenu = new \Simplify\Menu('options', null, __('Opções'));
         $general = new \Simplify\MenuItem('general', 'Geral', null, new \Simplify\URL('route://admin_options'));
         $modules = new \Simplify\MenuItem('modules', 'Módulos', 'options', new \Simplify\URL('route://admin_modules'));
         $email = new \Simplify\MenuItem('email', 'Email', null, \Simplify\URL::make('route://admin_options_email'));
         $optionsMenu->addItem($general);
         $optionsMenu->addItem($modules);
         $optionsMenu->addItem($email);
         $this->menu->addItem($optionsMenu);
     }
     \Amplify\Modules::executeCallback('onCreateMenu', $this->menu);
 }