Пример #1
0
/**
 * Returns the object based on the id
 *
 * @param string  $id     id of the object to find
 * @param boolean $create should the object be created if id is missing
 *
 * @return /ElggObject|false
 */
function ckeditor_extended_get_inline_object($id, $create = false)
{
    static $cached = [];
    if (empty($id)) {
        return false;
    }
    $prefix = elgg_extract(0, explode('_', $id));
    if (!array_key_exists($prefix, $cached)) {
        $cached[$prefix] = [];
        // preload entities
        $entities = elgg_get_entities(['type' => 'object', 'subtype' => 'ckeditor_inline', 'limit' => false, 'joins' => 'JOIN ' . elgg_get_config('dbprefix') . "objects_entity oe ON oe.guid = e.guid", 'wheres' => "oe.title LIKE '{$prefix}%'"]);
        foreach ($entities as $entity) {
            $cached[$prefix][$entity->title] = $entity;
        }
    }
    if (array_key_exists($id, $cached[$prefix])) {
        return $cached[$prefix][$id];
    }
    if (!$create) {
        return false;
    }
    $object = new \ElggObject();
    $object->subtype = 'ckeditor_inline';
    $object->title = $id;
    $object->owner_guid = elgg_get_site_entity()->guid;
    $object->container_guid = elgg_get_site_entity()->guid;
    $object->access_id = ACCESS_PUBLIC;
    $cached[$prefix][$id] = $object;
    return $object;
}
 /**
  * Prepares notification elements
  * @return \stdClass
  */
 public function prepare()
 {
     $object_type = $this->getObjectType();
     $object_link = elgg_view('output/url', array('text' => $this->object->getDisplayName(), 'href' => elgg_http_add_url_query_elements($this->object->getURL(), array('active_tab' => 'comments'))));
     if ($this->author->guid == $this->object->owner_guid) {
         $object_summary_title = elgg_echo('interactions:ownership:own', array($object_type), $this->language);
     } else {
         if ($this->recipient->guid == $this->object->owner_guid) {
             $object_summary_title = elgg_echo('interactions:ownership:your', array($object_type), $this->language);
         } else {
             $object_owner = $this->object->getOwnerEntity() ?: elgg_get_site_entity();
             $object_summary_title = elgg_echo('interactions:ownership:owner', array($object_owner->getDisplayName(), $object_type), $this->language);
         }
     }
     if ($this->object instanceof Comment) {
         $object_full_title = $object_summary_title;
     } else {
         $object_full_title = $object_summary_title . ' ' . $object_link;
     }
     if ($this->root->guid !== $this->object->guid) {
         $root_link = elgg_view('output/url', array('text' => $this->root->getDisplayName(), 'href' => elgg_http_add_url_query_elements($this->root->getURL(), array('active_tab' => 'comments'))));
         $object_full_title .= ' ' . elgg_echo('interactions:comment:in_thread', array($root_link));
     }
     $author_link = elgg_view('output/url', array('text' => $this->author->name, 'href' => $this->author->getURL()));
     $object_summary_link = elgg_view('output/url', array('text' => $object_summary_title, 'href' => elgg_http_add_url_query_elements($this->object->getURL(), array('active_tab' => 'comments'))));
     $action_type = $this->getActionType();
     $notification = new \stdClass();
     $notification->summary = elgg_echo('interactions:response:email:subject', array($author_link, $action_type, $object_summary_link), $this->language);
     $notification->subject = strip_tags($notification->summary);
     $notification->body = elgg_echo('interactions:response:email:body', array($author_link, $action_type, $object_full_title, $this->getComment(), $this->comment->getURL(), $this->root->getURL(), $this->author->getDisplayName(), $this->author->getURL()), $this->language);
     return $notification;
 }
Пример #3
0
 public function getRegisterApp()
 {
     $user = elgg_get_logged_in_user_entity();
     $site = elgg_get_site_entity();
     $response = array('BaseUrl' => $site->url, 'Name' => $site->name, 'User' => $user->username, 'LogoUrl' => $site->url . 'mod/pleiobox/_graphics/icon.png', 'BackColor' => '#005dac', 'FontColor' => '#999999', 'pin_cert' => '', 'APIKeys' => array(array('Name' => 'LocalBox iOS', 'Key' => 'testclient', 'Secret' => 'testpass'), array('Name' => 'Localbox Android', 'Key' => 'testclient', 'Secret' => 'testpass')));
     return $this->sendResponse($response);
 }
Пример #4
0
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->attributes['access_id'] = ACCESS_PUBLIC;
     $this->attributes['owner_guid'] = elgg_get_site_entity()->getGUID();
     $this->attributes['container_guid'] = elgg_get_site_entity()->getGUID();
 }
Пример #5
0
/**
 * function to replace group profile fields
 * 
 * @param $hook_name
 * @param $entity_type
 * @param $return_value
 * @param $parameters
 * @return unknown_type
 */
function profile_manager_group_override($hook_name, $entity_type, $return_value, $parameters)
{
    $result = $return_value;
    // Get all custom group fields
    $options = array("type" => "object", "subtype" => CUSTOM_PROFILE_FIELDS_GROUP_SUBTYPE, "limit" => false, "owner_guid" => elgg_get_site_entity()->getGUID());
    $group_fields = elgg_get_entities($options);
    if ($group_fields) {
        $result = array();
        $ordered = array();
        // Order the group fields and filter some types out
        foreach ($group_fields as $group_field) {
            if ($group_field->admin_only != "yes" || elgg_is_admin_logged_in()) {
                $ordered[$group_field->order] = $group_field;
            }
        }
        ksort($ordered);
        // build the correct list
        $result["name"] = "text";
        foreach ($ordered as $group_field) {
            $result[$group_field->metadata_name] = $group_field->metadata_type;
            // should it be handled as tags? TODO: is this still needed? Yes it is, it handles presentation of these fields in listing mode
            if (elgg_get_context() == "search" && ($group_field->output_as_tags == "yes" || $group_field->metadata_type == "multiselect")) {
                $result[$group_field->metadata_name] = "tags";
            }
        }
    }
    return $result;
}
Пример #6
0
 /**
  * Add menu items to the filter menu
  *
  * @param string $hook         'cron'
  * @param string $type         'daily'
  * @param string $return_value optional output
  * @param array  $params       supplied params
  *
  * @return void
  */
 public static function daily($hook, $type, $return_value, $params)
 {
     if (!static_out_of_date_enabled()) {
         return;
     }
     $time = elgg_extract('time', $params, time());
     $days = (int) elgg_get_plugin_setting('out_of_date_days', 'static');
     $site = elgg_get_site_entity();
     $options = ['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'limit' => false, 'modified_time_upper' => $time - $days * 24 * 60 * 60, 'modified_time_lower' => $time - ($days + 1) * 24 * 60 * 60, 'order_by' => 'e.time_updated DESC'];
     // ignore access
     $ia = elgg_set_ignore_access(true);
     $batch = new \ElggBatch('elgg_get_entities', $options);
     $users = [];
     foreach ($batch as $entity) {
         $last_editors = $entity->getAnnotations(['annotation_name' => 'static_revision', 'limit' => 1, 'order_by' => 'n_table.time_created DESC']);
         if (empty($last_editors)) {
             continue;
         }
         $users[$last_editors[0]->getOwnerGUID()] = $last_editors[0]->getOwnerEntity();
     }
     // restore access
     elgg_set_ignore_access($ia);
     if (empty($users)) {
         return;
     }
     foreach ($users as $user) {
         $subject = elgg_echo('static:out_of_date:notification:subject');
         $message = elgg_echo('static:out_of_date:notification:message', [$user->name, elgg_normalize_url('static/out_of_date/' . $user->username)]);
         notify_user($user->getGUID(), $site->getGUID(), $subject, $message, [], 'email');
     }
 }
Пример #7
0
/**
 * Save SEF data
 *
 * @param array $data Data
 * @return bool
 */
function seo_save_data($data)
{
    $path = elgg_extract('path', $data);
    $sef_path = elgg_extract('sef_path', $data);
    if (!$path || !$sef_path) {
        return false;
    }
    $sef_hash = sha1($sef_path);
    $original_hash = sha1($path);
    $site = elgg_get_site_entity();
    $file = new ElggFile();
    $file->owner_guid = $site->guid;
    $file->setFilename("seo/{$sef_hash}.json");
    $file->open('write');
    $file->write(json_encode($data));
    $file->close();
    if ($sef_hash != $original_hash) {
        $file = new ElggFile();
        $file->owner_guid = $site->guid;
        $file->setFilename("seo/{$original_hash}.json");
        $file->open('write');
        $file->write(json_encode($data));
        $file->close();
    }
    return true;
}
Пример #8
0
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->attributes['subtype'] = 'hjfield';
     $this->attributes['owner_guid'] = elgg_get_site_entity()->guid;
     $this->attributes['access_id'] = ACCESS_PUBLIC;
 }
Пример #9
0
/**
 * Create a log notification
 * 
 * @param string $hook   Hook name
 * @param string $type   Hook type
 * @param bool   $result Has the notification been sent
 * @param array  $params Hook parameters
 */
function log_emails_send($hook, $type, $result, $params)
{
    $message = $params['notification'];
    $sender = $message->getSender();
    $recipient = $message->getRecipient();
    if (!$sender) {
        return false;
    }
    if (!$recipient || !$recipient->email) {
        return false;
    }
    $to = $recipient->email;
    $site = elgg_get_site_entity();
    // If there's an email address, use it - but only if it's not from a user.
    if (!$sender instanceof \ElggUser && $sender->email) {
        $from = $sender->email;
    } else {
        if ($site->email) {
            $from = $site->email;
        } else {
            // If all else fails, use the domain of the site.
            $from = 'noreply@' . $site->getDomain();
        }
    }
    $date = date("Y-m-d H:i:s");
    error_log(sprintf(elgg_echo('log_emails:content'), $from, $to, $date, $message->subject, $message->body), 3, "php://stderr");
    return true;
    //return elgg_send_email($from, $to, $message->subject, $message->body, $params);
}
Пример #10
0
Файл: Router.php Проект: n8b/VMN
 /**
  * Handles embedded URLs
  *
  * @param array $page URL segments
  * @return boolean
  */
 function handlePages($page)
 {
     $url = get_input('url');
     $handle = get_input('handle');
     $iframe = get_input('iframe', false);
     $site = elgg_get_site_entity();
     if (!$handle) {
         $handle = $site->guid;
     }
     if (!$url || !$handle) {
         return false;
     }
     $parse = elgg_is_logged_in();
     switch ($page[0]) {
         default:
             $data = $this->model->get($url, $handle, $parse);
             $layout = elgg_view('output/card', array('href' => $url, 'handle' => $handle));
             $shell = $iframe ? 'iframe' : 'default';
             echo elgg_view_page($data['title'], $layout, $shell);
             break;
         case 'json':
             $data = $this->model->get($url, $handle, $parse);
             header('Content-Type: application/json');
             echo json_encode($data);
             exit;
     }
     return true;
 }
Пример #11
0
/**
 * Listen to the usersettings save hook for some notifications to the user
 *
 * @param string $hook         usersettings:save
 * @param string $type         user
 * @param bool   $return_value not supplied for this hook
 * @param null   $params       not supplied for this hook
 *
 * @return void
 */
function security_tools_usersettings_save_handler($hook, $type, $return_value, $params)
{
    $user_guid = (int) get_input("guid");
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    if (empty($user_guid)) {
        return $return_value;
    }
    $user = get_user($user_guid);
    if (empty($user) || !$user->canEdit()) {
        return $return_value;
    }
    // passwords are different
    if (_elgg_set_user_password() === true) {
        // do we need to notify the user about a password change
        $setting = elgg_get_plugin_setting("mails_password_change", "security_tools");
        if ($setting != "no") {
            $site = elgg_get_site_entity();
            $subject = elgg_echo("security_tools:notify_user:password:subject");
            $message = elgg_echo("security_tools:notify_user:password:message", array($user->name, $site->name, $site->url));
            notify_user($user->getGUID(), $site->getGUID(), $subject, $message, null, "email");
        }
    }
    // email are also different
    $setting = elgg_get_plugin_setting("mails_verify_email_change", "security_tools");
    if ($setting != "no" && $user->getGUID() == elgg_get_logged_in_user_guid()) {
        // verify new email address
        security_tools_prepare_email_change();
    } else {
        // old way, or admin changes your email
        _elgg_set_user_email();
    }
}
Пример #12
0
 /**
  * {@inheritdoc}
  */
 public function post(ParameterBag $params)
 {
     $params->subject_uid = "ue{$params->guid}";
     $params->guid = elgg_get_site_entity()->guid;
     $ctrl = new SiteActivity($this->request, $this->graph);
     return $ctrl->post($params);
 }
Пример #13
0
/**
 * Post to a facebook users wall.
 *
 * @param unknown_type $hook
 * @param unknown_type $entity_type
 * @param unknown_type $returnvalue
 * @param unknown_type $params
 */
function facebookservice_post($hook, $entity_type, $returnvalue, $params)
{
    $user_id = $params['userid'];
    $access_token = elgg_get_plugin_user_setting('access_token', $user_id, 'facebook_api');
    $target = elgg_get_plugin_user_setting('uid', $user_id, 'facebook_api');
    $site = elgg_get_site_entity();
    if (!$params['name']) {
        $site_name = $site->name;
    } else {
        $site_name = $params['name'];
    }
    if (!$params['logo']) {
        $logo = elgg_get_site_url() . '_graphics/elgg_logo.png';
    } else {
        $logo = $params['logo'];
    }
    if (!$params['link']) {
        $link = elgg_get_site_url();
    } else {
        $link = $params['link'];
    }
    $attachment = array('access_token' => $access_token, 'message' => $params['message'], 'name' => $site_name, 'link' => $link, 'description' => $params['description'], 'picture' => $logo);
    if (!($access_token && $target)) {
        return NULL;
    }
    $facebook = facebookservice_api();
    $ret_code = $facebook->api('/me/feed', 'POST', $attachment);
    return TRUE;
}
Пример #14
0
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->siteDomain = get_site_domain($CONFIG->site_guid);
     $this->site = elgg_get_site_entity();
     $this->approvedDomains = ['forces.gc.ca', 'test.gc.ca'];
 }
Пример #15
0
function river_activity_3C_bday_mailer($hook, $entity_type, $returnvalue, $params)
{
    $bday = elgg_get_plugin_setting('birth_day', 'river_activity_3C');
    elgg_set_ignore_access(true);
    $siteurl = elgg_get_site_entity()->url;
    $sitename = elgg_get_site_entity()->name;
    $siteemail = elgg_get_site_entity()->email;
    $from = $sitename . ' <' . $siteemail . '>';
    $month = date('m', strtotime("now"));
    $options = array('metadata_names' => 'BD_month', 'metadata_values' => $month, 'types' => 'user', 'limit' => false, 'full_view' => false, 'pagination' => false);
    $bd_users = new ElggBatch('elgg_get_entities_from_metadata', $options);
    $bd_today = date('j, F', strtotime('now'));
    foreach ($bd_users as $bd_user) {
        $bd_name = $bd_user->name;
        $bd_email = $bd_user->email;
        $bd_day = date('j, F', strtotime($bd_user->{$bday}));
        if ($bd_day == $bd_today) {
            if ($bd_email) {
                $message = elgg_echo('river_activity_3C:bday_message', array($bd_name, $bd_day, $sitename, $siteurl));
                elgg_send_email($from, $bd_email, elgg_echo('river_activity_3C:bday_message:subject'), $message);
                $result = elgg_echo("river_activity_3C:bday_mailer_cron_true");
            } else {
                $result = elgg_echo("river_activity_3C:bday_mailer_cron_false");
            }
        }
    }
    elgg_set_ignore_access(false);
    return $returnvalue . $result;
}
Пример #16
0
/**
 * Notify subscribed users
 * @param int $guid
 */
function hj_forum_notify_subscribed_users($guid)
{
    $entity = get_entity($guid);
    //$parentEntity = get_entity($entity->container_guid);
    $subscribers = $entity->getSubscribedUsers();
    $to = array();
    foreach ($subscribers as $subscribed) {
        $to[] = $subscribed->guid;
    }
    $subtype = $entity->getSubtype();
    $from = elgg_get_site_entity()->guid;
    $subject = elgg_echo("hj:forum:new:{$subtype}");
    $subject_link = elgg_view('framework/bootstrap/user/elements/name', array('entity' => $entity->getOwnerEntity()));
    $object_link = elgg_view('framework/bootstrap/object/elements/title', array('entity' => $entity));
    $breadcrumbs = elgg_view('framework/bootstrap/object/elements/breadcrumbs', array('entity' => $entity));
    if (!empty($breadcrumbs)) {
        $breadcrumbs_link = elgg_echo('river:in:forum', array($breadcrumbs));
    }
    $key = "river:create:object:{$subtype}";
    $summary = elgg_echo($key, array($subject_link, $object_link)) . $breadcrumbs_link;
    $body = elgg_view('framework/bootstrap/object/elements/description', array('entity' => $entity));
    $link = elgg_view('output/url', array('text' => elgg_echo('hj:framework:notification:link'), 'href' => $entity->getURL(), 'is_trusted' => true));
    $footer = elgg_echo('hj:framework:notification:full_link', array($link));
    $message = "<p>{$summary}</p><p>{$body}</p><p>{$footer}</p>";
    notify_user($to, $from, $subject, $message);
}
Пример #17
0
function elgg_modifications_pagesetup()
{
    $user = elgg_get_logged_in_user_entity();
    if (!$user) {
        return;
    }
    if (elgg_in_context("accept_terms")) {
        return;
    }
    $site = elgg_get_site_entity();
    if ($site->isPublicPage()) {
        return;
    }
    if (!empty($_SESSION["terms_accepted"])) {
        return;
    }
    if (elgg_get_plugin_setting("accept_terms", "elgg_modifications") === "no") {
        return;
    }
    $user_ts = $user->getPrivateSetting("general_terms_accepted");
    if (empty($user_ts)) {
        $_SESSION["terms_forward_from"] = current_page_url();
        forward("accept_terms");
    } else {
        // user has accepted the terms, so don't check again
        $_SESSION["terms_accepted"] = $user_ts;
    }
}
Пример #18
0
/**
 * Returns a ACL for use in widgets
 *
 * @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 array
 */
function widget_manager_write_access_hook($hook_name, $entity_type, $return_value, $params)
{
    if (!elgg_in_context('widget_access')) {
        return $return_value;
    }
    $widget = elgg_extract('entity', $params['input_params']);
    if ($widget instanceof ElggWidget) {
        $widget_context = $widget->context;
        if ($widget_context == 'groups') {
            $group = $widget->getContainerEntity();
            if (!empty($group->group_acl)) {
                $return_value = [$group->group_acl => elgg_echo('groups:group') . ': ' . $group->name, ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
            }
        } elseif ($widget->getContainerGUID() === elgg_get_site_entity()->getGUID()) {
            // admins only have the following options for index widgets
            if (elgg_is_admin_logged_in()) {
                $return_value = [ACCESS_PRIVATE => elgg_echo('access:admin_only'), ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_LOGGED_OUT => elgg_echo('LOGGED_OUT'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
            } elseif (elgg_can_edit_widget_layout($widget_context)) {
                // for non admins that can manage this widget context
                $return_value = [ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
            }
        }
    } elseif (elgg_in_context('index') && elgg_is_admin_logged_in()) {
        // admins only have the following options for index widgets
        $return_value = [ACCESS_PRIVATE => elgg_echo('access:admin_only'), ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_LOGGED_OUT => elgg_echo('LOGGED_OUT'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
    } elseif (elgg_in_context('groups')) {
        $group = elgg_get_page_owner_entity();
        if (!empty($group->group_acl)) {
            $return_value = [$group->group_acl => elgg_echo('groups:group') . ': ' . $group->name, ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
        }
    }
    return $return_value;
}
Пример #19
0
function upgrade_20141130()
{
    $upgrade_version = get_upgrade_version();
    if ($upgrade_version >= UPGRADE_VERSION) {
        return true;
    }
    $site = elgg_get_site_entity();
    $dbprefix = elgg_get_config('dbprefix');
    // move ip tracking from heavy object entities to lighter-weight annotations
    $options = array("type" => "object", "subtype" => "spam_login_filter_ip", 'limit' => false);
    $batch = new ElggBatch('elgg_get_entities', $options, null, 50, false);
    $week_ago = time() - 604800;
    // just delete anything over a week old
    foreach ($batch as $e) {
        // create a new record as an annotation and delete the entity
        if ($e->time_created > $week_ago) {
            $id = $site->annotate('spam_login_filter_ip', $e->ip_address, ACCESS_PUBLIC);
            if ($id) {
                $sql = "UPDATE {$dbprefix}annotations SET time_created = {$e->time_created} WHERE id = {$id}";
                update_data($sql);
            }
        }
        $e->delete();
    }
    set_upgrade_version(20141130);
}
Пример #20
0
function birthdays_get_upcoming_user_guids()
{
    $site = elgg_get_site_entity();
    $today = (int) date("z");
    $field = birthdays_get_configured_birthday_field();
    if (!$field) {
        return false;
    }
    if (date("w") == 1) {
        // Mondays
        $today -= 2;
    } elseif (date("w") == 2) {
        // Tuesdays
        $today -= 1;
    }
    $dbprefix = elgg_get_config('dbprefix');
    $field_id = (int) get_metastring_id($field);
    $sql = "SELECT\n\t\te.guid,\n\t\tDAYOFYEAR(DATE(msv.string)) AS birthday\n\t\tFROM {$dbprefix}entities e\n\t\tJOIN {$dbprefix}entity_relationships r ON r.guid_one = e.guid\n\t\tJOIN {$dbprefix}metadata m ON e.guid = m.entity_guid\n\t\tJOIN {$dbprefix}metastrings msv ON m.value_id = msv.id\n\t\tWHERE\n\t\te.type = 'user' AND\n\t\tr.relationship = 'member_of_site' AND\n\t\tr.guid_two = {$site->guid} AND\n\t\tm.name_id = {$field_id}\n\t\tHAVING birthday >= {$today}\n\t\tORDER BY birthday\n\t\tLIMIT 25";
    $users = get_data($sql);
    $return = array();
    foreach ($users as $user) {
        $return[] = $user->guid;
    }
    return $return;
}
Пример #21
0
/**
 * Serve pages. URLs in the form:
 *
 * pg/block_users/blocked_users/<username> - Users blocked by <username>. If not set, defaults to logged in.
 * pg/block_users/blocked - The page to display when a user is blocked. 
 *
 * @param array $page
 * @return bool Depending on success
 */
function page_handler($page)
{
    gatekeeper();
    if (!isset($page[0])) {
        $page[0] = 'blocked_users';
    }
    switch ($page[0]) {
        case 'blocked_user_content':
            $site = elgg_get_site_entity();
            elgg_set_page_owner_guid($site->guid);
            include dirname(__FILE__) . '/pages/block_users/blocked_user_content.php';
            break;
        case 'blocked_content':
            $site = elgg_get_site_entity();
            elgg_set_page_owner_guid($site->guid);
            include dirname(__FILE__) . '/pages/block_users/blocked_content.php';
            break;
        default:
        case 'blocked_users':
            $logged_in_user = elgg_get_logged_in_user_entity();
            if (!isset($page[1])) {
                $page[1] = $logged_in_user->username;
            }
            set_input('blocking_username', $page[1]);
            // only admins can see another user's block list
            if ($page[1] != $logged_in_user->username) {
                admin_gatekeeper();
            }
            include dirname(__FILE__) . '/pages/block_users/blocked_users.php';
    }
    return true;
}
Пример #22
0
function elgg_modifications_create_user_event_handler($event, $object_type, $object)
{
    if (elgg_instanceof($object, "user")) {
        if (subsite_manager_on_subsite()) {
            $object->setPrivateSetting("digest_" . elgg_get_site_entity()->getOwnerGUID(), "none");
        }
    }
}
Пример #23
0
 /**
  * (non-PHPdoc)
  * @see ElggObject::initializeAttributes()
  */
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $this->attributes['subtype'] = self::SUBTYPE;
     $this->attributes['owner_guid'] = elgg_get_site_entity()->guid;
     $this->attributes['container_guid'] = elgg_get_site_entity()->guid;
     $this->attributes['access_id'] = ACCESS_PUBLIC;
 }
Пример #24
0
/**
 * Prepend some widget titles with an icon
 * 
 * @param ElggWidget $widget the current widget
 * @param string     $title  the current title
 * 
 * @return string
 */
function theme_oirschot_is_subsite_member()
{
    $site = elgg_get_site_entity();
    if ($site->isUser()) {
        return true;
    } else {
        return false;
    }
}
Пример #25
0
 /**
  * overrule / extend some parent functions
  * 
  * @return void
  * 
  * @see ElggObject::initializeAttributes()
  */
 protected function initializeAttributes()
 {
     parent::initializeAttributes();
     $site = elgg_get_site_entity();
     $this->attributes["subtype"] = self::SUBTYPE;
     $this->attributes["access_id"] = ACCESS_PUBLIC;
     $this->attributes["owner_guid"] = $site->getGUID();
     $this->attributes["container_guid"] = $site->getGUID();
 }
Пример #26
0
 function getURL()
 {
     $result = false;
     if ($this->guid) {
         $site = elgg_get_site_entity($this->site_guid);
         $result = $site->url . "dashboard/" . $this->getGUID();
     }
     return $result;
 }
Пример #27
0
 public function testElggEntitySaveAndDelete()
 {
     // check attributes populated during create()
     $time_minimum = time() - 5;
     $this->assertTrue($this->entity->time_created > $time_minimum);
     $this->assertTrue($this->entity->time_updated > $time_minimum);
     $this->assertEqual($this->entity->site_guid, elgg_get_site_entity()->guid);
     $this->assertEqual($this->entity->container_guid, elgg_get_logged_in_user_guid());
 }
Пример #28
0
/**
 * Record cron running
 *
 * @param string $hook   Hook name
 * @param string $period Cron period
 * @param string $output Output content
 * @param array  $params Hook parameters
 * @return void
 * @access private
 */
function _elgg_cron_monitor($hook, $period, $output, $params)
{
    $time = $params['time'];
    $periods = elgg_get_config('elgg_cron_periods');
    if (in_array($period, $periods)) {
        $key = "cron_latest:{$period}:ts";
        elgg_get_site_entity()->setPrivateSetting($key, $time);
    }
}
 /**
  * Initializes attributes for this class
  *
  * @return void
  *
  * @see ElggObject::initializeAttributes()
  */
 public function initializeAttributes()
 {
     parent::initializeAttributes();
     $site = elgg_get_site_entity();
     $this->attributes['subtype'] = self::SUBTYPE;
     $this->attributes['owner_guid'] = $site->getGUID();
     $this->attributes['container_guid'] = $site->getGUID();
     $this->attributes['access_id'] = ACCESS_PRIVATE;
 }
Пример #30
0
/**
 * called on daily cron - cleans up ip address cache
 * 
 * @param type $hook
 * @param type $entity_type
 * @param type $returnvalue
 * @param type $params
 */
function daily_cron($hook, $entity_type, $returnvalue, $params)
{
    $ia = elgg_set_ignore_access(true);
    //Retrieve the ips older than one week
    $week_ago = time() - 604800;
    //(7 * 24 * 60 * 60);
    elgg_delete_annotations(array('guid' => elgg_get_site_entity()->guid, 'annotation_names' => 'spam_login_filter_ip', 'annotation_created_time_upper' => $week_ago, 'limit' => false));
    elgg_set_ignore_access($ia);
}