forked from GNUsocial/gnu-social
Merge branch 'refactor-api' of git@gitorious.org:~zcopley/statusnet/zcopleys-clone into refactor-api
This commit is contained in:
commit
ccc7caf932
12
EVENTS.txt
12
EVENTS.txt
@ -170,12 +170,6 @@ StartShowBody: called before showing the <body> element and children
|
|||||||
EndShowBody: called after showing the <body> element (and </body>)
|
EndShowBody: called after showing the <body> element (and </body>)
|
||||||
- $action: action object being shown
|
- $action: action object being shown
|
||||||
|
|
||||||
StartHeadChildren: called before showing the children of <head> element (after <head> tag)
|
|
||||||
- $action: action object being shown
|
|
||||||
|
|
||||||
EndHeadChildren: called after showing the children of <head> element (before </head>)
|
|
||||||
- $action: action object being shown
|
|
||||||
|
|
||||||
StartPersonalGroupNav: beginning of personal group nav menu
|
StartPersonalGroupNav: beginning of personal group nav menu
|
||||||
- $action: action object being shown
|
- $action: action object being shown
|
||||||
|
|
||||||
@ -271,3 +265,9 @@ GetValidDaemons: Just before determining which daemons to run
|
|||||||
|
|
||||||
HandleQueuedNotice: Handle a queued notice at queue time (or immediately if no queue)
|
HandleQueuedNotice: Handle a queued notice at queue time (or immediately if no queue)
|
||||||
- &$notice: notice to handle
|
- &$notice: notice to handle
|
||||||
|
|
||||||
|
StartShowHeadElements: Right after the <head> tag
|
||||||
|
- $action: the current action
|
||||||
|
|
||||||
|
EndShowHeadElements: Right before the </head> tag; put <script>s here if you need them in <head>
|
||||||
|
- $action: the current action
|
||||||
|
@ -68,6 +68,7 @@ class AllrssAction extends Rss10Action
|
|||||||
$this->clientError(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
$this->notices = $this->getNotices($this->limit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,13 +362,13 @@ class AvatarsettingsAction extends AccountSettingsAction
|
|||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
$avatar = $profile->getOriginalAvatar();
|
$avatar = $profile->getOriginalAvatar();
|
||||||
$avatar->delete();
|
if($avatar) $avatar->delete();
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
$avatar->delete();
|
if($avatar) $avatar->delete();
|
||||||
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
||||||
$avatar->delete();
|
if($avatar) $avatar->delete();
|
||||||
$avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
|
$avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
|
||||||
$avatar->delete();
|
if($avatar) $avatar->delete();
|
||||||
|
|
||||||
$this->showForm(_('Avatar deleted.'), true);
|
$this->showForm(_('Avatar deleted.'), true);
|
||||||
}
|
}
|
||||||
|
@ -50,11 +50,11 @@ require_once INSTALLDIR.'/lib/rssaction.php';
|
|||||||
*/
|
*/
|
||||||
class FavoritesrssAction extends Rss10Action
|
class FavoritesrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
|
|
||||||
/** The user whose favorites to display */
|
/** The user whose favorites to display */
|
||||||
|
|
||||||
var $user = null;
|
var $user = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the user to display by supplied nickname
|
* Find the user to display by supplied nickname
|
||||||
*
|
*
|
||||||
@ -66,7 +66,7 @@ class FavoritesrssAction extends Rss10Action
|
|||||||
function prepare($args)
|
function prepare($args)
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$nickname = $this->trimmed('nickname');
|
$nickname = $this->trimmed('nickname');
|
||||||
$this->user = User::staticGet('nickname', $nickname);
|
$this->user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
@ -74,10 +74,11 @@ class FavoritesrssAction extends Rss10Action
|
|||||||
$this->clientError(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
$this->notices = $this->getNotices($this->limit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get notices
|
* Get notices
|
||||||
*
|
*
|
||||||
|
@ -104,6 +104,7 @@ class groupRssAction extends Rss10Action
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->notices = $this->getNotices($this->limit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,13 +433,14 @@ class NewnoticeAction extends Action
|
|||||||
$content = $this->trimmed('status_textarea');
|
$content = $this->trimmed('status_textarea');
|
||||||
if (!$content) {
|
if (!$content) {
|
||||||
$replyto = $this->trimmed('replyto');
|
$replyto = $this->trimmed('replyto');
|
||||||
|
$inreplyto = $this->trimmed('inreplyto');
|
||||||
$profile = Profile::staticGet('nickname', $replyto);
|
$profile = Profile::staticGet('nickname', $replyto);
|
||||||
if ($profile) {
|
if ($profile) {
|
||||||
$content = '@' . $profile->nickname . ' ';
|
$content = '@' . $profile->nickname . ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$notice_form = new NoticeForm($this, '', $content);
|
$notice_form = new NoticeForm($this, '', $content, null, $inreplyto);
|
||||||
$notice_form->show();
|
$notice_form->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +49,23 @@ require_once INSTALLDIR.'/lib/rssaction.php';
|
|||||||
*/
|
*/
|
||||||
class PublicrssAction extends Rss10Action
|
class PublicrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Read arguments and initialize members
|
||||||
|
*
|
||||||
|
* @param array $args Arguments from $_REQUEST
|
||||||
|
* @return boolean success
|
||||||
|
*/
|
||||||
|
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
$this->notices = $this->getNotices($this->limit);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization.
|
* Initialization.
|
||||||
*
|
*
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
*/
|
*/
|
||||||
function init()
|
function init()
|
||||||
@ -73,7 +87,7 @@ class PublicrssAction extends Rss10Action
|
|||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
$notices[] = clone($notice);
|
$notices[] = clone($notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $notices;
|
return $notices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ class RepliesrssAction extends Rss10Action
|
|||||||
$this->clientError(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
$this->notices = $this->getNotices($this->limit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,8 +378,13 @@ class ShowstreamAction extends ProfileAction
|
|||||||
$this->showEmptyListMessage();
|
$this->showEmptyListMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$args = array('nickname' => $this->user->nickname);
|
||||||
|
if (!empty($this->tag))
|
||||||
|
{
|
||||||
|
$args['tag'] = $this->tag;
|
||||||
|
}
|
||||||
$this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
|
$this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
|
||||||
'showstream', array('nickname' => $this->user->nickname));
|
'showstream', $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAnonymousMessage()
|
function showAnonymousMessage()
|
||||||
|
@ -293,6 +293,105 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function join($args, $apidata)
|
||||||
|
{
|
||||||
|
parent::handle($args);
|
||||||
|
|
||||||
|
common_debug("in groups api action");
|
||||||
|
|
||||||
|
$this->auth_user = $apidata['user'];
|
||||||
|
$group = $this->get_group($apidata['api_arg'], $apidata);
|
||||||
|
|
||||||
|
if (empty($group)) {
|
||||||
|
$this->clientError('Not Found', 404, $apidata['content-type']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->auth_user->isMember($group)){
|
||||||
|
$this->clientError(_('You are already a member of that group'), $code = 403);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Group_block::isBlocked($group, $this->auth_user->getProfile())) {
|
||||||
|
$this->clientError(_('You have been blocked from that group by the admin.'), 403);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$member = new Group_member();
|
||||||
|
|
||||||
|
$member->group_id = $group->id;
|
||||||
|
$member->profile_id = $this->auth_user->id;
|
||||||
|
$member->created = common_sql_now();
|
||||||
|
|
||||||
|
$result = $member->insert();
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
common_log_db_error($member, 'INSERT', __FILE__);
|
||||||
|
$this->serverError(sprintf(_('Could not join user %s to group %s'),
|
||||||
|
$this->auth_user->nickname, $group->nickname));
|
||||||
|
}
|
||||||
|
|
||||||
|
switch($apidata['content-type']) {
|
||||||
|
case 'xml':
|
||||||
|
$this->show_single_xml_group($group);
|
||||||
|
break;
|
||||||
|
case 'json':
|
||||||
|
$this->show_single_json_group($group);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function leave($args, $apidata)
|
||||||
|
{
|
||||||
|
parent::handle($args);
|
||||||
|
|
||||||
|
common_debug("in groups api action");
|
||||||
|
|
||||||
|
$this->auth_user = $apidata['user'];
|
||||||
|
$group = $this->get_group($apidata['api_arg'], $apidata);
|
||||||
|
|
||||||
|
if (empty($group)) {
|
||||||
|
$this->clientError('Not Found', 404, $apidata['content-type']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! $this->auth_user->isMember($group)){
|
||||||
|
$this->clientError(_('You are not a member of that group'), $code = 403);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$member = new Group_member();
|
||||||
|
|
||||||
|
$member->group_id = $group->id;
|
||||||
|
$member->profile_id = $this->auth_user->id;
|
||||||
|
|
||||||
|
if (!$member->find(true)) {
|
||||||
|
$this->serverError(_('Could not find membership record.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $member->delete();
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
common_log_db_error($member, 'INSERT', __FILE__);
|
||||||
|
$this->serverError(sprintf(_('Could not remove user %s to group %s'),
|
||||||
|
$this->auth_user->nickname, $group->nickname));
|
||||||
|
}
|
||||||
|
|
||||||
|
switch($apidata['content-type']) {
|
||||||
|
case 'xml':
|
||||||
|
$this->show_single_xml_group($group);
|
||||||
|
break;
|
||||||
|
case 'json':
|
||||||
|
$this->show_single_json_group($group);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function is_member($args, $apidata)
|
function is_member($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
@ -326,4 +425,29 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
|
|||||||
$this->clientError(_('API method not found!'), $code = 404);
|
$this->clientError(_('API method not found!'), $code = 404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create($args, $apidata)
|
||||||
|
{
|
||||||
|
die("todo");
|
||||||
|
}
|
||||||
|
|
||||||
|
function update($args, $apidata)
|
||||||
|
{
|
||||||
|
die("todo");
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_group_logo($args, $apidata)
|
||||||
|
{
|
||||||
|
die("todo");
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroy($args, $apidata)
|
||||||
|
{
|
||||||
|
die("todo");
|
||||||
|
}
|
||||||
|
|
||||||
|
function tag($args, $apidata)
|
||||||
|
{
|
||||||
|
die("todo");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ require_once(INSTALLDIR.'/lib/rssaction.php');
|
|||||||
|
|
||||||
class UserrssAction extends Rss10Action
|
class UserrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
var $user = null;
|
|
||||||
var $tag = null;
|
var $tag = null;
|
||||||
|
|
||||||
function prepare($args)
|
function prepare($args)
|
||||||
@ -39,6 +38,7 @@ class UserrssAction extends Rss10Action
|
|||||||
$this->clientError(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
$this->notices = $this->getNotices($this->limit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,9 +64,8 @@ class UserrssAction extends Rss10Action
|
|||||||
|
|
||||||
function getNotices($limit=0)
|
function getNotices($limit=0)
|
||||||
{
|
{
|
||||||
|
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
|
|
||||||
if (is_null($user)) {
|
if (is_null($user)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -909,7 +909,8 @@ class Notice extends Memcached_DataObject
|
|||||||
$qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') ";
|
$qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') ";
|
||||||
$cnt++;
|
$cnt++;
|
||||||
if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) {
|
if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) {
|
||||||
Notice_inbox::gc($id);
|
// FIXME: Causes lag in replicated servers
|
||||||
|
// Notice_inbox::gc($id);
|
||||||
}
|
}
|
||||||
if ($cnt >= MAX_BOXCARS) {
|
if ($cnt >= MAX_BOXCARS) {
|
||||||
$inbox = new Notice_inbox();
|
$inbox = new Notice_inbox();
|
||||||
|
@ -117,11 +117,15 @@ class User extends Memcached_DataObject
|
|||||||
function allowed_nickname($nickname)
|
function allowed_nickname($nickname)
|
||||||
{
|
{
|
||||||
// XXX: should already be validated for size, content, etc.
|
// XXX: should already be validated for size, content, etc.
|
||||||
static $blacklist = array('rss', 'xrds', 'doc', 'main',
|
|
||||||
'settings', 'notice', 'user',
|
$blacklist = array();
|
||||||
'search', 'avatar', 'tag', 'tags',
|
|
||||||
'api', 'message', 'group', 'groups',
|
//all directory and file names should be blacklisted
|
||||||
'local');
|
$d = dir(INSTALLDIR);
|
||||||
|
while (false !== ($entry = $d->read())) {
|
||||||
|
$blacklist[]=$entry;
|
||||||
|
}
|
||||||
|
$d->close();
|
||||||
$merged = array_merge($blacklist, common_config('nickname', 'blacklist'));
|
$merged = array_merge($blacklist, common_config('nickname', 'blacklist'));
|
||||||
return !in_array($nickname, $merged);
|
return !in_array($nickname, $merged);
|
||||||
}
|
}
|
||||||
|
@ -61,4 +61,5 @@ VALUES
|
|||||||
(100113, 'T-Mobile Germany', '%s@t-mobile-sms.de', now()),
|
(100113, 'T-Mobile Germany', '%s@t-mobile-sms.de', now()),
|
||||||
(100114, 'Vodafone Germany', '%s@vodafone-sms.de', now()),
|
(100114, 'Vodafone Germany', '%s@vodafone-sms.de', now()),
|
||||||
(100115, 'E-Plus', '%s@smsmail.eplus.de', now()),
|
(100115, 'E-Plus', '%s@smsmail.eplus.de', now()),
|
||||||
(100116, 'Cellular South', '%s@csouth1.com', now());
|
(100116, 'Cellular South', '%s@csouth1.com', now()),
|
||||||
|
(100117, 'ChinaMobile (139)', '%s@139.com', now());
|
||||||
|
@ -2,6 +2,4 @@ A bookmarklet is a small piece of javascript code used as a bookmark. This one w
|
|||||||
|
|
||||||
Drag-and-drop the following link to your bookmarks bar or right-click it and add it to your browser favorites to keep it handy.
|
Drag-and-drop the following link to your bookmarks bar or right-click it and add it to your browser favorites to keep it handy.
|
||||||
|
|
||||||
<MTMarkdownOptions output='raw'>
|
<a href="javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://%%site.server%%/%%site.path%%/index.php?action=newnotice',l=d.location,e=encodeURIComponent,g=f+'&status_textarea=%22'+((e(s))?e(s):e(document.title))+'%22 from '+l.href;function%20a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=800,height=570')){l.href=g;}}a();void(0);">Post to %%site.name%%</a>
|
||||||
<a href="javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://%%site.server%%/%%site.path%%/index.php?action=newnotice',l=d.location,e=encodeURIComponent,g=f+'&status_textarea=%22'+((e(s))?e(s):e(document.title))+'%22 from '+l.href;function%20a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=800,height=570')){l.href=g;}}a();void(0);">Post to %%site.name%%</a>
|
|
||||||
</MTMarkdownOptions>
|
|
||||||
|
@ -37,10 +37,10 @@ currently-implemented commands:
|
|||||||
* **help**: Show this help. List available Jabber/XMPP commands
|
* **help**: Show this help. List available Jabber/XMPP commands
|
||||||
* **follow <nickname>**: Subscribe to <nickname>
|
* **follow <nickname>**: Subscribe to <nickname>
|
||||||
* **sub <nickname>**: Same as follow
|
* **sub <nickname>**: Same as follow
|
||||||
* **leave <nickname>**: Subscribe to <nickname>
|
* **leave <nickname>**: Unsubscribe from <nickname>
|
||||||
* **unsub <nickname>**: Same as leave
|
* **unsub <nickname>**: Same as leave
|
||||||
* **d <nickname> <text>**: Send direct message to <nickname> with message body <text>
|
* **d <nickname> <text>**: Send direct message to <nickname> with message body <text>
|
||||||
* **get <nickname>**: Get last notice from <nickname>
|
* **get <nickname>**: Get last notice from <nickname>
|
||||||
* **last <nickname>**: Same as 'get'
|
* **last <nickname>**: Same as 'get'
|
||||||
* **whois <nickname>**: Get Profile info on <nickname>
|
* **whois <nickname>**: Get Profile info on <nickname>
|
||||||
* **fav <nickname>**: Add user's last notice as a favorite
|
* **fav <nickname>**: Add user's last notice as a favorite
|
||||||
|
@ -376,7 +376,7 @@ function Auth_OpenID_detectMathLibrary($exts)
|
|||||||
// Try to load dynamic modules.
|
// Try to load dynamic modules.
|
||||||
if (!$loaded) {
|
if (!$loaded) {
|
||||||
foreach ($extension['modules'] as $module) {
|
foreach ($extension['modules'] as $module) {
|
||||||
if (@dl($module . "." . PHP_SHLIB_SUFFIX)) {
|
if (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode') && @dl($module . "." . PHP_SHLIB_SUFFIX)) {
|
||||||
$loaded = true;
|
$loaded = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ function &Auth_Yadis_getXMLParser()
|
|||||||
foreach ($extensions as $name => $params) {
|
foreach ($extensions as $name => $params) {
|
||||||
if (!extension_loaded($name)) {
|
if (!extension_loaded($name)) {
|
||||||
foreach ($params['libname'] as $libname) {
|
foreach ($params['libname'] as $libname) {
|
||||||
if (@dl($libname)) {
|
if (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode') && @dl($libname)) {
|
||||||
$classname = $params['classname'];
|
$classname = $params['classname'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ class OAuthRequest {/*{{{*/
|
|||||||
public function get_normalized_http_url() {/*{{{*/
|
public function get_normalized_http_url() {/*{{{*/
|
||||||
$parts = parse_url($this->http_url);
|
$parts = parse_url($this->http_url);
|
||||||
|
|
||||||
$port = @$parts['port'];
|
$port = isset($parts['port']) ? $parts['port'] : null;
|
||||||
$scheme = $parts['scheme'];
|
$scheme = $parts['scheme'];
|
||||||
$host = $parts['host'];
|
$host = $parts['host'];
|
||||||
$path = @$parts['path'];
|
$path = @$parts['path'];
|
||||||
|
@ -746,7 +746,7 @@ class PEAR
|
|||||||
{
|
{
|
||||||
if (!extension_loaded($ext)) {
|
if (!extension_loaded($ext)) {
|
||||||
// if either returns true dl() will produce a FATAL error, stop that
|
// if either returns true dl() will produce a FATAL error, stop that
|
||||||
if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
|
if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1) || !function_exists('dl')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (OS_WINDOWS) {
|
if (OS_WINDOWS) {
|
||||||
|
@ -49,7 +49,13 @@ function getPath($req)
|
|||||||
) {
|
) {
|
||||||
return $req['p'];
|
return $req['p'];
|
||||||
} else if (array_key_exists('PATH_INFO', $_SERVER)) {
|
} else if (array_key_exists('PATH_INFO', $_SERVER)) {
|
||||||
return $_SERVER['PATH_INFO'];
|
$path = $_SERVER['PATH_INFO'];
|
||||||
|
$script = $_SERVER['SCRIPT_NAME'];
|
||||||
|
if (substr($path, 0, mb_strlen($script)) == $script) {
|
||||||
|
return substr($path, mb_strlen($script));
|
||||||
|
} else {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
30
install.php
30
install.php
@ -244,7 +244,7 @@ function main()
|
|||||||
*/
|
*/
|
||||||
function haveExternalLibrary($external_library)
|
function haveExternalLibrary($external_library)
|
||||||
{
|
{
|
||||||
if (isset($external_library['include']) && ! @include_once $external_library['include'] ) {
|
if (isset($external_library['include']) && !haveIncludeFile($external_library['include'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isset($external_library['check_function']) && ! function_exists($external_library['check_function'])) {
|
if (isset($external_library['check_function']) && ! function_exists($external_library['check_function'])) {
|
||||||
@ -256,6 +256,15 @@ function haveExternalLibrary($external_library)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attempt to include a PHP file and report if it worked, while
|
||||||
|
// suppressing the annoying warning messages on failure.
|
||||||
|
function haveIncludeFile($filename) {
|
||||||
|
$old = error_reporting(error_reporting() & ~E_WARNING);
|
||||||
|
$ok = include_once($filename);
|
||||||
|
error_reporting($old);
|
||||||
|
return $ok;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if all is ready for installation
|
* Check if all is ready for installation
|
||||||
*
|
*
|
||||||
@ -328,12 +337,19 @@ function checkPrereqs()
|
|||||||
*/
|
*/
|
||||||
function checkExtension($name)
|
function checkExtension($name)
|
||||||
{
|
{
|
||||||
if (!extension_loaded($name)) {
|
if (extension_loaded($name)) {
|
||||||
if (!@dl($name.'.so')) {
|
return true;
|
||||||
return false;
|
} elseif (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode')) {
|
||||||
}
|
// dl will throw a fatal error if it's disabled or we're in safe mode.
|
||||||
|
// More fun, it may not even exist under some SAPIs in 5.3.0 or later...
|
||||||
|
$soname = $name . '.' . PHP_SHLIB_SUFFIX;
|
||||||
|
if (PHP_SHLIB_SUFFIX == 'dll') {
|
||||||
|
$soname = "php_" . $soname;
|
||||||
|
}
|
||||||
|
return @dl($soname);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -390,7 +406,7 @@ E_O_T;
|
|||||||
E_O_T;
|
E_O_T;
|
||||||
foreach ($present_libraries as $library) {
|
foreach ($present_libraries as $library) {
|
||||||
echo '<li>';
|
echo '<li>';
|
||||||
if ($library['url']) {
|
if (isset($library['url'])) {
|
||||||
echo '<a href=">'.$library['url'].'">'.htmlentities($library['name']).'</a>';
|
echo '<a href=">'.$library['url'].'">'.htmlentities($library['name']).'</a>';
|
||||||
} else {
|
} else {
|
||||||
echo htmlentities($library['name']);
|
echo htmlentities($library['name']);
|
||||||
|
@ -120,17 +120,14 @@ class Action extends HTMLOutputter // lawsuit
|
|||||||
{
|
{
|
||||||
// XXX: attributes (profile?)
|
// XXX: attributes (profile?)
|
||||||
$this->elementStart('head');
|
$this->elementStart('head');
|
||||||
if (Event::handle('StartHeadChildren', array($this))) {
|
$this->showTitle();
|
||||||
$this->showTitle();
|
$this->showShortcutIcon();
|
||||||
$this->showShortcutIcon();
|
$this->showStylesheets();
|
||||||
$this->showStylesheets();
|
$this->showScripts();
|
||||||
$this->showScripts();
|
$this->showOpenSearch();
|
||||||
$this->showOpenSearch();
|
$this->showFeeds();
|
||||||
$this->showFeeds();
|
$this->showDescription();
|
||||||
$this->showDescription();
|
$this->extraHead();
|
||||||
$this->extraHead();
|
|
||||||
Event::handle('EndHeadChildren', array($this));
|
|
||||||
}
|
|
||||||
$this->elementEnd('head');
|
$this->elementEnd('head');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -879,6 +876,7 @@ class Action extends HTMLOutputter // lawsuit
|
|||||||
*/
|
*/
|
||||||
function handle($argarray=null)
|
function handle($argarray=null)
|
||||||
{
|
{
|
||||||
|
header('Vary: Accept-Encoding,Cookie');
|
||||||
$lm = $this->lastModified();
|
$lm = $this->lastModified();
|
||||||
$etag = $this->etag();
|
$etag = $this->etag();
|
||||||
if ($etag) {
|
if ($etag) {
|
||||||
|
@ -325,7 +325,6 @@ class DesignSettingsAction extends AccountSettingsAction
|
|||||||
parent::showScripts();
|
parent::showScripts();
|
||||||
|
|
||||||
$this->script('js/farbtastic/farbtastic.js');
|
$this->script('js/farbtastic/farbtastic.js');
|
||||||
$this->script('js/farbtastic/farbtastic.go.js');
|
|
||||||
$this->script('js/userdesign.go.js');
|
$this->script('js/userdesign.go.js');
|
||||||
|
|
||||||
$this->autofocus('design_background-image_file');
|
$this->autofocus('design_background-image_file');
|
||||||
|
16
lib/mail.php
16
lib/mail.php
@ -551,9 +551,9 @@ function mail_notify_fave($other, $user, $notice)
|
|||||||
|
|
||||||
common_init_locale($other->language);
|
common_init_locale($other->language);
|
||||||
|
|
||||||
$subject = sprintf(_('%s added your notice as a favorite'), $bestname);
|
$subject = sprintf(_('%s (@%s) added your notice as a favorite'), $bestname, $user->nickname);
|
||||||
|
|
||||||
$body = sprintf(_("%1\$s just added your notice from %2\$s".
|
$body = sprintf(_("%1\$s (@%7\$s) just added your notice from %2\$s".
|
||||||
" as one of their favorites.\n\n" .
|
" as one of their favorites.\n\n" .
|
||||||
"The URL of your notice is:\n\n" .
|
"The URL of your notice is:\n\n" .
|
||||||
"%3\$s\n\n" .
|
"%3\$s\n\n" .
|
||||||
@ -570,7 +570,8 @@ function mail_notify_fave($other, $user, $notice)
|
|||||||
$notice->content,
|
$notice->content,
|
||||||
common_local_url('showfavorites',
|
common_local_url('showfavorites',
|
||||||
array('nickname' => $user->nickname)),
|
array('nickname' => $user->nickname)),
|
||||||
common_config('site', 'name'));
|
common_config('site', 'name'),
|
||||||
|
$user->nickname);
|
||||||
|
|
||||||
common_init_locale();
|
common_init_locale();
|
||||||
mail_to_user($other, $subject, $body);
|
mail_to_user($other, $subject, $body);
|
||||||
@ -607,9 +608,9 @@ function mail_notify_attn($user, $notice)
|
|||||||
$conversationUrl = null;
|
$conversationUrl = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$subject = sprintf(_('%s sent a notice to your attention'), $bestname);
|
$subject = sprintf(_('%s (@%s) sent a notice to your attention'), $bestname, $sender->nickname);
|
||||||
|
|
||||||
$body = sprintf(_("%1\$s just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
|
$body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
|
||||||
"The notice is here:\n\n".
|
"The notice is here:\n\n".
|
||||||
"\t%3\$s\n\n" .
|
"\t%3\$s\n\n" .
|
||||||
"It reads:\n\n".
|
"It reads:\n\n".
|
||||||
@ -629,10 +630,11 @@ function mail_notify_attn($user, $notice)
|
|||||||
$notice->content,//%4
|
$notice->content,//%4
|
||||||
$conversationUrl,//%5
|
$conversationUrl,//%5
|
||||||
common_local_url('newnotice',
|
common_local_url('newnotice',
|
||||||
array('replyto' => $sender->nickname)),//%6
|
array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6
|
||||||
common_local_url('replies',
|
common_local_url('replies',
|
||||||
array('nickname' => $user->nickname)),//%7
|
array('nickname' => $user->nickname)),//%7
|
||||||
common_local_url('emailsettings'));//%8
|
common_local_url('emailsettings'), //%8
|
||||||
|
$sender->nickname); //%9
|
||||||
|
|
||||||
common_init_locale();
|
common_init_locale();
|
||||||
mail_to_user($user, $subject, $body);
|
mail_to_user($user, $subject, $body);
|
||||||
|
@ -69,6 +69,12 @@ class NoticeForm extends Form
|
|||||||
|
|
||||||
var $user = null;
|
var $user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The notice being replied to
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $inreplyto = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -77,12 +83,13 @@ class NoticeForm extends Form
|
|||||||
* @param string $content content to pre-fill
|
* @param string $content content to pre-fill
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function __construct($out=null, $action=null, $content=null, $user=null)
|
function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto=null)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
|
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
|
$this->inreplyto = $inreplyto;
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
@ -168,7 +175,7 @@ class NoticeForm extends Form
|
|||||||
if ($this->action) {
|
if ($this->action) {
|
||||||
$this->out->hidden('notice_return-to', $this->action, 'returnto');
|
$this->out->hidden('notice_return-to', $this->action, 'returnto');
|
||||||
}
|
}
|
||||||
$this->out->hidden('notice_in-reply-to', $this->action, 'inreplyto');
|
$this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -261,7 +261,7 @@ class NoticeListItem extends Widget
|
|||||||
$attrs = array('href' => $this->profile->profileurl,
|
$attrs = array('href' => $this->profile->profileurl,
|
||||||
'class' => 'url');
|
'class' => 'url');
|
||||||
if (!empty($this->profile->fullname)) {
|
if (!empty($this->profile->fullname)) {
|
||||||
$attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ') ';
|
$attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
|
||||||
}
|
}
|
||||||
$this->out->elementStart('a', $attrs);
|
$this->out->elementStart('a', $attrs);
|
||||||
$this->showAvatar();
|
$this->showAvatar();
|
||||||
@ -418,9 +418,17 @@ class NoticeListItem extends Widget
|
|||||||
|
|
||||||
function showContext()
|
function showContext()
|
||||||
{
|
{
|
||||||
// XXX: also show context if there are replies to this notice
|
$hasConversation = false;
|
||||||
if (!empty($this->notice->conversation)
|
if( !empty($this->notice->conversation)
|
||||||
&& $this->notice->conversation != $this->notice->id) {
|
&& $this->notice->conversation != $this->notice->id){
|
||||||
|
$hasConversation = true;
|
||||||
|
}else{
|
||||||
|
$conversation = Notice::conversationStream($this->notice->id, 1, 1);
|
||||||
|
if($conversation->N > 0){
|
||||||
|
$hasConversation = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($hasConversation){
|
||||||
$convurl = common_local_url('conversation',
|
$convurl = common_local_url('conversation',
|
||||||
array('id' => $this->notice->conversation));
|
array('id' => $this->notice->conversation));
|
||||||
$this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id,
|
$this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id,
|
||||||
@ -442,7 +450,7 @@ class NoticeListItem extends Widget
|
|||||||
{
|
{
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
$reply_url = common_local_url('newnotice',
|
$reply_url = common_local_url('newnotice',
|
||||||
array('replyto' => $this->profile->nickname));
|
array('replyto' => $this->profile->nickname, 'inreplyto' => $this->notice->id));
|
||||||
$this->out->elementStart('a', array('href' => $reply_url,
|
$this->out->elementStart('a', array('href' => $reply_url,
|
||||||
'class' => 'notice_reply',
|
'class' => 'notice_reply',
|
||||||
'title' => _('Reply to this notice')));
|
'title' => _('Reply to this notice')));
|
||||||
|
@ -172,6 +172,10 @@ class Router
|
|||||||
$m->connect('notice/new?replyto=:replyto',
|
$m->connect('notice/new?replyto=:replyto',
|
||||||
array('action' => 'newnotice'),
|
array('action' => 'newnotice'),
|
||||||
array('replyto' => '[A-Za-z0-9_-]+'));
|
array('replyto' => '[A-Za-z0-9_-]+'));
|
||||||
|
$m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto',
|
||||||
|
array('action' => 'newnotice'),
|
||||||
|
array('replyto' => '[A-Za-z0-9_-]+'),
|
||||||
|
array('inreplyto' => '[0-9]+'));
|
||||||
|
|
||||||
$m->connect('notice/:notice/file',
|
$m->connect('notice/:notice/file',
|
||||||
array('action' => 'file'),
|
array('action' => 'file'),
|
||||||
|
@ -78,25 +78,12 @@ class Rss10Action extends Action
|
|||||||
function prepare($args)
|
function prepare($args)
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
$this->limit = (int) $this->trimmed('limit');
|
$this->limit = (int) $this->trimmed('limit');
|
||||||
|
|
||||||
if ($this->limit == 0) {
|
if ($this->limit == 0) {
|
||||||
$this->limit = DEFAULT_RSS_LIMIT;
|
$this->limit = DEFAULT_RSS_LIMIT;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle a request
|
|
||||||
*
|
|
||||||
* @param array $args Arguments from $_REQUEST
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
|
|
||||||
function handle($args)
|
|
||||||
{
|
|
||||||
// Parent handling, including cache check
|
|
||||||
parent::handle($args);
|
|
||||||
|
|
||||||
if (common_config('site', 'private')) {
|
if (common_config('site', 'private')) {
|
||||||
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
||||||
@ -122,8 +109,21 @@ class Rss10Action extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the list of notices
|
return true;
|
||||||
$this->notices = $this->getNotices($this->limit);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a request
|
||||||
|
*
|
||||||
|
* @param array $args Arguments from $_REQUEST
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function handle($args)
|
||||||
|
{
|
||||||
|
// Parent handling, including cache check
|
||||||
|
parent::handle($args);
|
||||||
$this->showRss();
|
$this->showRss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ class Rss10Action extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the notices to output in this stream
|
* Get the notices to output in this stream.
|
||||||
*
|
*
|
||||||
* @return array an array of Notice objects sorted in reverse chron
|
* @return array an array of Notice objects sorted in reverse chron
|
||||||
*/
|
*/
|
||||||
|
20
lib/util.php
20
lib/util.php
@ -391,10 +391,10 @@ function common_render_content($text, $notice)
|
|||||||
{
|
{
|
||||||
$r = common_render_text($text);
|
$r = common_render_text($text);
|
||||||
$id = $notice->profile_id;
|
$id = $notice->profile_id;
|
||||||
$r = preg_replace('/(^|\s+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
|
$r = preg_replace('/(^|[\s\.\,\:\;]+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
|
||||||
$r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r);
|
$r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r);
|
||||||
$r = preg_replace('/(^|\s+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r);
|
$r = preg_replace('/(^|[\s\.\,\:\;]+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r);
|
||||||
$r = preg_replace('/(^|\s)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r);
|
$r = preg_replace('/(^|[\s\.\,\:\;]+)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r);
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,9 +442,9 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) {
|
|||||||
')'.
|
')'.
|
||||||
'(?:'.
|
'(?:'.
|
||||||
'(?:\:\d+)?'. //:port
|
'(?:\:\d+)?'. //:port
|
||||||
'(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"]*)?'. // /path
|
'(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"@]*)?'. // /path
|
||||||
'(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\/]*)?'. // ?query string
|
'(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"@\/]*)?'. // ?query string
|
||||||
'(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\/\?\#]*)?'. // #fragment
|
'(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\@/\?\#]*)?'. // #fragment
|
||||||
')(?<![\?\.\,\#\,])'.
|
')(?<![\?\.\,\#\,])'.
|
||||||
')'.
|
')'.
|
||||||
'#ixu';
|
'#ixu';
|
||||||
@ -552,12 +552,13 @@ function common_linkify($url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($f)) {
|
if (!empty($f)) {
|
||||||
if (isset($f->filename)) {
|
if ($f->isEnclosure()) {
|
||||||
$is_attachment = true;
|
$is_attachment = true;
|
||||||
$attachment_id = $f->id;
|
$attachment_id = $f->id;
|
||||||
} else { // if it has OEmbed info, it's an attachment, too
|
} else {
|
||||||
$foe = File_oembed::staticGet('file_id', $f->id);
|
$foe = File_oembed::staticGet('file_id', $f->id);
|
||||||
if (!empty($foe)) {
|
if (!empty($foe)) {
|
||||||
|
// if it has OEmbed info, it's an attachment, too
|
||||||
$is_attachment = true;
|
$is_attachment = true;
|
||||||
$attachment_id = $f->id;
|
$attachment_id = $f->id;
|
||||||
|
|
||||||
@ -1393,9 +1394,6 @@ function common_shorten_url($long_url)
|
|||||||
$short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]);
|
$short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]);
|
||||||
$short_url = $short_url_service->shorten($long_url);
|
$short_url = $short_url_service->shorten($long_url);
|
||||||
|
|
||||||
if(substr($short_url,0,7)=='http://'){
|
|
||||||
$short_url = substr($short_url,7);
|
|
||||||
}
|
|
||||||
return $short_url;
|
return $short_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,38 +1,37 @@
|
|||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$.getJSON($('address .url')[0].href+'/api/statuses/friends.json?user_id=' + current_user['id'] + '&lite=true&callback=?',
|
$('#notice_data-text').autocomplete($('address .url')[0].href+'/plugins/Autocomplete/autocomplete.json', {
|
||||||
function(friends){
|
|
||||||
$('#notice_data-text').autocomplete(friends, {
|
|
||||||
multiple: true,
|
multiple: true,
|
||||||
multipleSeparator: " ",
|
multipleSeparator: " ",
|
||||||
minChars: 1,
|
minChars: 1,
|
||||||
formatItem: function(row, i, max){
|
formatItem: function(row, i, max){
|
||||||
return '@' + row.screen_name + ' (' + row.name + ')';
|
row = eval("(" + row + ")");
|
||||||
|
switch(row.type)
|
||||||
|
{
|
||||||
|
case 'user':
|
||||||
|
return row.nickname + ' (' + row.fullname + ')';
|
||||||
|
case 'group':
|
||||||
|
return row.nickname + ' (' + row.fullname + ')';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
formatMatch: function(row, i, max){
|
formatMatch: function(row, i, max){
|
||||||
return '@' + row.screen_name;
|
row = eval("(" + row + ")");
|
||||||
|
switch(row.type)
|
||||||
|
{
|
||||||
|
case 'user':
|
||||||
|
return row.nickname;
|
||||||
|
case 'group':
|
||||||
|
return row.nickname;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
formatResult: function(row){
|
formatResult: function(row){
|
||||||
return '@' + row.screen_name;
|
row = eval("(" + row + ")");
|
||||||
|
switch(row.type)
|
||||||
|
{
|
||||||
|
case 'user':
|
||||||
|
return '@' + row.nickname;
|
||||||
|
case 'group':
|
||||||
|
return '!' + row.nickname;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
$.getJSON($('address .url')[0].href+'/api/statusnet/groups/list.json?user_id=' + current_user['id'] + '&callback=?',
|
|
||||||
function(groups){
|
|
||||||
$('#notice_data-text').autocomplete(groups, {
|
|
||||||
multiple: true,
|
|
||||||
multipleSeparator: " ",
|
|
||||||
minChars: 1,
|
|
||||||
formatItem: function(row, i, max){
|
|
||||||
return '!' + row.nickname + ' (' + row.fullname + ')';
|
|
||||||
},
|
|
||||||
formatMatch: function(row, i, max){
|
|
||||||
return '!' + row.nickname;
|
|
||||||
},
|
|
||||||
formatResult: function(row){
|
|
||||||
return '!' + row.nickname;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
@ -31,6 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_once(INSTALLDIR.'/plugins/Autocomplete/autocomplete.php');
|
||||||
|
|
||||||
class AutocompletePlugin extends Plugin
|
class AutocompletePlugin extends Plugin
|
||||||
{
|
{
|
||||||
function __construct()
|
function __construct()
|
||||||
@ -40,13 +42,6 @@ class AutocompletePlugin extends Plugin
|
|||||||
|
|
||||||
function onEndShowScripts($action){
|
function onEndShowScripts($action){
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
$current_user = common_current_user();
|
|
||||||
$js_string = <<<EOT
|
|
||||||
<script type="text/javascript">
|
|
||||||
var current_user = { id: '$current_user->id' };
|
|
||||||
</script>
|
|
||||||
EOT;
|
|
||||||
$action->raw($js_string);
|
|
||||||
$action->script('plugins/Autocomplete/jquery-autocomplete/jquery.autocomplete.pack.js');
|
$action->script('plugins/Autocomplete/jquery-autocomplete/jquery.autocomplete.pack.js');
|
||||||
$action->script('plugins/Autocomplete/Autocomplete.js');
|
$action->script('plugins/Autocomplete/Autocomplete.js');
|
||||||
}
|
}
|
||||||
@ -59,5 +54,12 @@ EOT;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onRouterInitialized($m)
|
||||||
|
{
|
||||||
|
if (common_logged_in()) {
|
||||||
|
$m->connect('plugins/Autocomplete/autocomplete.json', array('action'=>'autocomplete'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
136
plugins/Autocomplete/autocomplete.php
Normal file
136
plugins/Autocomplete/autocomplete.php
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* List users for autocompletion
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* LICENCE: 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/>.
|
||||||
|
*
|
||||||
|
* @category Plugin
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Craig Andrews <candrews@integralblue.com>
|
||||||
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List users for autocompletion
|
||||||
|
*
|
||||||
|
* This is the form for adding a new g
|
||||||
|
*
|
||||||
|
* @category Plugin
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Craig Andrews <candrews@integralblue.com>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AutocompleteAction extends Action
|
||||||
|
{
|
||||||
|
private $result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last-modified date for page
|
||||||
|
*
|
||||||
|
* When was the content of this page last modified? Based on notice,
|
||||||
|
* profile, avatar.
|
||||||
|
*
|
||||||
|
* @return int last-modified date as unix timestamp
|
||||||
|
*/
|
||||||
|
function lastModified()
|
||||||
|
{
|
||||||
|
$max=0;
|
||||||
|
foreach($this->users as $user){
|
||||||
|
$max = max($max,strtotime($user->modified),strtotime($user->profile->modified));
|
||||||
|
}
|
||||||
|
foreach($this->groups as $group){
|
||||||
|
$max = max($max,strtotime($group->modified));
|
||||||
|
}
|
||||||
|
return $max;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An entity tag for this page
|
||||||
|
*
|
||||||
|
* Shows the ETag for the page, based on the notice ID and timestamps
|
||||||
|
* for the notice, profile, and avatar. It's weak, since we change
|
||||||
|
* the date text "one hour ago", etc.
|
||||||
|
*
|
||||||
|
* @return string etag
|
||||||
|
*/
|
||||||
|
function etag()
|
||||||
|
{
|
||||||
|
return '"' . implode(':', array($this->arg('action'),
|
||||||
|
crc32($this->arg('q')), //the actual string can have funny characters in we don't want showing up in the etag
|
||||||
|
$this->arg('limit'),
|
||||||
|
$this->lastModified())) . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepare($args)
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
$this->groups=array();
|
||||||
|
$this->users=array();
|
||||||
|
$q = $this->arg('q');
|
||||||
|
$limit = $this->arg('limit');
|
||||||
|
if($limit > 200) $limit=200; //prevent DOS attacks
|
||||||
|
if(substr($q,0,1)=='@'){
|
||||||
|
//user search
|
||||||
|
$q=substr($q,1);
|
||||||
|
$user = new User();
|
||||||
|
$user->limit($limit);
|
||||||
|
$user->whereAdd('nickname like \'' . trim($user->escape($q), '\'') . '%\'');
|
||||||
|
$user->find();
|
||||||
|
while($user->fetch()) {
|
||||||
|
$profile = Profile::staticGet($user->id);
|
||||||
|
$user->profile=$profile;
|
||||||
|
$this->users[]=$user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(substr($q,0,1)=='!'){
|
||||||
|
//group search
|
||||||
|
$q=substr($q,1);
|
||||||
|
$group = new User_group();
|
||||||
|
$group->limit($limit);
|
||||||
|
$group->whereAdd('nickname like \'' . trim($group->escape($q), '\'') . '%\'');
|
||||||
|
$group->find();
|
||||||
|
while($group->fetch()) {
|
||||||
|
$this->groups[]=$group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle($args)
|
||||||
|
{
|
||||||
|
parent::handle($args);
|
||||||
|
$results = array();
|
||||||
|
foreach($this->users as $user){
|
||||||
|
$results[]=array('nickname' => $user->nickname, 'fullname'=> $user->profile->fullname, 'type'=>'user');
|
||||||
|
}
|
||||||
|
foreach($this->groups as $group){
|
||||||
|
$results[]=array('nickname' => $group->nickname, 'fullname'=> $group->fullname, 'type'=>'group');
|
||||||
|
}
|
||||||
|
foreach($results as $result) {
|
||||||
|
print json_encode($result) . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
Autocomplete allows users to autocomplete screen names in @ replies. When an "@" is typed into the notice text area, an autocomplete box is displayed populated with the user's friends' screen names.
|
Autocomplete allows users to autocomplete screen names in @ replies. When an "@" is typed into the notice text area, an autocomplete box is displayed populated with the user's friends' screen names.
|
||||||
|
|
||||||
|
Note: This plugin doesn't work if the site is in Private mode, i.e. when $config['site']['private'] is set to true.
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
Add "addPlugin('Autocomplete');" to the bottom of your config.php
|
Add "addPlugin('Autocomplete');" to the bottom of your config.php
|
||||||
|
@ -40,7 +40,7 @@ class InfiniteScrollPlugin extends Plugin
|
|||||||
|
|
||||||
function onEndShowScripts($action)
|
function onEndShowScripts($action)
|
||||||
{
|
{
|
||||||
$action->script('plugins/InfiniteScroll/jquery.infinitescroll.min.js');
|
$action->script('plugins/InfiniteScroll/jquery.infinitescroll.js');
|
||||||
$action->script('plugins/InfiniteScroll/infinitescroll.js');
|
$action->script('plugins/InfiniteScroll/infinitescroll.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
jQuery(document).ready(function($){
|
jQuery(document).ready(function($){
|
||||||
$('notices_primary').infinitescroll({
|
$('notices_primary').infinitescroll({
|
||||||
debug: true,
|
debug: true,
|
||||||
|
infiniteScroll : false,
|
||||||
nextSelector : "li.nav_next a",
|
nextSelector : "li.nav_next a",
|
||||||
loadingImg : $('address .url')[0].href+'plugins/InfiniteScroll/ajax-loader.gif',
|
loadingImg : $('address .url')[0].href+'plugins/InfiniteScroll/ajax-loader.gif',
|
||||||
text : "<em>Loading the next set of posts...</em>",
|
text : "<em>Loading the next set of posts...</em>",
|
||||||
@ -12,4 +13,3 @@ jQuery(document).ready(function($){
|
|||||||
NoticeAttachments();
|
NoticeAttachments();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -92,14 +92,14 @@
|
|||||||
|
|
||||||
if (props.isDuringAjax || props.isInvalidPage || props.isDone) return;
|
if (props.isDuringAjax || props.isInvalidPage || props.isDone) return;
|
||||||
|
|
||||||
if ( !isNearBottom(opts,props) ) return;
|
if ( opts.infiniteScroll && !isNearBottom(opts,props) ) return;
|
||||||
|
|
||||||
// we dont want to fire the ajax multiple times
|
// we dont want to fire the ajax multiple times
|
||||||
props.isDuringAjax = true;
|
props.isDuringAjax = true;
|
||||||
|
|
||||||
// show the loading message and hide the previous/next links
|
// show the loading message and hide the previous/next links
|
||||||
props.loadingMsg.appendTo( opts.contentSelector ).show();
|
props.loadingMsg.appendTo( opts.contentSelector ).show();
|
||||||
$( opts.navSelector ).hide();
|
if(opts.infiniteScroll) $( opts.navSelector ).hide();
|
||||||
|
|
||||||
// increment the URL bit. e.g. /page/3/
|
// increment the URL bit. e.g. /page/3/
|
||||||
props.currPage++;
|
props.currPage++;
|
||||||
@ -205,10 +205,19 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// bind scroll handler to element (if its a local scroll) or window
|
if(opts.infiniteScroll){
|
||||||
$(opts.localMode ? this : window)
|
// bind scroll handler to element (if its a local scroll) or window
|
||||||
.bind('scroll.infscr', function(){ infscrSetup(path,opts,props,callback); } )
|
$(opts.localMode ? this : window)
|
||||||
.trigger('scroll.infscr'); // trigger the event, in case it's a short page
|
.bind('scroll.infscr', function(){ infscrSetup(path,opts,props,callback); } )
|
||||||
|
.trigger('scroll.infscr'); // trigger the event, in case it's a short page
|
||||||
|
}else{
|
||||||
|
$(opts.nextSelector).click(
|
||||||
|
function(){
|
||||||
|
infscrSetup(path,opts,props,callback);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@ -222,6 +231,7 @@
|
|||||||
$.infinitescroll = {
|
$.infinitescroll = {
|
||||||
defaults : {
|
defaults : {
|
||||||
debug : false,
|
debug : false,
|
||||||
|
infiniteScroll : true,
|
||||||
preload : false,
|
preload : false,
|
||||||
nextSelector : "div.navigation a:first",
|
nextSelector : "div.navigation a:first",
|
||||||
loadingImg : "http://www.infinite-scroll.com/loading.gif",
|
loadingImg : "http://www.infinite-scroll.com/loading.gif",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// update the local timeline from a Meteor server
|
// Update the local timeline from a Meteor server
|
||||||
//
|
// XXX: If @a is subscribed to @b, @a should get @b's notices in @a's Personal timeline.
|
||||||
|
// Do Replies timeline.
|
||||||
|
|
||||||
var MeteorUpdater = function()
|
var MeteorUpdater = function()
|
||||||
{
|
{
|
||||||
|
@ -59,9 +59,9 @@ if (!defined('STATUSNET')) {
|
|||||||
class PiwikAnalyticsPlugin extends Plugin
|
class PiwikAnalyticsPlugin extends Plugin
|
||||||
{
|
{
|
||||||
/** the base of your Piwik installation */
|
/** the base of your Piwik installation */
|
||||||
var $piwikroot = null;
|
public $piwikroot = null;
|
||||||
/** the Piwik Id of your statusnet installation */
|
/** the Piwik Id of your statusnet installation */
|
||||||
var $piwikId = null;
|
public $piwikId = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
@ -73,7 +73,7 @@ class PiwikAnalyticsPlugin extends Plugin
|
|||||||
function __construct($root=null, $id=null)
|
function __construct($root=null, $id=null)
|
||||||
{
|
{
|
||||||
$this->piwikroot = $root;
|
$this->piwikroot = $root;
|
||||||
$this->piwikid = $id;
|
$this->piwikId = $id;
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/ja
|
|||||||
</script>
|
</script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
try {
|
try {
|
||||||
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 4);
|
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {$this->piwikId});
|
||||||
piwikTracker.trackPageView();
|
piwikTracker.trackPageView();
|
||||||
piwikTracker.enableLinkTracking();
|
piwikTracker.enableLinkTracking();
|
||||||
} catch( err ) {}
|
} catch( err ) {}
|
||||||
@ -108,4 +108,4 @@ ENDOFPIWIK;
|
|||||||
$action->raw($piwikCode);
|
$action->raw($piwikCode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,11 @@ class RealtimePlugin extends Plugin
|
|||||||
protected $favorurl = null;
|
protected $favorurl = null;
|
||||||
protected $deleteurl = null;
|
protected $deleteurl = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When it's time to initialize the plugin, calculate and
|
||||||
|
* pass the URLs we need.
|
||||||
|
*/
|
||||||
|
|
||||||
function onInitializePlugin()
|
function onInitializePlugin()
|
||||||
{
|
{
|
||||||
$this->replyurl = common_local_url('newnotice');
|
$this->replyurl = common_local_url('newnotice');
|
||||||
@ -57,29 +62,26 @@ class RealtimePlugin extends Plugin
|
|||||||
// FIXME: need to find a better way to pass this pattern in
|
// FIXME: need to find a better way to pass this pattern in
|
||||||
$this->deleteurl = common_local_url('deletenotice',
|
$this->deleteurl = common_local_url('deletenotice',
|
||||||
array('notice' => '0000000000'));
|
array('notice' => '0000000000'));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndShowScripts($action)
|
function onEndShowScripts($action)
|
||||||
{
|
{
|
||||||
$path = null;
|
$timeline = $this->_getTimeline($action);
|
||||||
|
|
||||||
switch ($action->trimmed('action')) {
|
// If there's not a timeline on this page,
|
||||||
case 'public':
|
// just return true
|
||||||
$path = array('public');
|
|
||||||
break;
|
if (empty($timeline)) {
|
||||||
case 'tag':
|
|
||||||
$tag = $action->trimmed('tag');
|
|
||||||
if (!empty($tag)) {
|
|
||||||
$path = array('tag', $tag);
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$timeline = $this->_pathToChannel($path);
|
$base = $action->selfUrl();
|
||||||
|
if (mb_strstr($base, '?')) {
|
||||||
|
$url = $base . '&realtime=1';
|
||||||
|
} else {
|
||||||
|
$url = $base . '?realtime=1';
|
||||||
|
}
|
||||||
|
|
||||||
$scripts = $this->_getScripts();
|
$scripts = $this->_getScripts();
|
||||||
|
|
||||||
@ -95,10 +97,22 @@ class RealtimePlugin extends Plugin
|
|||||||
$user_id = 0;
|
$user_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action->boolean('realtime')) {
|
||||||
|
$realtimeUI = ' RealtimeUpdate.initPopupWindow();';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$iconurl = common_path('plugins/Realtime/icon_external.gif');
|
||||||
|
$realtimeUI = ' RealtimeUpdate.addPopup("'.$url.'", "'.$timeline.'", "'. $iconurl .'");';
|
||||||
|
}
|
||||||
|
|
||||||
$action->elementStart('script', array('type' => 'text/javascript'));
|
$action->elementStart('script', array('type' => 'text/javascript'));
|
||||||
$action->raw("$(document).ready(function() { ");
|
|
||||||
$action->raw($this->_updateInitialize($timeline, $user_id));
|
$script = ' $(document).ready(function() { '.
|
||||||
$action->raw(" });");
|
$realtimeUI.
|
||||||
|
$this->_updateInitialize($timeline, $user_id).
|
||||||
|
'}); ';
|
||||||
|
$action->raw($script);
|
||||||
|
|
||||||
$action->elementEnd('script');
|
$action->elementEnd('script');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -108,13 +122,23 @@ class RealtimePlugin extends Plugin
|
|||||||
{
|
{
|
||||||
$paths = array();
|
$paths = array();
|
||||||
|
|
||||||
// XXX: Add other timelines; this is just for the public one
|
// Add to the author's timeline
|
||||||
|
|
||||||
|
$user = User::staticGet('id', $notice->profile_id);
|
||||||
|
|
||||||
|
if (!empty($user)) {
|
||||||
|
$paths[] = array('showstream', $user->nickname);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add to the public timeline
|
||||||
|
|
||||||
if ($notice->is_local ||
|
if ($notice->is_local ||
|
||||||
($notice->is_local == 0 && !common_config('public', 'localonly'))) {
|
($notice->is_local == 0 && !common_config('public', 'localonly'))) {
|
||||||
$paths[] = array('public');
|
$paths[] = array('public');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add to the tags timeline
|
||||||
|
|
||||||
$tags = $this->getNoticeTags($notice);
|
$tags = $this->getNoticeTags($notice);
|
||||||
|
|
||||||
if (!empty($tags)) {
|
if (!empty($tags)) {
|
||||||
@ -123,6 +147,46 @@ class RealtimePlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add to inbox timelines
|
||||||
|
// XXX: do a join
|
||||||
|
|
||||||
|
$inbox = new Notice_inbox();
|
||||||
|
$inbox->notice_id = $notice->id;
|
||||||
|
|
||||||
|
if ($inbox->find()) {
|
||||||
|
while ($inbox->fetch()) {
|
||||||
|
$user = User::staticGet('id', $inbox->user_id);
|
||||||
|
$paths[] = array('all', $user->nickname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add to the replies timeline
|
||||||
|
|
||||||
|
$reply = new Reply();
|
||||||
|
$reply->notice_id = $notice->id;
|
||||||
|
|
||||||
|
if ($reply->find()) {
|
||||||
|
while ($reply->fetch()) {
|
||||||
|
$user = User::staticGet('id', $reply->profile_id);
|
||||||
|
if (!empty($user)) {
|
||||||
|
$paths[] = array('replies', $user->nickname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add to the group timeline
|
||||||
|
// XXX: join
|
||||||
|
|
||||||
|
$gi = new Group_inbox();
|
||||||
|
$gi->notice_id = $notice->id;
|
||||||
|
|
||||||
|
if ($gi->find()) {
|
||||||
|
while ($gi->fetch()) {
|
||||||
|
$ug = User_group::staticGet('id', $gi->group_id);
|
||||||
|
$paths[] = array('showgroup', $ug->nickname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (count($paths) > 0) {
|
if (count($paths) > 0) {
|
||||||
|
|
||||||
$json = $this->noticeAsJson($notice);
|
$json = $this->noticeAsJson($notice);
|
||||||
@ -140,6 +204,39 @@ class RealtimePlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onStartShowBody($action)
|
||||||
|
{
|
||||||
|
$realtime = $action->boolean('realtime');
|
||||||
|
if (!$realtime) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$action->elementStart('body',
|
||||||
|
(common_current_user()) ? array('id' => $action->trimmed('action'),
|
||||||
|
'class' => 'user_in')
|
||||||
|
: array('id' => $action->trimmed('action')));
|
||||||
|
|
||||||
|
$action->elementStart('div', array('id' => 'header'));
|
||||||
|
|
||||||
|
// XXX hack to deal with JS that tries to get the
|
||||||
|
// root url from page output
|
||||||
|
|
||||||
|
$action->elementStart('address');
|
||||||
|
$action->element('a', array('class' => 'url',
|
||||||
|
'href' => common_local_url('public')),
|
||||||
|
'');
|
||||||
|
$action->elementEnd('address');
|
||||||
|
|
||||||
|
if (common_logged_in()) {
|
||||||
|
$action->showNoticeForm();
|
||||||
|
}
|
||||||
|
$action->elementEnd('div');
|
||||||
|
|
||||||
|
$action->showContentBlock();
|
||||||
|
$action->elementEnd('body');
|
||||||
|
return false; // No default processing
|
||||||
|
}
|
||||||
|
|
||||||
function noticeAsJson($notice)
|
function noticeAsJson($notice)
|
||||||
{
|
{
|
||||||
// FIXME: this code should be abstracted to a neutral third
|
// FIXME: this code should be abstracted to a neutral third
|
||||||
@ -224,4 +321,41 @@ class RealtimePlugin extends Plugin
|
|||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _getTimeline($action)
|
||||||
|
{
|
||||||
|
$path = null;
|
||||||
|
$timeline = null;
|
||||||
|
|
||||||
|
$action_name = $action->trimmed('action');
|
||||||
|
|
||||||
|
switch ($action_name) {
|
||||||
|
case 'public':
|
||||||
|
$path = array('public');
|
||||||
|
break;
|
||||||
|
case 'tag':
|
||||||
|
$tag = $action->trimmed('tag');
|
||||||
|
if (!empty($tag)) {
|
||||||
|
$path = array('tag', $tag);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'showstream':
|
||||||
|
case 'all':
|
||||||
|
case 'replies':
|
||||||
|
case 'showgroup':
|
||||||
|
$nickname = common_canonical_nickname($action->trimmed('nickname'));
|
||||||
|
if (!empty($nickname)) {
|
||||||
|
$path = array($action_name, $nickname);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($path)) {
|
||||||
|
$timeline = $this->_pathToChannel($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $timeline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
plugins/Realtime/icon_external.gif
Normal file
BIN
plugins/Realtime/icon_external.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 B |
72
plugins/Realtime/jquery.getUrlParam.js
Normal file
72
plugins/Realtime/jquery.getUrlParam.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/* Copyright (c) 2006-2007 Mathias Bank (http://www.mathias-bank.de)
|
||||||
|
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||||
|
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||||
|
*
|
||||||
|
* Version 2.1
|
||||||
|
*
|
||||||
|
* Thanks to
|
||||||
|
* Hinnerk Ruemenapf - http://hinnerk.ruemenapf.de/ for bug reporting and fixing.
|
||||||
|
* Tom Leonard for some improvements
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
jQuery.fn.extend({
|
||||||
|
/**
|
||||||
|
* Returns get parameters.
|
||||||
|
*
|
||||||
|
* If the desired param does not exist, null will be returned
|
||||||
|
*
|
||||||
|
* To get the document params:
|
||||||
|
* @example value = $(document).getUrlParam("paramName");
|
||||||
|
*
|
||||||
|
* To get the params of a html-attribut (uses src attribute)
|
||||||
|
* @example value = $('#imgLink').getUrlParam("paramName");
|
||||||
|
*/
|
||||||
|
getUrlParam: function(strParamName){
|
||||||
|
strParamName = escape(unescape(strParamName));
|
||||||
|
|
||||||
|
var returnVal = new Array();
|
||||||
|
var qString = null;
|
||||||
|
|
||||||
|
if ($(this).attr("nodeName")=="#document") {
|
||||||
|
//document-handler
|
||||||
|
|
||||||
|
if (window.location.search.search(strParamName) > -1 ){
|
||||||
|
|
||||||
|
qString = window.location.search.substr(1,window.location.search.length).split("&");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ($(this).attr("src")!="undefined") {
|
||||||
|
|
||||||
|
var strHref = $(this).attr("src")
|
||||||
|
if ( strHref.indexOf("?") > -1 ){
|
||||||
|
var strQueryString = strHref.substr(strHref.indexOf("?")+1);
|
||||||
|
qString = strQueryString.split("&");
|
||||||
|
}
|
||||||
|
} else if ($(this).attr("href")!="undefined") {
|
||||||
|
|
||||||
|
var strHref = $(this).attr("href")
|
||||||
|
if ( strHref.indexOf("?") > -1 ){
|
||||||
|
var strQueryString = strHref.substr(strHref.indexOf("?")+1);
|
||||||
|
qString = strQueryString.split("&");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (qString==null) return null;
|
||||||
|
|
||||||
|
|
||||||
|
for (var i=0;i<qString.length; i++){
|
||||||
|
if (escape(unescape(qString[i].split("=")[0])) == strParamName){
|
||||||
|
returnVal.push(qString[i].split("=")[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (returnVal.length==0) return null;
|
||||||
|
else if (returnVal.length==1) return returnVal[0];
|
||||||
|
else return returnVal;
|
||||||
|
}
|
||||||
|
});
|
@ -1,8 +1,8 @@
|
|||||||
// add a notice encoded as JSON into the current timeline
|
// add a notice encoded as JSON into the current timeline
|
||||||
//
|
//
|
||||||
|
// TODO: i18n
|
||||||
|
|
||||||
RealtimeUpdate = {
|
RealtimeUpdate = {
|
||||||
|
|
||||||
_userid: 0,
|
_userid: 0,
|
||||||
_replyurl: '',
|
_replyurl: '',
|
||||||
_favorurl: '',
|
_favorurl: '',
|
||||||
@ -10,10 +10,10 @@ RealtimeUpdate = {
|
|||||||
|
|
||||||
init: function(userid, replyurl, favorurl, deleteurl)
|
init: function(userid, replyurl, favorurl, deleteurl)
|
||||||
{
|
{
|
||||||
RealtimeUpdate._userid = userid;
|
RealtimeUpdate._userid = userid;
|
||||||
RealtimeUpdate._replyurl = replyurl;
|
RealtimeUpdate._replyurl = replyurl;
|
||||||
RealtimeUpdate._favorurl = favorurl;
|
RealtimeUpdate._favorurl = favorurl;
|
||||||
RealtimeUpdate._deleteurl = deleteurl;
|
RealtimeUpdate._deleteurl = deleteurl;
|
||||||
},
|
},
|
||||||
|
|
||||||
receive: function(data)
|
receive: function(data)
|
||||||
@ -21,7 +21,7 @@ RealtimeUpdate = {
|
|||||||
id = data.id;
|
id = data.id;
|
||||||
|
|
||||||
// Don't add it if it already exists
|
// Don't add it if it already exists
|
||||||
|
//
|
||||||
if ($("#notice-"+id).length > 0) {
|
if ($("#notice-"+id).length > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -50,30 +50,19 @@ RealtimeUpdate = {
|
|||||||
"<p class=\"entry-content\">"+html+"</p>"+
|
"<p class=\"entry-content\">"+html+"</p>"+
|
||||||
"</div>"+
|
"</div>"+
|
||||||
"<div class=\"entry-content\">"+
|
"<div class=\"entry-content\">"+
|
||||||
"<dl class=\"timestamp\">"+
|
"<a class=\"timestamp\" rel=\"bookmark\" href=\""+data['url']+"\" >"+
|
||||||
"<dt>Published</dt>"+
|
|
||||||
"<dd>"+
|
|
||||||
"<a rel=\"bookmark\" href=\""+data['url']+"\" >"+
|
|
||||||
"<abbr class=\"published\" title=\""+data['created_at']+"\">a few seconds ago</abbr>"+
|
"<abbr class=\"published\" title=\""+data['created_at']+"\">a few seconds ago</abbr>"+
|
||||||
"</a> "+
|
"</a> "+
|
||||||
"</dd>"+
|
"<span class=\"source\">"+
|
||||||
"</dl>"+
|
"from "+
|
||||||
"<dl class=\"device\">"+
|
"<span class=\"device\">"+source+"</span>"+ // may have a link
|
||||||
"<dt>From</dt> "+
|
"</span>";
|
||||||
"<dd>"+source+"</dd>"+ // may have a link, I think
|
|
||||||
"</dl>";
|
|
||||||
|
|
||||||
if (data['in_reply_to_status_id']) {
|
if (data['in_reply_to_status_id']) {
|
||||||
ni = ni+" <dl class=\"response\">"+
|
ni = ni+" <a class=\"response\" href=\""+data['in_reply_to_status_url']+"\">in context</a>";
|
||||||
"<dt>To</dt>"+
|
|
||||||
"<dd>"+
|
|
||||||
"<a href=\""+data['in_reply_to_status_url']+"\" rel=\"in-reply-to\">in reply to</a>"+
|
|
||||||
"</dd>"+
|
|
||||||
"</dl>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ni = ni+"</div>"+
|
ni = ni+"</div>"+
|
||||||
"<div class=\"notice-options\">";
|
"<div class=\"notice-options\">";
|
||||||
|
|
||||||
if (RealtimeUpdate._userid != 0) {
|
if (RealtimeUpdate._userid != 0) {
|
||||||
var input = $("form#form_notice fieldset input#token");
|
var input = $("form#form_notice fieldset input#token");
|
||||||
@ -95,12 +84,12 @@ RealtimeUpdate = {
|
|||||||
var ff;
|
var ff;
|
||||||
|
|
||||||
ff = "<form id=\"favor-"+id+"\" class=\"form_favor\" method=\"post\" action=\""+RealtimeUpdate._favorurl+"\">"+
|
ff = "<form id=\"favor-"+id+"\" class=\"form_favor\" method=\"post\" action=\""+RealtimeUpdate._favorurl+"\">"+
|
||||||
"<fieldset>"+
|
"<fieldset>"+
|
||||||
"<legend>Favor this notice</legend>"+ // XXX: i18n
|
"<legend>Favor this notice</legend>"+
|
||||||
"<input name=\"token-"+id+"\" type=\"hidden\" id=\"token-"+id+"\" value=\""+session_key+"\"/>"+
|
"<input name=\"token-"+id+"\" type=\"hidden\" id=\"token-"+id+"\" value=\""+session_key+"\"/>"+
|
||||||
"<input name=\"notice\" type=\"hidden\" id=\"notice-n"+id+"\" value=\""+id+"\"/>"+
|
"<input name=\"notice\" type=\"hidden\" id=\"notice-n"+id+"\" value=\""+id+"\"/>"+
|
||||||
"<input type=\"submit\" id=\"favor-submit-"+id+"\" name=\"favor-submit-"+id+"\" class=\"submit\" value=\"Favor\" title=\"Favor this notice\"/>"+
|
"<input type=\"submit\" id=\"favor-submit-"+id+"\" name=\"favor-submit-"+id+"\" class=\"submit\" value=\"Favor\" title=\"Favor this notice\"/>"+
|
||||||
"</fieldset>"+
|
"</fieldset>"+
|
||||||
"</form>";
|
"</form>";
|
||||||
return ff;
|
return ff;
|
||||||
},
|
},
|
||||||
@ -108,28 +97,51 @@ RealtimeUpdate = {
|
|||||||
makeReplyLink: function(id, nickname)
|
makeReplyLink: function(id, nickname)
|
||||||
{
|
{
|
||||||
var rl;
|
var rl;
|
||||||
rl = "<dl class=\"notice_reply\">"+
|
rl = "<a class=\"notice_reply\" href=\""+RealtimeUpdate._replyurl+"?replyto="+nickname+"\" title=\"Reply to this notice\">Reply <span class=\"notice_id\">"+id+"</span></a>";
|
||||||
"<dt>Reply to this notice</dt>"+
|
|
||||||
"<dd>"+
|
|
||||||
"<a href=\""+RealtimeUpdate._replyurl+"?replyto="+nickname+"\" title=\"Reply to this notice\">Reply <span class=\"notice_id\">"+id+"</span>"+
|
|
||||||
"</a>"+
|
|
||||||
"</dd>"+
|
|
||||||
"</dl>";
|
|
||||||
return rl;
|
return rl;
|
||||||
},
|
},
|
||||||
|
|
||||||
makeDeleteLink: function(id)
|
makeDeleteLink: function(id)
|
||||||
{
|
{
|
||||||
var dl, delurl;
|
var dl, delurl;
|
||||||
delurl = RealtimeUpdate._deleteurl.replace("0000000000", id);
|
delurl = RealtimeUpdate._deleteurl.replace("0000000000", id);
|
||||||
|
|
||||||
dl = "<dl class=\"notice_delete\">"+
|
dl = "<a class=\"notice_delete\" href=\""+delurl+"\" title=\"Delete this notice\">Delete</a>";
|
||||||
"<dt>Delete this notice</dt>"+
|
|
||||||
"<dd>"+
|
|
||||||
"<a href=\""+delurl+"\" title=\"Delete this notice\">Delete</a>"+
|
|
||||||
"</dd>"+
|
|
||||||
"</dl>";
|
|
||||||
|
|
||||||
return dl;
|
return dl;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addPopup: function(url, timeline, iconurl)
|
||||||
|
{
|
||||||
|
$('#site_nav_local_views .current a').append('<button id="realtime_timeline" title="Real-time pop window">↗</button>');
|
||||||
|
|
||||||
|
$('#realtime_timeline').css({
|
||||||
|
'margin':'2px 0 0 11px',
|
||||||
|
'background':'transparent url('+ iconurl + ') no-repeat 45% 45%',
|
||||||
|
'text-indent':'-9999px',
|
||||||
|
'width':'16px',
|
||||||
|
'height':'16px',
|
||||||
|
'padding':'0',
|
||||||
|
'display':'block',
|
||||||
|
'float':'right',
|
||||||
|
'border':'none',
|
||||||
|
'cursor':'pointer'
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#realtime_timeline').click(function() {
|
||||||
|
window.open(url,
|
||||||
|
timeline,
|
||||||
|
'toolbar=no,resizable=yes,scrollbars=yes,status=yes');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
initPopupWindow: function()
|
||||||
|
{
|
||||||
|
window.resizeTo(575, 640);
|
||||||
|
$('address').hide();
|
||||||
|
$('#content').css({'width':'92%'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ Use:
|
|||||||
1. Get an API key from http://recaptcha.net
|
1. Get an API key from http://recaptcha.net
|
||||||
|
|
||||||
2. In config.php add:
|
2. In config.php add:
|
||||||
include_once('plugins/recaptcha.php');
|
include_once('plugins/recaptcha/recaptcha.php');
|
||||||
$captcha = new recaptcha(publickey, privatekey, showErrors);
|
$captcha = new recaptcha(publickey, privatekey, showErrors);
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
@ -27,6 +27,8 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
|
|||||||
return array(
|
return array(
|
||||||
array('not a link :: no way',
|
array('not a link :: no way',
|
||||||
'not a link :: no way'),
|
'not a link :: no way'),
|
||||||
|
array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
|
||||||
|
'link <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="external">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
|
||||||
array('http://127.0.0.1',
|
array('http://127.0.0.1',
|
||||||
'<a href="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
|
'<a href="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
|
||||||
array('127.0.0.1',
|
array('127.0.0.1',
|
||||||
|
@ -120,6 +120,10 @@ float:left;
|
|||||||
margin-left:11px;
|
margin-left:11px;
|
||||||
float:left;
|
float:left;
|
||||||
}
|
}
|
||||||
|
.form_settings .form_data textarea {
|
||||||
|
width:325px;
|
||||||
|
}
|
||||||
|
|
||||||
.form_settings .form_data input.submit {
|
.form_settings .form_data input.submit {
|
||||||
margin-left:0;
|
margin-left:0;
|
||||||
}
|
}
|
||||||
@ -968,9 +972,6 @@ right:7px;
|
|||||||
top:47px;
|
top:47px;
|
||||||
right:7px;
|
right:7px;
|
||||||
}
|
}
|
||||||
.notice-options .notice_reply dt {
|
|
||||||
display:none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.notice-options input,
|
.notice-options input,
|
||||||
.notice-options a {
|
.notice-options a {
|
||||||
@ -978,13 +979,13 @@ text-indent:-9999px;
|
|||||||
outline:none;
|
outline:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notice-options .notice_reply a,
|
.notice-options .notice_reply,
|
||||||
.notice-options input.submit {
|
.notice-options input.submit {
|
||||||
display:block;
|
display:block;
|
||||||
border:0;
|
border:0;
|
||||||
}
|
}
|
||||||
.notice-options .notice_reply a,
|
.notice-options .notice_reply,
|
||||||
.notice-options .notice_delete a {
|
.notice-options .notice_delete {
|
||||||
text-decoration:none;
|
text-decoration:none;
|
||||||
padding-left:16px;
|
padding-left:16px;
|
||||||
}
|
}
|
||||||
@ -1375,6 +1376,12 @@ padding-top:160px;
|
|||||||
#smssettings #form_notice,
|
#smssettings #form_notice,
|
||||||
#twittersettings #form_notice,
|
#twittersettings #form_notice,
|
||||||
#imsettings #form_notice,
|
#imsettings #form_notice,
|
||||||
|
#userdesignsettings #form_notice,
|
||||||
|
#groupdesignsettings #form_notice,
|
||||||
|
#grouplogo #form_notice,
|
||||||
|
#editgroup #form_notice,
|
||||||
|
#blockedfromgroup #form_notice,
|
||||||
|
#groupmembers #form_notice,
|
||||||
#doc #form_notice,
|
#doc #form_notice,
|
||||||
#usergroups #form_notice,
|
#usergroups #form_notice,
|
||||||
#invite #form_notice,
|
#invite #form_notice,
|
||||||
@ -1584,11 +1591,11 @@ background:transparent url(../../base/images/icons/twotone/green/clip-02.gif) no
|
|||||||
background:none;
|
background:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notice-options .notice_reply a,
|
.notice-options .notice_reply,
|
||||||
.notice-options form input.submit {
|
.notice-options form input.submit {
|
||||||
background-color:transparent;
|
background-color:transparent;
|
||||||
}
|
}
|
||||||
.notice-options .notice_reply a {
|
.notice-options .notice_reply {
|
||||||
background:transparent url(../images/icons/icon_reply.gif) no-repeat 0 45%;
|
background:transparent url(../images/icons/icon_reply.gif) no-repeat 0 45%;
|
||||||
}
|
}
|
||||||
.notice-options form.form_favor input.submit {
|
.notice-options form.form_favor input.submit {
|
||||||
@ -1597,7 +1604,7 @@ background:transparent url(../images/icons/icon_favourite.gif) no-repeat 0 45%;
|
|||||||
.notice-options form.form_disfavor input.submit {
|
.notice-options form.form_disfavor input.submit {
|
||||||
background:transparent url(../images/icons/icon_disfavourite.gif) no-repeat 0 45%;
|
background:transparent url(../images/icons/icon_disfavourite.gif) no-repeat 0 45%;
|
||||||
}
|
}
|
||||||
.notice-options .notice_delete a {
|
.notice-options .notice_delete {
|
||||||
background:transparent url(../images/icons/icon_trash.gif) no-repeat 0 45%;
|
background:transparent url(../images/icons/icon_trash.gif) no-repeat 0 45%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user