Esempio n. 1
0
/**
 * Log the current user out
 *
 * @return bool
 */
function logout()
{
    $session = _elgg_services()->session;
    $user = $session->getLoggedInUser();
    if (!$user) {
        return false;
    }
    if (!elgg_trigger_before_event('logout', 'user', $user)) {
        return false;
    }
    // deprecate event
    $message = "The 'logout' event was deprecated. Register for 'logout:before' or 'logout:after'";
    $version = "1.9";
    if (!elgg_trigger_deprecated_event('logout', 'user', $user, $message, $version)) {
        return false;
    }
    _elgg_services()->persistentLogin->removePersistentLogin();
    // pass along any messages into new session
    $old_msg = $session->get('msg');
    $session->invalidate();
    $session->set('msg', $old_msg);
    elgg_trigger_after_event('logout', 'user', $user);
    return true;
}
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function save()
 {
     $result = false;
     if (elgg_trigger_before_event('create', 'object', $this)) {
         $result = parent::save();
         if ($result) {
             elgg_trigger_after_event('create', 'object', $this);
         }
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * Send a response
  *
  * @param Response $response Response object
  * @return Response
  */
 public function send(Response $response)
 {
     if ($this->response_sent) {
         if ($this->response_sent !== $response) {
             _elgg_services()->logger->error('Unable to send the following response: ' . PHP_EOL . (string) $response . PHP_EOL . 'because another response has already been sent: ' . PHP_EOL . (string) $this->response_sent);
         }
     } else {
         if (!elgg_trigger_before_event('send', 'http_response', $response)) {
             return false;
         }
         if (!$this->transport->send($response)) {
             return false;
         }
         elgg_trigger_after_event('send', 'http_response', $response);
         $this->response_sent = $response;
     }
     return $this->response_sent;
 }
Esempio n. 4
0
} else {
    unset_config('debug', $site->getGUID());
}
// allow new user registration?
$allow_registration = 'on' === get_input('allow_registration', false);
set_config('allow_registration', $allow_registration, $site->getGUID());
// setup walled garden
$walled_garden = 'on' === get_input('walled_garden', false);
set_config('walled_garden', $walled_garden, $site->getGUID());
if ('on' === get_input('https_login')) {
    set_config('https_login', 1, $site->getGUID());
} else {
    unset_config('https_login', $site->getGUID());
}
$regenerate_site_secret = get_input('regenerate_site_secret', false);
if ($regenerate_site_secret) {
    // if you cancel this even you should present a message to the user
    if (elgg_trigger_before_event('regenerate_site_secret', 'system')) {
        init_site_secret();
        elgg_reset_system_cache();
        elgg_trigger_after_event('regenerate_site_secret', 'system');
        system_message(elgg_echo('admin:site:secret_regenerated'));
        elgg_delete_admin_notice('weak_site_key');
    }
}
if ($site->save()) {
    system_message(elgg_echo("admin:configuration:success"));
} else {
    register_error(elgg_echo("admin:configuration:fail"));
}
forward(REFERER);
Esempio n. 5
0
 /**
  * Validate that a message has a sender, at least one recipient and body
  * @return boolean
  */
 public function validate()
 {
     $sender = $this->getSender();
     if (!$sender) {
         return false;
     }
     $recipients = $this->getRecipients();
     if (!is_array($recipients) || !count($recipients)) {
         return false;
     }
     $body = $this->getBody();
     if (!$body) {
         return false;
     }
     if (elgg_trigger_before_event('send', 'object', $this) === false) {
         return false;
     }
     return true;
 }
Esempio n. 6
0
/**
 * Log the current user out
 *
 * @return bool
 */
function logout()
{
    $session = _elgg_services()->session;
    $user = $session->getLoggedInUser();
    if (!$user) {
        return false;
    }
    if (!elgg_trigger_before_event('logout', 'user', $user)) {
        return false;
    }
    _elgg_services()->persistentLogin->removePersistentLogin();
    // pass along any messages into new session
    $old_msg = $session->get('msg');
    $session->invalidate();
    $session->set('msg', $old_msg);
    elgg_trigger_after_event('logout', 'user', $user);
    return true;
}