We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 31f20794 authored by Sarven Capadisli's avatar Sarven Capadisli

Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x

parents bf123d14 7ee875b1
......@@ -175,13 +175,43 @@ class Notice extends Memcached_DataObject
}
}
/**
* Save a new notice and push it out to subscribers' inboxes.
* Poster's permissions are checked before sending.
*
* @param int $profile_id Profile ID of the poster
* @param string $content source message text; links may be shortened
* per current user's preference
* @param string $source source key ('web', 'api', etc)
* @param array $options Associative array of optional properties:
* string 'created' timestamp of notice; defaults to now
* int 'is_local' source/gateway ID, one of:
* Notice::LOCAL_PUBLIC - Local, ok to appear in public timeline
* Notice::REMOTE_OMB - Sent from a remote OMB service;
* hide from public timeline but show in
* local "and friends" timelines
* Notice::LOCAL_NONPUBLIC - Local, but hide from public timeline
* Notice::GATEWAY - From another non-OMB service;
* will not appear in public views
* float 'lat' decimal latitude for geolocation
* float 'lon' decimal longitude for geolocation
* int 'location_id' geoname identifier
* int 'location_ns' geoname namespace to interpret location_id
* int 'reply_to'; notice ID this is a reply to
* int 'repeat_of'; notice ID this is a repeat of
* string 'uri' permalink to notice; defaults to local notice URL
*
* @return Notice
* @throws ClientException
*/
static function saveNew($profile_id, $content, $source, $options=null) {
$defaults = array('uri' => null,
'reply_to' => null,
'repeat_of' => null);
if (!empty($options)) {
$options = $options + $defaults;
extract($options);
if (!isset($reply_to)) {
$reply_to = NULL;
}
}
if (empty($is_local)) {
......@@ -966,6 +996,9 @@ class Notice extends Memcached_DataObject
return true;
}
/**
* @return array of integer profile IDs
*/
function saveReplies()
{
// Alternative reply format
......@@ -1044,8 +1077,8 @@ class Notice extends Memcached_DataObject
$recipientIds = array_keys($replied);
foreach ($recipientIds as $recipient) {
$user = User::staticGet('id', $recipient);
foreach ($recipientIds as $recipientId) {
$user = User::staticGet('id', $recipientId);
if ($user) {
mail_notify_attn($user, $this);
}
......
......@@ -180,6 +180,27 @@ class User extends Memcached_DataObject
return $result;
}
/**
* Register a new user account and profile and set up default subscriptions.
* If a new-user welcome message is configured, this will be sent.
*
* @param array $fields associative array of optional properties
* string 'bio'
* string 'email'
* bool 'email_confirmed' pass true to mark email as pre-confirmed
* string 'fullname'
* string 'homepage'
* string 'location' informal string description of geolocation
* float 'lat' decimal latitude for geolocation
* float 'lon' decimal longitude for geolocation
* int 'location_id' geoname identifier
* int 'location_ns' geoname namespace to interpret location_id
* string 'nickname' REQUIRED
* string 'password' (may be missing for eg OpenID registrations)
* string 'code' invite code
* ?string 'uri' permalink to notice; defaults to local notice URL
* @return mixed User object or false on failure
*/
static function register($fields) {
// MAGICALLY put fields into current scope
......@@ -329,7 +350,7 @@ class User extends Memcached_DataObject
$profile->query('COMMIT');
if ($email && !$user->email) {
if (!empty($email) && !$user->email) {
mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
}
......
<?php
/*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* PHP 5.3 implementation of function currying, using native closures.
* On 5.2 and lower we use the fallback implementation in util.php
*
* @param callback $fn
* @param ... any remaining arguments will be appended to call-time params
* @return callback
*/
function curry($fn) {
$extra_args = func_get_args();
array_shift($extra_args);
return function() use ($fn, $extra_args) {
$args = func_get_args();
return call_user_func_array($fn,
array_merge($args, $extra_args));
};
}
......@@ -523,19 +523,23 @@ function callback_helper($matches, $callback, $notice_id) {
return substr($matches[0],0,$left) . $result . substr($matches[0],$right);
}
function curry($fn) {
//TODO switch to a PHP 5.3 function closure based approach if PHP 5.3 is used
$args = func_get_args();
array_shift($args);
$id = uniqid('_partial');
$GLOBALS[$id] = array($fn, $args);
return create_function('',
'$args = func_get_args(); '.
'return call_user_func_array('.
'$GLOBALS["'.$id.'"][0],'.
'array_merge('.
'$args,'.
'$GLOBALS["'.$id.'"][1]));');
if (version_compare(PHP_VERSION, '5.3.0', 'ge')) {
// lambda implementation in a separate file; PHP 5.2 won't parse it.
require_once INSTALLDIR . "/lib/curry.php";
} else {
function curry($fn) {
$args = func_get_args();
array_shift($args);
$id = uniqid('_partial');
$GLOBALS[$id] = array($fn, $args);
return create_function('',
'$args = func_get_args(); '.
'return call_user_func_array('.
'$GLOBALS["'.$id.'"][0],'.
'array_merge('.
'$args,'.
'$GLOBALS["'.$id.'"][1]));');
}
}
function common_linkify($url) {
......@@ -1240,8 +1244,12 @@ function common_copy_args($from)
return $to;
}
// Neutralise the evil effects of magic_quotes_gpc in the current request.
// This is used before handing a request off to OAuthRequest::from_request.
/**
* Neutralise the evil effects of magic_quotes_gpc in the current request.
* This is used before handing a request off to OAuthRequest::from_request.
* @fixme Doesn't consider vars other than _POST and _GET?
* @fixme Can't be undone and could corrupt data if run twice.
*/
function common_remove_magic_from_request()
{
if(get_magic_quotes_gpc()) {
......@@ -1443,6 +1451,17 @@ function common_database_tablename($tablename)
return $tablename;
}
/**
* Shorten a URL with the current user's configured shortening service,
* or ur1.ca if configured, or not at all if no shortening is set up.
* Length is not considered.
*
* @param string $long_url
* @return string may return the original URL if shortening failed
*
* @fixme provide a way to specify a particular shortener
* @fixme provide a way to specify to use a given user's shortening preferences
*/
function common_shorten_url($long_url)
{
$user = common_current_user();
......@@ -1463,6 +1482,16 @@ function common_shorten_url($long_url)
}
}
/**
* @return mixed array($proxy, $ip) for web requests; proxy may be null
* null if not a web request
*
* @fixme X-Forwarded-For can be chained by multiple proxies;
we should parse the list and provide a cleaner array
* @fixme X-Forwarded-For can be forged by clients; only use them if trusted
* @fixme X_Forwarded_For headers will override X-Forwarded-For read through $_SERVER;
* use function to get exact request headers from Apache if possible.
*/
function common_client_ip()
{
if (!isset($_SERVER) || !array_key_exists('REQUEST_METHOD', $_SERVER)) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment