Ejemplo n.º 1
0
 /**
  * Find the editor title when provided with editorname
  * 
  * @param array $args
  * @return string 
  */
 public function getEditorTitle($args)
 {
     if (!PluginUtil::isAvailable('moduleplugin.scribite.' . strtolower($args['editorname']))) {
         return '';
     }
     $className = 'ModulePlugin_Scribite_' . $args['editorname'] . '_Plugin';
     $instance = PluginUtil::loadPlugin($className);
     return $instance->getMetaDisplayName();
 }
Ejemplo n.º 2
0
 * information regarding copyright and licensing.
 */
ini_set('mbstring.internal_encoding', 'UTF-8');
ini_set('default_charset', 'UTF-8');
mb_regex_encoding('UTF-8');
ini_set('memory_limit', '64M');
ini_set('max_execution_time', 86400);
include 'lib/bootstrap.php';
ZLoader::addAutoloader('Users', 'system/Users/lib', '_');
include_once __DIR__ . '/plugins/Doctrine/Plugin.php';
// check if the config.php was renewed
if (!isset($GLOBALS['ZConfig']['Log']['log.to_debug_toolbar'])) {
    echo __('It seems to be that your config.php is outdated. Please check the release notes for more information.');
    die;
}
PluginUtil::loadPlugin('SystemPlugin_Doctrine_Plugin');
$eventManager = $core->getEventManager();
$eventManager->attach('core.init', 'upgrade_suppressErrors');
// load zikula core
define('_ZINSTALLVER', Zikula_Core::VERSION_NUM);
define('_Z_MINUPGVER', '1.2.0');
// Signal that upgrade is running.
$GLOBALS['_ZikulaUpgrader'] = array();
// include config file for retrieving name of temporary directory
$GLOBALS['ZConfig']['System']['multilingual'] = true;
$GLOBALS['ZConfig']['System']['Z_CONFIG_USE_OBJECT_ATTRIBUTION'] = false;
$GLOBALS['ZConfig']['System']['Z_CONFIG_USE_OBJECT_LOGGING'] = false;
$GLOBALS['ZConfig']['System']['Z_CONFIG_USE_OBJECT_META'] = false;
// Lazy load DB connection to avoid testing DSNs that are not yet valid (e.g. no DB created yet)
$dbEvent = new Zikula_Event('doctrine.init_connection', null, array('lazy' => true));
$connection = $eventManager->notify($dbEvent)->getData();
Ejemplo n.º 3
0
function installmodules($lang = 'en')
{
    // This is a temporary hack for release 1.3.x to be able to install modules
    // load DoctrineExtensions plugin
    include_once __DIR__ . '/../plugins/DoctrineExtensions/Plugin.php';
    PluginUtil::loadPlugin('SystemPlugin_DoctrineExtensions_Plugin');
    // Lang validation
    $lang = DataUtil::formatForOS($lang);
    // create a result set
    $results = array();
    $sm = ServiceUtil::getManager();
    $coremodules = array('Extensions', 'Settings', 'Theme', 'Admin', 'Permissions', 'Groups', 'Blocks', 'Users');
    // manually install the modules module
    foreach ($coremodules as $coremodule) {
        $modpath = 'system';
        ZLoader::addModule($coremodule, $modpath);
        $bootstrap = __DIR__ . "/../{$modpath}/{$coremodule}/bootstrap.php";
        if (file_exists($bootstrap)) {
            include_once $bootstrap;
        }
        ModUtil::dbInfoLoad($coremodule, $coremodule);
        $className = "{$coremodule}_Installer";
        $instance = new $className($sm);
        if ($instance->install()) {
            $results[$coremodule] = true;
        }
    }
    // regenerate modules list
    $filemodules = ModUtil::apiFunc('ExtensionsModule', 'admin', 'getfilemodules');
    ModUtil::apiFunc('ExtensionsModule', 'admin', 'regenerate', array('filemodules' => $filemodules));
    // set each of the core modules to active
    reset($coremodules);
    foreach ($coremodules as $coremodule) {
        $mid = ModUtil::getIdFromName($coremodule, true);
        ModUtil::apiFunc('ExtensionsModule', 'admin', 'setstate', array('id' => $mid, 'state' => ModUtil::STATE_INACTIVE));
        ModUtil::apiFunc('ExtensionsModule', 'admin', 'setstate', array('id' => $mid, 'state' => ModUtil::STATE_ACTIVE));
    }
    // Add them to the appropriate category
    reset($coremodules);
    $coremodscat = array('Extensions' => __('System'), 'Permissions' => __('Users'), 'Groups' => __('Users'), 'Blocks' => __('Layout'), 'Users' => __('Users'), 'Theme' => __('Layout'), 'Admin' => __('System'), 'Settings' => __('System'));
    $categories = ModUtil::apiFunc('AdminModule', 'admin', 'getall');
    $modscat = array();
    foreach ($categories as $category) {
        $modscat[$category['name']] = $category['cid'];
    }
    foreach ($coremodules as $coremodule) {
        $category = $coremodscat[$coremodule];
        ModUtil::apiFunc('AdminModule', 'admin', 'addmodtocategory', array('module' => $coremodule, 'category' => $modscat[$category]));
    }
    // create the default blocks.
    $blockInstance = new Blocks_Installer($sm);
    $blockInstance->defaultdata();
    // install all the basic modules
    $modules = array(array('module' => 'SecurityCenter', 'category' => __('Security')), array('module' => 'Tour', 'category' => __('Content')), array('module' => 'Categories', 'category' => __('Content')), array('module' => 'Legal', 'category' => __('Content')), array('module' => 'Mailer', 'category' => __('System')), array('module' => 'Errors', 'category' => __('System')), array('module' => 'Theme', 'category' => __('Layout')), array('module' => 'Search', 'category' => __('Content')));
    foreach ($modules as $module) {
        // sanity check - check if module is already installed
        if (ModUtil::available($module['module'])) {
            continue;
        }
        $modpath = 'modules';
        //        ZLoader::addModule($module, $modpath);
        ZLoader::addAutoloader($module, "{$modpath}");
        $bootstrap = __DIR__ . "/../{$modpath}/{$module}/bootstrap.php";
        if (file_exists($bootstrap)) {
            include_once $bootstrap;
        }
        ZLanguage::bindModuleDomain($module);
        $results[$module['module']] = false;
        // #6048 - prevent trying to install modules which are contained in an install type, but are not available physically
        if (!file_exists('system/' . $module['module'] . '/') && !file_exists('modules/' . $module['module'] . '/')) {
            continue;
        }
        $mid = ModUtil::getIdFromName($module['module']);
        // init it
        if (ModUtil::apiFunc('ExtensionsModule', 'admin', 'initialise', array('id' => $mid)) == true) {
            // activate it
            if (ModUtil::apiFunc('ExtensionsModule', 'admin', 'setstate', array('id' => $mid, 'state' => ModUtil::STATE_ACTIVE))) {
                $results[$module['module']] = true;
            }
            // Set category
            ModUtil::apiFunc('AdminModule', 'admin', 'addmodtocategory', array('module' => $module['module'], 'category' => $modscat[$module['category']]));
        }
    }
    System::setVar('language_i18n', $lang);
    return $results;
}
Ejemplo n.º 4
0
    /**
     * Lists all plugins.
     * @return string HTML output string
     */
    public function viewPlugins()
    {
        // Security check
        if (!SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        $state = FormUtil::getPassedValue('state', -1, 'GETPOST');
        $sort = FormUtil::getPassedValue('sort', null, 'GETPOST');
        $module = FormUtil::getPassedValue('bymodule', null, 'GETPOST');
        $systemplugins = FormUtil::getPassedValue('systemplugins', false, 'GETPOST')? true : null;

        $this->view->assign('state', $state);

        // generate an auth key to use in urls
        $csrfToken = SecurityUtil::generateCsrfToken($this->serviceManager, true);
        $plugins = array();
        $pluginClasses = ($systemplugins) ? PluginUtil::loadAllSystemPlugins() : PluginUtil::loadAllModulePlugins();

        foreach ($pluginClasses as $className) {
            $instance = PluginUtil::loadPlugin($className);
            $pluginstate = PluginUtil::getState($instance->getServiceId(), PluginUtil::getDefaultState());

            // Tweak UI if the plugin is AlwaysOn
            if ($instance instanceof Zikula_Plugin_AlwaysOnInterface) {
                $pluginstate['state'] = PluginUtil::ENABLED;
                $pluginstate['version'] = $instance->getMetaVersion();
            }

            // state filer
            if ($state >= 0 && $pluginstate['state'] != $state) {
                continue;
            }

            // module filter
            if (!empty($module) && $instance->getModuleName() != $module) {
                continue;
            }

            $actions = array();
            // Translate state
            switch ($pluginstate['state']) {
                case PluginUtil::NOTINSTALLED:
                    $status = $this->__('Not installed');
                    $statusimage = 'redled.png';

                    $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'initialisePlugin',
                                                    array('plugin' => $className,
                                                          'state'  => $state,
                                                          'bymodule' => $module,
                                                          'sort'   => $sort,
                                                          'systemplugins' => $systemplugins,
                                                          'csrftoken' => $csrfToken)
                                                ),
                                       'image' => 'folder_new.png',
                                       'title' => $this->__('Install'));
                    break;
                case PluginUtil::ENABLED:
                    $status = $this->__('Active');
                    $statusimage = 'greenled.png';
                    $pluginLink = array();
                    if (!$systemplugins) {
                        $pluginLink['_module'] = $instance->getModuleName();
                    }
                    $pluginLink['_plugin'] = $instance->getPluginName();
                    $pluginLink['_action'] = 'configure';

                    if ($instance instanceof Zikula_Plugin_ConfigurableInterface) {
                        $actions[] = array('url' => ModUtil::url('Extensions', 'adminplugin', 'dispatch', $pluginLink),
                                           'image' => 'configure.png',
                                           'title' => $this->__('Configure plugin'));
                    }

                    // Dont allow to disable/uninstall plugins that are AlwaysOn
                    if (!$instance instanceof Zikula_Plugin_AlwaysOnInterface) {
                        $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'deactivatePlugin',
                                                    array('plugin' => $className,
                                                          'state'  => $state,
                                                          'bymodule' => $module,
                                                          'sort'   => $sort,
                                                          'systemplugins' => $systemplugins,
                                                          'csrftoken' => $csrfToken)
                                                ),
                                       'image' => 'folder_red.png',
                                       'title' => $this->__('Deactivate'));

                        $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'removePlugin',
                                                    array('plugin' => $className,
                                                          'state'  => $state,
                                                          'bymodule' => $module,
                                                          'sort'   => $sort,
                                                          'systemplugins' => $systemplugins,
                                                          'csrftoken' => $csrfToken)
                                                ),
                                       'image' => '14_layer_deletelayer.png',
                                       'title' => $this->__('Remove plugin'));
                    }
                    break;
                case PluginUtil::DISABLED:
                    $status = $this->__('Inactive');
                    $statusimage = 'yellowled.png';

                    $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'activatePlugin',
                                                    array('plugin' => $className,
                                                          'state'  => $state,
                                                          'bymodule' => $module,
                                                          'sort'   => $sort,
                                                          'systemplugins' => $systemplugins,
                                                          'csrftoken' => $csrfToken)
                                                ),
                                       'image' => 'folder_green.png',
                                       'title' => $this->__('Activate'));

                    $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'removePlugin',
                                                    array('plugin' => $className,
                                                           'state' => $state,
                                                           'bymodule' => $module,
                                                           'sort'   => $sort,
                                                           'systemplugins' => $systemplugins,
                                                           'csrftoken' => $csrfToken)
                                                ),
                                       'image' => '14_layer_deletelayer.png',
                                       'title' => $this->__('Remove plugin'));

                    break;
            }

            // upgrade ?
            if ($pluginstate['state'] != PluginUtil::NOTINSTALLED
                && $pluginstate['version'] != $instance->getMetaVersion()) {

                $status = $this->__('New version');
                $statusimage = 'redled.png';

                $actions = array();
                $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'upgradePlugin',
                                                array('plugin' => $className,
                                                      'state'  => $state,
                                                      'bymodule' => $module,
                                                      'sort'   => $sort,
                                                      'systemplugins' => $systemplugins,
                                                      'csrftoken' => $csrfToken)
                                            ),
                                       'image' => 'folder_favorites.png',
                                       'title' => $this->__('Upgrade'));

                $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'removePlugin',
                                                array('plugin' => $className,
                                                       'state' => $state,
                                                       'bymodule' => $module,
                                                       'sort'   => $sort,
                                                       'systemplugins' => $systemplugins,
                                                       'csrftoken' => $csrfToken)
                                            ),
                                       'image' => '14_layer_deletelayer.png',
                                       'title' => $this->__('Remove plugin'));
            }

            $info =  array('instance'    => $instance,
                           'status'      => $status,
                           'statusimage' => $statusimage,
                           'actions'     => $actions,
                           'version'     => $pluginstate['state'] == PluginUtil::NOTINSTALLED ?
                                                 $instance->getMetaVersion() : $pluginstate['version']);

            // new version of plugin?
            if ($pluginstate['state'] != PluginUtil::NOTINSTALLED
                && $pluginstate['version'] != $instance->getMetaVersion()) {
                $info['newversion'] = $instance->getMetaVersion();
            }

            $plugins[] = $info;
        }

        // sort plugins array
        if (empty($sort) || $sort == 'module') {
            usort($plugins, array($this, 'viewPluginsSorter_byModule'));
        } elseif ($sort == 'name') {
            usort($plugins, array($this, 'viewPluginsSorter_byName'));
        }

        $this->view->assign('plugins', $plugins)
                   ->assign('module', $module)
                   ->assign('sort', $sort)
                   ->assign('state', $state)
                   ->assign('systemplugins', $systemplugins)
                   ->assign('_type', ($systemplugins) ? 'system' : 'module');

        // Return the output that has been generated by this function
        return $this->view->fetch('extensions_admin_viewPlugins.tpl');
    }