Ejemplo n.º 1
0
function rename_friends_init()
{
    // Load the language file
    register_translations(elgg_get_plugins_path() . "rename_friends/languages/");
    // Extend system CSS with our own styles
    elgg_extend_view('css/elgg', 'rename_friends/css');
}
Ejemplo n.º 2
0
/**
 * LDAP Authentication init
 * 
 * These parameters are required for the event API, but we won't use them:
 * 
 * @param unknown_type $event
 * @param unknown_type $object_type
 * @param unknown_type $object 
 */
function ldap_auth_init()
{
    global $CONFIG;
    // Register the authentication handler
    register_pam_handler('ldap_auth_authenticate');
    register_translations($CONFIG->pluginspath . "ldap_auth/languages/");
}
Ejemplo n.º 3
0
/**
 * This function is executed during the 'plugins_boot' event, before most plugins are initialized
 *
 * @return void
 */
function translation_editor_plugins_boot_event()
{
    // add the custom_keys_locations to language paths
    $custom_keys_path = elgg_get_data_path() . 'translation_editor' . DIRECTORY_SEPARATOR . 'custom_keys' . DIRECTORY_SEPARATOR;
    if (is_dir($custom_keys_path)) {
        register_translations($custom_keys_path);
    }
    // force creation of static to prevent reload of unwanted translations
    reload_all_translations();
    if (elgg_in_context('translation_editor') || elgg_in_context('settings') || elgg_in_context('admin')) {
        translation_editor_reload_all_translations();
    }
    translation_editor_load_custom_languages();
    if (!elgg_in_context('translation_editor')) {
        // remove disabled languages
        translation_editor_unregister_translations();
    }
    // load custom translations
    $user_language = get_current_language();
    $elgg_default_language = 'en';
    $load_languages = [$user_language, $elgg_default_language];
    $load_languages = array_unique($load_languages);
    $disabled_languages = translation_editor_get_disabled_languages();
    foreach ($load_languages as $language) {
        if (empty($disabled_languages) || !in_array($language, $disabled_languages)) {
            // add custom translations
            translation_editor_load_translations($language);
        }
    }
}
/**
 * Elgg Sitemap plugin
 * 
 * @package
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Matthias Sutter email@matthias-sutter.de
 * @copyright CubeYoo.de
 * @link http://cubeyoo.de
 */
function sitemap_init()
{
    global $CONFIG;
    // Extend footer
    extend_view("footer/links", "sitemap/footer");
    extend_view('css', 'sitemap/css');
    // Register page handler and translations
    register_page_handler('sitemap', 'sitemap_page_handler');
    register_translations($CONFIG->pluginspath . "sitemap/languages/");
}
function everybody_init()
{
    global $CONFIG;
    // Set up menu for logged in users
    register_translations($CONFIG->pluginspath . "everybody/languages/");
    if (isloggedin()) {
        add_menu(elgg_echo('everybody'), $CONFIG->wwwroot . "pg/everybody");
    }
    register_page_handler('everybody', 'everybody_page_handler');
}
Ejemplo n.º 6
0
 /**
  * Constructor bootstraps the Elgg engine
  */
 public function __construct()
 {
     $this->isAction = $_SERVER['REQUEST_METHOD'] === 'POST';
     $this->bootstrapConfig();
     $this->bootstrapEngine();
     elgg_set_viewtype('installation');
     set_error_handler('_elgg_php_error_handler');
     set_exception_handler('_elgg_php_exception_handler');
     register_translations(dirname(__FILE__) . '/languages/', TRUE);
 }
Ejemplo n.º 7
0
function cas_auth_init()
{
    global $CONFIG;
    $root = dirname(__FILE__);
    elgg_register_library('elgg:cas_auth', "{$root}/lib/lib.php");
    // actions
    $action_path = "{$root}/actions/cas_auth";
    elgg_register_action('login', "{$action_path}/login.php", 'public');
    elgg_register_action('logout', "{$action_path}/logout.php");
    register_pam_handler('cas_auth_authenticate');
    register_translations("{$root}/languages/");
}
Ejemplo n.º 8
0
 /**
  * Constructor bootstraps the Elgg engine
  */
 public function __construct()
 {
     // load ElggRewriteTester as we depend on it
     require_once dirname(__FILE__) . "/ElggRewriteTester.php";
     $this->isAction = $_SERVER['REQUEST_METHOD'] === 'POST';
     $this->bootstrapConfig();
     $this->bootstrapEngine();
     elgg_set_viewtype('installation');
     set_error_handler('_elgg_php_error_handler');
     set_exception_handler('_elgg_php_exception_handler');
     register_translations(dirname(__FILE__) . '/languages/', TRUE);
 }
Ejemplo n.º 9
0
function beechat_init()
{
    global $CONFIG;
    register_translations($CONFIG->pluginspath . "beechat/languages/");
    if (isloggedin()) {
        //			$_SESSION['user']->nbfriends = (int)get_entities_from_relationship('friend', $_SESSION['user']->guid, false, "user", "", 0, "", 10, 0, true);
        //			if ($_SESSION['user']->nbfriends)
        //			extend_view('js/lib', 'beechat/beechat');
        extend_view('metatags', 'beechat/metatags');
    }
    /*                $CONFIG->chatsettings['domain'] = "example.com";
                    $CONFIG->chatsettings['dbname'] = "ejabberd";
                    $CONFIG->chatsettings['dbhost'] = "locahost";
                    $CONFIG->chatsettings['dbuser'] = "******";
                    $CONFIG->chatsettings['dbpassword'] = "";                 */
}
Ejemplo n.º 10
0
/**
 * mediawiki_init 
 * 
 * @return void
 */
function mediawiki_init()
{
    // Load system configuration
    global $CONFIG;
    // Load the language files
    register_translations($CONFIG->pluginspath . "mediawiki/languages/");
    add_group_tool_option('mediawiki_minor_edits', elgg_echo('mediawiki:enable_minor_edits'), FALSE);
    // add to the css
    extend_view('css', 'mediawiki/css');
    // Set up menu for users
    if (isloggedin()) {
        $mediawiki_url = get_plugin_setting('url', 'mediawiki');
        add_menu(elgg_echo('item:object:mediawiki'), $mediawiki_url . "index.php");
    }
    // add a widget
    add_widget_type('mediawiki', elgg_echo("mediawiki:widget_title"), elgg_echo('mediawiki:widget:description'));
}
Ejemplo n.º 11
0
/**
 * Initialisation. Register page handler and extend some views.
 */
function chat_init()
{
    global $CONFIG;
    // Add topbar icon
    extend_view('elgg_topbar/extend', 'chat/topbar');
    // Add link for users not logged in to access the chat
    if (!get_plugin_setting('strict_access', 'chat') && !isloggedin()) {
        if (get_plugin_setting('use_popup', 'chat')) {
            add_menu(elgg_echo('Chat'), "javascript:chat_open('" . $CONFIG->wwwroot . "pg/chat')");
        } else {
            add_menu(elgg_echo('Chat'), $CONFIG->wwwroot . 'pg/chat');
        }
    }
    // Add styles
    extend_view('css', 'chat/css');
    // Add javascript stuff
    extend_view('metatags', 'chat/metatags');
    // Register page handler and translations
    register_page_handler('chat', 'chat_page_handler');
    register_translations($CONFIG->pluginspath . "chat/languages/");
}
Ejemplo n.º 12
0
/**
 * Form initialisation
 *
 * These parameters are required for the event API, but we won't use them:
 * 
 * @param unknown_type $event
 * @param unknown_type $object_type
 * @param unknown_type $object
 */
function form_init()
{
    // Load system configuration
    global $CONFIG;
    // Load the language files
    register_translations($CONFIG->pluginspath . "form/languages/");
    register_translations($CONFIG->pluginspath . "form/languages/formtrans/");
    // Register entity type
    register_entity_type('object', 'form_data');
    // Register a page handler, so we can have nice URLs
    register_page_handler('form', 'form_page_handler');
    register_plugin_hook('usersettings:save', 'user', 'form_user_settings_save');
    // Register a URL handler for form data
    register_entity_url_handler('form_data_url', 'object', 'form_data');
    extend_view('css', 'form/css');
    add_subtype('object', 'form:form');
    add_subtype('object', 'form:config');
    add_subtype('object', 'form:field');
    add_subtype('object', 'form:field_map');
    add_subtype('object', 'form:field_choice');
    add_subtype('object', 'form:search_definition');
    add_subtype('object', 'form_data');
}
Ejemplo n.º 13
0
function beechat_init()
{
    global $CONFIG;
    register_translations($CONFIG->pluginspath . "beechat/languages/");
    register_elgg_event_handler('pagesetup', 'system', 'beechat_pagesetup');
    register_action('beechat/get_statuses', false, $CONFIG->pluginspath . 'beechat/actions/get_statuses.php');
    register_action('beechat/get_icons', false, $CONFIG->pluginspath . 'beechat/actions/get_icons.php');
    register_action('beechat/get_details', false, $CONFIG->pluginspath . 'beechat/actions/get_details.php');
    register_action('beechat/get_connection', false, $CONFIG->pluginspath . 'beechat/actions/get_connection.php');
    register_action('beechat/get_state', false, $CONFIG->pluginspath . 'beechat/actions/get_state.php');
    register_action('beechat/save_state', false, $CONFIG->pluginspath . 'beechat/actions/save_state.php');
    register_plugin_hook('action', 'friends/add', 'beechat_xmpp_add_friend');
    register_plugin_hook('action', 'friends/remove', 'beechat_xmpp_remove_friend');
    extend_view('js/initialise_elgg', 'js/json2.js');
    extend_view('js/initialise_elgg', 'js/jquery.cookie.min.js');
    extend_view('js/initialise_elgg', 'js/jquery.scrollTo-min.js');
    extend_view('js/initialise_elgg', 'js/jquery.serialScroll-min.js');
    extend_view('js/initialise_elgg', 'js/b64.js');
    extend_view('js/initialise_elgg', 'js/sha1.js');
    extend_view('js/initialise_elgg', 'js/md5.js');
    extend_view('js/initialise_elgg', 'js/strophe.min.js');
    extend_view('js/initialise_elgg', 'js/jquery.tools.min.js');
    extend_view('css', 'beechat/screen.css');
    extend_view('js/initialise_elgg', 'beechat/beechat.js');
    extend_view('metatags', 'beechat/beechat.userjs');
    extend_view('footer/analytics', 'beechat/beechat');
    $domain = get_plugin_setting("domain", "beechat");
    $dbname = get_plugin_setting("dbname", "beechat");
    $dbhost = get_plugin_setting("dbhost", "beechat");
    $dbuser = get_plugin_setting("dbuser", "beechat");
    $dbpassword = get_plugin_setting("dbpassword", "beechat");
    $CONFIG->chatsettings['domain'] = $domain;
    $CONFIG->chatsettings['dbname'] = $dbname;
    $CONFIG->chatsettings['dbhost'] = $dbhost;
    $CONFIG->chatsettings['dbuser'] = $dbuser;
    $CONFIG->chatsettings['dbpassword'] = $dbpassword;
}
Ejemplo n.º 14
0
/**
 * Initialises the system session and potentially logs the user in
 * 
 * This function looks for:
 * 
 * 1. $_SESSION['id'] - if not present, we're logged out, and this is set to 0
 * 2. The cookie 'elggperm' - if present, checks it for an authentication token, validates it, and potentially logs the user in 
 *
 * @uses $_SESSION
 * @param unknown_type $event
 * @param unknown_type $object_type
 * @param unknown_type $object
 */
function session_init($event, $object_type, $object)
{
    global $DB_PREFIX, $CONFIG;
    if (!is_db_installed()) {
        return false;
    }
    // Use database for sessions
    $DB_PREFIX = $CONFIG->dbprefix;
    // HACK to allow access to prefix after object distruction
    if (!isset($CONFIG->use_file_sessions)) {
        session_set_save_handler("__elgg_session_open", "__elgg_session_close", "__elgg_session_read", "__elgg_session_write", "__elgg_session_destroy", "__elgg_session_gc");
    }
    session_name('Elgg');
    session_start();
    // Do some sanity checking by generating a fingerprint (makes some XSS attacks harder)
    if (isset($_SESSION['__elgg_fingerprint'])) {
        if ($_SESSION['__elgg_fingerprint'] != get_session_fingerprint()) {
            session_destroy();
            return false;
        }
    } else {
        $_SESSION['__elgg_fingerprint'] = get_session_fingerprint();
    }
    // Generate a simple token (private from potentially public session id)
    if (!isset($_SESSION['__elgg_session'])) {
        $_SESSION['__elgg_session'] = md5(microtime() . rand());
    }
    if (empty($_SESSION['guid'])) {
        if (isset($_COOKIE['elggperm'])) {
            $code = $_COOKIE['elggperm'];
            $code = md5($code);
            unset($_SESSION['guid']);
            //$_SESSION['guid'] = 0;
            unset($_SESSION['id']);
            //$_SESSION['id'] = 0;
            if ($user = get_user_by_code($code)) {
                $_SESSION['user'] = $user;
                $_SESSION['id'] = $user->getGUID();
                $_SESSION['guid'] = $_SESSION['id'];
                $_SESSION['code'] = $_COOKIE['elggperm'];
            }
        } else {
            unset($_SESSION['id']);
            //$_SESSION['id'] = 0;
            unset($_SESSION['guid']);
            //$_SESSION['guid'] = 0;
            unset($_SESSION['code']);
            //$_SESSION['code'] = "";
        }
    } else {
        if (!empty($_SESSION['code'])) {
            $code = md5($_SESSION['code']);
            if ($user = get_user_by_code($code)) {
                $_SESSION['user'] = $user;
                $_SESSION['id'] = $user->getGUID();
                $_SESSION['guid'] = $_SESSION['id'];
            } else {
                unset($_SESSION['user']);
                unset($_SESSION['id']);
                //$_SESSION['id'] = 0;
                unset($_SESSION['guid']);
                //$_SESSION['guid'] = 0;
                unset($_SESSION['code']);
                //$_SESSION['code'] = "";
            }
        } else {
            //$_SESSION['user'] = new ElggDummy();
            unset($_SESSION['id']);
            //$_SESSION['id'] = 0;
            unset($_SESSION['guid']);
            //$_SESSION['guid'] = 0;
            unset($_SESSION['code']);
            //$_SESSION['code'] = "";
        }
    }
    if ($_SESSION['id'] > 0) {
        set_last_action($_SESSION['id']);
    }
    register_action("login", true);
    register_action("logout");
    // Register a default PAM handler
    register_pam_handler('pam_auth_userpass');
    // Initialise the magic session
    global $SESSION;
    $SESSION = new ElggSession();
    // Finally we ensure that a user who has been banned with an open session is kicked.
    if (isset($_SESSION['user']) && $_SESSION['user']->isBanned()) {
        session_destroy();
        return false;
    }
    // Since we have loaded a new user, this user may have different language preferences
    register_translations(dirname(dirname(dirname(__FILE__))) . "/languages/");
    return true;
}
Ejemplo n.º 15
0
/**
 * Boots the engine
 *
 * 1. sets error handlers
 * 2. connects to database
 * 3. verifies the installation suceeded
 * 4. loads application configuration
 * 5. loads site configuration
 *
 * @access private
 */
function _elgg_engine_boot()
{
    // Register the error handlers
    set_error_handler('_elgg_php_error_handler');
    set_exception_handler('_elgg_php_exception_handler');
    register_translations(dirname(dirname(dirname(__FILE__))) . "/languages/");
    setup_db_connections();
    verify_installation();
    _elgg_load_application_config();
    _elgg_load_site_config();
    _elgg_load_cache();
}
Ejemplo n.º 16
0
<?php

/**
 * Arabic Language Pack for Elgg 1.8
 *
 * This plugin provides the Arabic translations for the language files of Elgg including bundled plugins.
 *
 * (C) okhayat 2013
 * GNU Public License version 2
 *
 * https://github.com/okhayat
 * Contact: okhayat@gmail.com
 */
register_translations(dirname(__FILE__) . "/languages/", true);
Ejemplo n.º 17
0
 /**
  * Load remaining engine libraries and complete bootstraping (see start.php)
  *
  * @param string $step Which step to boot strap for. Required because
  *                     boot strapping is different until the DB is populated.
  *
  * @return void
  */
 protected function finishBootstraping($step)
 {
     $dbIndex = array_search('database', $this->getSteps());
     $settingsIndex = array_search('settings', $this->getSteps());
     $adminIndex = array_search('admin', $this->getSteps());
     $completeIndex = array_search('complete', $this->getSteps());
     $stepIndex = array_search($step, $this->getSteps());
     // To log in the user, we need to use the Elgg core session handling.
     // Otherwise, use default php session handling
     $useElggSession = $stepIndex == $adminIndex && $this->isAction || $stepIndex == $completeIndex;
     if (!$useElggSession) {
         session_name('Elgg_install');
         session_start();
         elgg_unregister_event_handler('boot', 'system', 'session_init');
     }
     if ($stepIndex > $dbIndex) {
         // once the database has been created, load rest of engine
         global $CONFIG;
         $lib_dir = $CONFIG->path . 'engine/lib/';
         $this->loadSettingsFile();
         $lib_files = array('database.php', 'actions.php', 'admin.php', 'annotations.php', 'cron.php', 'entities.php', 'extender.php', 'filestore.php', 'group.php', 'location.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php', 'metastrings.php', 'navigation.php', 'notification.php', 'objects.php', 'opendd.php', 'pagehandler.php', 'pam.php', 'plugins.php', 'private_settings.php', 'relationships.php', 'river.php', 'sites.php', 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', 'deprecated-1.7.php', 'deprecated-1.8.php', 'deprecated-1.9.php');
         foreach ($lib_files as $file) {
             $path = $lib_dir . $file;
             if (!(include_once $path)) {
                 $msg = elgg_echo('InstallationException:MissingLibrary', array($file));
                 throw new InstallationException($msg);
             }
         }
         setup_db_connections();
         register_translations(dirname(dirname(__FILE__)) . "/languages/");
         if ($stepIndex > $settingsIndex) {
             $CONFIG->site_guid = (int) datalist_get('default_site');
             $CONFIG->site_id = $CONFIG->site_guid;
             $CONFIG->site = get_entity($CONFIG->site_guid);
             $CONFIG->dataroot = datalist_get('dataroot');
             _elgg_session_boot(NULL, NULL, NULL);
         }
         elgg_trigger_event('init', 'system');
     }
 }
Ejemplo n.º 18
0
/**
 * Initialises the system session and potentially logs the user in
 *
 * This function looks for:
 *
 * 1. $_SESSION['id'] - if not present, we're logged out, and this is set to 0
 * 2. The cookie 'elggperm' - if present, checks it for an authentication
 * token, validates it, and potentially logs the user in
 *
 * @uses $_SESSION
 *
 * @param string $event       Event name
 * @param string $object_type Object type
 * @param mixed  $object      Object
 *
 * @return bool
 */
function session_init($event, $object_type, $object)
{
    global $DB_PREFIX, $CONFIG;
    // Use database for sessions
    // HACK to allow access to prefix after object destruction
    $DB_PREFIX = $CONFIG->dbprefix;
    if (!isset($CONFIG->use_file_sessions)) {
        session_set_save_handler("_elgg_session_open", "_elgg_session_close", "_elgg_session_read", "_elgg_session_write", "_elgg_session_destroy", "_elgg_session_gc");
    }
    session_name('Elgg');
    session_start();
    // Generate a simple token (private from potentially public session id)
    if (!isset($_SESSION['__elgg_session'])) {
        $_SESSION['__elgg_session'] = md5(microtime() . rand());
    }
    // test whether we have a user session
    if (empty($_SESSION['guid'])) {
        // clear session variables before checking cookie
        unset($_SESSION['user']);
        unset($_SESSION['id']);
        unset($_SESSION['guid']);
        unset($_SESSION['code']);
        // is there a remember me cookie
        if (isset($_COOKIE['elggperm'])) {
            // we have a cookie, so try to log the user in
            $code = $_COOKIE['elggperm'];
            $code = md5($code);
            if ($user = get_user_by_code($code)) {
                // we have a user, log him in
                $_SESSION['user'] = $user;
                $_SESSION['id'] = $user->getGUID();
                $_SESSION['guid'] = $_SESSION['id'];
                $_SESSION['code'] = $_COOKIE['elggperm'];
            }
        }
    } else {
        // we have a session and we have already checked the fingerprint
        // reload the user object from database in case it has changed during the session
        if ($user = get_user($_SESSION['guid'])) {
            $_SESSION['user'] = $user;
            $_SESSION['id'] = $user->getGUID();
            $_SESSION['guid'] = $_SESSION['id'];
        } else {
            // user must have been deleted with a session active
            unset($_SESSION['user']);
            unset($_SESSION['id']);
            unset($_SESSION['guid']);
            unset($_SESSION['code']);
        }
    }
    if (isset($_SESSION['guid'])) {
        set_last_action($_SESSION['guid']);
    }
    elgg_register_action("login", '', 'public');
    elgg_register_action("logout");
    // Register a default PAM handler
    register_pam_handler('pam_auth_userpass');
    // Initialise the magic session
    global $SESSION;
    $SESSION = new ElggSession();
    // Finally we ensure that a user who has been banned with an open session is kicked.
    if (isset($_SESSION['user']) && $_SESSION['user']->isBanned()) {
        session_destroy();
        return false;
    }
    // Since we have loaded a new user, this user may have different language preferences
    register_translations(dirname(dirname(dirname(__FILE__))) . "/languages/");
    return true;
}
Ejemplo n.º 19
0
/**
 * Reload all translations from all registered paths.
 *
 * This is only called by functions which need to know all possible translations, namely the
 * statistic gathering ones.
 *
 * @todo Better on demand loading based on language_paths array
 *
 * @return bool
 */
function reload_all_translations()
{
    global $CONFIG;
    static $LANG_RELOAD_ALL_RUN;
    if ($LANG_RELOAD_ALL_RUN) {
        return null;
    }
    foreach ($CONFIG->language_paths as $path => $dummy) {
        register_translations($path, true);
    }
    $LANG_RELOAD_ALL_RUN = true;
}
Ejemplo n.º 20
0
 /**
  * Registers the plugin's languages
  *
  * @throws PluginException
  * @return true
  */
 protected function registerLanguages()
 {
     $languages_path = "{$this->path}/languages";
     // don't need to have classes
     if (!is_dir($languages_path)) {
         return true;
     }
     // but need to have working ones.
     if (!register_translations($languages_path)) {
         $msg = elgg_echo('ElggPlugin:Exception:CannotRegisterLanguages', array($this->getID(), $this->guid, $languages_path));
         throw new PluginException($msg);
     }
     return true;
 }
Ejemplo n.º 21
0
if (strpos($username, '@') !== false && ($users = get_user_by_email($username))) {
    $username = $users[0]->username;
}
$result = elgg_authenticate($username, $password);
if ($result !== true) {
    register_error($result);
    forward(REFERER);
}
$user = get_user_by_username($username);
if (!$user) {
    register_error(elgg_echo('login:baduser'));
    forward(REFERER);
}
try {
    login($user, $persistent);
    // re-register at least the core language file for users with language other than site default
    register_translations(dirname(dirname(__FILE__)) . "/languages/");
} catch (LoginException $e) {
    register_error($e->getMessage());
    forward(REFERER);
}
// elgg_echo() caches the language and does not provide a way to change the language.
// @todo we need to use the config object to store this so that the current language
// can be changed. Refs #4171
if ($user->language) {
    $message = elgg_echo('loginok', array(), $user->language);
} else {
    $message = elgg_echo('loginok');
}
system_message($message);
forward($forward_url);
Ejemplo n.º 22
0
/**
 * Reload all translations from all registered paths.
 *
 * This is only called by functions which need to know all possible translations.
 *
 * @todo Better on demand loading based on language_paths array
 *
 * @return void
 */
function reload_all_translations()
{
    global $CONFIG;
    static $LANG_RELOAD_ALL_RUN;
    if ($LANG_RELOAD_ALL_RUN) {
        return;
    }
    if ($CONFIG->i18n_loaded_from_cache) {
        $cache = elgg_get_system_cache();
        $cache_dir = $cache->getVariable("cache_path");
        $filenames = elgg_get_file_list($cache_dir, array(), array(), array(".lang"));
        foreach ($filenames as $filename) {
            // Look for files matching for example 'en.lang', 'cmn.lang' or 'pt_br.lang'.
            // Note that this regex is just for the system cache. The original language
            // files are allowed to have uppercase letters (e.g. pt_BR.php).
            if (preg_match('/(([a-z]{2,3})(_[a-z]{2})?)\\.lang$/', $filename, $matches)) {
                $language = $matches[1];
                $data = elgg_load_system_cache("{$language}.lang");
                if ($data) {
                    add_translation($language, unserialize($data));
                }
            }
        }
    } else {
        foreach ($CONFIG->language_paths as $path => $dummy) {
            register_translations($path, true);
        }
    }
    $LANG_RELOAD_ALL_RUN = true;
}
<?php

/**
 * Elgg 1.8.15 upgrade 2013060900
 * site_secret
 *
 * Description
 */
$strength = _elgg_get_site_secret_strength();
if ($strength !== 'strong') {
    // a new key is needed immediately
    register_translations(elgg_get_root_path() . 'languages/');
    elgg_add_admin_notice('weak_site_key', elgg_echo("upgrade:site_secret_warning:{$strength}"));
}
Ejemplo n.º 24
0
/**
 * For now, loads plugins directly
 *
 * @todo Add proper plugin handler that launches plugins in an admin-defined order and activates them on admin request
 * @package Elgg
 * @subpackage Core
 */
function load_plugins()
{
    global $CONFIG;
    $cache = elgg_get_filepath_cache();
    if (!empty($CONFIG->pluginspath)) {
        // See if we have cached values for things
        $cached_view_paths = $cache->load('view_paths');
        if ($cached_view_paths) {
            $CONFIG->views = unserialize($cached_view_paths);
        }
        // temporary disable all plugins if there is a file called 'disabled' in the plugin dir
        if (file_exists($CONFIG->pluginspath . "disabled")) {
            return;
        }
        $plugins = get_plugin_list();
        if (sizeof($plugins)) {
            foreach ($plugins as $mod) {
                if (is_plugin_enabled($mod)) {
                    if (file_exists($CONFIG->pluginspath . $mod)) {
                        if (!(include $CONFIG->pluginspath . $mod . "/start.php")) {
                            throw new PluginException(sprintf(elgg_echo('PluginException:MisconfiguredPlugin'), $mod));
                        }
                        if (!$cached_view_paths) {
                            if (is_dir($CONFIG->pluginspath . $mod . "/views")) {
                                if ($handle = opendir($CONFIG->pluginspath . $mod . "/views")) {
                                    while ($viewtype = readdir($handle)) {
                                        if (!in_array($viewtype, array('.', '..', '.svn', 'CVS')) && is_dir($CONFIG->pluginspath . $mod . "/views/" . $viewtype)) {
                                            autoregister_views("", $CONFIG->pluginspath . $mod . "/views/" . $viewtype, $CONFIG->pluginspath . $mod . "/views/", $viewtype);
                                        }
                                    }
                                }
                            }
                        }
                        if (is_dir($CONFIG->pluginspath . $mod . "/languages")) {
                            register_translations($CONFIG->pluginspath . $mod . "/languages/");
                        }
                    }
                }
            }
        }
        // Cache results
        if (!$cached_view_paths) {
            $cache->save('view_paths', serialize($CONFIG->views));
        }
    }
}
/**
 * For now, loads plugins directly
 *
 * @todo Add proper plugin handler that launches plugins in an admin-defined order and activates them on admin request
 * @package Elgg
 * @subpackage Core
 */
function load_plugins()
{
    global $CONFIG;
    if (!empty($CONFIG->pluginspath)) {
        // See if we have cached values for things
        $cached_view_paths = elgg_filepath_cache_load();
        if ($cached_view_paths) {
            $CONFIG->views = unserialize($cached_view_paths);
        }
        // temporary disable all plugins if there is a file called 'disabled' in the plugin dir
        if (file_exists($CONFIG->pluginspath . "disabled")) {
            return;
        }
        $plugins = get_plugin_list();
        if (sizeof($plugins)) {
            foreach ($plugins as $mod) {
                if (is_plugin_enabled($mod)) {
                    if (file_exists($CONFIG->pluginspath . $mod)) {
                        if (!(include $CONFIG->pluginspath . $mod . "/start.php")) {
                            // automatically disable the bad plugin
                            disable_plugin($mod);
                            // register error rather than rendering the site unusable with exception
                            register_error(sprintf(elgg_echo('PluginException:MisconfiguredPlugin'), $mod));
                            // continue loading remaining plugins
                            continue;
                        }
                        if (!$cached_view_paths) {
                            if (is_dir($CONFIG->pluginspath . $mod . "/views")) {
                                if ($handle = opendir($CONFIG->pluginspath . $mod . "/views")) {
                                    while ($viewtype = readdir($handle)) {
                                        if (!in_array($viewtype, array('.', '..', '.svn', 'CVS')) && is_dir($CONFIG->pluginspath . $mod . "/views/" . $viewtype)) {
                                            autoregister_views("", $CONFIG->pluginspath . $mod . "/views/" . $viewtype, $CONFIG->pluginspath . $mod . "/views/", $viewtype);
                                        }
                                    }
                                }
                            }
                        }
                        if (is_dir($CONFIG->pluginspath . $mod . "/languages")) {
                            register_translations($CONFIG->pluginspath . $mod . "/languages/");
                        }
                    }
                }
            }
        }
        // Cache results
        if (!$cached_view_paths) {
            elgg_filepath_cache_save(serialize($CONFIG->views));
        }
    }
}
Ejemplo n.º 26
0
 /**
  * Load translations of all plugins
  *
  * @return void
  */
 private function loadAllPluginTranslations()
 {
     $plugins = elgg_get_plugins('all');
     foreach ($plugins as $plugin) {
         $path = elgg_get_plugins_path() . $plugin->getID() . '/languages';
         if (is_dir($path)) {
             register_translations($path);
         }
     }
 }
Ejemplo n.º 27
0
/**
 * Reload all translations from all registered paths.
 *
 * This is only called by functions which need to know all possible translations.
 *
 * @todo Better on demand loading based on language_paths array
 *
 * @return void
 */
function reload_all_translations()
{
    global $CONFIG;
    static $LANG_RELOAD_ALL_RUN;
    if ($LANG_RELOAD_ALL_RUN) {
        return;
    }
    if ($CONFIG->i18n_loaded_from_cache) {
        $cache = elgg_get_system_cache();
        $cache_dir = $cache->getVariable("cache_path");
        $filenames = elgg_get_file_list($cache_dir, array(), array(), array(".lang"));
        foreach ($filenames as $filename) {
            if (preg_match('/([a-z]+)\\.[^.]+$/', $filename, $matches)) {
                $language = $matches[1];
                $data = elgg_load_system_cache("{$language}.lang");
                if ($data) {
                    add_translation($language, unserialize($data));
                }
            }
        }
    } else {
        foreach ($CONFIG->language_paths as $path => $dummy) {
            register_translations($path, true);
        }
    }
    $LANG_RELOAD_ALL_RUN = true;
}