Inheritance: extends Gc\Db\AbstractTable
Ejemplo n.º 1
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     $this->module->delete();
     unset($this->module);
     unset($this->renderer);
     unset($this->object);
 }
Ejemplo n.º 2
0
 /**
  * Test
  *
  * @return void
  */
 public function testInit()
 {
     $moduleModel = ModuleModel::fromArray(array('name' => 'Sitemap'));
     $moduleModel->save();
     $this->assertNull($this->object->init());
     $moduleModel->delete();
 }
Ejemplo n.º 3
0
 /**
  * Initialize modules
  *
  * @return \Gc\Module\Collection
  */
 protected function setModules()
 {
     $rows = $this->fetchAll($this->select(function (Select $select) {
         $select->order('name ASC');
     }));
     $modules = array();
     foreach ($rows as $row) {
         $modules[] = Model::fromArray((array) $row);
     }
     $this->setData('modules', $modules);
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     $this->boostrap->uninstall();
     $this->document->delete();
     $this->view->delete();
     $this->layout->delete();
     $this->documentType->delete();
     $this->user->delete();
     $this->module->delete();
     unset($this->module);
     unset($this->document);
     unset($this->view);
     unset($this->layout);
     unset($this->documentType);
     unset($this->user);
     unset($this->object);
     unset($this->renderer);
 }
Ejemplo n.º 5
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 public function tearDown()
 {
     StaticEventManager::resetInstance();
     ModuleModel::uninstall(Registry::get('Application')->getServiceManager()->get('CustomModules')->getModule('Social'), ModuleModel::fromName('Social'));
     parent::tearDown();
 }
Ejemplo n.º 6
0
 /**
  * Determine if we can create an instance.
  *
  * @param string|array $moduleName Module name
  * @param string       $pluginName Plugin name
  *
  * @return bool
  */
 public function canCreate($moduleName, $pluginName = null)
 {
     if (is_array($moduleName)) {
         list($moduleName, $pluginName) = $moduleName;
     } else {
         $pluginName = $this->toCamelCase($pluginName);
     }
     if (isset($this->instances[$moduleName][$pluginName])) {
         return true;
     }
     if (ModuleModel::fromName($moduleName)) {
         $className = $moduleName . '\\Plugin\\' . $pluginName;
         if (class_exists($className)) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 7
0
 /**
  * Test
  *
  * @return void
  */
 public function testUninstallAction()
 {
     $moduleModel = ModuleModel::fromArray(array('name' => 'Sitemap'));
     $moduleModel->save();
     $this->dispatch('/admin/module/uninstall/' . $moduleModel->getId());
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcModule');
     $this->assertControllerName('ModuleController');
     $this->assertControllerClass('IndexController');
     $this->assertMatchedRouteName('module/uninstall');
     $moduleModel->delete();
 }
Ejemplo n.º 8
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 public function tearDown()
 {
     StaticEventManager::resetInstance();
     ModuleModel::uninstall(Registry::get('Application')->getServiceManager()->get('CustomModules')->getModule('Blog'), ModuleModel::fromName('Blog'));
     $this->document->delete();
     $this->view->delete();
     $this->layout->delete();
     $this->documentType->delete();
     unset($this->document);
     unset($this->object);
     unset($this->view);
     unset($this->layout);
     unset($this->documentType);
     parent::tearDown();
 }
Ejemplo n.º 9
0
 /**
  * Insert data into database
  *
  * @param \Zend\Db\Adapter\Adapter $dbAdapter Database adapter
  * @param string                   $template  Template name
  * @param string                   $sqlType   Sql database type
  *
  * @return \Zend\View\Model\JsonModel|null
  */
 protected function installTemplate($dbAdapter, $template, $sqlType)
 {
     $templatePath = GC_APPLICATION_PATH . sprintf('/data/install/design/%s', $template);
     $info = new Info();
     $info->fromFile($templatePath . '/design.info');
     $filePath = sprintf('%s/sql/%s.sql', $templatePath, $sqlType);
     if (!file_exists($filePath)) {
         return $this->returnJson(array('success' => false, 'message' => sprintf('Could not find data for this template and driver: Driver %s, path %s', $sqlType, $templatePath)));
     }
     $designInfos = $info->getInfos();
     if (!empty($designInfos['modules'])) {
         $modules = $this->getServiceLocator()->get('CustomModules');
         foreach ($designInfos['modules'] as $module) {
             ModuleModel::install($modules, $module);
         }
     }
     $sql = file_get_contents($filePath);
     $dbAdapter->getDriver()->getConnection()->getResource()->exec($sql);
     File::copyDirectory($templatePath . '/frontend', GC_PUBLIC_PATH . '/frontend');
     if (file_exists($templatePath . '/files')) {
         File::copyDirectory($templatePath . '/files', GC_MEDIA_PATH . '/files');
     }
     File::copyDirectory($templatePath . '/templates', GC_APPLICATION_PATH . '/templates');
 }
Ejemplo n.º 10
0
 /**
  * Uninstall from module name
  *
  * @param AbstractModule $module Module
  * @param Model          $model  Module model
  *
  * @return boolean
  */
 public static function uninstall($module, $model)
 {
     if (empty($model) or !$module->uninstall()) {
         return false;
     }
     $select = new Sql\Select();
     $select->from('user_acl_permission')->columns(array('id'))->where->equalTo('permission', $model->getName());
     $userAclPermissionId = $model->fetchOne($select);
     $delete = new Sql\Delete();
     $delete->from('user_acl');
     $delete->where->equalTo('user_acl_permission_id', $userAclPermissionId);
     $model->execute($delete);
     $delete = new Sql\Delete();
     $delete->from('user_acl_permission');
     $delete->where->equalTo('id', $userAclPermissionId);
     $model->execute($delete);
     $model->delete();
     return true;
 }
Ejemplo n.º 11
0
 /**
  * Check user acl
  *
  * @param UserModel $userModel User model
  *
  * @return \Zend\Http\Response|null
  */
 protected function checkAcl(UserModel $userModel)
 {
     if (!empty($this->aclPage) and $userModel->getRole()->getName() !== RoleModel::PROTECTED_NAME) {
         $permission = null;
         $acl = $userModel->getAcl(true);
         if ($this->aclPage['resource'] == 'modules') {
             $moduleId = $this->getRouteMatch()->getParam('m');
             if (empty($moduleId)) {
                 $action = $this->getRouteMatch()->getParam('action');
                 $permission = $action === 'index' ? 'list' : $action;
             } else {
                 $moduleModel = ModuleModel::fromId($moduleId);
                 if (!empty($moduleModel)) {
                     $permission = $moduleModel->getName();
                 }
             }
         } else {
             $permission = empty($this->aclPage['permission']) ? null : $this->aclPage['permission'];
             if ($this->aclPage['permission'] != 'index' and !in_array($this->aclPage['resource'], array('content', 'stats'))) {
                 $action = $this->getRouteMatch()->getParam('action');
                 $permission .= (!empty($permission) ? '/' : '') . ($action === 'index' ? 'list' : $action);
             }
         }
         if (!$acl->isAllowed($userModel->getRole()->getName(), $this->aclPage['resource'], $permission)) {
             return $this->redirect()->toRoute('config/user/forbidden');
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * Uninstall module
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function uninstallAction()
 {
     $moduleId = $this->getRouteMatch()->getParam('id');
     $modules = $this->getServiceLocator()->get('CustomModules');
     $moduleModel = ModuleModel::fromId($moduleId);
     if (!empty($moduleModel)) {
         $module = $modules->getModule($moduleModel->getName());
         if (ModuleModel::uninstall($module, $moduleModel)) {
             return $this->returnJson(array('success' => true, 'message' => 'Module uninstalled'));
         }
     }
     return $this->returnJson(array('success' => false, 'message' => 'Can\'t uninstall module'));
 }
Ejemplo n.º 13
0
 /**
  * Test
  *
  * @return void
  */
 public function testInstallAndUninstall()
 {
     $modules = Registry::get('Application')->getServiceManager()->get('CustomModules');
     Model::uninstall($modules->getModule('Blog'), Model::fromName('Blog'));
     $this->assertInternalType('integer', (int) Model::install($modules, 'Blog'));
     $this->assertTrue(Model::uninstall($modules->getModule('Blog'), Model::fromName('Blog')));
 }