[DATABASE] Introduce a bool type in schema
PostgreSQL has a clear distinction between integers and booleans, so it makes sense to draw a clear line.
This commit is contained in:
@@ -1,47 +1,38 @@
|
||||
<?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.
|
||||
*
|
||||
* Score of a notice by activity spam service
|
||||
*
|
||||
* 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 Spam
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Score of a notice per the activity spam service
|
||||
*
|
||||
* @category Spam
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
class Spam_score extends Managed_DataObject
|
||||
{
|
||||
@@ -54,7 +45,6 @@ class Spam_score extends Managed_DataObject
|
||||
|
||||
public static function save($notice, $result)
|
||||
{
|
||||
|
||||
$orig = null;
|
||||
$score = Spam_score::getKV('notice_id', $notice->id);
|
||||
|
||||
@@ -98,7 +88,7 @@ class Spam_score extends Managed_DataObject
|
||||
'description' => 'score for the notice (0.0, 1.0)'),
|
||||
'scaled' => array('type' => 'int',
|
||||
'description' => 'scaled score for the notice (0, 10000)'),
|
||||
'is_spam' => array('type' => 'tinyint',
|
||||
'is_spam' => array('type' => 'bool',
|
||||
'description' => 'flag for spamosity'),
|
||||
'created' => array('type' => 'datetime',
|
||||
'not null' => true,
|
||||
@@ -146,7 +136,7 @@ class Spam_score extends Managed_DataObject
|
||||
if ($score->find()) {
|
||||
while ($score->fetch()) {
|
||||
$orig = clone($score);
|
||||
$score->is_spam = ($score->score >= 0.90) ? 1 : 0;
|
||||
$score->is_spam = ($score->score >= 0.90) ? true : false;
|
||||
$score->update($orig);
|
||||
}
|
||||
}
|
||||
@@ -169,9 +159,8 @@ class Spam_score extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
function saveNew($notice, $result)
|
||||
public function saveNew($notice, $result)
|
||||
{
|
||||
|
||||
$score = new Spam_score();
|
||||
|
||||
$score->notice_id = $notice->id;
|
@@ -1,52 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2012, StatusNet, Inc.
|
||||
*
|
||||
* Spam notice stream
|
||||
*
|
||||
* 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 Spam
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2012 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Spam notice stream
|
||||
*
|
||||
* @category Spam
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2012 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Spam notice stream
|
||||
*
|
||||
* @copyright 2012 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
*/
|
||||
class SpamNoticeStream extends ScopingNoticeStream
|
||||
{
|
||||
function __construct(Profile $scoped=null)
|
||||
public function __construct(Profile $scoped = null)
|
||||
{
|
||||
parent::__construct(new CachingNoticeStream(new RawSpamNoticeStream(), 'spam_score:notice_ids'),
|
||||
$scoped);
|
||||
parent::__construct(
|
||||
new CachingNoticeStream(new RawSpamNoticeStream(), 'spam_score:notice_ids'),
|
||||
$scoped
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,20 +47,16 @@ class SpamNoticeStream extends ScopingNoticeStream
|
||||
* Raw stream of spammy notices
|
||||
*
|
||||
* @category Stream
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class RawSpamNoticeStream extends NoticeStream
|
||||
{
|
||||
function getNoticeIds($offset, $limit, $since_id, $max_id)
|
||||
public function getNoticeIds($offset, $limit, $since_id, $max_id)
|
||||
{
|
||||
$ss = new Spam_score();
|
||||
|
||||
$ss->is_spam = 1;
|
||||
$ss->is_spam = true;
|
||||
|
||||
$ss->selectAdd();
|
||||
$ss->selectAdd('notice_id');
|
||||
|
@@ -1,20 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2013 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/>.
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* @copyright 2013 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
|
||||
@@ -33,13 +35,13 @@ END_OF_SILENCESPAMMER_HELP;
|
||||
|
||||
require_once INSTALLDIR.'/scripts/commandline.inc';
|
||||
|
||||
function testAllUsers($filter, $minimum, $percent) {
|
||||
function testAllUsers($filter, $minimum, $percent)
|
||||
{
|
||||
$found = false;
|
||||
$offset = 0;
|
||||
$limit = 1000;
|
||||
|
||||
do {
|
||||
|
||||
$user = new User();
|
||||
$user->orderBy('created');
|
||||
$user->limit($offset, $limit);
|
||||
@@ -56,37 +58,36 @@ function testAllUsers($filter, $minimum, $percent) {
|
||||
}
|
||||
$offset += $found;
|
||||
}
|
||||
|
||||
} while ($found > 0);
|
||||
}
|
||||
|
||||
function silencespammer($filter, $user, $minimum, $percent) {
|
||||
|
||||
function silencespammer($filter, $user, $minimum, $percent)
|
||||
{
|
||||
printfnq("Testing user %s\n", $user->nickname);
|
||||
|
||||
$profile = Profile::getKV('id', $user->id);
|
||||
|
||||
if ($profile->isSilenced()) {
|
||||
printfnq("Already silenced %s\n", $user->nickname);
|
||||
return;
|
||||
printfnq("Already silenced %s\n", $user->nickname);
|
||||
return;
|
||||
}
|
||||
|
||||
$cnt = $profile->noticeCount();
|
||||
|
||||
if ($cnt < $minimum) {
|
||||
printfnq("Only %d notices posted (minimum %d); skipping\n", $cnt, $minimum);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
$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 = 1", $profile->id));
|
||||
'WHERE notice.profile_id = %d AND spam_score.is_spam = TRUE', $profile->id));
|
||||
|
||||
while ($ss->fetch()) {
|
||||
$spam_count = $ss->spam_count;
|
||||
}
|
||||
}
|
||||
|
||||
$spam_percent = ($spam_count * 100.0 / $cnt);
|
||||
|
||||
@@ -94,10 +95,10 @@ function silencespammer($filter, $user, $minimum, $percent) {
|
||||
printfnq("Silencing user %s (%d/%d = %0.2f%% spam)\n", $user->nickname, $spam_count, $cnt, $spam_percent);
|
||||
try {
|
||||
$profile->silence();
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
printfnq("Error: %s", $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
@@ -1,35 +1,30 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Data class for email summary status
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Data
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2010, 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/>.
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010, StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
|
||||
@@ -38,19 +33,17 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
*
|
||||
* Email summary information for users
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @category Action
|
||||
* @copyright 2010, StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
class Email_summary_status extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'email_summary_status'; // table name
|
||||
public $user_id; // int(4) primary_key not_null
|
||||
public $send_summary; // tinyint not_null
|
||||
public $send_summary; // bool not_null default_true
|
||||
public $last_summary_id; // int(4) null
|
||||
public $created; // datetime not_null
|
||||
public $modified; // datetime not_null
|
||||
@@ -60,9 +53,9 @@ class Email_summary_status extends Managed_DataObject
|
||||
return array(
|
||||
'fields' => array(
|
||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
||||
'send_summary' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'not null' => true, 'description' => 'whether to send a summary or not'),
|
||||
'send_summary' => array('type' => 'bool', 'default' => true, 'not null' => true, 'description' => 'whether to send a summary or not'),
|
||||
'last_summary_id' => array('type' => 'int', 'description' => 'last summary id'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('user_id'),
|
||||
@@ -79,7 +72,7 @@ class Email_summary_status extends Managed_DataObject
|
||||
*
|
||||
* @return int flag for whether to send this user a summary email
|
||||
*/
|
||||
static function getSendSummary($user_id)
|
||||
public static function getSendSummary($user_id)
|
||||
{
|
||||
$ess = Email_summary_status::getKV('user_id', $user_id);
|
||||
|
||||
@@ -97,7 +90,7 @@ class Email_summary_status extends Managed_DataObject
|
||||
*
|
||||
* @return Email_summary_status instance for this user, with count already incremented.
|
||||
*/
|
||||
static function getLastSummaryID($user_id)
|
||||
public static function getLastSummaryID($user_id)
|
||||
{
|
||||
$ess = Email_summary_status::getKV('user_id', $user_id);
|
||||
|
||||
|
@@ -1,35 +1,30 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Data class for counting greetings
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Data
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @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/>.
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2009, StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
|
||||
@@ -44,19 +39,17 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
* extension of DB_DataObject that provides caching, internationalization,
|
||||
* and other bits of good functionality to StatusNet-specific data classes.
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @category Action
|
||||
* @copyright 2009, StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
class User_followeveryone_prefs extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'user_followeveryone_prefs'; // table name
|
||||
public $user_id; // int(4) primary_key not_null
|
||||
public $followeveryone; // tinyint(1)
|
||||
public $followeveryone; // bool default_true
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
@@ -65,7 +58,7 @@ class User_followeveryone_prefs extends Managed_DataObject
|
||||
return array(
|
||||
'fields' => array(
|
||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
||||
'followeveryone' => array('type' => 'int', 'default' => 1, 'size' => 'tiny', 'description' => 'whether to follow everyone'),
|
||||
'followeveryone' => array('type' => 'bool', 'default' => true, 'description' => 'whether to follow everyone'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
@@ -76,7 +69,7 @@ class User_followeveryone_prefs extends Managed_DataObject
|
||||
);
|
||||
}
|
||||
|
||||
static function followEveryone($user_id)
|
||||
public static function followEveryone($user_id)
|
||||
{
|
||||
$ufep = self::getKV('user_id', $user_id);
|
||||
|
||||
@@ -87,7 +80,7 @@ class User_followeveryone_prefs extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
static function savePref($user_id, $followEveryone)
|
||||
public static function savePref($user_id, $followEveryone)
|
||||
{
|
||||
$ufep = self::getKV('user_id', $user_id);
|
||||
|
||||
|
@@ -1,52 +1,37 @@
|
||||
<?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) 2012, StatusNet, Inc.
|
||||
*
|
||||
* ModLogPlugin.php
|
||||
*
|
||||
* 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 Moderation
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2012 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
// This check helps protect against security problems;
|
||||
// your code file can't be executed directly from the web.
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Moderation logging
|
||||
*
|
||||
* Shows a history of moderation for this user in the sidebar
|
||||
*
|
||||
* @category Moderation
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2012 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
class ModLogPlugin extends Plugin
|
||||
{
|
||||
const PLUGIN_VERSION = '2.0.0';
|
||||
@@ -63,7 +48,7 @@ class ModLogPlugin extends Plugin
|
||||
* @return boolean hook value; true means continue processing, false means stop.
|
||||
*/
|
||||
|
||||
function onCheckSchema()
|
||||
public function onCheckSchema()
|
||||
{
|
||||
$schema = Schema::get();
|
||||
|
||||
@@ -72,7 +57,7 @@ class ModLogPlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
function onEndGrantRole($profile, $role)
|
||||
public function onEndGrantRole($profile, $role)
|
||||
{
|
||||
$modlog = new ModLog();
|
||||
|
||||
@@ -86,7 +71,7 @@ class ModLogPlugin extends Plugin
|
||||
}
|
||||
|
||||
$modlog->role = $role;
|
||||
$modlog->is_grant = 1;
|
||||
$modlog->is_grant = true;
|
||||
$modlog->created = common_sql_now();
|
||||
|
||||
$modlog->insert();
|
||||
@@ -94,7 +79,7 @@ class ModLogPlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
function onEndRevokeRole($profile, $role)
|
||||
public function onEndRevokeRole($profile, $role)
|
||||
{
|
||||
$modlog = new ModLog();
|
||||
|
||||
@@ -109,7 +94,7 @@ class ModLogPlugin extends Plugin
|
||||
}
|
||||
|
||||
$modlog->role = $role;
|
||||
$modlog->is_grant = 0;
|
||||
$modlog->is_grant = false;
|
||||
$modlog->created = common_sql_now();
|
||||
|
||||
$modlog->insert();
|
||||
@@ -117,7 +102,7 @@ class ModLogPlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
function onEndShowSections(Action $action)
|
||||
public function onEndShowSections(Action $action)
|
||||
{
|
||||
if (!$action instanceof ShowstreamAction) {
|
||||
// early return for actions we're not interested in
|
||||
@@ -140,7 +125,6 @@ class ModLogPlugin extends Plugin
|
||||
$cnt = $ml->find();
|
||||
|
||||
if ($cnt > 0) {
|
||||
|
||||
$action->elementStart('div', array('id' => 'entity_mod_log',
|
||||
'class' => 'section'));
|
||||
|
||||
@@ -158,9 +142,14 @@ class ModLogPlugin extends Plugin
|
||||
if (empty($mod)) {
|
||||
$action->text(_('[unknown]'));
|
||||
} else {
|
||||
$action->element('a', array('href' => $mod->getUrl(),
|
||||
'title' => $mod->getFullname()),
|
||||
$mod->getNickname());
|
||||
$action->element(
|
||||
'a',
|
||||
[
|
||||
'href' => $mod->getUrl(),
|
||||
'title' => $mod->getFullname(),
|
||||
],
|
||||
$mod->getNickname()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$action->text(_('[unknown]'));
|
||||
@@ -175,7 +164,8 @@ class ModLogPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
function onUserRightsCheck($profile, $right, &$result) {
|
||||
public function onUserRightsCheck($profile, $right, &$result)
|
||||
{
|
||||
switch ($right) {
|
||||
case self::VIEWMODLOG:
|
||||
$result = ($profile->hasRole(Profile_role::MODERATOR) || $profile->hasRole('modhelper'));
|
||||
|
@@ -1,49 +1,37 @@
|
||||
<?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) 2012, StatusNet, Inc.
|
||||
*
|
||||
* ModLog.php -- data object to store moderation logs
|
||||
*
|
||||
* 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/>.
|
||||
* Data object to store moderation logs
|
||||
*
|
||||
* @category Moderation
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2012 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Class comment here
|
||||
* @copyright 2012 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @category Category here
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
|
||||
class ModLog extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'mod_log'; // table name
|
||||
@@ -52,7 +40,7 @@ class ModLog extends Managed_DataObject
|
||||
public $profile_id; // profile id
|
||||
public $moderator_id; // profile id
|
||||
public $role; // the role
|
||||
public $grant; // 1 = grant, 0 = revoke
|
||||
public $is_grant; // true = grant, false = revoke
|
||||
public $created; // datetime
|
||||
|
||||
/**
|
||||
@@ -75,9 +63,8 @@ class ModLog extends Managed_DataObject
|
||||
'length' => 32,
|
||||
'not null' => true,
|
||||
'description' => 'role granted or revoked'),
|
||||
'is_grant' => array('type' => 'int',
|
||||
'size' => 'tiny',
|
||||
'default' => 1,
|
||||
'is_grant' => array('type' => 'bool',
|
||||
'default' => true,
|
||||
'description' => 'Was this a grant or revocation of a role'),
|
||||
'created' => array('type' => 'datetime',
|
||||
'not null' => true,
|
||||
|
@@ -1,35 +1,30 @@
|
||||
<?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
|
||||
*
|
||||
* Settings for OpenID
|
||||
*
|
||||
* 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
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once INSTALLDIR.'/plugins/OpenID/openid.php';
|
||||
|
||||
@@ -38,11 +33,8 @@ require_once INSTALLDIR.'/plugins/OpenID/openid.php';
|
||||
*
|
||||
* Lets users add, edit and delete OpenIDs from their account
|
||||
*
|
||||
* @category Settings
|
||||
* @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/
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class OpenidsettingsAction extends SettingsAction
|
||||
{
|
||||
@@ -100,17 +92,26 @@ class OpenidsettingsAction extends SettingsAction
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label.
|
||||
$this->input('openid_url', _m('OpenID URL'), null,
|
||||
// TRANS: Form guide.
|
||||
_m('An OpenID URL which identifies you.'),
|
||||
null, true,
|
||||
['placeholder'=>'https://example.com/you']);
|
||||
$this->input(
|
||||
'openid_url',
|
||||
_m('OpenID URL'),
|
||||
null,
|
||||
// TRANS: Form guide.
|
||||
_m('An OpenID URL which identifies you.'),
|
||||
null,
|
||||
true,
|
||||
['placeholder' => 'https://example.com/you']
|
||||
);
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label.
|
||||
$this->checkbox('openid-synch', _m('Synchronize Account'), false,
|
||||
// TRANS: Form guide.
|
||||
_m('Synchronize GNU social profile with this OpenID identity.'));
|
||||
$this->checkbox(
|
||||
'openid-synch',
|
||||
_m('Synchronize Account'),
|
||||
false,
|
||||
// TRANS: Form guide.
|
||||
_m('Synchronize GNU social profile with this OpenID identity.')
|
||||
);
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
// TRANS: Button text for adding an OpenID URL.
|
||||
@@ -129,13 +130,16 @@ class OpenidsettingsAction extends SettingsAction
|
||||
$this->element('h2', null, _m('HEADER', 'OpenID Actions'));
|
||||
|
||||
if ($cnt == 1 && !$this->scoped->hasPassword()) {
|
||||
$this->element('p', 'form_guide',
|
||||
// TRANS: Form guide.
|
||||
_m('You can\'t remove your main OpenID account ' .
|
||||
'without either adding a password to your ' .
|
||||
'GNU social account or another OpenID account. ' .
|
||||
'You can synchronize your profile with your ' .
|
||||
'OpenID by clicking the button labeled "Synchronize".'));
|
||||
$this->element(
|
||||
'p',
|
||||
'form_guide',
|
||||
// TRANS: Form guide.
|
||||
_m('You can\'t remove your main OpenID account ' .
|
||||
'without either adding a password to your ' .
|
||||
'GNU social account or another OpenID account. ' .
|
||||
'You can synchronize your profile with your ' .
|
||||
'OpenID by clicking the button labeled "Synchronize".')
|
||||
);
|
||||
|
||||
if ($oid->fetch()) {
|
||||
$this->elementStart('form', ['method' => 'POST',
|
||||
@@ -152,12 +156,15 @@ class OpenidsettingsAction extends SettingsAction
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
} else {
|
||||
$this->element('p', 'form_guide',
|
||||
// TRANS: Form guide.
|
||||
_m('You can remove an OpenID from your account ' .
|
||||
'by clicking the button labeled "Remove". ' .
|
||||
'You can synchronize your profile with an OpenID ' .
|
||||
'by clicking the button labeled "Synchronize".'));
|
||||
$this->element(
|
||||
'p',
|
||||
'form_guide',
|
||||
// TRANS: Form guide.
|
||||
_m('You can remove an OpenID from your account ' .
|
||||
'by clicking the button labeled "Remove". ' .
|
||||
'You can synchronize your profile with an OpenID ' .
|
||||
'by clicking the button labeled "Synchronize".')
|
||||
);
|
||||
$idx = 0;
|
||||
|
||||
while ($oid->fetch()) {
|
||||
@@ -191,26 +198,38 @@ class OpenidsettingsAction extends SettingsAction
|
||||
// TRANS: Fieldset legend.
|
||||
$this->element('legend', null, _m('OpenID Trusted Sites'));
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->element('p', 'form_guide',
|
||||
// TRANS: Form guide.
|
||||
_m('The following sites are allowed to access your ' .
|
||||
'identity and log you in. You can remove a site from ' .
|
||||
'this list to deny it access to your OpenID.'));
|
||||
$this->element(
|
||||
'p',
|
||||
'form_guide',
|
||||
// TRANS: Form guide.
|
||||
_m('The following sites are allowed to access your ' .
|
||||
'identity and log you in. You can remove a site from ' .
|
||||
'this list to deny it access to your OpenID.')
|
||||
);
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$user_openid_trustroot = new User_openid_trustroot();
|
||||
$user_openid_trustroot->user_id = $this->scoped->getID();
|
||||
if ($user_openid_trustroot->find()) {
|
||||
while ($user_openid_trustroot->fetch()) {
|
||||
$this->elementStart('li');
|
||||
$this->element('input', ['name' => 'openid_trustroot[]',
|
||||
'type' => 'checkbox',
|
||||
'class' => 'checkbox',
|
||||
'value' => $user_openid_trustroot->trustroot,
|
||||
'id' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot)]);
|
||||
$this->element('label',
|
||||
['class'=>'checkbox',
|
||||
'for' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot)],
|
||||
$user_openid_trustroot->trustroot);
|
||||
$this->element(
|
||||
'input',
|
||||
[
|
||||
'name' => 'openid_trustroot[]',
|
||||
'type' => 'checkbox',
|
||||
'class' => 'checkbox',
|
||||
'value' => $user_openid_trustroot->trustroot,
|
||||
'id' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot),
|
||||
]
|
||||
);
|
||||
$this->element(
|
||||
'label',
|
||||
[
|
||||
'class'=>'checkbox',
|
||||
'for' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot),
|
||||
],
|
||||
$user_openid_trustroot->trustroot
|
||||
);
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
}
|
||||
@@ -363,7 +382,7 @@ class OpenidsettingsAction extends SettingsAction
|
||||
$orig = clone($prefs);
|
||||
}
|
||||
|
||||
$prefs->hide_profile_link = $this->booleanintstring('hide_profile_link');
|
||||
$prefs->hide_profile_link = $this->boolean('hide_profile_link');
|
||||
|
||||
if ($orig instanceof User_openid_prefs) {
|
||||
$prefs->update($orig);
|
||||
|
@@ -1,44 +1,37 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Data class to record user prefs for polls
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PollPlugin
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2012, 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/>.
|
||||
* @category PollPlugin
|
||||
* @package GNUsocial
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2012, StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* For storing the poll prefs
|
||||
*
|
||||
* @category PollPlugin
|
||||
* @package StatusNet
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @copyright 2012, StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
@@ -46,7 +39,7 @@ class User_poll_prefs extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'user_poll_prefs'; // table name
|
||||
public $user_id; // int id
|
||||
public $hide_responses; // boolean
|
||||
public $hide_responses; // bool
|
||||
public $created; // datetime
|
||||
public $modified; // datetime
|
||||
|
||||
@@ -59,7 +52,7 @@ class User_poll_prefs extends Managed_DataObject
|
||||
'description' => 'Record of user preferences for polls',
|
||||
'fields' => array(
|
||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
||||
'hide_responses' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'Hide all poll responses'),
|
||||
'hide_responses' => array('type' => 'bool', 'default' => false, 'description' => 'Hide all poll responses'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
|
@@ -1,47 +1,36 @@
|
||||
<?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.
|
||||
*
|
||||
* Close a question to further answers
|
||||
*
|
||||
* 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 QnA
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or late
|
||||
*/
|
||||
if (!defined('STATUSNET')) {
|
||||
// This check helps protect against security problems;
|
||||
// your code file can't be executed directly from the web.
|
||||
exit(1);
|
||||
}
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Close a question to new answers
|
||||
*
|
||||
* @category QnA
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or late
|
||||
*/
|
||||
class QnaclosequestionAction extends Action
|
||||
{
|
||||
@@ -57,7 +46,7 @@ class QnaclosequestionAction extends Action
|
||||
*
|
||||
* @return string Action title
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Page title for close a question
|
||||
return _m('Close question');
|
||||
@@ -71,7 +60,7 @@ class QnaclosequestionAction extends Action
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare(array $args = [])
|
||||
public function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
if ($this->boolean('ajax')) {
|
||||
@@ -107,7 +96,7 @@ class QnaclosequestionAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle()
|
||||
public function handle()
|
||||
{
|
||||
parent::handle();
|
||||
|
||||
@@ -125,7 +114,7 @@ class QnaclosequestionAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function closeQuestion()
|
||||
public function closeQuestion()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
@@ -136,9 +125,8 @@ class QnaclosequestionAction extends Action
|
||||
}
|
||||
|
||||
$orig = clone($this->question);
|
||||
$this->question->closed = 1;
|
||||
$this->question->closed = true;
|
||||
$this->question->update($orig);
|
||||
|
||||
} catch (ClientException $ce) {
|
||||
$this->error = $ce->getMessage();
|
||||
$this->showPage();
|
||||
@@ -166,7 +154,7 @@ class QnaclosequestionAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
if (!empty($this->error)) {
|
||||
$this->element('p', 'error', $this->error);
|
||||
@@ -184,7 +172,7 @@ class QnaclosequestionAction extends Action
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
function isReadOnly($args)
|
||||
public function isReadOnly($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
|
||||
|
@@ -1,47 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2011, StatusNet, Inc.
|
||||
*
|
||||
* Revise an answer
|
||||
*
|
||||
* 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 QnA
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
if (!defined('STATUSNET')) {
|
||||
// This check helps protect against security problems;
|
||||
// your code file can't be executed directly from the web.
|
||||
exit(1);
|
||||
}
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Revise an answer
|
||||
*
|
||||
* @category QnA
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Revise an answer
|
||||
*
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class QnareviseanswerAction extends Action
|
||||
{
|
||||
@@ -56,7 +45,7 @@ class QnareviseanswerAction extends Action
|
||||
*
|
||||
* @return string Action title
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Page title for revising a question
|
||||
return _m('Revise answer');
|
||||
@@ -70,7 +59,7 @@ class QnareviseanswerAction extends Action
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare(array $args = [])
|
||||
public function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
if ($this->boolean('ajax')) {
|
||||
@@ -110,7 +99,7 @@ class QnareviseanswerAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle()
|
||||
public function handle()
|
||||
{
|
||||
parent::handle();
|
||||
|
||||
@@ -119,7 +108,7 @@ class QnareviseanswerAction extends Action
|
||||
if ($this->arg('revise')) {
|
||||
$this->showContent();
|
||||
return;
|
||||
} else if ($this->arg('best')) {
|
||||
} elseif ($this->arg('best')) {
|
||||
if ($this->user->id == $this->question->profile_id) {
|
||||
$this->markBest();
|
||||
return;
|
||||
@@ -138,7 +127,7 @@ class QnareviseanswerAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
if (!empty($this->error)) {
|
||||
$this->element('p', 'error', $this->error);
|
||||
@@ -154,7 +143,7 @@ class QnareviseanswerAction extends Action
|
||||
return;
|
||||
}
|
||||
|
||||
function showAjaxReviseForm()
|
||||
public function showAjaxReviseForm()
|
||||
{
|
||||
$this->startHTML('text/xml;charset=utf-8');
|
||||
$this->elementStart('head');
|
||||
@@ -173,7 +162,7 @@ class QnareviseanswerAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function markBest()
|
||||
public function markBest()
|
||||
{
|
||||
$question = $this->question;
|
||||
$answer = $this->answer;
|
||||
@@ -181,12 +170,12 @@ class QnareviseanswerAction extends Action
|
||||
try {
|
||||
// close the question to further answers
|
||||
$orig = clone($question);
|
||||
$question->closed = 1;
|
||||
$question->closed = true;
|
||||
$result = $question->update($orig);
|
||||
|
||||
// mark this answer an the best answer
|
||||
$orig = clone($answer);
|
||||
$answer->best = 1;
|
||||
$answer->best = true;
|
||||
$result = $answer->update($orig);
|
||||
} catch (ClientException $ce) {
|
||||
$this->error = $ce->getMessage();
|
||||
@@ -215,7 +204,7 @@ class QnareviseanswerAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function reviseAnswer()
|
||||
public function reviseAnswer()
|
||||
{
|
||||
$answer = $this->answer;
|
||||
|
||||
@@ -255,7 +244,7 @@ class QnareviseanswerAction extends Action
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
function isReadOnly($args)
|
||||
public function isReadOnly($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
|
||||
|
@@ -1,46 +1,38 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Data class to save answers to questions
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category QnA
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2011, 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/>.
|
||||
* @category QnA
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('STATUSNET') || die();
|
||||
|
||||
/**
|
||||
* For storing answers
|
||||
*
|
||||
* @category QnA
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
class QnA_Answer extends Managed_DataObject
|
||||
{
|
||||
@@ -51,7 +43,7 @@ class QnA_Answer extends Managed_DataObject
|
||||
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $question_id; // char(36) -> question.id UUID
|
||||
public $profile_id; // int -> question.id
|
||||
public $best; // (boolean) int -> whether the question asker has marked this as the best answer
|
||||
public $best; // bool -> whether the question asker has marked this as the best answer
|
||||
public $revisions; // int -> count of revisions to this answer
|
||||
public $content; // text -> response text
|
||||
public $created; // datetime
|
||||
@@ -82,7 +74,7 @@ class QnA_Answer extends Managed_DataObject
|
||||
'description' => 'UUID of question being responded to',
|
||||
),
|
||||
'content' => array('type' => 'text'), // got a better name?
|
||||
'best' => array('type' => 'int', 'size' => 'tiny'),
|
||||
'best' => array('type' => 'bool'),
|
||||
'revisions' => array('type' => 'int'),
|
||||
'profile_id' => array('type' => 'int'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true),
|
||||
@@ -105,7 +97,7 @@ class QnA_Answer extends Managed_DataObject
|
||||
*
|
||||
* @return QnA_Answer found response or null
|
||||
*/
|
||||
static function getByNotice($notice)
|
||||
public static function getByNotice($notice)
|
||||
{
|
||||
$answer = self::getKV('uri', $notice->uri);
|
||||
if (empty($answer)) {
|
||||
@@ -119,17 +111,17 @@ class QnA_Answer extends Managed_DataObject
|
||||
*
|
||||
* @return Notice
|
||||
*/
|
||||
function getNotice()
|
||||
public function getNotice()
|
||||
{
|
||||
return Notice::getKV('uri', $this->uri);
|
||||
}
|
||||
|
||||
static function fromNotice($notice)
|
||||
public static function fromNotice($notice)
|
||||
{
|
||||
return QnA_Answer::getKV('uri', $notice->uri);
|
||||
}
|
||||
|
||||
function getUrl()
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->getNotice()->getUrl();
|
||||
}
|
||||
@@ -139,29 +131,29 @@ class QnA_Answer extends Managed_DataObject
|
||||
*
|
||||
* @return QnA_Question
|
||||
*/
|
||||
function getQuestion()
|
||||
public function getQuestion()
|
||||
{
|
||||
$question = QnA_Question::getKV('id', $this->question_id);
|
||||
if (empty($question)) {
|
||||
// TRANS: Exception thown when getting a question with a non-existing ID.
|
||||
// TRANS: %s is the non-existing question ID.
|
||||
throw new Exception(sprintf(_m('No question with ID %s'),$this->question_id));
|
||||
throw new Exception(sprintf(_m('No question with ID %s'), $this->question_id));
|
||||
}
|
||||
return $question;
|
||||
}
|
||||
|
||||
function getProfile()
|
||||
public function getProfile()
|
||||
{
|
||||
$profile = Profile::getKV('id', $this->profile_id);
|
||||
if (empty($profile)) {
|
||||
// TRANS: Exception thown when getting a profile with a non-existing ID.
|
||||
// TRANS: %s is the non-existing profile ID.
|
||||
throw new Exception(sprintf(_m('No profile with ID %s'),$this->profile_id));
|
||||
throw new Exception(sprintf(_m('No profile with ID %s'), $this->profile_id));
|
||||
}
|
||||
return $profile;
|
||||
}
|
||||
|
||||
function asHTML()
|
||||
public function asHTML()
|
||||
{
|
||||
return self::toHTML(
|
||||
$this->getProfile(),
|
||||
@@ -170,7 +162,7 @@ class QnA_Answer extends Managed_DataObject
|
||||
);
|
||||
}
|
||||
|
||||
function asString()
|
||||
public function asString()
|
||||
{
|
||||
return self::toString(
|
||||
$this->getProfile(),
|
||||
@@ -179,7 +171,7 @@ class QnA_Answer extends Managed_DataObject
|
||||
);
|
||||
}
|
||||
|
||||
static function toHTML($profile, $question, $answer)
|
||||
public static function toHTML($profile, $question, $answer)
|
||||
{
|
||||
$notice = $question->getNotice();
|
||||
|
||||
@@ -201,7 +193,7 @@ class QnA_Answer extends Managed_DataObject
|
||||
htmlspecialchars(
|
||||
// Notification of how often an answer was revised.
|
||||
// TRANS: %s is the number of answer revisions.
|
||||
sprintf(_m('%s revision','%s revisions',$answer->revisions), $answer->revisions)
|
||||
sprintf(_m('%s revision', '%s revisions', $answer->revisions), $answer->revisions)
|
||||
)
|
||||
);
|
||||
$out->elementEnd('span');
|
||||
@@ -212,7 +204,7 @@ class QnA_Answer extends Managed_DataObject
|
||||
return $out->getString();
|
||||
}
|
||||
|
||||
static function toString($profile, $question, $answer)
|
||||
public static function toString($profile, $question, $answer)
|
||||
{
|
||||
// @todo FIXME: unused variable?
|
||||
$notice = $question->getNotice();
|
||||
@@ -237,7 +229,7 @@ class QnA_Answer extends Managed_DataObject
|
||||
*
|
||||
* @return Notice saved notice
|
||||
*/
|
||||
static function saveNew($profile, $question, $text, $options = null)
|
||||
public static function saveNew($profile, $question, $text, $options = null)
|
||||
{
|
||||
if (empty($options)) {
|
||||
$options = array();
|
||||
@@ -248,7 +240,7 @@ class QnA_Answer extends Managed_DataObject
|
||||
$answer->profile_id = $profile->id;
|
||||
$answer->question_id = $question->id;
|
||||
$answer->revisions = 0;
|
||||
$answer->best = 0;
|
||||
$answer->best = false;
|
||||
$answer->content = $text;
|
||||
$answer->created = common_sql_now();
|
||||
$answer->uri = common_local_url(
|
||||
|
@@ -1,46 +1,38 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Data class to mark a notice as a question
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category QnA
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2011, 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/>.
|
||||
* @category QnA
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* For storing a question
|
||||
*
|
||||
* @category QnA
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
class QnA_Question extends Managed_DataObject
|
||||
{
|
||||
@@ -52,7 +44,7 @@ class QnA_Question extends Managed_DataObject
|
||||
public $profile_id; // int -> profile.id
|
||||
public $title; // text
|
||||
public $description; // text
|
||||
public $closed; // int (boolean) whether a question is closed
|
||||
public $closed; // bool -> whether a question is closed
|
||||
public $created; // datetime
|
||||
|
||||
/**
|
||||
@@ -76,7 +68,7 @@ class QnA_Question extends Managed_DataObject
|
||||
),
|
||||
'profile_id' => array('type' => 'int'),
|
||||
'title' => array('type' => 'text'),
|
||||
'closed' => array('type' => 'int', 'size' => 'tiny'),
|
||||
'closed' => array('type' => 'bool'),
|
||||
'description' => array('type' => 'text'),
|
||||
'created' => array(
|
||||
'type' => 'datetime',
|
||||
@@ -97,28 +89,28 @@ class QnA_Question extends Managed_DataObject
|
||||
*
|
||||
* @return Question found question or null
|
||||
*/
|
||||
static function getByNotice($notice)
|
||||
public static function getByNotice($notice)
|
||||
{
|
||||
return self::getKV('uri', $notice->uri);
|
||||
}
|
||||
|
||||
function getNotice()
|
||||
public function getNotice()
|
||||
{
|
||||
return Notice::getKV('uri', $this->uri);
|
||||
}
|
||||
|
||||
function getUrl()
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->getNotice()->getUrl();
|
||||
}
|
||||
|
||||
function getProfile()
|
||||
public function getProfile()
|
||||
{
|
||||
$profile = Profile::getKV('id', $this->profile_id);
|
||||
if (empty($profile)) {
|
||||
// TRANS: Exception trown when getting a profile for a non-existing ID.
|
||||
// TRANS: %s is the provided profile ID.
|
||||
throw new Exception(sprintf(_m('No profile with ID %s'),$this->profile_id));
|
||||
throw new Exception(sprintf(_m('No profile with ID %s'), $this->profile_id));
|
||||
}
|
||||
return $profile;
|
||||
}
|
||||
@@ -130,7 +122,7 @@ class QnA_Question extends Managed_DataObject
|
||||
*
|
||||
* @return Answer object or null
|
||||
*/
|
||||
function getAnswer(Profile $profile)
|
||||
public function getAnswer(Profile $profile)
|
||||
{
|
||||
$a = new QnA_Answer();
|
||||
$a->question_id = $this->id;
|
||||
@@ -143,7 +135,7 @@ class QnA_Question extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
function getAnswers()
|
||||
public function getAnswers()
|
||||
{
|
||||
$a = new QnA_Answer();
|
||||
$a->question_id = $this->id;
|
||||
@@ -155,7 +147,7 @@ class QnA_Question extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
function countAnswers()
|
||||
public function countAnswers()
|
||||
{
|
||||
$a = new QnA_Answer();
|
||||
|
||||
@@ -164,22 +156,22 @@ class QnA_Question extends Managed_DataObject
|
||||
return $a->count();
|
||||
}
|
||||
|
||||
static function fromNotice($notice)
|
||||
public static function fromNotice($notice)
|
||||
{
|
||||
return QnA_Question::getKV('uri', $notice->uri);
|
||||
}
|
||||
|
||||
function asHTML()
|
||||
public function asHTML()
|
||||
{
|
||||
return self::toHTML($this->getProfile(), $this);
|
||||
}
|
||||
|
||||
function asString()
|
||||
public function asString()
|
||||
{
|
||||
return self::toString($this->getProfile(), $this);
|
||||
}
|
||||
|
||||
static function toHTML($profile, $question)
|
||||
public static function toHTML($profile, $question)
|
||||
{
|
||||
$notice = $question->getNotice();
|
||||
|
||||
@@ -205,7 +197,7 @@ class QnA_Question extends Managed_DataObject
|
||||
$out->elementStart('span', 'answer-count');
|
||||
// TRANS: Number of given answers to a question.
|
||||
// TRANS: %s is the number of given answers.
|
||||
$out->text(sprintf(_m('%s answer','%s answers',$cnt), $cnt));
|
||||
$out->text(sprintf(_m('%s answer', '%s answers', $cnt), $cnt));
|
||||
$out->elementEnd('span');
|
||||
}
|
||||
|
||||
@@ -221,7 +213,7 @@ class QnA_Question extends Managed_DataObject
|
||||
return $out->getString();
|
||||
}
|
||||
|
||||
static function toString($profile, $question, $answers)
|
||||
public static function toString($profile, $question, $answers)
|
||||
{
|
||||
return sprintf(htmlspecialchars($question->description));
|
||||
}
|
||||
@@ -237,7 +229,7 @@ class QnA_Question extends Managed_DataObject
|
||||
*
|
||||
* @return Notice saved notice
|
||||
*/
|
||||
static function saveNew($profile, $title, $description, $options = array())
|
||||
public static function saveNew($profile, $title, $description, $options = [])
|
||||
{
|
||||
$q = new QnA_Question();
|
||||
|
||||
|
@@ -1,51 +1,72 @@
|
||||
<?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 SensitiveContentSettingsAction extends SettingsAction
|
||||
{
|
||||
function title()
|
||||
{
|
||||
return _m('Sensitive content settings');
|
||||
}
|
||||
public function title()
|
||||
{
|
||||
return _m('Sensitive content settings');
|
||||
}
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _m('Set preferences for display of "sensitive" content');
|
||||
}
|
||||
public function getInstructions()
|
||||
{
|
||||
return _m('Set preferences for display of "sensitive" content');
|
||||
}
|
||||
|
||||
function showContent()
|
||||
{
|
||||
public function showContent()
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
$user = $this->scoped->getUser();
|
||||
$this->elementStart(
|
||||
'form',
|
||||
[
|
||||
'method' => 'post',
|
||||
'id' => 'sensitivecontent',
|
||||
'class' => 'form_settings',
|
||||
'action' => common_local_url('sensitivecontentsettings'),
|
||||
]
|
||||
);
|
||||
|
||||
$this->elementStart('form', array('method' => 'post',
|
||||
'id' => 'sensitivecontent',
|
||||
'class' => 'form_settings',
|
||||
'action' => common_local_url('sensitivecontentsettings')));
|
||||
$this->elementStart('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->elementStart('ul', 'form_data');
|
||||
|
||||
$this->elementStart('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->elementStart('ul', 'form_data');
|
||||
|
||||
$this->elementStart('li');
|
||||
$this->checkbox('hidesensitive', _('Hide attachments in posts hashtagged #NSFW'),
|
||||
($this->arg('hidesensitive')) ?
|
||||
$this->boolean('hidesensitive') : $this->scoped->getPref('MoonMan','hide_sensitive',0));
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->checkbox(
|
||||
'hidesensitive',
|
||||
_('Hide attachments in posts hashtagged #NSFW'),
|
||||
($this->arg('hidesensitive') ?
|
||||
$this->boolean('hidesensitive') : $this->scoped->getPref('MoonMan', 'hide_sensitive', 0))
|
||||
);
|
||||
$this->elementEnd('li');
|
||||
|
||||
|
||||
$this->elementEnd('ul');
|
||||
$this->submit('save', _m('BUTTON','Save'));
|
||||
$this->elementEnd('ul');
|
||||
$this->submit('save', _m('BUTTON', 'Save'));
|
||||
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
|
||||
function doPost()
|
||||
{
|
||||
$hidesensitive = $this->booleanintstring('hidesensitive');
|
||||
$this->scoped->setPref('MoonMan','hide_sensitive', $hidesensitive);
|
||||
return _('Settings saved.');
|
||||
}
|
||||
public function doPost()
|
||||
{
|
||||
$hidesensitive = $this->boolean('hidesensitive') ? '1' : '0';
|
||||
$this->scoped->setPref('MoonMan', 'hide_sensitive', $hidesensitive);
|
||||
return _('Settings saved.');
|
||||
}
|
||||
}
|
||||
|
@@ -1,35 +1,30 @@
|
||||
<?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
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Plugin
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Julien C <chaumond@gmail.com>
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @copyright 2009-2010 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')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once dirname(__DIR__) . '/twitter.php';
|
||||
|
||||
@@ -38,14 +33,8 @@ require_once dirname(__DIR__) . '/twitter.php';
|
||||
* Is used by both the polling twitterstatusfetcher.php daemon, and the
|
||||
* in-progress streaming import.
|
||||
*
|
||||
* @category Plugin
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Julien C <chaumond@gmail.com>
|
||||
* @author Brion Vibber <brion@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/
|
||||
* @link http://twitter.com/
|
||||
* @copyright 2009-2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class TwitterImport
|
||||
{
|
||||
@@ -74,12 +63,12 @@ class TwitterImport
|
||||
return $notice;
|
||||
}
|
||||
|
||||
function name()
|
||||
public function name()
|
||||
{
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
function saveStatus($status)
|
||||
public function saveStatus($status)
|
||||
{
|
||||
$profile = $this->ensureProfile($status->user);
|
||||
|
||||
@@ -103,7 +92,7 @@ class TwitterImport
|
||||
}
|
||||
|
||||
$dupe = Notice::getKV('uri', $statusUri);
|
||||
if($dupe instanceof Notice) {
|
||||
if ($dupe instanceof Notice) {
|
||||
// Add it to our record
|
||||
Notice_to_status::saveNew($dupe->id, $statusId);
|
||||
common_log(
|
||||
@@ -123,24 +112,29 @@ class TwitterImport
|
||||
$author = $original->getProfile();
|
||||
// TRANS: Message used to repeat a notice. RT is the abbreviation of 'retweet'.
|
||||
// TRANS: %1$s is the repeated user's name, %2$s is the repeated notice.
|
||||
$content = sprintf(_m('RT @%1$s %2$s'),
|
||||
$author->nickname,
|
||||
$original->content);
|
||||
$content = sprintf(
|
||||
_m('RT @%1$s %2$s'),
|
||||
$author->nickname,
|
||||
$original->content
|
||||
);
|
||||
|
||||
if (Notice::contentTooLong($content)) {
|
||||
$contentlimit = Notice::maxContent();
|
||||
$content = mb_substr($content, 0, $contentlimit - 4) . ' ...';
|
||||
}
|
||||
|
||||
$repeat = Notice::saveNew($profile->id,
|
||||
$content,
|
||||
'twitter',
|
||||
array('repeat_of' => $original->id,
|
||||
'uri' => $statusUri,
|
||||
'is_local' => Notice::GATEWAY,
|
||||
'object_type' => ActivityObject::NOTE,
|
||||
'verb' => ActivityVerb::POST
|
||||
));
|
||||
$repeat = Notice::saveNew(
|
||||
$profile->id,
|
||||
$content,
|
||||
'twitter',
|
||||
[
|
||||
'repeat_of' => $original->id,
|
||||
'uri' => $statusUri,
|
||||
'is_local' => Notice::GATEWAY,
|
||||
'object_type' => ActivityObject::NOTE,
|
||||
'verb' => ActivityVerb::POST,
|
||||
]
|
||||
);
|
||||
common_log(LOG_INFO, "Saved {$repeat->id} as a repeat of {$original->id}");
|
||||
Notice_to_status::saveNew($repeat->id, $statusId);
|
||||
return $repeat;
|
||||
@@ -183,11 +177,10 @@ class TwitterImport
|
||||
|
||||
$notice->is_local = Notice::GATEWAY;
|
||||
|
||||
$notice->content = html_entity_decode($this->linkify($status, FALSE), ENT_QUOTES, 'UTF-8');
|
||||
$notice->rendered = $this->linkify($status, TRUE);
|
||||
$notice->content = html_entity_decode($this->linkify($status, false), ENT_QUOTES, 'UTF-8');
|
||||
$notice->rendered = $this->linkify($status, true);
|
||||
|
||||
if (Event::handle('StartNoticeSave', array(&$notice))) {
|
||||
|
||||
if (empty($notice->conversation)) {
|
||||
$conv = Conversation::create();
|
||||
common_log(LOG_INFO, "No known conversation for status {$statusId} so a new one ({$conv->getID()}) was created.");
|
||||
@@ -221,7 +214,7 @@ class TwitterImport
|
||||
*
|
||||
* @return string URI
|
||||
*/
|
||||
function makeStatusURI($username, $id)
|
||||
public function makeStatusURI($username, $id)
|
||||
{
|
||||
return 'https://twitter.com/'
|
||||
. $username
|
||||
@@ -283,7 +276,7 @@ class TwitterImport
|
||||
if (empty($id)) {
|
||||
throw new Exception('Failed insert');
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
common_log(LOG_WARNING, __METHOD__ . " Couldn't insert profile: " . $e->getMessage());
|
||||
common_log_db_error($profile, 'INSERT', __FILE__);
|
||||
$profile->query("ROLLBACK");
|
||||
@@ -314,8 +307,13 @@ class TwitterImport
|
||||
if ($avatar->filename === $filename) {
|
||||
return null;
|
||||
}
|
||||
common_debug(__METHOD__ . " - Updating profile avatar (profile_id={$profile->id}) " .
|
||||
"from {$avatar->filename} to {$filename}");
|
||||
common_debug(sprintf(
|
||||
'%s - Updating profile avatar (profile_id=%d) from %s to %s',
|
||||
__METHOD__,
|
||||
$profile->id,
|
||||
$avatar->filename,
|
||||
$filename
|
||||
));
|
||||
// else we continue with creating a new avatar
|
||||
} catch (NoAvatarException $e) {
|
||||
// Avatar was not found. We can catch NoAvatarException or FileNotFoundException
|
||||
@@ -367,7 +365,7 @@ class TwitterImport
|
||||
|
||||
$avatar = new Avatar();
|
||||
$avatar->profile_id = $profile->id;
|
||||
$avatar->original = 1; // this is an original/"uploaded" avatar
|
||||
$avatar->original = true; // this is an original/"uploaded" avatar
|
||||
$avatar->mediatype = $mediatype;
|
||||
$avatar->filename = $filename;
|
||||
$avatar->width = $this->avatarsize;
|
||||
@@ -416,7 +414,7 @@ class TwitterImport
|
||||
const HASHTAG = 2;
|
||||
const MENTION = 3;
|
||||
|
||||
function linkify($status, $html = FALSE)
|
||||
public function linkify($status, $html = false)
|
||||
{
|
||||
$text = $status->text;
|
||||
|
||||
@@ -424,10 +422,20 @@ class TwitterImport
|
||||
$statusId = twitter_id($status);
|
||||
common_log(LOG_WARNING, "No entities data for {$statusId}; trying to fake up links ourselves.");
|
||||
$text = common_replace_urls_callback($text, 'common_linkify');
|
||||
$text = preg_replace_callback('/(^|\"\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/',
|
||||
function ($m) { return $m[1].'#'.TwitterStatusFetcher::tagLink($m[2]); }, $text);
|
||||
$text = preg_replace_callback('/(^|\s+)@([a-z0-9A-Z_]{1,64})/',
|
||||
function ($m) { return $m[1].'@'.TwitterStatusFetcher::atLink($m[2]); }, $text);
|
||||
$text = preg_replace_callback(
|
||||
'/(^|\"\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/',
|
||||
function ($m) {
|
||||
return $m[1] . '#'.TwitterStatusFetcher::tagLink($m[2]);
|
||||
},
|
||||
$text
|
||||
);
|
||||
$text = preg_replace_callback(
|
||||
'/(^|\s+)@([a-z0-9A-Z_]{1,64})/',
|
||||
function ($m) {
|
||||
return $m[1] . '@'.TwitterStatusFetcher::atLink($m[2]);
|
||||
},
|
||||
$text
|
||||
);
|
||||
return $text;
|
||||
}
|
||||
|
||||
@@ -472,21 +480,21 @@ class TwitterImport
|
||||
$cursor = $start;
|
||||
}
|
||||
$orig = $this->twitEscape(mb_substr($text, $start, $end - $start));
|
||||
switch($type) {
|
||||
switch ($type) {
|
||||
case self::URL:
|
||||
$linkText = $this->makeUrlLink($object, $orig, $html);
|
||||
break;
|
||||
case self::HASHTAG:
|
||||
if ($html) {
|
||||
$linkText = $this->makeHashtagLink($object, $orig);
|
||||
}else{
|
||||
} else {
|
||||
$linkText = $orig;
|
||||
}
|
||||
break;
|
||||
case self::MENTION:
|
||||
if ($html) {
|
||||
$linkText = $this->makeMentionLink($object, $orig);
|
||||
}else{
|
||||
} else {
|
||||
$linkText = $orig;
|
||||
}
|
||||
break;
|
||||
@@ -503,7 +511,7 @@ class TwitterImport
|
||||
return $result;
|
||||
}
|
||||
|
||||
function twitEscape($str)
|
||||
public function twitEscape($str)
|
||||
{
|
||||
// Twitter seems to preemptive turn < and > into < and >
|
||||
// but doesn't for &, so while you may have some magic protection
|
||||
@@ -516,31 +524,31 @@ class TwitterImport
|
||||
return htmlspecialchars(html_entity_decode($str, ENT_COMPAT, 'UTF-8'));
|
||||
}
|
||||
|
||||
function makeUrlLink($object, $orig, $html)
|
||||
public function makeUrlLink($object, $orig, $html)
|
||||
{
|
||||
if ($html) {
|
||||
return '<a href="'.htmlspecialchars($object->expanded_url).'" class="extlink">'.htmlspecialchars($object->display_url).'</a>';
|
||||
}else{
|
||||
} else {
|
||||
return htmlspecialchars($object->expanded_url);
|
||||
}
|
||||
}
|
||||
|
||||
function makeHashtagLink($object, $orig)
|
||||
public function makeHashtagLink($object, $orig)
|
||||
{
|
||||
return "#" . self::tagLink($object->text, substr($orig, 1));
|
||||
}
|
||||
|
||||
function makeMentionLink($object, $orig)
|
||||
public function makeMentionLink($object, $orig)
|
||||
{
|
||||
return "@".self::atLink($object->screen_name, $object->name, substr($orig, 1));
|
||||
}
|
||||
|
||||
static function tagLink($tag, $orig)
|
||||
public static function tagLink($tag, $orig)
|
||||
{
|
||||
return "<a href='https://twitter.com/search?q=%23{$tag}' class='hashtag'>{$orig}</a>";
|
||||
}
|
||||
|
||||
static function atLink($screenName, $fullName, $orig)
|
||||
public static function atLink($screenName, $fullName, $orig)
|
||||
{
|
||||
if (!empty($fullName)) {
|
||||
return "<a href='https://twitter.com/{$screenName}' title='{$fullName}'>{$orig}</a>";
|
||||
@@ -549,7 +557,7 @@ class TwitterImport
|
||||
}
|
||||
}
|
||||
|
||||
function saveStatusMentions($notice, $status)
|
||||
public function saveStatusMentions($notice, $status)
|
||||
{
|
||||
$mentions = array();
|
||||
|
||||
@@ -582,7 +590,7 @@ class TwitterImport
|
||||
* @param Notice $notice
|
||||
* @param object $status
|
||||
*/
|
||||
function saveStatusAttachments(Notice $notice, $status)
|
||||
public function saveStatusAttachments(Notice $notice, $status)
|
||||
{
|
||||
if (common_config('attachments', 'process_links')) {
|
||||
if (!empty($status->entities) && !empty($status->entities->urls)) {
|
||||
|
Reference in New Issue
Block a user