[DATABASE] Use "<>" as an SQL non-equality sign in more cases

A follow-up to commit 644b417f6c
This commit is contained in:
Alexei Sorokin 2020-06-08 18:31:22 +03:00 committed by Diogo Peralta Cordeiro
parent 9ac632ca2d
commit 434f07430d
12 changed files with 384 additions and 320 deletions

View File

@ -1,23 +1,25 @@
<?php <?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/* /*
* StatusNet - the distributed open-source microblogging tool * @copyright 2008, 2009 StatusNet, Inc.
* Copyright (C) 2008, 2009, StatusNet, Inc. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
* 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/>.
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } defined('GNUSOCIAL') || die();
define('LISTENER', 1); define('LISTENER', 1);
define('LISTENEE', -1); define('LISTENEE', -1);
@ -26,7 +28,7 @@ define('BOTH', 0);
// @todo XXX: Documentation missing. // @todo XXX: Documentation missing.
class FoafAction extends ManagedAction class FoafAction extends ManagedAction
{ {
function isReadOnly($args) public function isReadOnly($args)
{ {
return true; return true;
} }
@ -45,9 +47,13 @@ class FoafAction extends ManagedAction
// Permanent redirect on non-canonical nickname // Permanent redirect on non-canonical nickname
if ($nickname_arg != $this->nickname) { if ($nickname_arg != $this->nickname) {
common_redirect(common_local_url('foaf', common_redirect(
array('nickname' => $this->nickname)), common_local_url(
301); 'foaf',
['nickname' => $this->nickname]
),
301
);
} }
$this->user = User::getKV('nickname', $this->nickname); $this->user = User::getKV('nickname', $this->nickname);
@ -152,22 +158,27 @@ class FoafAction extends ManagedAction
// No avatar for this user! // No avatar for this user!
} }
$person = $this->showMicrobloggingAccount($this->profile, $person = $this->showMicrobloggingAccount(
common_root_url(), $this->user->getUri(), $this->profile,
/*$fetchSubscriptions*/true, common_root_url(),
/*$isSubscriber*/false); $this->user->getUri(),
// $fetchSubscriptions
true,
// $isSubscriber
false
);
// Get people who subscribe to user // Get people who subscribe to user
$sub = new Subscription(); $sub = new Subscription();
$sub->subscribed = $this->profile->id; $sub->subscribed = $this->profile->id;
$sub->whereAdd('subscriber != subscribed'); $sub->whereAdd('subscriber <> subscribed');
if ($sub->find()) { if ($sub->find()) {
while ($sub->fetch()) { while ($sub->fetch()) {
$profile = Profile::getKV('id', $sub->subscriber); $profile = Profile::getKV('id', $sub->subscriber);
if (!$profile instanceof Profile) { if (!$profile instanceof Profile) {
common_debug('Got a bad subscription: '.print_r($sub,true)); common_debug('Got a bad subscription: ' . print_r($sub, true));
continue; continue;
} }
$other_uri = $profile->getUri(); $other_uri = $profile->getUri();
@ -206,11 +217,15 @@ class FoafAction extends ManagedAction
if ($type == BOTH) { if ($type == BOTH) {
$this->element('knows', array('rdf:resource' => $this->user->getUri())); $this->element('knows', array('rdf:resource' => $this->user->getUri()));
} }
$this->showMicrobloggingAccount($profile, $this->showMicrobloggingAccount(
($local == 'local') ? common_root_url() : null, $profile,
$uri, ($local === 'local') ? common_root_url() : null,
/*$fetchSubscriptions*/false, $uri,
/*$isSubscriber*/($type == LISTENER || $type == BOTH)); // $fetchSubscriptions
false,
// $isSubscriber
($type == LISTENER || $type == BOTH)
);
if ($foaf_url) { if ($foaf_url) {
$this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url)); $this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url));
} }
@ -227,7 +242,7 @@ class FoafAction extends ManagedAction
$this->endXML(); $this->endXML();
} }
function showPpd($foaf_url, $person_uri) public function showPpd($foaf_url, $person_uri)
{ {
$this->elementStart('PersonalProfileDocument', array('rdf:about' => $foaf_url)); $this->elementStart('PersonalProfileDocument', array('rdf:about' => $foaf_url));
$this->element('maker', array('rdf:resource' => $person_uri)); $this->element('maker', array('rdf:resource' => $person_uri));
@ -248,7 +263,7 @@ class FoafAction extends ManagedAction
* @return array if $fetchSubscribers is set, return a list of info on those * @return array if $fetchSubscribers is set, return a list of info on those
* subscriptions. * subscriptions.
*/ */
function showMicrobloggingAccount($profile, $service=null, $useruri=null, $fetchSubscriptions=false, $isSubscriber=false) public function showMicrobloggingAccount($profile, $service = null, $useruri = null, $fetchSubscriptions = false, $isSubscriber = false)
{ {
$attr = array(); $attr = array();
if ($useruri) { if ($useruri) {
@ -274,13 +289,13 @@ class FoafAction extends ManagedAction
// Get people user is subscribed to // Get people user is subscribed to
$sub = new Subscription(); $sub = new Subscription();
$sub->subscriber = $profile->id; $sub->subscriber = $profile->id;
$sub->whereAdd('subscriber != subscribed'); $sub->whereAdd('subscriber <> subscribed');
if ($sub->find()) { if ($sub->find()) {
while ($sub->fetch()) { while ($sub->fetch()) {
$profile = Profile::getKV('id', $sub->subscribed); $profile = Profile::getKV('id', $sub->subscribed);
if (empty($profile)) { if (empty($profile)) {
common_debug('Got a bad subscription: '.print_r($sub,true)); common_debug('Got a bad subscription: ' . print_r($sub, true));
continue; continue;
} }
$other_uri = $profile->getUri(); $other_uri = $profile->getUri();
@ -294,7 +309,7 @@ class FoafAction extends ManagedAction
} }
unset($sub); unset($sub);
} else if ($isSubscriber) { } elseif ($isSubscriber) {
// Just declare that they follow the user whose FOAF we're showing. // Just declare that they follow the user whose FOAF we're showing.
$this->element('sioc:follows', array('rdf:resource' => $this->user->getUri() . '#acct')); $this->element('sioc:follows', array('rdf:resource' => $this->user->getUri() . '#acct'));
} }

View File

@ -1,42 +1,38 @@
<?php <?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/** /**
* StatusNet, the distributed open-source microblogging tool
*
* List the OAuth applications that a user has registered with this instance * List the OAuth applications that a user has registered with this instance
* *
* 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 Settings * @category Settings
* @package StatusNet * @package GNUsocial
* @author Zach Copley <zach@status.net> * @author Zach Copley <zach@status.net>
* @copyright 2008-2009 StatusNet, Inc. * @copyright 2008-2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } defined('GNUSOCIAL') || die();
/** /**
* Show a user's registered OAuth applications * Show a user's registered OAuth applications
* *
* @category Settings * @category Settings
* @package StatusNet * @package GNUsocial
* @author Zach Copley <zach@status.net> * @author Zach Copley <zach@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
* *
* @see SettingsAction * @see SettingsAction
*/ */
@ -56,7 +52,7 @@ class OauthappssettingsAction extends SettingsAction
* @return string Title of the page * @return string Title of the page
*/ */
function title() public function title()
{ {
// TRANS: Page title for OAuth applications // TRANS: Page title for OAuth applications
return _('OAuth applications'); return _('OAuth applications');
@ -68,20 +64,20 @@ class OauthappssettingsAction extends SettingsAction
* @return instructions for use * @return instructions for use
*/ */
function getInstructions() public function getInstructions()
{ {
// TRANS: Page instructions for OAuth applications // TRANS: Page instructions for OAuth applications
return _('Applications you have registered'); return _('Applications you have registered');
} }
function showContent() public function showContent()
{ {
$offset = ($this->page - 1) * APPS_PER_PAGE; $offset = ($this->page - 1) * APPS_PER_PAGE;
$limit = APPS_PER_PAGE + 1; $limit = APPS_PER_PAGE + 1;
$application = new Oauth_application(); $application = new Oauth_application();
$application->owner = $this->scoped->getID(); $application->owner = $this->scoped->getID();
$application->whereAdd("name != 'anonymous'"); $application->whereAdd("name <> 'anonymous'");
$application->limit($offset, $limit); $application->limit($offset, $limit);
$application->orderBy('created DESC'); $application->orderBy('created DESC');
$application->find(); $application->find();
@ -96,13 +92,16 @@ class OauthappssettingsAction extends SettingsAction
} }
} }
$this->elementStart('p', array('id' => 'application_register')); $this->elementStart('p', ['id' => 'application_register']);
$this->element('a', $this->element(
array('href' => common_local_url('newapplication'), 'a',
'class' => 'more' [
), 'href' => common_local_url('newapplication'),
'class' => 'more',
],
// TRANS: Link description to add a new OAuth application. // TRANS: Link description to add a new OAuth application.
'Register a new application'); 'Register a new application'
);
$this->elementEnd('p'); $this->elementEnd('p');
$this->pagination( $this->pagination(
@ -113,7 +112,7 @@ class OauthappssettingsAction extends SettingsAction
); );
} }
function showEmptyListMessage() public function showEmptyListMessage()
{ {
// TRANS: Empty list message on page with OAuth applications. Markup allowed // TRANS: Empty list message on page with OAuth applications. Markup allowed
$message = sprintf(_('You have not registered any applications yet.')); $message = sprintf(_('You have not registered any applications yet.'));

View File

@ -1,64 +1,65 @@
<?php <?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/** /**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2011, StatusNet, Inc.
*
* Stream of notices sorted by popularity * Stream of notices sorted by popularity
* *
* PHP version 5
*
* 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 Popular * @category Popular
* @package StatusNet * @package GNUsocial
* @author Evan Prodromou <evan@status.net> * @author Evan Prodromou <evan@status.net>
* @copyright 2011 StatusNet, Inc. * @copyright 2011 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } defined('GNUSOCIAL') || die();
/** /**
* Stream of notices sorted by popularity * Stream of notices sorted by popularity
* *
* @category Popular * @category Popular
* @package StatusNet * @package GNUsocial
* @author Evan Prodromou <evan@status.net> * @author Evan Prodromou <evan@status.net>
* @copyright 2011 StatusNet, Inc. * @copyright 2011 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
class PopularNoticeStream extends ScopingNoticeStream class PopularNoticeStream extends ScopingNoticeStream
{ {
function __construct(Profile $scoped=null) public function __construct(Profile $scoped=null)
{ {
parent::__construct(new CachingNoticeStream(new RawPopularNoticeStream(), parent::__construct(
'popular', new CachingNoticeStream(
false), new RawPopularNoticeStream(),
$scoped); 'popular',
false
),
$scoped
);
} }
} }
class RawPopularNoticeStream extends NoticeStream class RawPopularNoticeStream extends NoticeStream
{ {
function getNoticeIds($offset, $limit, $since_id, $max_id) public function getNoticeIds($offset, $limit, $since_id, $max_id)
{ {
$weightexpr = common_sql_weight('modified', common_config('popular', 'dropoff')); $weightexpr = common_sql_weight('modified', common_config('popular', 'dropoff'));
$cutoff = sprintf("modified > '%s'", $cutoff = sprintf(
common_sql_date(time() - common_config('popular', 'cutoff'))); "modified > TIMESTAMP '%s'",
common_sql_date(time() - common_config('popular', 'cutoff'))
);
$fave = new Fave(); $fave = new Fave();
$fave->selectAdd(); $fave->selectAdd();
@ -85,4 +86,3 @@ class RawPopularNoticeStream extends NoticeStream
return $ids; return $ids;
} }
} }

View File

@ -557,7 +557,7 @@ class Activitypub_profile extends Managed_DataObject
$user_table = common_database_tablename('user'); $user_table = common_database_tablename('user');
$sub = new Subscription(); $sub = new Subscription();
$sub->subscribed = $profile->id; $sub->subscribed = $profile->id;
$sub->whereAdd('subscriber != subscribed'); $sub->whereAdd('subscriber <> subscribed');
$sub->whereAdd("subscriber IN (SELECT id FROM {$user_table} UNION SELECT profile_id AS id FROM activitypub_profile)"); $sub->whereAdd("subscriber IN (SELECT id FROM {$user_table} UNION SELECT profile_id AS id FROM activitypub_profile)");
$cnt = $sub->count('distinct subscriber'); $cnt = $sub->count('distinct subscriber');
@ -585,7 +585,7 @@ class Activitypub_profile extends Managed_DataObject
$user_table = common_database_tablename('user'); $user_table = common_database_tablename('user');
$sub = new Subscription(); $sub = new Subscription();
$sub->subscriber = $profile->id; $sub->subscriber = $profile->id;
$sub->whereAdd('subscriber != subscribed'); $sub->whereAdd('subscriber <> subscribed');
$sub->whereAdd("subscribed IN (SELECT id FROM {$user_table} UNION SELECT profile_id AS id FROM activitypub_profile)"); $sub->whereAdd("subscribed IN (SELECT id FROM {$user_table} UNION SELECT profile_id AS id FROM activitypub_profile)");
$cnt = $sub->count('distinct subscribed'); $cnt = $sub->count('distinct subscribed');

View File

@ -1,19 +1,33 @@
<?php <?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
if (!defined('GNUSOCIAL')) { exit(1); } defined('GNUSOCIAL') || die();
class RawBookmarksNoticeStream extends NoticeStream class RawBookmarksNoticeStream extends NoticeStream
{ {
protected $user_id; protected $user_id;
protected $own; protected $own;
function __construct($user_id, $own) public function __construct($user_id, $own)
{ {
$this->user_id = $user_id; $this->user_id = $user_id;
$this->own = $own; $this->own = $own;
} }
function getNoticeIds($offset, $limit, $since_id, $max_id) public function getNoticeIds($offset, $limit, $since_id, $max_id)
{ {
$notice = new Notice(); $notice = new Notice();
$qry = null; $qry = null;
@ -21,7 +35,7 @@ class RawBookmarksNoticeStream extends NoticeStream
$qry = 'SELECT notice.* FROM notice '; $qry = 'SELECT notice.* FROM notice ';
$qry .= 'INNER JOIN bookmark ON bookmark.uri = notice.uri '; $qry .= 'INNER JOIN bookmark ON bookmark.uri = notice.uri ';
$qry .= 'WHERE bookmark.profile_id = ' . $this->user_id . ' '; $qry .= 'WHERE bookmark.profile_id = ' . $this->user_id . ' ';
$qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' '; $qry .= 'AND notice.is_local <> ' . Notice::GATEWAY . ' ';
if ($since_id != 0) { if ($since_id != 0) {
$qry .= 'AND notice.id > ' . $since_id . ' '; $qry .= 'AND notice.id > ' . $since_id . ' ';
@ -62,7 +76,7 @@ class RawBookmarksNoticeStream extends NoticeStream
class BookmarksNoticeStream extends ScopingNoticeStream class BookmarksNoticeStream extends ScopingNoticeStream
{ {
function __construct($user_id, $own, Profile $scoped=null) public function __construct($user_id, $own, Profile $scoped = null)
{ {
$stream = new RawBookmarksNoticeStream($user_id, $own); $stream = new RawBookmarksNoticeStream($user_id, $own);

View File

@ -1,17 +1,31 @@
<?php <?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
if (!defined('GNUSOCIAL')) { exit(1); } defined('GNUSOCIAL') || die();
class RawEventsNoticeStream extends NoticeStream class RawEventsNoticeStream extends NoticeStream
{ {
function getNoticeIds($offset, $limit, $since_id, $max_id) public function getNoticeIds($offset, $limit, $since_id, $max_id)
{ {
$notice = new Notice(); $notice = new Notice();
$qry = null; $qry = null;
$qry = 'SELECT notice.* FROM notice '; $qry = 'SELECT notice.* FROM notice ';
$qry .= 'INNER JOIN happening ON happening.uri = notice.uri '; $qry .= 'INNER JOIN happening ON happening.uri = notice.uri ';
$qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' '; $qry .= 'AND notice.is_local <> ' . Notice::GATEWAY . ' ';
if ($since_id != 0) { if ($since_id != 0) {
$qry .= 'AND notice.id > ' . $since_id . ' '; $qry .= 'AND notice.id > ' . $since_id . ' ';
@ -45,7 +59,7 @@ class EventsNoticeStream extends ScopingNoticeStream
protected $rsvp = ['Y', 'N', '?']; protected $rsvp = ['Y', 'N', '?'];
protected $target = null; protected $target = null;
function __construct(Profile $target, Profile $scoped=null, array $rsvp=array()) public function __construct(Profile $target, Profile $scoped = null, array $rsvp = [])
{ {
$stream = new RawEventsNoticeStream(); $stream = new RawEventsNoticeStream();

View File

@ -1,38 +1,30 @@
<?php <?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/** /**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2010, StatusNet, Inc.
*
* When a new user registers, all existing users follow them automatically. * When a new user registers, all existing users follow them automatically.
* *
* PHP version 5
*
* 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 Community * @category Community
* @package StatusNet * @package GNUsocial
* @author Evan Prodromou <evan@status.net> * @author Evan Prodromou <evan@status.net>
* @copyright 2010 StatusNet, Inc. * @copyright 2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
if (!defined('STATUSNET')) { defined('GNUSOCIAL') || die();
// This check helps protect against security problems;
// your code file can't be executed directly from the web.
exit(1);
}
/** /**
* Plugin to make all users follow each other at registration * Plugin to make all users follow each other at registration
@ -40,11 +32,10 @@ if (!defined('STATUSNET')) {
* Users can unfollow afterwards if they want. * Users can unfollow afterwards if they want.
* *
* @category Sample * @category Sample
* @package StatusNet * @package GNUsocial
* @author Evan Prodromou <evan@status.net> * @author Evan Prodromou <evan@status.net>
* @copyright 2010 StatusNet, Inc. * @copyright 2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
class FollowEveryonePlugin extends Plugin class FollowEveryonePlugin extends Plugin
{ {
@ -64,7 +55,7 @@ class FollowEveryonePlugin extends Plugin
public function onEndUserRegister(Profile $profile) public function onEndUserRegister(Profile $profile)
{ {
$otherUser = new User(); $otherUser = new User();
$otherUser->whereAdd('id != ' . $profile->id); $otherUser->whereAdd('id <> ' . $profile->id);
if ($otherUser->find()) { if ($otherUser->find()) {
while ($otherUser->fetch()) { while ($otherUser->fetch()) {
@ -110,7 +101,7 @@ class FollowEveryonePlugin extends Plugin
* *
* @return boolean hook value; true means continue processing, false means stop. * @return boolean hook value; true means continue processing, false means stop.
*/ */
function onCheckSchema() public function onCheckSchema()
{ {
$schema = Schema::get(); $schema = Schema::get();
@ -127,16 +118,17 @@ class FollowEveryonePlugin extends Plugin
* *
* @return boolean hook value * @return boolean hook value
*/ */
function onEndProfileFormData($action) public function onEndProfileFormData($action)
{ {
$user = common_current_user(); $user = common_current_user();
$action->elementStart('li'); $action->elementStart('li');
// TRANS: Checkbox label in form for profile settings. // TRANS: Checkbox label in form for profile settings.
$action->checkbox('followeveryone', _m('Follow everyone'), $action->checkbox(
($action->arg('followeveryone')) ? 'followeveryone',
$action->arg('followeveryone') : _m('Follow everyone'),
User_followeveryone_prefs::followEveryone($user->id)); ($action->arg('followeveryone') ?? User_followeveryone_prefs::followEveryone($user->id))
);
$action->elementEnd('li'); $action->elementEnd('li');
return true; return true;
@ -149,12 +141,14 @@ class FollowEveryonePlugin extends Plugin
* *
* @return boolean hook value * @return boolean hook value
*/ */
function onEndProfileSaveForm($action) public function onEndProfileSaveForm($action)
{ {
$user = common_current_user(); $user = common_current_user();
User_followeveryone_prefs::savePref($user->id, User_followeveryone_prefs::savePref(
$action->boolean('followeveryone')); $user->id,
$action->boolean('followeveryone')
);
return true; return true;
} }

View File

@ -1,32 +1,31 @@
<?php <?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/** /**
* StatusNet, the distributed open-source microblogging tool * Plugin for sending and importing Twitter statuses
*
* 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 * @category Plugin
* @package StatusNet * @package GNUsocial
* @author Zach Copley <zach@status.net> * @author Zach Copley <zach@status.net>
* @author Julien C <chaumond@gmail.com> * @author Julien C <chaumond@gmail.com>
* @copyright 2009-2010 Control Yourself, Inc. * @copyright 2009-2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } defined('GNUSOCIAL') || die();
require_once __DIR__ . '/twitter.php'; require_once __DIR__ . '/twitter.php';
@ -37,13 +36,11 @@ require_once __DIR__ . '/twitter.php';
* *
* Depends on Favorite plugin. * Depends on Favorite plugin.
* *
* @category Plugin * @category Plugin
* @package StatusNet * @package GNUsocial
* @author Zach Copley <zach@status.net> * @author Zach Copley <zach@status.net>
* @author Julien C <chaumond@gmail.com> * @author Julien C <chaumond@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
* @link http://twitter.com/
*/ */
class TwitterBridgePlugin extends Plugin class TwitterBridgePlugin extends Plugin
{ {
@ -53,7 +50,7 @@ class TwitterBridgePlugin extends Plugin
/** /**
* Initializer for the plugin. * Initializer for the plugin.
*/ */
function initialize() public function initialize()
{ {
// Allow the key and secret to be passed in // Allow the key and secret to be passed in
// Control panel will override // Control panel will override
@ -83,7 +80,7 @@ class TwitterBridgePlugin extends Plugin
* *
* @return boolean result * @return boolean result
*/ */
static function hasKeys() public static function hasKeys()
{ {
$ckey = common_config('twitter', 'consumer_key'); $ckey = common_config('twitter', 'consumer_key');
$csecret = common_config('twitter', 'consumer_secret'); $csecret = common_config('twitter', 'consumer_secret');
@ -114,14 +111,20 @@ class TwitterBridgePlugin extends Plugin
$m->connect('panel/twitter', ['action' => 'twitteradminpanel']); $m->connect('panel/twitter', ['action' => 'twitteradminpanel']);
if (self::hasKeys()) { if (self::hasKeys()) {
$m->connect('twitter/authorization', $m->connect(
['action' => 'twitterauthorization']); 'twitter/authorization',
$m->connect('settings/twitter', ['action' => 'twitterauthorization']
['action' => 'twittersettings']); );
$m->connect(
'settings/twitter',
['action' => 'twittersettings']
);
if (common_config('twitter', 'signin')) { if (common_config('twitter', 'signin')) {
$m->connect('main/twitterlogin', $m->connect(
['action' => 'twitterlogin']); 'main/twitterlogin',
['action' => 'twitterlogin']
);
} }
} }
@ -135,7 +138,7 @@ class TwitterBridgePlugin extends Plugin
* *
* @return void * @return void
*/ */
function onEndLoginGroupNav($action) public function onEndLoginGroupNav($action)
{ {
$action_name = $action->trimmed('action'); $action_name = $action->trimmed('action');
@ -143,7 +146,7 @@ class TwitterBridgePlugin extends Plugin
$action->menuItem( $action->menuItem(
common_local_url('twitterlogin'), common_local_url('twitterlogin'),
// TRANS: Menu item in login navigation. // TRANS: Menu item in login navigation.
_m('MENU','Twitter'), _m('MENU', 'Twitter'),
// TRANS: Title for menu item in login navigation. // TRANS: Title for menu item in login navigation.
_m('Login or register using Twitter.'), _m('Login or register using Twitter.'),
'twitterlogin' === $action_name 'twitterlogin' === $action_name
@ -160,7 +163,7 @@ class TwitterBridgePlugin extends Plugin
* *
* @return boolean hook return * @return boolean hook return
*/ */
function onEndConnectSettingsNav($action) public function onEndConnectSettingsNav($action)
{ {
if (self::hasKeys()) { if (self::hasKeys()) {
$action_name = $action->trimmed('action'); $action_name = $action->trimmed('action');
@ -168,7 +171,7 @@ class TwitterBridgePlugin extends Plugin
$action->menuItem( $action->menuItem(
common_local_url('twittersettings'), common_local_url('twittersettings'),
// TRANS: Menu item in connection settings navigation. // TRANS: Menu item in connection settings navigation.
_m('MENU','Twitter'), _m('MENU', 'Twitter'),
// TRANS: Title for menu item in connection settings navigation. // TRANS: Title for menu item in connection settings navigation.
_m('Twitter integration options'), _m('Twitter integration options'),
$action_name === 'twittersettings' $action_name === 'twittersettings'
@ -185,7 +188,7 @@ class TwitterBridgePlugin extends Plugin
* *
* @return boolean hook return * @return boolean hook return
*/ */
function onStartEnqueueNotice($notice, &$transports) public function onStartEnqueueNotice($notice, &$transports)
{ {
if (self::hasKeys() && $notice->isLocal() && $notice->inScope(null)) { if (self::hasKeys() && $notice->isLocal() && $notice->inScope(null)) {
// Avoid a possible loop // Avoid a possible loop
@ -203,7 +206,7 @@ class TwitterBridgePlugin extends Plugin
* *
* @return boolean hook return * @return boolean hook return
*/ */
function onGetValidDaemons(&$daemons) public function onGetValidDaemons(&$daemons)
{ {
if (self::hasKeys()) { if (self::hasKeys()) {
array_push( array_push(
@ -216,7 +219,7 @@ class TwitterBridgePlugin extends Plugin
$daemons, $daemons,
INSTALLDIR INSTALLDIR
. '/plugins/TwitterBridge/daemons/twitterstatusfetcher.php' . '/plugins/TwitterBridge/daemons/twitterstatusfetcher.php'
); );
} }
} }
@ -230,7 +233,7 @@ class TwitterBridgePlugin extends Plugin
* *
* @return boolean hook return * @return boolean hook return
*/ */
function onEndInitializeQueueManager($manager) public function onEndInitializeQueueManager($manager)
{ {
if (self::hasKeys()) { if (self::hasKeys()) {
// Outgoing notices -> twitter // Outgoing notices -> twitter
@ -245,7 +248,7 @@ class TwitterBridgePlugin extends Plugin
/** /**
* If the plugin's installed, this should be accessible to admins * If the plugin's installed, this should be accessible to admins
*/ */
function onAdminPanelCheck($name, &$isOK) public function onAdminPanelCheck($name, &$isOK)
{ {
if ($name == 'twitter') { if ($name == 'twitter') {
$isOK = true; $isOK = true;
@ -262,10 +265,9 @@ class TwitterBridgePlugin extends Plugin
* @return boolean hook value * @return boolean hook value
*/ */
function onEndAdminPanelNav($nav) public function onEndAdminPanelNav($nav)
{ {
if (AdminPanelAction::canAdmin('twitter')) { if (AdminPanelAction::canAdmin('twitter')) {
$action_name = $nav->action->trimmed('action'); $action_name = $nav->action->trimmed('action');
$nav->out->menuItem( $nav->out->menuItem(
@ -297,7 +299,8 @@ class TwitterBridgePlugin extends Plugin
'author' => 'Zach Copley, Julien C, Jean Baptiste Favre', 'author' => 'Zach Copley, Julien C, Jean Baptiste Favre',
'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/TwitterBridge', 'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/TwitterBridge',
// TRANS: Plugin description. // TRANS: Plugin description.
'rawdescription' => _m('The Twitter "bridge" plugin allows integration ' . 'rawdescription' => _m(
'The Twitter "bridge" plugin allows integration ' .
'of a StatusNet instance with ' . 'of a StatusNet instance with ' .
'<a href="http://twitter.com/">Twitter</a>.' '<a href="http://twitter.com/">Twitter</a>.'
) )
@ -312,7 +315,7 @@ class TwitterBridgePlugin extends Plugin
* *
* @return boolean hook value; * @return boolean hook value;
*/ */
function onTwitterBridgeAdminImportControl() public function onTwitterBridgeAdminImportControl()
{ {
return (bool)$this->adminImportControl; return (bool)$this->adminImportControl;
} }
@ -327,7 +330,7 @@ class TwitterBridgePlugin extends Plugin
* *
* @return boolean hook value; true means continue processing, false means stop. * @return boolean hook value; true means continue processing, false means stop.
*/ */
function onCheckSchema() public function onCheckSchema()
{ {
$schema = Schema::get(); $schema = Schema::get();
@ -350,12 +353,11 @@ class TwitterBridgePlugin extends Plugin
* *
* @return boolean hook value * @return boolean hook value
*/ */
function onStartDeleteOwnNotice(User $user, Notice $notice) public function onStartDeleteOwnNotice(User $user, Notice $notice)
{ {
$n2s = Notice_to_status::getKV('notice_id', $notice->id); $n2s = Notice_to_status::getKV('notice_id', $notice->id);
if ($n2s instanceof Notice_to_status) { if ($n2s instanceof Notice_to_status) {
try { try {
$flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE); // twitter service $flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE); // twitter service
} catch (NoResultException $e) { } catch (NoResultException $e) {
@ -388,7 +390,7 @@ class TwitterBridgePlugin extends Plugin
* @param Notice $notice being favored * @param Notice $notice being favored
* @return hook return value * @return hook return value
*/ */
function onEndFavorNotice(Profile $profile, Notice $notice) public function onEndFavorNotice(Profile $profile, Notice $notice)
{ {
try { try {
$flink = Foreign_link::getByUserID($profile->getID(), TWITTER_SERVICE); // twitter service $flink = Foreign_link::getByUserID($profile->getID(), TWITTER_SERVICE); // twitter service
@ -427,7 +429,7 @@ class TwitterBridgePlugin extends Plugin
* *
* @return hook return value * @return hook return value
*/ */
function onEndDisfavorNotice(Profile $profile, Notice $notice) public function onEndDisfavorNotice(Profile $profile, Notice $notice)
{ {
try { try {
$flink = Foreign_link::getByUserID($profile->getID(), TWITTER_SERVICE); // twitter service $flink = Foreign_link::getByUserID($profile->getID(), TWITTER_SERVICE); // twitter service
@ -458,7 +460,7 @@ class TwitterBridgePlugin extends Plugin
return true; return true;
} }
function onStartGetProfileUri($profile, &$uri) public function onStartGetProfileUri($profile, &$uri)
{ {
if (preg_match('!^https?://twitter.com/!', $profile->profileurl)) { if (preg_match('!^https?://twitter.com/!', $profile->profileurl)) {
$uri = $profile->profileurl; $uri = $profile->profileurl;
@ -476,7 +478,7 @@ class TwitterBridgePlugin extends Plugin
* @return boolean hook value (true) * @return boolean hook value (true)
*/ */
function onOtherAccountProfiles($profile, &$links) public function onOtherAccountProfiles($profile, &$links)
{ {
$fuser = null; $fuser = null;
@ -496,7 +498,8 @@ class TwitterBridgePlugin extends Plugin
public function onEndShowHeadElements(Action $action) public function onEndShowHeadElements(Action $action)
{ {
if($action instanceof ShowNoticeAction) { // Showing a notice // Showing a notice
if ($action instanceof ShowNoticeAction) {
$notice = Notice::getKV('id', $action->arg('notice')); $notice = Notice::getKV('id', $action->arg('notice'));
try { try {
@ -507,7 +510,7 @@ class TwitterBridgePlugin extends Plugin
} }
$statusId = twitter_status_id($notice); $statusId = twitter_status_id($notice);
if($notice instanceof Notice && $notice->isLocal() && $statusId) { if ($notice instanceof Notice && $notice->isLocal() && $statusId) {
$tweetUrl = 'https://twitter.com/' . $fuser->nickname . '/status/' . $statusId; $tweetUrl = 'https://twitter.com/' . $fuser->nickname . '/status/' . $statusId;
$action->element('link', array('rel' => 'syndication', 'href' => $tweetUrl)); $action->element('link', array('rel' => 'syndication', 'href' => $tweetUrl));
} }
@ -529,24 +532,48 @@ class TwitterBridgePlugin extends Plugin
case 'image/jpg': case 'image/jpg':
case 'image/png': case 'image/png':
case 'image/gif': case 'image/gif':
$action->element('meta', array('name' => 'twitter:card', $action->element(
'content' => 'photo'), 'meta',
null); [
$action->element('meta', array('name' => 'twitter:url', 'name' => 'twitter:card',
'content' => common_local_url('attachment', 'content' => 'photo',
array('attachment' => $action->attachment->id))), ],
null ); null
$action->element('meta', array('name' => 'twitter:image', );
'content' => $action->attachment->url)); $action->element(
$action->element('meta', array('name' => 'twitter:title', 'meta',
'content' => $action->attachment->title)); [
'name' => 'twitter:url',
'content' => common_local_url(
'attachment',
['attachment' => $action->attachment->id]
)
],
null
);
$action->element(
'meta',
[
'name' => 'twitter:image',
'content' => $action->attachment->url,
]
);
$action->element(
'meta',
[
'name' => 'twitter:title',
'content' => $action->attachment->title,
]
);
$ns = new AttachmentNoticeSection($action); $ns = new AttachmentNoticeSection($action);
$notices = $ns->getNotices(); $notices = $ns->getNotices();
$noticeArray = $notices->fetchAll(); $noticeArray = $notices->fetchAll();
// Should not have more than 1 notice for this attachment. // Should not have more than 1 notice for this attachment.
if( count($noticeArray) != 1 ) { break; } if (count($noticeArray) != 1) {
break;
}
$post = $noticeArray[0]; $post = $noticeArray[0];
try { try {
@ -572,20 +599,20 @@ class TwitterBridgePlugin extends Plugin
*/ */
public function onEndUpgrade() public function onEndUpgrade()
{ {
printfnq("Ensuring all Twitter notices have an object_type..."); printfnq('Ensuring all Twitter notices have an object_type...');
$notice = new Notice(); $notice = new Notice();
$notice->whereAdd("source='twitter'"); $notice->whereAdd("source = 'twitter'");
$notice->whereAdd('object_type IS NULL'); $notice->whereAdd('object_type IS NULL');
if ($notice->find()) { if ($notice->find()) {
while ($notice->fetch()) { while ($notice->fetch()) {
$orig = Notice::getKV('id', $notice->id); $orig = Notice::getKV('id', $notice->id);
$notice->object_type = ActivityObject::NOTE; $notice->object_type = ActivityObject::NOTE;
$notice->update($orig); $notice->update($orig);
} }
} }
printfnq("DONE.\n"); printfnq("DONE.\n");
} }
} }

View File

@ -1,44 +1,38 @@
<?php <?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Clear all flags for a profile * Clear all flags for a profile
* *
* PHP version 5 * @category Action
* * @package GNUsocial
* @category Action * @author Evan Prodromou <evan@status.net>
* @package StatusNet * @copyright 2009 StatusNet, Inc.
* @author Evan Prodromou <evan@status.net> * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 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/>.
*/ */
if (!defined('STATUSNET')) { defined('GNUSOCIAL') || die();
exit(1);
}
/** /**
* Action to clear flags for a profile * Action to clear flags for a profile
* *
* @category Action * @category Action
* @package StatusNet * @package GNUsocial
* @author Evan Prodromou <evan@status.net> * @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
class ClearflagAction extends ProfileFormAction class ClearflagAction extends ProfileFormAction
{ {
@ -49,7 +43,7 @@ class ClearflagAction extends ProfileFormAction
* *
* @return boolean success flag * @return boolean success flag
*/ */
function prepare(array $args = array()) public function prepare(array $args = [])
{ {
if (!parent::prepare($args)) { if (!parent::prepare($args)) {
return false; return false;
@ -73,7 +67,7 @@ class ClearflagAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function handle() public function handle()
{ {
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->handlePost(); $this->handlePost();
@ -90,7 +84,7 @@ class ClearflagAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function handlePost() public function handlePost()
{ {
$ufp = new User_flag_profile(); $ufp = new User_flag_profile();
@ -102,8 +96,10 @@ class ClearflagAction extends ProfileFormAction
if ($result == false) { if ($result == false) {
// TRANS: Server exception given when flags could not be cleared. // TRANS: Server exception given when flags could not be cleared.
// TRANS: %s is a profile nickname. // TRANS: %s is a profile nickname.
$msg = sprintf(_m('Could not clear flags for profile "%s".'), $msg = sprintf(
$this->profile->nickname); _m('Could not clear flags for profile "%s".'),
$this->profile->nickname
);
throw new ServerException($msg); throw new ServerException($msg);
} }
@ -119,7 +115,7 @@ class ClearflagAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function ajaxResults() public function ajaxResults()
{ {
$this->startHTML('text/xml;charset=utf-8'); $this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head'); $this->elementStart('head');

View File

@ -1,21 +1,23 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
/* // This file is part of GNU social - https://www.gnu.org/software/social
* StatusNet - a distributed open-source microblogging tool //
* Copyright (C) 2008, 2009, 2010, StatusNet, Inc. // GNU social is free software: you can redistribute it and/or modify
* // it under the terms of the GNU Affero General Public License as published by
* This program is free software: you can redistribute it and/or modify // the Free Software Foundation, either version 3 of the License, or
* it under the terms of the GNU Affero General Public License as published by // (at your option) any later version.
* the Free Software Foundation, either version 3 of the License, or //
* (at your option) any later version. // GNU social is distributed in the hope that it will be useful,
* // but WITHOUT ANY WARRANTY; without even the implied warranty of
* This program is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* but WITHOUT ANY WARRANTY; without even the implied warranty of // GNU Affero General Public License for more details.
* 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
* 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/>. /**
* @copyright 2008-2010 StatusNet, Inc.
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
define('INSTALLDIR', dirname(__DIR__)); define('INSTALLDIR', dirname(__DIR__));
@ -44,16 +46,16 @@ if (have_option('i', 'id')) {
print "Can't find user with ID $id\n"; print "Can't find user with ID $id\n";
exit(1); exit(1);
} }
} else if (have_option('n', 'nickname')) { } elseif (have_option('n', 'nickname')) {
$nickname = get_option_value('n', 'nickname'); $nickname = get_option_value('n', 'nickname');
$user = User::getKV('nickname', $nickname); $user = User::getKV('nickname', $nickname);
if (empty($user)) { if (empty($user)) {
print "Can't find user with nickname '$nickname'\n"; print "Can't find user with nickname '$nickname'\n";
exit(1); exit(1);
} }
} else if (have_option('all')) { } elseif (have_option('all')) {
$user = new User(); $user = new User();
$user->whereAdd("jabber != ''"); $user->whereAdd("jabber <> ''");
$user->find(true); $user->find(true);
if ($user->N == 0) { if ($user->N == 0) {
print "No users with registered Jabber addresses in database.\n"; print "No users with registered Jabber addresses in database.\n";
@ -83,7 +85,7 @@ function clear_jabber($id)
} }
} }
echo "\n"; echo "\n";
} else if (!$user) { } elseif (!$user) {
echo "Missing user for $id\n"; echo "Missing user for $id\n";
} else { } else {
echo "Cleared jabber already for $id\n"; echo "Cleared jabber already for $id\n";

View File

@ -1,21 +1,23 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
/* // This file is part of GNU social - https://www.gnu.org/software/social
* StatusNet - a distributed open-source microblogging tool //
* Copyright (C) 2009-2010, StatusNet, Inc. // GNU social is free software: you can redistribute it and/or modify
* // it under the terms of the GNU Affero General Public License as published by
* This program is free software: you can redistribute it and/or modify // the Free Software Foundation, either version 3 of the License, or
* it under the terms of the GNU Affero General Public License as published by // (at your option) any later version.
* the Free Software Foundation, either version 3 of the License, or //
* (at your option) any later version. // GNU social is distributed in the hope that it will be useful,
* // but WITHOUT ANY WARRANTY; without even the implied warranty of
* This program is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* but WITHOUT ANY WARRANTY; without even the implied warranty of // GNU Affero General Public License for more details.
* 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
* 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/>. /**
* @copyright 2009-2010 StatusNet, Inc.
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
define('INSTALLDIR', dirname(__DIR__)); define('INSTALLDIR', dirname(__DIR__));
@ -46,7 +48,7 @@ if (have_option('i', 'id')) {
print "Can't find local or remote profile with ID $id\n"; print "Can't find local or remote profile with ID $id\n";
exit(1); exit(1);
} }
} else if (have_option('n', 'nickname')) { } elseif (have_option('n', 'nickname')) {
$nickname = get_option_value('n', 'nickname'); $nickname = get_option_value('n', 'nickname');
$user = User::getKV('nickname', $nickname); $user = User::getKV('nickname', $nickname);
if (empty($user)) { if (empty($user)) {
@ -76,7 +78,7 @@ if (have_option('--all')) {
print "Finding all notices by $profile->nickname..."; print "Finding all notices by $profile->nickname...";
} else { } else {
print "Finding notices by $profile->nickname with geolocation data..."; print "Finding notices by $profile->nickname with geolocation data...";
$notice->whereAdd("lat != ''"); $notice->whereAdd("lat <> ''");
} }
$notice->find(); $notice->find();

View File

@ -362,7 +362,8 @@ function initNoticeReshare()
$notice = new Notice(); $notice = new Notice();
$notice->whereAdd('repeat_of is not null'); $notice->whereAdd('repeat_of is not null');
$notice->whereAdd('(verb != "'.ActivityVerb::SHARE.'" OR object_type != "'.ActivityObject::ACTIVITY.'")'); $notice->whereAdd('(verb <> "' . ActivityVerb::SHARE
. '" OR object_type <> "' . ActivityObject::ACTIVITY . '")');
if ($notice->find()) { if ($notice->find()) {
while ($notice->fetch()) { while ($notice->fetch()) {
@ -580,7 +581,7 @@ function deleteMissingLocalFileThumbnails()
printfnq("Removing all local File_thumbnail entries without existing files..."); printfnq("Removing all local File_thumbnail entries without existing files...");
$thumbs = new File_thumbnail(); $thumbs = new File_thumbnail();
$thumbs->whereAdd("filename IS NOT NULL AND filename != ''"); $thumbs->whereAdd("filename IS NOT NULL AND filename <> ''");
// Checking if there were any File_thumbnail entries without filename // Checking if there were any File_thumbnail entries without filename
if ($thumbs->find()) { if ($thumbs->find()) {
while ($thumbs->fetch()) { while ($thumbs->fetch()) {
@ -603,7 +604,7 @@ function setFilehashOnLocalFiles()
printfnq('Ensuring all local files have the filehash field set...'); printfnq('Ensuring all local files have the filehash field set...');
$file = new File(); $file = new File();
$file->whereAdd("filename IS NOT NULL AND filename != ''"); // local files $file->whereAdd("filename IS NOT NULL AND filename <> ''"); // local files
$file->whereAdd('filehash IS NULL', 'AND'); // without filehash value $file->whereAdd('filehash IS NULL', 'AND'); // without filehash value
if ($file->find()) { if ($file->find()) {