Пример #1
0
/**
 * @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;
}
Пример #2
0
function agerestriction_register_hook()
{
    elgg_make_sticky_form('register');
    if (get_input('agevalid', false) != 'true') {
        register_error(elgg_echo('agerestriction:required'));
        forward(REFERER);
    }
}
Пример #3
0
function action_hook($h, $t, $r, $p)
{
    $actions = get_recaptcha_actions();
    if (is_array($actions) && in_array($t, $actions)) {
        if (!validate_recaptcha()) {
            elgg_make_sticky_form($t);
            register_error(elgg_echo('elgg_recaptcha:message:fail'));
            // workaround for https://github.com/Elgg/Elgg/issues/8960
            elgg_unregister_plugin_hook_handler('forward', 'system', 'uservalidationbyemail_after_registration_url');
            forward(REFERER);
        }
    }
}
Пример #4
0
/**
 * Listen to the action plugin hook and check the captcha.
 *
 * @param string $hook        name of the hook
 * @param string $action      the action being called
 * @param array  $returnvalue current returnvalue
 * @param array  $params      parameters
 *
 * @return boolean
 */
function image_captcha_verify_action_hook($hook, $action, $returnvalue, $params)
{
    $token = get_input('image_captcha');
    if ($token && $token == $_SESSION["image_captcha"]) {
        return true;
    }
    if ($action === 'register') {
        // Make sure the entered user data is not lost
        elgg_make_sticky_form('register');
    }
    register_error(elgg_echo('image_captcha:verify:fail'));
    // forward to referrer or else action code sends to front page
    forward(REFERER);
}
Пример #5
0
 /**
  * Executes an action
  * Triggers 'action:after', $ation hook that allows you to filter the Result object
  * 
  * @param mixed $controller Action name or instance of Action
  * @param bool  $feedback   Display errors and messages
  * @return ActionResult
  */
 public function execute($controller = null, $feedback = true)
 {
     try {
         $action = $this->parseActionName($controller);
         elgg_make_sticky_form($action);
         if (!$controller instanceof Action) {
             $controller = $this->getController($action);
         }
         if (!$controller instanceof Action) {
             throw new Exception("Not a valid action controller");
         }
         $controller->setup();
         if ($controller->validate() === false) {
             throw new ActionValidationException("Invalid input for action {$action}");
         }
         $controller->execute();
         $this->result = $controller->getResult();
     } catch (ActionValidationException $ex) {
         $this->result->addError($ex->getMessage());
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (PermissionsException $ex) {
         $this->result->addError(elgg_echo('apps:permissions:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (InvalidEntityException $ex) {
         $this->result->addError(elgg_echo('apps:entity:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (Exception $ex) {
         $this->result->addError(elgg_echo('apps:action:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     }
     $errors = $this->result->getErrors();
     $messages = $this->result->getMessages();
     if (empty($errors)) {
         elgg_clear_sticky_form($action);
     } else {
         $this->result->setForwardURL(REFERRER);
     }
     if ($feedback) {
         foreach ($errors as $error) {
             register_error($error);
         }
         foreach ($messages as $message) {
             system_message($message);
         }
     }
     return elgg_trigger_plugin_hook('action:after', $action, null, $this->result);
 }
Пример #6
0
/**
 * @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 the terms of use checkbox is checked - if not register an error
 */
function terms_of_use_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 'Require user to accept terms' Plugin setting is enabled --*/
    //fetch the plugin settings
    $plugin_obj = elgg_get_plugin_from_id('terms_of_use');
    $plugin_settings = $plugin_obj->getAllSettings();
    if ($plugin_settings['require_terms_of_use'] == 'on') {
        //if the setting is enabled
        // Get POST variables
        $require_terms_of_use = get_input('checkbox-require-terms-of-use');
        if (trim($require_terms_of_use) != 'on') {
            register_error(elgg_echo('terms_of_use:registration_exception:require_checkbox'));
            forward(REFERER);
        }
    }
    return true;
}
Пример #7
0
<?php

/**
 * Topic save action
 */
// Get variables
$title = htmlspecialchars(get_input('title', '', false), ENT_QUOTES, 'UTF-8');
$desc = get_input("description");
$status = get_input("status");
$access_id = (int) get_input("access_id");
$container_guid = (int) get_input('container_guid');
$guid = (int) get_input('topic_guid');
$tags = get_input("tags");
elgg_make_sticky_form('topic');
// validation of inputs
if (!$title || !$desc) {
    register_error(elgg_echo('discussion:error:missing'));
    forward(REFERER);
}
$container = get_entity($container_guid);
if (!$container || !$container->canWriteToContainer(0, 'object', 'groupforumtopic')) {
    register_error(elgg_echo('discussion:error:permissions'));
    forward(REFERER);
}
// check whether this is a new topic or an edit
$new_topic = true;
if ($guid > 0) {
    $new_topic = false;
}
if ($new_topic) {
    $topic = new ElggObject();
Пример #8
0
$input = array();
foreach ($variables as $name => $type) {
    if ($name == 'title') {
        $input[$name] = htmlspecialchars(get_input($name, '', false), ENT_QUOTES, 'UTF-8');
    } else {
        $input[$name] = get_input($name);
    }
    if ($type == 'tags') {
        $input[$name] = string_to_tag_array($input[$name]);
    }
}
// Get guids
$page_guid = (int) get_input('page_guid');
$container_guid = (int) get_input('container_guid');
$parent_guid = (int) get_input('parent_guid');
elgg_make_sticky_form('page');
if (!$input['title']) {
    register_error(elgg_echo('pages:error:no_title'));
    forward(REFERER);
}
if ($page_guid) {
    $page = get_entity($page_guid);
    if (!$page || !$page->canEdit()) {
        register_error(elgg_echo('pages:error:no_save'));
        forward(REFERER);
    }
    /*elseif($page->checkedOut && $page->checkedOut != elgg_get_logged_in_user_guid()){
    		$checkee = get_entity($page->checkedOut)->name;
    		register_error(elgg_echo('Page is currently checked out by: '.$checkee));
    		forward($page->getURL());
    	}*/
Пример #9
0
<?php

/**
 * Elgg groups plugin edit action.
 *
 * @package ElggGroups
 */
elgg_make_sticky_form('groups');
/**
 * wrapper for recursive array walk decoding
 */
function profile_array_decoder(&$v)
{
    $v = _elgg_html_decode($v);
}
// Get group fields
$input = array();
foreach (elgg_get_config('group') as $shortname => $valuetype) {
    $input[$shortname] = get_input($shortname);
    // @todo treat profile fields as unescaped: don't filter, encode on output
    if (is_array($input[$shortname])) {
        array_walk_recursive($input[$shortname], 'profile_array_decoder');
    } else {
        $input[$shortname] = _elgg_html_decode($input[$shortname]);
    }
    if ($valuetype == 'tags') {
        $input[$shortname] = string_to_tag_array($input[$shortname]);
    }
}
$input['name'] = htmlspecialchars(get_input('name', '', false), ENT_QUOTES, 'UTF-8');
$user = elgg_get_logged_in_user_entity();
Пример #10
0
$title = get_input('title');
$description = get_input('description');
$tags = get_input('tags');
$container_guid = (int) get_input('container_guid');
$guid = (int) get_input('guid');
$access_id = get_input('access_id');
$user_guid = elgg_get_logged_in_user_guid();
if (is_null($access_id)) {
    $access_id = get_default_access($user_guid);
    $sysmsg = " failed to get access id";
}
if (!can_write_to_container($user_guid, $container_guid)) {
    register_error(elgg_echo('answers:error'));
    forward(REFERER);
}
elgg_make_sticky_form('question');
// Make sure the title / description aren't blank
if (empty($title)) {
    register_error(elgg_echo('answers:question:blank'));
    forward(REFERER);
}
// Otherwise, save the question
if ($guid) {
    $question = get_entity($guid);
    $new = false;
} else {
    $question = new ElggObject();
    $question->subtype = 'question';
    $new = true;
}
$question->access_id = $access_id;
<?php

/**
 * Elgg add action
 *
 * @package Elgg
 * @subpackage Core
 */
elgg_make_sticky_form('useradd');
// Get variables
$username = get_input('username');
$password = get_input('password');
$password2 = get_input('password2');
$email = get_input('email');
$name = get_input('name');
$admin = get_input('admin');
if (is_array($admin)) {
    $admin = $admin[0];
}
$notify = get_input('notify', false);
if (is_array($notify)) {
    $notify = $notify[0];
}
$use_default_access = get_input('use_default_access', false);
if (is_array($use_default_access)) {
    $use_default_access = $use_default_access[0];
}
$custom_profile_fields = get_input("custom_profile_fields");
// For now, just try and register the user
try {
    $guid = register_user($username, $password, $name, $email, TRUE);
Пример #12
0
function subsite_manager_set_missing_subsite_profile_fields($user_guid = 0)
{
    $result = false;
    $accesslevel = get_input('accesslevel');
    elgg_make_sticky_form("subsite_missing_profile_fields");
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    if (!empty($user_guid) && ($user = get_user($user_guid))) {
        $form_vars = elgg_get_sticky_values("subsite_missing_profile_fields");
        $profile_fields = array();
        // filter the input
        foreach ($form_vars as $key => $value) {
            if (strpos($key, "custom_profile_fields_") === 0) {
                $key = substr($key, 22);
                $profile_fields[$key] = $value;
            }
        }
        if (!empty($profile_fields)) {
            foreach ($profile_fields as $key => $value) {
                remove_metadata($user->getGUID(), $key);
                if (!empty($value)) {
                    if ($accesslevel && array_key_exists($key, $accesslevel)) {
                        $access_id = $accesslevel[$key];
                    } else {
                        $access_id = get_default_access($user);
                    }
                    if (is_array($value)) {
                        foreach ($value as $index => $v) {
                            $multiple = false;
                            if ($index > 0) {
                                $multiple = true;
                            }
                            create_metadata($user->getGUID(), $key, $v, "text", $user->getGUID(), $access_id, $multiple);
                        }
                    } else {
                        create_metadata($user->getGUID(), $key, $value, "text", $user->getGUID(), $access_id);
                    }
                }
            }
            // in javascript we trust ;)
            $result = true;
        } else {
            $result = true;
        }
    }
    return $result;
}
Пример #13
0
<?php

/**
 * Add recipients to a newsletter.
 *
 * This can be done by providing
 * - user_guids
 * - group_guids
 * - email addresses
 * - set subscibers
 * - set members (site or group)
 * - uploading a CSV with email addresses
 */
elgg_make_sticky_form("newsletter_recipients");
$guid = (int) get_input("guid");
$user_guids = get_input("user_guids");
$group_guids = get_input("group_guids");
$emails = get_input("emails");
$subscribers = (int) get_input("subscribers");
$members = (int) get_input("members");
$forward_url = REFERER;
if (!empty($guid)) {
    $entity = get_entity($guid);
    if (!empty($entity) && $entity->canEdit()) {
        if (elgg_instanceof($entity, "object", Newsletter::SUBTYPE)) {
            $recipients = $entity->getRecipients();
            if (empty($recipients)) {
                $forward_url = "newsletter/edit/" . $entity->getGUID() . "/schedule";
            }
            // make sere we have the correct format
            if (empty($user_guids)) {
Пример #14
0
 /**
  * Store submitted sticky values
  *
  * @param string $action Action name
  * @return bool
  */
 public function saveStickyValues($action = '')
 {
     return elgg_make_sticky_form($action);
 }
Пример #15
0
<?php

elgg_make_sticky_form('data_generator/run');
$amount = get_input('amount');
$profile = get_input('profile');
$locale = get_input('locale');
try {
    $mt = microtime(true);
    $success = data_generator::generate($amount, $profile, $locale);
    $total = microtime(true) - $mt;
    system_message(elgg_echo('data_generator:action:run:success', array($success, $total)));
    elgg_clear_sticky_form('data_generator/run');
} catch (Exception $e) {
    register_error($e->getMessage());
}
Пример #16
0
<?php

/**
 * Elgg profile edit action
 *
 */
elgg_make_sticky_form('profile:edit');
$guid = get_input('guid');
$owner = get_entity($guid);
if (!$owner || !$owner instanceof ElggUser || !$owner->canEdit()) {
    register_error(elgg_echo('profile:noaccess'));
    forward(REFERER);
}
// grab the defined profile field names and their load the values from POST.
// each field can have its own access, so sort that too.
$input = array();
$accesslevel = get_input('accesslevel');
if (!is_array($accesslevel)) {
    $accesslevel = array();
}
/**
 * wrapper for recursive array walk decoding
 */
function profile_array_decoder(&$v)
{
    $v = _elgg_html_decode($v);
}
$profile_fields = elgg_get_config('profile_fields');
foreach ($profile_fields as $shortname => $valuetype) {
    // the decoding is a stop gap to prevent &amp;&amp; showing up in profile fields
    // because it is escaped on both input (get_input()) and output (view:output/text). see #561 and #1405.
Пример #17
0
<?php

/**
 * Save blog entity
 *
 * Can be called by clicking save button or preview button. If preview button,
 * we automatically save as draft. The preview button is only available for
 * non-published drafts.
 *
 * Drafts are saved with the access set to private.
 *
 * @package Blog
 */
// start a new sticky form session in case of failure
elgg_make_sticky_form('blog');
// save or preview
$save = (bool) get_input('save');
// store errors to pass along
$error = FALSE;
$error_forward_url = REFERER;
$user = elgg_get_logged_in_user_entity();
// edit or create a new entity
$guid = get_input('guid');
if ($guid) {
    $entity = get_entity($guid);
    if (elgg_instanceof($entity, 'object', 'blog') && $entity->canEdit()) {
        $blog = $entity;
    } else {
        register_error(elgg_echo('blog:error:post_not_found'));
        forward(get_input('forward', REFERER));
    }
Пример #18
0
<?php

/**
 * Create or edit a project
 */
// Get guids
$project_guid = (int) get_input('project_guid');
$container_guid = (int) get_input('container_guid');
$title = get_input('title');
$short_desc = get_input('short_desc');
$description = get_input('description');
$competencies = get_input('competencies');
$tags = get_input('tags');
elgg_make_sticky_form('project');
if (!$title) {
    register_error(elgg_echo('gvprojects:error:no_title'));
    forward(REFERER);
}
if ($project_guid) {
    $project = get_entity($project_guid);
    if (!$project || !$project->canEdit()) {
        register_error(elgg_echo('gvprojects:error:no_save'));
        forward(REFERER);
    }
    $new_project = false;
} else {
    $project = new ElggObject();
    $project->subtype = 'project';
    $new_project = true;
}
$project->title = $title;
Пример #19
0
<?php

/**
 * Elgg registration action
 *
 * @package Elgg.Core
 * @subpackage User.Account
 */
elgg_make_sticky_form('register');
// Get variables
$username = get_input('username');
$password = get_input('password', null, false);
$password2 = get_input('password2', null, false);
$email = get_input('email');
$name = get_input('name');
$friend_guid = (int) get_input('friend_guid', 0);
$invitecode = get_input('invitecode');
if (elgg_get_config('allow_registration')) {
    try {
        if (trim($password) == "" || trim($password2) == "") {
            throw new RegistrationException(elgg_echo('RegistrationException:EmptyPassword'));
        }
        if (strcmp($password, $password2) != 0) {
            throw new RegistrationException(elgg_echo('RegistrationException:PasswordMismatch'));
        }
        $guid = register_user($username, $password, $name, $email);
        if ($guid) {
            $new_user = get_entity($guid);
            // allow plugins to respond to self registration
            // note: To catch all new users, even those created by an admin,
            // register for the create, user event instead.
Пример #20
0
<?php

namespace AU\AnonymousComments;

elgg_make_sticky_form('comments/anon_add');
// add in some extra htmlawed rules for non logged in commenters
elgg_register_plugin_hook_handler('htmlawed', 'config', __NAMESPACE__ . '\\htmlawed_config');
$anon_name = get_input('anon_name');
$anon_email = get_input('anon_email');
$entity_guid = (int) get_input('entity_guid', 0, false);
$comment_guid = (int) get_input('comment_guid', 0, false);
$comment_text = get_input('generic_comment');
if (empty($comment_text)) {
    register_error(elgg_echo("generic_comment:blank"));
    forward(REFERER);
}
// check if name was entered, if not send them back
if (empty($anon_name)) {
    register_error(elgg_echo("AU_anonymous_comments:name_blank"));
    forward(REFERER);
}
// check if name was entered, if not send them back
if (empty($anon_email)) {
    register_error(elgg_echo("AU_anonymous_comments:email_blank"));
    forward(REFERER);
}
if (substr_count($comment_text, "http://") > 1 || substr_count($comment_text, "https://") > 1) {
    register_error(elgg_echo("AU_anonymous_comments:no_URLs_allowed"));
    forward(REFERER);
}
//simple check to ensure default text was overwritten
Пример #21
0
<?php

/**
* Ssend a message action
*
* @package ElggMessages
*/
$subject = strip_tags(get_input('subject'));
$body = get_input('body');
$recipients = (array) get_input('recipients');
$original_msg_guid = (int) get_input('original_guid');
elgg_make_sticky_form('messages');
if (empty($recipients)) {
    register_error(elgg_echo("messages:user:blank"));
    forward("messages/compose");
}
$recipient = (int) elgg_extract(0, $recipients);
if ($recipient == elgg_get_logged_in_user_guid()) {
    register_error(elgg_echo("messages:user:self"));
    forward("messages/compose");
}
$user = get_user($recipient);
if (!$user) {
    register_error(elgg_echo("messages:user:nonexist"));
    forward("messages/compose");
}
// Make sure the message field, send to field and title are not blank
if (!$body || !$subject) {
    register_error(elgg_echo("messages:blank"));
    forward("messages/compose");
}
Пример #22
0
 * License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
$crud_type = get_input('crud');
$guid = get_input('guid');
$entity = get_entity($guid);
$crud = crud_get_handler($crud_type);
$msg_prefix = $crud->module . ":general";
$variables = array('periodicity' => 'text', 'chat' => 'text', 'streaming' => 'text', 'voip' => 'text', 'location' => 'text');
$input = array();
foreach ($variables as $name => $type) {
    $input[$name] = get_input($name);
}
// Get guids
$group = (int) get_input('guid');
elgg_make_sticky_form('assemblies_general');
foreach ($input as $name => $value) {
    $name = 'assembly_' . $name;
    $entity->{$name} = $value;
}
if ($entity->save()) {
    elgg_clear_sticky_form('assemblies_general');
    system_message(elgg_echo($msg_prefix . ':saved'));
    /*if ($new_entity) {
    		add_to_river('river/object/crud/create', 'create', elgg_get_logged_in_user_guid(), $entity->guid);
    	}
    	else {
    		add_to_river('river/object/crud/create', 'edited', elgg_get_logged_in_user_guid(), $entity->guid);
    	}*/
    forward('assembly/owner/' . $guid);
} else {
Пример #23
0
<?php

/*
 * Elgg Poll plugin
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 *
 * add/edit action
 */
elgg_load_library('elgg:poll');
// start a new sticky form session in case of failure
elgg_make_sticky_form('poll');
// Get input data
$question = get_input('question');
$description = get_input('description');
$number_of_choices = (int) get_input('number_of_choices', 0);
$front_page = get_input('front_page');
$close_date = get_input('close_date');
$open_poll = (int) get_input('open_poll');
$tags = get_input('tags');
$access_id = get_input('access_id');
$container_guid = get_input('container_guid');
$guid = get_input('guid');
//get response choices
$count = 0;
$new_choices = array();
if ($number_of_choices) {
    for ($i = 0; $i < $number_of_choices; $i++) {
        $text = get_input('choice_text_' . $i, '');
        if ($text) {
            $new_choices[] = $text;
            $count++;
/**
 * function to check if custom fields on register have been filled (if required)
 * 
 * @param $hook_name
 * @param $entity_type
 * @param $return_value
 * @param $parameters
 * @return unknown_type
 */
function profile_manager_action_register_hook($hook_name, $entity_type, $return_value, $parameters)
{
    elgg_make_sticky_form('register');
    elgg_make_sticky_form('profile_manager_register');
    // validate mandatory profile fields
    $profile_icon = elgg_get_plugin_setting("profile_icon_on_register", "profile_manager");
    // new
    $profile_type_guid = get_input("custom_profile_fields_custom_profile_type", false);
    $fields = profile_manager_get_categorized_fields($user, true, true, true, $profile_type_guid);
    $required_fields = array();
    if (!empty($fields["categories"])) {
        foreach ($fields["categories"] as $cat_guid => $cat) {
            $cat_fields = $fields["fields"][$cat_guid];
            foreach ($cat_fields as $field) {
                if ($field->show_on_register == "yes" && $field->admin_only != "yes" && $field->mandatory == "yes") {
                    $required_fields[] = $field;
                }
            }
        }
    }
    if ($required_fields || $profile_icon == "yes") {
        $custom_profile_fields = array();
        foreach ($_POST as $key => $value) {
            if (strpos($key, "custom_profile_fields_") == 0) {
                $key = substr($key, 22);
                $custom_profile_fields[$key] = $value;
            }
        }
        foreach ($required_fields as $entity) {
            $passed_value = $custom_profile_fields[$entity->metadata_name];
            if (empty($passed_value)) {
                register_error(sprintf(elgg_echo("profile_manager:register_pre_check:missing"), $entity->getTitle()));
                forward(REFERER);
            }
        }
        if ($profile_icon == "yes") {
            $profile_icon = $_FILES["profile_icon"];
            $error = false;
            if (empty($profile_icon["name"])) {
                register_error(sprintf(elgg_echo("profile_manager:register_pre_check:missing"), "profile_icon"));
                $error = true;
            } elseif ($profile_icon["error"] != 0) {
                register_error(elgg_echo("profile_manager:register_pre_check:profile_icon:error"));
                $error = true;
            } elseif (!in_array(strtolower(substr($profile_icon["name"], -3)), array("jpg", "png", "gif"))) {
                register_error(elgg_echo("profile_manager:register_pre_check:profile_icon:nosupportedimage"));
                $error = true;
            }
            if ($error) {
                forward(REFERER);
            }
        }
    }
}
Пример #25
0
$input = array();
foreach ($variables as $name => $type) {
    if ($name != 'summary') {
        $input[$name] = get_input($name);
    }
    if ($name == 'title') {
        $input[$name] = strip_tags($input[$name]);
    }
    if ($type == 'tags') {
        $input[$name] = string_to_tag_array($input[$name]);
    }
    if ($name == 'description') {
        $input[$name] = get_markdown_input($_REQUEST[$name]);
    }
}
elgg_make_sticky_form('markdown_wiki');
if (!$input['container_guid']) {
    register_error(elgg_echo('markdown_wiki:error:no_group'));
    forward(elgg_get_site_url() . 'wiki/all');
}
if (!can_write_to_container($user_guid, $input['container_guid'], 'object', 'markdown_wiki')) {
    register_error(elgg_echo('markdown_wiki:error:no_access'));
    forward(REFERER);
}
if (!$input['title']) {
    register_error(elgg_echo('markdown_wiki:error:no_title'));
    forward(REFERER);
}
if (!$input['description']) {
    register_error(elgg_echo('markdown_wiki:error:no_description'));
    forward(REFERER);
Пример #26
0
<?php

/**
 * Elgg registration action
 *
 * @package Elgg.Core
 * @subpackage User.Account
 */
elgg_make_sticky_form('hybridauth_register');
// Get variables
$username = get_input('username');
$password = get_input('password', null, false);
$password2 = get_input('password2', null, false);
$email = get_input('email');
$email_verified = get_input('email_verified');
$authpass = get_input('authpass', null, false);
if ($email_verified) {
    $email = $email_verified;
    $verified = true;
}
$name = get_input('name');
$friend_guid = (int) get_input('friend_guid', 0);
$invitecode = get_input('invitecode');
$provider_uid = get_input('provider_uid');
$provider = get_input('provider');
$photo_url = get_input('photo_url');
// The user has an existing account. Lets prompt for their password
if ($users = get_user_by_email($email)) {
    $return_url = elgg_get_site_url() . "hybridauth/authenticate?provider={$provider}&require_auth=true&e=" . urlencode($email);
    if ($authpass) {
        // Authenticate the user
Пример #27
0
<?php

elgg_make_sticky_form('answer');
$guid = (int) get_input('guid');
$answer = new ElggAnswer($guid);
$adding = !$answer->guid;
$editing = !$adding;
if ($editing && !$answer->canEdit()) {
    register_error(elgg_echo('InvalidParameterException:NoEntityFound'));
    forward(REFERER);
}
$container_guid = (int) get_input('container_guid');
$description = get_input('description');
if (empty($container_guid) || empty($description)) {
    register_error(elgg_echo('questions:action:answer:save:error:body', [$container_guid, $description]));
    forward(REFERER);
}
if ($adding && !can_write_to_container(0, $container_guid, 'object', 'answer')) {
    register_error(elgg_echo('questions:action:answer:save:error:container'));
    forward(REFERER);
}
$question = get_entity($container_guid);
if (empty($question) || !$question instanceof ElggQuestion) {
    register_error(elgg_echo('ClassException:ClassnameNotClass', [$container_guid, elgg_echo('item:object:question')]));
    forward(REFERER);
}
if ($question->getStatus() != 'open') {
    elgg_clear_sticky_form('answer');
    register_error(elgg_echo('questions:action:answer:save:error:question_closed'));
    forward(REFERER);
}
Пример #28
0
<?php

elgg_make_sticky_form('scheduling');
$guid = get_input('guid');
$entity = get_entity($guid);
if (!$entity instanceof ElggSchedulingPoll || !$entity->canEdit()) {
    register_error(elgg_echo('scheduling:error:cannot_edit'));
    forward();
}
$slots = array();
$input = (array) get_input('slots', array());
foreach ($input as $index => $date_info) {
    $date = $date_info['date'];
    $date_slots = $date_info['slot'];
    foreach ($date_slots as $slot) {
        if (empty($slot)) {
            continue;
        }
        $slots[] = strtotime("{$date} {$slot}");
    }
}
if ($entity->setSlots($slots)) {
    system_message(elgg_echo('scheduling:save:success'));
} else {
    register_error(elgg_echo('scheduling:save:error'));
}
elgg_clear_sticky_form('scheduling');
forward($entity->getURL());
Пример #29
0
<?php

/**
 * Invite a user to join a group
 *
 * @package ElggGroups
 */
elgg_make_sticky_form('group_invite');
$logged_in_user = elgg_get_logged_in_user_entity();
$user_guids = get_input("user_guid");
if (!empty($user_guids) && !is_array($user_guids)) {
    $user_guids = array($user_guids);
}
$adding = false;
if (elgg_is_admin_logged_in()) {
    // add all users?
    if (get_input("all_users") == "yes") {
        $site = elgg_get_site_entity();
        $options = array("limit" => false, "callback" => "group_tools_guid_only_callback");
        $user_guids = $site->getMembers($options);
    }
    // add users directly?
    if (get_input("submit") == elgg_echo("group_tools:add_users")) {
        $adding = true;
    }
}
$group_guid = (int) get_input("group_guid");
$text = get_input("comment");
$emails = get_input("user_guid_email");
if (!empty($emails) && !is_array($emails)) {
    $emails = array($emails);
Пример #30
0
function private_profiles_pm_intercept($hook, $type, $result, $params)
{
    $subject = strip_tags(get_input('subject'));
    $body = get_input('body');
    $recipient_username = get_input('recipient_username');
    $original_msg_guid = (int) get_input('original_guid');
    elgg_make_sticky_form('messages');
    $user = get_user_by_username($recipient_username);
    if (!$user || elgg_is_admin_logged_in() || $user->isAdmin()) {
        return $result;
    }
    $logged_in_user = elgg_get_logged_in_user_entity();
    $custom_access_setting = elgg_get_plugin_setting('custom_access_setting', 'private_profiles');
    if (!$custom_access_setting) {
        $custom_access_setting = 'yes';
    }
    if ($custom_access_setting == 'no') {
        $default_messages_setting = elgg_get_plugin_setting('default_messages_setting', 'private_profiles');
        if (!$default_messages_setting) {
            $default_messages_setting = 'friends';
        }
        if ($default_messages_setting == 'yes' || $default_messages_setting == 'friends' && ($logged_in_user && $logged_in_user->isFriendOf($user->getGUID()))) {
            return $result;
        }
    } else {
        $user_messages_setting = elgg_get_plugin_user_setting('user_messages_setting', $user->getGUID(), 'private_profiles');
        if (!$user_messages_setting) {
            $default_messages_setting = elgg_get_plugin_setting('default_messages_setting', 'private_profiles');
            if (!$default_messages_setting) {
                $default_messages_setting = 'friends';
            }
            $user_messages_setting = $default_messages_setting;
        }
        if ($user_messages_setting == 'yes' || $user_messages_setting == 'friends' && ($logged_in_user && $logged_in_user->isFriendOf($user->getGUID()))) {
            return $result;
        }
    }
    register_error(elgg_echo('private_profiles:sending_denied'));
    forward("messages/compose");
    return false;
}