public function onDeactivation(&$controller)
 {
     // Remove basePath setting
     $controller->Setting->deleteAll(['key' => 'Service.mailChimpKey']);
     $CroogoPlugin = new CroogoPlugin();
     $CroogoPlugin->unmigrate('MailChimp');
 }
 /**
  * Called after activating the plugin in ExtensionsPluginsController::admin_toggle()
  *
  * @param object $controller Controller
  * @return void
  */
 public function onActivation(&$controller)
 {
     $controller->Croogo->addAco('Translate/Translate/admin_index');
     $controller->Croogo->addAco('Translate/Translate/admin_edit');
     $controller->Croogo->addAco('Translate/Translate/admin_delete');
     App::uses('CroogoPlugin', 'Extensions.Lib');
     $CroogoPlugin = new CroogoPlugin();
     $CroogoPlugin->migrate('Translate');
 }
Example #3
0
 /**
  * Creates the necessary settings
  *
  * @param object $controller Controller
  * @return void
  */
 public function onActivation(&$controller)
 {
     $CroogoPlugin = new CroogoPlugin();
     $result = $CroogoPlugin->migrate('Assets');
     if ($result) {
         $Setting = ClassRegistry::init('Settings.Setting');
         $Setting->write('Assets.installed', true);
     }
     return $result;
 }
 /**
  * Called after deactivating the plugin in ExtensionsPluginsController::admin_toggle()
  *
  * @param object $controller Controller
  * @return void
  */
 public function onDeactivation($controller)
 {
     // ACL: remove ACOs with permissions
     $controller->Croogo->removeAco('Cforms');
     $controller->Croogo->removeAco('FormFields');
     $controller->Croogo->removeAco('Submissions');
     //db config
     App::uses('CroogoPlugin', 'Extensions.Lib');
     $CroogoPlugin = new CroogoPlugin();
     $CroogoPlugin->unmigrate('Cforms');
 }
 /**
  * Called after deactivating the plugin in ExtensionsPluginsController::admin_toggle()
  *
  * @param object $controller Controller
  * @return void
  */
 public function onDeactivation(&$controller)
 {
     $CroogoPlugin = new CroogoPlugin();
     $result = $CroogoPlugin->unmigrate('ClearSession');
     if ($result) {
         $sessionConfig = 'php';
         $croogoConfigFile = APP . 'Config' . DS . 'croogo' . '.' . 'php';
         $File =& new File($croogoConfigFile);
         $fileContent = $File->read();
         $content = preg_replace('/(?<=\'defaults\' => \')([^\' ]+)/', $sessionConfig, $fileContent);
         if (!$File->write($content)) {
             return false;
         }
         return true;
     }
 }
 /**
  * Indirectly test CroogoEventManager::detachPluginSubscribers()
  * triggerred by calling CroogoPlugin::unload(null)
  */
 public function testDetachPluginSubscribers()
 {
     $loaded = CakePlugin::loaded('Shops');
     $this->assertNotEmpty($loaded);
     $eventName = 'Controller.Users.activationFailure';
     $event = Croogo::dispatchEvent($eventName, $this->Users);
     $this->assertTrue($event->result, sprintf('Event: %s', $eventName));
     CroogoPlugin::unload('Shops');
     $eventName = 'Controller.Users.activationFailure';
     $event = Croogo::dispatchEvent($eventName, $this->Users);
     $this->assertNull($event->result, sprintf('Event: %s', $eventName));
 }
Example #7
0
 /**
  * Deactivate a plugin
  *
  * @param string $plugin
  * @return boolean
  */
 protected function _deactivatePlugin($plugin = null)
 {
     $result = $this->_CroogoPlugin->deactivate($plugin);
     if ($result === true) {
         $this->out(__('Plugin "%s" deactivated successfully.', $plugin));
         return true;
     } elseif (is_string($result)) {
         $this->err($result);
     } else {
         $this->err(__('Plugin "%s" could not be deactivated. Please, try again.', $plugin));
     }
     return false;
 }
Example #8
0
 /**
  * testUsedBy
  */
 public function testUsedBy()
 {
     Cache::delete('pluginDeps', 'cached_settings');
     CroogoPlugin::load('Widgets');
     CroogoPlugin::load('Editors');
     CroogoPlugin::load('Articles');
     CroogoPlugin::cacheDependencies();
     $usedBy = $this->CroogoPlugin->usedBy('Widgets');
     $this->assertTrue(in_array('Articles', $usedBy));
     $this->assertTrue(in_array('Editors', $usedBy));
     CroogoPlugin::unload('Articles');
     CroogoPlugin::unload('Editors');
     CroogoPlugin::unload('Widgets');
 }
Example #9
0
 /**
  * Deactivate plugin
  *
  * @param string $plugin Plugin name
  * @return boolean true when successful, false or error message when failed
  */
 public function deactivate($plugin)
 {
     if (!CakePlugin::loaded($plugin)) {
         return __d('croogo', 'Plugin "%s" is not active.', $plugin);
     }
     $pluginActivation = $this->getActivator($plugin);
     if (!isset($pluginActivation) || isset($pluginActivation) && method_exists($pluginActivation, 'beforeDeactivation') && $pluginActivation->beforeDeactivation($this->_Controller)) {
         $this->removeBootstrap($plugin);
         if (isset($pluginActivation) && method_exists($pluginActivation, 'onDeactivation')) {
             $pluginActivation->onDeactivation($this->_Controller);
         }
         CroogoPlugin::unload($plugin);
         Cache::delete('file_map', '_cake_core_');
         return true;
     } else {
         return __d('croogo', 'Plugin could not be deactivated. Please, try again.');
     }
 }
 public function onActivation(&$controller)
 {
     $CroogoPlugin = new CroogoPlugin();
     $CroogoPlugin->migrate('Webshop');
 }
Example #11
0
 /**
  * List plugins
  */
 public function plugins($plugin = null)
 {
     App::uses('CroogoPlugin', 'Extensions.Lib');
     $all = $this->params['all'];
     $plugins = $plugin == null ? App::objects('plugins') : array($plugin);
     $loaded = CakePlugin::loaded();
     $CroogoPlugin = new CroogoPlugin();
     $this->out(__d('croogo', 'Plugins:'), 2);
     $this->out(__d('croogo', '%-20s%-50s%s', __d('croogo', 'Plugin'), __d('croogo', 'Author'), __d('croogo', 'Status')));
     $this->out(str_repeat('-', 80));
     foreach ($plugins as $plugin) {
         $status = '<info>inactive</info>';
         if ($active = in_array($plugin, $loaded)) {
             $status = '<success>active</success>';
         }
         if (!$active && !$all) {
             continue;
         }
         $data = $CroogoPlugin->getPluginData($plugin);
         $author = isset($data['author']) ? $data['author'] : '';
         $this->out(__d('croogo', '%-20s%-50s%s', $plugin, $author, $status));
     }
 }
Example #12
0
 */
if ($theme = Configure::read('Site.theme')) {
    App::build(array('View/Helper' => array(App::themePath($theme) . 'Helper' . DS)));
}
/**
 * List of core plugins
 */
Configure::write('Core.corePlugins', array('Settings', 'Acl', 'Blocks', 'Comments', 'Contacts', 'Menus', 'Meta', 'Nodes', 'Taxonomy', 'Users'));
/**
 * Plugins
 */
$aclPlugin = Configure::read('Site.acl_plugin');
$pluginBootstraps = Configure::read('Hook.bootstraps');
$plugins = array_filter(explode(',', $pluginBootstraps));
if (!in_array($aclPlugin, $plugins)) {
    $plugins = Hash::merge((array) $aclPlugin, $plugins);
}
foreach ($plugins as $plugin) {
    $pluginName = Inflector::camelize($plugin);
    if (!file_exists(APP . 'Plugin' . DS . $pluginName)) {
        CakeLog::write(LOG_ERR, 'Plugin not found during bootstrap: ' . $pluginName);
        continue;
    }
    $bootstrapFile = APP . 'Plugin' . DS . $pluginName . DS . 'Config' . DS . 'bootstrap.php';
    $bootstrap = file_exists($bootstrapFile);
    $routesFile = APP . 'Plugin' . DS . $pluginName . DS . 'Config' . DS . 'routes.php';
    $routes = file_exists($routesFile);
    $option = array($pluginName => array('bootstrap' => $bootstrap, 'routes' => $routes));
    CroogoPlugin::load($option);
}
CroogoEventManager::loadListeners();
Example #13
0
 /**
  * Called after activating the plugin in ExtensionsPluginsController::admin_toggle()
  *
  * @param object $controller Controller
  * @return void
  */
 public function onActivation(&$controller)
 {
     App::uses('CroogoPlugin', 'Extensions.Lib');
     $CroogoPlugin = new CroogoPlugin();
     $CroogoPlugin->migrate('Switcher');
 }
Example #14
0
 /**
  * onBootstrapComplete
  */
 public function onBootstrapComplete($event)
 {
     CroogoPlugin::cacheDependencies();
 }
Example #15
0
 /**
  * Runs all available pending migrations for core plugins
  */
 public function migrations()
 {
     $CroogoPlugin = new CroogoPlugin();
     foreach ((array) Configure::read('Core.corePlugins') as $plugin) {
         $result = $CroogoPlugin->migrate($plugin);
         if (!$result) {
             $this->out($CroogoPlugin->migrationErrors);
         }
     }
 }
Example #16
0
 public function testUnmigrateNoMapping()
 {
     $actives = Configure::read('Hook.bootstraps');
     Configure::write('Hook.bootstraps', 'Suppliers');
     $migrationVersion = $this->__getMockMigrationVersion();
     $migrationVersion->expects($this->once())->method('getMapping')->will($this->returnValue(array()));
     $migrationVersion->expects($this->never())->method('run')->will($this->returnValue(false));
     $croogoPlugin = new CroogoPlugin($migrationVersion);
     $this->assertEquals(false, $croogoPlugin->unmigrate('Suppliers'));
     Configure::read('Hook.bootstraps', $actives);
 }
Example #17
0
 /**
  * testDeleteEmptyPlugin
  * @expectedException InvalidArgumentException
  */
 public function testDeleteEmptyPlugin()
 {
     $this->CroogoPlugin->delete(null);
 }