Inheritance: extends Gc\Db\AbstractTable
コード例 #1
0
ファイル: ModulePluginTest.php プロジェクト: gotcms/gotcms
 /**
  * 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);
 }
コード例 #2
0
ファイル: ModuleTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testInit()
 {
     $moduleModel = ModuleModel::fromArray(array('name' => 'Sitemap'));
     $moduleModel->save();
     $this->assertNull($this->object->init());
     $moduleModel->delete();
 }
コード例 #3
0
ファイル: Collection.php プロジェクト: gotcms/gotcms
 /**
  * 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;
 }
コード例 #4
0
ファイル: CommentListTest.php プロジェクト: gotcms/gotcms
 /**
  * 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);
 }
コード例 #5
0
ファイル: IndexControllerTest.php プロジェクト: gotcms/gotcms
 /**
  * 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();
 }
コード例 #6
0
ファイル: ModulePlugin.php プロジェクト: gotcms/gotcms
 /**
  * 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;
 }
コード例 #7
0
ファイル: IndexControllerTest.php プロジェクト: gotcms/gotcms
 /**
  * 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();
 }
コード例 #8
0
ファイル: IndexControllerTest.php プロジェクト: gotcms/gotcms
 /**
  * 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();
 }
コード例 #9
0
ファイル: InstallController.php プロジェクト: gotcms/gotcms
 /**
  * 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');
 }
コード例 #10
0
ファイル: Model.php プロジェクト: gotcms/gotcms
 /**
  * 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;
 }
コード例 #11
0
ファイル: Action.php プロジェクト: gotcms/gotcms
 /**
  * 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');
         }
     }
 }
コード例 #12
0
ファイル: IndexController.php プロジェクト: gotcms/gotcms
 /**
  * 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'));
 }
コード例 #13
0
ファイル: ModelTest.php プロジェクト: gotcms/gotcms
 /**
  * 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')));
 }