Example #1
0
/**
 * 
 * @param array $credentials
 * @return unknown_type
 */
function au_cas_auth_authenticate($credentials)
{
    // do a redirect to the cas URL
    $config = elgg_get_plugin_from_id(PLUGIN_ID);
    send_to_cas($config, $credentials);
    return false;
}
Example #2
0
 /**
  * Loads the plugin by GUID or path.
  *
  * @warning Unlike other ElggEntity objects, you cannot null instantiate
  *          ElggPlugin. You must point it to an actual plugin GUID or location.
  *
  * @param mixed $plugin The GUID of the ElggPlugin object or the path of
  *                      the plugin to load.
  */
 public function __construct($plugin)
 {
     if (!$plugin) {
         throw new PluginException(elgg_echo('PluginException:NullInstantiated'));
     }
     // ElggEntity can be instantiated with a guid or an object.
     // @todo plugins w/id 12345
     if (is_numeric($plugin) || is_object($plugin)) {
         parent::__construct($plugin);
         $this->path = elgg_get_plugins_path() . $this->getID();
     } else {
         $plugin_path = elgg_get_plugins_path();
         // not a full path, so assume an id
         // use the default path
         if (strpos($plugin, $plugin_path) !== 0) {
             $plugin = $plugin_path . $plugin;
         }
         // path checking is done in the package
         $plugin = sanitise_filepath($plugin);
         $this->path = $plugin;
         $path_parts = explode('/', rtrim($plugin, '/'));
         $plugin_id = array_pop($path_parts);
         $this->pluginID = $plugin_id;
         // check if we're loading an existing plugin
         $existing_plugin = elgg_get_plugin_from_id($this->pluginID);
         $existing_guid = null;
         if ($existing_plugin) {
             $existing_guid = $existing_plugin->guid;
         }
         // load the rest of the plugin
         parent::__construct($existing_guid);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $plugins = elgg_get_plugins('inactive');
     if (empty($plugins)) {
         system_message('All plugins are active');
         return;
     }
     $ids = array_map(function (ElggPlugin $plugin) {
         return $plugin->getID();
     }, $plugins);
     $ids = array_values($ids);
     if ($this->option('all')) {
         $activate_ids = $ids;
     } else {
         $helper = $this->getHelper('question');
         $question = new ChoiceQuestion('Please select plugins you would like to activate (comma-separated list of indexes)', $ids);
         $question->setMultiselect(true);
         $activate_ids = $helper->ask($this->input, $this->output, $question);
     }
     if (empty($activate_ids)) {
         throw new \RuntimeException('You must select at least one plugin');
     }
     $plugins = [];
     foreach ($activate_ids as $plugin_id) {
         $plugins[] = elgg_get_plugin_from_id($plugin_id);
     }
     do {
         $additional_plugins_activated = false;
         foreach ($plugins as $key => $plugin) {
             if ($plugin->isActive()) {
                 unset($plugins[$key]);
                 continue;
             }
             if (!$plugin->activate()) {
                 // plugin could not be activated in this loop, maybe in the next loop
                 continue;
             }
             $ids = array('cannot_start' . $plugin->getID(), 'invalid_and_deactivated_' . $plugin->getID());
             foreach ($ids as $id) {
                 elgg_delete_admin_notice($id);
             }
             // mark that something has changed in this loop
             $additional_plugins_activated = true;
             unset($plugins[$key]);
             system_message("Plugin {$plugin->getFriendlyName()} has been activated");
         }
         if (!$additional_plugins_activated) {
             // no updates in this pass, break the loop
             break;
         }
     } while (count($plugins) > 0);
     if (count($plugins) > 0) {
         foreach ($plugins as $plugin) {
             $msg = $plugin->getError();
             $string = $msg ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no';
             register_error(elgg_echo($string, array($plugin->getFriendlyName())));
         }
     }
     elgg_flush_caches();
 }
Example #4
0
 /**
  * Creates a new plugin from path
  *
  * @note Internal: also supports database objects
  *
  * @warning Unlike other \ElggEntity objects, you cannot null instantiate
  *          \ElggPlugin. You must provide the path to the plugin directory.
  *
  * @param string $path The absolute path of the plugin
  *
  * @throws PluginException
  */
 public function __construct($path)
 {
     if (!$path) {
         throw new \PluginException("ElggPlugin cannot be null instantiated. You must pass a full path.");
     }
     if (is_object($path)) {
         // database object
         parent::__construct($path);
         $this->path = _elgg_services()->config->getPluginsPath() . $this->getID();
         _elgg_cache_plugin_by_id($this);
         return;
     }
     if (is_numeric($path)) {
         // guid
         // @todo plugins with directory names of '12345'
         throw new \InvalidArgumentException('$path cannot be a GUID');
     }
     $this->initializeAttributes();
     // path checking is done in the package
     $path = sanitise_filepath($path);
     $this->path = $path;
     $path_parts = explode('/', rtrim($path, '/'));
     $plugin_id = array_pop($path_parts);
     $this->title = $plugin_id;
     // check if we're loading an existing plugin
     $existing_plugin = elgg_get_plugin_from_id($plugin_id);
     if ($existing_plugin) {
         $this->load($existing_plugin->guid);
     }
     _elgg_cache_plugin_by_id($this);
 }
Example #5
0
/**
 * @param $hook
 * @param $type
 * @param $returnvalue
 * @param $params
 *
 * @return bool
 *
 * function called when the below plugin trigger is initiated
 * @see /engine/lib/actions.php
 * @see elgg_trigger_plugin_hook('action', $action, null, $event_result);
 *
 * this hook is triggered for the action = "register"
 * this hooks is called before the default "register" action handler at /actions/register.php
 * checks if recaptcha is valid - if not register an error
 */
function recaptcha_check_form($hook, $type, $returnvalue, $params)
{
    // retain entered form values and re-populate form fields if validation error
    elgg_make_sticky_form('register');
    /*-- check if the 'Use Recaptcha for user registration' Plugin setting is enabled --*/
    //fetch the plugin settings
    $plugin_entity = elgg_get_plugin_from_id('recaptcha');
    $plugin_settings = $plugin_entity->getAllSettings();
    if (array_key_exists('recaptcha_verified', $_SESSION) && $_SESSION['recaptcha_verified'] == 1) {
        //do nothing
    } else {
        if ($plugin_settings['require_recaptcha'] == 'on') {
            //if the setting is enabled
            // include the recaptcha lib
            require_once 'lib/recaptchalib.php';
            // check the recaptcha
            $resp = recaptcha_check_answer($plugin_settings['recaptcha_private_key'], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
            if (!$resp->is_valid) {
                register_error(elgg_echo('recaptcha:human_verification_failed'));
                forward(REFERER);
            } else {
                /* note that the user has successfully passed the captcha
                 * in case the form submission fails due to other factors, we do not want to
                 * ask the user to fill in the captcha details again
                 * so we store it in a session variable and destroy it after the form is successfully submitted
                 */
                $_SESSION['recaptcha_verified'] = 1;
            }
        }
    }
    return true;
}
Example #6
0
 public static function factory()
 {
     if (null === self::$instance) {
         $plugin = elgg_get_plugin_from_id('hypeDropzone');
         self::$instance = new self($plugin);
     }
     return self::$instance;
 }
Example #7
0
/**
 * Plugin container
 * 
 * @return \hypeJunction\Inbox\Plugin
 * @access private since 6.0
 */
function hypeInbox()
{
    static $instance;
    if (null === $instance) {
        $plugin = elgg_get_plugin_from_id('hypeInbox');
        $instance = new \hypeJunction\Inbox\Plugin($plugin);
    }
    return $instance;
}
Example #8
0
function is_allowed_type($entity)
{
    $plugin = elgg_get_plugin_from_id('favourites');
    $allowed_object_subtypes_array = explode(', ', $plugin->allowed_object_subtypes);
    foreach ($allowed_object_subtypes_array as $sub_type) {
        if (elgg_instanceof($entity, 'object', $sub_type)) {
            return true;
        }
    }
    return true;
}
Example #9
0
/**
 * Get a plugin setting
 *
 * @param string $setting the name of the setting to get
 *
 * @return mixed
 */
function poll_get_plugin_setting($setting)
{
    static $settings;
    if (!isset($settings)) {
        $defaults = ['enable_site' => 'no', 'enable_group' => 'no', 'group_create' => 'members', 'close_date_required' => 'no', 'vote_change_allowed' => 'yes'];
        $plugin = elgg_get_plugin_from_id('poll');
        $plugin_settings = $plugin->getAllSettings();
        $settings = array_merge($defaults, $plugin_settings);
    }
    return elgg_extract($setting, $settings);
}
Example #10
0
function livewire_init()
{
    $action_path = dirname(__FILE__) . '/actions';
    $plugin = elgg_get_plugin_from_id('livewire');
    elgg_register_action("livewire/add", "{$action_path}/add.php");
    elgg_extend_view('js/elgg', 'js/livewire/update');
    elgg_register_widget_type('livewire', elgg_echo('ONGARDE Live'), elgg_echo('Display the wire'), "index,dashboard", true);
    elgg_unregister_page_handler('activity', 'elgg_river_page_handler');
    elgg_register_page_handler('activity', 'livewire_river_page_handler');
    if (elgg_is_logged_in() && elgg_get_context() == 'activity') {
        elgg_extend_view('page/layouts/content/header', 'page/elements/riverwire', 1);
    }
}
Example #11
0
/**
 * Returns as list of sort options
 * @return array
 */
function user_sort_get_sort_options()
{
    $fields = array();
    $plugin = elgg_get_plugin_from_id('user_sort');
    $settings = $plugin->getAllSettings();
    foreach ($settings as $k => $val) {
        if (!$val) {
            continue;
        }
        list($sort, $option) = explode('::', $k);
        if ($sort && in_array(strtolower($option), array('asc', 'desc'))) {
            $fields[] = $k;
        }
    }
    return elgg_trigger_plugin_hook('sort_fields', 'user', null, $fields);
}
Example #12
0
/**
 * init function for the plugin
 * custom header and footer are set in Elgg Admin Menu -> Settings -> Customize Notification
 * plugin settings form defined in: views/default/plugins/custom_notify/settings.php
 * 
 * @param hook
 * @param type
 * @param retrunvalue
 * @param params 
 * 		params is an array[to, from, subject, body]
 * 
 * @return array 
 * 		returns the modified $params array 
 */
function custom_notify_init($hook, $type, $returnvalue, $params)
{
    //fetch the header and footer values if they have been set
    $plugin_obj = elgg_get_plugin_from_id('custom_notify');
    $plugin_settings = $plugin_obj->getAllSettings();
    //prepend header
    $header = trim($plugin_settings['custom_notify_header']);
    if ($header != '') {
        $params['body'] = $header . "\n\n" . $params['body'];
    }
    //append footer
    $footer = trim($plugin_settings['custom_notify_footer']);
    if ($footer != '') {
        $params['body'] = $params['body'] . "\n\n" . $footer;
    }
    return $params;
}
Example #13
0
function developers_process_settings()
{
    $settings = elgg_get_plugin_from_id('developers')->getAllSettings();
    ini_set('display_errors', (int) (!empty($settings['display_errors'])));
    if (!empty($settings['screen_log'])) {
        // don't show in action/simplecache
        $path = substr(current_page_url(), strlen(elgg_get_site_url()));
        if (!preg_match('~^(cache|action)/~', $path)) {
            $cache = new ElggLogCache();
            elgg_set_config('log_cache', $cache);
            elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump'));
            elgg_register_plugin_hook_handler('view_vars', 'page/elements/html', function ($hook, $type, $vars, $params) {
                $vars['body'] .= elgg_view('developers/log');
                return $vars;
            });
        }
    }
    if (!empty($settings['show_strings'])) {
        // Beginning and end to make sure both early-rendered and late-loaded translations get included
        elgg_register_event_handler('init', 'system', 'developers_decorate_all_translations', 1);
        elgg_register_event_handler('init', 'system', 'developers_decorate_all_translations', 1000);
    }
    if (!empty($settings['show_modules'])) {
        elgg_require_js('elgg/dev/amd_monitor');
    }
    if (!empty($settings['wrap_views'])) {
        elgg_register_plugin_hook_handler('view', 'all', 'developers_wrap_views', 600);
    }
    if (!empty($settings['log_events'])) {
        elgg_register_event_handler('all', 'all', 'developers_log_events', 1);
        elgg_register_plugin_hook_handler('all', 'all', 'developers_log_events', 1);
    }
    if (!empty($settings['show_gear']) && elgg_is_admin_logged_in() && !elgg_in_context('admin')) {
        elgg_require_js('elgg/dev/gear');
        elgg_load_js('lightbox');
        elgg_load_css('lightbox');
        elgg_register_ajax_view('developers/gear_popup');
        elgg_register_simplecache_view('elgg/dev/gear.html');
        // TODO use ::class in 2.0
        $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSectionVars'];
        elgg_register_plugin_hook_handler('view_vars', 'navigation/menu/elements/section', $handler);
        $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSections'];
        elgg_register_plugin_hook_handler('view', 'navigation/menu/elements/section', $handler);
    }
}
Example #14
0
 /**
  * Loads the plugin by GUID or path.
  *
  * @warning Unlike other ElggEntity objects, you cannot null instantiate
  *          ElggPlugin. You must point it to an actual plugin GUID or location.
  *
  * @param mixed $plugin The GUID of the ElggPlugin object or the path of
  *                      the plugin to load.
  */
 public function __construct($plugin)
 {
     if (!$plugin) {
         throw new PluginException(elgg_echo('PluginException:NullInstantiated'));
     }
     // ElggEntity can be instantiated with a guid or an object.
     // @todo plugins w/id 12345
     if (is_numeric($plugin) || is_object($plugin)) {
         parent::__construct($plugin);
         $this->path = elgg_get_plugins_path() . $this->getID();
     } else {
         $plugin_path = elgg_get_plugins_path();
         // not a full path, so assume an id
         // use the default path
         if (strpos($plugin, $plugin_path) !== 0) {
             $plugin = $plugin_path . $plugin;
         }
         // path checking is done in the package
         $plugin = sanitise_filepath($plugin);
         $this->path = $plugin;
         $path_parts = explode('/', rtrim($plugin, '/'));
         $plugin_id = array_pop($path_parts);
         $this->pluginID = $plugin_id;
         // check if we're loading an existing plugin
         $existing_plugin = elgg_get_plugin_from_id($this->pluginID);
         $existing_guid = null;
         if ($existing_plugin) {
             $existing_guid = $existing_plugin->guid;
         }
         // load the rest of the plugin
         parent::__construct($existing_guid);
     }
     // We have to let the entity load so we can manipulate it with the API.
     // If the path is wrong or would cause an exception, catch it,
     // disable the plugin, and emit an error.
     try {
         $this->package = new ElggPluginPackage($this->path, false);
         $this->manifest = $this->package->getManifest();
     } catch (Exception $e) {
         // we always have to allow the entity to load.
         elgg_log("Failed to load {$this->guid} as a plugin. " . $e->getMessage(), 'WARNING');
         $this->errorMsg = $e->getmessage();
     }
 }
Example #15
0
function subsite_manager_fix_piwik_settings()
{
    global $SUBSITE_MANAGER_IGNORE_WRITE_ACCESS;
    if (subsite_manager_on_subsite()) {
        $site = elgg_get_site_entity();
        if ($piwik_settings = $site->phloor_analytics_piwik_settings) {
            $SUBSITE_MANAGER_IGNORE_WRITE_ACCESS = true;
            if ($site->canEdit()) {
                // log to the error log that we did something
                error_log("PIWIK saving settings for " . $site->name . " (" . $site->getGUID() . ")");
                error_log("PIWIK settings: " . $piwik_settings);
                if ($piwik_settings = json_decode($piwik_settings, true)) {
                    if (!empty($piwik_settings) && is_array($piwik_settings)) {
                        $enabled = elgg_extract("enable_tracking", $piwik_settings);
                        $piwik_url = elgg_extract("path_to_piwik", $piwik_settings);
                        $piwik_site_id = elgg_extract("site_guid", $piwik_settings);
                        if ($enabled == "true") {
                            if (!empty($piwik_url) && !empty($piwik_site_id)) {
                                // check if analytics is enabled
                                if (!elgg_is_active_plugin("analytics")) {
                                    // not active so enable
                                    if ($plugin = elgg_get_plugin_from_id("analytics")) {
                                        $plugin->activate();
                                        elgg_invalidate_simplecache();
                                        elgg_reset_system_cache();
                                    }
                                }
                                // save settings, if not exists
                                if (!elgg_get_plugin_setting("piwik_url", "analytics") && !elgg_get_plugin_setting("piwik_site_id", "analytics")) {
                                    elgg_set_plugin_setting("piwik_url", $piwik_url, "analytics");
                                    elgg_set_plugin_setting("piwik_site_id", $piwik_site_id, "analytics");
                                }
                            }
                        }
                    }
                }
                // remove the settings so we don't do this again
                unset($site->phloor_analytics_piwik_settings);
            }
            // unset write access
            $SUBSITE_MANAGER_IGNORE_WRITE_ACCESS = false;
        }
    }
}
Example #16
0
/**
 * @param $hook
 * @param $type
 * @param $returnvalue
 * @param $params
 *
 * @return bool
 *
 * function called when the below plugin trigger is initiated
 * @see /engine/lib/actions.php
 * @see elgg_trigger_plugin_hook('action', $action, null, $event_result);  [
 *
 * this hook is triggered for the action = "register"
 * this hooks is called before the default "register" action handler at /actions/register.php
 * checks if the terms of use checkbox is checked - if not register an error
 */
function terms_of_use_check_form($hook, $type, $returnvalue, $params)
{
    // retain entered form values and re-populate form fields if validation error
    elgg_make_sticky_form('register');
    /*-- check if the 'Require user to accept terms' Plugin setting is enabled --*/
    //fetch the plugin settings
    $plugin_obj = elgg_get_plugin_from_id('terms_of_use');
    $plugin_settings = $plugin_obj->getAllSettings();
    if ($plugin_settings['require_terms_of_use'] == 'on') {
        //if the setting is enabled
        // Get POST variables
        $require_terms_of_use = get_input('checkbox-require-terms-of-use');
        if (trim($require_terms_of_use) != 'on') {
            register_error(elgg_echo('terms_of_use:registration_exception:require_checkbox'));
            forward(REFERER);
        }
    }
    return true;
}
Example #17
0
 /**
  * Creates a new plugin from path
  *
  * @internal also supports database objects
  *
  * @warning Unlike other ElggEntity objects, you cannot null instantiate
  *          ElggPlugin. You must provide the path to the plugin directory.
  *
  * @param string $path The absolute path of the plugin
  *
  * @throws PluginException
  */
 public function __construct($path)
 {
     if (!$path) {
         throw new PluginException("ElggPlugin cannot be null instantiated. You must pass a full path.");
     }
     if (is_object($path)) {
         // database object
         parent::__construct($path);
         $this->path = elgg_get_plugins_path() . $this->getID();
     } else {
         if (is_numeric($path)) {
             // guid
             // @todo plugins with directory names of '12345'
             elgg_deprecated_notice("Use elgg_get_plugin_from_id() to load a plugin.", 1.9);
             parent::__construct($path);
             $this->path = elgg_get_plugins_path() . $this->getID();
         } else {
             $mod_dir = elgg_get_plugins_path();
             // not a full path, so assume a directory name and use the default path
             if (strpos($path, $mod_dir) !== 0) {
                 elgg_deprecated_notice("You should pass a full path to ElggPlugin.", 1.9);
                 $path = $mod_dir . $path;
             }
             // path checking is done in the package
             $path = sanitise_filepath($path);
             $this->path = $path;
             $path_parts = explode('/', rtrim($path, '/'));
             $plugin_id = array_pop($path_parts);
             $this->pluginID = $plugin_id;
             // check if we're loading an existing plugin
             $existing_plugin = elgg_get_plugin_from_id($this->pluginID);
             $existing_guid = null;
             if ($existing_plugin) {
                 $existing_guid = $existing_plugin->guid;
             }
             // load the rest of the plugin
             parent::__construct($existing_guid);
         }
     }
     _elgg_cache_plugin_by_id($this);
 }
Example #18
0
File: start.php Project: xop32/Elgg
function developers_process_settings()
{
    $settings = elgg_get_plugin_from_id('developers')->getAllSettings();
    ini_set('display_errors', (int) (!empty($settings['display_errors'])));
    if (!empty($settings['screen_log'])) {
        $cache = new ElggLogCache();
        elgg_set_config('log_cache', $cache);
        elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump'));
        elgg_register_plugin_hook_handler('view_vars', 'page/elements/html', function ($hook, $type, $vars, $params) {
            $vars['body'] .= elgg_view('developers/log');
            return $vars;
        });
    }
    if (!empty($settings['show_strings'])) {
        // first and last in case a plugin registers a translation in an init method
        elgg_register_event_handler('init', 'system', 'developers_clear_strings', 1000);
        elgg_register_event_handler('init', 'system', 'developers_clear_strings', 1);
    }
    if (!empty($settings['show_modules'])) {
        elgg_require_js('elgg/dev/amd_monitor');
    }
    if (!empty($settings['wrap_views'])) {
        elgg_register_plugin_hook_handler('view', 'all', 'developers_wrap_views', 600);
    }
    if (!empty($settings['log_events'])) {
        elgg_register_event_handler('all', 'all', 'developers_log_events', 1);
        elgg_register_plugin_hook_handler('all', 'all', 'developers_log_events', 1);
    }
    if (!empty($settings['show_gear']) && elgg_is_admin_logged_in() && !elgg_in_context('admin')) {
        elgg_require_js('elgg/dev/gear');
        elgg_load_js('lightbox');
        elgg_load_css('lightbox');
        elgg_register_ajax_view('developers/gear_popup');
        elgg_register_simplecache_view('elgg/dev/gear.html');
        // TODO use ::class in 2.0
        $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSectionVars'];
        elgg_register_plugin_hook_handler('view_vars', 'navigation/menu/elements/section', $handler);
        $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSections'];
        elgg_register_plugin_hook_handler('view', 'navigation/menu/elements/section', $handler);
    }
}
 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $plugins = elgg_get_plugins('active');
     if (empty($plugins)) {
         system_message('All plugins are inactive');
         return;
     }
     $ids = array_map(function (ElggPlugin $plugin) {
         return $plugin->getID();
     }, $plugins);
     $ids = array_values($ids);
     if ($this->option('all')) {
         $deactivate_ids = $ids;
     } else {
         $helper = $this->getHelper('question');
         $question = new ChoiceQuestion('Please select plugins you would like to deactivate (comma-separated list of indexes)', $ids);
         $question->setMultiselect(true);
         $deactivate_ids = $helper->ask($this->input, $this->output, $question);
     }
     if (empty($deactivate_ids)) {
         throw new RuntimeException('You must select at least one plugin');
     }
     $plugins = [];
     foreach ($deactivate_ids as $plugin_id) {
         $plugins[] = elgg_get_plugin_from_id($plugin_id);
     }
     foreach ($plugins as $plugin) {
         if (!$plugin->isActive()) {
             continue;
         }
         if (!$plugin->deactivate()) {
             $msg = $plugin->getError();
             $string = $msg ? 'admin:plugins:deactivate:no_with_msg' : 'admin:plugins:deactivate:no';
             register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
         } else {
             system_message("Plugin {$plugin->getFriendlyName()} has been deactivated");
         }
     }
     elgg_flush_caches();
 }
Example #20
0
/**
 * Authenticate user against the credential
 *
 * @param array $credentials
 * @return boolean
 */
function ldap_auth_authenticate($credentials)
{
    $settings = elgg_get_plugin_from_id('ldap_auth');
    $server = ldap_auth_get_server();
    if (!$server) {
        // Unable to connect to LDAP server
        register_error(elgg_echo('ldap_auth:connection_error'));
        return false;
    }
    $settings = elgg_get_plugin_from_id('ldap_auth');
    $username = elgg_extract('username', $credentials);
    $password = elgg_extract('password', $credentials);
    $filter = "({$settings->filter_attr}={$username})";
    if (!$server->bind()) {
        register_error(elgg_echo('ldap_auth:connection_error'));
        return false;
    }
    $result = $server->search($filter);
    if (empty($result)) {
        // User was not found
        return false;
    }
    // Bind using user's distinguished name and password
    $success = $server->bind($result['dn'], $password);
    if (!$success) {
        // dn/password combination doesn't exist
        return false;
    }
    $user = get_user_by_username($username);
    if ($user) {
        return login($user);
    }
    if ($settings->create_user !== 'off') {
        return ldap_auth_create_user($username, $password, $result);
    }
    register_error(elgg_echo("ldap_auth:no_account"));
    return false;
}
Example #21
0
function basic_init()
{
    $action_path = dirname(__FILE__) . '/actions';
    elgg_register_action("basic_light/admin/settings", "{$action_path}/settings.php", 'admin');
    elgg_register_action("basic_light/admin/sidebar", "{$action_path}/settings.php", 'admin');
    $plugin = elgg_get_plugin_from_id('basic_light');
    if ($plugin->show_thewire == 'yes') {
        elgg_register_action("basic_light/add", "{$action_path}/add.php");
        elgg_extend_view('js/elgg', 'js/basic_light/update');
    }
    elgg_register_event_handler('pagesetup', 'system', 'basic_pagesetup_handler', 1000);
    elgg_register_admin_menu_item('configure', 'basic_light', 'settings');
    elgg_extend_view('css/elgg', 'basic_light/css');
    elgg_extend_view('css/admin', 'basic_light/admin');
    elgg_unregister_js('elgg.friendspicker');
    if (elgg_is_logged_in() && elgg_get_context() == 'activity') {
        if ($plugin->show_thewire == 'yes') {
            elgg_extend_view('page/layouts/content/header', 'page/elements/riverwire', 1);
        }
        if ($plugin->show_icon != 'no') {
            elgg_extend_view('page/elements/' . $plugin->show_icon, 'page/elements/rivericon', '501');
        }
        if ($plugin->show_menu != 'no') {
            elgg_extend_view('page/elements/' . $plugin->show_menu, 'page/elements/ownermenu', '502');
        }
    }
    if (elgg_get_context() == 'activity' || elgg_get_context() == 'thewire') {
        if ($plugin->show_custom != 'no') {
            elgg_extend_view('page/elements/' . $plugin->show_custom, 'page/elements/custom_module', 504);
        }
    }
    themes_register_themes();
    $theme = elgg_get_plugin_setting('active_theme', 'basic_light');
    if ($theme != 'default' && elgg_get_context() != 'admin') {
        elgg_load_css($theme);
    }
}
Example #22
0
/**
 * Shorthand function for finding the plugin settings.
 *
 * @deprecated 1.8 Use elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()
 *
 * @param string $plugin_id Optional plugin id, if not specified
 *                          then it is detected from where you are calling.
 *
 * @return mixed
 */
function find_plugin_settings($plugin_id = null)
{
    elgg_deprecated_notice('find_plugin_setting() is deprecated by elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()', 1.8);
    if ($plugin_id) {
        return elgg_get_plugin_from_id($plugin_id);
    } else {
        return elgg_get_calling_plugin_entity();
    }
}
Example #23
0
<?php

/**
 * Save Tidypics plugin settings
 *
 * @author Cash Costello
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
 */
$plugin = elgg_get_plugin_from_id('tidypics');
$params = get_input('params');
foreach ($params as $k => $v) {
    if (!$plugin->setSetting($k, $v)) {
        register_error(elgg_echo('plugins:settings:save:fail', array('tidypics')));
        forward(REFERER);
    }
}
// image sizes
$image_sizes = array();
$image_sizes['large_image_width'] = get_input('large_image_width');
$image_sizes['large_image_height'] = get_input('large_image_height');
$image_sizes['small_image_width'] = get_input('small_image_width');
$image_sizes['small_image_height'] = get_input('small_image_height');
$image_sizes['tiny_image_width'] = get_input('tiny_image_width');
$image_sizes['tiny_image_height'] = get_input('tiny_image_height');
$plugin->setSetting('image_sizes', serialize($image_sizes));
system_message(elgg_echo('tidypics:settings:save:ok'));
forward(REFERER);
Example #24
0
/**
 * Generate a unsubscribe code to be used in validation
 *
 * @param ElggEntity $container Which newsletter container (ElggSite or ElggGroup)
 * @param string|int $recipient The user_guid or email address of the recipient
 *
 * @return bool|string The unsubscribe code or false on failure
 */
function newsletter_generate_unsubscribe_code(ElggEntity $container, $recipient)
{
    $result = false;
    if (!empty($container) && (elgg_instanceof($container, "site") || elgg_instanceof($container, "group")) && !empty($recipient)) {
        // make sure we have a user_guid or email address
        if (is_numeric($recipient) || newsletter_is_email_address($recipient)) {
            $plugin = elgg_get_plugin_from_id("newsletter");
            $result = hash_hmac("sha256", $container->getGUID() . "|" . $recipient . "|" . $plugin->time_created, get_site_secret());
        }
    }
    return $result;
}
 /**
  * Checks if $plugins meets the requirement by $dep.
  *
  * @param array $dep     An Elgg manifest.xml deps array
  * @param array $plugins A list of plugins as returned by elgg_get_plugins();
  * @param bool  $inverse Inverse the results to use as a conflicts.
  * @return bool
  */
 private function checkDepPriority(array $dep, array $plugins, $inverse = false)
 {
     // grab the ElggPlugin using this package.
     $plugin_package = elgg_get_plugin_from_id($this->getID());
     $plugin_priority = $plugin_package->getPriority();
     $test_plugin = elgg_get_plugin_from_id($dep['plugin']);
     // If this isn't a plugin or the plugin isn't installed or active
     // priority doesn't matter. Use requires to check if a plugin is active.
     if (!$plugin_package || !$test_plugin || !$test_plugin->isActive()) {
         return array('status' => true, 'value' => 'uninstalled');
     }
     $test_plugin_priority = $test_plugin->getPriority();
     switch ($dep['priority']) {
         case 'before':
             $status = $plugin_priority < $test_plugin_priority;
             break;
         case 'after':
             $status = $plugin_priority > $test_plugin_priority;
             break;
         default:
             $status = false;
     }
     // get the current value
     if ($plugin_priority < $test_plugin_priority) {
         $value = 'before';
     } else {
         $value = 'after';
     }
     if ($inverse) {
         $status = !$status;
     }
     return array('status' => $status, 'value' => $value);
 }
Example #26
0
<?php

elgg_push_context('widgets');
global $CONFIG, $vars;
$config = elgg_get_plugin_from_id('igolf_news');
function catch_that_image($content)
{
    $first_img = '';
    ob_start();
    ob_end_clean();
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
    $first_img = $matches[1][0];
    if (empty($first_img)) {
        $first_img = "images/noimages.jpg";
    }
    return $first_img;
}
$conn = mysqli_connect($config->mysqlhostname, $config->mysqluser, $config->mysqlpass, $config->mysqldbname, $config->mysqlport);
$sql = "SELECT post_date,post_content,post_title,post_status,post_type,guid FROM wp_posts WHERE post_status='publish' AND post_type='post' LIMIT 10";
$query = mysqli_query($conn, $sql) or die(mysqli_error());
echo "<div class='elgg-module elgg-module-highlight elgg-module-featured'>";
echo "<div class='elgg-head'><h3>Latest News</h3></div>";
echo "<div class='elgg-body'>";
echo "<ul class='igolf-news'>";
while ($row1 = mysqli_fetch_array($query)) {
    echo "<li>";
    ?>
	<img src="<?php 
    echo catch_that_image($row1['post_content']);
    ?>
" />
Example #27
0
    elgg_set_plugin_setting('phototag', $pointssettings->phototag, 'elggx_userpoints');
    elgg_set_plugin_setting('discussion_reply', $pointssettings->group_topic_post, 'elggx_userpoints');
    elgg_set_plugin_setting('login', $pointssettings->login, 'elggx_userpoints');
    elgg_set_plugin_setting('delete', $pointssettings->delete, 'elggx_userpoints');
    elgg_set_plugin_setting('invite', $pointssettings->invite, 'elggx_userpoints');
    elgg_set_plugin_setting('verify_email', $pointssettings->verify_email, 'elggx_userpoints');
    elgg_set_plugin_setting('require_registration', $pointssettings->require_registration, 'elggx_userpoints');
    elgg_set_plugin_setting('expire_invite', $pointssettings->expire_invite, 'elggx_userpoints');
    // Set new version
    elgg_set_plugin_setting('version', '1.9.8', 'elggx_userpoints');
} else {
    if ($current_version < '1.9.7') {
        $pointssettings = elgg_get_plugin_from_id('elggx_userpoints');
        elgg_set_plugin_setting('discussion_reply', $pointssettings->group_topic_post, 'elggx_userpoints');
        elgg_set_plugin_setting('comment', $pointssettings->generic_comment, 'elggx_userpoints');
        // Set new version
        elgg_set_plugin_setting('version', '1.9.8', 'elggx_userpoints');
    } else {
        if ($current_version < '1.9.8') {
            $pointssettings = elgg_get_plugin_from_id('elggx_userpoints');
            elgg_set_plugin_setting('comment', $pointssettings->generic_comment, 'elggx_userpoints');
            // Set new version
            elgg_set_plugin_setting('version', '1.9.8', 'elggx_userpoints');
        }
    }
}
$current_version = elgg_get_plugin_setting('version', 'elggx_userpoints');
if ($current_version != '1.9.8') {
    // Set new version
    elgg_set_plugin_setting('version', '1.9.8', 'elggx_userpoints');
}
Example #28
0
<?php

/**
 * Custom Content
 *
 */
$plugin = elgg_get_plugin_from_id('basic_light');
$html = $plugin->html_content;
$title = elgg_echo("basic_light:demo:title");
//$text = elgg_echo("basic_light:demo:text");
echo elgg_view_module('aside', $title, $html);
<?php

/**
* 	Plugin: Valoraciones linguisticas con HFLTS
*	Author: Rosana Montes Soldado
*			Universidad de Granada
*	Licence: 	CC-ByNCSA
*	Reference:	Microproyecto CEI BioTIC Ref. 11-2015
* 	Project coordinator: @rosanamontes
*	Website: http://lsi.ugr.es/rosana
*	
*	File: Developer settings
*/
$plugin = elgg_get_plugin_from_id('hflts');
$data = array('aggOperator' => array('type' => 'dropdown', 'value' => $plugin->aggOperator, 'options_values' => array('0' => elgg_echo('hflts:aggOperator:minmax'), '1' => elgg_echo('hflts:aggOperator:HLWA')), 'readonly' => false), 'termset' => array('type' => 'dropdown', 'value' => $plugin->termset, 'options_values' => array('0' => elgg_echo('hflts:settings:s3'), '1' => elgg_echo('hflts:settings:s5'), '2' => elgg_echo('hflts:settings:s7')), 'readonly' => false), 'profile_display' => array('type' => 'dropdown', 'value' => $plugin->profile_display, 'options_values' => array('1' => elgg_echo('hflts:settings:yes'), '0' => elgg_echo('hflts:settings:no')), 'readonly' => false), 'auto_moderation' => array('type' => 'dropdown', 'value' => $plugin->auto_moderation, 'options_values' => array('1' => elgg_echo('hflts:settings:yes'), '0' => elgg_echo('hflts:settings:no')), 'readonly' => false), 'weight_experts' => array('type' => 'dropdown', 'value' => $plugin->weight_experts, 'options_values' => array('1' => elgg_echo('hflts:settings:yes'), '0' => elgg_echo('hflts:settings:no')), 'readonly' => false), 'base_expertise' => array('type' => 'range', 'value' => $plugin->base_expertise, 'readonly' => false), 'weight_assessments' => array('type' => 'dropdown', 'value' => $plugin->weight_assessments, 'options_values' => array('1' => elgg_echo('hflts:settings:yes'), '0' => elgg_echo('hflts:settings:no')), 'readonly' => false));
/*$form .= "<br><br><b>" . elgg_echo('elggx_userpoints:settings:profile_display') . "</b>";
$form .= elgg_view('input/dropdown', array(
                'name' => 'params[profile_display]',
                'options_values' => array('1' => elgg_echo('elggx_userpoints:settings:yes'), '0' => elgg_echo('elggx_userpoints:settings:no')),
                'value' => $plugin->profile_display
));
*/
$form_vars = array('id' => 'hflts-settings-form', 'class' => 'elgg-form-settings');
$body_vars = array('data' => $data);
echo elgg_view_form('hflts/settings', $form_vars, $body_vars);
Example #30
0
$user = elgg_get_logged_in_user_entity();
$username = $user->username;
$two_plugin = elgg_get_plugin_from_id('twoapp2');
//$g_token = $two_plugin->getUserSetting($name2.'token', $user->guid );
//$g_secret = $two_plugin->getUserSetting($name2.'secret', $user->guid );
//if no show two API keys
$r = elgg_get_entities(array('types' => 'object', 'subtypes' => 'appname', 'title' => $name2));
//if(!elgg_get_entities(array('types' => 'object',
//'subtypes' => 'appname', 'title'=>$name2)))
if (!get_subtype_id('object', 'app' . $name2)) {
    //register_error( elgg_echo("show two application not register!!"));
    //forward(REFERER);
    echo $name2 . "  application not register!!";
} else {
    if (elgg_get_entities(array('types' => 'object', 'subtypes' => 'appname', 'title' => 'app' . $name2, 'owner_guid' => elgg_get_logged_in_user_guid()))) {
        $user_plugin = elgg_get_plugin_from_id('userAPI');
        $user2_public = $user_plugin->getUserSetting($name2 . 'public', $user->guid);
        $user2_private = $user_plugin->getUserSetting($name2 . 'private', $user->guid);
        //
        /*if($user2_public && $user2_private)
        {
        
        
        ///system_message( elgg_echo("you are get token and secret for show two application from:usersettings/configureyourtools/get_token"));
        //forward(REFERER);
        
        
        echo "</br>Your Public key   :  ";
        echo $user2_public;
        echo "</br>Your private key  :  ";
        echo $user2_private;