Skip to content

Commit

Permalink
Merge pull request #3 from RedEnchilada/statusnet-1.0.1
Browse files Browse the repository at this point in the history
Update Local
  • Loading branch information
Serrio committed Dec 10, 2013
2 parents e490a29 + a543fe7 commit 3efac62
Show file tree
Hide file tree
Showing 29 changed files with 570 additions and 172 deletions.
10 changes: 5 additions & 5 deletions actions/profilesettings.php
Expand Up @@ -202,14 +202,14 @@ function showContent()
false,
(empty($user->subscribe_policy)) ? User::SUBSCRIBE_POLICY_OPEN : $user->subscribe_policy);
$this->elementEnd('li');
}
}/* removing private non-group notices
$this->elementStart('li');
$this->checkbox('private_stream',
// TRANS: Checkbox label in profile settings.
_('Make updates visible only to my followers'),
($this->arg('private_stream')) ?
$this->boolean('private_stream') : $user->private_stream);
$this->elementEnd('li');
$this->elementEnd('li');*/
$this->elementEnd('ul');
// TRANS: Button to save input in profile settings.
$this->submit('save', _m('BUTTON','Save'));
Expand Down Expand Up @@ -252,7 +252,7 @@ function handlePost()
$location = $this->trimmed('location');
$autosubscribe = $this->boolean('autosubscribe');
$subscribe_policy = $this->trimmed('subscribe_policy');
$private_stream = $this->boolean('private_stream');
//$private_stream = $this->boolean('private_stream'); //removing private non-group notices
$language = $this->trimmed('language');
$timezone = $this->trimmed('timezone');
$tagstring = $this->trimmed('tags');
Expand Down Expand Up @@ -359,13 +359,13 @@ function handlePost()

// XXX: XOR
if (($user->autosubscribe ^ $autosubscribe) ||
($user->private_stream ^ $private_stream) ||
//($user->private_stream ^ $private_stream) ||
($user->subscribe_policy != $subscribe_policy)) {

$original = clone($user);

$user->autosubscribe = $autosubscribe;
$user->private_stream = $private_stream;
//$user->private_stream = $private_stream;
$user->subscribe_policy = $subscribe_policy;

$result = $user->update($original);
Expand Down
23 changes: 19 additions & 4 deletions classes/Notice.php
Expand Up @@ -474,11 +474,13 @@ static function saveNew($profile_id, $content, $source, $options=null) {
// If the original is private to a group, and notice has no group specified,
// make it to the same group(s)

if (empty($groups) && ($reply->scope | Notice::GROUP_SCOPE)) {
if (empty($groups) && ($reply->scope & Notice::GROUP_SCOPE)) {
$groups = array();
$replyGroups = $reply->getGroups();
foreach ($replyGroups as $group) {
if ($profile->isMember($group)) {
if ($profile->isMember($group)
|| $profile->hasRole(Profile_role::MODERATOR) // Make sure if a mod replies to a private notice that it gets to all groups
) {
$groups[] = $group->id;
}
}
Expand Down Expand Up @@ -532,7 +534,7 @@ static function saveNew($profile_id, $content, $source, $options=null) {
}

// For private streams

/* removing private non-group notices
$user = $profile->getUser();
if (!empty($user)) {
Expand All @@ -541,7 +543,7 @@ static function saveNew($profile_id, $content, $source, $options=null) {
$notice->scope == Notice::SITE_SCOPE)) {
$notice->scope |= Notice::FOLLOWER_SCOPE;
}
}
}*/

// Force the scope for private groups

Expand Down Expand Up @@ -2729,4 +2731,17 @@ static function fillRepeats(&$notices)
$notice->_setRepeats($repeats);
}
}

function showsOnPublic($profile) {
if ($this->is_local == Notice::LOCAL_PUBLIC ||
($this->is_local == Notice::REMOTE && !common_config('public', 'localonly')))
return true;

if($profile == null)
return false;

$noticeProfile = Profile::staticGet('id', $this->profile_id);

return $profile->isSubscribed($noticeProfile);
}
}
10 changes: 10 additions & 0 deletions js/util.js
Expand Up @@ -150,6 +150,16 @@ var SN = { // StatusNet
jQuery.data(form[0], 'ElementData', {MaxLength:MaxLength});

SN.U.Counter(form);

toSelector = form.find('#notice_to');

toSelector.bind('change', function(e) {
q = $(this).val();
if(q == 'public:everyone')
$(this).next().removeClass('visible');
else
$(this).next().addClass('visible');
});

NDT = form.find('.notice_data-text:first');

Expand Down
2 changes: 1 addition & 1 deletion js/util.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/default.php
Expand Up @@ -248,8 +248,8 @@
'application/vnd.oasis.opendocument.formula-template',
'application/vnd.oasis.opendocument.text-master',
'application/vnd.oasis.opendocument.text-web',
'application/x-zip',
'application/zip',
//'application/x-zip',
//'application/zip',
'text/plain',
'video/mpeg',
'video/mp4',
Expand Down
38 changes: 37 additions & 1 deletion lib/publicnoticestream.php
Expand Up @@ -49,7 +49,25 @@ class PublicNoticeStream extends ScopingNoticeStream
{
function __construct($profile=null, $images=false)
{
parent::__construct(new CachingNoticeStream(new RawPublicNoticeStream(),
$check = false;
if($profile != null) {
$subscriptions = $profile->getSubscriptions();
while($subscriptions->fetch()) {
if($subscriptions->isSandboxed()) {
$check = true;
break;
} else if(class_exists('Ostatus_profile') && Ostatus_profile::staticGet('profile_id', $subscriptions->id)) {
$check = true;
break;
}
}
}

if($check)
parent::__construct(new RawPublicNoticeStream($profile),
$profile);
else
parent::__construct(new CachingNoticeStream(new RawPublicNoticeStream(false),
'public'),
$profile);

Expand All @@ -70,6 +88,12 @@ function __construct($profile=null, $images=false)

class RawPublicNoticeStream extends NoticeStream
{
var $hasRemote;

function __construct($hasRemote=false) {
$this->hasRemote = $hasRemote;
}

function getNoticeIds($offset, $limit, $since_id, $max_id)
{
$notice = new Notice();
Expand All @@ -90,6 +114,18 @@ function getNoticeIds($offset, $limit, $since_id, $max_id)
$notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC);
$notice->whereAdd('is_local !='. Notice::GATEWAY);
}

if($this->hasRemote) {
$profile = $this->hasRemote;
$subscriptions = $profile->getSubscriptions();
$subscribedIds = array();
while($subscriptions->fetch()) {
$subscribedIds[] = $subscriptions->id;
}
$subscribedIds = implode(',', $subscribedIds);

$notice->whereAdd('profile_id IN (' . $subscribedIds . ')', 'OR');
}

Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id);
Expand Down
17 changes: 10 additions & 7 deletions lib/toselector.php
Expand Up @@ -94,11 +94,14 @@ function show()
}

$groups = $this->user->getGroups();

$privateButtonShow = '';

while ($groups->fetch()) {
$value = 'group:'.$groups->id;
if (($this->to instanceof User_group) && $this->to->id == $groups->id) {
$default = $value;
$privateButtonShow = ' visible';
}
$choices[$value] = $groups->getBestName();
}
Expand All @@ -119,7 +122,7 @@ function show()
false,
$default);

$this->out->elementStart('span', 'checkbox-wrapper');
$this->out->elementStart('span', 'checkbox-wrapper'.$privateButtonShow);
$this->out->checkbox('notice_private',
// TRANS: Checkbox label in widget for selecting potential addressees to mark the notice private.
_('Private?'),
Expand Down Expand Up @@ -147,20 +150,20 @@ static function fillOptions($action, &$options)
break;
case 'profile':
$profile = Profile::staticGet('id', $value);
$options['replies'] = array($profile->getUri());
$options['replies'] = array($profile->getUri());/* removing private non-group notices
if ($private) {
$options['scope'] = Notice::ADDRESSEE_SCOPE;
}
}*/
break;
case 'public':
if ($value == 'everyone' && !common_config('site', 'private')) {
$options['scope'] = 0;
if ($private) {
$options['scope'] = Notice::SITE_SCOPE;
}
} else if ($value == 'site') {
$options['scope'] = Notice::SITE_SCOPE;
}
}/* removing private non-group notices
if ($private) {
$options['scope'] = Notice::FOLLOWER_SCOPE;
}*/
break;
default:
// TRANS: Client exception thrown in widget for selecting potential addressees when an invalid fill option was received.
Expand Down
4 changes: 4 additions & 0 deletions lib/util.php
Expand Up @@ -2151,6 +2151,10 @@ function common_shorten_url($long_url, User $user=null, $force = false)
if (mb_strlen($long_url) < $maxUrlLength && !$force) {
return $long_url;
}

// return on emails
if(strpos($long_url, 'mailto:') !== false || preg_match('/.+\@.+\..+/i', $long_url))
return $long_url;

$shortenerName = User_urlshortener_prefs::urlShorteningService($user);

Expand Down
28 changes: 18 additions & 10 deletions plugins/MobileProfile/mobile.js
@@ -1,14 +1,19 @@
$('head').append($('<style>#content .notice > :not(.notices) {pointer-events: none !important;}</style>'));
//$('head').append($('<style>#content .notice > :not(.notices) {pointer-events: none !important;}</style>'));
//alert('testing D!');

$('#content .notice').live('click', function() {
var notice = $(this).clone(true);
notice.find('.notices').remove();
$('#content .notice .timestamp').live('click', function() {
var notice = $(this).closest('.notice').clone(true);
var nest = notice.find('.notices');
if(nest.length)
nest.remove();
var popup = $('<div id="notice-popup"></div>');
popup.append(notice);
popup.append($('<a id="notice-popup-close">&#xf00d;</a>'));
popup.append($('<a id="notice-popup-close" href="#">&#xf00d;</a>'));
$('body').append(popup);
adjustNoticePopup();
$(window).bind('resize.popadjust', adjustNoticePopup);
try {
adjustNoticePopup();
$(window).bind('resize.popadjust', adjustNoticePopup);
} catch (e) {}
return false;
});

Expand All @@ -19,10 +24,11 @@ $('#notice-popup-close').live('click', function() {
}
$('#notice-popup, #notice-popup-style').remove();
$(window).unbind('.popadjust');
return false;
});

if($('body#shownotice').length) {
$('.notice').click();
$('.notice .author').click();
$('#notice-popup').css({'background-color':'#889'});
}

Expand All @@ -41,7 +47,7 @@ $('#user_info_card img, #user_info_card .profile_block_name').bind('click', func

$('#user_info_card').append($('#dmcounter'));

// @fixme This isn't working any more for some reason... it worked in an earlier pass of the code. :c
/* @fixme This isn't working any more for some reason... it worked in an earlier pass of the code. :c
$('a').live('click', function() {
if($(this).is('#notice-popup a.timestamp') || $('body#shownotice').length)
return true;
Expand Down Expand Up @@ -79,9 +85,10 @@ $('a').live('click', function() {
}
});
return false;
});
});*/

function adjustNoticePopup() {
return;
try{$('#notice-popup-style').remove();}catch(e) {}
var popup = $('#notice-popup');
popup.css({'padding-bottom':'38px', 'padding-top':'38px'});
Expand All @@ -103,6 +110,7 @@ $('#user_info_card #form_login input.submit').live('click', function() {
$('.entity_actions h2').live('click', function() {
$(this).parent().toggleClass('opened');
});
$('.entity_actions h2').html('<a href="#">'+$('.entity_actions h2').html()+'</a>');

$('#site_nav_local_views li.current').live('click', function() {
$('#site_nav_local_views').toggleClass('opened');
Expand Down
54 changes: 46 additions & 8 deletions plugins/PromoteEverything/Promote.php
Expand Up @@ -103,10 +103,10 @@ function getNoticeIds($offset, $limit, $since_id, $max_id) {
while ($promote->fetch()) {
switch($promote->type) {
case 'group':
$item = new User_group();
$item = new Group_inbox();
break;
case 'profile':
$item = new Profile();
$item = new Notice();
break;
case 'tag':
$item = new Notice_tag();
Expand All @@ -118,12 +118,50 @@ function getNoticeIds($offset, $limit, $since_id, $max_id) {
if(empty($item)) continue;

if($item instanceof Notice_tag) {
$ids = array_merge($ids, $item->_streamDirect($promote->item_id, 0, 1));
}
else {
$item->id = intval($promote->item_id);
$ids = array_merge($ids, $item->_streamDirect(0, 1));
}
//$ids = array_merge($ids, $item->_streamDirect($promote->item_id, 0, 1));
$item->tag = $promote->item_id;
$item->orderBy('created DESC, notice_id DESC');
if($item->find()) {
while($item->fetch()) {
$notice = Notice::staticGet('id', $item->notice_id);
if($notice->isLocal() && empty($notice->repeat_of)) {
$ids[] = $notice->id;
break;
}
}
}
} else if($item instanceof Group_inbox) {
$item->group_id = $promote->item_id;

$item->selectAdd();
$item->selectAdd('notice_id');
$item->orderBy('created DESC, notice_id DESC');
if($item->find()) {
while($item->fetch()) {
$notice = Notice::staticGet('id', $item->notice_id);
if(empty($notice->reply_to) && empty($notice->repeat_of)) {
$ids[] = $notice->id;
break;
}
}
}
} else {
$item->profile_id = $promote->item_id;

$item->selectAdd();
$item->selectAdd('id');

$item->orderBy('created DESC, id DESC');

if($item->find()) {
while($item->fetch()) {
if(empty($item->repeat_of)) {
$ids[] = $item->id;
break;
}
}
}
}

$item->free();
$item = NULL;
Expand Down

0 comments on commit 3efac62

Please sign in to comment.