コード例 #1
0
ファイル: functions.php プロジェクト: amcfarlane1251/ongarde
function bookmark_tools_get_folders($container_guid = 0)
{
    $result = false;
    if (empty($container_guid)) {
        $container_guid = elgg_get_page_owner_guid();
    }
    if (!empty($container_guid)) {
        $options = array("type" => "object", "subtype" => BOOKMARK_TOOLS_SUBTYPE, "container_guid" => $container_guid, "limit" => false);
        if ($folders = elgg_get_entities($options)) {
            $parents = array();
            foreach ($folders as $folder) {
                $parent_guid = (int) $folder->parent_guid;
                if (!empty($parent_guid)) {
                    if ($temp = get_entity($parent_guid)) {
                        if ($temp->getSubtype() != BOOKMARK_TOOLS_SUBTYPE) {
                            $parent_guid = 0;
                        }
                    } else {
                        $parent_guid = 0;
                    }
                } else {
                    $parent_guid = 0;
                }
                if (!array_key_exists($parent_guid, $parents)) {
                    $parents[$parent_guid] = array();
                }
                $parents[$parent_guid][] = $folder;
            }
            $result = bookmark_tools_sort_folders($parents, 0);
        }
    }
    return $result;
}
コード例 #2
0
ファイル: WidgetsService.php プロジェクト: cyrixhero/Elgg
 /**
  * @see elgg_create_widget
  * @access private
  * @since 1.9.0
  */
 public function createWidget($owner_guid, $handler, $context, $access_id = null)
 {
     if (empty($owner_guid) || empty($handler) || !$this->validateType($handler)) {
         return false;
     }
     $owner = get_entity($owner_guid);
     if (!$owner) {
         return false;
     }
     $widget = new \ElggWidget();
     $widget->owner_guid = $owner_guid;
     $widget->container_guid = $owner_guid;
     // @todo - will this work for group widgets?
     if (isset($access_id)) {
         $widget->access_id = $access_id;
     } else {
         $widget->access_id = get_default_access();
     }
     if (!$widget->save()) {
         return false;
     }
     // private settings cannot be set until \ElggWidget saved
     $widget->handler = $handler;
     $widget->context = $context;
     return $widget->getGUID();
 }
コード例 #3
0
ファイル: system.php プロジェクト: pleio/subsite_manager
function subsite_manager_siteid_hook($hook, $type, $return, $params)
{
    global $SUBSITE_MANAGER_CUSTOM_DOMAIN;
    $result = false;
    elgg_register_classes(dirname(__FILE__) . "/classes/");
    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "") {
        $protocol = "https";
    } else {
        $protocol = "http";
    }
    if (strpos($_SERVER["HTTP_HOST"], "www.") === 0) {
        $alt_host = str_replace("www.", "", $_SERVER["HTTP_HOST"]);
    } else {
        $alt_host = "www." . $_SERVER["HTTP_HOST"];
    }
    $url = $protocol . "://" . $_SERVER["HTTP_HOST"] . "/";
    $alt_url = $protocol . "://" . $alt_host . "/";
    if ($site = get_site_by_url($url)) {
        $result = $site->getGUID();
    } elseif ($site = get_site_by_url($alt_url)) {
        $result = $site->getGUID();
    } else {
        // no site found, forward to main site
        $default_site_guid = (int) datalist_get("default_site");
        $default_site = get_entity($default_site_guid);
        forward($default_site->url);
    }
    return $result;
}
コード例 #4
0
ファイル: page_handlers.php プロジェクト: pleio/odt_editor
/**
 * Dispatches odt_editor pages.
 * URLs take the form of
 *  Save as:       odt_editor/saveas/<guid>
 *
 * @param array $page
 * @return bool
 */
function odt_editor_page_handler($page)
{
    $odt_editor_pages_dir = elgg_get_plugins_path() . 'odt_editor/pages';
    $page_type = $page[0];
    switch ($page_type) {
        case 'saveas':
            set_input('guid', $page[1]);
            include "{$odt_editor_pages_dir}/odt_editor/saveas.php";
            break;
        case 'create':
            $container = get_entity($page[1]);
            if (!$container) {
                $container = get_loggedin_userid();
            }
            // show new document in WebODF editor page
            // 0 as indicator for new document
            set_input('guid', 0);
            set_input('container_guid', $page[1]);
            include "{$odt_editor_pages_dir}/file/odt_editor.php";
            $result = false;
            break;
        case 'gettemplate':
            include "{$odt_editor_pages_dir}/odt_editor/gettemplate.php";
            break;
        default:
            return false;
    }
    return true;
}
コード例 #5
0
ファイル: view.php プロジェクト: mustafabicer/elggplugins
/**
 * View a single blogbook
 *
 * @package Elggtblogs
 */
function recursive_breadcrumb($tblog)
{
    if ($tblog->parent_guid != '') {
        recursive_breadcrumb(get_entity($tblog->parent_guid));
    }
    elgg_push_breadcrumb($tblog->title, "/blogbook/view/{$tblog->guid}");
}
コード例 #6
0
ファイル: Menus.php プロジェクト: coldtrick/event_manager
 /**
  * Adds menu items to the user hover menu
  *
  * @param string $hook        hook name
  * @param string $entity_type hook type
  * @param array  $returnvalue current return value
  * @param array  $params      parameters
  *
  * @return array
  */
 public static function registerUserHover($hook, $entity_type, $returnvalue, $params)
 {
     $guid = get_input('guid');
     $user = elgg_extract('entity', $params);
     if (empty($guid) || empty($user)) {
         return;
     }
     $event = get_entity($guid);
     if (!$event instanceof \Event) {
         return;
     }
     if (!$event->canEdit()) {
         return;
     }
     $result = $returnvalue;
     // kick from event (assumes users listed on the view page of an event)
     $href = 'action/event_manager/event/rsvp?guid=' . $event->getGUID() . '&user='******'&type=' . EVENT_MANAGER_RELATION_UNDO;
     $item = \ElggMenuItem::factory(['name' => 'event_manager_kick', 'text' => elgg_echo('event_manager:event:relationship:kick'), 'href' => $href, 'is_action' => true, 'section' => 'action']);
     $result[] = $item;
     $user_relationship = $event->getRelationshipByUser($user->getGUID());
     if ($user_relationship == EVENT_MANAGER_RELATION_ATTENDING_PENDING) {
         // resend confirmation
         $href = 'action/event_manager/event/resend_confirmation?guid=' . $event->getGUID() . '&user='******'name' => 'event_manager_resend_confirmation', 'text' => elgg_echo("event_manager:event:menu:user_hover:resend_confirmation"), 'href' => $href, 'is_action' => true, 'section' => 'action']);
         $result[] = $item;
     }
     if (in_array($user_relationship, [EVENT_MANAGER_RELATION_ATTENDING_PENDING, EVENT_MANAGER_RELATION_ATTENDING_WAITINGLIST])) {
         // move to attendees
         $href = 'action/event_manager/attendees/move_to_attendees?guid=' . $event->getGUID() . '&user='******'name' => 'event_manager_move_to_attendees', 'text' => elgg_echo('event_manager:event:menu:user_hover:move_to_attendees'), 'href' => $href, 'is_action' => true, 'section' => 'action']);
         $result[] = $item;
     }
     return $result;
 }
コード例 #7
0
ファイル: start.php プロジェクト: centillien/anypage_widgets
/**
 * Anypage Widgets convert
 *
 * Convers a description/text into content with widgets.
 * It replaces BBCode tags with content from widgets, for example:
 * [WIDGET:home]
 *
 * @param string $description Description to transform
 *
 * @return string Transformed description
 */
function anypage_widgets_convert($description)
{
    return preg_replace_callback('/\\[WIDGET:[^]]+\\]/', function ($matches) {
        $paramsString = substr(strip_tags($matches[0]), 8, -1);
        $params = (array) explode(':', $paramsString);
        if (!isset($params[0])) {
            return 'Widget ID not defined.';
        }
        $widget = get_entity($params[0]);
        if (!myvox_instanceof($widget, 'object', 'widget')) {
            return 'Widget not found.';
        }
        $style = '';
        foreach ($params as $param) {
            $subparam = explode('|', $param);
            switch ($subparam[0]) {
                case 'style':
                    if (isset($subparam[1]) && isset($subparam[2])) {
                        $style .= $subparam[1] . ': ' . $subparam[2] . ';';
                    }
                    break;
            }
        }
        return myvox_view('anypage_widgets/widget', array('body' => myvox_view_entity($widget), 'style' => $style));
    }, $description);
}
コード例 #8
0
ファイル: page_handlers.php プロジェクト: n8b/VMN
/**
 * Take over the groupicon page handler for fallback
 *
 * @param array $page the url elements
 *
 * @return void
 */
function group_tools_groupicon_page_handler($page)
{
    // group guid
    if (!isset($page[0])) {
        header("HTTP/1.1 400 Bad Request");
        exit;
    }
    $group_guid = $page[0];
    $group = get_entity($group_guid);
    if (empty($group) || !elgg_instanceof($group, "group")) {
        header("HTTP/1.1 400 Bad Request");
        exit;
    }
    $owner_guid = $group->getOwnerGUID();
    $icontime = (int) $group->icontime;
    if (empty($icontime)) {
        header("HTTP/1.1 404 Not Found");
        exit;
    }
    // size
    $size = "medium";
    if (isset($page[1])) {
        $icon_sizes = elgg_get_config("icon_sizes");
        if (!empty($icon_sizes) && array_key_exists($page[1], $icon_sizes)) {
            $size = $page[1];
        }
    }
    $params = array("group_guid" => $group_guid, "guid" => $owner_guid, "size" => $size, "icontime" => $icontime);
    $url = elgg_http_add_url_query_elements("mod/group_tools/pages/groups/thumbnail.php", $params);
    forward($url);
}
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function post(ParameterBag $params)
 {
     $user = elgg_get_logged_in_user_entity();
     $object = get_entity($params->guid);
     if (!$object || !$object->canWriteToContainer(0, 'object', 'comment')) {
         throw new GraphException("You are not allowed to comment on this object", 403);
     }
     $comment_text = $params->comment;
     $comment = new ElggComment();
     $comment->owner_guid = $user->guid;
     $comment->container_guid = $object->guid;
     $comment->description = $comment_text;
     $comment->access_id = $object->access_id;
     if (!$comment->save()) {
         throw new GraphException(elgg_echo("generic_comment:failure"));
     }
     // Notify if poster wasn't owner
     if ($object->owner_guid != $user->guid) {
         $owner = $object->getOwnerEntity();
         notify_user($owner->guid, $user->guid, elgg_echo('generic_comment:email:subject', array(), $owner->language), elgg_echo('generic_comment:email:body', array($object->title, $user->name, $comment->description, $comment->getURL(), $user->name, $user->getURL()), $owner->language), array('object' => $comment, 'action' => 'create'));
     }
     $return = array('nodes' => array('comment' => $comment));
     // Add to river
     $river_id = elgg_create_river_item(array('view' => 'river/object/comment/create', 'action_type' => 'comment', 'subject_guid' => $user->guid, 'object_guid' => $comment->guid, 'target_guid' => $object->guid));
     if ($river_id) {
         $river = elgg_get_river(array('ids' => $river_id));
         $return['nodes']['activity'] = $river ? $river[0] : $river_id;
     }
     return $return;
 }
コード例 #10
0
ファイル: start.php プロジェクト: duanhv/mdg-social
/**
 * Determine the best from email address
 *
 * @return string with email address
 */
function phpmailer_extract_from_email()
{
    global $CONFIG;
    $from_email = '';
    $site = get_entity($CONFIG->site_guid);
    // If there's an email address, use it - but only if its not from a user.
    if (isset($from->email) && !$from instanceof ElggUser) {
        $from_email = $from->email;
        // Has the current site got a from email address?
    } else {
        if ($site && isset($site->email)) {
            $from_email = $site->email;
            // If we have a url then try and use that.
        } else {
            if (isset($from->url)) {
                $breakdown = parse_url($from->url);
                $from_email = 'noreply@' . $breakdown['host'];
                // Handle anything with a url
                // If all else fails, use the domain of the site.
            } else {
                $from_email = 'noreply@' . get_site_domain($CONFIG->site_guid);
            }
        }
    }
    return $from_email;
}
コード例 #11
0
ファイル: start.php プロジェクト: iionly/elggx_badges
/**
 * This method is called when a users points are updated.
 * We check to see what the users current balance is and
 * assign the appropriate badge.
 */
function badges_userpoints($hook, $type, $return, $params)
{
    if ($params['entity']->badges_locked) {
        return true;
    }
    $points = $params['entity']->userpoints_points;
    $badge = get_entity($params['entity']->badges_badge);
    $options = array('type' => 'object', 'subtype' => 'badge', 'limit' => false, 'order_by_metadata' => array('name' => 'badges_userpoints', 'direction' => DESC, 'as' => integer));
    $options['metadata_name_value_pairs'] = array(array('name' => 'badges_userpoints', 'value' => $points, 'operand' => '<='));
    $entities = elgg_get_entities_from_metadata($options);
    if ((int) elgg_get_plugin_setting('lock_high', 'elggx_badges')) {
        if ($badge->badges_userpoints > $entities[0]->badges_userpoints) {
            return true;
        }
    }
    if ($badge->guid != $entities[0]->guid) {
        $params['entity']->badges_badge = $entities[0]->guid;
        if (!elgg_trigger_plugin_hook('badges:update', 'object', array('entity' => $user), true)) {
            $params['entity']->badges_badge = $badge->guid;
            return false;
        }
        // Announce it on the river
        $user_guid = $params['entity']->getGUID();
        elgg_delete_river(array("view" => 'river/object/badge/assign', "subject_guid" => $user_guid, "object_guid" => $user_guid));
        elgg_delete_river(array("view" => 'river/object/badge/award', "subject_guid" => $user_guid, "object_guid" => $user_guid));
        elgg_create_river_item(array('view' => 'river/object/badge/award', 'action_type' => 'award', 'subject_guid' => $user_guid, 'object_guid' => $user_guid));
    }
    return true;
}
コード例 #12
0
 public static function renderURLHTML($url)
 {
     $favicon = "http://g.etfv.co/{$url}";
     if (class_exists('UFCOE\\Elgg\\Url')) {
         $sniffer = new Url();
         $guid = $sniffer->getGuid($url);
         if ($entity = get_entity($guid)) {
             $favicon = $entity->getIconURL('tiny');
             if (elgg_instanceof($entity->user)) {
                 $text = "@{$entity->username}";
             } else {
                 $text = isset($entity->name) ? $entity->name : $entity->title;
             }
         }
     }
     if (!$text) {
         $embedder = new Embedder($url);
         $meta = $embedder->extractMeta('oembed');
         if ($meta->title) {
             $text = $meta->title;
         } else {
             $text = elgg_get_excerpt($url, 35);
         }
     }
     return elgg_view('output/url', array('text' => "<span class=\"favicon\" style=\"background-image:url({$favicon})\"></span><span class=\"link\">{$text}</span>", 'href' => $url, 'class' => 'extractor-link'));
 }
コード例 #13
0
ファイル: start.php プロジェクト: n8b/VMN
/**
 * Unserialize tokeninput field values before performing an action
 */
function elgg_tokeninput_explode_field_values($hook, $type, $return, $params)
{
    $elgg_tokeninput_fields = (array) get_input('elgg_tokeninput_fields', array());
    $elgg_tokneinput_autocomplete = (array) get_input('elgg_tokeninput_autocomplete', array());
    if (!empty($elgg_tokeninput_fields)) {
        foreach ($elgg_tokeninput_fields as $field_name) {
            $values = explode(',', get_input($field_name, ''));
            if (in_array($field_name, $elgg_tokneinput_autocomplete)) {
                foreach ($values as $key => $value) {
                    $user = get_entity($value);
                    if ($user instanceof ElggUser) {
                        $values[$key] = $user->username;
                    }
                }
                if (sizeof($values) === 1) {
                    $values = array_values($values)[0];
                }
            }
            set_input($field_name, $values);
        }
    }
    set_input('elgg_tokeninput_fields', null);
    set_input('elgg_tokeninput_autocomplete', null);
    return $return;
}
コード例 #14
0
 /**
  * Handle a request for a file
  *
  * @param Request $request HTTP request
  * @return Response
  */
 public function getResponse($request)
 {
     $response = new Response();
     $response->prepare($request);
     $path = implode('/', $request->getUrlSegments());
     if (!preg_match('~download-file/g(\\d+)$~', $path, $m)) {
         return $response->setStatusCode(400)->setContent('Malformatted request URL');
     }
     $this->application->start();
     $guid = (int) $m[1];
     $file = get_entity($guid);
     if (!$file instanceof ElggFile) {
         return $response->setStatusCode(404)->setContent("File with guid {$guid} does not exist");
     }
     $filenameonfilestore = $file->getFilenameOnFilestore();
     if (!is_readable($filenameonfilestore)) {
         return $response->setStatusCode(404)->setContent('File not found');
     }
     $last_updated = filemtime($filenameonfilestore);
     $etag = '"' . $last_updated . '"';
     $response->setPublic()->setEtag($etag);
     if ($response->isNotModified($request)) {
         return $response;
     }
     $response = new BinaryFileResponse($filenameonfilestore, 200, array(), false, 'attachment');
     $response->prepare($request);
     $expires = strtotime('+1 year');
     $expires_dt = (new DateTime())->setTimestamp($expires);
     $response->setExpires($expires_dt);
     $response->setEtag($etag);
     return $response;
 }
コード例 #15
0
ファイル: RelationshipsTest.php プロジェクト: ibou77/elgg
 /**
  * Remove the entities that are created for each test
  */
 protected function tearDown()
 {
     foreach ($this->guids as $guid) {
         $e = get_entity($guid);
         $e->delete();
     }
 }
コード例 #16
0
ファイル: MarkAsRead.php プロジェクト: n8b/VMN
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $count = count($this->guids);
     $success = $notfound = 0;
     foreach ($this->guids as $guid) {
         $message = get_entity($guid);
         if (!$message instanceof Message) {
             $notfound++;
             continue;
         }
         $message->markRead($this->threaded);
         $success++;
     }
     if ($count > 1) {
         $msg[] = elgg_echo('inbox:markread:success', array($success));
         if ($notfound > 0) {
             $msg[] = elgg_echo('inbox:error:notfound', array($notfound));
         }
     } else {
         if ($success) {
             $msg[] = elgg_echo('inbox:markread:success:single');
         } else {
             $msg[] = elgg_echo('inbox:markread:error');
         }
     }
     $msg = implode('<br />', $msg);
     if ($success < $count) {
         $this->result->addError($msg);
     } else {
         $this->result->addMessage($msg);
     }
 }
コード例 #17
0
function westorElggMan_cron_handler($hook, $entity_type, $returnvalue, $params)
{
    global $CONFIG;
    // old elgg bevore 1.7.0
    global $is_admin;
    $is_admin = true;
    if (function_exists("elgg_set_ignore_access")) {
        // new function for access overwrite
        elgg_set_ignore_access(true);
    }
    $context = westorElggMan_get_context();
    westorElggMan_set_context('westorElggMan');
    $prefix = $CONFIG->dbprefix;
    $sql = "SELECT {$prefix}metadata.entity_guid\nFROM (({$prefix}metadata AS {$prefix}metadata_1 INNER JOIN {$prefix}metastrings AS {$prefix}metastrings_3\nON {$prefix}metadata_1.name_id = {$prefix}metastrings_3.id) INNER JOIN {$prefix}metastrings\nAS {$prefix}metastrings_2 ON {$prefix}metadata_1.value_id = {$prefix}metastrings_2.id) INNER JOIN (({$prefix}metadata INNER JOIN {$prefix}metastrings ON {$prefix}metadata.name_id = {$prefix}metastrings.id) INNER JOIN {$prefix}metastrings AS {$prefix}metastrings_1 ON {$prefix}metadata.value_id = {$prefix}metastrings_1.id) ON {$prefix}metadata_1.entity_guid = {$prefix}metadata.entity_guid\nWHERE ((({$prefix}metastrings.string)='waitForSend') AND (({$prefix}metastrings_1.string)='1')\nAND (({$prefix}metastrings_3.string)='hiddenTo') AND (({$prefix}metastrings_2.string)<>'1'))";
    // and (scheduled is null || scheduled <= now());
    try {
        $result = get_data($sql);
    } catch (Exception $e) {
        westorElggMan_set_context($context);
        throw new Exception($e);
    }
    if (is_array($result)) {
        $elggMan = new class_elggMan();
        foreach ($result as $row) {
            $message = get_entity($row->entity_guid);
            if (is_object($message) && $message->getSubtype() == "messages") {
                $elggMan->sendMsgNow($message);
            }
        }
    }
    westorElggMan_set_context($context);
}
コード例 #18
0
ファイル: EventSerialization.php プロジェクト: elgg/elgg
 /**
  * Unserializes the event object stored in the database
  *
  * @param string $serialized Serialized string
  * @return string
  */
 public function unserialize($serialized)
 {
     $data = unserialize($serialized);
     if (isset($data->action)) {
         $this->action = $data->action;
     }
     if (isset($data->object_id) && isset($data->object_type)) {
         switch ($data->object_type) {
             case 'object':
             case 'user':
             case 'group':
             case 'site':
                 $this->object = get_entity($data->object_id);
                 break;
             case 'annotation':
                 $this->object = elgg_get_annotation_from_id($data->object_id);
                 break;
             case 'metadata':
                 $this->object = elgg_get_metadata_from_id($data->object_id);
                 break;
             case 'relationship':
                 $this->object = get_relationship($data->object_id);
         }
     }
     if (isset($data->actor_guid)) {
         $this->actor = get_entity($data->actor_guid);
     }
 }
コード例 #19
0
ファイル: functions.php プロジェクト: pleio/theme_ffd
function theme_ffd_fivestar_get_top_users($n_days = 21, $eps = 0.5)
{
    $options = array('annotation_name' => 'fivestar', 'where' => 'n_table.time_created > ' . (time() - 3600 * 24 * $n_days), 'order_by' => 'n_table.time_created desc', 'limit' => 250);
    $annotations = elgg_get_annotations($options);
    $top_users = array();
    foreach ($annotations as $annotation) {
        $user = $annotation->getEntity()->getOwnerGuid();
        if (!array_key_exists($user, $top_users)) {
            $top_users[$user] = array();
        }
        $top_users[$user][] = $annotation->value / 100;
    }
    $max_scores = 0;
    foreach ($top_users as $guid => $scores) {
        if (count($scores) > $max_scores) {
            $max_scores = count($scores);
        }
    }
    // calculate the average score
    $top_users = array_map(function ($scores) use($max_scores, $eps) {
        return $eps * (array_sum($scores) / count($scores)) * ((1 - $eps) * (count($scores) / $max_scores));
    }, $top_users);
    arsort($top_users);
    $top_users = array_slice($top_users, 0, 10, true);
    $users = array();
    foreach ($top_users as $guid => $score) {
        $users[] = get_entity($guid);
    }
    return $users;
}
コード例 #20
0
ファイル: start.php プロジェクト: amcfarlane1251/ongarde
function au_group_tag_menu_page_handler($page, $identifier)
{
    //show the page of search results
    // assumes url of group/guid/tag
    // if the tag is 'all' then will display a tagcloud
    switch ($page[0]) {
        case 'group':
            $entity = get_entity($page[1]);
            if (!elgg_instanceof($entity, 'group') || $entity->au_group_tag_menu_enable == 'no') {
                return false;
            }
            elgg_push_breadcrumb($entity->name, $entity->getURL());
            //should be OK if this is empty
            $tag = $page[2];
            elgg_push_breadcrumb($tag);
            if ($tag == "all") {
                //show a tag cloud for all group tags
                //arbitrarily set to a max of 640 tags - should be enough for anyone :-)
                $title = elgg_echo("au_group_tag_menu:tagcloud");
                $options = array('container_guid' => $entity->getGUID(), 'type' => 'object', 'threshold' => 0, 'limit' => 640, 'tag_names' => array('tags'));
                $thetags = elgg_get_tags($options);
                //make it an alphabetical tag cloud, not with most popular first
                sort($thetags);
                //find the highest tag count for scaling the font
                $max = 0;
                foreach ($thetags as $key) {
                    if ($key->total > $max) {
                        $max = $key->total;
                    }
                }
                $content = "  ";
                //loop through and generate tags so they display nicely
                //in the group, not as a dumb search page
                foreach ($thetags as $key) {
                    $url = elgg_get_site_url() . "group_tag_menu/group/" . $entity->getGUID() . "/" . urlencode($key->tag);
                    $taglink = elgg_view('output/url', array('text' => ' ' . $key->tag, 'href' => $url, 'title' => "{$key->tag} ({$key->total})", 'rel' => 'tag'));
                    //  get the font size for the tag (taken from elgg's own tagcloud code - not sure I love this)
                    $size = round(log($key->total) / log($max + 0.0001) * 100) + 30;
                    if ($size < 100) {
                        $size = 100;
                    }
                    // generate the link
                    $content .= " <a href='{$url}' style='font-size:{$size}%'>" . $key->tag . "</a> &nbsp; ";
                }
            } else {
                //show the results for the selected tag
                $title = elgg_echo("au_group_tag_menu:title") . "{$tag}";
                $options = array('type' => 'object', 'metadata_name' => 'tags', 'metadata_value' => $tag, 'container_guid' => $entity->guid, 'full_view' => false);
                $content = elgg_list_entities_from_metadata($options);
            }
            //display the page
            if (!$content) {
                $content = elgg_echo('au_group_tag_menu:noresults');
            }
            $layout = elgg_view_layout('content', array('title' => elgg_view_title($title), 'content' => $content, 'filter' => false));
            echo elgg_view_page($title, $layout);
            break;
    }
    return true;
}
コード例 #21
0
ファイル: start.php プロジェクト: amcfarlane1251/ongarde
function update_user_friends_notifications_settings($guid, $metodos)
{
    $new_user = get_entity($guid);
    switch ($metodos) {
        case 'email':
            $new_user->collections_notifications_preferences_email = -1;
            $new_user->collections_notifications_preferences_site = 0;
            break;
        case 'site':
            $new_user->collections_notifications_preferences_email = 0;
            $new_user->collections_notifications_preferences_site = -1;
            break;
        case 'todos':
            $new_user->collections_notifications_preferences_email = -1;
            $new_user->collections_notifications_preferences_site = -1;
            break;
        case 'ninguno':
            $new_user->collections_notifications_preferences_email = 0;
            $new_user->collections_notifications_preferences_site = 0;
            break;
        default:
            // (metodo = nocambiar)
            break;
    }
    $new_user->save();
}
コード例 #22
0
ファイル: start.php プロジェクト: beck24/elgg-db-cleaner
/**
 * Look for entities with an owner that cannot be loaded
 */
function dbvalidate_get_bad_entities()
{
    global $ENTITY_CACHE;
    $access_status = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    $db_prefix = elgg_get_config('dbprefix');
    _elgg_services()->db->disableQueryCache();
    $query = "SELECT COUNT(*) as total from {$db_prefix}entities WHERE type='object' OR type='group'";
    $result = get_data_row($query);
    $num_entities = $result->total;
    $bad_guids = array();
    // handle 1000 at time
    $count = 0;
    $step = 1000;
    while ($count < $num_entities) {
        // flush caches so that we don't have memory issues
        $ENTITY_CACHE = array();
        $query = "SELECT guid, owner_guid from {$db_prefix}entities WHERE type='object' OR type='group' LIMIT {$count}, {$step}";
        $guids = get_data($query);
        $count = $count += $step;
        // looking for 0 owner or an owner that cannot be loaded
        foreach ($guids as $guid) {
            if ($guid->owner_guid == 0) {
                $bad_guids[] = $guid->guid;
            } else {
                if (!get_entity($guid->owner_guid)) {
                    $bad_guids[] = $guid->guid;
                }
            }
        }
    }
    _elgg_services()->db->enableQueryCache();
    access_show_hidden_entities($access_status);
    return $bad_guids;
}
コード例 #23
0
ファイル: start.php プロジェクト: elainenaomi/labxp2014
function get_like_comment_string($annotation_guid)
{
    $results["unlikeid"] = "";
    $results["listusername"] = "";
    $loginuser = get_loggedin_user();
    if (!empty($annotation_guid)) {
        $like_object = get_likerating_byannotation($annotation_guid);
        if ($like_object && !empty($like_object)) {
            foreach ($like_object as $like) {
                if ($like->owner_guid == $loginuser->guid) {
                    $results["listusername"] = add_and_between_name($results["listusername"], "you");
                    $results["unlikeid"] = $like->guid;
                } else {
                    $user_entity = get_entity($like->owner_guid);
                    $results["listusername"] = add_and_between_name($results["listusername"], $user_entity->name);
                }
            }
        }
        if (!empty($results["listusername"])) {
            $results["listusername"] .= " " . elgg_echo("like:likethis");
        }
        if (!empty($results["listusername"])) {
            $results['listnumberusername'] = sizeof($like_object);
        }
    }
    return $results;
}
コード例 #24
0
 /**
  * Set folder breadcrumb menu
  *
  * @param string         $hook        the name of the hook
  * @param string         $type        the type of the hook
  * @param ElggMenuItem[] $return_value current return value
  * @param array          $params      supplied params
  *
  * @return void|ElggMenuItem[]
  */
 public static function register($hook, $type, $return_value, $params)
 {
     if (empty($params) || !is_array($params)) {
         return;
     }
     $container = elgg_get_page_owner_entity();
     /* @var $folder \ElggObject */
     $folder = elgg_extract('entity', $params);
     if (elgg_instanceof($folder, 'object', FILE_TOOLS_SUBTYPE)) {
         $container = $folder->getContainerEntity();
         $priority = 9999999;
         $return_value[] = \ElggMenuItem::factory(['name' => "folder_{$folder->getGUID()}", 'text' => $folder->getDisplayName(), 'href' => false, 'priority' => $priority]);
         $parent_guid = (int) $folder->parent_guid;
         while (!empty($parent_guid)) {
             $parent = get_entity($parent_guid);
             if (!elgg_instanceof($parent, 'object', FILE_TOOLS_SUBTYPE)) {
                 break;
             }
             $priority--;
             $return_value[] = \ElggMenuItem::factory(['name' => "folder_{$parent->getGUID()}", 'text' => $parent->getDisplayName(), 'href' => $parent->getURL(), 'priority' => $priority]);
             $parent_guid = (int) $parent->parent_guid;
         }
     }
     // make main folder item
     $main_folder_options = ['name' => 'main_folder', 'text' => elgg_echo('file_tools:list:folder:main'), 'priority' => 0];
     if ($container instanceof \ElggGroup) {
         $main_folder_options['href'] = "file/group/{$container->getGUID()}/all#";
     } else {
         $main_folder_options['href'] = "file/owner/{$container->username}/all#";
     }
     $return_value[] = \ElggMenuItem::factory($main_folder_options);
     return $return_value;
 }
コード例 #25
0
ファイル: ElggMetadata.php プロジェクト: ibou77/elgg
 /**
  * Determines whether or not the user can edit this piece of metadata
  *
  * @param int $user_guid The GUID of the user (defaults to currently logged in user)
  *
  * @return bool
  * @see elgg_set_ignore_access()
  */
 public function canEdit($user_guid = 0)
 {
     if ($entity = get_entity($this->entity_guid)) {
         return $entity->canEditMetadata($this, $user_guid);
     }
     return false;
 }
コード例 #26
0
ファイル: Upgrade.php プロジェクト: coldtrick/menu_builder
 /**
  * Migrates old (pre MenuBuilder 2.0) menu entities to json
  *
  * @return void
  */
 public static function migrateEntitiesToJSON()
 {
     $ia = elgg_set_ignore_access(true);
     $menu = new \ColdTrick\MenuBuilder\Menu('site');
     $menu->save();
     $options = ['type' => 'object', 'subtype' => 'menu_builder_menu_item', 'limit' => false];
     $entities = elgg_get_entities($options);
     if (empty($entities)) {
         elgg_set_ignore_access($ia);
         return;
     }
     foreach ($entities as $menu_item) {
         $parent_name = null;
         $parent_guid = $menu_item->parent_guid;
         if ($parent_guid) {
             $parent = get_entity($parent_guid);
             if ($parent) {
                 $parent_name = "menu_name_{$parent_guid}";
             }
         }
         $menu->addMenuItem(['name' => "menu_name_{$menu_item->guid}", 'text' => $menu_item->title, 'href' => $menu_item->url, 'target' => $menu_item->target, 'is_action' => $menu_item->is_action, 'access_id' => $menu_item->access_id, 'priority' => $menu_item->order, 'parent_name' => $parent_name]);
     }
     // delete entities need to do it afterwards as parents are not always available otherwise
     foreach ($entities as $menu_item) {
         $menu_item->delete();
     }
     elgg_set_ignore_access($ia);
 }
コード例 #27
0
/**
 * Create or update the extras table for a given object.
 * Call create_entity first.
 *
 * @param int    $guid        The guid of the entity you're creating (as obtained by create_entity)
 * @param string $title       The title of the object
 * @param string $description The object's description
 *
 * @return bool
 */
function create_object_entity($guid, $title, $description)
{
    global $CONFIG;
    $guid = (int) $guid;
    $title = sanitise_string($title);
    $description = sanitise_string($description);
    $row = get_entity_as_row($guid);
    if ($row) {
        // Core entities row exists and we have access to it
        $query = "SELECT guid from {$CONFIG->dbprefix}objects_entity where guid = {$guid}";
        if ($exists = get_data_row($query)) {
            $query = "UPDATE {$CONFIG->dbprefix}objects_entity\n\t\t\t\tset title='{$title}', description='{$description}' where guid={$guid}";
            $result = update_data($query);
            if ($result != false) {
                // Update succeeded, continue
                $entity = get_entity($guid);
                elgg_trigger_event('update', $entity->type, $entity);
                return $guid;
            }
        } else {
            // Update failed, attempt an insert.
            $query = "INSERT into {$CONFIG->dbprefix}objects_entity\n\t\t\t\t(guid, title, description) values ({$guid}, '{$title}','{$description}')";
            $result = insert_data($query);
            if ($result !== false) {
                $entity = get_entity($guid);
                if (elgg_trigger_event('create', $entity->type, $entity)) {
                    return $guid;
                } else {
                    $entity->delete();
                }
            }
        }
    }
    return false;
}
コード例 #28
0
ファイル: comments.php プロジェクト: sephiroth88/Elgg
/**
 * Page handler for generic comments manipulation.
 *
 * @param array $page
 * @return bool
 * @access private
 */
function _elgg_comments_page_handler($page)
{
    switch ($page[0]) {
        case 'edit':
            elgg_gatekeeper();
            if (empty($page[1])) {
                register_error(elgg_echo('generic_comment:notfound'));
                forward(REFERER);
            }
            $comment = get_entity($page[1]);
            if (!$comment instanceof \ElggComment || !$comment->canEdit()) {
                register_error(elgg_echo('generic_comment:notfound'));
                forward(REFERER);
            }
            $target = $comment->getContainerEntity();
            if (!$target instanceof \ElggEntity) {
                register_error(elgg_echo('generic_comment:notfound'));
                forward(REFERER);
            }
            $title = elgg_echo('generic_comments:edit');
            elgg_push_breadcrumb($target->getDisplayName(), $target->getURL());
            elgg_push_breadcrumb($title);
            $params = array('entity' => $target, 'comment' => $comment, 'is_edit_page' => true);
            $content = elgg_view_form('comment/save', null, $params);
            $params = array('content' => $content, 'title' => $title, 'filter' => '');
            $body = elgg_view_layout('content', $params);
            echo elgg_view_page($title, $body);
            return true;
            break;
        default:
            return false;
            break;
    }
}
コード例 #29
0
ファイル: ElggMetadata.php プロジェクト: redvabel/Vabelgg
 /**
  * Determines whether or not the user can edit this piece of metadata
  *
  * @return true|false Depending on permissions
  */
 function canEdit()
 {
     if ($entity = get_entity($this->get('entity_guid'))) {
         return $entity->canEditMetadata($this);
     }
     return false;
 }
コード例 #30
0
ファイル: Membership.php プロジェクト: lorea/Hydra-dev
 /**
  * Listen to the delete of a membership request
  *
  * @param stirng            $event        the name of the event
  * @param stirng            $type         the type of the event
  * @param \ElggRelationship $relationship the relationship
  *
  * @return void
  */
 public static function deleteRequest($event, $type, $relationship)
 {
     if (!$relationship instanceof \ElggRelationship) {
         return;
     }
     if ($relationship->relationship !== 'membership_request') {
         // not a membership request
         return;
     }
     $action_pattern = '/action\\/groups\\/killrequest/i';
     if (!preg_match($action_pattern, current_page_url())) {
         // not in the action, so do nothing
         return;
     }
     $group = get_entity($relationship->guid_two);
     $user = get_user($relationship->guid_one);
     if (empty($user) || !$group instanceof \ElggGroup) {
         return;
     }
     if ($user->getGUID() === elgg_get_logged_in_user_guid()) {
         // user kills own request
         return;
     }
     $reason = get_input('reason');
     if (empty($reason)) {
         $body = elgg_echo('group_tools:notify:membership:declined:message', array($user->name, $group->name, $group->getURL()));
     } else {
         $body = elgg_echo('group_tools:notify:membership:declined:message:reason', array($user->name, $group->name, $reason, $group->getURL()));
     }
     $subject = elgg_echo('group_tools:notify:membership:declined:subject', array($group->name));
     $params = array('object' => $group, 'action' => 'delete');
     notify_user($user->getGUID(), $group->getGUID(), $subject, $body, $params);
 }