[DATABASE] Check SQL boolean values with "IS TRUE"
This way UNKNOWN (NULL) explicitly turns to FALSE when three-valued logic is
reduced to binary.
In pgsqlschema, however, use "IS FALSE" as boolean attributes in pg_index are
non-nullable, there is no outer join and there's no clear preference for NULL
reduction.
Over-complicated constructions in TagCloud queries have been simplified, which
should not affect their performance.
Additionally, in TagCloud's lib/subscriptionspeopleselftagcloudsection.php
a typing mistake in an equi-join of "profile_tag" and "profile_list" on
"tagger" was fixed.
That regression was introduced in f446db8e2a
This commit is contained in:
parent
a996ac797a
commit
e902a9bdfc
|
@ -1,39 +1,32 @@
|
|||
<?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
|
||||
*
|
||||
* Lists by a user
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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 Personal
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Shashi Gowda <connect2shashi@gmail.com>
|
||||
* @copyright 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/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/peopletaglist.php';
|
||||
// cache 3 pages
|
||||
|
@ -41,15 +34,15 @@ define('PEOPLETAG_CACHE_WINDOW', PEOPLETAGS_PER_PAGE*3 + 1);
|
|||
|
||||
class PeopletagAction extends Action
|
||||
{
|
||||
var $page = null;
|
||||
var $tag = null;
|
||||
public $page = null;
|
||||
public $tag = null;
|
||||
|
||||
function isReadOnly($args)
|
||||
public function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
// TRANS: Title for list page.
|
||||
|
@ -62,7 +55,7 @@ class PeopletagAction extends Action
|
|||
}
|
||||
}
|
||||
|
||||
function prepare(array $args = array())
|
||||
public function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
|
@ -84,19 +77,19 @@ class PeopletagAction extends Action
|
|||
return true;
|
||||
}
|
||||
|
||||
function handle()
|
||||
public function handle()
|
||||
{
|
||||
parent::handle();
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
function showLocalNav()
|
||||
public function showLocalNav()
|
||||
{
|
||||
$nav = new PublicGroupNav($this);
|
||||
$nav->show();
|
||||
}
|
||||
|
||||
function showAnonymousMessage()
|
||||
public function showAnonymousMessage()
|
||||
{
|
||||
$notice =
|
||||
// TRANS: Message for anonymous users on list page.
|
||||
|
@ -106,13 +99,13 @@ class PeopletagAction extends Action
|
|||
'(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
|
||||
'You can then easily keep track of what they ' .
|
||||
'are doing by subscribing to the list\'s timeline.' );
|
||||
"are doing by subscribing to the list's timeline.");
|
||||
$this->elementStart('div', array('id' => 'anon_notice'));
|
||||
$this->raw(common_markup_to_html($notice));
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
$offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
|
||||
$limit = PEOPLETAGS_PER_PAGE + 1;
|
||||
|
@ -143,9 +136,15 @@ class PeopletagAction extends Action
|
|||
$ptags->find();
|
||||
}
|
||||
} else {
|
||||
$ptags->whereAdd('(profile_list.private = false OR (' .
|
||||
' profile_list.tagger =' . $user->id .
|
||||
' AND profile_list.private = true) )');
|
||||
$ptags->whereAdd(sprintf(
|
||||
<<<'END'
|
||||
(
|
||||
(profile_list.tagger = %d AND profile_list.private IS TRUE)
|
||||
OR profile_list.private IS NOT TRUE
|
||||
)
|
||||
END,
|
||||
$user->getID()
|
||||
));
|
||||
|
||||
$ptags->orderBy('profile_list.modified DESC');
|
||||
$ptags->find();
|
||||
|
@ -154,11 +153,16 @@ class PeopletagAction extends Action
|
|||
$pl = new PeopletagList($ptags, $this);
|
||||
$cnt = $pl->show();
|
||||
|
||||
$this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
|
||||
$this->page, 'peopletag', array('tag' => $this->tag));
|
||||
$this->pagination(
|
||||
($this->page > 1),
|
||||
($cnt > PEOPLETAGS_PER_PAGE),
|
||||
$this->page,
|
||||
'peopletag',
|
||||
['tag' => $this->tag]
|
||||
);
|
||||
}
|
||||
|
||||
function showSections()
|
||||
public function showSections()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,10 +107,10 @@ class SelftagAction extends Action
|
|||
|
||||
$user = common_current_user();
|
||||
if (empty($user)) {
|
||||
$qry .= 'AND profile_list.private = false ';
|
||||
$qry .= 'AND profile_list.private IS NOT TRUE ';
|
||||
} else {
|
||||
$qry .= 'AND (profile_list.tagger = ' . $user->id .
|
||||
' OR profile_list.private = false) ';
|
||||
' OR profile_list.private IS NOT TRUE) ';
|
||||
}
|
||||
|
||||
$qry .= 'ORDER BY profile_tag.modified DESC ' .
|
||||
|
|
|
@ -504,13 +504,13 @@ class Profile extends Managed_DataObject
|
|||
|
||||
if (!is_null($scoped)) {
|
||||
$qry .= sprintf(
|
||||
'AND ( profile_list.private = false ' .
|
||||
'AND ( profile_list.private IS NOT TRUE ' .
|
||||
'OR ( profile_list.tagger = %d AND ' .
|
||||
'profile_list.private = TRUE ) )',
|
||||
'profile_list.private IS TRUE ) )',
|
||||
$scoped->getID()
|
||||
);
|
||||
} else {
|
||||
$qry .= 'AND profile_list.private = FALSE ';
|
||||
$qry .= 'AND profile_list.private IS NOT TRUE ';
|
||||
}
|
||||
|
||||
if ($since > 0) {
|
||||
|
|
|
@ -95,7 +95,7 @@ class Profile_tag extends Managed_DataObject
|
|||
$qry = sprintf($qry, $tagger, $tagged);
|
||||
|
||||
if (!$include_priv) {
|
||||
$qry .= ' AND profile_list.private = FALSE';
|
||||
$qry .= ' AND profile_list.private IS NOT TRUE';
|
||||
}
|
||||
|
||||
$profile_list->query($qry);
|
||||
|
@ -121,7 +121,7 @@ class Profile_tag extends Managed_DataObject
|
|||
);
|
||||
|
||||
if (!$scoped instanceof Profile || $scoped->getID() !== $tagger) {
|
||||
$qry .= 'AND profile_list.private = FALSE';
|
||||
$qry .= 'AND profile_list.private IS NOT TRUE';
|
||||
}
|
||||
|
||||
$tags = array();
|
||||
|
|
|
@ -299,8 +299,11 @@ class User_group extends Managed_DataObject
|
|||
public function getAdmins($offset = null, $limit = null)
|
||||
{
|
||||
$admins = new Profile();
|
||||
$admins->joinAdd(array('id', 'group_member:profile_id'));
|
||||
$admins->whereAdd('group_member.group_id = ' . $this->id . ' AND group_member.is_admin = true');
|
||||
$admins->joinAdd(['id', 'group_member:profile_id']);
|
||||
$admins->whereAdd(sprintf(
|
||||
'group_member.group_id = %d AND group_member.is_admin IS TRUE',
|
||||
$this->getID()
|
||||
));
|
||||
$admins->orderBy('group_member.modified ASC');
|
||||
$admins->limit($offset, $limit);
|
||||
$admins->find();
|
||||
|
|
|
@ -260,14 +260,20 @@ class MysqlSchema extends Schema
|
|||
*/
|
||||
public function fetchIndexInfo(string $table): array
|
||||
{
|
||||
$query = 'SELECT INDEX_NAME AS `key_name`, INDEX_TYPE AS `key_type`, COLUMN_NAME AS `col` ' .
|
||||
'FROM INFORMATION_SCHEMA.STATISTICS ' .
|
||||
'WHERE TABLE_SCHEMA = \'%s\' AND TABLE_NAME = \'%s\' AND NON_UNIQUE = TRUE ' .
|
||||
'AND INDEX_NAME NOT IN (SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME IS NOT NULL) ' .
|
||||
'ORDER BY SEQ_IN_INDEX';
|
||||
$schema = $this->conn->dsn['database'];
|
||||
$sql = sprintf($query, $schema, $table);
|
||||
$data = $this->fetchQueryData($sql);
|
||||
$data = $this->fetchQueryData(
|
||||
<<<END
|
||||
SELECT INDEX_NAME AS `key_name`, INDEX_TYPE AS `key_type`, COLUMN_NAME AS `col`
|
||||
FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE TABLE_SCHEMA = '{$schema}' AND TABLE_NAME = '{$table}'
|
||||
AND NON_UNIQUE IS TRUE
|
||||
AND INDEX_NAME NOT IN (
|
||||
SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
||||
WHERE REFERENCED_TABLE_NAME IS NOT NULL
|
||||
)
|
||||
ORDER BY SEQ_IN_INDEX;
|
||||
END
|
||||
);
|
||||
|
||||
$rows = [];
|
||||
foreach ($data as $row) {
|
||||
|
|
|
@ -201,12 +201,16 @@ class PgsqlSchema extends Schema
|
|||
*/
|
||||
public function fetchIndexInfo(string $table): array
|
||||
{
|
||||
$query = 'SELECT indexname AS key_name, indexdef AS key_def, pg_index.* ' .
|
||||
'FROM pg_index INNER JOIN pg_indexes ON pg_index.indexrelid = CAST(pg_indexes.indexname AS regclass) ' .
|
||||
'WHERE tablename = \'%s\' AND indisprimary = FALSE AND indisunique = FALSE ' .
|
||||
'ORDER BY indrelid, indexrelid';
|
||||
$sql = sprintf($query, $table);
|
||||
return $this->fetchQueryData($sql);
|
||||
return $this->fetchQueryData(
|
||||
<<<END
|
||||
SELECT indexname AS key_name, indexdef AS key_def, pg_index.*
|
||||
FROM pg_index INNER JOIN pg_indexes
|
||||
ON pg_index.indexrelid = CAST(pg_indexes.indexname AS regclass)
|
||||
WHERE pg_indexes.tablename = '{$table}'
|
||||
AND indisprimary IS FALSE AND indisunique IS FALSE
|
||||
ORDER BY indrelid, indexrelid;
|
||||
END
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,26 +34,28 @@ defined('GNUSOCIAL') || die();
|
|||
*/
|
||||
class PeopletagsBySubsSection extends PeopletagSection
|
||||
{
|
||||
function getPeopletags()
|
||||
public function getPeopletags()
|
||||
{
|
||||
$limit = PEOPLETAGS_PER_SECTION;
|
||||
|
||||
$qry = 'SELECT profile_list.*, subscriber_count AS value ' .
|
||||
'FROM profile_list WHERE profile_list.private = FALSE ' .
|
||||
'ORDER BY value DESC ' .
|
||||
'LIMIT ' . $limit;
|
||||
$qry = <<<END
|
||||
SELECT profile_list.*, subscriber_count AS value
|
||||
FROM profile_list WHERE profile_list.private IS NOT TRUE
|
||||
ORDER BY value DESC
|
||||
LIMIT {$limit};
|
||||
END;
|
||||
|
||||
$peopletag = Memcached_DataObject::cachedQuery('Profile_list', $qry, 3600);
|
||||
return $peopletag;
|
||||
}
|
||||
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title for section contaning lists with the most subscribers.
|
||||
return _('Popular lists');
|
||||
}
|
||||
|
||||
function divId()
|
||||
public function divId()
|
||||
{
|
||||
return 'top_peopletags_by_subs';
|
||||
}
|
||||
|
|
|
@ -434,11 +434,11 @@ function mail_broadcast_notice_sms($notice)
|
|||
// Users (other than the sender) who `want SMS notices':
|
||||
'WHERE %1$s.id <> %2$d ' .
|
||||
'AND %1$s.smsemail IS NOT NULL ' .
|
||||
'AND %1$s.smsnotify = TRUE ' .
|
||||
'AND %1$s.smsnotify IS TRUE ' .
|
||||
// ... where either the user _is_ subscribed to the sender
|
||||
// (any of the "subscription" fields IS NOT NULL)
|
||||
// and wants to get SMS for all of this scribe's notices...
|
||||
'AND (subscription.sms = TRUE ' .
|
||||
'AND (subscription.sms IS TRUE ' .
|
||||
// ... or where the user was mentioned in
|
||||
// or replied-to with the notice:
|
||||
$repliesQry .
|
||||
|
|
|
@ -83,9 +83,14 @@ function silencespammer($filter, $user, $minimum, $percent)
|
|||
|
||||
$ss = new Spam_score();
|
||||
|
||||
$ss->query(sprintf("SELECT count(*) as spam_count ".
|
||||
"FROM notice join spam_score on notice.id = spam_score.notice_id ".
|
||||
'WHERE notice.profile_id = %d AND spam_score.is_spam = TRUE', $profile->id));
|
||||
$ss->query(sprintf(
|
||||
<<<'END'
|
||||
SELECT COUNT(*) AS spam_count
|
||||
FROM notice INNER JOIN spam_score ON notice.id = spam_score.notice_id
|
||||
WHERE notice.profile_id = %d AND spam_score.is_spam IS TRUE;
|
||||
END,
|
||||
$profile->getID()
|
||||
));
|
||||
|
||||
while ($ss->fetch()) {
|
||||
$spam_count = $ss->spam_count;
|
||||
|
|
|
@ -1,58 +1,61 @@
|
|||
<?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
|
||||
*
|
||||
* Personal tag cloud section
|
||||
*
|
||||
* 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 Widget
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 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/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Personal tag cloud section
|
||||
*
|
||||
* @category Widget
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @category Widget
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class SubscribersPeopleSelfTagCloudSection extends SubPeopleTagCloudSection
|
||||
{
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title of personal tag cloud section.
|
||||
return _('People Tagcloud as self-tagged');
|
||||
}
|
||||
|
||||
function query() {
|
||||
// return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscribed != subscriber and tagger = tagged group by tag order by weight desc';
|
||||
|
||||
return 'select profile_tag.tag, count(profile_tag.tag) as weight from subscription left join (profile_tag, profile_list) on profile_list.tag = profile_tag.tag and profile_list.tagger = profile_tag.tagger and profile_tag.tagger = subscriber where subscribed=%d and subscribed != subscriber and profile_tag.tagger = tagged and profile_list.private = false and profile_tag.tag is not null group by profile_tag.tag order by weight desc';
|
||||
|
||||
// return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscribed where subscriber=%d and subscribed != subscriber and tagger = tagged and tag is not null group by tag order by weight desc';
|
||||
public function query()
|
||||
{
|
||||
return <<<'END'
|
||||
SELECT profile_tag.tag, COUNT(profile_tag.tag) AS weight
|
||||
FROM profile_tag
|
||||
INNER JOIN subscription AS sub
|
||||
ON profile_tag.tagger = sub.subscriber
|
||||
LEFT JOIN profile_list
|
||||
ON profile_tag.tag = profile_list.tag
|
||||
AND profile_tag.tagger = profile_list.tagger
|
||||
WHERE profile_tag.tagger = profile_tag.tagged
|
||||
AND profile_list.private IS NOT TRUE
|
||||
AND sub.subscribed = %d AND sub.subscribed <> sub.subscriber
|
||||
GROUP BY profile_tag.tag ORDER BY weight DESC;
|
||||
END;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,60 +1,67 @@
|
|||
<?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
|
||||
*
|
||||
* Personal tag cloud section
|
||||
*
|
||||
* 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 Widget
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 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/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Personal tag cloud section
|
||||
*
|
||||
* @category Widget
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @category Widget
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class SubscribersPeopleTagCloudSection extends SubPeopleTagCloudSection
|
||||
{
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title of personal tag cloud section.
|
||||
return _('People Tagcloud as tagged');
|
||||
}
|
||||
|
||||
function tagUrl($tag) {
|
||||
public function tagUrl($tag)
|
||||
{
|
||||
$nickname = $this->out->profile->nickname;
|
||||
return common_local_url('subscribers', array('nickname' => $nickname, 'tag' => $tag));
|
||||
}
|
||||
|
||||
function query() {
|
||||
// return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagged and subscribed=tagger where subscribed=%d and subscriber != subscribed group by tag order by weight desc';
|
||||
return 'select profile_tag.tag, count(profile_tag.tag) as weight from subscription left join (profile_tag, profile_list) on subscriber=profile_tag.tagged and subscribed=profile_tag.tagger and profile_tag.tagger = profile_list.tagger and profile_tag.tag = profile_list.tag where subscribed=%d and subscriber != subscribed and profile_list.private = false and profile_tag.tag is not null group by profile_tag.tag order by weight desc';
|
||||
public function query()
|
||||
{
|
||||
return <<<'END'
|
||||
SELECT profile_tag.tag, COUNT(profile_tag.tag) AS weight
|
||||
FROM profile_tag
|
||||
INNER JOIN subscription AS sub
|
||||
ON profile_tag.tagged = sub.subscriber
|
||||
AND profile_tag.tagger = sub.subscribed
|
||||
LEFT JOIN profile_list
|
||||
ON profile_tag.tagger = profile_list.tagger
|
||||
AND profile_tag.tag = profile_list.tag
|
||||
WHERE profile_list.private IS NOT TRUE
|
||||
AND sub.subscribed = %d AND sub.subscriber <> sub.subscribed
|
||||
GROUP BY profile_tag.tag ORDER BY weight DESC;
|
||||
END;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,58 +1,61 @@
|
|||
<?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
|
||||
*
|
||||
* Personal tag cloud section
|
||||
*
|
||||
* 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 Widget
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 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/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Personal tag cloud section
|
||||
*
|
||||
* @category Widget
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @category Widget
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class SubscriptionsPeopleSelfTagCloudSection extends SubPeopleTagCloudSection
|
||||
{
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title of personal tag cloud section.
|
||||
return _('People Tagcloud as self-tagged');
|
||||
}
|
||||
|
||||
function query() {
|
||||
// return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscriber != subscribed and tagger = tagged group by tag order by weight desc';
|
||||
|
||||
return 'select profile_tag.tag, count(profile_tag.tag) as weight from subscription left join (profile_tag, profile_list) on profile_tag.tagger = subscribed and profile_tag.tag = profile_list.tag and profile_tag.tagger = profile_tag.tagger where subscriber=%d and subscribed != subscriber and profile_tag.tagger = profile_tag.tagged and profile_list.private = false and profile_tag.tag is not null group by profile_tag.tag order by weight desc';
|
||||
|
||||
// return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscribed != subscriber and tagger = tagged and tag is not null group by tag order by weight desc';
|
||||
public function query()
|
||||
{
|
||||
return <<<'END'
|
||||
SELECT profile_tag.tag, COUNT(profile_tag.tag) AS weight
|
||||
FROM profile_tag
|
||||
INNER JOIN subscription AS sub
|
||||
ON profile_tag.tagger = sub.subscribed
|
||||
LEFT JOIN profile_list
|
||||
ON profile_tag.tag = profile_list.tag
|
||||
AND profile_tag.tagger = profile_list.tagger
|
||||
WHERE profile_tag.tagger = profile_tag.tagged
|
||||
AND profile_list.private IS NOT TRUE
|
||||
AND sub.subscriber = %d AND sub.subscribed <> sub.subscriber
|
||||
GROUP BY profile_tag.tag ORDER BY weight DESC;
|
||||
END;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,60 +1,67 @@
|
|||
<?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
|
||||
*
|
||||
* Personal tag cloud section
|
||||
*
|
||||
* 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 Widget
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 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/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Personal tag cloud section
|
||||
*
|
||||
* @category Widget
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @category Widget
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class SubscriptionsPeopleTagCloudSection extends SubPeopleTagCloudSection
|
||||
{
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title of personal tag cloud section.
|
||||
return _('People Tagcloud as tagged');
|
||||
}
|
||||
|
||||
function tagUrl($tag) {
|
||||
public function tagUrl($tag)
|
||||
{
|
||||
$nickname = $this->out->profile->nickname;
|
||||
return common_local_url('subscriptions', array('nickname' => $nickname, 'tag' => $tag));
|
||||
}
|
||||
|
||||
function query() {
|
||||
// return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagger and subscribed=tagged where subscriber=%d and subscriber != subscribed group by tag order by weight desc';
|
||||
return 'select profile_tag.tag, count(profile_tag.tag) as weight from subscription left join (profile_tag, profile_list) on subscriber=profile_tag.tagger and subscribed=tagged and profile_tag.tag = profile_list.tag and profile_tag.tagger = profile_list.tagger where subscriber=%d and subscriber != subscribed and profile_list.private = false and profile_tag.tag is not null group by profile_tag.tag order by weight desc';
|
||||
public function query()
|
||||
{
|
||||
return <<<'END'
|
||||
SELECT profile_tag.tag, COUNT(profile_tag.tag) AS weight
|
||||
FROM profile_tag
|
||||
INNER JOIN subscription AS sub
|
||||
ON profile_tag.tagger = sub.subscriber
|
||||
AND profile_tag.tagged = sub.subscribed
|
||||
LEFT JOIN profile_list
|
||||
ON profile_tag.tag = profile_list.tag
|
||||
AND profile_tag.tagger = profile_list.tagger
|
||||
WHERE profile_list.private IS NOT TRUE
|
||||
AND sub.subscriber = %d AND sub.subscriber <> sub.subscribed
|
||||
GROUP BY profile_tag.tag ORDER BY weight DESC;
|
||||
END;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user