Example #1
0
function group_tools_join_site_handler($event, $type, $relationship)
{
    if (!empty($relationship) && $relationship instanceof ElggRelationship) {
        $user_guid = $relationship->guid_one;
        $site_guid = $relationship->guid_two;
        if ($user = get_user($user_guid)) {
            // ignore access
            $ia = elgg_set_ignore_access(true);
            // add user to the auto join groups
            if ($auto_joins = elgg_get_plugin_setting("auto_join", "group_tools")) {
                $auto_joins = string_to_tag_array($auto_joins);
                foreach ($auto_joins as $group_guid) {
                    if (($group = get_entity($group_guid)) && $group instanceof ElggGroup) {
                        if ($group->site_guid == $site_guid) {
                            // join the group
                            $group->join($user);
                        }
                    }
                }
            }
            // auto detect email invited groups
            if ($groups = group_tools_get_invited_groups_by_email($user->email, $site_guid)) {
                foreach ($groups as $group) {
                    // join the group
                    $group->join($user);
                }
            }
            // restore access settings
            elgg_set_ignore_access($ia);
        }
    }
}
Example #2
0
function language_selector_get_allowed_translations()
{
    $configured_allowed = elgg_get_plugin_setting("allowed_languages", "language_selector");
    if (empty($configured_allowed)) {
        $allowed = array("en");
        $installed_languages = get_installed_translations();
        $min_completeness = (int) elgg_get_plugin_setting("min_completeness", "language_selector");
        if ($min_completeness > 0) {
            $update_completeness = false;
            if (elgg_is_active_plugin("translation_editor")) {
                if (elgg_is_admin_logged_in()) {
                    $update_completeness = true;
                }
                $completeness_function = "translation_editor_get_language_completeness";
            } else {
                $completeness_function = "get_language_completeness";
            }
            foreach ($installed_languages as $lang_id => $lang_description) {
                if ($lang_id != "en") {
                    if (($completeness = $completeness_function($lang_id)) >= $min_completeness) {
                        $allowed[] = $lang_id;
                    }
                }
            }
        }
        elgg_set_plugin_setting("allowed_languages", implode(",", $allowed), "language_selector");
    } else {
        $allowed = string_to_tag_array($configured_allowed);
    }
    return $allowed;
}
Example #3
0
/**
 * Web service to update profile information
 *
 * @param string $username username to update profile information
 *
 * @param $profile
 * @return bool
 * @throws InvalidParameterException
 */
function user_save_profile($username, $profile)
{
    if (!$username) {
        $user = elgg_get_logged_in_user_entity();
    } else {
        $user = get_user_by_username($username);
    }
    if (!$user) {
        throw new InvalidParameterException('registration:usernamenotvalid');
    }
    $owner = get_entity($user->guid);
    $profile_fields = elgg_get_config('profile_fields');
    foreach ($profile_fields as $shortname => $valuetype) {
        $value = $profile[$shortname];
        $value = html_entity_decode($value, ENT_COMPAT, 'UTF-8');
        if ($valuetype != 'longtext' && elgg_strlen($value) > 250) {
            $error = elgg_echo('profile:field_too_long', array(elgg_echo("profile:{$shortname}")));
            return $error;
        }
        if ($valuetype == 'tags') {
            $value = string_to_tag_array($value);
        }
        $input[$shortname] = $value;
    }
    $name = strip_tags($profile['name']);
    if ($name) {
        if (elgg_strlen($name) > 50) {
            return elgg_echo('user:name:fail');
        } elseif ($owner->name != $name) {
            $owner->name = $name;
            return $owner->save();
        }
    }
    if (sizeof($input) > 0) {
        foreach ($input as $shortname => $value) {
            $options = array('guid' => $owner->guid, 'metadata_name' => $shortname);
            elgg_delete_metadata($options);
            if (isset($accesslevel[$shortname])) {
                $access_id = (int) $accesslevel[$shortname];
            } else {
                // this should never be executed since the access level should always be set
                $access_id = ACCESS_DEFAULT;
            }
            if (is_array($value)) {
                $i = 0;
                foreach ($value as $interval) {
                    $i++;
                    $multiple = $i > 1 ? TRUE : FALSE;
                    create_metadata($owner->guid, $shortname, $interval, 'text', $owner->guid, $access_id, $multiple);
                }
            } else {
                create_metadata($owner->guid, $shortname, $value, 'text', $owner->guid, $access_id);
            }
        }
    }
    return "Success";
}
 public function getOptions()
 {
     $field_options = array();
     if (!empty($this->fieldoptions)) {
         $field_options = string_to_tag_array($this->fieldoptions);
         $field_options = array_combine(array_values($field_options), $field_options);
         // input radio and checkbox require non-numeric keys
     }
     return $field_options;
 }
Example #5
0
/**
 * Get the configured group guids
 *
 * @return array
 */
function test_panel_get_group_guids()
{
    static $result;
    if (!isset($result)) {
        $result = [];
        $setting = elgg_get_plugin_setting('group_guids', 'test_panel');
        if (!empty($setting)) {
            $result = string_to_tag_array($setting);
        }
    }
    return $result;
}
Example #6
0
function white_list_admin($hook, $type, $value, $params)
{
    $pluginId = get_input('plugin_id');
    if ($pluginId != 'white_list') {
        return $value;
    }
    $company_emails = get_input('company_email');
    $company_emails = string_to_tag_array($company_emails);
    $site = elgg_get_site_entity();
    $site->company_emails = $company_emails;
    system_message(elgg_echo("filters:save:success"));
    forward(REFERER);
}
Example #7
0
 /**
  * Register new widget contexts for use on custom widget pages
  *
  * @param string $hook_name    name of the hook
  * @param string $entity_type  type of the hook
  * @param string $return_value current return value
  * @param array  $params       hook parameters
  *
  * @return string
  */
 public static function addExtraContextsAsAvailableWidgetsContext($hook_name, $entity_type, $return_value, $params)
 {
     if (empty($return_value)) {
         return;
     }
     $setting = strtolower(elgg_get_plugin_setting('extra_contexts', 'widget_manager'));
     if (empty($setting)) {
         return;
     }
     $contexts = string_to_tag_array($setting);
     if ($contexts && in_array($return_value, $contexts)) {
         return 'index';
     }
 }
Example #8
0
/**
 * Saves the site categories.
 *
 * @param type $hook
 * @param type $type
 * @param type $value
 * @param type $params
 */
function categories_save_site_categories($hook, $type, $value, $params)
{
    $plugin_id = get_input('plugin_id');
    if ($plugin_id != 'categories') {
        return $value;
    }
    $categories = get_input('categories');
    $categories = string_to_tag_array($categories);
    $site = elgg_get_site_entity();
    $site->categories = $categories;
    system_message(elgg_echo("categories:save:success"));
    elgg_delete_admin_notice('categories_admin_notice_no_categories');
    forward(REFERER);
}
Example #9
0
/**
 * Reorganize entity menu
 *
 * @param string         $hook   "register"
 * @param string         $type   "menu:entity"
 * @param ElggMenuItem[] $return Menu
 * @param array          $params Hook params
 * @return ElggMenuItem[]
 */
function menus_entity_setup($hook, $type, $return, $params)
{
    $setting_primary = elgg_get_plugin_setting('primary_actions', 'menus_entity', '');
    $primary_actions = (array) string_to_tag_array($setting_primary);
    $setting_remove = elgg_get_plugin_setting('remove_actions', 'menus_entity', '');
    $remove_actions = (array) string_to_tag_array($setting_remove);
    $ellipsis = false;
    foreach ($return as &$item) {
        if (!$item instanceof ElggMenuItem) {
            continue;
        }
        if (in_array($item->getName(), $remove_actions)) {
            $item = null;
            continue;
        }
        if (in_array($item->getName(), $primary_actions) || !$item->getHref()) {
            continue;
        }
        $ellipsis = true;
        $item->setParentName('ellipsis');
        // combine all menus into one section
        // subsection data is used by menus_api, if enabled
        $item->setData('subsection', $item->getSection());
        $item->setSection('default');
        switch ($item->getName()) {
            case 'edit':
                $item->setText(elgg_echo('edit'));
                $item->setData('icon', 'pencil');
                $item->setData('subsection', 'admin');
                break;
            case 'delete':
                $item->setText(elgg_echo('delete'));
                $item->setData('icon', 'remove');
                $item->setData('subsection', 'admin');
                break;
        }
    }
    if ($ellipsis) {
        $icon = elgg_get_plugin_setting('icon', 'menus_entity');
        if (!$icon) {
            $icon = 'ellipsis-v';
        }
        $return[] = ElggMenuItem::factory(array('name' => 'ellipsis', 'href' => '#', 'text' => elgg_view_icon($icon), 'item_class' => 'elgg-menu-item-has-dropdown', 'data-my' => 'right top', 'data-at' => 'right bottom+5px', 'priority' => 9999, 'section' => 'default'));
    }
    return array_filter($return);
}
Example #10
0
/**
 * Save FollowTags
 *
 */
function follow_tags_save_follow_tags($input, $id, $notify)
{
    // Get FollowTagObject and Clear all Tag Relationships
    $user = elgg_get_logged_in_user_entity();
    $followTags = get_entity($id);
    $followTags->clearRelationships();
    $followTags->description = $input;
    $followTags->title = $user->name;
    $followTags->access_id = 1;
    $followTags->notify = $notify;
    // Convert the Taginput string to array and save to FollowTagObj
    $tagarray = string_to_tag_array($input);
    $followTags->tags = $tagarray;
    $saved = $followTags->save();
    if (!$saved) {
        return false;
    }
    return true;
}
Example #11
0
/**
 * Save FollowTags
 *
 */
function follow_tags_save_follow_tags($input, $id, $notify)
{
    // Get FollowTagObject and Delete all Tag Relationships
    $user = elgg_get_logged_in_user_entity();
    $access_id = get_default_access($user);
    $followTags = get_entity($id);
    if ($followTags->getSubtype() == 'FollowTags') {
        $followTags->deleteRelationships();
        $followTags->description = $input;
        $followTags->title = $user->name;
        $followTags->access_id = $access_id;
        // Convert the Taginput string to array and save to FollowTagObj
        $tagarray = string_to_tag_array($input);
        $followTags->tags = $tagarray;
        $saved = $followTags->save();
    }
    if (!$saved) {
        return false;
    }
    return true;
}
Example #12
0
function elgg_stars_init()
{
    // Register valid annotaiton names
    $criteria = elgg_get_plugin_setting('criteria', 'elgg_stars');
    if (!$criteria) {
        elgg_stars_register_rating_annotation_name('starrating');
    } else {
        $criteria = string_to_tag_array($criteria);
        foreach ($criteria as $criterion) {
            elgg_stars_register_rating_annotation_name($criterion);
        }
    }
    $root = dirname(__FILE__);
    // Register actions
    elgg_register_action('elgg_stars/settings/save', "{$root}/actions/settings/elgg_stars.php", 'admin');
    elgg_register_action('stars/rate', "{$root}/actions/stars/rate.php");
    elgg_register_action('stars/delete', "{$root}/actions/stars/delete.php");
    // Stars JS and CSS
    elgg_extend_view('css/elgg', 'stars/css');
    elgg_register_js('jquery.rateit', '/mod/elgg_stars/vendors/rateit/jquery.rateit.min.js', 'footer', 600);
    elgg_register_simplecache_view('js/stars/js');
    elgg_register_js('elgg.rateit', elgg_get_simplecache_url('js', 'stars/js'), 'footer', 700);
    // Setup menus
    elgg_register_plugin_hook_handler('register', 'menu:entity', 'elgg_stars_menu_setup');
    elgg_register_plugin_hook_handler('register', 'menu:annotation', 'elgg_stars_annotation_menu_setup');
    // Permissions
    elgg_register_plugin_hook_handler('permissions_check:annotate', 'all', 'elgg_stars_can_annotate');
    // Add an annotation view for registered ratings
    elgg_register_plugin_hook_handler('view', 'annotation/default', 'elgg_stars_annotation_view_replacement');
    // Extend the sidebar with the ratings module
    elgg_register_plugin_hook_handler('view', 'page/elements/comments', 'elgg_stars_comments_rating_addon', 900);
    elgg_register_plugin_hook_handler('comments', 'all', 'elgg_stars_comments_rating_addon', 900);
    // Get rating criteria that applies to an entity
    elgg_register_plugin_hook_handler('criteria', 'stars', 'elgg_stars_rating_criteria_hook');
    // Setup widgets
    elgg_register_widget_type('highestrating', elgg_echo('stars:widget:highestrating'), elgg_echo('stars:widget:highestrating:desc'), 'all', false);
}
Example #13
0
File: save.php Project: ibou77/elgg
    $topic = new ElggObject();
    $topic->subtype = 'groupforumtopic';
} else {
    // load original file object
    $topic = get_entity($guid);
    if (!elgg_instanceof($topic, 'object', 'groupforumtopic') || !$topic->canEdit()) {
        register_error(elgg_echo('discussion:topic:notfound'));
        forward(REFERER);
    }
}
$topic->title = $title;
$topic->description = $desc;
$topic->status = $status;
$topic->access_id = $access_id;
$topic->container_guid = $container_guid;
$topic->tags = string_to_tag_array($tags);
$result = $topic->save();
if (!$result) {
    register_error(elgg_echo('discussion:error:notsaved'));
    forward(REFERER);
}
// topic saved so clear sticky form
elgg_clear_sticky_form('topic');
// handle results differently for new topics and topic edits
if ($new_topic) {
    system_message(elgg_echo('discussion:topic:created'));
    elgg_create_river_item(array('view' => 'river/object/groupforumtopic/create', 'action_type' => 'create', 'subject_guid' => elgg_get_logged_in_user_guid(), 'object_guid' => $topic->guid));
} else {
    system_message(elgg_echo('discussion:topic:updated'));
}
forward($topic->getURL());
Example #14
0
function profile_array_decoder(&$v)
{
    $v = _elgg_html_decode($v);
}
// Get group fields
$input = array();
foreach (elgg_get_config('group') as $shortname => $valuetype) {
    $input[$shortname] = get_input($shortname);
    // @todo treat profile fields as unescaped: don't filter, encode on output
    if (is_array($input[$shortname])) {
        array_walk_recursive($input[$shortname], 'profile_array_decoder');
    } else {
        $input[$shortname] = _elgg_html_decode($input[$shortname]);
    }
    if ($valuetype == 'tags') {
        $input[$shortname] = string_to_tag_array($input[$shortname]);
    }
}
$input['name'] = htmlspecialchars(get_input('name', '', false), ENT_QUOTES, 'UTF-8');
$user = elgg_get_logged_in_user_entity();
$group_guid = (int) get_input('group_guid');
$is_new_group = $group_guid == 0;
if ($is_new_group && elgg_get_plugin_setting('limited_groups', 'groups') == 'yes' && !$user->isAdmin()) {
    register_error(elgg_echo("groups:cantcreate"));
    forward(REFERER);
}
$group = new ElggGroup($group_guid);
// load if present, if not create a new group
if ($group_guid && !$group->canEdit()) {
    register_error(elgg_echo("groups:cantedit"));
    forward(REFERER);
Example #15
0
    $vars['categories'] = hypeCategories()->categories->getItemCategories($vars['entity']);
    unset($vars['entity']);
}
if (!empty($vars['type'])) {
    $type = "&type=" . rawurlencode($vars['type']);
} else {
    $type = "";
}
if (!empty($vars['subtype'])) {
    $subtype = "&subtype=" . rawurlencode($vars['subtype']);
} else {
    $subtype = "";
}
if (empty($vars['categories']) && !empty($vars['value'])) {
    if (!is_array($vars['value'])) {
        $vars['value'] = string_to_tag_array($vars['value']);
    }
    foreach ($vars['value'] as $guid) {
        $vars['categories'][] = get_entity($guid);
    }
}
if (empty($vars['categories'])) {
    return;
}
$list_class = "elgg-categories";
if (isset($vars['list_class'])) {
    $list_class = "{$list_class} {$vars['list_class']}";
}
$item_class = "elgg-category";
if (isset($vars['item_class'])) {
    $item_class = "{$item_class} {$vars['item_class']}";
Example #16
0
    $new = true;
    // Initialise a new Poll
    $poll = new Poll();
    // Set its owner to the current user
    $poll->owner_guid = $user->guid;
    $poll->container_guid = $container_guid;
    // Success message
    $message = elgg_echo("poll:added");
}
$poll->access_id = $access_id;
$poll->question = $question;
$poll->title = $question;
$poll->description = $description;
$poll->open_poll = $open_poll ? 1 : 0;
$poll->close_date = empty($close_date) ? null : $close_date;
$poll->tags = string_to_tag_array($tags);
if (!$poll->save()) {
    register_error(elgg_echo("poll:error"));
    forward(REFERER);
}
$poll->setChoices($new_choices);
poll_manage_front_page($poll, $front_page);
elgg_clear_sticky_form('poll');
if ($new) {
    $poll_create_in_river = elgg_get_plugin_setting('create_in_river', 'poll');
    if ($poll_create_in_river != 'no') {
        elgg_create_river_item(array('view' => 'river/object/poll/create', 'action_type' => 'create', 'subject_guid' => $user->guid, 'object_guid' => $poll->guid));
    }
}
system_message($message);
// Forward to the poll page
Example #17
0
// Make sure the title / description aren't blank
if (empty($title)) {
    register_error(elgg_echo('answers:question:blank'));
    forward(REFERER);
}
// Otherwise, save the question
if ($guid) {
    $question = get_entity($guid);
    $new = false;
} else {
    $question = new ElggObject();
    $question->subtype = 'question';
    $new = true;
}
$question->access_id = $access_id;
$question->title = $title;
$question->description = $description;
$question->tags = string_to_tag_array($tags);
$question->container_guid = $container_guid;
if ($question->save()) {
    elgg_clear_sticky_form('question');
    system_message(elgg_echo('answers:question:posted') . $sysmsg);
    if ($new) {
        // only add river item when this is a new question
        add_to_river('river/object/question/create', 'create', $user_guid, $question->guid);
    }
    forward($question->getURL());
} else {
    register_error(elgg_echo('answers:error'));
    forward(REFERER);
}
<?php

/**
 * Add a language without the need for a plugin to provide a part
 */
$code = get_input('code');
if (empty($code)) {
    forward(REFERER);
}
// check for existing custom languages
$custom_languages = elgg_get_plugin_setting('custom_languages', 'translation_editor');
if (!empty($custom_languages)) {
    $custom_languages = string_to_tag_array($custom_languages);
    $custom_languages[] = $code;
    $code = implode(',', array_unique($custom_languages));
}
elgg_set_plugin_setting('custom_languages', $code, 'translation_editor');
// invalidate cache
elgg_flush_caches();
system_message(elgg_echo('translation_editor:action:add_language:success'));
forward(REFERER);
Example #19
0
echo elgg_view('input/text', array('name' => 'params[criteria]', 'value' => $entity->criteria));
echo '</div>';
echo '</div>';
$registered_entities = elgg_get_config('registered_entities');
foreach ($registered_entities as $type => $subtypes) {
    if (sizeof($subtypes) == 0) {
        $str = elgg_echo("item:{$type}");
        $subtype_options[$str] = "{$type}:default";
    } else {
        foreach ($subtypes as $subtype) {
            $str = elgg_echo("item:{$type}:{$subtype}");
            $subtype_options[$str] = "{$type}:{$subtype}";
        }
    }
}
$criteria = $entity->criteria ? string_to_tag_array($entity->criteria) : array();
foreach ($criteria as $criterion) {
    $criteria_options[$criterion] = $criterion;
}
$type_subtype_pairs_setting = isset($entity->type_subtype_pairs) ? unserialize($entity->type_subtype_pairs) : array();
$granular_criteria = isset($entity->granular_criteria) ? unserialize($entity->granular_criteria) : array();
echo '<div>';
echo '<h3>' . elgg_echo('stars:settings:type_subtype_pairs') . '</h3>';
echo elgg_view('input/hidden', array('name' => 'params[type_subtype_pairs]', 'value' => ''));
echo '<table class="elgg-table-alt">';
echo '<thead>';
echo '<tr>';
echo '<th>' . elgg_echo('stars:settings:type_subtype_pairs') . '</th>';
if ($criteria) {
    echo '<th>' . elgg_echo('stars:settings:granular_criteria') . '</th>';
}
Example #20
0
/**
 * Returns suggested groups
 *
 * @param ElggUser $user  (optional) the user to get the groups for, defaults to the current user
 * @param int      $limit (optional) the number of suggested groups to return, default = 10
 *
 * @return ElggGroup[] all the suggested groups
 */
function group_tools_get_suggested_groups($user = null, $limit = null)
{
    $result = array();
    if (!elgg_instanceof($user, "user")) {
        $user = elgg_get_logged_in_user_entity();
    }
    if (is_null($limit)) {
        $limit = get_input("limit", 10);
    }
    $limit = sanitize_int($limit, false);
    if ($user && $limit > 0) {
        $dbprefix = elgg_get_config("dbprefix");
        $group_membership_where = "e.guid NOT IN (SELECT er.guid_two FROM {$dbprefix}entity_relationships er where er.guid_one = {$user->getGUID()} and er.relationship IN ('member', 'membership_request'))";
        if (elgg_get_plugin_setting("auto_suggest_groups", "group_tools") !== "no") {
            $tag_names = elgg_get_registered_tag_metadata_names();
            if (!empty($tag_names)) {
                $user_metadata_options = array("guid" => $user->getGUID(), "limit" => false, "metadata_names" => $tag_names);
                // get metadata
                $user_values = elgg_get_metadata($user_metadata_options);
                if (!empty($user_values)) {
                    // transform to values
                    $user_values = metadata_array_to_values($user_values);
                    // find group with these metadatavalues
                    $group_options = array("type" => "group", "metadata_names" => $tag_names, "metadata_values" => $user_values, "wheres" => $group_membership_where, "group_by" => "e.guid", "order_by" => "count(msn.id) DESC", "limit" => $limit);
                    $groups = elgg_get_entities_from_metadata($group_options);
                    if (!empty($groups)) {
                        foreach ($groups as $group) {
                            $result[$group->getGUID()] = $group;
                            $limit--;
                        }
                    }
                }
            }
        }
        // get admin defined suggested groups
        $group_guids = string_to_tag_array(elgg_get_plugin_setting("suggested_groups", "group_tools"));
        if (!empty($group_guids) && $limit > 0) {
            $group_options = array("guids" => $group_guids, "type" => "group", "wheres" => array($group_membership_where), "limit" => $limit);
            if (!empty($result)) {
                $suggested_guids = array_keys($result);
                $group_options["wheres"][] = "e.guid NOT IN (" . implode(",", $suggested_guids) . ")";
            }
            $groups = elgg_get_entities($group_options);
            if (!empty($groups)) {
                foreach ($groups as $group) {
                    $result[$group->getGUID()] = $group;
                }
            }
        }
    }
    return $result;
}
Example #21
0
/**
 * Check if a given handler is part of the configured extra contexts
 *
 * @param string $handler name of the context handler to check
 *
 * @return boolean
 */
function widget_manager_is_extra_context($handler)
{
    $result = false;
    $extra_contexts = elgg_get_plugin_setting('extra_contexts', 'widget_manager');
    if ($extra_contexts) {
        $contexts = string_to_tag_array($extra_contexts);
        if ($contexts) {
            if (in_array($handler, $contexts)) {
                $result = true;
            }
        }
    }
    return $result;
}
Example #22
0
function subsite_manager_get_global_enabled_plugins()
{
    static $result;
    if (!isset($result)) {
        $result = subsite_manager_get_required_plugins();
        $site = elgg_get_site_entity();
        if (subsite_manager_on_subsite()) {
            $site = $site->getOwnerEntity();
        }
        if ($enable_everywhere = $site->getPrivateSetting("enabled_everywhere")) {
            $enable_everywhere = string_to_tag_array($enable_everywhere);
            $result = array_merge($result, $enable_everywhere);
        }
        $result = array_values(array_unique($result));
    }
    return $result;
}
Example #23
0
foreach ($values as $name => $default) {
    if ($name === 'title') {
        $value = htmlspecialchars(get_input('title', $default, false), ENT_QUOTES, 'UTF-8');
    } else {
        $value = get_input($name, $default);
    }
    if (in_array($name, $required) && empty($value)) {
        $error = elgg_echo("blog:error:missing:{$name}");
    }
    if ($error) {
        break;
    }
    switch ($name) {
        case 'tags':
            if ($value) {
                $values[$name] = string_to_tag_array($value);
            } else {
                unset($values[$name]);
            }
            break;
        case 'excerpt':
            if ($value) {
                $values[$name] = elgg_get_excerpt($value);
            }
            break;
        case 'container_guid':
            // this can't be empty or saving the base entity fails
            if (!empty($value)) {
                if (can_write_to_container($user->getGUID(), $value)) {
                    $values[$name] = $value;
                } else {
Example #24
0
function translation_editor_get_disabled_languages()
{
    static $result;
    if (!isset($result)) {
        $result = false;
        if ($disabled_languages = elgg_get_plugin_setting(TRANSLATION_EDITOR_DISABLED_LANGUAGE, "translation_editor")) {
            $result = string_to_tag_array($disabled_languages);
        }
    }
    return $result;
}
Example #25
0
/**
 * Create or edit a page
 *
 * @package ElggPages
 */
$variables = elgg_get_config('pages');
$input = array();
foreach ($variables as $name => $type) {
    if ($name == 'title') {
        $input[$name] = htmlspecialchars(get_input($name, '', false), ENT_QUOTES, 'UTF-8');
    } else {
        $input[$name] = get_input($name);
    }
    if ($type == 'tags') {
        $input[$name] = string_to_tag_array($input[$name]);
    }
}
// Get guids
$page_guid = (int) get_input('page_guid');
$container_guid = (int) get_input('container_guid');
$parent_guid = (int) get_input('parent_guid');
elgg_make_sticky_form('page');
if (!$input['title']) {
    register_error(elgg_echo('pages:error:no_title'));
    forward(REFERER);
}
if ($page_guid) {
    $page = get_entity($page_guid);
    if (!$page || !$page->canEdit()) {
        register_error(elgg_echo('pages:error:no_save'));
    register_error(elgg_echo('plugins:error:badlicense'));
    forward(REFERER);
}
$mimetype = plugins_get_mimetype('upload');
if (!$mimetype) {
    register_error(elgg_echo('plugins:error:badformat'));
    forward(REFERER);
}
// Create the plugin project
$plugin_project = new PluginProject();
$plugin_project->owner_guid = $user->getGUID();
$plugin_project->container_guid = $user->getGUID();
$plugin_project->access_id = $project_access_id;
$plugin_project->title = $title;
$plugin_project->description = $description;
$plugin_project->tags = string_to_tag_array($tags);
$plugin_project->plugincat = $plugincat;
$plugin_project->license = $license;
$plugin_project->summary = $summary;
$plugin_project->homepage = $homepage;
$plugin_project->repo = $repo;
$plugin_project->donate = $donate;
$plugin_project->digg = 0;
$plugin_project->plugin_type = $plugin_type;
$plugin_project->save();
// Extract file and save to default filestore (for now)
$prefix = "plugins/";
$filestorename = $prefix . strtolower(time() . $_FILES['upload']['name']);
$release = new PluginRelease();
$release->title = $plugin_project->title;
$release->setFilename($filestorename);
<?php

// only logged in users can add blog posts
gatekeeper();
// get the form input
$title = get_input('title');
$body = get_input('body');
$tags = string_to_tag_array(get_input('tags'));
// create a new blog object
$blogpost = new ElggObject();
$blogpost->title = $title;
$blogpost->description = $body;
$blogpost->subtype = "blog";
// for now make all blog posts public
$blogpost->access_id = ACCESS_PUBLIC;
// owner is logged in user
$blogpost->owner_guid = get_loggedin_userid();
// save tags as metadata
$blogpost->tags = $tags;
// save to database
$blogpost->save();
// forward user to a page that displays the post
forward($blogpost->getURL());
Example #28
0
<?php

/**
 * Image word tag river view
 */
$tagger = $vars['item']->getSubjectEntity();
$tagged_image = $vars['item']->getObjectEntity();
$annotation = $vars['item']->getAnnotation();
if (!$annotation) {
    return;
}
$image = get_entity($annotation->entity_guid);
// viewer may not have permission to view image
if (!$image) {
    return;
}
$attachments = elgg_view_entity_icon($image, 'tiny');
$tagger_link = elgg_view('output/url', array('href' => $tagger->getURL(), 'text' => $tagger->name, 'class' => 'elgg-river-subject', 'is_trusted' => true));
$image_link = elgg_view('output/url', array('href' => $image->getURL(), 'text' => $image->getTitle(), 'is_trusted' => true));
$value = $annotation->value;
$tag = unserialize($value);
$tag_array = string_to_tag_array($tag->value);
$message = elgg_view('output/tags', array('value' => $tag_array));
if (count($tag_array) > 1) {
    $summary = elgg_echo('image:river:wordtagged', array($tagger_link, $image_link));
} else {
    $summary = elgg_echo('image:river:wordtagged_single', array($tagger_link, $image_link));
}
echo elgg_view('river/elements/layout', array('item' => $vars['item'], 'attachments' => $attachments, 'message' => $message, 'summary' => $summary));
Example #29
0
File: content.php Project: n8b/VMN
                $text .= "<a href='" . $owner->getURL() . "'>" . $owner->name . "</a>";
                if ($show_timestamp) {
                    $text .= " <span class='elgg-quiet'>" . elgg_view_friendly_time($entity->time_created) . "</span>";
                }
                $result .= elgg_view_image_block($icon, $text);
            }
            $result .= "</li>";
        }
        $result .= "</ul>";
    }
} else {
    $result = elgg_list_entities($options);
}
if (empty($result)) {
    $result = elgg_echo("notfound");
} elseif ($widget->show_search_link == "yes" && !empty($widget->tags) && elgg_is_active_plugin("search")) {
    $tags = $widget->tags;
    if (elgg_is_active_plugin("search_advanced")) {
        $tags_text = $tags;
    } else {
        $tags = string_to_tag_array($tags);
        $tags_text = $tags[0];
    }
    $search_postfix = "";
    if (count($content_type) == 1) {
        $search_postfix = "&entity_subtype=" . $content_type[0] . "&entity_type=object&search_type=entities";
    }
    $result .= "<div class='elgg-widget-more'>" . elgg_view("output/url", array("text" => elgg_echo("searchtitle", array($tags_text)), "href" => "search?q=" . $tags_text . $search_postfix)) . "</div>";
}
echo $result;
elgg_pop_context();
Example #30
0
/**
 * Update the Elgg profile with LinkedIn data
 *
 * @param int $user_guid the user_guid of the profile to update
 *
 * @return void
 */
function socialink_linkedin_sync_profile_metadata($user_guid = 0)
{
    global $CONFIG;
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    // can we get a user
    if (($user = get_user($user_guid)) && socialink_linkedin_is_connected($user_guid)) {
        // does the user allow sync
        if (elgg_get_plugin_user_setting("linkedin_sync_allow", $user->getGUID(), "socialink") != "no") {
            // get configured fields and network fields
            if (($configured_fields = socialink_get_configured_network_fields("linkedin")) && ($network_fields = socialink_get_network_fields("linkedin"))) {
                // ask the api for all fields
                if ($api_result = socialink_linkedin_get_profile_information($user->getGUID())) {
                    $api_result = json_decode($api_result);
                    // check settings for each field
                    foreach ($configured_fields as $setting_name => $profile_field) {
                        $setting = "linkedin_sync_" . $setting_name;
                        if (elgg_get_plugin_user_setting($setting, $user->getGUID(), "socialink") != "no") {
                            $api_setting = $network_fields[$setting_name];
                            // get the correct value from api result
                            if (stristr($api_setting, "->")) {
                                $temp_fields = explode("->", $api_setting);
                                $temp_result = $api_result;
                                for ($i = 0; $i < count($temp_fields); $i++) {
                                    $temp_result = $temp_result->{$temp_fields}[$i];
                                }
                            } else {
                                $temp_result = $api_result->{$api_setting};
                            }
                            // are we dealing with a tags profile field type
                            if (!empty($CONFIG->profile) && is_array($CONFIG->profile)) {
                                if (array_key_exists($profile_field, $CONFIG->profile) && $CONFIG->profile[$profile_field] == "tags") {
                                    $temp_result = string_to_tag_array($temp_result);
                                }
                            }
                            // check if the user has this metadata field, to get access id
                            $params = array("guid" => $user->getGUID(), "metadata_name" => $profile_field, "limit" => false);
                            if ($metadata = elgg_get_metadata($params)) {
                                if (is_array($metadata)) {
                                    $access_id = $metadata[0]->access_id;
                                } else {
                                    $access_id = $metadata->access_id;
                                }
                            } else {
                                $access_id = get_default_access($user);
                            }
                            // remove metadata to set new values
                            elgg_delete_metadata($params);
                            // make new metadata field
                            if (!empty($temp_result)) {
                                if (is_array($temp_result)) {
                                    foreach ($temp_result as $index => $temp_value) {
                                        if ($index > 0) {
                                            $multiple = true;
                                        } else {
                                            $multiple = false;
                                        }
                                        create_metadata($user->getGUID(), $profile_field, $temp_value, 'text', $user->getGUID(), $access_id, $multiple);
                                    }
                                } else {
                                    create_metadata($user->getGUID(), $profile_field, $temp_result, 'text', $user->getGUID(), $access_id);
                                }
                            }
                        }
                    }
                }
            }
            // sync profile icon, only if the user has no icon
            if (empty($user->icontime)) {
                socialink_linkedin_sync_profile_icon($user->getGUID());
            }
        }
    }
}