Пример #1
0
 /**
  * display block
  *
  * @param array       $blockinfo     a blockinfo structure
  * @return output      the rendered bock
  */
 public function display($blockinfo)
 {
     // Security check
     if (!SecurityUtil::checkPermission('EZComments:MostCommentsBlock:', "{$blockinfo['bid']}::", ACCESS_READ)) {
         return false;
     }
     if (!ModUtil::load('EZComments')) {
         return false;
     }
     // Get variables from content block
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     // Defaults
     if (!isset($vars['numentries'])) {
         $vars['numentries'] = 5;
     }
     if (!isset($vars['showcount'])) {
         $vars['showcount'] = false;
     }
     $options = array('numitems' => $vars['numentries']);
     if (isset($vars['mod']) && $vars['mod'] != '*') {
         $options['mod'] = $vars['mod'];
     }
     // get the comments
     $items = $this->MostCommentsBlock_getall($options);
     // augment the info
     $comments = ModUtil::apiFunc('EZComments', 'user', 'prepareCommentsForDisplay', $items);
     $this->view->assign($vars);
     $this->view->assign('comments', $comments);
     // Populate block info and pass to theme
     $blockinfo['content'] = $this->view->fetch('ezcomments_block_mostcomments.tpl');
     return BlockUtil::themesideblock($blockinfo);
 }
Пример #2
0
    /**
     * Initialise the IWmenu module creating module tables and module vars
     * @author Albert Perez Monfort (aperezm@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function Install() {
        // Checks if module IWmain is installed. If not returns error
        $modid = ModUtil::getIdFromName('IWmain');
        $modinfo = ModUtil::getInfo($modid);

        if ($modinfo['state'] != 3) {
            return LogUtil::registerError($this->__('Module IWmain is needed. You have to install the IWmain module previously to install it.'));
        }

        // Check if the version needed is correct
        $versionNeeded = '3.0.0';
        if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
            return false;
        }

        // Create module table
        if (!DBUtil::createTable('IWmenu'))
            return false;

        //Create indexes
        $pntable = DBUtil::getTables();
        $c = $pntable['IWmenu_column'];
        if (!DBUtil::createIndex($c['id_parent'], 'IWmenu', 'id_parent'))
            return false;

        //Create module vars
        ModUtil::setVar('IWmenu', 'height', 26); // Default height
        ModUtil::setVar('IWmenu', 'width', 200); // Default width
        ModUtil::setVar('IWmenu', 'imagedir', "menu"); // Default directori of menu images
        // checks if module vhmenu exists. If it exists import module vhmenu tables
        $modid = ModUtil::getIdFromName('IWmenu');
        $modinfo = ModUtil::getInfo($modid);
        if ($modinfo['state'] == 3) {
            // get the objects from the db
            ModUtil::load('IWvhmenu', 'user');
            $items = DBUtil::selectObjectArray('IWvhmenu');
            if ($items) {
                foreach ($items as $item) {
                    $groups = str_replace('|0', '', $item['groups']);
                    $groups = substr($groups, 1, strlen($groups));
                    $itemArray = array('text' => $item['text'],
                        'url' => $item['url'],
                        'icon' => '',
                        'id_parent' => $item['id_parent'],
                        'groups' => $groups,
                        'active' => $item['active'],
                        'target' => $item['target'],
                        'descriu' => $item['descriu']);

                    DBUtil::insertObject($itemArray, 'IWmenu', 'mid');
                }
            }
        }
        return true;
    }
Пример #3
0
 public function __construct(Zikula_ServiceManager $serviceManager, \Zikula\Core\AbstractModule $bundle = null)
 {
     parent::__construct($serviceManager, $bundle);
     if ($bundle !== null) {
         // Get bundle from route.
         $module = $bundle->getName();
         // Load module.
         \ModUtil::load($module);
         // Set legacy to true, as the Controller's response will not have the theme around it otherwise.
         // See Zikula\Bundle\CoreBundle\EventListener\ThemeListener::onKernelResponse() - The only place it is used.
         $request = $serviceManager->get("request");
         $request->attributes->set('_legacy', true);
     }
 }
Пример #4
0
 /**
  * display block
  *
  * @param array       $blockinfo     a blockinfo structure
  * @return output      the rendered bock
  */
 public function display($blockinfo)
 {
     // Security check
     if (!SecurityUtil::checkPermission('EZComments:EZCommentsblock:', "{$blockinfo['bid']}::", ACCESS_READ)) {
         return false;
     }
     if (!ModUtil::load('EZComments')) {
         return false;
     }
     // Get variables from content block
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     // Defaults
     if (!isset($vars['numentries'])) {
         $vars['numentries'] = 5;
     }
     if (!isset($vars['numdays'])) {
         $vars['numdays'] = 0;
     }
     if (!isset($vars['showdate'])) {
         $vars['showdate'] = 0;
     }
     if (!isset($vars['showusername'])) {
         $vars['showusername'] = 0;
     }
     if (!isset($vars['linkusername'])) {
         $vars['linkusername'] = 0;
     }
     $options = array('numitems' => $vars['numentries']);
     if (isset($vars['mod']) && $vars['mod'] != '*') {
         $options['mod'] = $vars['mod'];
     }
     if (!isset($vars['showpending']) || $vars['showpending'] == 0) {
         // don't show pending comments
         $options['status'] = 0;
     }
     // filter comments posted in last number of days
     if ($vars['numdays'] > 0) {
         // date for filtering in format: yyyy-mm-dd hh:mm:ss
         $options['addwhere'] = "date>='" . DateUtil::getDatetime_NextDay(-$vars['numdays']) . "'";
     }
     // get the comments
     $items = ModUtil::apiFunc('EZComments', 'user', 'getall', $options);
     // augment the info
     $comments = ModUtil::apiFunc('EZComments', 'user', 'prepareCommentsForDisplay', $items);
     $this->view->assign($vars);
     $this->view->assign('comments', $comments);
     // Populate block info and pass to theme
     $blockinfo['content'] = $this->view->fetch('ezcomments_block_ezcomments.tpl');
     return BlockUtil::themesideblock($blockinfo);
 }
Пример #5
0
    /**
     * Load a block.
     *
     * @param string $modname Module name.
     * @param string $block   Name of the block.
     *
     * @throws LogicException Uf OO-Block is not a Zikula_Controller_AbstractBlock object.
     * @return bool True on successful load, false otherwise.
     */
    public static function load($modname, $block)
    {
        $sm = ServiceUtil::getManager();
        $modinfo = ModUtil::getInfoFromName($modname);

        $serviceId = strtolower('block.' . $modinfo['name'] . '_' . 'Block_' . $block);
        if ($sm->hasService($serviceId)) {
            return $sm->getService($serviceId);
        }

        if ($modinfo['type'] == ModUtil::TYPE_MODULE) {
            ZLanguage::bindModuleDomain($modinfo['name']);
        }

        $basedir = ($modinfo['type'] == ModUtil::TYPE_SYSTEM) ? 'system' : 'modules';
        $moddir = DataUtil::formatForOS($modinfo['directory']);
        $blockdir = "$basedir/$moddir/lib/$moddir/Block";
        $ooblock = "$blockdir/" . ucwords($block) . '.php';
        ModUtil::load($modname);
        $isOO = ModUtil::isOO($modname);

        if (!$isOO) {
            $blockdirOld = $moddir . '/pnblocks';
            $incfile = DataUtil::formatForOS($block . '.php');

            if (file_exists("$basedir/$blockdirOld/$incfile")) {
                include_once "$basedir/$blockdirOld/$incfile";
            } else {
                return false;
            }
        }

        // get the block info
        if ($isOO) {
            $className = ucwords($modinfo['name']) . '_' . 'Block_' . ucwords($block);
            $r = new ReflectionClass($className);
            $blockInstance = $r->newInstanceArgs(array($sm));
            try {
                if (!$blockInstance instanceof Zikula_Controller_AbstractBlock) {
                    throw new LogicException(sprintf('Block %s must inherit from Zikula_Controller_AbstractBlock', $className));
                }
            } catch (LogicException $e) {
                if (System::isDevelopmentMode()) {
                    throw $e;
                } else {
                    LogUtil::registerError('A fatal error has occured which can be viewed only in development mode.', 500);
                    return false;
                }
            }

            $sm->attachService($serviceId, $blockInstance);
        }

        $result = ($isOO ? $blockInstance : true);

        if ($isOO) {
            $blocks_modules[$block] = call_user_func(array($blockInstance, 'info'));
        } else {
            $infofunc = "{$modname}_{$block}block_info";
            $blocks_modules[$block] = $infofunc();
        }

        // set the module and keys for the new block
        $blocks_modules[$block]['bkey'] = $block;
        $blocks_modules[$block]['module'] = $modname;
        $blocks_modules[$block]['mid'] = ModUtil::getIdFromName($modname);

        // merge the blockinfo in the global list of blocks
        if (!isset($GLOBALS['blocks_modules'])) {
            $GLOBALS['blocks_modules'] = array();
        }
        $GLOBALS['blocks_modules'][$blocks_modules[$block]['mid']][$block] = $blocks_modules[$block];

        // Initialise block if required (new-style)
        if ($isOO) {
            call_user_func(array($blockInstance, 'init'));
        } else {
            $initfunc = "{$modname}_{$block}block_init";
            $initfunc();
        }

        // add stylesheet to the page vars, this makes manual loading obsolete
        PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet($modname));

        return $result;
    }
Пример #6
0
 /**
  * Load a block.
  *
  * @param string $modname Module name.
  * @param string $block   Name of the block.
  *
  * @throws LogicException Uf OO-Block is not a Zikula_Controller_AbstractBlock object.
  * @return bool           True on successful load, false otherwise.
  */
 public static function load($modname, $block)
 {
     $sm = ServiceUtil::getManager();
     $modinfo = ModUtil::getInfoFromName($modname);
     if ($modinfo['state'] != \ModUtil::STATE_ACTIVE) {
         return false;
     }
     $serviceId = strtolower('block.' . $modinfo['name'] . '_' . 'Block_' . $block);
     if ($sm->has($serviceId)) {
         return $sm->get($serviceId);
     }
     if ($modinfo['type'] == ModUtil::TYPE_MODULE) {
         ZLanguage::bindModuleDomain($modinfo['name']);
     }
     $basedir = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules';
     $moddir = DataUtil::formatForOS($modinfo['directory']);
     $blockdir = "{$basedir}/{$moddir}/lib/{$moddir}/Block";
     $ooblock = "{$blockdir}/" . ucwords($block) . '.php';
     ModUtil::load($modname);
     // get the block info
     $kernel = $sm->get('kernel');
     $module = null;
     try {
         /** @var $module \Zikula\Core\AbstractModule */
         $module = $kernel->getModule($modinfo['name']);
         $className = $module->getNamespace() . '\\Block\\' . ucwords($block);
         $className = preg_match('/.*Block$/', $className) ? $className : $className . 'Block';
     } catch (\InvalidArgumentException $e) {
     }
     if (!isset($className)) {
         $className = ucwords($modinfo['name']) . '\\' . 'Block\\' . ucwords($block);
         $className = preg_match('/.*Block$/', $className) ? $className : $className . 'Block';
         $classNameOld = ucwords($modinfo['name']) . '_' . 'Block_' . ucwords($block);
         $className = class_exists($className) ? $className : $classNameOld;
     }
     $r = new ReflectionClass($className);
     $instanceArgs = array();
     if (is_subclass_of($className, 'Zikula_Controller_AbstractBlock')) {
         $instanceArgs = array($sm, $module);
     } elseif (is_subclass_of($className, 'Zikula\\Core\\Controller\\AbstractBlockController')) {
         $instanceArgs = array($module);
     }
     $blockInstance = $r->newInstanceArgs($instanceArgs);
     if (!$blockInstance instanceof Zikula_Controller_AbstractBlock && !$blockInstance instanceof AbstractBlockController) {
         throw new LogicException(sprintf('Block %s must inherit from Zikula_Controller_AbstractBlock or Zikula\\Core\\Controller\\AbstractBlockController', $className));
     }
     $sm->set($serviceId, $blockInstance);
     if ($blockInstance instanceof \Symfony\Component\DependencyInjection\ContainerAwareInterface) {
         $blockInstance->setContainer($sm);
     }
     $result = $blockInstance;
     $blocks_modules[$block] = call_user_func(array($blockInstance, 'info'));
     // set the module and keys for the new block
     $blocks_modules[$block]['bkey'] = $block;
     $blocks_modules[$block]['module'] = $modname;
     $blocks_modules[$block]['mid'] = ModUtil::getIdFromName($modname);
     // merge the blockinfo in the global list of blocks
     if (!isset($GLOBALS['blocks_modules'])) {
         $GLOBALS['blocks_modules'] = array();
     }
     $GLOBALS['blocks_modules'][$blocks_modules[$block]['mid']][$block] = $blocks_modules[$block];
     // Initialise block if required (new-style)
     call_user_func(array($blockInstance, 'init'));
     // add stylesheet to the page vars, this makes manual loading obsolete
     PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet($modname));
     return $result;
 }
Пример #7
0
<?php

//1. Init zikula engine
$time = time();
include 'lib/bootstrap.php';
$core->init();
ModUtil::load('IWmain', 'admin');
$langcode = ModUtil::getVar('ZConfig', 'language_i18n');
ZLanguage::setLocale($langcode);
ZLanguage::bindCoreDomain();
$dom = ZLanguage::getModuleDomain('IWmain');

//2. Checking cron password
$passwordActive = ModUtil::getVar('IWmain','cronPasswordActive');
if ($passwordActive) {
    $passwordString = ModUtil::getVar('IWmain','cronPasswordString');
    $passwordSended = FormUtil::getPassedValue('password',null,'GET');
    if ($passwordString !== $passwordSended) {
        print __("You can't execute iwcron", $dom);
        cronShutdown();

    }
}

//3. Cron actions
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$lastCronSuccessfull = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => -100,
            'name' => 'lastCronSuccessfull',
            'module' => 'IWmain_cron',
            'sv' => $sv));
$dateTimeFrom = (int)$lastCronSuccessfull;
Пример #8
0
 public function ajaxDispatch(Request $request)
 {
     $module = $request->attributes->get('_module');
     $type = $request->attributes->get('_controller');
     $func = $request->attributes->get('_action');
     if (empty($func)) {
         $response = new NotFoundResponse(__f("Missing parameter '%s'", 'func'));
     }
     // get module information
     $modinfo = \ModUtil::getInfoFromName($module);
     if ($modinfo == false) {
         $response = new NotFoundResponse(__f("Error! The '%s' module is unknown.", \DataUtil::formatForDisplay($module)));
     }
     if (!\ModUtil::available($modinfo['name'])) {
         $response = new NotFoundResponse(__f("Error! The '%s' module is not available.", \DataUtil::formatForDisplay($module)));
     }
     if (!\ModUtil::load($modinfo['name'], $type)) {
         $response = new NotFoundResponse(__f("Error! The '%s' module is not available.", \DataUtil::formatForDisplay($module)));
     }
     // Dispatch controller.
     try {
         $response = \ModUtil::func($modinfo['name'], $type, $func);
     } catch (NotFoundException $e) {
         $response = new NotFoundResponse($e->getMessage());
     } catch (ForbiddenException $e) {
         $response = new ForbiddenResponse($e->getMessage());
     } catch (FatalException $e) {
         $response = new FatalResponse($e->getMessage());
     } catch (\PDOException $e) {
         $response = new FatalResponse($e->getMessage());
     } catch (\Exception $e) {
         $response = new FatalResponse($e->getMessage());
     }
     // Issue response.
     return $response;
 }
Пример #9
0
        UserUtil::logout();
    }
    die(new Zikula_Response_Ajax_Unavailable(__('The site is currently off-line.')));
}
if (empty($func)) {
    die(new Zikula_Response_Ajax_NotFound(__f("Missing parameter '%s'", 'func')));
}
// get module information
$modinfo = ModUtil::getInfoFromName($module);
if ($modinfo == false) {
    die(new Zikula_Response_Ajax_NotFound(__f("Error! The '%s' module is unknown.", DataUtil::formatForDisplay($module))));
}
if (!ModUtil::available($modinfo['name'])) {
    die(new Zikula_Response_Ajax_NotFound(__f("Error! The '%s' module is not available.", DataUtil::formatForDisplay($module))));
}
if (!ModUtil::load($modinfo['name'], $type)) {
    die(new Zikula_Response_Ajax_NotFound(__f("Error! The '%s' module is not available.", DataUtil::formatForDisplay($module))));
}
// Handle database transactions
if (System::getVar('Z_CONFIG_USE_TRANSACTIONS')) {
    $dbConn = Doctrine_Manager::getInstance()->getCurrentConnection();
    $dbConn->beginTransaction();
}
// Dispatch controller.
try {
    $response = ModUtil::func($modinfo['name'], $type, $func);
    if (System::isLegacyMode() && $response == false && LogUtil::hasErrors()) {
        throw new Zikula_Exception_Fatal(__('An unknown error occurred in module %s, controller %s, action %s', array($modinfo['name'], $type, $func)));
    }
} catch (Zikula_Exception_NotFound $e) {
    $response = new Zikula_Response_Ajax_NotFound($e->getMessage());
Пример #10
0
    }
    $l_online_users = sprintf($l_t_user_s, $total_online_users);
    $l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
    $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
    $l_online_users .= sprintf($l_g_user_s, $guests_online);
}
//
// Obtain number of new private messages
// if user is logged in
//
if ($userdata['session_logged_in'] && empty($gen_simple_header)) {
    // Begin PNphpBB2 Module
    if ($board_config['pnphpbb2_pn_pm']) {
        if (ModUtil::available('InterCom')) {
            // ZphpBB2
            ModUtil::load('InterCom');
            $info = ModUtil::apiFunc('InterCom', 'user', 'getmessagecount');
            $unread = $info['unread'];
        } else {
            /* Standard Messages module */
            $column =& $pntable['priv_msgs_column'];
            $sql = "SELECT count(*) FROM {$pntable['priv_msgs']} WHERE {$column['read_msg']} ='0' and {$column['to_userid']}=" . $userdata['user_id'];
            if ($result = $db->sql_query($sql)) {
                list($unread) = $db->sql_fetchrow($result);
            }
        }
        $s_privmsg_new = 0;
        $icon_pm = $images['pm_new_msg'];
        if ($unread > 0) {
            $l_message_unread = $unread == 1 ? $lang['Unread_pm'] : $lang['Unread_pms'];
            $l_privmsgs_text_unread = sprintf($l_message_unread, $unread);
Пример #11
0
/**
 * Loads a module.
 *
 * @deprecated
 * @see ModUtil::load()
 *
 * @param string  $modname The name of the module.
 * @param string  $type    The type of functions to load.
 * @param boolean $force   Determines to load Module even if module isn't active.
 *
 * @return string|boolean Name of module loaded, or false on failure.
 */
function pnModLoad($modname, $type = 'user', $force = false)
{
    LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'ModUtil::load()')), E_USER_DEPRECATED);
    return ModUtil::load($modname, $type, $force);
}
Пример #12
0
 /**
  * Load a block.
  *
  * @param string $modname Module name.
  * @param string $block   Name of the block.
  *
  * @throws LogicException Uf OO-Block is not a Zikula_Controller_AbstractBlock object.
  * @return bool           True on successful load, false otherwise.
  */
 public static function load($modname, $block)
 {
     $sm = ServiceUtil::getManager();
     $modinfo = ModUtil::getInfoFromName($modname);
     $serviceId = strtolower('block.' . $modinfo['name'] . '\\Block\\' . $block . 'Block');
     if ($sm->has($serviceId)) {
         return $sm->get($serviceId);
     }
     if ($modinfo['type'] == ModUtil::TYPE_MODULE) {
         ZLanguage::bindModuleDomain($modinfo['name']);
     }
     ModUtil::load($modname);
     // get the block info
     $className = ucwords($modinfo['name']) . '\\Block\\' . ucwords($block) . 'Block';
     $r = new ReflectionClass($className);
     $blockInstance = $r->newInstanceArgs(array($sm));
     $sm->set($serviceId, $blockInstance);
     $result = $blockInstance;
     $blocks_modules[$block] = call_user_func(array($blockInstance, 'info'));
     // set the module and keys for the new block
     $blocks_modules[$block]['bkey'] = $block;
     $blocks_modules[$block]['module'] = $modname;
     $blocks_modules[$block]['mid'] = ModUtil::getIdFromName($modname);
     // merge the blockinfo in the global list of blocks
     if (!isset($GLOBALS['blocks_modules'])) {
         $GLOBALS['blocks_modules'] = array();
     }
     $GLOBALS['blocks_modules'][$blocks_modules[$block]['mid']][$block] = $blocks_modules[$block];
     // Initialise block if required (new-style)
     call_user_func(array($blockInstance, 'init'));
     // add stylesheet to the page vars, this makes manual loading obsolete
     PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet($modname));
     return $result;
 }
Пример #13
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer $stage Stage to load.
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function onInit(GetResponseEvent $event)
 {
     if ($event->getRequestType() === HttpKernelInterface::SUB_REQUEST) {
         return;
     }
     $this->dispatcher = $event->getDispatcher();
     $this->stage = $stage = self::STAGE_ALL;
     $coreInitEvent = new GenericEvent($this);
     $coreInitEvent['request'] = $event->getRequest();
     // store the load stages in a global so other API's can check whats loaded
     $this->dispatcher->dispatch(CoreEvents::PREINIT, new GenericEvent($this));
     //        // Initialise and load configuration
     //        if ($stage & self::STAGE_CONFIG) {
     //            // error reporting
     //            if (!\System::isInstalling()) {
     //                // this is here because it depends on the config.php loading.
     //                $event = new GenericEvent(null, array('stage' => $stage));
     //                $this->dispatcher->dispatch(CoreEvents::ERRORREPORTING, $event);
     //            }
     //
     //            // initialise custom event listeners from config.php settings
     //            $coreInitEvent->setArg('stage', self::STAGE_CONFIG);
     //            $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     //        }
     //        // Check that Zikula is installed before continuing
     //        if (\System::getVar('installed') == 0 && !\System::isInstalling()) {
     //            $response = new RedirectResponse(\System::getBaseUrl().'install.php?notinstalled');
     //            $response->send();
     //            \System::shutdown();
     //        }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new GenericEvent();
             $this->dispatcher->dispatch('doctrine.init_connection', $dbEvent);
             $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
             $this->dispatcher->dispatch(CoreEvents::INIT, $dbEvent);
         } catch (\PDOException $e) {
             if (!\System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once \System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 \System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         \ModUtil::initCoreVars();
         \ModUtil::dbInfoLoad('SettingsModule', 'SettingsModule');
         \ModUtil::dbInfoLoad('ThemeModule', 'ThemeModule');
         \ModUtil::dbInfoLoad('UsersModule', 'UsersModule');
         \ModUtil::dbInfoLoad('GroupsModule', 'GroupsModule');
         \ModUtil::dbInfoLoad('PermissionsModule', 'PermissionsModule');
         \ModUtil::dbInfoLoad('CategoriesModule', 'CategoriesModule');
         if (!\System::isInstalling()) {
             \ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArg('stage', self::STAGE_TABLES);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         \SessionUtil::requireSession();
         $coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = \ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         \System::queryStringDecode();
         $coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup();
         $coreInitEvent->setArg('stage', self::STAGE_LANGS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         // Set compression on if desired
         if (\System::getVar('UseCompression') == 1) {
             //ob_start("ob_gzhandler");
         }
         \ModUtil::load('SecurityCenter');
         $coreInitEvent->setArg('stage', self::STAGE_MODS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         \PageUtil::registerVar('title');
         \PageUtil::setVar('title', \System::getVar('defaultpagetitle'));
         \PageUtil::registerVar('keywords', true);
         \PageUtil::registerVar('stylesheet', true);
         \PageUtil::registerVar('javascript', true);
         \PageUtil::registerVar('jsgettext', true);
         \PageUtil::registerVar('body', true);
         \PageUtil::registerVar('header', true);
         \PageUtil::registerVar('footer', true);
         $theme = \Zikula_View_Theme::getInstance();
         // set some defaults
         // Metadata for SEO
         $this->container['zikula_view.metatags']['description'] = \System::getVar('defaultmetadescription');
         $this->container['zikula_view.metatags']['keywords'] = \System::getVar('metakeywords');
         $coreInitEvent->setArg('stage', self::STAGE_THEME);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (\UserUtil::isLoggedIn()) {
         $userstatus = \UserUtil::getVar('activated');
         if ($userstatus != UsersConstant::ACTIVATED_ACTIVE) {
             \UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             \LogUtil::registerStatus(__('You have been logged out.'));
             $response = new RedirectResponse(\ModUtil::url('Users', 'user', 'login'));
             $response->send();
             exit;
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->dispatcher->dispatch(CoreEvents::POSTINIT, new GenericEvent($this, array('stages' => $stage)));
     }
     $this->dispatcher->dispatch('frontcontroller.predispatch', new GenericEvent());
 }
Пример #14
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer             $stage Stage to load.
  * @param Zikula_Request_Http $request
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function init($stage = self::STAGE_ALL, Request $request)
 {
     $GLOBALS['__request'] = $request;
     // hack for pre 1.5.0 - drak
     $coreInitEvent = new GenericEvent($this);
     // store the load stages in a global so other API's can check whats loaded
     $this->stage = $this->stage | $stage;
     if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
         ModUtil::flushCache();
         System::flushCache();
         $args = !System::isInstalling() ? array('lazy' => true) : array();
         $this->dispatcher->dispatch('core.preinit', new GenericEvent($this, $args));
     }
     // Initialise and load configuration
     if ($stage & self::STAGE_CONFIG) {
         // for BC only. remove this code in 2.0.0
         if (!System::isInstalling()) {
             $this->dispatcher->dispatch('setup.errorreporting', new GenericEvent(null, array('stage' => $stage)));
         }
         // initialise custom event listeners from config.php settings
         $coreInitEvent->setArgument('stage', self::STAGE_CONFIG);
         /***************************************************
          * NOTE: this event is monitored by
          * \Zikula\Bundle\CoreInstallerBundle\EventListener\InstallUpgradeCheckListener
          * to see if install or upgrade is needed
          ***************************************************/
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
             $this->dispatcher->dispatch('core.init', $dbEvent);
         } catch (PDOException $e) {
             if (!System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         ModUtil::dbInfoLoad('ZikulaExtensionsModule', 'ZikulaExtensionsModule');
         ModUtil::initCoreVars();
         ModUtil::dbInfoLoad('ZikulaSettingsModule', 'ZikulaSettingsModule');
         ModUtil::dbInfoLoad('ZikulaThemeModule', 'ZikulaThemeModule');
         ModUtil::dbInfoLoad('ZikulaUsersModule', 'ZikulaUsersModule');
         ModUtil::dbInfoLoad('ZikulaGroupsModule', 'ZikulaGroupsModule');
         ModUtil::dbInfoLoad('ZikulaPermissionsModule', 'ZikulaPermissionsModule');
         ModUtil::dbInfoLoad('ZikulaCategoriesModule', 'ZikulaCategoriesModule');
         // Add AutoLoading for non-symfony 1.3 modules in /modules
         if (!System::isInstalling()) {
             ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArgument('stage', self::STAGE_TABLES);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         //            SessionUtil::requireSession();
         $coreInitEvent->setArgument('stage', self::STAGE_SESSIONS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         System::queryStringDecode($request);
         $coreInitEvent->setArgument('stage', self::STAGE_DECODEURLS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup($request);
         $coreInitEvent->setArgument('stage', self::STAGE_LANGS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         if (!System::isInstalling()) {
             ModUtil::load('ZikulaSecurityCenterModule');
         }
         $coreInitEvent->setArgument('stage', self::STAGE_MODS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         PageUtil::registerVar('polyfill_features', true);
         PageUtil::registerVar('title');
         PageUtil::setVar('title', System::getVar('defaultpagetitle'));
         PageUtil::registerVar('keywords', true);
         PageUtil::registerVar('stylesheet', true);
         PageUtil::registerVar('javascript', true);
         PageUtil::registerVar('jsgettext', true);
         PageUtil::registerVar('body', true);
         PageUtil::registerVar('header', true);
         PageUtil::registerVar('footer', true);
         // set some defaults
         // Metadata for SEO
         $this->container->setParameter('zikula_view.metatags', array('description' => System::getVar('defaultmetadescription'), 'keywords' => System::getVar('metakeywords')));
         $coreInitEvent->setArgument('stage', self::STAGE_THEME);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (!System::isInstalling() && UserUtil::isLoggedIn()) {
         $userstatus = UserUtil::getVar('activated');
         if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) {
             UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             LogUtil::registerStatus(__('You have been logged out.'));
             System::redirect(ModUtil::url('ZikulaUsersModule', 'user', 'login'));
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->dispatcher->dispatch('core.postinit', new GenericEvent($this, array('stages' => $stage)));
     }
 }
Пример #15
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer $stage Stage to load.
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function init($stage = self::STAGE_ALL)
 {
     $coreInitEvent = new Zikula_Event('core.init', $this);
     // store the load stages in a global so other API's can check whats loaded
     $this->stage = $this->stage | $stage;
     if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
         ModUtil::flushCache();
         System::flushCache();
         $this->eventManager->notify(new Zikula_Event('core.preinit', $this));
     }
     // Initialise and load configuration
     if ($stage & self::STAGE_CONFIG) {
         if (System::isLegacyMode()) {
             require_once 'lib/legacy/Compat.php';
         }
         // error reporting
         if (!System::isInstalling()) {
             // this is here because it depends on the config.php loading.
             $event = new Zikula_Event('setup.errorreporting', null, array('stage' => $stage));
             $this->eventManager->notify($event);
         }
         // initialise custom event listeners from config.php settings
         $coreInitEvent->setArg('stage', self::STAGE_CONFIG);
         $this->eventManager->notify($coreInitEvent);
     }
     // Check that Zikula is installed before continuing
     if (System::getVar('installed') == 0 && !System::isInstalling()) {
         System::redirect(System::getBaseUrl() . 'install.php?notinstalled');
         System::shutDown();
     }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new Zikula_Event('core.init', $this, array('stage' => self::STAGE_DB));
             $this->eventManager->notify($dbEvent);
         } catch (PDOException $e) {
             if (!System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         ModUtil::dbInfoLoad('Extensions', 'Extensions');
         ModUtil::initCoreVars();
         ModUtil::dbInfoLoad('Settings', 'Settings');
         ModUtil::dbInfoLoad('Theme', 'Theme');
         ModUtil::dbInfoLoad('Users', 'Users');
         ModUtil::dbInfoLoad('Groups', 'Groups');
         ModUtil::dbInfoLoad('Permissions', 'Permissions');
         ModUtil::dbInfoLoad('Categories', 'Categories');
         if (!System::isInstalling()) {
             ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArg('stage', self::STAGE_TABLES);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         SessionUtil::requireSession();
         $coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
         $this->eventManager->notify($coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         System::queryStringDecode();
         $coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup();
         $coreInitEvent->setArg('stage', self::STAGE_LANGS);
         $this->eventManager->notify($coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         // Set compression on if desired
         if (System::getVar('UseCompression') == 1) {
             //ob_start("ob_gzhandler");
         }
         ModUtil::load('SecurityCenter');
         $coreInitEvent->setArg('stage', self::STAGE_MODS);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         PageUtil::registerVar('title');
         PageUtil::setVar('title', System::getVar('defaultpagetitle'));
         PageUtil::registerVar('keywords', true);
         PageUtil::registerVar('stylesheet', true);
         PageUtil::registerVar('javascript', true);
         PageUtil::registerVar('jsgettext', true);
         PageUtil::registerVar('body', true);
         PageUtil::registerVar('header', true);
         PageUtil::registerVar('footer', true);
         $theme = Zikula_View_Theme::getInstance();
         // set some defaults
         // Metadata for SEO
         $this->serviceManager['zikula_view.metatags']['description'] = System::getVar('defaultmetadescription');
         $this->serviceManager['zikula_view.metatags']['keywords'] = System::getVar('metakeywords');
         $coreInitEvent->setArg('stage', self::STAGE_THEME);
         $this->eventManager->notify($coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (UserUtil::isLoggedIn()) {
         $userstatus = UserUtil::getVar('activated');
         if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) {
             UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             LogUtil::registerStatus(__('You have been logged out.'));
             System::redirect(ModUtil::url('Users', 'user', 'login'));
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->eventManager->notify(new Zikula_Event('core.postinit', $this, array('stages' => $stage)));
     }
 }
Пример #16
0
            $arguments[$argument[0]] = $argument[1];
        }
    }
}
// get module information
$modinfo = ModUtil::getInfoFromName($module);
// we need to force the mod load if we want to call a modules interactive init
// function because the modules is not active right now
if ($modinfo) {
    $module = $modinfo['url'];
    if (System::isLegacyMode()) {
        $type = empty($type) ? $type = 'user' : $type;
        $func = empty($func) ? $func = 'main' : $func;
    }
    if ($type == 'init' || $type == 'interactiveinstaller') {
        ModUtil::load($modinfo['name'], $type, true);
    }
}
$httpCode = 404;
$message = '';
$debug = null;
$return = false;
$e = null;
if (System::getVar('Z_CONFIG_USE_TRANSACTIONS')) {
    $dbConn = Doctrine_Manager::getInstance()->getCurrentConnection();
    $dbConn->beginTransaction();
}
try {
    if (empty($module)) {
        // we have a static homepage
        $return = ' ';
Пример #17
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer             $stage Stage to load.
  * @param Zikula_Request_Http $request
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function init($stage = self::STAGE_ALL, Request $request)
 {
     $GLOBALS['__request'] = $request;
     // hack for pre 1.5.0 - drak
     $coreInitEvent = new GenericEvent($this);
     // store the load stages in a global so other API's can check whats loaded
     $this->stage = $this->stage | $stage;
     if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
         ModUtil::flushCache();
         System::flushCache();
         $args = !System::isInstalling() ? array('lazy' => true) : array();
         $this->dispatcher->dispatch('core.preinit', new GenericEvent($this, $args));
     }
     // Initialise and load configuration
     if ($stage & self::STAGE_CONFIG) {
         // for BC only. remove this code in 2.0.0
         if (!System::isInstalling()) {
             $this->dispatcher->dispatch('setup.errorreporting', new GenericEvent(null, array('stage' => $stage)));
         }
         // initialise custom event listeners from config.php settings
         $coreInitEvent->setArgument('stage', self::STAGE_CONFIG);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // create several booleans to test condition of request regrading install/upgrade
     $installed = $this->getContainer()->getParameter('installed');
     if ($installed) {
         self::defineCurrentInstalledCoreVersion($this->getContainer());
     }
     $requiresUpgrade = $installed && version_compare(ZIKULACORE_CURRENT_INSTALLED_VERSION, self::VERSION_NUM, '<');
     // can't use $request->get('_route') to get any of the following
     // all these routes are hard-coded in xml files
     $uriContainsInstall = strpos($request->getRequestUri(), '/install') !== false;
     $uriContainsUpgrade = strpos($request->getRequestUri(), '/upgrade') !== false;
     $uriContainsDoc = strpos($request->getRequestUri(), '/installdoc') !== false;
     $uriContainsWdt = strpos($request->getRequestUri(), '/_wdt') !== false;
     $uriContainsProfiler = strpos($request->getRequestUri(), '/_profiler') !== false;
     $uriContainsRouter = strpos($request->getRequestUri(), '/js/routing?callback=fos.Router.setData') !== false;
     $doNotRedirect = $uriContainsProfiler || $uriContainsWdt || $uriContainsRouter || $request->isXmlHttpRequest();
     // check if Zikula Core is not installed
     if (!$installed && !$uriContainsDoc && !$uriContainsInstall && !$doNotRedirect) {
         $this->container->get('router')->getContext()->setBaseUrl($request->getBasePath());
         // compensate for sub-directory installs
         $url = $this->container->get('router')->generate('install');
         $response = new RedirectResponse($url);
         $response->send();
         System::shutDown();
     }
     // check if Zikula Core requires upgrade
     if ($requiresUpgrade && !$uriContainsDoc && !$uriContainsUpgrade && !$doNotRedirect) {
         $this->container->get('router')->getContext()->setBaseUrl($request->getBasePath());
         // compensate for sub-directory installs
         $url = $this->container->get('router')->generate('upgrade');
         $response = new RedirectResponse($url);
         $response->send();
         System::shutDown();
     }
     if (!$installed || $requiresUpgrade || $this->getContainer()->hasParameter('upgrading')) {
         System::setInstalling(true);
     }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
             $this->dispatcher->dispatch('core.init', $dbEvent);
         } catch (PDOException $e) {
             if (!System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         ModUtil::dbInfoLoad('ZikulaExtensionsModule', 'ZikulaExtensionsModule');
         ModUtil::initCoreVars();
         ModUtil::dbInfoLoad('ZikulaSettingsModule', 'ZikulaSettingsModule');
         ModUtil::dbInfoLoad('ZikulaThemeModule', 'ZikulaThemeModule');
         ModUtil::dbInfoLoad('ZikulaUsersModule', 'ZikulaUsersModule');
         ModUtil::dbInfoLoad('ZikulaGroupsModule', 'ZikulaGroupsModule');
         ModUtil::dbInfoLoad('ZikulaPermissionsModule', 'ZikulaPermissionsModule');
         ModUtil::dbInfoLoad('ZikulaCategoriesModule', 'ZikulaCategoriesModule');
         // Add AutoLoading for non-symfony 1.3 modules in /modules
         if (!System::isInstalling()) {
             ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArgument('stage', self::STAGE_TABLES);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         //            SessionUtil::requireSession();
         $coreInitEvent->setArgument('stage', self::STAGE_SESSIONS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         System::queryStringDecode($request);
         $coreInitEvent->setArgument('stage', self::STAGE_DECODEURLS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup($request);
         $coreInitEvent->setArgument('stage', self::STAGE_LANGS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         if (!System::isInstalling()) {
             ModUtil::load('ZikulaSecurityCenterModule');
         }
         $coreInitEvent->setArgument('stage', self::STAGE_MODS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         PageUtil::registerVar('polyfill_features', true);
         PageUtil::registerVar('title');
         PageUtil::setVar('title', System::getVar('defaultpagetitle'));
         PageUtil::registerVar('keywords', true);
         PageUtil::registerVar('stylesheet', true);
         PageUtil::registerVar('javascript', true);
         PageUtil::registerVar('jsgettext', true);
         PageUtil::registerVar('body', true);
         PageUtil::registerVar('header', true);
         PageUtil::registerVar('footer', true);
         // set some defaults
         // Metadata for SEO
         $this->container->setParameter('zikula_view.metatags', array('description' => System::getVar('defaultmetadescription'), 'keywords' => System::getVar('metakeywords')));
         $coreInitEvent->setArgument('stage', self::STAGE_THEME);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (!System::isInstalling() && UserUtil::isLoggedIn()) {
         $userstatus = UserUtil::getVar('activated');
         if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) {
             UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             LogUtil::registerStatus(__('You have been logged out.'));
             System::redirect(ModUtil::url('ZikulaUsersModule', 'user', 'login'));
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->dispatcher->dispatch('core.postinit', new GenericEvent($this, array('stages' => $stage)));
     }
 }