Пример #1
0
/**
 * Profile page handler
 *
 * @param array $page Array of URL segments passed by the page handling mechanism
 * @return bool
 */
function profile_page_handler($page)
{
    if (isset($page[0])) {
        $username = $page[0];
        $user = get_user_by_username($username);
        elgg_set_page_owner_guid($user->guid);
    } elseif (elgg_is_logged_in()) {
        forward(elgg_get_logged_in_user_entity()->getURL());
    }
    // short circuit if invalid or banned username
    if (!$user || $user->isBanned() && !elgg_is_admin_logged_in()) {
        register_error(elgg_echo('profile:notfound'));
        forward();
    }
    $action = NULL;
    if (isset($page[1])) {
        $action = $page[1];
    }
    if ($action == 'edit') {
        // use the core profile edit page
        $base_dir = elgg_get_root_path();
        require "{$base_dir}pages/profile/edit.php";
        return true;
    }
    $content = elgg_view('profile/layout', array('entity' => $user));
    $body = elgg_view_layout('one_column', array('content' => $content));
    echo elgg_view_page($user->name, $body);
    return true;
}
Пример #2
0
/**
 * Profile page handler
 *
 * @param array $page Array of page elements, forwarded by the page handling mechanism
 */
function profile_page_handler($page)
{
    if (isset($page[0])) {
        $username = $page[0];
        $user = get_user_by_username($username);
        elgg_set_page_owner_guid($user->guid);
    }
    // short circuit if invalid or banned username
    if (!$user || $user->isBanned() && !elgg_is_admin_logged_in()) {
        register_error(elgg_echo('profile:notfound'));
        forward();
    }
    $action = NULL;
    if (isset($page[1])) {
        $action = $page[1];
    }
    if ($action == 'edit') {
        // use the core profile edit page
        $base_dir = elgg_get_root_path();
        require "{$base_dir}pages/profile/edit.php";
        return;
    }
    // main profile page
    $params = array('content' => elgg_view('profile/wrapper'), 'num_columns' => 3);
    $content = elgg_view_layout('widgets', $params);
    $body = elgg_view_layout('one_column', array('content' => $content));
    echo elgg_view_page($title, $body);
}
Пример #3
0
/**
 * Returns a list of upgrade files relative to the $upgrade_path dir.
 *
 * @param string $upgrade_path The directory that has upgrade scripts
 * @return array|false
 * @access private
 *
 * @todo the wire and groups plugins and the installer are using this
 */
function elgg_get_upgrade_files($upgrade_path = null)
{
    if (!$upgrade_path) {
        $upgrade_path = elgg_get_root_path() . 'engine/lib/upgrades/';
    }
    $upgrade_path = sanitise_filepath($upgrade_path);
    $handle = opendir($upgrade_path);
    if (!$handle) {
        return false;
    }
    $upgrade_files = array();
    while ($upgrade_file = readdir($handle)) {
        // make sure this is a well formed upgrade.
        if (is_dir($upgrade_path . '$upgrade_file')) {
            continue;
        }
        $upgrade_version = elgg_get_upgrade_file_version($upgrade_file);
        if (!$upgrade_version) {
            continue;
        }
        $upgrade_files[] = $upgrade_file;
    }
    sort($upgrade_files);
    return $upgrade_files;
}
Пример #4
0
function hj_framework_init()
{
    $path_libraries = elgg_get_root_path() . 'mod/hypeFramework/lib/';
    elgg_register_library('framework:base', $path_libraries . 'base.php');
    elgg_load_library('framework:base');
    hj_framework_check_release('hypeFramework', HYPEFRAMEWORK_RELEASE);
    // Classes
    elgg_register_classes(elgg_get_root_path() . 'mod/hypeFramework/classes/');
    // Libraries
    $libraries = array('forms', 'page_handlers', 'actions', 'assets', 'views', 'ajax', 'menus', 'files', 'lists', 'hierarchies', 'location', 'knowledge', 'deprecated');
    foreach ($libraries as $lib) {
        $path = "{$path_libraries}{$lib}.php";
        if (file_exists($path)) {
            elgg_register_library("framework:library:{$lib}", $path);
            elgg_load_library("framework:library:{$lib}");
        }
    }
    // Vendor Libraries
    // DomPDF library is not included by default
    // Download and unzip to vendors/dompdf
    $dompdf = elgg_get_root_path() . 'mod/hypeFramework/vendors/dompdf/dompdf_config.inc.php';
    if (file_exists($dompdf)) {
        elgg_register_library('framework:dompdf', $dompdf);
    }
}
Пример #5
0
/**
 * Page handlers for hypeFramework
 *
 *
 * @param type $page
 * @return type
 */
function hj_framework_page_handlers($page)
{
    if (!isset($page[0])) {
        forward();
    }
    $path_pages = elgg_get_root_path() . 'mod/hypeFramework/pages/';
    switch ($page[0]) {
        case 'edit':
            set_input('guid', $page[1]);
            include $path_pages . 'edit/object.php';
            break;
        case 'icon':
            set_input('guid', $page[1]);
            set_input('size', $page[2]);
            include $path_pages . "icon/icon.php";
            break;
        case 'download':
            set_input('guid', $page[1]);
            include $path_pages . "file/download.php";
            break;
        case 'file':
            switch ($page[1]) {
                case 'create':
                    gatekeeper();
                    $container_guid = elgg_extract(2, $page, false);
                    if (!$container_guid) {
                        $container_guid = elgg_get_logged_in_user_guid();
                    }
                    elgg_set_page_owner_guid($container_guid);
                    set_input('container_guid', $container_guid);
                    include "{$path_pages}create/file.php";
                    break;
                case 'edit':
                    gatekeeper();
                    set_input('guid', $page[2]);
                    include "{$path_pages}edit/object.php";
                    break;
                case 'view':
                    if (!isset($page[2])) {
                        return false;
                    }
                    $entity = get_entity($page[2]);
                    if (!$entity) {
                        return false;
                    }
                    $sidebar = elgg_view('framework/file/dashboard/sidebar', array('entity' => $entity));
                    echo elgg_view_page($entity->title, elgg_view_layout('framework/entity', array('entity' => $entity, 'sidebar' => $sidebar)));
                    break;
            }
            break;
        default:
            return false;
            break;
    }
    return true;
}
Пример #6
0
/**
 * Gets called when the Elgg system initializes
 *
 * @return void
 */
function fontawesome_init()
{
    // add CSS / JS
    elgg_extend_view("css/elements/forms", "css/fontawesome/forms");
    elgg_extend_view("css/admin", "css/fontawesome/admin");
    // register css
    $root_path = elgg_get_root_path();
    $plugins_path = elgg_get_plugins_path();
    if (file_exists("{$root_path}/vendor/fortawesome/font-awesome/css/font-awesome.min.css")) {
        // this plugin was installed as a composer dependency
        elgg_register_css("fontawesome", "vendor/fortawesome/font-awesome/css/font-awesome.min.css");
    } elseif (file_exists("{$plugins_path}/fontawesome/vendor/fortawesome/font-awesome/css/font-awesome.min.css")) {
        // this plugin was installed stand-alone
        elgg_register_css("fontawesome", "mod/fontawesome/vendor/fortawesome/font-awesome/css/font-awesome.min.css");
    }
    elgg_load_css("fontawesome");
}
/**
 * The profile page handler
 *
 * @param array $page page elements
 *
 * @return bool
 */
function theme_haarlem_intranet_profile_page_handler($page)
{
    $user = false;
    if (isset($page[0])) {
        $username = $page[0];
        $user = get_user_by_username($username);
        if (!empty($user)) {
            elgg_set_page_owner_guid($user->getGUID());
        }
    }
    if (empty($user) && elgg_is_logged_in()) {
        forward(elgg_get_logged_in_user_entity()->getURL());
    }
    // short circuit if invalid or banned username
    if (empty($user) || $user->isBanned() && !elgg_is_admin_logged_in()) {
        register_error(elgg_echo("profile:notfound"));
        forward();
    }
    $action = false;
    if (isset($page[1])) {
        $action = $page[1];
    }
    if ($action == "edit") {
        // use the core profile edit page
        $base_dir = elgg_get_root_path();
        require $base_dir . "pages/profile/edit.php";
        return true;
    }
    $menu = elgg_trigger_plugin_hook('register', "menu:user_hover", array('entity' => $user), array());
    $builder = new ElggMenuBuilder($menu);
    $menu = $builder->getMenu();
    $content = '<table id="theme-haarlem-intranet-profile"><tr><td>' . elgg_view("profile/owner_block", array("entity" => $user, 'menu' => $menu));
    $content .= '</td><td>';
    if (!theme_haarlem_is_extranet()) {
        $content .= elgg_view("profile/details", array("entity" => $user, 'menu' => $menu));
    } else {
        $content .= elgg_view("profile/extranet", array("entity" => $user, 'menu' => $menu));
    }
    $content .= '</td></tr></table>';
    $sidebar = elgg_view('theme_haarlem_intranet/profile/group_membership', array('entity' => $user));
    // view profile
    $body = elgg_view_layout("one_sidebar", array("content" => $content, 'menu' => $menu, 'layout' => 'content', 'sidebar' => $sidebar));
    echo elgg_view_page($user->name, $body);
    return true;
}
Пример #8
0
 /**
  * Returns array of suggestions of plugin keys that could probably be replaced with core keys
  */
 public function getSuggestions()
 {
     $suggestions = [];
     $plugin_translations = $this->plugin_language_keys;
     $plugin_translations = array_map('strtolower', $plugin_translations);
     $core_translations = (include elgg_get_root_path() . 'languages/en.php');
     $core_translations = array_map('strtolower', $core_translations);
     foreach ($plugin_translations as $plugin_key => $plugin_value) {
         foreach ($core_translations as $core_key => $core_value) {
             similar_text($plugin_value, $core_value, $similarity);
             if ($similarity > 90) {
                 $suggestions[$plugin_key] = $core_key;
                 break;
             }
         }
     }
     return $suggestions;
 }
Пример #9
0
/**
 * Return the url to the FontAwesome CSS
 *
 * @param bool $realpath return the file location
 *
 * @return false|string
 */
function fontawesome_get_css_location($realpath = false)
{
    $realpath = (bool) $realpath;
    $externals = elgg_get_config('externals_map');
    if (empty($externals) || !is_array($externals)) {
        return false;
    }
    $css = elgg_extract('css', $externals);
    if (empty($css) || !is_array($css)) {
        return false;
    }
    $fa = elgg_extract('fontawesome', $css);
    if (empty($fa)) {
        return false;
    }
    $result = elgg_normalize_url($fa->url);
    if ($realpath) {
        $result = str_ireplace(elgg_get_site_url(), elgg_get_root_path(), $result);
    }
    return $result;
}
Пример #10
0
function theme_eersel_profile_page_handler($page)
{
    $user = false;
    if (isset($page[0])) {
        $username = $page[0];
        $user = get_user_by_username($username);
        if (!empty($user)) {
            elgg_set_page_owner_guid($user->getGUID());
        }
    }
    if (empty($user) && elgg_is_logged_in()) {
        forward(elgg_get_logged_in_user_entity()->getURL());
    }
    // short circuit if invalid or banned username
    if (empty($user) || $user->isBanned() && !elgg_is_admin_logged_in()) {
        register_error(elgg_echo("profile:notfound"));
        forward();
    }
    $action = false;
    if (isset($page[1])) {
        $action = $page[1];
    }
    if ($action == "edit") {
        // use the core profile edit page
        $base_dir = elgg_get_root_path();
        require $base_dir . "pages/profile/edit.php";
        return true;
    }
    // view profile
    $sidebar = "";
    $content = elgg_view("profile/details", array("entity" => $user));
    $title = $user->name;
    if (elgg_is_logged_in()) {
        $sidebar = elgg_view("profile/owner_block");
        $content .= elgg_view_layout('widgets', array('num_columns' => 2));
    }
    $body = elgg_view_layout("two_sidebar", array("title" => $title, "content" => $content, "sidebar" => $sidebar, "filter" => false, "class" => "theme-eersel-profile-page"));
    echo elgg_view_page($user->name, $body);
    return true;
}
Пример #11
0
/**
 * Init function for Profile Sync
 *
 * @return void
 */
function profile_sync_init()
{
    elgg_extend_view('css/admin', 'css/profile_sync/admin');
    // register ajax views
    elgg_register_ajax_view('profile_sync/forms/datasource');
    elgg_register_ajax_view('profile_sync/forms/sync_config');
    elgg_register_ajax_view('profile_sync/sync_logs');
    elgg_register_ajax_view('profile_sync/view_log');
    elgg_register_ajax_view('profile_sync/sync_config/run');
    elgg_register_admin_menu_item('configure', 'profile_sync', 'configure_utilities');
    // register hooks
    elgg_register_plugin_hook_handler('register', 'menu:entity', '\\ColdTrick\\ProfileSync\\EntityMenu::addDataSourceMenus');
    elgg_register_plugin_hook_handler('register', 'menu:entity', '\\ColdTrick\\ProfileSync\\EntityMenu::addSyncConfigMenus');
    elgg_register_plugin_hook_handler('cron', 'all', '\\ColdTrick\\ProfileSync\\Cron::runSyncs');
    elgg_register_plugin_hook_handler('permissions_check:comment', 'object', '\\ColdTrick\\ProfileSync\\Comments::disallowComments');
    // register actions
    elgg_register_action('profile_sync/datasource/edit', dirname(__FILE__) . '/actions/datasource/edit.php', 'admin');
    elgg_register_action('profile_sync/datasource/delete', elgg_get_root_path() . '/actions/entities/delete.php', 'admin');
    elgg_register_action('profile_sync/sync_config', dirname(__FILE__) . '/actions/sync_config/edit.php', 'admin');
    elgg_register_action('profile_sync/sync_config/delete', elgg_get_root_path() . '/actions/entities/delete.php', 'admin');
    elgg_register_action('profile_sync/sync_config/run', dirname(__FILE__) . '/actions/sync_config/run.php', 'admin');
}
Пример #12
0
/**
 * Page handler for register and invite-only page
 *
 * @param array $page_elements Page elements
 * @param string $handler The handler string
 *
 * @return bool
 */
function inviteonly_page_handler($page_elements, $handler)
{
    if ($handler == 'invite-only') {
        require_once elgg_get_plugins_path() . 'inviteonly/pages/inviteonly.php';
        return true;
    }
    if ($handler == 'register') {
        if (get_input('invitecode') && get_input('friend_guid')) {
            $friend = get_user(get_input('friend_guid'));
            if (!elgg_instanceof($friend, 'user')) {
                return inviteonly_redirect();
            }
            $friend_invitecode = generate_invite_code($friend->username);
            if ($friend_invitecode !== get_input('invitecode')) {
                return inviteonly_redirect();
            }
            require_once elgg_get_root_path() . 'pages/account/register.php';
            return true;
        }
        return inviteonly_redirect();
    }
    return false;
}
Пример #13
0
 /**
  * Setup views for a given role
  * 
  * @param ElggRole $role Role
  * @return void
  */
 public function setupViews(\ElggRole $role)
 {
     $role_perms = $this->getPermissions($role, 'views');
     foreach ($role_perms as $view => $perm_details) {
         switch ($perm_details['rule']) {
             case self::DENY:
                 elgg_register_plugin_hook_handler('view', $view, array($this, 'supressView'));
                 break;
             case self::EXTEND:
                 $params = $perm_details['view_extension'];
                 $view_extension = $this->replaceDynamicPaths($params['view']);
                 $priority = isset($params['priority']) ? $params['priority'] : 501;
                 $viewtype = isset($params['viewtype']) ? $params['viewtype'] : '';
                 elgg_extend_view($view, $view_extension, $priority, $viewtype);
                 break;
             case self::REPLACE:
                 $params = $perm_details['view_replacement'];
                 $location = elgg_get_root_path() . $this->replaceDynamicPaths($params['location']);
                 $viewtype = isset($params['viewtype']) ? $params['viewtype'] : '';
                 elgg_set_view_location($view, $location, $viewtype);
                 break;
             case self::ALLOW:
                 elgg_unregister_plugin_hook_handler('view', $view, array($this, 'supressView'));
                 break;
         }
     }
 }
Пример #14
0
<?php

$data = elgg_extract("data", $vars);
if (empty($data)) {
    return;
}
$views = elgg_extract('views', $data);
$global_hooks = elgg_extract('global_hooks', $data);
$filtered_views = elgg_extract('filtered_views', $data);
$input_filtered_views = (array) elgg_extract('input_filtered_views', $data);
$root = elgg_get_root_path();
$strip = function ($file) use($root) {
    return 0 === strpos($file, $root) ? substr($file, strlen($root)) : $file;
};
$make_id = function ($view) {
    return "z" . md5($view);
};
$viewtype = elgg_extract("viewtype", $vars);
$viewtypes = elgg_extract("viewtypes", $vars);
foreach ($viewtypes as $type) {
    $href = "admin/develop_tools/inspect?inspect_type=Views";
    if ($type !== "default") {
        $href .= "&type={$type}";
    }
    elgg_register_menu_item('developers_inspect_viewtype', array('name' => $type, 'text' => $type, 'href' => $href));
}
echo elgg_view_menu('developers_inspect_viewtype', array('class' => 'elgg-tabs mbm'));
if ($global_hooks) {
    array_walk($global_hooks, function (&$hook) {
        $id = "z" . md5($hook);
        $hook = "<a href='?inspect_type=Plugin%20Hooks#{$id}'>{$hook}</a>";
Пример #15
0
/**
 * Page handler for account related pages
 *
 * @param array  $page_elements Page elements
 * @param string $handler The handler string
 *
 * @return bool
 * @access private
 */
function elgg_user_account_page_handler($page_elements, $handler)
{
    $base_dir = elgg_get_root_path() . 'pages/account';
    switch ($handler) {
        case 'login':
            require_once "{$base_dir}/login.php";
            break;
        case 'forgotpassword':
            require_once "{$base_dir}/forgotten_password.php";
            break;
        case 'resetpassword':
            require_once "{$base_dir}/reset_password.php";
            break;
        case 'register':
            require_once "{$base_dir}/register.php";
            break;
        default:
            return false;
    }
    return true;
}
Пример #16
0
/**
 * Initialize the plugin system
 *
 * @return void
 * @access private
 */
function _elgg_plugins_init()
{
    if (elgg_is_admin_logged_in()) {
        elgg_register_ajax_view('object/plugin/full');
    }
    elgg_register_plugin_hook_handler('unit_test', 'system', '_elgg_plugins_test');
    // note - plugins are booted by the time this handler is registered
    // deactivation due to error may have already occurred
    elgg_register_event_handler('deactivate', 'plugin', '_plugins_deactivate_dependency_check');
    elgg_register_action("plugins/settings/save", '', 'admin');
    elgg_register_action("plugins/usersettings/save");
    elgg_register_action('admin/plugins/activate', '', 'admin');
    elgg_register_action('admin/plugins/deactivate', '', 'admin');
    elgg_register_action('admin/plugins/activate_all', '', 'admin');
    elgg_register_action('admin/plugins/deactivate_all', '', 'admin');
    elgg_register_action('admin/plugins/set_priority', '', 'admin');
    elgg_register_library('elgg:markdown', elgg_get_root_path() . 'vendors/markdown/markdown.php');
}
Пример #17
0
/**
 * Serves up screenshots for plugins from
 * admin_plugin_screenshot/<plugin_id>/<size>/<ss_name>.<ext>
 *
 * @param array $pages The pages array
 * @return bool
 * @access private
 */
function admin_plugin_screenshot_page_handler($pages)
{
    // only admins can use this for security
    admin_gatekeeper();
    $plugin_id = elgg_extract(0, $pages);
    // only thumbnail or full.
    $size = elgg_extract(1, $pages, 'thumbnail');
    // the rest of the string is the filename
    $filename_parts = array_slice($pages, 2);
    $filename = implode('/', $filename_parts);
    $filename = sanitise_filepath($filename, false);
    $plugin = new ElggPlugin($plugin_id);
    if (!$plugin) {
        $file = elgg_get_root_path() . '_graphics/icons/default/medium.png';
    } else {
        $file = $plugin->getPath() . $filename;
        if (!file_exists($file)) {
            $file = elgg_get_root_path() . '_graphics/icons/default/medium.png';
        }
    }
    header("Content-type: image/jpeg");
    // resize to 100x100 for thumbnails
    switch ($size) {
        case 'thumbnail':
            echo get_resized_image_from_existing_file($file, 100, 100, true);
            break;
        case 'full':
        default:
            echo file_get_contents($file);
            break;
    }
    return true;
}
Пример #18
0
if (!$album->save()) {
    register_error(elgg_echo('gallery:save:error'));
    forward(REFERER);
} else {
    // Update image access if album access has changed
    if ($guid && $previous_access_id !== $album->access_id) {
        $images = new ElggBatch('elgg_get_entities', array('types' => 'object', 'subtypes' => hjAlbumImage::SUBTYPE, 'container_guids' => $album->guid, 'limit' => 0));
        foreach ($images as $image) {
            $image->access_id = $album->access_id;
            $image->save();
        }
    }
    system_message(elgg_echo('gallery:save:success'));
}
if ($location) {
    $album->location = $location;
    $coordinates = elgg_trigger_plugin_hook('geocode', 'location', array('location' => $location));
    if ($coordinates) {
        $album->setLatLong($coordinates['lat'], $coordinates['long']);
    }
}
$album->date = $date;
$album->categories = string_to_tag_array($categories);
$album->tags = string_to_tag_array($tags);
$album->permission = $permission;
$album->save();
set_input('container_guid', $album->guid);
include elgg_get_root_path() . 'mod/hypeGallery/actions/upload/handle.php';
include elgg_get_root_path() . 'mod/hypeGallery/actions/upload/describe.php';
elgg_clear_sticky_form('edit:object:hjalbum');
forward("gallery/manage/{$album->guid}");
Пример #19
0
    }
    $screenshots_menu = elgg_format_element('ul', [], $screenshots_menu);
    $screenshots_body = elgg_format_element('div', [], $screenshots_body);
}
// table contents
$info = [];
$info[elgg_echo('admin:plugins:label:version')] = htmlspecialchars($plugin->getManifest()->getVersion());
$info[elgg_echo('admin:plugins:label:id')] = elgg_view('output/text', array('value' => $plugin->getID()));
$info[elgg_echo('admin:plugins:label:author')] = elgg_view('output/text', array('value' => $plugin->getManifest()->getAuthor()));
$url = $plugin->getManifest()->getWebsite();
if ($url) {
    $info[elgg_echo('admin:plugins:label:website')] = elgg_view('output/url', array('href' => $plugin->getManifest()->getWebsite(), 'text' => $plugin->getManifest()->getWebsite(), 'is_trusted' => true));
}
$info[elgg_echo('admin:plugins:label:copyright')] = elgg_view('output/text', array('value' => $plugin->getManifest()->getCopyright()));
$info[elgg_echo('admin:plugins:label:licence')] = elgg_view('output/text', array('value' => $plugin->getManifest()->getLicense()));
$site_path = elgg_get_root_path();
$path = $plugin->getPath();
if (0 === strpos($path, $site_path)) {
    $path = substr($path, strlen($site_path));
}
$info[elgg_echo('admin:plugins:label:location')] = htmlspecialchars($path);
$categories = (array) $plugin->getManifest()->getCategories();
array_walk($categories, function (&$value) {
    $value = htmlspecialchars(ElggPluginManifest::getFriendlyCategory($value));
});
$info[elgg_echo('admin:plugins:label:categories')] = implode(', ', $categories);
// assemble table
$rows = '';
foreach ($info as $name => $value) {
    if (trim($value) === '') {
        continue;
Пример #20
0
 /**
  * @return string
  */
 private function ouptutUnusedFunctionsReport()
 {
     //prepare unused functions report
     $functions = get_defined_functions();
     $functions = array_filter($functions['user'], 'strtolower');
     $calledFunctions = array_filter($this->calledFunctions, 'strtolower');
     $deprecatedFunctions = array_filter(array_keys(code_review::getDeprecatedFunctionsList($this->maxVersion)), 'strtolower');
     $functions = array_diff($functions, $calledFunctions, $deprecatedFunctions);
     foreach ($functions as $key => $function) {
         if (function_exists($function)) {
             $reflectionFunction = new ReflectionFunction($function);
             if (!$reflectionFunction->isInternal()) {
                 continue;
             }
             unset($reflectionFunction);
         }
         unset($functions[$key]);
     }
     sort($functions);
     //unused functions report
     $result = "Not called but defined funcions:\n";
     $baseLenght = strlen(elgg_get_root_path());
     foreach (array_values($functions) as $functionName) {
         $reflectionFunction = new ReflectionFunction($functionName);
         $path = substr($reflectionFunction->getFileName(), $baseLenght);
         if (strpos($path, 'engine') !== 0) {
             continue;
         }
         $result .= "{$functionName} \t{$path}:{$reflectionFunction->getStartLine()}\n";
     }
     return $result;
 }
Пример #21
0
$hole = get_input('hole');
$error = 0;
if ($_FILES['hole_img']['error'] != 0 || $_FILES['hole_img_large']['error'] != 0) {
    $error = -1;
} else {
    $milliseconds = round(microtime(true) * 1000);
    $name = $_FILES["hole_img"]["name"];
    if (strrpos($name, '.') > -1) {
        $name = $milliseconds . substr($name, strrpos($name, '.'));
        $name_large = $milliseconds . '_large' . substr($name, strrpos($name, '.'));
    } else {
        $name = $milliseconds . '.jpg';
        $name_large = $milliseconds . '_large' . '.jpg';
    }
    move_uploaded_file($_FILES["hole_img"]["tmp_name"], elgg_get_root_path() . "_graphics/hole/" . $name);
    move_uploaded_file($_FILES["hole_img_large"]["tmp_name"], elgg_get_root_path() . "_graphics/hole/" . $name_large);
    $golf_course_card = elgg_get_golf_course_card(array('golf_course_id' => $golf_course_id, 'hole' => $hole));
    if ($golf_course_card) {
        $golf_course_card = $golf_course_card[0];
        $golf_course_card_id = $golf_course_card->golf_course_card_id;
    }
    $golf_course_card = new ElggGolfCourseCardItem();
    if ($golf_course_card_id) {
        $golf_course_card->golf_course_card_id = $golf_course_card_id;
    }
    $golf_course_card->golf_course_id = $golf_course_id;
    $golf_course_card->hole = $hole;
    $golf_course_card->map = $name;
    save_golf_course_card($golf_course_card);
    $error = array('error' => $error);
    $error = json_encode($error);
Пример #22
0
/**
 * Initialize the plugin system
 * Listens to system init and registers actions
 *
 * @return void
 * @access private
 */
function plugin_init()
{
    run_function_once("plugin_run_once");
    elgg_register_plugin_hook_handler('unit_test', 'system', 'plugins_test');
    elgg_register_action("plugins/settings/save", '', 'admin');
    elgg_register_action("plugins/usersettings/save");
    elgg_register_action('admin/plugins/activate', '', 'admin');
    elgg_register_action('admin/plugins/deactivate', '', 'admin');
    elgg_register_action('admin/plugins/activate_all', '', 'admin');
    elgg_register_action('admin/plugins/deactivate_all', '', 'admin');
    elgg_register_action('admin/plugins/set_priority', '', 'admin');
    elgg_register_library('elgg:markdown', elgg_get_root_path() . 'vendors/markdown/markdown.php');
}
Пример #23
0
 /**
  * Build a tree of event handlers
  *
  * @param array $all_handlers Set of handlers from a HooksRegistrationService
  *
  * @return array
  */
 protected function buildHandlerTree($all_handlers)
 {
     $tree = array();
     $root = elgg_get_root_path();
     foreach ($all_handlers as $hook => $types) {
         foreach ($types as $type => $priorities) {
             ksort($priorities);
             foreach ($priorities as $priority => $handlers) {
                 foreach ($handlers as $callable) {
                     $description = $this->describeCallable($callable, $root);
                     $callable = "{$priority}: {$description}";
                     $tree["{$hook}, {$type}"][] = $callable;
                 }
             }
         }
     }
     ksort($tree);
     return $tree;
 }
Пример #24
0
/**
 * Checks if /cache directory has been symlinked to views simplecache directory
 * 
 * @return bool
 * @access private
 */
function _elgg_is_cache_symlinked()
{
    $link = elgg_get_root_path() . 'cache/';
    $target = elgg_get_cache_path() . 'views_simplecache/';
    return is_dir($link) && realpath($target) == realpath($link);
}
Пример #25
0
function backup_tool_restore_backup($options = array())
{
    global $CONFIG;
    $dbuser = $CONFIG->dbuser;
    //get database user
    $dbpass = $CONFIG->dbpass;
    //get database password
    $dbname = $CONFIG->dbname;
    //get database name
    $dbhost = $CONFIG->dbhost;
    //get path to default backup dir specified in plugin settings
    $backup_dir = elgg_get_plugin_setting('backup_dir', 'backup-tool');
    $backip_file_name = $options['file_name'];
    $backup_data_dir = $backup_dir . str_replace(".tar.gz", "", $backip_file_name) . "/";
    $backup_file_path = $backup_dir . $backip_file_name;
    mkdir($backup_data_dir);
    //extract files from backup file into the new backup's dir
    $cmd = "cd {$backup_data_dir} && tar xfz {$backup_file_path}";
    exec($cmd);
    //restore dump
    $dump_dir = $backup_data_dir . "dump/";
    $dump_file_path = $dump_dir . $dbname . ".sql";
    $cmd = "mysql --user={$dbuser} --password={$dbpass} --host={$dbhost} {$dbname} < {$dump_file_path}";
    exec($cmd);
    //restore data folder
    $data_dir = $backup_data_dir . "dataroot/";
    if (is_dir($data_dir)) {
        $datafolder = elgg_get_data_path();
        $cmd = "cd {$data_dir} && cp -R . {$datafolder}";
        exec($cmd);
    }
    //restore site folder
    $site_dir = $backup_data_dir . "siteroot/";
    if (is_dir($site_dir)) {
        $sitefolder = elgg_get_root_path();
        $cmd = "cd {$site_dir} && cp -R . {$sitefolder}";
        exec($cmd);
    }
    //remove backup's dir
    $cmd = "rm {$backup_data_dir} -R";
    exec($cmd);
    return true;
}
Пример #26
0
if ($GLOBALS['_ELGG']->simplecache_enabled_in_settings) {
    $params['class'] = 'elgg-state-disabled';
    $params['label_class'] = 'elgg-state-disabled';
    $simple_cache_warning .= "<span class=\"elgg-text-help\">" . elgg_echo('admin:settings:in_settings_file') . "</span>";
}
$simple_cache_input = elgg_view("input/checkbox", $params);
$cache_symlinked = _elgg_is_cache_symlinked();
$params = array('label' => elgg_echo('installation:cache_symlink:label'), 'name' => 'cache_symlink_enabled', 'checked' => $cache_symlinked, 'class' => $simple_cache_disabled_class, 'label_class' => $simple_cache_disabled_class, 'switch' => true);
$symlink_warning = '<p class="elgg-text-help">' . elgg_echo('installation:cache_symlink:description') . '</p>';
if ($cache_symlinked) {
    $params['class'] = 'elgg-state-disabled';
    $params['label_class'] = 'elgg-state-disabled';
    $symlink_warning .= elgg_format_element('span', ['class' => 'elgg-text-help'], elgg_echo('installation:cache_symlink:warning'));
}
$symlink_input = elgg_view('input/checkbox', $params);
$symlink_source = elgg_get_root_path() . 'cache/';
$symlink_target = elgg_get_cache_path() . 'views_simplecache/';
$symlink_paths_help = elgg_echo('installation:cache_symlink:paths', [$symlink_source, $symlink_target]);
$symlink_warning .= elgg_format_element('span', ['class' => 'elgg-text-help'], $symlink_paths_help);
// minify
$minify_description = elgg_echo('installation:minify:description');
$minify_js_input = elgg_view("input/checkbox", array('label' => elgg_echo('installation:minify_js:label'), 'name' => 'simplecache_minify_js', 'checked' => (bool) elgg_get_config('simplecache_minify_js'), 'label_class' => $simple_cache_disabled_class, 'switch' => true));
$minify_css_input = elgg_view("input/checkbox", array('label' => elgg_echo('installation:minify_css:label'), 'name' => 'simplecache_minify_css', 'checked' => (bool) elgg_get_config('simplecache_minify_css'), 'label_class' => $simple_cache_disabled_class, 'switch' => true));
$system_cache_input = elgg_view_field(['#type' => 'checkbox', 'label' => elgg_echo('installation:systemcache:label'), 'help' => elgg_echo('installation:systemcache:description'), 'name' => 'system_cache_enabled', 'switch' => true, 'checked' => elgg_is_system_cache_enabled(), '#class' => 'mtm']);
$body = <<<BODY
\t<div>
\t\t{$simple_cache_input}
\t\t{$simple_cache_warning}
\t</div>
\t<div>
\t\t{$symlink_input}
Пример #27
0
/**
 * Minifies simplecache CSS and JS views by handling the "simplecache:generate" hook
 *
 * @param string $hook    The name of the hook
 * @param string $type    View type (css, js, or unknown)
 * @param string $content Content of the view
 * @param array  $params  Array of parameters
 *
 * @return string|null View content minified (if css/js type)
 * @access private
 */
function _elgg_views_minify($hook, $type, $content, $params)
{
    static $autoload_registered;
    if (!$autoload_registered) {
        $path = elgg_get_root_path() . 'vendors/minify/lib';
        elgg_get_class_loader()->addFallback($path);
        $autoload_registered = true;
    }
    if (preg_match('~[\\.-]min\\.~', $params['view'])) {
        // bypass minification
        return;
    }
    if ($type == 'js') {
        if (elgg_get_config('simplecache_minify_js')) {
            return JSMin::minify($content);
        }
    } elseif ($type == 'css') {
        if (elgg_get_config('simplecache_minify_css')) {
            $cssmin = new CSSMin();
            return $cssmin->run($content);
        }
    }
}
Пример #28
0
/**
 * Get some information about the files installed on a system.
 *
 * @return string
 */
function diagnostics_sigs_hook($hook, $entity_type, $returnvalue, $params)
{
    $base_dir = elgg_get_root_path();
    $returnvalue .= elgg_echo('diagnostics:report:md5', array(diagnostics_md5_dir($base_dir)));
    return $returnvalue;
}
Пример #29
0
/**
 *
 * Processes view permissions from the role configuration array. This is called after the 'ready', 'system' event.
 *
 * For view extension and replacements the function simply calls the corresponding {@link elgg_extend_view()} and
 * {@link elgg_set_view_location()} functions, to post-register views after all plugins have been initalized.
 *
 * For suppressing views (by using the "deny" rule), it registers a specific handler for the given view,
 * to return an empty string instead of the view's original output. This is to conserve resources -
 * there are hundreds of views contributing to any elgg page. Listening for all "views", "all" hooks would
 * be quite a waste.
 *
 * @param string $event Equals 'ready'
 * @param string $event_type Equals 'system'
 * @param mixed $object Not in use for this specific listener
*/
function roles_register_views($event, $type, $object)
{
    $role = roles_get_role();
    if (elgg_instanceof($role, 'object', 'role')) {
        $role_perms = roles_get_role_permissions($role, 'views');
        if (is_array($role_perms) && !empty($role_perms)) {
            foreach ($role_perms as $view => $perm_details) {
                switch ($perm_details['rule']) {
                    case 'deny':
                        elgg_register_plugin_hook_handler('view', $view, 'roles_views_permissions');
                        break;
                    case 'extend':
                        $params = $perm_details['view_extension'];
                        $view_extension = roles_replace_dynamic_paths($params['view']);
                        $priority = isset($params['priority']) ? $params['priority'] : 501;
                        $viewtype = isset($params['viewtype']) ? $params['viewtype'] : '';
                        elgg_extend_view($view, $view_extension, $priority, $viewtype);
                        break;
                    case 'replace':
                        $params = $perm_details['view_replacement'];
                        $location = elgg_get_root_path() . roles_replace_dynamic_paths($params['location']);
                        $viewtype = isset($params['viewtype']) ? $params['viewtype'] : '';
                        elgg_set_view_location($view, $location, $viewtype);
                        break;
                    case 'allow':
                    default:
                        break;
                }
            }
        }
    }
}
Пример #30
0
<?php

/**
 * this file overrides the default /actions/register.php
 * a terms of use checkbox is added to the "/register" page
 * @see Plugin Settings for Terms of Use plugin
 * @see /mod/terms_of_use/views/default/plugins/terms_of_use/settings.php
 *
 */
// 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);
    }
}
/*-- call the default /actions/register.php file to take care of the rest of the register process --*/
$default_register_action_path = elgg_get_root_path() . 'actions/register.php';
require_once $default_register_action_path;