コード例 #1
0
ファイル: start.php プロジェクト: elgg/twitter_api
/**
 * Serves pages for twitter.
 *
 * @param array $page
 * @return bool
 */
function twitter_api_pagehandler($page)
{
    if (!isset($page[0])) {
        return false;
    }
    switch ($page[0]) {
        case 'authorize':
            twitter_api_authorize();
            break;
        case 'revoke':
            twitter_api_revoke();
            break;
        case 'forward':
            twitter_api_forward();
            break;
        case 'login':
            twitter_api_login();
            break;
        case 'interstitial':
            elgg_gatekeeper();
            // only let twitter users do this.
            $guid = elgg_get_logged_in_user_guid();
            $twitter_name = elgg_get_plugin_user_setting('twitter_name', $guid, 'twitter_api');
            if (!$twitter_name) {
                register_error(elgg_echo('twitter_api:invalid_page'));
                forward();
            }
            echo elgg_view('resources/twitter_api/interstitial');
            break;
        default:
            return false;
    }
    return true;
}
コード例 #2
0
ファイル: start.php プロジェクト: elgg/elgg
/**
 * Redirect the requestor to the new URL
 * Checks the plugin setting to determine the course of action:
 * a) Displays an error page with the new URL
 * b) Forwards to the new URL and displays an error message
 * c) Silently forwards to the new URL
 *
 * @param string $url Relative or absolute URL
 * @return mixed
 */
function legacy_urls_redirect($url)
{
    $method = elgg_get_plugin_setting('redirect_method', 'legacy_urls');
    // we only show landing page or queue warning if html generating page
    $viewtype = elgg_get_viewtype();
    if ($viewtype != 'default' && !elgg_does_viewtype_fallback($viewtype)) {
        $method = 'immediate';
    }
    switch ($method) {
        case 'landing':
            $content = elgg_view('legacy_urls/message', array('url' => $url));
            $body = elgg_view_layout('error', array('content' => $content));
            echo elgg_view_page('', $body, 'error');
            return true;
            break;
        case 'immediate_error':
            // drop through after setting error message
            register_error(elgg_echo('changebookmark'));
        case 'immediate':
        default:
            $url = elgg_normalize_url($url);
            header("HTTP/1.1 301 Moved Permanently");
            header("Location: {$url}");
            exit;
            break;
    }
}
コード例 #3
0
ファイル: start.php プロジェクト: rasul/Elgg
/**
 * Handles old pg/twitterservice/ handler
 *
 * @param array$page
 */
function twitter_api_pagehandler_deprecated($page)
{
    $url = elgg_get_site_url() . 'pg/twitter_api/authorize';
    $msg = elgg_echo('twitter_api:deprecated_callback_url', array($url));
    register_error($msg);
    return twitter_api_pagehandler($page);
}
コード例 #4
0
ファイル: events.php プロジェクト: arckinteractive/events_api
/**
 * Clean up operations on calendar delete
 *
 * @param string     $event  "delete"
 * @param string     $type   "object"
 * @param ElggEntity $entity Entity being deleted
 */
function delete_event_handler($event, $type, $entity)
{
    if ($entity instanceof Calendar) {
        // Do not allow users to delete publi calendars
        if ($entity->isPublicCalendar() && !elgg_is_admin_logged_in()) {
            register_error(elgg_echo('events:error:public_calendar_delete'));
            return false;
        }
        // Move all orphaned events to the public calendar
        $owner = $entity->getContainerEntity();
        $public_calendar = Calendar::getPublicCalendar($owner);
        if (!$public_calendar) {
            register_error(elgg_echo('events:error:no_public_for_orphans'));
            return false;
        }
        $dbprefix = elgg_get_config('dbprefix');
        $relationship_name = sanitize_string(Calendar::EVENT_CALENDAR_RELATIONSHIP);
        $calendar_subtype_id = (int) get_subtype_id('object', Calendar::SUBTYPE);
        // Get all events that do not appear on container's other calendars
        $events = new ElggBatch('elgg_get_entities_from_relationship', array('types' => 'object', 'subtypes' => Event::SUBTYPE, 'relationship' => Calendar::EVENT_CALENDAR_RELATIONSHIP, 'relationship_guid' => $entity->guid, 'inverse_relationship' => true, 'limit' => 0, 'wheres' => array("NOT EXISTS(SELECT * FROM {$dbprefix}entity_relationships er2\n\t\t\t\t\tJOIN {$dbprefix}entities e2 ON er2.guid_two = e2.guid\n\t\t\t\t\tWHERE er2.relationship = '{$relationship_name}'\n\t\t\t\t\t\tAND er2.guid_one = e.guid\n\t\t\t\t\t\tAND er2.guid_two != {$entity->guid}\n\t\t\t\t\t\tAND e2.container_guid = {$entity->container_guid}\n\t\t\t\t\t\tAND e2.type = 'object' AND e2.subtype = {$calendar_subtype_id})")));
        foreach ($events as $event) {
            /* @var Event $event */
            $public_calendar->addEvent($event);
        }
    }
    return true;
}
コード例 #5
0
ファイル: start.php プロジェクト: redvabel/Vabelgg
/**
 * Serves pages for twitter.
 *
 * @param array $page
 */
function twitter_api_pagehandler($page)
{
    if (!isset($page[0])) {
        forward();
    }
    switch ($page[0]) {
        case 'authorize':
            twitter_api_authorize();
            break;
        case 'revoke':
            twitter_api_revoke();
            break;
        case 'forward':
            twitter_api_forward();
            break;
        case 'login':
            twitter_api_login();
            break;
        case 'interstitial':
            gatekeeper();
            // only let twitter users do this.
            $guid = elgg_get_logged_in_user_guid();
            $twitter_name = elgg_get_plugin_user_setting('twitter_name', $guid, 'twitter_api');
            if (!$twitter_name) {
                register_error(elgg_echo('twitter_api:invalid_page'));
                forward();
            }
            $pages = dirname(__FILE__) . '/pages/twitter_api';
            include "{$pages}/interstitial.php";
            break;
        default:
            forward();
            break;
    }
}
コード例 #6
0
/**
 * Profile page handler
 *
 * @param array $page Array of URL segments passed by the page handling mechanism
 * @return bool
 */
function profile_page_handler($page)
{
    if (isset($page[0])) {
        $username = $page[0];
        $user = get_user_by_username($username);
        elgg_set_page_owner_guid($user->guid);
    } elseif (elgg_is_logged_in()) {
        forward(elgg_get_logged_in_user_entity()->getURL());
    }
    // short circuit if invalid or banned username
    if (!$user || $user->isBanned() && !elgg_is_admin_logged_in()) {
        register_error(elgg_echo('profile:notfound'));
        forward();
    }
    $action = NULL;
    if (isset($page[1])) {
        $action = $page[1];
    }
    if ($action == 'edit') {
        // use the core profile edit page
        $base_dir = elgg_get_root_path();
        require "{$base_dir}pages/profile/edit.php";
        return true;
    }
    $content = elgg_view('profile/layout', array('entity' => $user));
    $body = elgg_view_layout('one_column', array('content' => $content));
    echo elgg_view_page($user->name, $body);
    return true;
}
コード例 #7
0
ファイル: start.php プロジェクト: elgg/elgg
/**
 * Profile page handler
 *
 * @param array $page Array of URL segments passed by the page handling mechanism
 * @return bool
 */
function profile_page_handler($page)
{
    if (isset($page[0])) {
        $username = $page[0];
        $user = get_user_by_username($username);
        elgg_set_page_owner_guid($user->guid);
    } elseif (elgg_is_logged_in()) {
        forward(elgg_get_logged_in_user_entity()->getURL());
    }
    // short circuit if invalid or banned username
    if (!$user || $user->isBanned() && !elgg_is_admin_logged_in()) {
        register_error(elgg_echo('profile:notfound'));
        forward();
    }
    $action = NULL;
    if (isset($page[1])) {
        $action = $page[1];
    }
    if ($action == 'edit') {
        // use the core profile edit page
        echo elgg_view_resource('profile/edit');
        return true;
    }
    echo elgg_view_resource('profile/view', ['username' => $page[0]]);
    return true;
}
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $plugins = elgg_get_plugins('inactive');
     if (empty($plugins)) {
         system_message('All plugins are active');
         return;
     }
     $ids = array_map(function (ElggPlugin $plugin) {
         return $plugin->getID();
     }, $plugins);
     $ids = array_values($ids);
     if ($this->option('all')) {
         $activate_ids = $ids;
     } else {
         $helper = $this->getHelper('question');
         $question = new ChoiceQuestion('Please select plugins you would like to activate (comma-separated list of indexes)', $ids);
         $question->setMultiselect(true);
         $activate_ids = $helper->ask($this->input, $this->output, $question);
     }
     if (empty($activate_ids)) {
         throw new \RuntimeException('You must select at least one plugin');
     }
     $plugins = [];
     foreach ($activate_ids as $plugin_id) {
         $plugins[] = elgg_get_plugin_from_id($plugin_id);
     }
     do {
         $additional_plugins_activated = false;
         foreach ($plugins as $key => $plugin) {
             if ($plugin->isActive()) {
                 unset($plugins[$key]);
                 continue;
             }
             if (!$plugin->activate()) {
                 // plugin could not be activated in this loop, maybe in the next loop
                 continue;
             }
             $ids = array('cannot_start' . $plugin->getID(), 'invalid_and_deactivated_' . $plugin->getID());
             foreach ($ids as $id) {
                 elgg_delete_admin_notice($id);
             }
             // mark that something has changed in this loop
             $additional_plugins_activated = true;
             unset($plugins[$key]);
             system_message("Plugin {$plugin->getFriendlyName()} has been activated");
         }
         if (!$additional_plugins_activated) {
             // no updates in this pass, break the loop
             break;
         }
     } while (count($plugins) > 0);
     if (count($plugins) > 0) {
         foreach ($plugins as $plugin) {
             $msg = $plugin->getError();
             $string = $msg ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no';
             register_error(elgg_echo($string, array($plugin->getFriendlyName())));
         }
     }
     elgg_flush_caches();
 }
コード例 #9
0
ファイル: ElggPad.php プロジェクト: smellems/elggpad-lite
 function save()
 {
     $guid = parent::save();
     try {
         $sessionID = $this->startSession();
         $groupID = $this->groupID;
         // Create a pad if not exists
         if (!$this->pname) {
             $name = uniqid();
             $this->get_pad_client()->createGroupPad($groupID, $name, elgg_get_plugin_setting('new_pad_text', 'etherpad'));
             $this->setMetaData('pname', $groupID . "\$" . $name);
         }
         $padID = $this->getMetadata('pname');
         //set etherpad permissions
         if ($this->access_id == ACCESS_PUBLIC) {
             $this->get_pad_client()->setPublicStatus($padID, "true");
         } else {
             $this->get_pad_client()->setPublicStatus($padID, "false");
         }
         $this->get_pad_client()->deleteSession($sessionID);
     } catch (Exception $e) {
         register_error($e->getMessage());
         return false;
     }
     return $guid;
 }
コード例 #10
0
ファイル: hooks.php プロジェクト: hypeJunction/au_subgroups
/**
 * prevent users from being invited to subgroups they can't join
 */
function group_invite($hook, $type, $return, $params)
{
    $user_guid = get_input('user_guid');
    $group_guid = get_input('group_guid');
    $group = get_entity($group_guid);
    $parent = get_parent_group($group);
    // if $parent, then this is a subgroup they're being invited to
    // make sure they're a member of the parent
    if ($parent) {
        if (!is_array($user_guid)) {
            $user_guid = array($user_guid);
        }
        $invalid_users = array();
        foreach ($user_guid as $guid) {
            $user = get_user($guid);
            if ($user && !$parent->isMember($user)) {
                $invalid_users[] = $user;
            }
        }
        if (count($invalid_users)) {
            $error_suffix = "<ul>";
            foreach ($invalid_users as $user) {
                $error_suffix .= "<li>{$user->name}</li>";
            }
            $error_suffix .= "</ul>";
            register_error(elgg_echo('au_subgroups:error:invite') . $error_suffix);
            return false;
        }
    }
}
コード例 #11
0
ファイル: start.php プロジェクト: naveensnayak/recaptcha
/**
 * @param $hook
 * @param $type
 * @param $returnvalue
 * @param $params
 *
 * @return bool
 *
 * function called when the below plugin trigger is initiated
 * @see /engine/lib/actions.php
 * @see elgg_trigger_plugin_hook('action', $action, null, $event_result);
 *
 * this hook is triggered for the action = "register"
 * this hooks is called before the default "register" action handler at /actions/register.php
 * checks if recaptcha is valid - if not register an error
 */
function recaptcha_check_form($hook, $type, $returnvalue, $params)
{
    // retain entered form values and re-populate form fields if validation error
    elgg_make_sticky_form('register');
    /*-- check if the 'Use Recaptcha for user registration' Plugin setting is enabled --*/
    //fetch the plugin settings
    $plugin_entity = elgg_get_plugin_from_id('recaptcha');
    $plugin_settings = $plugin_entity->getAllSettings();
    if (array_key_exists('recaptcha_verified', $_SESSION) && $_SESSION['recaptcha_verified'] == 1) {
        //do nothing
    } else {
        if ($plugin_settings['require_recaptcha'] == 'on') {
            //if the setting is enabled
            // include the recaptcha lib
            require_once 'lib/recaptchalib.php';
            // check the recaptcha
            $resp = recaptcha_check_answer($plugin_settings['recaptcha_private_key'], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
            if (!$resp->is_valid) {
                register_error(elgg_echo('recaptcha:human_verification_failed'));
                forward(REFERER);
            } else {
                /* note that the user has successfully passed the captcha
                 * in case the form submission fails due to other factors, we do not want to
                 * ask the user to fill in the captcha details again
                 * so we store it in a session variable and destroy it after the form is successfully submitted
                 */
                $_SESSION['recaptcha_verified'] = 1;
            }
        }
    }
    return true;
}
コード例 #12
0
ファイル: start.php プロジェクト: lorea/Hydra-dev
function url_getter_init()
{
    if (!function_exists('curl_version')) {
        // see, this is why I want a dependency check callback in the core!!
        register_error('The URL Getter depends on CURL, but the library was not found. Please install it.');
    }
}
コード例 #13
0
ファイル: hooks.php プロジェクト: remy40/gvrs
function group_tools_route_groups_handler($hook, $type, $return_value, $params)
{
    /**
     * $return_value contains:
     * $return_value['handler'] => requested handler
     * $return_value['segments'] => url parts ($page)
     */
    $result = $return_value;
    if (!empty($return_value) && is_array($return_value)) {
        $page = $return_value['segments'];
        switch ($page[0]) {
            case "all":
                $filter = get_input("filter");
                if (empty($filter) && ($default_filter = elgg_get_plugin_setting("group_listing", "group_tools"))) {
                    $filter = $default_filter;
                    set_input("filter", $default_filter);
                }
                if (in_array($filter, array("open", "closed", "alpha"))) {
                    // we will handle the output
                    $result = false;
                    include dirname(dirname(__FILE__)) . "/pages/groups/all.php";
                }
                break;
            case "requests":
                $result = false;
                set_input("group_guid", $page[1]);
                include dirname(dirname(__FILE__)) . "/pages/groups/membershipreq.php";
                break;
            case "invite":
                $result = false;
                set_input("group_guid", $page[1]);
                include dirname(dirname(__FILE__)) . "/pages/groups/invite.php";
                break;
            case "mail":
                $result = false;
                set_input("group_guid", $page[1]);
                include dirname(dirname(__FILE__)) . "/pages/mail.php";
                break;
            case "group_invite_autocomplete":
                $result = false;
                include dirname(dirname(__FILE__)) . "/procedures/group_invite_autocomplete.php";
                break;
            case "add":
                if (group_tools_is_group_creation_limited()) {
                    admin_gatekeeper();
                }
                break;
            default:
                // check if we have an old group profile link
                if (isset($page[0]) && is_numeric($page[0])) {
                    if (($group = get_entity($page[0])) && elgg_instanceof($group, "group", null, "ElggGroup")) {
                        register_error(elgg_echo("changebookmark"));
                        forward($group->getURL());
                    }
                }
                break;
        }
    }
    return $result;
}
コード例 #14
0
ファイル: start.php プロジェクト: rasul/Elgg
/**
 * Profile page handler
 *
 * @param array $page Array of page elements, forwarded by the page handling mechanism
 */
function profile_page_handler($page)
{
    if (isset($page[0])) {
        $username = $page[0];
        $user = get_user_by_username($username);
        elgg_set_page_owner_guid($user->guid);
    }
    // short circuit if invalid or banned username
    if (!$user || $user->isBanned() && !elgg_is_admin_logged_in()) {
        register_error(elgg_echo('profile:notfound'));
        forward();
    }
    $action = NULL;
    if (isset($page[1])) {
        $action = $page[1];
    }
    if ($action == 'edit') {
        // use the core profile edit page
        $base_dir = elgg_get_root_path();
        require "{$base_dir}pages/profile/edit.php";
        return;
    }
    // main profile page
    $params = array('content' => elgg_view('profile/wrapper'), 'num_columns' => 3);
    $content = elgg_view_layout('widgets', $params);
    $body = elgg_view_layout('one_column', array('content' => $content));
    echo elgg_view_page($title, $body);
}
コード例 #15
0
 /**
  * Undefined method calls handling. We are only entertaining getMethods and setMethods.
  * 
  * @param string  $functionName
  * @param array   $arguments
  * 
  * @return array
  * 
  * @throws IzapException
  * 
  * @version 5.0
  */
 public function __call($functionName, $arguments)
 {
     try {
         if (preg_match('/^getRequest([A-Za-z]+)/', $functionName, $matches)) {
             $value_to_get = strtolower($matches[1]);
             if (!isset($this->request[$value_to_get])) {
                 throw new IzapException(elgg_echo('izap-elgg-bridge:Exception:no_metadata', array($value_to_get)));
             }
             return $this->request[$value_to_get];
         } elseif (preg_match('/^setRequest([A-Za-z]+)/', $functionName, $matches)) {
             $index_to_set = strtolower($matches[1]);
             $this->request[$index_to_set] = $arguments[0];
         } elseif (preg_match('/^getMetadata/', $functionName, $matches)) {
             // returns whole metadata in term of array
             return $this->request['metadata'];
         } elseif (preg_match('/^get([A-Za-z]+)/', $functionName, $matches)) {
             $value_to_get = strtolower($matches[1]);
             if (!isset($this->request['metadata'][$value_to_get])) {
                 throw new IzapException(sprintf(elgg_echo('izap-elgg-bridge:Exception:no_metadata'), $value_to_get));
             }
             return $this->request['metadata'][$value_to_get];
         } elseif (preg_match('/^set([A-Za-z]+)/', $functionName, $matches)) {
             $index_to_set = strtolower($matches[1]);
             $this->request['metadata'][$index_to_set] = $arguments[0];
         } else {
             throw new IzapException(sprintf(elgg_echo('izap-elgg-bridge:Exception:no_method'), $functionName));
         }
     } catch (IzapException $ze) {
         register_error($ze->getMessage());
     }
 }
コード例 #16
0
ファイル: lib.php プロジェクト: duanhv/mdg-social
/**
 * insert user into elgg user table
 *
 * Get user info from db
 * Tries to insert, otherwise return error
 *
 * @return user
 */
function cas_insertUser($username, $casUser, $config)
{
    //     $name = $attr['cn'];
    //     $uname = !empty($attr['textuid']) ? $attr['textuid'] : str_replace(".", "",$username);
    //     $email = $attr['mail'];
    $name = $casUser->name;
    $uname = !empty($casUser->username) ? $casUser->username : $username;
    $email = $casUser->email;
    $password = md5($uname . $email);
    $user = new ElggUser();
    $user->username = $uname;
    $user->email = $email;
    $user->name = $name;
    $user->access_id = 2;
    $user->salt = generate_random_cleartext_password();
    // Note salt generated before password!
    $user->password = generate_user_password($user, $password);
    $user->save();
    $guid = $user->guid;
    $obj = get_entity($guid);
    if (isset($config->casadminuser) && $config->casadminuser == $username) {
        if ($obj instanceof ElggUser && $obj->canEdit()) {
            $obj->admin = 'yes';
            if ($obj->admin) {
                system_message(elgg_echo('admin:user:makeadmin:yes'));
            } else {
                register_error(elgg_echo('admin:user:makeadmin:no'));
            }
        } else {
            register_error(elgg_echo('admin:user:makeadmin:no'));
        }
    }
    return $user;
}
コード例 #17
0
ファイル: events.php プロジェクト: bgunn/spam_login_filter
/**
 * Called on the login user event
 * Checks for spammers
 * 
 * @param type $event
 * @param type $type
 * @param type $user
 * @return boolean
 */
function login_event($event, $type, $user)
{
    $check_login = elgg_get_plugin_setting('event_login', PLUGIN_ID);
    $ip = get_ip();
    $user->ip_address = $ip;
    if ($check_login != 'no' || !$user->last_login) {
        // do it by default
        if (!check_spammer($user->email, $ip, true) && !$user->isAdmin()) {
            register_error(elgg_echo('spam_login_filter:access_denied_mail_blacklist'));
            notify_admin($user->email, $ip, "Existing member identified as spammer has tried to login, check this account");
            return false;
        }
    }
    // check user metadata for banned words/phrases
    $banned = get_banned_strings();
    $metadata = get_metadata_names();
    if ($banned && $metadata) {
        foreach ($metadata as $m) {
            foreach ($banned as $str) {
                if (strpos($user->{$m}, $str) !== false) {
                    return false;
                }
            }
        }
    }
}
コード例 #18
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;
    }
}
コード例 #19
0
/**
 * Listen to the login event to make sure the user is validated
 *
 * @param string   $event the name of the event
 * @param string   $type  the type of the event
 * @param ElggUser $user  supplied user
 *
 * @return bool
 */
function uservalidationbyadmin_login_event($event, $type, $user)
{
    $result = false;
    // make sure we can see all users
    $hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // do we actualy have a user
    if (!empty($user) && elgg_instanceof($user, "user")) {
        // is the user enabled
        if ($user->isEnabled()) {
            if ($user->isAdmin()) {
                // admins are always allowed
                $result = true;
            } elseif (isset($user->admin_validated)) {
                // check if the user is validated
                if ($user->admin_validated) {
                    // user is validated and can login
                    $result = true;
                }
            } else {
                // user has register before this plugin was activated
                $result = true;
            }
        }
    }
    // check if the user can login
    if (empty($result)) {
        // register error
        register_error(elgg_echo("uservalidationbyadmin:login:error"));
    }
    // restore access setting
    access_show_hidden_entities($hidden);
    return $result;
}
コード例 #20
0
ファイル: start.php プロジェクト: adamboardman/Elgg
/**
 * Get security token, forward to action.
 *
 * @param unknown_type $page
 * @return unknown_type
 */
function uservalidationbyemail_page_handler($page)
{
    global $CONFIG;
    if (isset($page[0]) && $page[0] == 'confirm') {
        $code = sanitise_string(get_input('c', FALSE));
        $user_guid = get_input('u', FALSE);
        // new users are not enabled by default.
        $access_status = access_get_show_hidden_status();
        access_show_hidden_entities(true);
        $user = get_entity($user_guid);
        if ($code && $user) {
            if (uservalidationbyemail_validate_email($user_guid, $code)) {
                system_message(elgg_echo('email:confirm:success'));
                $user = get_entity($user_guid);
                $user->enable();
                notify_user($user_guid, $CONFIG->site->guid, sprintf(elgg_echo('email:validate:success:subject'), $user->username), sprintf(elgg_echo('email:validate:success:body'), $user->name), NULL, 'email');
            } else {
                register_error(elgg_echo('email:confirm:fail'));
            }
        } else {
            register_error(elgg_echo('email:confirm:fail'));
        }
        access_show_hidden_entities($access_status);
    } else {
        register_error(elgg_echo('email:confirm:fail'));
    }
    forward();
}
コード例 #21
0
ファイル: video_feed.php プロジェクト: rimpy/izap_videos
 function capture($url)
 {
     global $IZAPSETTINGS;
     $url = $IZAPSETTINGS->apiUrl . '&url=' . urlencode($url);
     $curl = new IzapCurl($url);
     $raw_contents = $curl->exec();
     $returnObject = json_decode($raw_contents);
     if ($returnObject == NULL || $returnObject == FALSE) {
         register_error(elgg_echo('izap_videos:no_response_from_server'));
         forward($_SERVER['HTTP_REFERER']);
         exit;
     }
     // We are not supporting this url.
     if (!$returnObject || empty($returnObject->embed_code)) {
         return $returnObject;
     }
     $obj = new stdClass();
     $obj->title = $returnObject->title;
     $obj->description = $returnObject->description;
     $obj->videoThumbnail = $returnObject->thumb_url;
     $obj->videoSrc = $returnObject->embed_code;
     $obj->videoTags = $returnObject->tags;
     $obj->domain = $returnObject->url;
     $obj->fileName = time() . '_' . basename($obj->videoThumbnail);
     $obj->fileContent = file_get_contents($obj->videoThumbnail);
     $obj->type = $returnObject->type;
     return $obj;
 }
コード例 #22
0
ファイル: start.php プロジェクト: iionly/agerestriction
function agerestriction_register_hook()
{
    elgg_make_sticky_form('register');
    if (get_input('agevalid', false) != 'true') {
        register_error(elgg_echo('agerestriction:required'));
        forward(REFERER);
    }
}
コード例 #23
0
ファイル: functions.php プロジェクト: lorea/Hydra-dev
/**
 * Only site announcement editors can access this part
 *
 * @return void
 */
function site_announcements_editor_gatekeeper()
{
    elgg_gatekeeper();
    if (!site_announcements_is_editor()) {
        register_error(elgg_echo('limited_access'));
        forward(REFERER);
    }
}
コード例 #24
0
ファイル: ajax_demo.php プロジェクト: elgg/elgg
function developers_ajax_demo_alter($hook, $type, Elgg\Services\AjaxResponse $v, $p)
{
    // check data added by client hook
    if (get_input('client_request_altered') == '1') {
        // add some data to the response
        $v->getData()->server_response_altered = 2;
    }
    register_error('Hello from ajax_response hook');
}
コード例 #25
0
 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $upgrader = _elgg_services()->upgrades;
     $result = $upgrader->run();
     if ($result['failure'] == true) {
         register_error($result['reason']);
     } else {
         system_message('Upgrade script ran without failures');
     }
 }
コード例 #26
0
ファイル: start.php プロジェクト: pleio/recaptcha
function recaptcha_action_hook($hook, $entity_type, $returnvalue, $params)
{
    $response = get_input('g-recaptcha-response');
    if ($response && recaptcha_validate_code($response)) {
        return true;
    } else {
        register_error(elgg_echo('recaptcha:could_not_validate'));
        forward(REFERER);
    }
}
コード例 #27
0
ファイル: start.php プロジェクト: adamboardman/Elgg
/**
 * Dispatches blog pages.
 * To maintain URL backward compatibility, expects old-style URLs like:
 * 	pg/blog/[username/[read|edit|archive|new/[time_start|guid/[time_end|title]]]]
 *
 * Without a username, show all blogs
 * Without an action (read|edit|archive|new), forward to pg/blog/username/read.
 * Without a guid, show all post for that user.
 * Title is ignored
 *
 * If archive, uses time_start/end
 *
 * @todo There is no way to say "show me archive view for all blog posts" with the
 * current URL scheme because $param[0] is the username instead of an action.
 * Could do something hideous like make '*' mean "all users" (since a username can't be *).
 * Can't change the URL scheme because of URL compatibility.
 *
 * @param array $page
 * @return NULL
 */
function blog_page_handler($page)
{
    global $CONFIG;
    elgg_push_breadcrumb(elgg_echo('blog:blogs'), "{$CONFIG->site->url}pg/blog");
    // see if we're showing all or just a user's
    if (isset($page[0]) && !empty($page[0])) {
        $username = $page[0];
        // forward away if invalid user.
        if (!($user = get_user_by_username($username))) {
            register_error('blog:error:unknown_username');
            forward($_SERVER['HTTP_REFERER']);
        }
        set_page_owner($user->getGUID());
        $crumbs_title = sprintf(elgg_echo('blog:owned_blogs'), $user->name);
        $crumbs_url = "{$CONFIG->site->url}pg/blog/{$username}/read";
        elgg_push_breadcrumb($crumbs_title, $crumbs_url);
        $action = isset($page[1]) ? $page[1] : FALSE;
        // yeah these are crap names, but they're used for different things.
        $page2 = isset($page[2]) ? $page[2] : FALSE;
        $page3 = isset($page[3]) ? $page[3] : FALSE;
        switch ($action) {
            case 'read':
                $title = sprintf(elgg_echo('blog:title:user_blogs'), $user->name);
                $content_info = blog_get_page_content_read($user->getGUID(), $page2);
                break;
            case 'new':
            case 'edit':
                //$sidebar = elgg_view('blog/sidebar_edit', array('blog_guid' => $page2));
                $content_info = blog_get_page_content_edit($page2, $page3);
                break;
            case 'archives':
                $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog'));
                $content .= blog_get_page_content_archive($user->getGUID(), $page2, $page3);
                break;
            case 'friends':
                $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog'));
                $content .= blog_get_page_content_archive($user->getGUID());
                break;
            default:
                forward("pg/blog/{$username}/read/");
                break;
        }
    } else {
        $title = elgg_echo('blog:title:all_blogs');
        $content_info = blog_get_page_content_read();
    }
    $sidebar .= elgg_view('blog/sidebar_menu');
    if (isset($content_info['sidebar'])) {
        $sidebar .= $content_info['sidebar'];
    }
    $content = elgg_view('navigation/breadcrumbs') . $content_info['content'];
    $body = elgg_view_layout('one_column_with_sidebar', $content, $sidebar);
    page_draw($title, $body);
}
コード例 #28
0
function elgg_modifications_generate_digischool_menu_page_handler($page)
{
    admin_gatekeeper();
    if (elgg_is_active_plugin("menu_builder")) {
        // remove current menu items
        $current_options = array("type" => "object", "subtype" => "menu_builder_menu_item", "limit" => false);
        if ($current_items = elgg_get_entities($current_options)) {
            foreach ($current_items as $current_item) {
                $current_item->delete();
            }
        }
        // 			var_dump($current_items);
        // 			exit();
        // add the new ones
        $site = elgg_get_site_entity();
        $site_acl = $site->getACL();
        $menu_items = array(array("title" => "Voorpagina", "url" => "[wwwroot]", "access_id" => ACCESS_PUBLIC, "children" => array(array("title" => "Alle blogs", "url" => "[wwwroot]blog/all", "access_id" => ACCESS_PUBLIC), array("title" => "Alle activiteiten", "url" => "[wwwroot]activity", "access_id" => ACCESS_LOGGED_IN))), array("title" => "Statische pagina's", "url" => "[wwwroot]lidworden", "access_id" => ACCESS_LOGGED_IN), array("title" => "Archief", "url" => "Zelf in te vullen", "access_id" => ACCESS_PUBLIC), array("title" => "Leermiddelen", "url" => "#", "access_id" => ACCESS_PUBLIC, "children" => array(array("title" => "Vakpagina", "url" => "hier de link naar uw vakp", "access_id" => ACCESS_PUBLIC), array("title" => "Leermiddelenbank Digischool", "url" => "[wwwroot]", "access_id" => ACCESS_PUBLIC), array("title" => "Leden keurmerkgroepen", "url" => "zelf te vullen", "access_id" => ACCESS_PUBLIC))), array("title" => "Leden", "url" => "#", "access_id" => ACCESS_LOGGED_IN, "children" => array(array("title" => "Mijn groepen", "url" => "[wwwroot]groups/member/[username]", "access_id" => $site_acl), array("title" => "Mijn profielpagina", "url" => "[wwwroot]profile/[username]", "access_id" => $site_acl), array("title" => "Alle groepen", "url" => "[wwwroot]groups/all/?filter=pop", "access_id" => $site_acl), array("title" => "Lid worden", "url" => "[wwwroot]lidworden", "access_id" => ACCESS_PUBLIC), array("title" => "Content toevoegen", "url" => "[wwwroot]add", "access_id" => $site_acl), array("title" => "Mijn dashboard", "url" => "[wwwroot]dashboard", "access_id" => $site_acl), array("title" => "Zoeken leden", "url" => "[wwwroot]members", "access_id" => $site_acl), array("title" => "Mijn contacten", "url" => "[wwwroot]friends/[username]", "access_id" => $site_acl), array("title" => "Contactverzoeken", "url" => "[wwwroot]friend_request/", "access_id" => $site_acl), array("title" => "Mijn instellingen", "url" => "[wwwroot]settings", "access_id" => $site_acl), array("title" => "Nieuwe groep maken", "url" => "[wwwroot]groups/add", "access_id" => $site_acl))), array("title" => "Beheer", "url" => "[wwwroot]admin", "access_id" => ACCESS_PRIVATE, "children" => array(array("title" => "Gebruikersbeheer", "url" => "[wwwroot]admin/users/newest", "access_id" => ACCESS_PRIVATE), array("title" => "Nodig leden uit", "url" => "[wwwroot]admin/users/invite", "access_id" => ACCESS_PRIVATE), array("title" => "Pluginbeheer", "url" => "[wwwroot]admin/plugins", "access_id" => ACCESS_PRIVATE), array("title" => "Beheer template", "url" => "[wwwroot]admin/appearance/template", "access_id" => ACCESS_PRIVATE))));
        $i = 0;
        foreach ($menu_items as $main_item) {
            $item = new ElggObject();
            $item->subtype = "menu_builder_menu_item";
            $item->owner_guid = $site->getGUID();
            $item->container_guid = $site->getGUID();
            $item->site_guid = $site->getGUID();
            $item->access_id = $main_item["access_id"];
            $item->parent_guid = 0;
            $item->title = $main_item["title"];
            $item->url = $main_item["url"];
            $item->order = $i;
            $i++;
            $item->save();
            if (array_key_exists("children", $main_item)) {
                foreach ($main_item["children"] as $sub_item) {
                    $submenu_item = new ElggObject();
                    $submenu_item->subtype = "menu_builder_menu_item";
                    $submenu_item->owner_guid = $site->getGUID();
                    $submenu_item->container_guid = $site->getGUID();
                    $submenu_item->site_guid = $site->getGUID();
                    $submenu_item->access_id = $sub_item["access_id"];
                    $submenu_item->parent_guid = $item->getGUID();
                    $submenu_item->title = $sub_item["title"];
                    $submenu_item->url = $sub_item["url"];
                    $submenu_item->order = $i;
                    $i++;
                    $submenu_item->save();
                }
            }
        }
        system_message("menu created");
    } else {
        register_error("plugin menu_builder not activated");
    }
    forward();
}
コード例 #29
0
/**
 * Page handler for embeds
 * 
 * @param array $page
 */
function embed_page_handler($page)
{
    $params = array('output' => '', 'status' => 0, 'system_messages' => array('error' => array(), 'success' => array()));
    $container_guid = get_input('container_guid');
    if ($container_guid && get_entity($container_guid)) {
        elgg_set_page_owner_guid($container_guid);
    }
    switch ($page[0]) {
        default:
        case 'tab':
            $default_tab = elgg_is_active_plugin('file') ? 'file' : 'content_items';
            $embed_tab = elgg_extract(1, $page, $default_tab);
            $title = elgg_echo("embed:embed");
            $filter = elgg_view('embed/filter', array('filter_context' => $embed_tab));
            $view = "embed/tab/{$embed_tab}";
            if (elgg_view_exists($view)) {
                $content = elgg_view($view);
            } else {
                $embed_tab = elgg_get_config('embed_tab');
                if ($embed_tab instanceof \ElggMenuItem) {
                    $view = $embed_tab->getData('view');
                    $options = $embed_tab->getData('options');
                    if ($view) {
                        $content = elgg_view($view);
                    } else {
                        if ($options) {
                            $content = elgg_view('embed/get_list', array('options' => $options));
                        }
                    }
                }
            }
            if (empty($content)) {
                $content = elgg_autop(elgg_echo('embed:section:invalid'));
            }
            $params['output'] = elgg_view_layout('one_column', array('title' => $title, 'content' => $filter . $content, 'class' => 'embed-wrapper'));
            break;
    }
    $system_messages = system_messages(NULL, "");
    if (isset($system_messages['success'])) {
        $params['system_messages']['success'] = $system_messages['success'];
    }
    if (isset($system_messages['error'])) {
        $params['system_messages']['error'] = $system_messages['error'];
        $params['status'] = -1;
    }
    // We do not want to serve this page via non-xhr requests
    if (!elgg_is_xhr()) {
        register_error(elgg_echo('embed:error:non_xhr_request'));
        return false;
    }
    echo json_encode($params);
    exit;
}
コード例 #30
0
ファイル: izap_sqlite.php プロジェクト: rimpy/izap_videos
 function __construct()
 {
     global $CONFIG;
     try {
         parent::__construct($CONFIG->dataroot . 'izap_queue_db/queue.db');
         $this->setup();
     } catch (PDOException $e) {
         register_error(elgg_echo("izap_videos:error:sqliteDrivers"));
         izapAdminSettings_izap_videos('izapVideoOptions', array('OFFSERVER', 'EMBED'), TRUE);
         izapAdminSettings_izap_videos('izap_cron_time', 'none', TRUE);
     }
 }