예제 #1
0
 /**
  * Test anchor tags as input
  */
 public function testHtmlawedFilterTagsAnchorsInput()
 {
     $tests = array();
     // these should all work
     foreach ($this->validSchemes as $scheme) {
         $input = "<a href=\"{$scheme}://test\">Test</a>";
         $tests[$input] = "<a href=\"{$scheme}://test\">Test</a>";
     }
     $bad_schemes = array('javascript', 'itmss', 'magnet');
     // these should be denied
     foreach ($bad_schemes as $scheme) {
         $input = "<a href=\"{$scheme}://test\">Test</a>";
         $tests[$input] = "<a href=\"denied:{$scheme}://test\">Test</a>";
     }
     // set context to input to avoid adding nofollow
     elgg_push_context('input');
     foreach ($tests as $input => $expected) {
         $result = _elgg_htmlawed_filter_tags(null, null, $input);
         $this->assertEqual($expected, $result);
     }
     $weird_schemes = array('<a href="http://javascript:alert">Test</a>' => '<a href="http://javascript:alert">Test</a>', '<a href="javascript:https://">Test</a>' => '<a href="denied:javascript:https://">Test</a>', '<a href="ftp:\\/\\/">Test</a>' => '<a href="ftp:\\/\\/">Test</a>');
     foreach ($weird_schemes as $input => $expected) {
         $result = _elgg_htmlawed_filter_tags(null, null, $input);
         $this->assertEqual($expected, $result);
     }
     elgg_pop_context();
 }
예제 #2
0
파일: Input.php 프로젝트: elgg/elgg
 /**
  * Get some input from variables passed submitted through GET or POST.
  *
  * If using any data obtained from get_input() in a web page, please be aware that
  * it is a possible vector for a reflected XSS attack. If you are expecting an
  * integer, cast it to an int. If it is a string, escape quotes.
  *
  * Note: this function does not handle nested arrays (ex: form input of param[m][n])
  * because of the filtering done in htmlawed from the filter_tags call.
  * @todo Is this ^ still true?
  *
  * @param string $variable      The variable name we want.
  * @param mixed  $default       A default value for the variable if it is not found.
  * @param bool   $filter_result If true, then the result is filtered for bad tags.
  *
  * @return mixed
  */
 function get($variable, $default = null, $filter_result = true)
 {
     $result = $default;
     elgg_push_context('input');
     if (isset($this->CONFIG->input[$variable])) {
         // a plugin has already set this variable
         $result = $this->CONFIG->input[$variable];
         if ($filter_result) {
             $result = filter_tags($result);
         }
     } else {
         $request = _elgg_services()->request;
         $value = $request->get($variable);
         if ($value !== null) {
             $result = $value;
             if (is_string($result)) {
                 // @todo why trim
                 $result = trim($result);
             }
             if ($filter_result) {
                 $result = filter_tags($result);
             }
         }
     }
     elgg_pop_context();
     return $result;
 }
예제 #3
0
/**
 * Listen to the registration of a new user
 *
 * @param string $hook         the name of the hook
 * @param string $type         the type of the hook
 * @param bool   $return_value the current return value
 * @param array  $params       supplied params
 *
 * @return bool
 */
function uservalidationbyadmin_register_user_hook($hook, $type, $return_value, $params)
{
    if (empty($params) || !is_array($params)) {
        return $return_value;
    }
    $user = elgg_extract("user", $params);
    if (empty($user) || !elgg_instanceof($user, "user")) {
        return $return_value;
    }
    // make sure we can see everything
    $hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // make sure we can save metadata
    elgg_push_context("uservalidationbyadmin_new_user");
    // this user needs validation
    $user->admin_validated = false;
    // check who to notify
    $notify_admins = uservalidationbyadmin_get_admin_notification_setting();
    if ($notify_admins == "direct") {
        uservalidationbyadmin_notify_admins();
    }
    // check if we need to disable the user
    if ($user->isEnabled()) {
        $user->disable();
    }
    // restore context
    elgg_pop_context();
    // restore access settings
    access_show_hidden_entities($hidden);
    return $return_value;
}
예제 #4
0
 public static function prepareMenu($h, $t, $v, $p)
 {
     $default = new MenuList(elgg_extract('default', $v, []));
     $alt = new MenuList(elgg_extract('alt', $v, []));
     // dump alt items into default
     $default->appendList($alt);
     $avatar = $default->get('profile');
     $account = $default->get('account');
     if ($avatar && $account) {
         $user = elgg_get_logged_in_user_entity();
         // copy account children under avatar
         $children = new MenuList($account->getChildren());
         // copy admin out
         $admin = $children->remove('administration');
         $url = $avatar->getHref();
         $profile = new \ElggMenuItem('view-profile', elgg_echo('profile'), $url);
         $children->move($profile, 0);
         $avatar->setHref(null);
         elgg_push_context('mrclay_aalborg_topbar');
         $avatar->setText(elgg_view_entity_icon($user, 'tiny'));
         elgg_pop_context();
         $default->remove($account);
         $default->push($avatar);
         if ($admin) {
             $admin->setTooltip(elgg_echo('admin'));
             $admin->setText(elgg_view_icon('settings-alt'));
             $default->move($admin, 0);
         }
     }
     return ['default' => $default->getItems()];
 }
예제 #5
0
/**
 * Disables a user upon registration.
 *
 * @param string $hook
 * @param string $type
 * @param bool   $value
 * @param array  $params
 * @return bool
 */
function uservalidationbyemail_disable_new_user($hook, $type, $value, $params)
{
    $user = elgg_extract('user', $params);
    // no clue what's going on, so don't react.
    if (!$user instanceof ElggUser) {
        return;
    }
    // another plugin is requesting that registration be terminated
    // no need for uservalidationbyemail
    if (!$value) {
        return $value;
    }
    // has the user already been validated?
    if (elgg_get_user_validation_status($user->guid) == true) {
        return $value;
    }
    // disable user to prevent showing up on the site
    // set context so our canEdit() override works
    elgg_push_context('uservalidationbyemail_new_user');
    $hidden_entities = access_get_show_hidden_status();
    access_show_hidden_entities(TRUE);
    // Don't do a recursive disable.  Any entities owned by the user at this point
    // are products of plugins that hook into create user and might need
    // access to the entities.
    // @todo That ^ sounds like a specific case...would be nice to track it down...
    $user->disable('uservalidationbyemail_new_user', FALSE);
    // set user as unvalidated and send out validation email
    elgg_set_user_validation_status($user->guid, FALSE);
    uservalidationbyemail_request_validation($user->guid);
    elgg_pop_context();
    access_show_hidden_entities($hidden_entities);
    return $value;
}
예제 #6
0
파일: start.php 프로젝트: rasul/Elgg
/**
 * Dispatcher for bookmarks.
 *
 * URLs take the form of
 *  All bookmarks:        bookmarks/all
 *  User's bookmarks:     bookmarks/owner/<username>
 *  Friends' bookmarks:   bookmarks/friends/<username>
 *  View bookmark:        bookmarks/view/<guid>/<title>
 *  New bookmark:         bookmarks/add/<guid> (container: user, group, parent)
 *  Edit bookmark:        bookmarks/edit/<guid>
 *  Group bookmarks:      bookmarks/group/<guid>/owner
 *  Bookmarklet:          bookmarks/bookmarklet/<guid> (user)
 *
 * Title is ignored
 *
 * @param array $page
 */
function bookmarks_page_handler($page)
{
    elgg_load_library('elgg:bookmarks');
    elgg_push_breadcrumb(elgg_echo('bookmarks'), 'bookmarks/all');
    elgg_push_context('bookmarks');
    // old group usernames
    if (substr_count($page[0], 'group:')) {
        preg_match('/group\\:([0-9]+)/i', $page[0], $matches);
        $guid = $matches[1];
        if ($entity = get_entity($guid)) {
            bookmarks_url_forwarder($page);
        }
    }
    // user usernames
    $user = get_user_by_username($page[0]);
    if ($user) {
        bookmarks_url_forwarder($page);
    }
    $pages = dirname(__FILE__) . '/pages/bookmarks';
    switch ($page[0]) {
        case "all":
            include "{$pages}/all.php";
            break;
        case "owner":
            include "{$pages}/owner.php";
            break;
        case "friends":
            include "{$pages}/friends.php";
            break;
        case "read":
        case "view":
            set_input('guid', $page[1]);
            include "{$pages}/view.php";
            break;
        case "add":
            gatekeeper();
            include "{$pages}/add.php";
            break;
        case "edit":
            gatekeeper();
            set_input('guid', $page[1]);
            include "{$pages}/edit.php";
            break;
        case 'group':
            group_gatekeeper();
            include "{$pages}/owner.php";
            break;
        case "bookmarklet":
            set_input('container_guid', $page[1]);
            include "{$pages}/bookmarklet.php";
            break;
        default:
            return false;
    }
    elgg_pop_context();
    return true;
}
예제 #7
0
/**
 * Can we allow the user with the credentials to log in?
 * Check stormpath, create the user if they can log in and don't exist
 * Enable the user if they can log in but were waiting for email verification
 * 
 * @param type $credentials
 * @return boolean
 */
function pam_handler($credentials)
{
    // try to authenticate first
    $application = get_application();
    $authResult = $application->authenticate($credentials['username'], $credentials['password']);
    $account = $authResult->account;
    if (!$account || strtolower($account->status) != 'enabled') {
        return false;
    }
    // we need to search hidden users too
    // in case of email confirmation disabling
    $show_hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // we have an account and it's enabled
    // see if we have a matching account here
    // check if logging in with email address
    if (strpos($credentials['username'], '@') !== false) {
        $users = get_user_by_email($credentials['username']);
        $user = $users[0];
    } else {
        $user = get_user_by_username($credentials['username']);
    }
    // custom context gives us permission to do this
    elgg_push_context('stormpath_validate_user');
    // if we don't have a user we need to create one
    if (!$user) {
        $user = new \ElggUser();
        $user->username = preg_replace("/[^a-zA-Z0-9]/", "", $account->username);
        $user->email = $account->email;
        $user->name = $account->fullName;
        $user->access_id = ACCESS_PUBLIC;
        $user->salt = _elgg_generate_password_salt();
        $user->password = generate_user_password($user, $credentials['password']);
        $user->owner_guid = 0;
        // Users aren't owned by anyone, even if they are admin created.
        $user->container_guid = 0;
        // Users aren't contained by anyone, even if they are admin created.
        $user->language = get_current_language();
        $user->save();
        $user->__stormpath_user = $account->href;
        elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
        // Turn on email notifications by default
        set_user_notification_setting($user->getGUID(), 'email', true);
    }
    // see if we need to enable/verify the user
    if (!$user->isEnabled() && in_array($user->disable_reason, array('stormpath_new_user', 'uservalidationbyemail_new_user'))) {
        $user->enable();
        $user->__stormpath_user = $account->href;
        elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
    }
    elgg_pop_context();
    access_show_hidden_entities($show_hidden);
    if ($user && $user->isEnabled()) {
        return true;
    }
    return false;
}
예제 #8
0
/**
 * Extends thewire pagehandler with some extra pages
 *
 * @param string $hook_name   'route'
 * @param string $entity_type 'thewire'
 * @param bool   $return      the default return value
 * @param array  $params      supplied params
 *
 * @return bool
 */
function thewire_tools_route_thewire($hook_name, $entity_type, $return, $params)
{
    $page = elgg_extract("segments", $return);
    if (is_array($page)) {
        switch ($page[0]) {
            case "group":
                if (!empty($page[1])) {
                    set_input("group_guid", $page[1]);
                    // @todo is this still needed or replace with page_owner in page
                    if (!empty($page[2])) {
                        set_input("wire_username", $page[2]);
                        // @todo is this still needed?
                    }
                    $include_file = "pages/group.php";
                    break;
                }
            case "tag":
            case "search":
                if (isset($page[1])) {
                    if ($page[0] == "tag") {
                        set_input("query", "#" . $page[1]);
                    } else {
                        set_input("query", $page[1]);
                    }
                }
                $include_file = "pages/search.php";
                break;
            case "autocomplete":
                $include_file = "procedures/autocomplete.php";
                break;
            case "conversation":
                if (isset($page[1])) {
                    set_input("guid", $page[1]);
                }
                $include_file = "procedures/conversation.php";
                break;
            case "thread":
                elgg_push_context("thewire_thread");
            case "reply":
                if (!empty($page[1])) {
                    $entity = get_entity($page[1]);
                    if (!empty($entity) && elgg_instanceof($entity->getContainerEntity(), "group")) {
                        elgg_set_page_owner_guid($entity->getContainerGUID());
                    }
                }
                break;
        }
        if (!empty($include_file)) {
            include dirname(dirname(__FILE__)) . "/" . $include_file;
            $return = false;
        }
    }
    return $return;
}
예제 #9
0
function list_relatedgroups($group, $options = array())
{
    if ($group instanceof ElggGroup) {
        $defaults = array('full_view' => false, 'pagination' => true);
        $options = array_merge($defaults, $options);
        $options['relationship'] = 'related';
        $options['relationship_guid'] = $group->guid;
        elgg_push_context('relatedgroups');
        $list = elgg_list_entities_from_relationship($options);
        elgg_pop_context();
        return $list;
    } else {
        return "";
    }
}
예제 #10
0
function list_subgroups($group, $options = array())
{
    if ($group instanceof ElggGroup) {
        $defaults = array('full_view' => false, 'pagination' => true);
        $options = array_merge($defaults, $options);
        $options['type'] = 'group';
        $options['container_guid'] = $group->guid;
        elgg_push_context('subgroups');
        $list = elgg_list_entities($options);
        elgg_pop_context();
        return $list;
    } else {
        return "";
    }
}
예제 #11
0
 /**
  * Extends thewire pagehandler with some extra pages
  *
  * @param string $hook_name   'route'
  * @param string $entity_type 'thewire'
  * @param bool   $return      the default return value
  * @param array  $params      supplied params
  *
  * @return bool
  */
 public static function thewire($hook_name, $entity_type, $return, $params)
 {
     $page = elgg_extract('segments', $return);
     if (!isset($page[0])) {
         $page = ['all'];
     }
     switch ($page[0]) {
         case 'all':
         case 'owner':
             set_input('limit', get_input('limit', elgg_get_config('default_limit')));
             return;
         case 'group':
             if (!empty($page[1])) {
                 set_input('group_guid', $page[1]);
                 // @todo is this still needed or replace with page_owner in page
                 if (!empty($page[2])) {
                     set_input('wire_username', $page[2]);
                     // @todo is this still needed?
                 }
                 echo elgg_view_resource('thewire/group');
                 return false;
             }
         case 'tag':
         case 'search':
             if (isset($page[1])) {
                 if ($page[0] == 'tag') {
                     set_input('query', '#' . $page[1]);
                 } else {
                     set_input('query', $page[1]);
                 }
             }
             echo elgg_view_resource('thewire/search');
             return false;
         case 'autocomplete':
             echo elgg_view_resource('thewire/autocomplete');
             return false;
         case 'thread':
             elgg_push_context('thewire_thread');
         case 'reply':
             if (!empty($page[1])) {
                 $entity = get_entity($page[1]);
                 if (!empty($entity) && elgg_instanceof($entity->getContainerEntity(), 'group')) {
                     elgg_set_page_owner_guid($entity->getContainerGUID());
                 }
             }
             break;
     }
 }
예제 #12
0
/**
 * Route groups pages
 *
 * @param string $hook   "route"
 * @param string $type   "groups"
 * @param array  $return Identifier and segments
 * @param array  $params Hook params
 * @return array
 */
function group_profile_router($hook, $type, $return, $params)
{
    if (!is_array($return)) {
        return;
    }
    // Initial page identifier might be different from /groups
    // i.e. subtype specific handler e.g. /schools
    $initial_identifier = elgg_extract('identifier', $params);
    $identifier = elgg_extract('identifier', $return);
    $segments = elgg_extract('segments', $return);
    if ($identifier !== 'groups') {
        return;
    }
    $page = array_shift($segments);
    if (!$page) {
        $page = 'all';
    }
    // we want to pass the original identifier to the resource view
    // doing this via route hook in order to keep the page handler intact
    $resource_params = array('identifier' => $initial_identifier ?: 'groups');
    switch ($page) {
        case 'profile':
            $guid = array_shift($segments);
            $resource_params['guid'] = $guid;
            elgg_push_context('group_profile');
            elgg_set_page_owner_guid($guid);
            break;
        case 'activity':
            $guid = array_shift($segments);
            $resource_params['guid'] = $guid;
            break;
        default:
            return;
    }
    elgg_load_library('elgg:groups');
    $resource_params['page'] = $page;
    $resource_params['segments'] = $segments;
    echo elgg_view_resource("groups/{$page}", $resource_params);
    return false;
}
예제 #13
0
/** 
 * Custom function to grab entities belonging to a container OR a tag
 */
function am_list_entities_by_container_or_tag($options)
{
    if ($options['container_guid']) {
        $container_sql = "e.container_guid IN ({$options['container_guid']})";
    }
    if ($options['tag']) {
        $access_sql = get_access_sql_suffix('tag_meta_table');
        $tag_sql = "\n\t\t\t(\n\t\t\t\t(tag_msn.string IN ('tags')) AND ( BINARY tag_msv.string IN ('{$options['tag']}')) \n\t\t\t\tAND\n\t\t\t\t{$access_sql}\n\t\t\t)\n\t\t";
    }
    $subtypes = is_array($options['subtypes']) ? $options['subtypes'] : array();
    $limit = $options['limit'] === NULL ? 10 : $options['limit'];
    $offset = $options['offset'] === NULL ? 0 : $options['offset'];
    $title = $options['title'] === NULL ? 'Custom Module' : $options['title'];
    global $CONFIG;
    // As long as we have either a container_guid or a tag, use the $wheres
    if ($container_sql || $tag_sql) {
        $joins[] = "JOIN {$CONFIG->dbprefix}metadata tag_meta_table on e.guid = tag_meta_table.entity_guid";
        $joins[] = "JOIN {$CONFIG->dbprefix}metastrings tag_msn on tag_meta_table.name_id = tag_msn.id";
        $joins[] = "JOIN {$CONFIG->dbprefix}metastrings tag_msv on tag_meta_table.value_id = tag_msv.id";
        // Need to watch the brackets here..
        $wheres[] = "\n\t\t\t(\n\t\t\t\t{$container_sql}\n\t\t\t\tOR\n\t\t\t\t{$tag_sql}\n\t\t\t)\n\t\t";
    }
    // Not sure if I still need this one..
    elgg_push_context('search');
    // Don't display metadata menu
    elgg_push_context('widgets');
    $params = array('type' => 'object', 'subtypes' => $subtypes, 'joins' => $joins, 'wheres' => $wheres, 'full_view' => FALSE, 'limit' => $limit, 'offset' => $offset, 'owner_guids' => $options['owner_guids'], 'created_time_upper' => $options['created_time_upper'], 'created_time_lower' => $options['created_time_lower'], 'count' => $options['count']);
    if ($options['count']) {
        $entities = elgg_get_entities_from_metadata($params);
        echo $entities;
    } else {
        $entities = elgg_list_entities_from_metadata($params);
        if ($entities) {
            return $entities;
        } else {
            return "<div style='width: 100%; text-align: center; margin: 10px;'><strong>No results</strong></div>";
        }
    }
}
예제 #14
0
파일: ContextTest.php 프로젝트: ibou77/elgg
 public function testContainsTellsYouIfAGivenContextIsInTheCurrentStack()
 {
     $context = new Context();
     $context->push('foo');
     $context->push('bar');
     $context->push('baz');
     $this->assertTrue($context->contains('foo'));
     $this->assertTrue($context->contains('bar'));
     $this->assertTrue($context->contains('baz'));
     $popped = $context->pop();
     $this->assertFalse($context->contains($popped));
     // TODO: remove once global state is fully deprecated (2.0)
     _elgg_services()->setValue('context', new Context());
     elgg_push_context('foo');
     elgg_push_context('bar');
     elgg_push_context('baz');
     $this->assertTrue(elgg_in_context('foo'));
     $this->assertTrue(elgg_in_context('bar'));
     $this->assertTrue(elgg_in_context('baz'));
     $popped = elgg_pop_context();
     $this->assertFalse(elgg_in_context($popped));
 }
예제 #15
0
/**
 * Get some input from variables passed submitted through GET or POST.
 *
 * If using any data obtained from get_input() in a web page, please be aware that
 * it is a possible vector for a reflected XSS attack. If you are expecting an
 * integer, cast it to an int. If it is a string, escape quotes.
 *
 * Note: this function does not handle nested arrays (ex: form input of param[m][n])
 * because of the filtering done in htmlawed from the filter_tags call.
 * @todo Is this ^ still true?
 *
 * @param string $variable      The variable name we want.
 * @param mixed  $default       A default value for the variable if it is not found.
 * @param bool   $filter_result If true, then the result is filtered for bad tags.
 *
 * @return mixed
 */
function get_input($variable, $default = NULL, $filter_result = TRUE)
{
    global $CONFIG;
    $result = $default;
    elgg_push_context('input');
    if (isset($CONFIG->input[$variable])) {
        $result = $CONFIG->input[$variable];
        if ($filter_result) {
            $result = filter_tags($result);
        }
    } elseif (isset($_REQUEST[$variable])) {
        if (is_array($_REQUEST[$variable])) {
            $result = $_REQUEST[$variable];
        } else {
            $result = trim($_REQUEST[$variable]);
        }
        if ($filter_result) {
            $result = filter_tags($result);
        }
    }
    elgg_pop_context();
    return $result;
}
예제 #16
0
<?php

/**
 * Group pages
 *
 * @package ElggPages
 */
$group = elgg_get_page_owner_entity();
if ($group->pages_enable == "no") {
    return true;
}
$all_link = elgg_view('output/url', array('href' => "pages/group/{$group->guid}/all", 'text' => elgg_echo('link:view:all')));
elgg_push_context('widgets');
$options = array('type' => 'object', 'subtype' => 'page_top', 'container_guid' => elgg_get_page_owner_guid(), 'limit' => 6, 'full_view' => false, 'pagination' => false);
$content = elgg_list_entities($options);
elgg_pop_context();
if (!$content) {
    $content = '<p>' . elgg_echo('pages:none') . '</p>';
}
$new_link = elgg_view('output/url', array('href' => "pages/add/{$group->guid}", 'text' => elgg_echo('pages:add')));
echo elgg_view('groups/profile/module', array('title' => elgg_echo('pages:group'), 'content' => $content, 'all_link' => $all_link, 'add_link' => $new_link));
예제 #17
0
파일: widgets.php 프로젝트: socialweb/PiGo
<?php

/**
* Profile widgets/tools
* 
*/
if (elgg_get_plugin_setting("group_enable", "widget_manager") == "yes" && $vars["entity"]->widget_manager_enable == "yes") {
    $params = array('num_columns' => 2, 'exact_match' => true);
    // need context = groups to fix the issue with the new group_profile context
    elgg_push_context("groups");
    echo elgg_view_layout('widgets', $params);
    elgg_pop_context();
} else {
    // traditional view
    // tools widget area
    echo '<ul id="groups-tools" class="elgg-gallery elgg-gallery-fluid mtl clearfix">';
    // enable tools to extend this area
    echo elgg_view("groups/tool_latest", $vars);
    // backward compatibility
    $right = elgg_view('groups/right_column', $vars);
    $left = elgg_view('groups/left_column', $vars);
    if ($right || $left) {
        elgg_deprecated_notice('The views groups/right_column and groups/left_column have been replaced by groups/tool_latest', 1.8);
        echo $left;
        echo $right;
    }
    echo "</ul>";
}
예제 #18
0
<?php

/**
 * Group zhaohu manager module
 */
$group = elgg_get_page_owner_entity();
if ($group->zhaohu_manager_enable == "no") {
    return true;
}
$zhaohu_options = array();
$zhaohu_options["container_guid"] = elgg_get_page_owner_guid();
$zhaohus = zhaohu_manager_find_zhaohus($zhaohu_options);
elgg_push_context("widgets");
$content = elgg_view_entity_list($zhaohus['entities'], array('count' => 0, 'offset' => 0, 'limit' => 5, 'full_view' => false));
elgg_pop_context();
if (!$content) {
    $content = '<p>' . elgg_echo('zhaohu:noresults') . '</p>';
}
$all_link = elgg_view('output/url', array('href' => "/zhaohus/zhaohu/list/" . $group->getGUID(), 'text' => elgg_echo('link:view:all')));
$new_link = elgg_view('output/url', array('href' => "/zhaohus/zhaohu/new/" . $group->getGUID(), 'text' => elgg_echo('zhaohu:new')));
echo elgg_view('groups/profile/module', array('title' => elgg_echo('zhaohu_manager:group'), 'content' => $content, 'all_link' => $all_link, 'add_link' => $new_link));
예제 #19
0
<?php

// generate a div which includes all the recommended groups
$search_options = array('type' => 'group', 'subtype' => 0, 'offset' => 0, 'limit' => 5, 'joins' => array(), 'wheres' => array());
$search_options['metadata_name_value_pairs'][] = array('name' => 'featured_group', 'value' => 'yes');
$search_options['count'] = false;
$recommended_groups = elgg_get_entities_from_metadata($search_options);
$display_options = array("count" => ZHAOHU_RECOMMENDED_SHOW_LIMIT, "offset" => 0, "limit" => ZHAOHU_RECOMMENDED_SHOW_LIMIT, "full_view" => false, "pagination" => false);
$header_title = elgg_echo("zhaohu:recommended_groups");
$content = "<div id='zhaohu_homepage_recommended_groups' class='zhaohu-homepage-right-sidebar-div'>";
$content .= "<div id='zhaohu_homepage_recommended_groups_header' class='zhaohu-homepage-right-sidebar-div-header'>{$header_title}</div>";
$content .= "<div id='zhaohu_homepage_recommended_groups_content' class='zhaohu-homepage-right-sidebar-div-content'>";
elgg_push_context("recommended_groups");
$list = elgg_view_entity_list($recommended_groups, $display_options);
elgg_pop_context("recommended_groups");
if (!empty($list)) {
    $content .= $list;
} else {
    $content .= elgg_echo('zhaohu:noresults');
}
$content .= "</div>";
$content .= "</div>";
echo $content;
예제 #20
0
<?php

$category = get_input('category', null);
$site = elgg_get_site_entity();
$user = elgg_get_logged_in_user_entity();
elgg_push_context('news');
elgg_set_page_owner_guid($site->guid);
if ($site->canWriteToContainer(0, 'object', 'news')) {
    elgg_register_title_button();
}
$options = array('type' => 'object', 'subtype' => 'news', 'full_view' => false, 'display_as_list' => false);
$topic = get_input('topic');
if (!$topic) {
    $topic = "mine";
}
if ($topic == "mine") {
    $interests = rijkshuisstijl_get_interests($user);
    if ($interests) {
        $options['container_guids'] = $interests;
    }
} else {
    $topic = (int) $topic;
    if ($topic) {
        $options['container_guid'] = $topic;
    }
}
$category = get_input('category', null);
if ($category) {
    $tags = get_metastring_id("tags");
    $juris = get_metastring_id("juris");
    if ($tags && $juris) {
예제 #21
0
}
// get view mode
$view_mode = $widget->view_mode;
// backup context and set
switch ($view_mode) {
    case "slider":
        elgg_push_context("slider");
        break;
    case "preview":
        elgg_push_context("preview");
        break;
    case "simple":
        elgg_push_context("simple");
        break;
    default:
        elgg_push_context("listing");
        break;
}
$options = array("type" => "object", "subtype" => "blog", "limit" => $count, "full_view" => false, "pagination" => false, "view_type_toggle" => false, "metadata_name_value_pairs" => array());
// only show published blogs to non admins
if (!elgg_is_admin_logged_in()) {
    $options["metadata_name_value_pairs"][] = array("name" => "status", "value" => "published");
}
// limit to featured blogs?
if ($widget->show_featured == "yes") {
    $options["metadata_name_value_pairs"][] = array("name" => "featured", "value" => true);
}
if ($blogs = elgg_list_entities_from_metadata($options)) {
    if ($view_mode == 'slider') {
        $blog_entities = elgg_get_entities_from_metadata($options);
        echo "<div id='blog_tools_widget_items_container_" . $widget->getGUID() . "' class='blog_tools_widget_items_container'>";
예제 #22
0
파일: overview.php 프로젝트: pleio/pinboard
<?php

/**
 * Shows the overview page of the FFD Cafe
 *
 * @package theme_ffd
 */
elgg_push_context("cafe");
if (elgg_is_logged_in() && can_write_to_container()) {
    $add = elgg_view_form('theme_ffd/cafe', array('name' => 'cafe', 'action' => 'action/cafe/save'), array('collapsable' => true));
} else {
    $add = "";
}
$options = array('type' => 'object', 'subtype' => 'cafe', 'order_by' => 'last_action DESC', 'full_view' => false);
$owner = get_input('owner');
if ($owner) {
    $owner = get_user_by_username($owner);
}
if ($owner) {
    $options['owner_guid'] = $owner->guid;
    $filter_context = 'mine';
} else {
    $filter_context = 'all';
}
$purpose = get_input('purpose');
if (in_array($purpose, array('search', 'share', 'experience'))) {
    $options['metadata_name_value_pairs'] = array(array('name' => 'purpose', 'value' => $purpose));
    $getter = 'elgg_get_entities_from_metadata';
} else {
    $getter = 'elgg_get_entities';
}
예제 #23
0
파일: groups.php 프로젝트: n8b/VMN
/**
 * Group profile page
 *
 * @param int $guid Group entity GUID
 */
function groups_handle_profile_page($guid)
{
    elgg_set_page_owner_guid($guid);
    // turn this into a core function
    global $autofeed;
    $autofeed = true;
    elgg_push_context('group_profile');
    elgg_entity_gatekeeper($guid, 'group');
    $group = get_entity($guid);
    elgg_push_breadcrumb($group->name);
    groups_register_profile_buttons($group);
    $content = elgg_view('groups/profile/layout', array('entity' => $group));
    $sidebar = '';
    if (elgg_group_gatekeeper(false)) {
        if (elgg_is_active_plugin('search')) {
            $sidebar .= elgg_view('groups/sidebar/search', array('entity' => $group));
        }
        $sidebar .= elgg_view('groups/sidebar/members', array('entity' => $group));
        $subscribed = false;
        if (elgg_is_active_plugin('notifications')) {
            $NOTIFICATION_HANDLERS = _elgg_services()->notifications->getMethodsAsDeprecatedGlobal();
            foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
                $relationship = check_entity_relationship(elgg_get_logged_in_user_guid(), 'notify' . $method, $guid);
                if ($relationship) {
                    $subscribed = true;
                    break;
                }
            }
        }
        $sidebar .= elgg_view('groups/sidebar/my_status', array('entity' => $group, 'subscribed' => $subscribed));
    }
    $params = array('content' => $content, 'sidebar' => $sidebar, 'title' => $group->name);
    $body = elgg_view_layout('one_sidebar', $params);
    echo elgg_view_page($group->name, $body);
}
예제 #24
0
<?php

/**
 * Wall post tag river item
 */
namespace hypeJunction\Wall;

elgg_push_context('wall');
// River access level will vary from that of the original post
$ia = elgg_set_ignore_access(true);
$tagged_user = $vars['item']->getSubjectEntity();
$wall_post = $vars['item']->getObjectEntity();
$poster = $wall_post->getOwnerEntity();
$tagged_user_link = elgg_view('output/url', array('text' => $tagged_user->name, 'href' => $tagged_user->getURL()));
$poster_link = elgg_view('output/url', array('text' => $poster->name, 'href' => $poster->getURL()));
$wall_post_link = elgg_view('output/url', array('text' => elgg_echo('wall:tag:river:post'), 'href' => $wall_post->getURL()));
$summary = elgg_echo('wall:tag:river', array($poster_link, $tagged_user_link, $wall_post_link));
elgg_set_ignore_access($ia);
echo elgg_view('river/item', array('item' => $vars['item'], 'summary' => $summary, 'message' => format_wall_message($wall_post), 'attachments' => format_wall_attachments($wall_post)));
elgg_pop_context();
예제 #25
0
/**
 * Groups page handler
 *
 * URLs take the form of
 *  All groups:           groups/all
 *  User's owned groups:  groups/owner/<username>
 *  User's member groups: groups/member/<username>
 *  Group profile:        groups/profile/<guid>/<title>
 *  New group:            groups/add/<guid>
 *  Edit group:           groups/edit/<guid>
 *  Group invitations:    groups/invitations/<username>
 *  Invite to group:      groups/invite/<guid>
 *  Membership requests:  groups/requests/<guid>
 *  Group activity:       groups/activity/<guid>
 *  Group members:        groups/members/<guid>
 *
 * @param array $page Array of url segments for routing
 * @return bool
 */
function groups_page_handler($page)
{
    elgg_load_library('elgg:groups');
    if (!isset($page[0])) {
        $page[0] = 'all';
    }
    elgg_push_breadcrumb(elgg_echo('groups'), "groups/all");
    $vars = [];
    switch ($page[0]) {
        case 'add':
        case 'all':
        case 'owner':
        case 'search':
            echo elgg_view_resource("groups/{$page[0]}");
            break;
        case 'invitations':
        case 'member':
            echo elgg_view_resource("groups/{$page[0]}", ['username' => $page[1]]);
            break;
        case 'members':
            $vars['sort'] = elgg_extract('2', $page, 'alpha');
            $vars['guid'] = elgg_extract('1', $page);
            if (elgg_view_exists("resources/groups/members/{$vars['sort']}")) {
                echo elgg_view_resource("groups/members/{$vars['sort']}", $vars);
            } else {
                echo elgg_view_resource('groups/members', $vars);
            }
            break;
        case 'profile':
            // Page owner and context need to be set before elgg_view() is
            // called so they'll be available in the [pagesetup, system] event
            // that is used for registering items for the sidebar menu.
            // @see groups_setup_sidebar_menus()
            elgg_push_context('group_profile');
            elgg_set_page_owner_guid($page[1]);
        case 'activity':
        case 'edit':
        case 'invite':
        case 'requests':
            echo elgg_view_resource("groups/{$page[0]}", ['guid' => $page[1]]);
            break;
        default:
            return false;
    }
    return true;
}
예제 #26
0
/**
 * Updates the fixed widgets for a given context and user
 *
 * @param string $context   context of the widgets
 * @param int    $user_guid owner of the new widgets
 *
 * @return void
 */
function widget_manager_update_fixed_widgets($context, $user_guid)
{
    // need to be able to access everything
    $old_ia = elgg_set_ignore_access(true);
    elgg_push_context('create_default_widgets');
    $options = ['type' => 'object', 'subtype' => 'widget', 'owner_guid' => elgg_get_site_entity()->guid, 'private_setting_name_value_pairs' => ['context' => $context, 'fixed' => 1.0], 'limit' => false];
    // see if there are configured fixed widgets
    $configured_fixed_widgets = elgg_get_entities_from_private_settings($options);
    widget_manager_sort_widgets_guid($configured_fixed_widgets);
    // fetch all currently configured widgets fixed AND not fixed
    $options['private_setting_name_value_pairs'] = ['context' => $context];
    $options['owner_guid'] = $user_guid;
    $user_widgets = elgg_get_entities_from_private_settings($options);
    widget_manager_sort_widgets_guid($user_widgets);
    $default_widget_guids = [];
    // update current widgets
    if ($user_widgets) {
        foreach ($user_widgets as $guid => $widget) {
            $widget_fixed = $widget->fixed;
            $default_widget_guid = $widget->fixed_parent_guid;
            $default_widget_guids[] = $default_widget_guid;
            if (empty($default_widget_guid)) {
                continue;
            }
            if ($widget_fixed && !array_key_exists($default_widget_guid, $configured_fixed_widgets)) {
                // remove fixed status
                $widget->fixed = false;
            } elseif (!$widget_fixed && array_key_exists($default_widget_guid, $configured_fixed_widgets)) {
                // add fixed status
                $widget->fixed = true;
            }
            // need to recheck the fixed status as it could have been changed
            if ($widget->fixed && array_key_exists($default_widget_guid, $configured_fixed_widgets)) {
                // update settings for currently configured widgets
                // pull in settings
                $settings = get_all_private_settings($configured_fixed_widgets[$default_widget_guid]->guid);
                foreach ($settings as $name => $value) {
                    $widget->{$name} = $value;
                }
                // access is no setting, but could also be controlled from the default widget
                $widget->access = $configured_fixed_widgets[$default_widget_guid]->access;
                // save the widget (needed for access update)
                $widget->save();
            }
        }
    }
    // add new fixed widgets
    if ($configured_fixed_widgets) {
        foreach ($configured_fixed_widgets as $guid => $widget) {
            if (in_array($guid, $default_widget_guids)) {
                continue;
            }
            // if no widget is found which is already linked to this default widget, clone the widget to the user
            $new_widget = clone $widget;
            $new_widget->container_guid = $user_guid;
            $new_widget->owner_guid = $user_guid;
            // pull in settings
            $settings = get_all_private_settings($guid);
            foreach ($settings as $name => $value) {
                $new_widget->{$name} = $value;
            }
            $new_widget->save();
        }
    }
    // fixing order on all columns for this context, fixed widgets should always stay on top of other 'free' widgets
    foreach ([1, 2, 3] as $column) {
        // reuse previous declared options with a minor adjustment
        $options['private_setting_name_value_pairs'] = ['context' => $context, 'column' => $column];
        $column_widgets = elgg_get_entities_from_private_settings($options);
        $free_widgets = [];
        $max_fixed_order = 0;
        if ($column_widgets) {
            foreach ($column_widgets as $widget) {
                if ($widget->fixed) {
                    if ($widget->order > $max_fixed_order) {
                        $max_fixed_order = $widget->order;
                    }
                } else {
                    $free_widgets[] = $widget;
                }
            }
            if (!empty($max_fixed_order) && !empty($free_widgets)) {
                foreach ($free_widgets as $widget) {
                    $widget->order += $max_fixed_order;
                }
            }
        }
    }
    // revert access
    elgg_set_ignore_access($old_ia);
    elgg_pop_context();
    // set the user timestamp
    elgg_set_plugin_user_setting($context . '_fixed_ts', time(), $user_guid, 'widget_manager');
}
 /**
  * elgg_admin_sort_page_menu() should not expect that the supplied menu has a certain hierarchy
  *
  * https://github.com/Elgg/Elgg/issues/6379
  */
 function test_admin_sort_page_menu()
 {
     elgg_push_context('admin');
     elgg_register_plugin_hook_handler('prepare', 'menu:page', 'elgg_admin_sort_page_menu');
     $result = elgg_trigger_plugin_hook('prepare', 'menu:page', array(), array());
     $this->assertTrue(is_array($result), "Admin page menu fails to prepare for viewing");
     elgg_pop_context();
 }
예제 #28
0
<?php

/**
 * List all suggested groups
 */
elgg_push_context('zhg_contact');
$options = array("count" => elgg_extract("count", $vars), "limit" => false, "full_view" => false, "pagination" => false);
$list = elgg_view_entity_list($vars["entities"], $options);
elgg_pop_context('zhg_contact');
$result .= "<div id='zhaohu_manager_member_listing'>";
if (!empty($list)) {
    $result .= $list;
} else {
    $result .= elgg_echo('zhaohu_manager:list:noresults');
}
$result .= "</div>";
echo elgg_view_module("main", "", $result);
예제 #29
0
파일: content.php 프로젝트: n8b/VMN
    }
    if (!empty($owner_guids)) {
        $options["owner_guids"] = $owner_guids;
    }
}
if ($widget->context == "groups") {
    if ($widget->group_only !== "no") {
        $options["container_guids"] = array($widget->getContainerGUID());
    }
} elseif (elgg_view_exists("input/grouppicker")) {
    $container_guids = $widget->container_guids;
    if (!empty($container_guids)) {
        $options["container_guids"] = $container_guids;
    }
}
elgg_push_context("search");
$display_option = $widget->display_option;
if (in_array($display_option, array("slim", "simple"))) {
    if ($entities = elgg_get_entities($options)) {
        $num_highlighted = (int) $widget->highlight_first;
        $result .= "<ul class='elgg-list'>";
        $show_avatar = true;
        if ($widget->show_avatar == "no") {
            $show_avatar = false;
        }
        $show_timestamp = true;
        if ($widget->show_timestamp == "no") {
            $show_timestamp = false;
        }
        foreach ($entities as $index => $entity) {
            $icon = "";
예제 #30
0
<?php

/**
 * Elgg owner block
 * Displays page ownership information
 *
 * @package Elgg
 * @subpackage Core
 *
 */
elgg_push_context('owner_block');
// groups and other users get owner block
$owner = elgg_get_page_owner_entity();
if ($owner instanceof ElggGroup || $owner instanceof ElggUser && $owner->getGUID() != elgg_get_logged_in_user_guid()) {
    $header = elgg_view_entity($owner, array('full_view' => false));
    $body = elgg_view_menu('owner_block', array('entity' => $owner));
    $body .= elgg_view('page/elements/owner_block/extend', $vars);
    echo elgg_view('page/components/module', array('header' => $header, 'body' => $body, 'class' => 'elgg-owner-block'));
}
elgg_pop_context();