[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:
parent
9d87c37ac1
commit
3f17a0efea
|
@ -295,11 +295,11 @@ class EmailsettingsAction extends SettingsAction
|
||||||
public function savePreferences()
|
public function savePreferences()
|
||||||
{
|
{
|
||||||
if (Event::handle('StartEmailSaveForm', array($this, $this->scoped))) {
|
if (Event::handle('StartEmailSaveForm', array($this, $this->scoped))) {
|
||||||
$emailnotifysub = $this->booleanintstring('emailnotifysub');
|
$emailnotifysub = $this->boolean('emailnotifysub');
|
||||||
$emailnotifymsg = $this->booleanintstring('emailnotifymsg');
|
$emailnotifymsg = $this->boolean('emailnotifymsg');
|
||||||
$emailnotifynudge = $this->booleanintstring('emailnotifynudge');
|
$emailnotifynudge = $this->boolean('emailnotifynudge');
|
||||||
$emailnotifyattn = $this->booleanintstring('emailnotifyattn');
|
$emailnotifyattn = $this->boolean('emailnotifyattn');
|
||||||
$emailpost = $this->booleanintstring('emailpost');
|
$emailpost = $this->boolean('emailpost');
|
||||||
|
|
||||||
$user = $this->scoped->getUser();
|
$user = $this->scoped->getUser();
|
||||||
$user->query('BEGIN');
|
$user->query('BEGIN');
|
||||||
|
@ -459,7 +459,7 @@ class EmailsettingsAction extends SettingsAction
|
||||||
|
|
||||||
$orig = clone($user);
|
$orig = clone($user);
|
||||||
$user->incomingemail = DB_DataObject_Cast::sql('NULL');
|
$user->incomingemail = DB_DataObject_Cast::sql('NULL');
|
||||||
$user->emailpost = 0;
|
$user->emailpost = false;
|
||||||
// Throws exception on failure. Also performs it within a transaction.
|
// Throws exception on failure. Also performs it within a transaction.
|
||||||
$user->updateWithKeys($orig);
|
$user->updateWithKeys($orig);
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ class EmailsettingsAction extends SettingsAction
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$orig = clone($user);
|
$orig = clone($user);
|
||||||
$user->incomingemail = mail_new_incoming_address();
|
$user->incomingemail = mail_new_incoming_address();
|
||||||
$user->emailpost = 1;
|
$user->emailpost = true;
|
||||||
// Throws exception on failure. Also performs it within a transaction.
|
// Throws exception on failure. Also performs it within a transaction.
|
||||||
$user->updateWithKeys($orig);
|
$user->updateWithKeys($orig);
|
||||||
|
|
||||||
|
|
|
@ -1,50 +1,41 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
* Make another user an admin of a group
|
//
|
||||||
*
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
* PHP version 5
|
// 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
|
||||||
* @category Action
|
// (at your option) any later version.
|
||||||
* @package StatusNet
|
//
|
||||||
* @author Evan Prodromou <evan@status.net>
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* @link http://status.net/
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
*
|
// GNU Affero General Public License for more details.
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
//
|
||||||
* Copyright (C) 2008, 2009, StatusNet, Inc.
|
// 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/>.
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make another user an admin of a group
|
* Make another user an admin of a group
|
||||||
*
|
*
|
||||||
* @category Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @copyright 2008, 2009 StatusNet, Inc.
|
||||||
* @link http://status.net/
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make another user an admin of a group
|
||||||
|
*
|
||||||
|
* @copyright 2008, 2009 StatusNet, Inc.
|
||||||
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
|
*/
|
||||||
class MakeadminAction extends RedirectingAction
|
class MakeadminAction extends RedirectingAction
|
||||||
{
|
{
|
||||||
var $profile = null;
|
public $profile = null;
|
||||||
var $group = null;
|
public $group = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take arguments for running
|
* Take arguments for running
|
||||||
|
@ -54,7 +45,7 @@ class MakeadminAction extends RedirectingAction
|
||||||
* @return boolean success flag
|
* @return boolean success flag
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function prepare(array $args = array())
|
public function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
|
@ -95,10 +86,14 @@ class MakeadminAction extends RedirectingAction
|
||||||
if ($this->profile->isAdmin($this->group)) {
|
if ($this->profile->isAdmin($this->group)) {
|
||||||
// TRANS: Client error displayed when trying to make another user admin on the Make Admin page who already is admin.
|
// TRANS: Client error displayed when trying to make another user admin on the Make Admin page who already is admin.
|
||||||
// TRANS: %1$s is the user that is already admin, %2$s is the group user is already admin for.
|
// TRANS: %1$s is the user that is already admin, %2$s is the group user is already admin for.
|
||||||
$this->clientError(sprintf(_('%1$s is already an admin for group "%2$s".'),
|
$this->clientError(
|
||||||
$this->profile->getBestName(),
|
sprintf(
|
||||||
$this->group->getBestName()),
|
_('%1$s is already an admin for group "%2$s".'),
|
||||||
401);
|
$this->profile->getBestName(),
|
||||||
|
$this->group->getBestName()
|
||||||
|
),
|
||||||
|
401
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +106,7 @@ class MakeadminAction extends RedirectingAction
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
parent::handle();
|
parent::handle();
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
@ -125,7 +120,7 @@ class MakeadminAction extends RedirectingAction
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function makeAdmin()
|
public function makeAdmin()
|
||||||
{
|
{
|
||||||
$member = Group_member::pkeyGet(array('group_id' => $this->group->id,
|
$member = Group_member::pkeyGet(array('group_id' => $this->group->id,
|
||||||
'profile_id' => $this->profile->id));
|
'profile_id' => $this->profile->id));
|
||||||
|
@ -134,14 +129,16 @@ class MakeadminAction extends RedirectingAction
|
||||||
// TRANS: Server error displayed when trying to make another user admin on the Make Admin page fails
|
// TRANS: Server error displayed when trying to make another user admin on the Make Admin page fails
|
||||||
// TRANS: because the group membership record could not be gotten.
|
// TRANS: because the group membership record could not be gotten.
|
||||||
// TRANS: %1$s is the to be admin user, %2$s is the group user should be admin for.
|
// TRANS: %1$s is the to be admin user, %2$s is the group user should be admin for.
|
||||||
$this->serverError(_('Can\'t get membership record for %1$s in group %2$s.'),
|
$this->serverError(
|
||||||
$this->profile->getBestName(),
|
_('Can\'t get membership record for %1$s in group %2$s.'),
|
||||||
$this->group->getBestName());
|
$this->profile->getBestName(),
|
||||||
|
$this->group->getBestName()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$orig = clone($member);
|
$orig = clone($member);
|
||||||
|
|
||||||
$member->is_admin = 1;
|
$member->is_admin = true;
|
||||||
|
|
||||||
$result = $member->update($orig);
|
$result = $member->update($orig);
|
||||||
|
|
||||||
|
@ -150,9 +147,11 @@ class MakeadminAction extends RedirectingAction
|
||||||
// TRANS: Server error displayed when trying to make another user admin on the Make Admin page fails
|
// TRANS: Server error displayed when trying to make another user admin on the Make Admin page fails
|
||||||
// TRANS: because the group adminship record coud not be saved properly.
|
// TRANS: because the group adminship record coud not be saved properly.
|
||||||
// TRANS: %1$s is the to be admin user, %2$s is the group user is already admin for.
|
// TRANS: %1$s is the to be admin user, %2$s is the group user is already admin for.
|
||||||
$this->serverError(_('Can\'t make %1$s an admin for group %2$s.'),
|
$this->serverError(
|
||||||
$this->profile->getBestName(),
|
_('Can\'t make %1$s an admin for group %2$s.'),
|
||||||
$this->group->getBestName());
|
$this->profile->getBestName(),
|
||||||
|
$this->group->getBestName()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->returnToPrevious();
|
$this->returnToPrevious();
|
||||||
|
@ -161,13 +160,14 @@ class MakeadminAction extends RedirectingAction
|
||||||
/**
|
/**
|
||||||
* If we reached this form without returnto arguments, default to
|
* If we reached this form without returnto arguments, default to
|
||||||
* the top of the group's member list.
|
* the top of the group's member list.
|
||||||
*
|
*
|
||||||
* @return string URL
|
* @return string URL
|
||||||
*/
|
*/
|
||||||
function defaultReturnTo()
|
public function defaultReturnTo()
|
||||||
{
|
{
|
||||||
return common_local_url('groupmembers',
|
return common_local_url(
|
||||||
array('nickname' => $this->group->nickname));
|
'groupmembers',
|
||||||
|
['nickname' => $this->group->nickname]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Change profile settings
|
* Change profile settings
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Settings
|
* @category Settings
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @author Sarven Capadisli <csarven@status.net>
|
* @author Sarven Capadisli <csarven@status.net>
|
||||||
* @copyright 2008-2009 StatusNet, Inc.
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change profile settings
|
* Change profile settings
|
||||||
*
|
*
|
||||||
* @category Settings
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @author Zach Copley <zach@status.net>
|
|
||||||
* @author Sarven Capadisli <csarven@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/
|
|
||||||
*/
|
*/
|
||||||
class ProfilesettingsAction extends SettingsAction
|
class ProfilesettingsAction extends SettingsAction
|
||||||
{
|
{
|
||||||
|
@ -49,7 +41,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
*
|
*
|
||||||
* @return string Title of the page
|
* @return string Title of the page
|
||||||
*/
|
*/
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
// TRANS: Page title for profile settings.
|
// TRANS: Page title for profile settings.
|
||||||
return _('Profile settings');
|
return _('Profile settings');
|
||||||
|
@ -60,14 +52,14 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
*
|
*
|
||||||
* @return instructions for use
|
* @return instructions for use
|
||||||
*/
|
*/
|
||||||
function getInstructions()
|
public function getInstructions()
|
||||||
{
|
{
|
||||||
// TRANS: Usage instructions for profile settings.
|
// TRANS: Usage instructions for profile settings.
|
||||||
return _('You can update your personal profile info here '.
|
return _('You can update your personal profile info here '.
|
||||||
'so people know more about you.');
|
'so people know more about you.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showScripts()
|
public function showScripts()
|
||||||
{
|
{
|
||||||
parent::showScripts();
|
parent::showScripts();
|
||||||
$this->autofocus('fullname');
|
$this->autofocus('fullname');
|
||||||
|
@ -80,7 +72,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showContent()
|
public function showContent()
|
||||||
{
|
{
|
||||||
$user = $this->scoped->getUser();
|
$user = $this->scoped->getUser();
|
||||||
|
|
||||||
|
@ -98,29 +90,40 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
if (Event::handle('StartProfileFormData', array($this))) {
|
if (Event::handle('StartProfileFormData', array($this))) {
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
// TRANS: Field label in form for profile settings.
|
// TRANS: Field label in form for profile settings.
|
||||||
$this->input('nickname', _('Nickname'),
|
$this->input(
|
||||||
$this->trimmed('nickname') ?: $this->scoped->getNickname(),
|
'nickname',
|
||||||
// TRANS: Tooltip for field label in form for profile settings.
|
_('Nickname'),
|
||||||
_('1-64 lowercase letters or numbers, no punctuation or spaces.'),
|
$this->trimmed('nickname') ?: $this->scoped->getNickname(),
|
||||||
null, false, // "name" (will be set to id), then "required"
|
// TRANS: Tooltip for field label in form for profile settings.
|
||||||
!common_config('profile', 'changenick')
|
_('1-64 lowercase letters or numbers, no punctuation or spaces.'),
|
||||||
? array('disabled' => 'disabled', 'placeholder' => null)
|
null,
|
||||||
: array('placeholder' => null));
|
false, // "name" (will be set to id), then "required"
|
||||||
|
(common_config('profile', 'changenick')
|
||||||
|
? ['placeholder' => null]
|
||||||
|
: ['disabled' => 'disabled', 'placeholder' => null])
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
// TRANS: Field label in form for profile settings.
|
// TRANS: Field label in form for profile settings.
|
||||||
$this->input('fullname', _('Full name'),
|
$this->input(
|
||||||
$this->trimmed('fullname') ?: $this->scoped->getFullname(),
|
'fullname',
|
||||||
// TRANS: Instructions for full name text field on profile settings
|
_('Full name'),
|
||||||
_('A full name is required, if empty it will be set to your nickname.'),
|
$this->trimmed('fullname') ?: $this->scoped->getFullname(),
|
||||||
null, true);
|
// TRANS: Instructions for full name text field on profile settings
|
||||||
|
_('A full name is required, if empty it will be set to your nickname.'),
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
// TRANS: Field label in form for profile settings.
|
// TRANS: Field label in form for profile settings.
|
||||||
$this->input('homepage', _('Homepage'),
|
$this->input(
|
||||||
$this->trimmed('homepage') ?: $this->scoped->getHomepage(),
|
'homepage',
|
||||||
// TRANS: Tooltip for field label in form for profile settings.
|
_('Homepage'),
|
||||||
_('URL of your homepage, blog, or profile on another site.'));
|
$this->trimmed('homepage') ?: $this->scoped->getHomepage(),
|
||||||
|
// TRANS: Tooltip for field label in form for profile settings.
|
||||||
|
_('URL of your homepage, blog, or profile on another site.')
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
$maxBio = Profile::maxBio();
|
$maxBio = Profile::maxBio();
|
||||||
|
@ -128,97 +131,129 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
// TRANS: Tooltip for field label in form for profile settings. Plural
|
// TRANS: Tooltip for field label in form for profile settings. Plural
|
||||||
// TRANS: is decided by the number of characters available for the
|
// TRANS: is decided by the number of characters available for the
|
||||||
// TRANS: biography (%d).
|
// TRANS: biography (%d).
|
||||||
$bioInstr = sprintf(_m('Describe yourself and your interests in %d character.',
|
$bioInstr = sprintf(
|
||||||
'Describe yourself and your interests in %d characters.',
|
_m('Describe yourself and your interests in %d character.',
|
||||||
$maxBio),
|
'Describe yourself and your interests in %d characters.',
|
||||||
$maxBio);
|
$maxBio),
|
||||||
|
$maxBio
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// TRANS: Tooltip for field label in form for profile settings.
|
// TRANS: Tooltip for field label in form for profile settings.
|
||||||
$bioInstr = _('Describe yourself and your interests.');
|
$bioInstr = _('Describe yourself and your interests.');
|
||||||
}
|
}
|
||||||
// TRANS: Text area label in form for profile settings where users can provide
|
// TRANS: Text area label in form for profile settings where users can provide
|
||||||
// TRANS: their biography.
|
// TRANS: their biography.
|
||||||
$this->textarea('bio', _('Bio'),
|
$this->textarea(
|
||||||
$this->trimmed('bio') ?: $this->scoped->getDescription(),
|
'bio',
|
||||||
$bioInstr);
|
_('Bio'),
|
||||||
|
($this->trimmed('bio') ?: $this->scoped->getDescription()),
|
||||||
|
$bioInstr
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
// TRANS: Field label in form for profile settings.
|
// TRANS: Field label in form for profile settings.
|
||||||
$this->input('location', _('Location'),
|
$this->input(
|
||||||
$this->trimmed('location') ?: $this->scoped->location,
|
'location',
|
||||||
// TRANS: Tooltip for field label in form for profile settings.
|
_('Location'),
|
||||||
_('Where you are, like "City, State (or Region), Country".'));
|
($this->trimmed('location') ?: $this->scoped->location),
|
||||||
|
// TRANS: Tooltip for field label in form for profile settings.
|
||||||
|
_('Where you are, like "City, State (or Region), Country".')
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
if (common_config('location', 'share') == 'user') {
|
if (common_config('location', 'share') == 'user') {
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
// TRANS: Checkbox label in form for profile settings.
|
// TRANS: Checkbox label in form for profile settings.
|
||||||
$this->checkbox('sharelocation', _('Share my current location when posting notices'),
|
$this->checkbox(
|
||||||
($this->arg('sharelocation')) ?
|
'sharelocation',
|
||||||
$this->boolean('sharelocation') : $this->scoped->shareLocation());
|
_('Share my current location when posting notices'),
|
||||||
|
($this->arg('sharelocation') ?
|
||||||
|
$this->boolean('sharelocation') : $this->scoped->shareLocation())
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
Event::handle('EndProfileFormData', array($this));
|
Event::handle('EndProfileFormData', array($this));
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
// TRANS: Field label in form for profile settings.
|
// TRANS: Field label in form for profile settings.
|
||||||
$this->input('tags', _('Tags'),
|
$this->input(
|
||||||
$this->trimmed('tags') ?: implode(' ', Profile_tag::getSelfTagsArray($this->scoped)),
|
'tags',
|
||||||
// TRANS: Tooltip for field label in form for profile settings.
|
_('Tags'),
|
||||||
_('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated.'));
|
($this->trimmed('tags') ?: implode(' ', Profile_tag::getSelfTagsArray($this->scoped))),
|
||||||
|
// TRANS: Tooltip for field label in form for profile settings.
|
||||||
|
_('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated.')
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
$language = common_language();
|
$language = common_language();
|
||||||
// TRANS: Dropdownlist label in form for profile settings.
|
// TRANS: Dropdownlist label in form for profile settings.
|
||||||
$this->dropdown('language', _('Language'),
|
$this->dropdown(
|
||||||
// TRANS: Tooltip for dropdown list label in form for profile settings.
|
'language',
|
||||||
get_nice_language_list(), _('Preferred language.'),
|
_('Language'),
|
||||||
false, $language);
|
// TRANS: Tooltip for dropdown list label in form for profile settings.
|
||||||
|
get_nice_language_list(),
|
||||||
|
_('Preferred language.'),
|
||||||
|
false,
|
||||||
|
$language
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$timezone = common_timezone();
|
$timezone = common_timezone();
|
||||||
$timezones = array();
|
$timezones = array();
|
||||||
foreach(DateTimeZone::listIdentifiers() as $k => $v) {
|
foreach (DateTimeZone::listIdentifiers() as $k => $v) {
|
||||||
$timezones[$v] = $v;
|
$timezones[$v] = $v;
|
||||||
}
|
}
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
// TRANS: Dropdownlist label in form for profile settings.
|
// TRANS: Dropdownlist label in form for profile settings.
|
||||||
$this->dropdown('timezone', _('Timezone'),
|
$this->dropdown(
|
||||||
// TRANS: Tooltip for dropdown list label in form for profile settings.
|
'timezone',
|
||||||
$timezones, _('What timezone are you normally in?'),
|
_('Timezone'),
|
||||||
true, $timezone);
|
// TRANS: Tooltip for dropdown list label in form for profile settings.
|
||||||
|
$timezones,
|
||||||
|
_('What timezone are you normally in?'),
|
||||||
|
true,
|
||||||
|
$timezone
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
$this->checkbox('autosubscribe',
|
$this->checkbox(
|
||||||
// TRANS: Checkbox label in form for profile settings.
|
'autosubscribe',
|
||||||
_('Automatically subscribe to whoever '.
|
// TRANS: Checkbox label in form for profile settings.
|
||||||
'subscribes to me (best for non-humans)'),
|
_('Automatically subscribe to whoever '.
|
||||||
($this->arg('autosubscribe')) ?
|
'subscribes to me (best for non-humans)'),
|
||||||
$this->boolean('autosubscribe') : $user->autosubscribe);
|
($this->arg('autosubscribe') ?
|
||||||
|
$this->boolean('autosubscribe') : $user->autosubscribe)
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
$this->dropdown('subscribe_policy',
|
$this->dropdown(
|
||||||
// TRANS: Dropdown field label on profile settings, for what policies to apply when someone else tries to subscribe to your updates.
|
'subscribe_policy',
|
||||||
_('Subscription policy'),
|
// TRANS: Dropdown field label on profile settings, for what policies to apply when someone else tries to subscribe to your updates.
|
||||||
// TRANS: Dropdown field option for following policy.
|
_('Subscription policy'),
|
||||||
array(User::SUBSCRIBE_POLICY_OPEN => _('Let anyone follow me'),
|
[
|
||||||
// TRANS: Dropdown field option for following policy.
|
// TRANS: Dropdown field option for following policy.
|
||||||
User::SUBSCRIBE_POLICY_MODERATE => _('Ask me first')),
|
User::SUBSCRIBE_POLICY_OPEN => _('Let anyone follow me'),
|
||||||
// TRANS: Dropdown field title on group edit form.
|
// TRANS: Dropdown field option for following policy.
|
||||||
_('Whether other users need your permission to follow your updates.'),
|
User::SUBSCRIBE_POLICY_MODERATE => _('Ask me first'),
|
||||||
false,
|
],
|
||||||
(empty($user->subscribe_policy)) ? User::SUBSCRIBE_POLICY_OPEN : $user->subscribe_policy);
|
// TRANS: Dropdown field title on group edit form.
|
||||||
|
_('Whether other users need your permission to follow your updates.'),
|
||||||
|
false,
|
||||||
|
(empty($user->subscribe_policy) ? User::SUBSCRIBE_POLICY_OPEN : $user->subscribe_policy)
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
if (common_config('profile', 'allowprivate') || $user->private_stream) {
|
if (common_config('profile', 'allowprivate') || $user->private_stream) {
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
$this->checkbox('private_stream',
|
$this->checkbox(
|
||||||
// TRANS: Checkbox label in profile settings.
|
'private_stream',
|
||||||
_('Make updates visible only to my followers'),
|
// TRANS: Checkbox label in profile settings.
|
||||||
($this->arg('private_stream')) ?
|
_('Make updates visible only to my followers'),
|
||||||
$this->boolean('private_stream') : $user->private_stream);
|
($this->arg('private_stream') ?
|
||||||
|
$this->boolean('private_stream') : $user->private_stream)
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
$this->elementEnd('ul');
|
$this->elementEnd('ul');
|
||||||
// TRANS: Button to save input in profile settings.
|
// TRANS: Button to save input in profile settings.
|
||||||
$this->submit('save', _m('BUTTON','Save'));
|
$this->submit('save', _m('BUTTON', 'Save'));
|
||||||
|
|
||||||
$this->elementEnd('fieldset');
|
$this->elementEnd('fieldset');
|
||||||
$this->elementEnd('form');
|
$this->elementEnd('form');
|
||||||
|
@ -255,7 +290,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
$homepage = $this->trimmed('homepage');
|
$homepage = $this->trimmed('homepage');
|
||||||
$bio = $this->trimmed('bio');
|
$bio = $this->trimmed('bio');
|
||||||
$location = $this->trimmed('location');
|
$location = $this->trimmed('location');
|
||||||
$autosubscribe = $this->booleanintstring('autosubscribe');
|
$autosubscribe = $this->boolean('autosubscribe');
|
||||||
$subscribe_policy = $this->trimmed('subscribe_policy');
|
$subscribe_policy = $this->trimmed('subscribe_policy');
|
||||||
$language = $this->trimmed('language');
|
$language = $this->trimmed('language');
|
||||||
$timezone = $this->trimmed('timezone');
|
$timezone = $this->trimmed('timezone');
|
||||||
|
@ -266,24 +301,26 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
!common_valid_http_url($homepage)) {
|
!common_valid_http_url($homepage)) {
|
||||||
// TRANS: Validation error in form for profile settings.
|
// TRANS: Validation error in form for profile settings.
|
||||||
throw new ClientException(_('Homepage is not a valid URL.'));
|
throw new ClientException(_('Homepage is not a valid URL.'));
|
||||||
} else if (!is_null($fullname) && mb_strlen($fullname) > 191) {
|
} elseif (!is_null($fullname) && mb_strlen($fullname) > 191) {
|
||||||
// TRANS: Validation error in form for profile settings.
|
// TRANS: Validation error in form for profile settings.
|
||||||
throw new ClientException(_('Full name is too long (maximum 191 characters).'));
|
throw new ClientException(_('Full name is too long (maximum 191 characters).'));
|
||||||
} else if (Profile::bioTooLong($bio)) {
|
} elseif (Profile::bioTooLong($bio)) {
|
||||||
// TRANS: Validation error in form for profile settings.
|
// TRANS: Validation error in form for profile settings.
|
||||||
// TRANS: Plural form is used based on the maximum number of allowed
|
// TRANS: Plural form is used based on the maximum number of allowed
|
||||||
// TRANS: characters for the biography (%d).
|
// TRANS: characters for the biography (%d).
|
||||||
throw new ClientException(sprintf(_m('Bio is too long (maximum %d character).',
|
throw new ClientException(sprintf(
|
||||||
'Bio is too long (maximum %d characters).',
|
_m('Bio is too long (maximum %d character).',
|
||||||
Profile::maxBio()),
|
'Bio is too long (maximum %d characters).',
|
||||||
Profile::maxBio()));
|
Profile::maxBio()),
|
||||||
} else if (!is_null($location) && mb_strlen($location) > 191) {
|
Profile::maxBio()
|
||||||
|
));
|
||||||
|
} elseif (!is_null($location) && mb_strlen($location) > 191) {
|
||||||
// TRANS: Validation error in form for profile settings.
|
// TRANS: Validation error in form for profile settings.
|
||||||
throw new ClientException(_('Location is too long (maximum 191 characters).'));
|
throw new ClientException(_('Location is too long (maximum 191 characters).'));
|
||||||
} else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
|
} elseif (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
|
||||||
// TRANS: Validation error in form for profile settings.
|
// TRANS: Validation error in form for profile settings.
|
||||||
throw new ClientException(_('Timezone not selected.'));
|
throw new ClientException(_('Timezone not selected.'));
|
||||||
} else if (!is_null($language) && strlen($language) > 50) {
|
} elseif (!is_null($language) && strlen($language) > 50) {
|
||||||
// TRANS: Validation error in form for profile settings.
|
// TRANS: Validation error in form for profile settings.
|
||||||
throw new ClientException(_('Language is too long (maximum 50 characters).'));
|
throw new ClientException(_('Language is too long (maximum 50 characters).'));
|
||||||
}
|
}
|
||||||
|
@ -291,7 +328,6 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
$tags = array();
|
$tags = array();
|
||||||
$tag_priv = array();
|
$tag_priv = array();
|
||||||
if (is_string($tagstring) && strlen($tagstring) > 0) {
|
if (is_string($tagstring) && strlen($tagstring) > 0) {
|
||||||
|
|
||||||
$tags = preg_split('/[\s,]+/', $tagstring);
|
$tags = preg_split('/[\s,]+/', $tagstring);
|
||||||
|
|
||||||
foreach ($tags as &$tag) {
|
foreach ($tags as &$tag) {
|
||||||
|
@ -314,21 +350,19 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
// Only allow setting private_stream if site policy allows it
|
// Only allow setting private_stream if site policy allows it
|
||||||
// (or user already _has_ a private stream, then you can unset it)
|
// (or user already _has_ a private stream, then you can unset it)
|
||||||
if (common_config('profile', 'allowprivate') || $user->private_stream) {
|
if (common_config('profile', 'allowprivate') || $user->private_stream) {
|
||||||
$private_stream = $this->booleanintstring('private_stream');
|
$private_stream = $this->boolean('private_stream');
|
||||||
} else {
|
} else {
|
||||||
// if not allowed, we set to the existing value
|
// if not allowed, we set to the existing value
|
||||||
$private_stream = $user->private_stream;
|
$private_stream = (bool) $user->private_stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $user->nickname is updated through Profile->update();
|
// $user->nickname is updated through Profile->update();
|
||||||
|
|
||||||
// XXX: XOR
|
if ((bool) $user->autosubscribe != $autosubscribe
|
||||||
if (($user->autosubscribe ^ $autosubscribe)
|
|| (bool) $user->private_stream != $private_stream
|
||||||
|| ($user->private_stream ^ $private_stream)
|
|
||||||
|| $user->timezone != $timezone
|
|| $user->timezone != $timezone
|
||||||
|| $user->language != $language
|
|| $user->language != $language
|
||||||
|| $user->subscribe_policy != $subscribe_policy) {
|
|| $user->subscribe_policy != $subscribe_policy) {
|
||||||
|
|
||||||
$original = clone($user);
|
$original = clone($user);
|
||||||
|
|
||||||
$user->autosubscribe = $autosubscribe;
|
$user->autosubscribe = $autosubscribe;
|
||||||
|
@ -378,7 +412,6 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
}
|
}
|
||||||
|
|
||||||
if (common_config('location', 'share') == 'user') {
|
if (common_config('location', 'share') == 'user') {
|
||||||
|
|
||||||
$exists = false;
|
$exists = false;
|
||||||
|
|
||||||
$prefs = User_location_prefs::getKV('user_id', $this->scoped->getID());
|
$prefs = User_location_prefs::getKV('user_id', $this->scoped->getID());
|
||||||
|
@ -393,7 +426,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
$orig = clone($prefs);
|
$orig = clone($prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
$prefs->share_location = $this->booleanintstring('sharelocation');
|
$prefs->share_location = $this->boolean('sharelocation');
|
||||||
|
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
$result = $prefs->update($orig);
|
$result = $prefs->update($orig);
|
||||||
|
@ -429,11 +462,11 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
|
|
||||||
// TRANS: Confirmation shown when user profile settings are saved.
|
// TRANS: Confirmation shown when user profile settings are saved.
|
||||||
return _('Settings saved.');
|
return _('Settings saved.');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAside() {
|
public function showAside()
|
||||||
|
{
|
||||||
$this->elementStart('div', array('id' => 'aside_primary',
|
$this->elementStart('div', array('id' => 'aside_primary',
|
||||||
'class' => 'aside'));
|
'class' => 'aside'));
|
||||||
|
|
||||||
|
@ -443,26 +476,32 @@ class ProfilesettingsAction extends SettingsAction
|
||||||
if (Event::handle('StartProfileSettingsActions', array($this))) {
|
if (Event::handle('StartProfileSettingsActions', array($this))) {
|
||||||
if ($this->scoped->hasRight(Right::BACKUPACCOUNT)) {
|
if ($this->scoped->hasRight(Right::BACKUPACCOUNT)) {
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
$this->element('a',
|
$this->element(
|
||||||
array('href' => common_local_url('backupaccount')),
|
'a',
|
||||||
// TRANS: Option in profile settings to create a backup of the account of the currently logged in user.
|
['href' => common_local_url('backupaccount')],
|
||||||
_('Backup account'));
|
// TRANS: Option in profile settings to create a backup of the account of the currently logged in user.
|
||||||
|
_('Backup account')
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
if ($this->scoped->hasRight(Right::DELETEACCOUNT)) {
|
if ($this->scoped->hasRight(Right::DELETEACCOUNT)) {
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
$this->element('a',
|
$this->element(
|
||||||
array('href' => common_local_url('deleteaccount')),
|
'a',
|
||||||
// TRANS: Option in profile settings to delete the account of the currently logged in user.
|
['href' => common_local_url('deleteaccount')],
|
||||||
_('Delete account'));
|
// TRANS: Option in profile settings to delete the account of the currently logged in user.
|
||||||
|
_('Delete account')
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
if ($this->scoped->hasRight(Right::RESTOREACCOUNT)) {
|
if ($this->scoped->hasRight(Right::RESTOREACCOUNT)) {
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
$this->element('a',
|
$this->element(
|
||||||
array('href' => common_local_url('restoreaccount')),
|
'a',
|
||||||
// TRANS: Option in profile settings to restore the account of the currently logged in user from a backup.
|
['href' => common_local_url('restoreaccount')],
|
||||||
_('Restore account'));
|
// TRANS: Option in profile settings to restore the account of the currently logged in user from a backup.
|
||||||
|
_('Restore account')
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
Event::handle('EndProfileSettingsActions', array($this));
|
Event::handle('EndProfileSettingsActions', array($this));
|
||||||
|
|
|
@ -1,6 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table Definition for avatar
|
* Table Definition for avatar
|
||||||
|
@ -10,20 +24,20 @@ class Avatar extends Managed_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'avatar'; // table name
|
public $__table = 'avatar'; // table name
|
||||||
public $profile_id; // int(4) primary_key not_null
|
public $profile_id; // int(4) primary_key not_null
|
||||||
public $original; // tinyint(1)
|
public $original; // bool default_false
|
||||||
public $width; // int(4) primary_key not_null
|
public $width; // int(4) primary_key not_null
|
||||||
public $height; // int(4) primary_key not_null
|
public $height; // int(4) primary_key not_null
|
||||||
public $mediatype; // varchar(32) not_null
|
public $mediatype; // varchar(32) not_null
|
||||||
public $filename; // varchar(191) not 255 because utf8mb4 takes more space
|
public $filename; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
public static function schemaDef()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
|
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
|
||||||
'original' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'uploaded by user or generated?'),
|
'original' => array('type' => 'bool', 'default' => false, 'description' => 'uploaded by user or generated?'),
|
||||||
'width' => array('type' => 'int', 'not null' => true, 'description' => 'image width'),
|
'width' => array('type' => 'int', 'not null' => true, 'description' => 'image width'),
|
||||||
'height' => array('type' => 'int', 'not null' => true, 'description' => 'image height'),
|
'height' => array('type' => 'int', 'not null' => true, 'description' => 'image height'),
|
||||||
'mediatype' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'),
|
'mediatype' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'),
|
||||||
|
@ -45,7 +59,7 @@ class Avatar extends Managed_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// We clean up the file, too
|
// We clean up the file, too
|
||||||
function delete($useWhere=false)
|
public function delete($useWhere = false)
|
||||||
{
|
{
|
||||||
$filename = $this->filename;
|
$filename = $this->filename;
|
||||||
if (file_exists(Avatar::path($filename))) {
|
if (file_exists(Avatar::path($filename))) {
|
||||||
|
@ -57,11 +71,12 @@ class Avatar extends Managed_DataObject
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deletes all avatars (but may spare the original) from a profile.
|
* Deletes all avatars (but may spare the original) from a profile.
|
||||||
*
|
*
|
||||||
* @param Profile $target The profile we're deleting avatars of.
|
* @param Profile $target The profile we're deleting avatars of.
|
||||||
* @param boolean $original Whether original should be removed or not.
|
* @param boolean $original Whether original should be removed or not.
|
||||||
*/
|
*/
|
||||||
public static function deleteFromProfile(Profile $target, $original=true) {
|
public static function deleteFromProfile(Profile $target, $original = true)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$avatars = self::getProfileAvatars($target);
|
$avatars = self::getProfileAvatars($target);
|
||||||
foreach ($avatars as $avatar) {
|
foreach ($avatars as $avatar) {
|
||||||
|
@ -77,7 +92,7 @@ class Avatar extends Managed_DataObject
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected $_avatars = array();
|
protected static $_avatars = [];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get an avatar by profile. Currently can't call newSize with $height
|
* Get an avatar by profile. Currently can't call newSize with $height
|
||||||
|
@ -93,7 +108,7 @@ class Avatar extends Managed_DataObject
|
||||||
$size = "{$width}x{$height}";
|
$size = "{$width}x{$height}";
|
||||||
if (!isset(self::$_avatars[$target->id])) {
|
if (!isset(self::$_avatars[$target->id])) {
|
||||||
self::$_avatars[$target->id] = array();
|
self::$_avatars[$target->id] = array();
|
||||||
} elseif (isset(self::$_avatars[$target->id][$size])){
|
} elseif (isset(self::$_avatars[$target->id][$size])) {
|
||||||
return self::$_avatars[$target->id][$size];
|
return self::$_avatars[$target->id][$size];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +152,8 @@ class Avatar extends Managed_DataObject
|
||||||
return $avatar;
|
return $avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getProfileAvatars(Profile $target) {
|
public static function getProfileAvatars(Profile $target)
|
||||||
|
{
|
||||||
$avatar = new Avatar();
|
$avatar = new Avatar();
|
||||||
$avatar->profile_id = $target->id;
|
$avatar->profile_id = $target->id;
|
||||||
if (!$avatar->find()) {
|
if (!$avatar->find()) {
|
||||||
|
@ -149,7 +165,7 @@ class Avatar extends Managed_DataObject
|
||||||
/**
|
/**
|
||||||
* Where should the avatar go for this user?
|
* Where should the avatar go for this user?
|
||||||
*/
|
*/
|
||||||
static function filename($id, $extension, $size=null, $extra=null)
|
public static function filename($id, $extension, $size = null, $extra = null)
|
||||||
{
|
{
|
||||||
if ($size) {
|
if ($size) {
|
||||||
return $id . '-' . $size . (($extra) ? ('-' . $extra) : '') . $extension;
|
return $id . '-' . $size . (($extra) ? ('-' . $extra) : '') . $extension;
|
||||||
|
@ -158,7 +174,7 @@ class Avatar extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function path($filename)
|
public static function path($filename)
|
||||||
{
|
{
|
||||||
$dir = common_config('avatar', 'dir');
|
$dir = common_config('avatar', 'dir');
|
||||||
|
|
||||||
|
@ -169,7 +185,7 @@ class Avatar extends Managed_DataObject
|
||||||
return $dir . $filename;
|
return $dir . $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function url($filename)
|
public static function url($filename)
|
||||||
{
|
{
|
||||||
$path = common_config('avatar', 'path');
|
$path = common_config('avatar', 'path');
|
||||||
|
|
||||||
|
@ -194,20 +210,21 @@ class Avatar extends Managed_DataObject
|
||||||
return $protocol.'://'.$server.$path.$filename;
|
return $protocol.'://'.$server.$path.$filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayUrl()
|
public function displayUrl()
|
||||||
{
|
{
|
||||||
return Avatar::url($this->filename);
|
return Avatar::url($this->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function urlByProfile(Profile $target, $width=null, $height=null) {
|
public static function urlByProfile(Profile $target, $width = null, $height = null)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
return self::byProfile($target, $width, $height)->displayUrl();
|
return self::byProfile($target, $width, $height)->displayUrl();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return self::defaultImage($width);
|
return self::defaultImage($width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function defaultImage($size=null)
|
public static function defaultImage($size = null)
|
||||||
{
|
{
|
||||||
if (is_null($size)) {
|
if (is_null($size)) {
|
||||||
$size = AVATAR_PROFILE_SIZE;
|
$size = AVATAR_PROFILE_SIZE;
|
||||||
|
@ -218,7 +235,8 @@ class Avatar extends Managed_DataObject
|
||||||
return Theme::path('default-avatar-'.$sizenames[$size].'.png');
|
return Theme::path('default-avatar-'.$sizenames[$size].'.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
static function newSize(Profile $target, $width) {
|
public static function newSize(Profile $target, $width)
|
||||||
|
{
|
||||||
$width = intval($width);
|
$width = intval($width);
|
||||||
if ($width < 1 || $width > common_config('avatar', 'maxsize')) {
|
if ($width < 1 || $width > common_config('avatar', 'maxsize')) {
|
||||||
// TRANS: An error message when avatar size is unreasonable
|
// TRANS: An error message when avatar size is unreasonable
|
||||||
|
@ -231,8 +249,12 @@ class Avatar extends Managed_DataObject
|
||||||
$original = Avatar::getUploaded($target);
|
$original = Avatar::getUploaded($target);
|
||||||
|
|
||||||
$imagefile = new ImageFile(null, Avatar::path($original->filename));
|
$imagefile = new ImageFile(null, Avatar::path($original->filename));
|
||||||
$filename = Avatar::filename($target->getID(), image_type_to_extension($imagefile->preferredType()),
|
$filename = Avatar::filename(
|
||||||
$width, common_timestamp());
|
$target->getID(),
|
||||||
|
image_type_to_extension($imagefile->preferredType()),
|
||||||
|
$width,
|
||||||
|
common_timestamp()
|
||||||
|
);
|
||||||
$imagefile->resizeTo(Avatar::path($filename), array('width'=>$width, 'height'=>$height));
|
$imagefile->resizeTo(Avatar::path($filename), array('width'=>$width, 'height'=>$height));
|
||||||
|
|
||||||
$scaled = clone($original);
|
$scaled = clone($original);
|
||||||
|
|
|
@ -1,4 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table Definition for group_member
|
* Table Definition for group_member
|
||||||
*/
|
*/
|
||||||
|
@ -11,7 +28,7 @@ class Group_member extends Managed_DataObject
|
||||||
public $__table = 'group_member'; // table name
|
public $__table = 'group_member'; // table name
|
||||||
public $group_id; // int(4) primary_key not_null
|
public $group_id; // int(4) primary_key not_null
|
||||||
public $profile_id; // int(4) primary_key not_null
|
public $profile_id; // int(4) primary_key not_null
|
||||||
public $is_admin; // tinyint(1)
|
public $is_admin; // bool default_false
|
||||||
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
@ -25,7 +42,7 @@ class Group_member extends Managed_DataObject
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'),
|
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'),
|
||||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
|
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
|
||||||
'is_admin' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this user an admin?'),
|
'is_admin' => array('type' => 'bool', 'default' => false, 'description' => 'is this user an admin?'),
|
||||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
|
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
|
@ -54,20 +71,22 @@ class Group_member extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @param integer $group_id Group to add to
|
* @param integer $group_id Group to add to
|
||||||
* @param integer $profile_id Profile being added
|
* @param integer $profile_id Profile being added
|
||||||
*
|
*
|
||||||
* @return Group_member new membership object
|
* @return Group_member new membership object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static function join($group_id, $profile_id)
|
public static function join($group_id, $profile_id)
|
||||||
{
|
{
|
||||||
$member = new Group_member();
|
$member = new Group_member();
|
||||||
|
|
||||||
$member->group_id = $group_id;
|
$member->group_id = $group_id;
|
||||||
$member->profile_id = $profile_id;
|
$member->profile_id = $profile_id;
|
||||||
$member->created = common_sql_now();
|
$member->created = common_sql_now();
|
||||||
$member->uri = self::newUri(Profile::getByID($profile_id),
|
$member->uri = self::newUri(
|
||||||
User_group::getByID($group_id),
|
Profile::getByID($profile_id),
|
||||||
$member->created);
|
User_group::getByID($group_id),
|
||||||
|
$member->created
|
||||||
|
);
|
||||||
|
|
||||||
$result = $member->insert();
|
$result = $member->insert();
|
||||||
|
|
||||||
|
@ -80,7 +99,7 @@ class Group_member extends Managed_DataObject
|
||||||
return $member;
|
return $member;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function leave($group_id, $profile_id)
|
public static function leave($group_id, $profile_id)
|
||||||
{
|
{
|
||||||
$member = Group_member::pkeyGet(array('group_id' => $group_id,
|
$member = Group_member::pkeyGet(array('group_id' => $group_id,
|
||||||
'profile_id' => $profile_id));
|
'profile_id' => $profile_id));
|
||||||
|
@ -101,27 +120,27 @@ class Group_member extends Managed_DataObject
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMember()
|
public function getMember()
|
||||||
{
|
{
|
||||||
$member = Profile::getKV('id', $this->profile_id);
|
$member = Profile::getKV('id', $this->profile_id);
|
||||||
|
|
||||||
if (empty($member)) {
|
if (empty($member)) {
|
||||||
// TRANS: Exception thrown providing an invalid profile ID.
|
// TRANS: Exception thrown providing an invalid profile ID.
|
||||||
// TRANS: %s is the invalid profile ID.
|
// TRANS: %s is the invalid profile ID.
|
||||||
throw new Exception(sprintf(_("Profile ID %s is invalid."),$this->profile_id));
|
throw new Exception(sprintf(_("Profile ID %s is invalid."), $this->profile_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $member;
|
return $member;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGroup()
|
public function getGroup()
|
||||||
{
|
{
|
||||||
$group = User_group::getKV('id', $this->group_id);
|
$group = User_group::getKV('id', $this->group_id);
|
||||||
|
|
||||||
if (empty($group)) {
|
if (empty($group)) {
|
||||||
// TRANS: Exception thrown providing an invalid group ID.
|
// TRANS: Exception thrown providing an invalid group ID.
|
||||||
// TRANS: %s is the invalid group ID.
|
// TRANS: %s is the invalid group ID.
|
||||||
throw new Exception(sprintf(_("Group ID %s is invalid."),$this->group_id));
|
throw new Exception(sprintf(_('Group ID %s is invalid.'), $this->group_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $group;
|
return $group;
|
||||||
|
@ -137,7 +156,7 @@ class Group_member extends Managed_DataObject
|
||||||
* @return Group_member stream of memberships, use fetch() to iterate
|
* @return Group_member stream of memberships, use fetch() to iterate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static function byMember($memberId, $offset=0, $limit=GROUPS_PER_PAGE)
|
public static function byMember($memberId, $offset = 0, $limit = GROUPS_PER_PAGE)
|
||||||
{
|
{
|
||||||
$membership = new Group_member();
|
$membership = new Group_member();
|
||||||
|
|
||||||
|
@ -152,7 +171,7 @@ class Group_member extends Managed_DataObject
|
||||||
return $membership;
|
return $membership;
|
||||||
}
|
}
|
||||||
|
|
||||||
function asActivity()
|
public function asActivity()
|
||||||
{
|
{
|
||||||
$member = $this->getMember();
|
$member = $this->getMember();
|
||||||
|
|
||||||
|
@ -180,13 +199,19 @@ class Group_member extends Managed_DataObject
|
||||||
|
|
||||||
// TRANS: Success message for subscribe to group attempt through OStatus.
|
// TRANS: Success message for subscribe to group attempt through OStatus.
|
||||||
// TRANS: %1$s is the member name, %2$s is the subscribed group's name.
|
// TRANS: %1$s is the member name, %2$s is the subscribed group's name.
|
||||||
$act->content = sprintf(_('%1$s has joined group %2$s.'),
|
$act->content = sprintf(
|
||||||
$member->getBestName(),
|
_('%1$s has joined group %2$s.'),
|
||||||
$group->getBestName());
|
$member->getBestName(),
|
||||||
|
$group->getBestName()
|
||||||
|
);
|
||||||
|
|
||||||
$url = common_local_url('AtomPubShowMembership',
|
$url = common_local_url(
|
||||||
array('profile' => $member->id,
|
'AtomPubShowMembership',
|
||||||
'group' => $group->id));
|
[
|
||||||
|
'profile' => $member->id,
|
||||||
|
'group' => $group->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$act->selfLink = $url;
|
$act->selfLink = $url;
|
||||||
$act->editLink = $url;
|
$act->editLink = $url;
|
||||||
|
@ -203,7 +228,7 @@ class Group_member extends Managed_DataObject
|
||||||
mail_notify_group_join($this->getGroup(), $this->getMember());
|
mail_notify_group_join($this->getGroup(), $this->getMember());
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUri()
|
public function getUri()
|
||||||
{
|
{
|
||||||
return $this->uri ?: self::newUri($this->getMember(), $this->getGroup()->getProfile(), $this->created);
|
return $this->uri ?: self::newUri($this->getMember(), $this->getGroup()->getProfile(), $this->created);
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,12 +238,15 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data type formatting style...
|
// Data type formatting style...
|
||||||
$formatStyles = array('blob' => DB_DATAOBJECT_BLOB,
|
$formatStyles = [
|
||||||
'text' => DB_DATAOBJECT_TXT,
|
'blob' => DB_DATAOBJECT_BLOB,
|
||||||
'date' => DB_DATAOBJECT_DATE,
|
'text' => DB_DATAOBJECT_TXT,
|
||||||
'time' => DB_DATAOBJECT_TIME,
|
'bool' => DB_DATAOBJECT_BOOL,
|
||||||
'datetime' => DB_DATAOBJECT_DATE | DB_DATAOBJECT_TIME,
|
'date' => DB_DATAOBJECT_DATE,
|
||||||
'timestamp' => DB_DATAOBJECT_MYSQLTIMESTAMP);
|
'time' => DB_DATAOBJECT_TIME,
|
||||||
|
'datetime' => DB_DATAOBJECT_DATE | DB_DATAOBJECT_TIME,
|
||||||
|
'timestamp' => DB_DATAOBJECT_MYSQLTIMESTAMP,
|
||||||
|
];
|
||||||
|
|
||||||
if (isset($formatStyles[$type])) {
|
if (isset($formatStyles[$type])) {
|
||||||
$style |= $formatStyles[$type];
|
$style |= $formatStyles[$type];
|
||||||
|
|
|
@ -1,48 +1,36 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 2011, StatusNet, Inc.
|
|
||||||
*
|
|
||||||
* Older-style UI preferences
|
* Older-style UI preferences
|
||||||
*
|
|
||||||
* 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 UI
|
* @category UI
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2011 StatusNet, Inc.
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
// This check helps protect against security problems;
|
|
||||||
// your code file can't be executed directly from the web.
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Separate table for storing UI preferences
|
* Separate table for storing UI preferences
|
||||||
*
|
*
|
||||||
* @category UI
|
|
||||||
* @package StatusNet
|
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @copyright 2011 StatusNet, Inc.
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Old_school_prefs extends Managed_DataObject
|
class Old_school_prefs extends Managed_DataObject
|
||||||
|
@ -60,17 +48,14 @@ class Old_school_prefs extends Managed_DataObject
|
||||||
return array(
|
return array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'),
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'),
|
||||||
'stream_mode_only' => array('type' => 'int',
|
'stream_mode_only' => array('type' => 'bool',
|
||||||
'size' => 'tiny',
|
'default' => true,
|
||||||
'default' => 1,
|
|
||||||
'description' => 'No conversation streams'),
|
'description' => 'No conversation streams'),
|
||||||
'conversation_tree' => array('type' => 'int',
|
'conversation_tree' => array('type' => 'bool',
|
||||||
'size' => 'tiny',
|
'default' => true,
|
||||||
'default' => 1,
|
|
||||||
'description' => 'Hierarchical tree view for conversations'),
|
'description' => 'Hierarchical tree view for conversations'),
|
||||||
'stream_nicknames' => array('type' => 'int',
|
'stream_nicknames' => array('type' => 'bool',
|
||||||
'size' => 'tiny',
|
'default' => true,
|
||||||
'default' => 1,
|
|
||||||
'description' => 'Show nicknames for authors and addressees in streams'),
|
'description' => 'Show nicknames for authors and addressees in streams'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
//
|
||||||
* Copyright (C) 2008-2011, StatusNet, Inc.
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
*
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
// (at your option) any later version.
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
//
|
||||||
* (at your option) any later version.
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
*
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* This program is distributed in the hope that it will be useful,
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// GNU Affero General Public License for more details.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
//
|
||||||
* GNU Affero General Public License for more details.
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
*
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
/**
|
||||||
|
* @copyright 2008-2011 StatusNet, Inc.
|
||||||
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table Definition for profile
|
* Table Definition for profile
|
||||||
|
@ -81,7 +83,7 @@ class Profile extends Managed_DataObject
|
||||||
throw new NoSuchUserException(array('email'=>$email));
|
throw new NoSuchUserException(array('email'=>$email));
|
||||||
}
|
}
|
||||||
return $user->getProfile();
|
return $user->getProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $_user = array();
|
protected $_user = array();
|
||||||
|
|
||||||
|
@ -202,16 +204,16 @@ class Profile extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getBestName()
|
public function getBestName()
|
||||||
{
|
{
|
||||||
return ($this->fullname) ? $this->fullname : $this->nickname;
|
return ($this->fullname) ? $this->fullname : $this->nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes the currently scoped profile into account to give a name
|
* Takes the currently scoped profile into account to give a name
|
||||||
* to list in notice streams. Preferences may differ between profiles.
|
* to list in notice streams. Preferences may differ between profiles.
|
||||||
*/
|
*/
|
||||||
function getStreamName()
|
public function getStreamName()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
if ($user instanceof User && $user->streamNicknames()) {
|
if ($user instanceof User && $user->streamNicknames()) {
|
||||||
|
@ -228,7 +230,7 @@ class Profile extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getFancyName()
|
public function getFancyName()
|
||||||
{
|
{
|
||||||
$uri = null;
|
$uri = null;
|
||||||
try {
|
try {
|
||||||
|
@ -243,7 +245,7 @@ class Profile extends Managed_DataObject
|
||||||
|
|
||||||
if (mb_strlen($this->getFullname()) > 0) {
|
if (mb_strlen($this->getFullname()) > 0) {
|
||||||
// TRANS: The "fancy name": Full name of a profile or group (%1$s) followed by some URI (%2$s) in parentheses.
|
// TRANS: The "fancy name": Full name of a profile or group (%1$s) followed by some URI (%2$s) in parentheses.
|
||||||
return sprintf(_m('FANCYNAME','%1$s (%2$s)'), $this->getFullname(), $uri);
|
return sprintf(_m('FANCYNAME', '%1$s (%2$s)'), $this->getFullname(), $uri);
|
||||||
} else {
|
} else {
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +256,7 @@ class Profile extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return mixed Notice or null
|
* @return mixed Notice or null
|
||||||
*/
|
*/
|
||||||
function getCurrentNotice(Profile $scoped=null)
|
public function getCurrentNotice(Profile $scoped = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$notice = $this->getNotices(0, 1, 0, 0, $scoped);
|
$notice = $this->getNotices(0, 1, 0, 0, $scoped);
|
||||||
|
@ -271,16 +273,16 @@ class Profile extends Managed_DataObject
|
||||||
// Maybe we should let this through if it's handled well upstream
|
// Maybe we should let this through if it's handled well upstream
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
public function getReplies($offset = 0, $limit = NOTICES_PER_PAGE, $since_id = 0, $before_id = 0)
|
||||||
{
|
{
|
||||||
return Reply::stream($this->getID(), $offset, $limit, $since_id, $before_id);
|
return Reply::stream($this->getID(), $offset, $limit, $since_id, $before_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
public function getTaggedNotices($tag, $offset = 0, $limit = NOTICES_PER_PAGE, $since_id = 0, $max_id = 0)
|
||||||
{
|
{
|
||||||
//FIXME: Get Profile::current() some other way to avoid possible
|
//FIXME: Get Profile::current() some other way to avoid possible
|
||||||
// confusion between current session profile and background processing.
|
// confusion between current session profile and background processing.
|
||||||
|
@ -289,39 +291,39 @@ class Profile extends Managed_DataObject
|
||||||
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, Profile $scoped=null)
|
public function getNotices($offset = 0, $limit = NOTICES_PER_PAGE, $since_id = 0, $max_id = 0, Profile $scoped = null)
|
||||||
{
|
{
|
||||||
$stream = new ProfileNoticeStream($this, $scoped);
|
$stream = new ProfileNoticeStream($this, $scoped);
|
||||||
|
|
||||||
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
return $stream->getNotices($offset, $limit, $since_id, $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMember(User_group $group)
|
public function isMember(User_group $group)
|
||||||
{
|
{
|
||||||
$groups = $this->getGroups(0, null);
|
$groups = $this->getGroups(0, null);
|
||||||
while ($groups instanceof User_group && $groups->fetch()) {
|
while ($groups instanceof User_group && $groups->fetch()) {
|
||||||
if ($groups->id == $group->id) {
|
if ($groups->id == $group->id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAdmin(User_group $group)
|
public function isAdmin(User_group $group)
|
||||||
{
|
{
|
||||||
$gm = Group_member::pkeyGet(array('profile_id' => $this->id,
|
$gm = Group_member::pkeyGet(array('profile_id' => $this->id,
|
||||||
'group_id' => $group->id));
|
'group_id' => $group->id));
|
||||||
return (!empty($gm) && $gm->is_admin);
|
return (!empty($gm) && $gm->is_admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPendingMember($group)
|
public function isPendingMember($group)
|
||||||
{
|
{
|
||||||
$request = Group_join_queue::pkeyGet(array('profile_id' => $this->id,
|
$request = Group_join_queue::pkeyGet(array('profile_id' => $this->id,
|
||||||
'group_id' => $group->id));
|
'group_id' => $group->id));
|
||||||
return !empty($request);
|
return !empty($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGroups($offset=0, $limit=PROFILES_PER_PAGE)
|
public function getGroups($offset = 0, $limit = PROFILES_PER_PAGE)
|
||||||
{
|
{
|
||||||
$ids = array();
|
$ids = array();
|
||||||
|
|
||||||
|
@ -356,14 +358,15 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGroupCount() {
|
public function getGroupCount()
|
||||||
|
{
|
||||||
$groups = $this->getGroups(0, null);
|
$groups = $this->getGroups(0, null);
|
||||||
return $groups instanceof User_group
|
return $groups instanceof User_group
|
||||||
? $groups->N
|
? $groups->N
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isTagged($peopletag)
|
public function isTagged($peopletag)
|
||||||
{
|
{
|
||||||
$tag = Profile_tag::pkeyGet(array('tagger' => $peopletag->tagger,
|
$tag = Profile_tag::pkeyGet(array('tagger' => $peopletag->tagger,
|
||||||
'tagged' => $this->id,
|
'tagged' => $this->id,
|
||||||
|
@ -371,7 +374,7 @@ class Profile extends Managed_DataObject
|
||||||
return !empty($tag);
|
return !empty($tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function canTag($tagged)
|
public function canTag($tagged)
|
||||||
{
|
{
|
||||||
if (empty($tagged)) {
|
if (empty($tagged)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -395,16 +398,16 @@ class Profile extends Managed_DataObject
|
||||||
if ($local) {
|
if ($local) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if ($subs) {
|
} elseif ($subs) {
|
||||||
return (Subscription::exists($this, $tagged) ||
|
return (Subscription::exists($this, $tagged) ||
|
||||||
Subscription::exists($tagged, $this));
|
Subscription::exists($tagged, $this));
|
||||||
} else if ($remote) {
|
} elseif ($remote) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLists(Profile $scoped=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
|
public function getLists(Profile $scoped = null, $offset = 0, $limit = null, $since_id = 0, $max_id = 0)
|
||||||
{
|
{
|
||||||
$ids = array();
|
$ids = array();
|
||||||
|
|
||||||
|
@ -421,15 +424,15 @@ class Profile extends Managed_DataObject
|
||||||
$list->tagger = $this->id;
|
$list->tagger = $this->id;
|
||||||
$list->selectAdd('id as "cursor"');
|
$list->selectAdd('id as "cursor"');
|
||||||
|
|
||||||
if ($since_id>0) {
|
if ($since_id > 0) {
|
||||||
$list->whereAdd('id > '.$since_id);
|
$list->whereAdd('id > ' . $since_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($max_id>0) {
|
if ($max_id > 0) {
|
||||||
$list->whereAdd('id <= '.$max_id);
|
$list->whereAdd('id <= ' . $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($offset>=0 && !is_null($limit)) {
|
if ($offset >= 0 && !is_null($limit)) {
|
||||||
$list->limit($offset, $limit);
|
$list->limit($offset, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +455,6 @@ class Profile extends Managed_DataObject
|
||||||
$list = Profile_list::getKV('id', $id);
|
$list = Profile_list::getKV('id', $id);
|
||||||
if (!empty($list) &&
|
if (!empty($list) &&
|
||||||
($showPrivate || !$list->private)) {
|
($showPrivate || !$list->private)) {
|
||||||
|
|
||||||
if (!isset($list->cursor)) {
|
if (!isset($list->cursor)) {
|
||||||
$list->cursor = $list->id;
|
$list->cursor = $list->id;
|
||||||
}
|
}
|
||||||
|
@ -476,25 +478,28 @@ class Profile extends Managed_DataObject
|
||||||
* @return Profile_list resulting lists
|
* @return Profile_list resulting lists
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getOtherTags(Profile $scoped=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
|
public function getOtherTags(Profile $scoped = null, $offset = 0, $limit = null, $since_id = 0, $max_id = 0)
|
||||||
{
|
{
|
||||||
$list = new Profile_list();
|
$list = new Profile_list();
|
||||||
|
|
||||||
$qry = sprintf('select profile_list.*, unix_timestamp(profile_tag.modified) as "cursor" ' .
|
$qry = sprintf(
|
||||||
'from profile_tag join profile_list '.
|
'SELECT profile_list.*, unix_timestamp(profile_tag.modified) AS "cursor" ' .
|
||||||
'on (profile_tag.tagger = profile_list.tagger ' .
|
'FROM profile_tag JOIN profile_list '.
|
||||||
' and profile_tag.tag = profile_list.tag) ' .
|
'ON (profile_tag.tagger = profile_list.tagger ' .
|
||||||
'where profile_tag.tagged = %d ',
|
' AND profile_tag.tag = profile_list.tag) ' .
|
||||||
$this->id);
|
'WHERE profile_tag.tagged = %d ',
|
||||||
|
$this->id
|
||||||
|
);
|
||||||
|
|
||||||
if (!is_null($scoped)) {
|
if (!is_null($scoped)) {
|
||||||
$qry .= sprintf('AND ( ( profile_list.private = false ) ' .
|
$qry .= sprintf(
|
||||||
'OR ( profile_list.tagger = %d AND ' .
|
'AND ( profile_list.private = false ' .
|
||||||
'profile_list.private = true ) )',
|
'OR ( profile_list.tagger = %d AND ' .
|
||||||
$scoped->getID());
|
'profile_list.private = TRUE ) )',
|
||||||
|
$scoped->getID()
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$qry .= 'AND profile_list.private = 0 ';
|
$qry .= 'AND profile_list.private = FALSE ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($since_id > 0) {
|
if ($since_id > 0) {
|
||||||
|
@ -515,21 +520,21 @@ class Profile extends Managed_DataObject
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPrivateTags($offset=0, $limit=null, $since_id=0, $max_id=0)
|
public function getPrivateTags($offset = 0, $limit = null, $since_id = 0, $max_id = 0)
|
||||||
{
|
{
|
||||||
$tags = new Profile_list();
|
$tags = new Profile_list();
|
||||||
$tags->private = true;
|
$tags->private = true;
|
||||||
$tags->tagger = $this->id;
|
$tags->tagger = $this->id;
|
||||||
|
|
||||||
if ($since_id>0) {
|
if ($since_id > 0) {
|
||||||
$tags->whereAdd('id > '.$since_id);
|
$tags->whereAdd('id > ' . $since_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($max_id>0) {
|
if ($max_id > 0) {
|
||||||
$tags->whereAdd('id <= '.$max_id);
|
$tags->whereAdd('id <= ' . $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($offset>=0 && !is_null($limit)) {
|
if ($offset >= 0 && !is_null($limit)) {
|
||||||
$tags->limit($offset, $limit);
|
$tags->limit($offset, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,7 +544,7 @@ class Profile extends Managed_DataObject
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasLocalTags()
|
public function hasLocalTags()
|
||||||
{
|
{
|
||||||
$tags = new Profile_tag();
|
$tags = new Profile_tag();
|
||||||
|
|
||||||
|
@ -553,7 +558,7 @@ class Profile extends Managed_DataObject
|
||||||
return ($tags->N == 0) ? false : true;
|
return ($tags->N == 0) ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTagSubscriptions($offset=0, $limit=null, $since_id=0, $max_id=0)
|
public function getTagSubscriptions($offset = 0, $limit = null, $since_id = 0, $max_id = 0)
|
||||||
{
|
{
|
||||||
$lists = new Profile_list();
|
$lists = new Profile_list();
|
||||||
$subs = new Profile_tag_subscription();
|
$subs = new Profile_tag_subscription();
|
||||||
|
@ -565,15 +570,15 @@ class Profile extends Managed_DataObject
|
||||||
|
|
||||||
$lists->whereAdd('profile_tag_subscription.profile_id = '.$this->id);
|
$lists->whereAdd('profile_tag_subscription.profile_id = '.$this->id);
|
||||||
|
|
||||||
if ($since_id>0) {
|
if ($since_id > 0) {
|
||||||
$lists->whereAdd('cursor > '.$since_id);
|
$lists->whereAdd('cursor > ' . $since_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($max_id>0) {
|
if ($max_id > 0) {
|
||||||
$lists->whereAdd('cursor <= '.$max_id);
|
$lists->whereAdd('cursor <= ' . $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($offset>=0 && !is_null($limit)) {
|
if ($offset >= 0 && !is_null($limit)) {
|
||||||
$lists->limit($offset, $limit);
|
$lists->limit($offset, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +595,7 @@ class Profile extends Managed_DataObject
|
||||||
* @param User_group $group
|
* @param User_group $group
|
||||||
* @return mixed: Group_member on success, Group_join_queue if pending approval, null on some cancels?
|
* @return mixed: Group_member on success, Group_join_queue if pending approval, null on some cancels?
|
||||||
*/
|
*/
|
||||||
function joinGroup(User_group $group)
|
public function joinGroup(User_group $group)
|
||||||
{
|
{
|
||||||
$join = null;
|
$join = null;
|
||||||
if ($group->join_policy == User_group::JOIN_POLICY_MODERATE) {
|
if ($group->join_policy == User_group::JOIN_POLICY_MODERATE) {
|
||||||
|
@ -616,7 +621,7 @@ class Profile extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @param User_group $group
|
* @param User_group $group
|
||||||
*/
|
*/
|
||||||
function leaveGroup(User_group $group)
|
public function leaveGroup(User_group $group)
|
||||||
{
|
{
|
||||||
if (Event::handle('StartLeaveGroup', array($group, $this))) {
|
if (Event::handle('StartLeaveGroup', array($group, $this))) {
|
||||||
Group_member::leave($group->id, $this->id);
|
Group_member::leave($group->id, $this->id);
|
||||||
|
@ -627,12 +632,12 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function avatarUrl($size=AVATAR_PROFILE_SIZE)
|
public function avatarUrl($size = AVATAR_PROFILE_SIZE)
|
||||||
{
|
{
|
||||||
return Avatar::urlByProfile($this, $size);
|
return Avatar::urlByProfile($this, $size);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSubscribed($offset=0, $limit=null)
|
public function getSubscribed($offset = 0, $limit = null)
|
||||||
{
|
{
|
||||||
$subs = Subscription::getSubscribedIDs($this->id, $offset, $limit);
|
$subs = Subscription::getSubscribedIDs($this->id, $offset, $limit);
|
||||||
try {
|
try {
|
||||||
|
@ -643,7 +648,7 @@ class Profile extends Managed_DataObject
|
||||||
return $profiles;
|
return $profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSubscribers($offset=0, $limit=null)
|
public function getSubscribers($offset = 0, $limit = null)
|
||||||
{
|
{
|
||||||
$subs = Subscription::getSubscriberIDs($this->id, $offset, $limit);
|
$subs = Subscription::getSubscriberIDs($this->id, $offset, $limit);
|
||||||
try {
|
try {
|
||||||
|
@ -654,7 +659,7 @@ class Profile extends Managed_DataObject
|
||||||
return $profiles;
|
return $profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTaggedSubscribers($tag, $offset=0, $limit=null)
|
public function getTaggedSubscribers($tag, $offset = 0, $limit = null)
|
||||||
{
|
{
|
||||||
$qry =
|
$qry =
|
||||||
'SELECT profile.* ' .
|
'SELECT profile.* ' .
|
||||||
|
@ -678,7 +683,7 @@ class Profile extends Managed_DataObject
|
||||||
return $profile;
|
return $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTaggedSubscriptions($tag, $offset=0, $limit=null)
|
public function getTaggedSubscriptions($tag, $offset = 0, $limit = null)
|
||||||
{
|
{
|
||||||
$qry =
|
$qry =
|
||||||
'SELECT profile.* ' .
|
'SELECT profile.* ' .
|
||||||
|
@ -707,7 +712,7 @@ class Profile extends Managed_DataObject
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
* @return Profile
|
* @return Profile
|
||||||
*/
|
*/
|
||||||
function getRequests($offset=0, $limit=null)
|
public function getRequests($offset = 0, $limit = null)
|
||||||
{
|
{
|
||||||
// FIXME: mysql only
|
// FIXME: mysql only
|
||||||
$subqueue = new Profile();
|
$subqueue = new Profile();
|
||||||
|
@ -721,7 +726,7 @@ class Profile extends Managed_DataObject
|
||||||
return $subqueue;
|
return $subqueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscriptionCount()
|
public function subscriptionCount()
|
||||||
{
|
{
|
||||||
$c = Cache::instance();
|
$c = Cache::instance();
|
||||||
|
|
||||||
|
@ -749,7 +754,7 @@ class Profile extends Managed_DataObject
|
||||||
return $cnt;
|
return $cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscriberCount()
|
public function subscriberCount()
|
||||||
{
|
{
|
||||||
$c = Cache::instance();
|
$c = Cache::instance();
|
||||||
if (!empty($c)) {
|
if (!empty($c)) {
|
||||||
|
@ -777,12 +782,12 @@ class Profile extends Managed_DataObject
|
||||||
* @param Profile $other
|
* @param Profile $other
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isSubscribed(Profile $other)
|
public function isSubscribed(Profile $other)
|
||||||
{
|
{
|
||||||
return Subscription::exists($this, $other);
|
return Subscription::exists($this, $other);
|
||||||
}
|
}
|
||||||
|
|
||||||
function readableBy(Profile $other=null)
|
public function readableBy(Profile $other = null)
|
||||||
{
|
{
|
||||||
// If it's not a private stream, it's readable by anyone
|
// If it's not a private stream, it's readable by anyone
|
||||||
if (!$this->isPrivateStream()) {
|
if (!$this->isPrivateStream()) {
|
||||||
|
@ -793,7 +798,7 @@ class Profile extends Managed_DataObject
|
||||||
return is_null($other) ? false : $other->isSubscribed($this);
|
return is_null($other) ? false : $other->isSubscribed($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function requiresSubscriptionApproval(Profile $other=null): bool
|
public function requiresSubscriptionApproval(Profile $other = null): bool
|
||||||
{
|
{
|
||||||
if (!$this->isLocal()) {
|
if (!$this->isLocal()) {
|
||||||
// We don't know for remote users, and we'll always be able to send
|
// We don't know for remote users, and we'll always be able to send
|
||||||
|
@ -818,7 +823,7 @@ class Profile extends Managed_DataObject
|
||||||
* @param Profile $other
|
* @param Profile $other
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function hasPendingSubscription(Profile $other)
|
public function hasPendingSubscription(Profile $other)
|
||||||
{
|
{
|
||||||
return Subscription_queue::exists($this, $other);
|
return Subscription_queue::exists($this, $other);
|
||||||
}
|
}
|
||||||
|
@ -829,13 +834,13 @@ class Profile extends Managed_DataObject
|
||||||
* @param Profile $other
|
* @param Profile $other
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function mutuallySubscribed(Profile $other)
|
public function mutuallySubscribed(Profile $other)
|
||||||
{
|
{
|
||||||
return $this->isSubscribed($other) &&
|
return $this->isSubscribed($other) &&
|
||||||
$other->isSubscribed($this);
|
$other->isSubscribed($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function noticeCount()
|
public function noticeCount()
|
||||||
{
|
{
|
||||||
$c = Cache::instance();
|
$c = Cache::instance();
|
||||||
|
|
||||||
|
@ -858,7 +863,7 @@ class Profile extends Managed_DataObject
|
||||||
return $cnt;
|
return $cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
function blowSubscriberCount()
|
public function blowSubscriberCount()
|
||||||
{
|
{
|
||||||
$c = Cache::instance();
|
$c = Cache::instance();
|
||||||
if (!empty($c)) {
|
if (!empty($c)) {
|
||||||
|
@ -866,7 +871,7 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function blowSubscriptionCount()
|
public function blowSubscriptionCount()
|
||||||
{
|
{
|
||||||
$c = Cache::instance();
|
$c = Cache::instance();
|
||||||
if (!empty($c)) {
|
if (!empty($c)) {
|
||||||
|
@ -874,7 +879,7 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function blowNoticeCount()
|
public function blowNoticeCount()
|
||||||
{
|
{
|
||||||
$c = Cache::instance();
|
$c = Cache::instance();
|
||||||
if (!empty($c)) {
|
if (!empty($c)) {
|
||||||
|
@ -882,7 +887,7 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function maxBio()
|
public static function maxBio()
|
||||||
{
|
{
|
||||||
$biolimit = common_config('profile', 'biolimit');
|
$biolimit = common_config('profile', 'biolimit');
|
||||||
// null => use global limit (distinct from 0!)
|
// null => use global limit (distinct from 0!)
|
||||||
|
@ -892,13 +897,13 @@ class Profile extends Managed_DataObject
|
||||||
return $biolimit;
|
return $biolimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function bioTooLong($bio)
|
public static function bioTooLong($bio)
|
||||||
{
|
{
|
||||||
$biolimit = self::maxBio();
|
$biolimit = self::maxBio();
|
||||||
return ($biolimit > 0 && !empty($bio) && (mb_strlen($bio) > $biolimit));
|
return ($biolimit > 0 && !empty($bio) && (mb_strlen($bio) > $biolimit));
|
||||||
}
|
}
|
||||||
|
|
||||||
function update($dataObject=false)
|
public function update($dataObject = false)
|
||||||
{
|
{
|
||||||
if (is_object($dataObject) && $this->nickname != $dataObject->nickname) {
|
if (is_object($dataObject) && $this->nickname != $dataObject->nickname) {
|
||||||
try {
|
try {
|
||||||
|
@ -946,7 +951,7 @@ class Profile extends Managed_DataObject
|
||||||
return $relMes;
|
return $relMes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete($useWhere=false)
|
public function delete($useWhere = false)
|
||||||
{
|
{
|
||||||
$this->_deleteNotices();
|
$this->_deleteNotices();
|
||||||
$this->_deleteSubscriptions();
|
$this->_deleteSubscriptions();
|
||||||
|
@ -957,10 +962,11 @@ class Profile extends Managed_DataObject
|
||||||
|
|
||||||
// Warning: delete() will run on the batch objects,
|
// Warning: delete() will run on the batch objects,
|
||||||
// not on individual objects.
|
// not on individual objects.
|
||||||
$related = array('Reply',
|
$related = [
|
||||||
'Group_member',
|
'Reply',
|
||||||
'Profile_role'
|
'Group_member',
|
||||||
);
|
'Profile_role',
|
||||||
|
];
|
||||||
Event::handle('ProfileDeleteRelated', array($this, &$related));
|
Event::handle('ProfileDeleteRelated', array($this, &$related));
|
||||||
|
|
||||||
foreach ($related as $cls) {
|
foreach ($related as $cls) {
|
||||||
|
@ -968,7 +974,7 @@ class Profile extends Managed_DataObject
|
||||||
$inst->profile_id = $this->id;
|
$inst->profile_id = $this->id;
|
||||||
$inst->delete();
|
$inst->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->grantRole(Profile_role::DELETED);
|
$this->grantRole(Profile_role::DELETED);
|
||||||
|
|
||||||
$localuser = User::getKV('id', $this->id);
|
$localuser = User::getKV('id', $this->id);
|
||||||
|
@ -979,7 +985,7 @@ class Profile extends Managed_DataObject
|
||||||
return parent::delete($useWhere);
|
return parent::delete($useWhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _deleteNotices()
|
public function _deleteNotices()
|
||||||
{
|
{
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
$notice->profile_id = $this->id;
|
$notice->profile_id = $this->id;
|
||||||
|
@ -992,7 +998,7 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _deleteSubscriptions()
|
public function _deleteSubscriptions()
|
||||||
{
|
{
|
||||||
$sub = new Subscription();
|
$sub = new Subscription();
|
||||||
$sub->subscriber = $this->getID();
|
$sub->subscriber = $this->getID();
|
||||||
|
@ -1040,14 +1046,14 @@ class Profile extends Managed_DataObject
|
||||||
$self->delete();
|
$self->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _deleteTags()
|
public function _deleteTags()
|
||||||
{
|
{
|
||||||
$tag = new Profile_tag();
|
$tag = new Profile_tag();
|
||||||
$tag->tagged = $this->id;
|
$tag->tagged = $this->id;
|
||||||
$tag->delete();
|
$tag->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _deleteBlocks()
|
public function _deleteBlocks()
|
||||||
{
|
{
|
||||||
$block = new Profile_block();
|
$block = new Profile_block();
|
||||||
$block->blocked = $this->id;
|
$block->blocked = $this->id;
|
||||||
|
@ -1058,7 +1064,7 @@ class Profile extends Managed_DataObject
|
||||||
$block->delete();
|
$block->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _deleteAttentions()
|
public function _deleteAttentions()
|
||||||
{
|
{
|
||||||
$att = new Attention();
|
$att = new Attention();
|
||||||
$att->profile_id = $this->getID();
|
$att->profile_id = $this->getID();
|
||||||
|
@ -1103,7 +1109,7 @@ class Profile extends Managed_DataObject
|
||||||
|
|
||||||
if ($cfg == 'always') {
|
if ($cfg == 'always') {
|
||||||
return true;
|
return true;
|
||||||
} else if ($cfg == 'never') {
|
} elseif ($cfg == 'never') {
|
||||||
return false;
|
return false;
|
||||||
} else { // user
|
} else { // user
|
||||||
$share = common_config('location', 'sharedefault');
|
$share = common_config('location', 'sharedefault');
|
||||||
|
@ -1120,7 +1126,7 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasRole($name)
|
public function hasRole($name)
|
||||||
{
|
{
|
||||||
$has_role = false;
|
$has_role = false;
|
||||||
if (Event::handle('StartHasRole', array($this, $name, &$has_role))) {
|
if (Event::handle('StartHasRole', array($this, $name, &$has_role))) {
|
||||||
|
@ -1132,10 +1138,9 @@ class Profile extends Managed_DataObject
|
||||||
return $has_role;
|
return $has_role;
|
||||||
}
|
}
|
||||||
|
|
||||||
function grantRole($name)
|
public function grantRole($name)
|
||||||
{
|
{
|
||||||
if (Event::handle('StartGrantRole', array($this, $name))) {
|
if (Event::handle('StartGrantRole', array($this, $name))) {
|
||||||
|
|
||||||
$role = new Profile_role();
|
$role = new Profile_role();
|
||||||
|
|
||||||
$role->profile_id = $this->id;
|
$role->profile_id = $this->id;
|
||||||
|
@ -1158,17 +1163,20 @@ class Profile extends Managed_DataObject
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function revokeRole($name)
|
public function revokeRole($name)
|
||||||
{
|
{
|
||||||
if (Event::handle('StartRevokeRole', array($this, $name))) {
|
if (Event::handle('StartRevokeRole', array($this, $name))) {
|
||||||
|
|
||||||
$role = Profile_role::pkeyGet(array('profile_id' => $this->id,
|
$role = Profile_role::pkeyGet(array('profile_id' => $this->id,
|
||||||
'role' => $name));
|
'role' => $name));
|
||||||
|
|
||||||
if (empty($role)) {
|
if (empty($role)) {
|
||||||
// TRANS: Exception thrown when trying to revoke an existing role for a user that does not exist.
|
// TRANS: Exception thrown when trying to revoke an existing role for a user that does not exist.
|
||||||
// TRANS: %1$s is the role name, %2$s is the user ID (number).
|
// TRANS: %1$s is the role name, %2$s is the user ID (number).
|
||||||
throw new Exception(sprintf(_('Cannot revoke role "%1$s" for user #%2$d; does not exist.'),$name, $this->id));
|
throw new Exception(sprintf(
|
||||||
|
_('Cannot revoke role "%1$s" for user #%2$d; does not exist.'),
|
||||||
|
$name,
|
||||||
|
$this->id
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $role->delete();
|
$result = $role->delete();
|
||||||
|
@ -1177,7 +1185,11 @@ class Profile extends Managed_DataObject
|
||||||
common_log_db_error($role, 'DELETE', __FILE__);
|
common_log_db_error($role, 'DELETE', __FILE__);
|
||||||
// TRANS: Exception thrown when trying to revoke a role for a user with a failing database query.
|
// TRANS: Exception thrown when trying to revoke a role for a user with a failing database query.
|
||||||
// TRANS: %1$s is the role name, %2$s is the user ID (number).
|
// TRANS: %1$s is the role name, %2$s is the user ID (number).
|
||||||
throw new Exception(sprintf(_('Cannot revoke role "%1$s" for user #%2$d; database error.'),$name, $this->id));
|
throw new Exception(sprintf(
|
||||||
|
_('Cannot revoke role "%1$s" for user #%2$d; database error.'),
|
||||||
|
$name,
|
||||||
|
$this->id
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name == 'owner') {
|
if ($name == 'owner') {
|
||||||
|
@ -1190,27 +1202,27 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSandboxed()
|
public function isSandboxed()
|
||||||
{
|
{
|
||||||
return $this->hasRole(Profile_role::SANDBOXED);
|
return $this->hasRole(Profile_role::SANDBOXED);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSilenced()
|
public function isSilenced()
|
||||||
{
|
{
|
||||||
return $this->hasRole(Profile_role::SILENCED);
|
return $this->hasRole(Profile_role::SILENCED);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sandbox()
|
public function sandbox()
|
||||||
{
|
{
|
||||||
$this->grantRole(Profile_role::SANDBOXED);
|
$this->grantRole(Profile_role::SANDBOXED);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsandbox()
|
public function unsandbox()
|
||||||
{
|
{
|
||||||
$this->revokeRole(Profile_role::SANDBOXED);
|
$this->revokeRole(Profile_role::SANDBOXED);
|
||||||
}
|
}
|
||||||
|
|
||||||
function silence()
|
public function silence()
|
||||||
{
|
{
|
||||||
$this->grantRole(Profile_role::SILENCED);
|
$this->grantRole(Profile_role::SILENCED);
|
||||||
if (common_config('notice', 'hidespam')) {
|
if (common_config('notice', 'hidespam')) {
|
||||||
|
@ -1218,7 +1230,7 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function silenceAs(Profile $actor)
|
public function silenceAs(Profile $actor)
|
||||||
{
|
{
|
||||||
if (!$actor->hasRight(Right::SILENCEUSER)) {
|
if (!$actor->hasRight(Right::SILENCEUSER)) {
|
||||||
throw new AuthorizationException(_('You cannot silence users on this site.'));
|
throw new AuthorizationException(_('You cannot silence users on this site.'));
|
||||||
|
@ -1234,7 +1246,7 @@ class Profile extends Managed_DataObject
|
||||||
return $this->silence();
|
return $this->silence();
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsilence()
|
public function unsilence()
|
||||||
{
|
{
|
||||||
$this->revokeRole(Profile_role::SILENCED);
|
$this->revokeRole(Profile_role::SILENCED);
|
||||||
if (common_config('notice', 'hidespam')) {
|
if (common_config('notice', 'hidespam')) {
|
||||||
|
@ -1242,7 +1254,7 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsilenceAs(Profile $actor)
|
public function unsilenceAs(Profile $actor)
|
||||||
{
|
{
|
||||||
if (!$actor->hasRight(Right::SILENCEUSER)) {
|
if (!$actor->hasRight(Right::SILENCEUSER)) {
|
||||||
// TRANS: Client error displayed trying to unsilence a user when the user does not have the right.
|
// TRANS: Client error displayed trying to unsilence a user when the user does not have the right.
|
||||||
|
@ -1255,7 +1267,7 @@ class Profile extends Managed_DataObject
|
||||||
return $this->unsilence();
|
return $this->unsilence();
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushVisibility()
|
public function flushVisibility()
|
||||||
{
|
{
|
||||||
// Get all notices
|
// Get all notices
|
||||||
$stream = new ProfileNoticeStream($this, $this);
|
$stream = new ProfileNoticeStream($this, $this);
|
||||||
|
@ -1301,8 +1313,7 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Event::handle('UserRightsCheck', array($this, $right, &$result))) {
|
if (Event::handle('UserRightsCheck', array($this, $right, &$result))) {
|
||||||
switch ($right)
|
switch ($right) {
|
||||||
{
|
|
||||||
case Right::DELETEOTHERSNOTICE:
|
case Right::DELETEOTHERSNOTICE:
|
||||||
case Right::MAKEGROUPADMIN:
|
case Right::MAKEGROUPADMIN:
|
||||||
case Right::SANDBOXUSER:
|
case Right::SANDBOXUSER:
|
||||||
|
@ -1380,7 +1391,7 @@ class Profile extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function asAtomAuthor($cur = null)
|
public function asAtomAuthor($cur = null)
|
||||||
{
|
{
|
||||||
$xs = new XMLStringer(true);
|
$xs = new XMLStringer(true);
|
||||||
|
|
||||||
|
@ -1388,7 +1399,7 @@ class Profile extends Managed_DataObject
|
||||||
$xs->element('name', null, $this->nickname);
|
$xs->element('name', null, $this->nickname);
|
||||||
$xs->element('uri', null, $this->getUri());
|
$xs->element('uri', null, $this->getUri());
|
||||||
if ($cur != null) {
|
if ($cur != null) {
|
||||||
$attrs = Array();
|
$attrs = [];
|
||||||
$attrs['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
|
$attrs['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
|
||||||
$attrs['blocking'] = $cur->hasBlocked($this) ? 'true' : 'false';
|
$attrs['blocking'] = $cur->hasBlocked($this) ? 'true' : 'false';
|
||||||
$xs->element('statusnet:profile_info', $attrs, null);
|
$xs->element('statusnet:profile_info', $attrs, null);
|
||||||
|
@ -1409,7 +1420,7 @@ class Profile extends Managed_DataObject
|
||||||
* @return array representation of <statusnet:profile_info> element or null
|
* @return array representation of <statusnet:profile_info> element or null
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function profileInfo(Profile $scoped=null)
|
public function profileInfo(Profile $scoped = null)
|
||||||
{
|
{
|
||||||
$profileInfoAttr = array('local_id' => $this->id);
|
$profileInfoAttr = array('local_id' => $this->id);
|
||||||
|
|
||||||
|
@ -1431,7 +1442,7 @@ class Profile extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function asActivityActor()
|
public function asActivityActor()
|
||||||
{
|
{
|
||||||
return $this->asActivityNoun('actor');
|
return $this->asActivityNoun('actor');
|
||||||
}
|
}
|
||||||
|
@ -1447,7 +1458,7 @@ class Profile extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function asActivityNoun($element)
|
public function asActivityNoun($element)
|
||||||
{
|
{
|
||||||
$noun = $this->asActivityObject();
|
$noun = $this->asActivityObject();
|
||||||
return $noun->asString('activity:' . $element);
|
return $noun->asString('activity:' . $element);
|
||||||
|
@ -1619,7 +1630,7 @@ class Profile extends Managed_DataObject
|
||||||
return $scheme ? $acct : mb_substr($acct, 5);
|
return $scheme ? $acct : mb_substr($acct, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasBlocked(Profile $other)
|
public function hasBlocked(Profile $other)
|
||||||
{
|
{
|
||||||
$block = Profile_block::exists($this, $other);
|
$block = Profile_block::exists($this, $other);
|
||||||
return !empty($block);
|
return !empty($block);
|
||||||
|
@ -1652,7 +1663,7 @@ class Profile extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @param string $uri A unique identifier for a resource (profile/group/whatever)
|
* @param string $uri A unique identifier for a resource (profile/group/whatever)
|
||||||
*/
|
*/
|
||||||
static function fromUri($uri)
|
public static function fromUri($uri)
|
||||||
{
|
{
|
||||||
$profile = null;
|
$profile = null;
|
||||||
|
|
||||||
|
@ -1677,7 +1688,7 @@ class Profile extends Managed_DataObject
|
||||||
return $profile;
|
return $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function canRead(Notice $notice)
|
public function canRead(Notice $notice)
|
||||||
{
|
{
|
||||||
if ($notice->scope & Notice::SITE_SCOPE) {
|
if ($notice->scope & Notice::SITE_SCOPE) {
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
@ -1717,7 +1728,7 @@ class Profile extends Managed_DataObject
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function current()
|
public static function current()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
|
@ -1728,7 +1739,7 @@ class Profile extends Managed_DataObject
|
||||||
return $profile;
|
return $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ensureCurrent()
|
public static function ensureCurrent()
|
||||||
{
|
{
|
||||||
$profile = self::current();
|
$profile = self::current();
|
||||||
if (!$profile instanceof Profile) {
|
if (!$profile instanceof Profile) {
|
||||||
|
@ -1747,7 +1758,7 @@ class Profile extends Managed_DataObject
|
||||||
* @return array of variable names to include in serialization.
|
* @return array of variable names to include in serialization.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function __sleep()
|
public function __sleep()
|
||||||
{
|
{
|
||||||
$vars = parent::__sleep();
|
$vars = parent::__sleep();
|
||||||
$skip = array('_user', '_group');
|
$skip = array('_user', '_group');
|
||||||
|
@ -1802,11 +1813,13 @@ class Profile extends Managed_DataObject
|
||||||
return !is_null($private_stream) && $private_stream;
|
return !is_null($private_stream) && $private_stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delPref($namespace, $topic) {
|
public function delPref($namespace, $topic)
|
||||||
|
{
|
||||||
return Profile_prefs::setData($this, $namespace, $topic, null);
|
return Profile_prefs::setData($this, $namespace, $topic, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPref($namespace, $topic, $default=null) {
|
public function getPref($namespace, $topic, $default = null)
|
||||||
|
{
|
||||||
// If you want an exception to be thrown, call Profile_prefs::getData directly
|
// If you want an exception to be thrown, call Profile_prefs::getData directly
|
||||||
try {
|
try {
|
||||||
return Profile_prefs::getData($this, $namespace, $topic, $default);
|
return Profile_prefs::getData($this, $namespace, $topic, $default);
|
||||||
|
@ -1821,7 +1834,8 @@ class Profile extends Managed_DataObject
|
||||||
return Profile_prefs::getConfigData($this, $namespace, $topic);
|
return Profile_prefs::getConfigData($this, $namespace, $topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPref($namespace, $topic, $data) {
|
public function setPref($namespace, $topic, $data)
|
||||||
|
{
|
||||||
return Profile_prefs::setData($this, $namespace, $topic, $data);
|
return Profile_prefs::setData($this, $namespace, $topic, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Profile_list extends Managed_DataObject
|
||||||
public $tagger; // int(4)
|
public $tagger; // int(4)
|
||||||
public $tag; // varchar(64)
|
public $tag; // varchar(64)
|
||||||
public $description; // text
|
public $description; // text
|
||||||
public $private; // tinyint(1)
|
public $private; // bool default_false
|
||||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||||
|
@ -47,7 +47,7 @@ class Profile_list extends Managed_DataObject
|
||||||
'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'),
|
'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'),
|
||||||
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'people tag'),
|
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'people tag'),
|
||||||
'description' => array('type' => 'text', 'description' => 'description of the people tag'),
|
'description' => array('type' => 'text', 'description' => 'description of the people tag'),
|
||||||
'private' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this tag private'),
|
'private' => array('type' => 'bool', 'default' => false, 'description' => 'is this tag private'),
|
||||||
|
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the tag was added'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the tag was added'),
|
||||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date the tag was modified'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date the tag was modified'),
|
||||||
|
|
|
@ -96,7 +96,7 @@ class Profile_tag extends Managed_DataObject
|
||||||
$qry = sprintf($qry, $tagger, $tagged);
|
$qry = sprintf($qry, $tagger, $tagged);
|
||||||
|
|
||||||
if (!$include_priv) {
|
if (!$include_priv) {
|
||||||
$qry .= ' and profile_list.private = 0';
|
$qry .= ' AND profile_list.private = FALSE';
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile_list->query($qry);
|
$profile_list->query($qry);
|
||||||
|
@ -122,7 +122,7 @@ class Profile_tag extends Managed_DataObject
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$scoped instanceof Profile || $scoped->getID() !== $tagger) {
|
if (!$scoped instanceof Profile || $scoped->getID() !== $tagger) {
|
||||||
$qry .= 'and profile_list.private = 0';
|
$qry .= 'AND profile_list.private = FALSE';
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags = array();
|
$tags = array();
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
//
|
||||||
* Copyright (C) 2008, 2009, StatusNet, Inc.
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
*
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
// (at your option) any later version.
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
//
|
||||||
* (at your option) any later version.
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
*
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* This program is distributed in the hope that it will be useful,
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// GNU Affero General Public License for more details.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
//
|
||||||
* GNU Affero General Public License for more details.
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
*
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
/**
|
||||||
|
* @copyright 2008, 2009, StatusNet, Inc.
|
||||||
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table Definition for subscription
|
* Table Definition for subscription
|
||||||
|
@ -30,8 +32,8 @@ class Subscription extends Managed_DataObject
|
||||||
public $__table = 'subscription'; // table name
|
public $__table = 'subscription'; // table name
|
||||||
public $subscriber; // int(4) primary_key not_null
|
public $subscriber; // int(4) primary_key not_null
|
||||||
public $subscribed; // int(4) primary_key not_null
|
public $subscribed; // int(4) primary_key not_null
|
||||||
public $jabber; // tinyint(1) default_1
|
public $jabber; // bool default_true
|
||||||
public $sms; // tinyint(1) default_1
|
public $sms; // bool default_true
|
||||||
public $token; // varchar(191) not 255 because utf8mb4 takes more space
|
public $token; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $secret; // varchar(191) not 255 because utf8mb4 takes more space
|
public $secret; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
|
@ -44,8 +46,8 @@ class Subscription extends Managed_DataObject
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'subscriber' => array('type' => 'int', 'not null' => true, 'description' => 'profile listening'),
|
'subscriber' => array('type' => 'int', 'not null' => true, 'description' => 'profile listening'),
|
||||||
'subscribed' => array('type' => 'int', 'not null' => true, 'description' => 'profile being listened to'),
|
'subscribed' => array('type' => 'int', 'not null' => true, 'description' => 'profile being listened to'),
|
||||||
'jabber' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'deliver jabber messages'),
|
'jabber' => array('type' => 'bool', 'default' => true, 'description' => 'deliver jabber messages'),
|
||||||
'sms' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'deliver sms messages'),
|
'sms' => array('type' => 'bool', 'default' => true, 'description' => 'deliver sms messages'),
|
||||||
'token' => array('type' => 'varchar', 'length' => 191, 'description' => 'authorization token'),
|
'token' => array('type' => 'varchar', 'length' => 191, 'description' => 'authorization token'),
|
||||||
'secret' => array('type' => 'varchar', 'length' => 191, 'description' => 'token secret'),
|
'secret' => array('type' => 'varchar', 'length' => 191, 'description' => 'token secret'),
|
||||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier'),
|
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier'),
|
||||||
|
@ -74,7 +76,7 @@ class Subscription extends Managed_DataObject
|
||||||
* @return mixed Subscription or Subscription_queue: new subscription info
|
* @return mixed Subscription or Subscription_queue: new subscription info
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static function start(Profile $subscriber, Profile $other, $force=false)
|
public static function start(Profile $subscriber, Profile $other, $force = false)
|
||||||
{
|
{
|
||||||
if (!$subscriber->hasRight(Right::SUBSCRIBE)) {
|
if (!$subscriber->hasRight(Right::SUBSCRIBE)) {
|
||||||
// TRANS: Exception thrown when trying to subscribe while being banned from subscribing.
|
// TRANS: Exception thrown when trying to subscribe while being banned from subscribing.
|
||||||
|
@ -117,7 +119,6 @@ class Subscription extends Managed_DataObject
|
||||||
$otherUser->autosubscribe &&
|
$otherUser->autosubscribe &&
|
||||||
!self::exists($other, $subscriber) &&
|
!self::exists($other, $subscriber) &&
|
||||||
!$subscriber->hasBlocked($other)) {
|
!$subscriber->hasBlocked($other)) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
self::start($other, $subscriber);
|
self::start($other, $subscriber);
|
||||||
} catch (AlreadyFulfilledException $e) {
|
} catch (AlreadyFulfilledException $e) {
|
||||||
|
@ -137,7 +138,7 @@ class Subscription extends Managed_DataObject
|
||||||
return $sub;
|
return $sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ensureStart(Profile $subscriber, Profile $other, $force=false)
|
public static function ensureStart(Profile $subscriber, Profile $other, $force = false)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$sub = self::start($subscriber, $other, $force);
|
$sub = self::start($subscriber, $other, $force);
|
||||||
|
@ -157,12 +158,14 @@ class Subscription extends Managed_DataObject
|
||||||
|
|
||||||
$sub->subscriber = $subscriber->getID();
|
$sub->subscriber = $subscriber->getID();
|
||||||
$sub->subscribed = $other->getID();
|
$sub->subscribed = $other->getID();
|
||||||
$sub->jabber = 1;
|
$sub->jabber = true;
|
||||||
$sub->sms = 1;
|
$sub->sms = true;
|
||||||
$sub->created = common_sql_now();
|
$sub->created = common_sql_now();
|
||||||
$sub->uri = self::newUri($subscriber,
|
$sub->uri = self::newUri(
|
||||||
$other,
|
$subscriber,
|
||||||
$sub->created);
|
$other,
|
||||||
|
$sub->created
|
||||||
|
);
|
||||||
|
|
||||||
$result = $sub->insert();
|
$result = $sub->insert();
|
||||||
|
|
||||||
|
@ -175,7 +178,7 @@ class Subscription extends Managed_DataObject
|
||||||
return $sub;
|
return $sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
function notify()
|
public function notify()
|
||||||
{
|
{
|
||||||
// XXX: add other notifications (Jabber, SMS) here
|
// XXX: add other notifications (Jabber, SMS) here
|
||||||
// XXX: queue this and handle it offline
|
// XXX: queue this and handle it offline
|
||||||
|
@ -184,12 +187,11 @@ class Subscription extends Managed_DataObject
|
||||||
$this->notifyEmail();
|
$this->notifyEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
function notifyEmail()
|
public function notifyEmail()
|
||||||
{
|
{
|
||||||
$subscribedUser = User::getKV('id', $this->subscribed);
|
$subscribedUser = User::getKV('id', $this->subscribed);
|
||||||
|
|
||||||
if ($subscribedUser instanceof User) {
|
if ($subscribedUser instanceof User) {
|
||||||
|
|
||||||
$subscriber = Profile::getKV('id', $this->subscriber);
|
$subscriber = Profile::getKV('id', $this->subscriber);
|
||||||
|
|
||||||
mail_subscribe_notify_profile($subscribedUser, $subscriber);
|
mail_subscribe_notify_profile($subscribedUser, $subscriber);
|
||||||
|
@ -200,7 +202,7 @@ class Subscription extends Managed_DataObject
|
||||||
* Cancel a subscription
|
* Cancel a subscription
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static function cancel(Profile $subscriber, Profile $other)
|
public static function cancel(Profile $subscriber, Profile $other)
|
||||||
{
|
{
|
||||||
if (!self::exists($subscriber, $other)) {
|
if (!self::exists($subscriber, $other)) {
|
||||||
// TRANS: Exception thrown when trying to unsibscribe without a subscription.
|
// TRANS: Exception thrown when trying to unsibscribe without a subscription.
|
||||||
|
@ -215,7 +217,6 @@ class Subscription extends Managed_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Event::handle('StartUnsubscribe', array($subscriber, $other))) {
|
if (Event::handle('StartUnsubscribe', array($subscriber, $other))) {
|
||||||
|
|
||||||
$sub = Subscription::pkeyGet(array('subscriber' => $subscriber->id,
|
$sub = Subscription::pkeyGet(array('subscriber' => $subscriber->id,
|
||||||
'subscribed' => $other->id));
|
'subscribed' => $other->id));
|
||||||
|
|
||||||
|
@ -245,7 +246,7 @@ class Subscription extends Managed_DataObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function exists(Profile $subscriber, Profile $other)
|
public static function exists(Profile $subscriber, Profile $other)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$sub = self::getSubscription($subscriber, $other);
|
$sub = self::getSubscription($subscriber, $other);
|
||||||
|
@ -256,7 +257,7 @@ class Subscription extends Managed_DataObject
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getSubscription(Profile $subscriber, Profile $other)
|
public static function getSubscription(Profile $subscriber, Profile $other)
|
||||||
{
|
{
|
||||||
// This is essentially a pkeyGet but we have an object to return in NoResultException
|
// This is essentially a pkeyGet but we have an object to return in NoResultException
|
||||||
$sub = new Subscription();
|
$sub = new Subscription();
|
||||||
|
@ -278,7 +279,7 @@ class Subscription extends Managed_DataObject
|
||||||
return Profile::getByID($this->subscribed);
|
return Profile::getByID($this->subscribed);
|
||||||
}
|
}
|
||||||
|
|
||||||
function asActivity()
|
public function asActivity()
|
||||||
{
|
{
|
||||||
$subscriber = $this->getSubscriber();
|
$subscriber = $this->getSubscriber();
|
||||||
$subscribed = $this->getSubscribed();
|
$subscribed = $this->getSubscribed();
|
||||||
|
@ -293,19 +294,25 @@ class Subscription extends Managed_DataObject
|
||||||
|
|
||||||
$act->time = strtotime($this->created);
|
$act->time = strtotime($this->created);
|
||||||
// TRANS: Activity title when subscribing to another person.
|
// TRANS: Activity title when subscribing to another person.
|
||||||
$act->title = _m('TITLE','Follow');
|
$act->title = _m('TITLE', 'Follow');
|
||||||
// TRANS: Notification given when one person starts following another.
|
// TRANS: Notification given when one person starts following another.
|
||||||
// TRANS: %1$s is the subscriber, %2$s is the subscribed.
|
// TRANS: %1$s is the subscriber, %2$s is the subscribed.
|
||||||
$act->content = sprintf(_('%1$s is now following %2$s.'),
|
$act->content = sprintf(
|
||||||
$subscriber->getBestName(),
|
_('%1$s is now following %2$s.'),
|
||||||
$subscribed->getBestName());
|
$subscriber->getBestName(),
|
||||||
|
$subscribed->getBestName()
|
||||||
|
);
|
||||||
|
|
||||||
$act->actor = $subscriber->asActivityObject();
|
$act->actor = $subscriber->asActivityObject();
|
||||||
$act->objects[] = $subscribed->asActivityObject();
|
$act->objects[] = $subscribed->asActivityObject();
|
||||||
|
|
||||||
$url = common_local_url('AtomPubShowSubscription',
|
$url = common_local_url(
|
||||||
array('subscriber' => $subscriber->id,
|
'AtomPubShowSubscription',
|
||||||
'subscribed' => $subscribed->id));
|
[
|
||||||
|
'subscriber' => $subscriber->id,
|
||||||
|
'subscribed' => $subscribed->id,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$act->selfLink = $url;
|
$act->selfLink = $url;
|
||||||
$act->editLink = $url;
|
$act->editLink = $url;
|
||||||
|
@ -356,11 +363,13 @@ class Subscription extends Managed_DataObject
|
||||||
|
|
||||||
// The following are helper functions to the subscription lists,
|
// The following are helper functions to the subscription lists,
|
||||||
// notably the public ones get used in places such as Profile
|
// notably the public ones get used in places such as Profile
|
||||||
public static function getSubscribedIDs($profile_id, $offset, $limit) {
|
public static function getSubscribedIDs($profile_id, $offset, $limit)
|
||||||
|
{
|
||||||
return self::getSubscriptionIDs('subscribed', $profile_id, $offset, $limit);
|
return self::getSubscriptionIDs('subscribed', $profile_id, $offset, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSubscriberIDs($profile_id, $offset, $limit) {
|
public static function getSubscriberIDs($profile_id, $offset, $limit)
|
||||||
|
{
|
||||||
return self::getSubscriptionIDs('subscriber', $profile_id, $offset, $limit);
|
return self::getSubscriptionIDs('subscriber', $profile_id, $offset, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +435,7 @@ class Subscription extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return boolean success flag.
|
* @return boolean success flag.
|
||||||
*/
|
*/
|
||||||
function update($dataObject=false)
|
public function update($dataObject = false)
|
||||||
{
|
{
|
||||||
self::blow('subscription:by-subscriber:'.$this->subscriber);
|
self::blow('subscription:by-subscriber:'.$this->subscriber);
|
||||||
self::blow('subscription:by-subscribed:'.$this->subscribed);
|
self::blow('subscription:by-subscribed:'.$this->subscribed);
|
||||||
|
|
|
@ -34,24 +34,24 @@ class User extends Managed_DataObject
|
||||||
public $password; // varchar(191) not 255 because utf8mb4 takes more space
|
public $password; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $email; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
public $email; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||||
public $incomingemail; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
public $incomingemail; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||||
public $emailnotifysub; // tinyint(1) default_1
|
public $emailnotifysub; // bool default_true
|
||||||
public $emailnotifyfav; // tinyint(1) default_1
|
public $emailnotifyfav; // tinyint(1) default_null
|
||||||
public $emailnotifynudge; // tinyint(1) default_1
|
public $emailnotifynudge; // bool default_true
|
||||||
public $emailnotifymsg; // tinyint(1) default_1
|
public $emailnotifymsg; // bool default_true
|
||||||
public $emailnotifyattn; // tinyint(1) default_1
|
public $emailnotifyattn; // bool default_true
|
||||||
public $language; // varchar(50)
|
public $language; // varchar(50)
|
||||||
public $timezone; // varchar(50)
|
public $timezone; // varchar(50)
|
||||||
public $emailpost; // tinyint(1) default_1
|
public $emailpost; // bool default_true
|
||||||
public $sms; // varchar(64) unique_key
|
public $sms; // varchar(64) unique_key
|
||||||
public $carrier; // int(4)
|
public $carrier; // int(4)
|
||||||
public $smsnotify; // tinyint(1)
|
public $smsnotify; // bool default_false
|
||||||
public $smsreplies; // tinyint(1)
|
public $smsreplies; // bool default_false
|
||||||
public $smsemail; // varchar(191) not 255 because utf8mb4 takes more space
|
public $smsemail; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||||
public $autosubscribe; // tinyint(1)
|
public $autosubscribe; // bool default_false
|
||||||
public $subscribe_policy; // tinyint(1)
|
public $subscribe_policy; // tinyint(1)
|
||||||
public $urlshorteningservice; // varchar(50) default_ur1.ca
|
public $urlshorteningservice; // varchar(50) default_ur1.ca
|
||||||
public $private_stream; // tinyint(1) default_0
|
public $private_stream; // bool default_false
|
||||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
|
@ -68,24 +68,24 @@ class User extends Managed_DataObject
|
||||||
'password' => array('type' => 'varchar', 'length' => 191, 'description' => 'salted password, can be null for OpenID users'),
|
'password' => array('type' => 'varchar', 'length' => 191, 'description' => 'salted password, can be null for OpenID users'),
|
||||||
'email' => array('type' => 'varchar', 'length' => 191, 'description' => 'email address for password recovery etc.'),
|
'email' => array('type' => 'varchar', 'length' => 191, 'description' => 'email address for password recovery etc.'),
|
||||||
'incomingemail' => array('type' => 'varchar', 'length' => 191, 'description' => 'email address for post-by-email'),
|
'incomingemail' => array('type' => 'varchar', 'length' => 191, 'description' => 'email address for post-by-email'),
|
||||||
'emailnotifysub' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of subscriptions'),
|
'emailnotifysub' => array('type' => 'bool', 'default' => true, 'description' => 'Notify by email of subscriptions'),
|
||||||
'emailnotifyfav' => array('type' => 'int', 'size' => 'tiny', 'default' => null, 'description' => 'Notify by email of favorites'),
|
'emailnotifyfav' => array('type' => 'int', 'size' => 'tiny', 'default' => null, 'description' => 'Notify by email of favorites'),
|
||||||
'emailnotifynudge' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of nudges'),
|
'emailnotifynudge' => array('type' => 'bool', 'default' => true, 'description' => 'Notify by email of nudges'),
|
||||||
'emailnotifymsg' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of direct messages'),
|
'emailnotifymsg' => array('type' => 'bool', 'default' => true, 'description' => 'Notify by email of direct messages'),
|
||||||
'emailnotifyattn' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of @-replies'),
|
'emailnotifyattn' => array('type' => 'bool', 'default' => true, 'description' => 'Notify by email of @-replies'),
|
||||||
'language' => array('type' => 'varchar', 'length' => 50, 'description' => 'preferred language'),
|
'language' => array('type' => 'varchar', 'length' => 50, 'description' => 'preferred language'),
|
||||||
'timezone' => array('type' => 'varchar', 'length' => 50, 'description' => 'timezone'),
|
'timezone' => array('type' => 'varchar', 'length' => 50, 'description' => 'timezone'),
|
||||||
'emailpost' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Post by email'),
|
'emailpost' => array('type' => 'bool', 'default' => true, 'description' => 'Post by email'),
|
||||||
'sms' => array('type' => 'varchar', 'length' => 64, 'description' => 'sms phone number'),
|
'sms' => array('type' => 'varchar', 'length' => 64, 'description' => 'sms phone number'),
|
||||||
'carrier' => array('type' => 'int', 'description' => 'foreign key to sms_carrier'),
|
'carrier' => array('type' => 'int', 'description' => 'foreign key to sms_carrier'),
|
||||||
'smsnotify' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to send notices to SMS'),
|
'smsnotify' => array('type' => 'bool', 'default' => false, 'description' => 'whether to send notices to SMS'),
|
||||||
'smsreplies' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to send notices to SMS on replies'),
|
'smsreplies' => array('type' => 'bool', 'default' => false, 'description' => 'whether to send notices to SMS on replies'),
|
||||||
'smsemail' => array('type' => 'varchar', 'length' => 191, 'description' => 'built from sms and carrier'),
|
'smsemail' => array('type' => 'varchar', 'length' => 191, 'description' => 'built from sms and carrier'),
|
||||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier, usually a tag URI'),
|
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier, usually a tag URI'),
|
||||||
'autosubscribe' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'automatically subscribe to users who subscribe to us'),
|
'autosubscribe' => array('type' => 'bool', 'default' => false, 'description' => 'automatically subscribe to users who subscribe to us'),
|
||||||
'subscribe_policy' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'),
|
'subscribe_policy' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'),
|
||||||
'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'),
|
'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'),
|
||||||
'private_stream' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to limit all notices to followers only'),
|
'private_stream' => array('type' => 'bool', 'default' => false, 'description' => 'whether to limit all notices to followers only'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
),
|
),
|
||||||
|
@ -265,11 +265,11 @@ class User extends Managed_DataObject
|
||||||
// Set default-on options here, otherwise they'll be disabled
|
// Set default-on options here, otherwise they'll be disabled
|
||||||
// initially for sites using caching, since the initial encache
|
// initially for sites using caching, since the initial encache
|
||||||
// doesn't know about the defaults in the database.
|
// doesn't know about the defaults in the database.
|
||||||
$user->emailnotifysub = 1;
|
$user->emailnotifysub = true;
|
||||||
$user->emailnotifynudge = 1;
|
$user->emailnotifynudge = true;
|
||||||
$user->emailnotifymsg = 1;
|
$user->emailnotifymsg = true;
|
||||||
$user->emailnotifyattn = 1;
|
$user->emailnotifyattn = true;
|
||||||
$user->emailpost = 1;
|
$user->emailpost = true;
|
||||||
|
|
||||||
$user->created = common_sql_now();
|
$user->created = common_sql_now();
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ class User_group extends Managed_DataObject
|
||||||
{
|
{
|
||||||
$block = new Group_member();
|
$block = new Group_member();
|
||||||
$block->group_id = $this->id;
|
$block->group_id = $this->id;
|
||||||
$block->is_admin = 1;
|
$block->is_admin = true;
|
||||||
|
|
||||||
return $block->count();
|
return $block->count();
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ class User_group extends Managed_DataObject
|
||||||
{
|
{
|
||||||
$admins = new Profile();
|
$admins = new Profile();
|
||||||
$admins->joinAdd(array('id', 'group_member:profile_id'));
|
$admins->joinAdd(array('id', 'group_member:profile_id'));
|
||||||
$admins->whereAdd(sprintf('group_member.group_id = %u AND group_member.is_admin = 1', $this->id));
|
$admins->whereAdd('group_member.group_id = ' . $this->id . ' AND group_member.is_admin = true');
|
||||||
$admins->orderBy('group_member.modified ASC');
|
$admins->orderBy('group_member.modified ASC');
|
||||||
$admins->limit($offset, $limit);
|
$admins->limit($offset, $limit);
|
||||||
$admins->find();
|
$admins->find();
|
||||||
|
@ -692,7 +692,7 @@ class User_group extends Managed_DataObject
|
||||||
|
|
||||||
$member->group_id = $group->id;
|
$member->group_id = $group->id;
|
||||||
$member->profile_id = $userid;
|
$member->profile_id = $userid;
|
||||||
$member->is_admin = 1;
|
$member->is_admin = true;
|
||||||
$member->created = $group->created;
|
$member->created = $group->created;
|
||||||
|
|
||||||
$result = $member->insert();
|
$result = $member->insert();
|
||||||
|
|
|
@ -1,32 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Data class for user IM preferences
|
* Data class for user IM preferences
|
||||||
*
|
*
|
||||||
* 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 Data
|
* @category Data
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Craig Andrews <candrews@integralblue.com>
|
* @author Craig Andrews <candrews@integralblue.com>
|
||||||
* @copyright 2009 StatusNet Inc.
|
* @copyright 2009 StatusNet Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||||
|
|
||||||
class User_im_prefs extends Managed_DataObject
|
class User_im_prefs extends Managed_DataObject
|
||||||
|
@ -38,9 +37,9 @@ class User_im_prefs extends Managed_DataObject
|
||||||
public $user_id; // int(4) primary_key not_null
|
public $user_id; // int(4) primary_key not_null
|
||||||
public $screenname; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
public $screenname; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||||
public $transport; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
public $transport; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||||
public $notify; // tinyint(1)
|
public $notify; // bool not_null default_false
|
||||||
public $replies; // tinyint(1)
|
public $replies; // bool not_null default_false
|
||||||
public $updatefrompresence; // tinyint(1)
|
public $updatefrompresence; // bool not_null default_false
|
||||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
|
@ -54,9 +53,9 @@ class User_im_prefs extends Managed_DataObject
|
||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user'),
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user'),
|
||||||
'screenname' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'screenname on this service'),
|
'screenname' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'screenname on this service'),
|
||||||
'transport' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'transport (ex xmpp, aim)'),
|
'transport' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'transport (ex xmpp, aim)'),
|
||||||
'notify' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Notify when a new notice is sent'),
|
'notify' => array('type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Notify when a new notice is sent'),
|
||||||
'replies' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to'),
|
'replies' => array('type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Send replies from people not subscribed to'),
|
||||||
'updatefrompresence' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to.'),
|
'updatefrompresence' => array('type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Update from presence.'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
),
|
),
|
||||||
|
@ -69,5 +68,4 @@ class User_im_prefs extends Managed_DataObject
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Data class for user location preferences
|
* Data class for user location preferences
|
||||||
*
|
*
|
||||||
* 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 Data
|
* @category Data
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2009 StatusNet Inc.
|
* @copyright 2009 StatusNet Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||||
|
@ -36,7 +33,7 @@ class User_location_prefs extends Managed_DataObject
|
||||||
|
|
||||||
public $__table = 'user_location_prefs'; // table name
|
public $__table = 'user_location_prefs'; // table name
|
||||||
public $user_id; // int(4) primary_key not_null
|
public $user_id; // int(4) primary_key not_null
|
||||||
public $share_location; // tinyint(1) default_1
|
public $share_location; // bool default_true
|
||||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
|
@ -48,7 +45,7 @@ class User_location_prefs extends Managed_DataObject
|
||||||
return array(
|
return array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'),
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'),
|
||||||
'share_location' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Whether to share location data'),
|
'share_location' => array('type' => 'bool', 'default' => true, 'description' => 'Whether to share location data'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||||
),
|
),
|
||||||
|
|
|
@ -4,10 +4,6 @@
|
||||||
*
|
*
|
||||||
* Some notes...
|
* Some notes...
|
||||||
*
|
*
|
||||||
* Drupal docs don't list a bool type, but it might be nice to use rather than 'tinyint'
|
|
||||||
* Note however that we use bitfields and things as well in tinyints, and PG's
|
|
||||||
* "bool" type isn't 100% compatible with 0/1 checks. Just keeping tinyints. :)
|
|
||||||
*
|
|
||||||
* decimal <-> numeric
|
* decimal <-> numeric
|
||||||
*
|
*
|
||||||
* MySQL 'timestamp' columns were formerly used for 'modified' files for their
|
* MySQL 'timestamp' columns were formerly used for 'modified' files for their
|
||||||
|
|
|
@ -1787,12 +1787,27 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||||
// note: we dont declare this to keep the print_r size down.
|
// note: we dont declare this to keep the print_r size down.
|
||||||
$_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid] = array_flip(array_keys($array));
|
$_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid] = array_flip(array_keys($array));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dbtype = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['phptype'];
|
||||||
|
if ($dbtype === 'pgsql') {
|
||||||
|
if (($_DB_DATAOBJECT['CONFIG']['db_driver'] ?? 'DB') === 'DB') {
|
||||||
|
$tableInfo = $result->tableInfo();
|
||||||
|
} elseif ($result->db->supports('result_introspection')) { // MDB2
|
||||||
|
$result->db->loadModule('Reverse', null, true);
|
||||||
|
$tableInfo = $result->db->reverse->tableInfo($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$replace = array('.', ' ');
|
$replace = array('.', ' ');
|
||||||
foreach ($array as $k => $v) {
|
foreach (array_keys($array) as $i => $k) {
|
||||||
// use strpos as str_replace is slow.
|
// use strpos as str_replace is slow.
|
||||||
$kk = (strpos($k, '.') === false && strpos($k, ' ') === false) ?
|
$kk = (strpos($k, '.') === false && strpos($k, ' ') === false) ?
|
||||||
$k : str_replace($replace, '_', $k);
|
$k : str_replace($replace, '_', $k);
|
||||||
|
|
||||||
|
if ($dbtype === 'pgsql' && $tableInfo[$i]['type'] == 'bool') {
|
||||||
|
$array[$k] = str_replace(['t', 'f'], ['1', '0'], $array[$k]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
|
if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
|
||||||
$this->debug("$kk = " . $array[$k], "fetchrow LINE", 3);
|
$this->debug("$kk = " . $array[$k], "fetchrow LINE", 3);
|
||||||
}
|
}
|
||||||
|
@ -2949,12 +2964,27 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||||
$this->raiseError("fetchrow: No results available", DB_DATAOBJECT_ERROR_NODATA);
|
$this->raiseError("fetchrow: No results available", DB_DATAOBJECT_ERROR_NODATA);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dbtype = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['phptype'];
|
||||||
|
if ($dbtype === 'pgsql') {
|
||||||
|
if (($_DB_DATAOBJECT['CONFIG']['db_driver'] ?? 'DB') === 'DB') {
|
||||||
|
$tableInfo = $result->tableInfo();
|
||||||
|
} elseif ($result->db->supports('result_introspection')) { // MDB2
|
||||||
|
$result->db->loadModule('Reverse', null, true);
|
||||||
|
$tableInfo = $result->db->reverse->tableInfo($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$replace = array('.', ' ');
|
$replace = array('.', ' ');
|
||||||
foreach ($array as $k => $v) {
|
foreach (array_keys($array) as $i => $k) {
|
||||||
// use strpos as str_replace is slow.
|
// use strpos as str_replace is slow.
|
||||||
$kk = (strpos($k, '.') === false && strpos($k, ' ') === false) ?
|
$kk = (strpos($k, '.') === false && strpos($k, ' ') === false) ?
|
||||||
$k : str_replace($replace, '_', $k);
|
$k : str_replace($replace, '_', $k);
|
||||||
|
|
||||||
|
if ($dbtype === 'pgsql' && $tableInfo[$i]['type'] == 'bool') {
|
||||||
|
$array[$k] = str_replace(['t', 'f'], ['1', '0'], $array[$k]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
|
if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
|
||||||
$this->debug("$kk = " . $array[$k], "fetchrow LINE", 3);
|
$this->debug("$kk = " . $array[$k], "fetchrow LINE", 3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Base class for all actions (~views)
|
* Base class for all actions (~views)
|
||||||
*
|
*
|
||||||
* 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 Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Sarven Capadisli <csarven@status.net>
|
* @author Sarven Capadisli <csarven@status.net>
|
||||||
* @copyright 2008 StatusNet, Inc.
|
* @copyright 2008 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all actions
|
* Base class for all actions
|
||||||
|
@ -41,14 +36,11 @@ if (!defined('GNUSOCIAL')) {
|
||||||
* Actions are responsible for extracting and validating parameters; using
|
* Actions are responsible for extracting and validating parameters; using
|
||||||
* model classes to read and write to the database; and doing ouput.
|
* model classes to read and write to the database; and doing ouput.
|
||||||
*
|
*
|
||||||
* @category Output
|
* @category Output
|
||||||
* @package StatusNet
|
* @copyright 2008 StatusNet, Inc.
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Sarven Capadisli <csarven@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/
|
|
||||||
*
|
*
|
||||||
* @see HTMLOutputter
|
* @see HTMLOutputter
|
||||||
*/
|
*/
|
||||||
class Action extends HTMLOutputter // lawsuit
|
class Action extends HTMLOutputter // lawsuit
|
||||||
{
|
{
|
||||||
|
@ -1566,19 +1558,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||||
// needs to be defined by the class
|
// needs to be defined by the class
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a cheap hack to avoid a bug in DB_DataObject
|
|
||||||
* where '' is non-type-aware compared to 0, which means it
|
|
||||||
* will always be true for values like false and 0 too...
|
|
||||||
*
|
|
||||||
* Upstream bug is::
|
|
||||||
* https://pear.php.net/bugs/bug.php?id=20291
|
|
||||||
*/
|
|
||||||
public function booleanintstring($key, $def = false)
|
|
||||||
{
|
|
||||||
return $this->boolean($key, $def) ? '1' : '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integer value of an argument
|
* Integer value of an argument
|
||||||
*
|
*
|
||||||
|
|
|
@ -396,9 +396,9 @@ class MysqlSchema extends Schema
|
||||||
function mapType($column)
|
function mapType($column)
|
||||||
{
|
{
|
||||||
$map = [
|
$map = [
|
||||||
'serial' => 'int',
|
|
||||||
'integer' => 'int',
|
'integer' => 'int',
|
||||||
'numeric' => 'decimal'
|
'bool' => 'tinyint',
|
||||||
|
'numeric' => 'decimal',
|
||||||
];
|
];
|
||||||
|
|
||||||
$type = $column['type'];
|
$type = $column['type'];
|
||||||
|
|
|
@ -348,10 +348,11 @@ class PgsqlSchema extends Schema
|
||||||
public function mapType($column)
|
public function mapType($column)
|
||||||
{
|
{
|
||||||
$map = [
|
$map = [
|
||||||
'serial' => 'bigserial', // FIXME: creates the wrong name for the sequence for some internal sequence-lookup function, so better fix this to do the real 'create sequence' dance.
|
'serial' => 'bigserial', // FIXME: creates the wrong name for the sequence for some internal sequence-lookup function, so better fix this to do the real 'create sequence' dance.
|
||||||
'numeric' => 'decimal',
|
'bool' => 'boolean',
|
||||||
|
'numeric' => 'decimal',
|
||||||
'datetime' => 'timestamp',
|
'datetime' => 'timestamp',
|
||||||
'blob' => 'bytea'
|
'blob' => 'bytea',
|
||||||
];
|
];
|
||||||
|
|
||||||
$type = $column['type'];
|
$type = $column['type'];
|
||||||
|
|
|
@ -434,11 +434,11 @@ function mail_broadcast_notice_sms($notice)
|
||||||
// Users (other than the sender) who `want SMS notices':
|
// Users (other than the sender) who `want SMS notices':
|
||||||
'WHERE %1$s.id <> %2$d ' .
|
'WHERE %1$s.id <> %2$d ' .
|
||||||
'AND %1$s.smsemail IS NOT NULL ' .
|
'AND %1$s.smsemail IS NOT NULL ' .
|
||||||
'AND %1$s.smsnotify = 1 ' .
|
'AND %1$s.smsnotify = TRUE ' .
|
||||||
// ... where either the user _is_ subscribed to the sender
|
// ... where either the user _is_ subscribed to the sender
|
||||||
// (any of the "subscription" fields IS NOT NULL)
|
// (any of the "subscription" fields IS NOT NULL)
|
||||||
// and wants to get SMS for all of this scribe's notices...
|
// and wants to get SMS for all of this scribe's notices...
|
||||||
'AND (subscription.sms = 1 ' .
|
'AND (subscription.sms = TRUE ' .
|
||||||
// ... or where the user was mentioned in
|
// ... or where the user was mentioned in
|
||||||
// or replied-to with the notice:
|
// or replied-to with the notice:
|
||||||
$repliesQry .
|
$repliesQry .
|
||||||
|
|
|
@ -507,9 +507,9 @@ class FavoriteModule extends ActivityVerbHandlerModule
|
||||||
|
|
||||||
public function onStartEmailSaveForm(Action $action, Profile $scoped)
|
public function onStartEmailSaveForm(Action $action, Profile $scoped)
|
||||||
{
|
{
|
||||||
$emailfave = $action->booleanintstring('email-notify_fave');
|
$emailfave = $action->boolean('email-notify_fave');
|
||||||
try {
|
try {
|
||||||
if ($emailfave == $scoped->getPref('email', 'notify_fave')) {
|
if ($emailfave == (bool) $scoped->getPref('email', 'notify_fave')) {
|
||||||
// No need to update setting
|
// No need to update setting
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 2011, StatusNet, Inc.
|
|
||||||
*
|
|
||||||
* Score of a notice by activity spam service
|
* 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
|
* @category Spam
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2011 StatusNet, Inc.
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Score of a notice per the activity spam service
|
* Score of a notice per the activity spam service
|
||||||
*
|
*
|
||||||
* @category Spam
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @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 Spam_score extends Managed_DataObject
|
class Spam_score extends Managed_DataObject
|
||||||
{
|
{
|
||||||
|
@ -54,7 +45,6 @@ class Spam_score extends Managed_DataObject
|
||||||
|
|
||||||
public static function save($notice, $result)
|
public static function save($notice, $result)
|
||||||
{
|
{
|
||||||
|
|
||||||
$orig = null;
|
$orig = null;
|
||||||
$score = Spam_score::getKV('notice_id', $notice->id);
|
$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)'),
|
'description' => 'score for the notice (0.0, 1.0)'),
|
||||||
'scaled' => array('type' => 'int',
|
'scaled' => array('type' => 'int',
|
||||||
'description' => 'scaled score for the notice (0, 10000)'),
|
'description' => 'scaled score for the notice (0, 10000)'),
|
||||||
'is_spam' => array('type' => 'tinyint',
|
'is_spam' => array('type' => 'bool',
|
||||||
'description' => 'flag for spamosity'),
|
'description' => 'flag for spamosity'),
|
||||||
'created' => array('type' => 'datetime',
|
'created' => array('type' => 'datetime',
|
||||||
'not null' => true,
|
'not null' => true,
|
||||||
|
@ -146,7 +136,7 @@ class Spam_score extends Managed_DataObject
|
||||||
if ($score->find()) {
|
if ($score->find()) {
|
||||||
while ($score->fetch()) {
|
while ($score->fetch()) {
|
||||||
$orig = clone($score);
|
$orig = clone($score);
|
||||||
$score->is_spam = ($score->score >= 0.90) ? 1 : 0;
|
$score->is_spam = ($score->score >= 0.90) ? true : false;
|
||||||
$score->update($orig);
|
$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 = new Spam_score();
|
||||||
|
|
||||||
$score->notice_id = $notice->id;
|
$score->notice_id = $notice->id;
|
|
@ -1,52 +1,45 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
//
|
||||||
* Copyright (C) 2012, StatusNet, Inc.
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
*
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
* Spam notice stream
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* PHP version 5
|
//
|
||||||
*
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// GNU Affero General Public License for more details.
|
||||||
* (at your option) any later version.
|
//
|
||||||
*
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
* This program is distributed in the hope that it will be useful,
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* 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); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spam notice stream
|
* Spam notice stream
|
||||||
*
|
*
|
||||||
* @category Spam
|
* @category Spam
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2012 StatusNet, Inc.
|
* @copyright 2012 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
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
|
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'),
|
parent::__construct(
|
||||||
$scoped);
|
new CachingNoticeStream(new RawSpamNoticeStream(), 'spam_score:notice_ids'),
|
||||||
|
$scoped
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,20 +47,16 @@ class SpamNoticeStream extends ScopingNoticeStream
|
||||||
* Raw stream of spammy notices
|
* Raw stream of spammy notices
|
||||||
*
|
*
|
||||||
* @category Stream
|
* @category Stream
|
||||||
* @package StatusNet
|
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @copyright 2011 StatusNet, Inc.
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class RawSpamNoticeStream extends NoticeStream
|
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 = new Spam_score();
|
||||||
|
|
||||||
$ss->is_spam = 1;
|
$ss->is_spam = true;
|
||||||
|
|
||||||
$ss->selectAdd();
|
$ss->selectAdd();
|
||||||
$ss->selectAdd('notice_id');
|
$ss->selectAdd('notice_id');
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
//
|
||||||
* Copyright (C) 2013 StatusNet, Inc.
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
*
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
// (at your option) any later version.
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
//
|
||||||
* (at your option) any later version.
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
*
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* This program is distributed in the hope that it will be useful,
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// GNU Affero General Public License for more details.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
//
|
||||||
* GNU Affero General Public License for more details.
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
*
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
/**
|
||||||
|
* @copyright 2013 StatusNet, Inc.
|
||||||
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
|
||||||
|
@ -33,13 +35,13 @@ END_OF_SILENCESPAMMER_HELP;
|
||||||
|
|
||||||
require_once INSTALLDIR.'/scripts/commandline.inc';
|
require_once INSTALLDIR.'/scripts/commandline.inc';
|
||||||
|
|
||||||
function testAllUsers($filter, $minimum, $percent) {
|
function testAllUsers($filter, $minimum, $percent)
|
||||||
|
{
|
||||||
$found = false;
|
$found = false;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
$limit = 1000;
|
$limit = 1000;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$user->orderBy('created');
|
$user->orderBy('created');
|
||||||
$user->limit($offset, $limit);
|
$user->limit($offset, $limit);
|
||||||
|
@ -56,37 +58,36 @@ function testAllUsers($filter, $minimum, $percent) {
|
||||||
}
|
}
|
||||||
$offset += $found;
|
$offset += $found;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while ($found > 0);
|
} while ($found > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function silencespammer($filter, $user, $minimum, $percent) {
|
function silencespammer($filter, $user, $minimum, $percent)
|
||||||
|
{
|
||||||
printfnq("Testing user %s\n", $user->nickname);
|
printfnq("Testing user %s\n", $user->nickname);
|
||||||
|
|
||||||
$profile = Profile::getKV('id', $user->id);
|
$profile = Profile::getKV('id', $user->id);
|
||||||
|
|
||||||
if ($profile->isSilenced()) {
|
if ($profile->isSilenced()) {
|
||||||
printfnq("Already silenced %s\n", $user->nickname);
|
printfnq("Already silenced %s\n", $user->nickname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cnt = $profile->noticeCount();
|
$cnt = $profile->noticeCount();
|
||||||
|
|
||||||
if ($cnt < $minimum) {
|
if ($cnt < $minimum) {
|
||||||
printfnq("Only %d notices posted (minimum %d); skipping\n", $cnt, $minimum);
|
printfnq("Only %d notices posted (minimum %d); skipping\n", $cnt, $minimum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ss = new Spam_score();
|
$ss = new Spam_score();
|
||||||
|
|
||||||
$ss->query(sprintf("SELECT count(*) as spam_count ".
|
$ss->query(sprintf("SELECT count(*) as spam_count ".
|
||||||
"FROM notice join spam_score on notice.id = spam_score.notice_id ".
|
"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()) {
|
while ($ss->fetch()) {
|
||||||
$spam_count = $ss->spam_count;
|
$spam_count = $ss->spam_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
$spam_percent = ($spam_count * 100.0 / $cnt);
|
$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);
|
printfnq("Silencing user %s (%d/%d = %0.2f%% spam)\n", $user->nickname, $spam_count, $cnt, $spam_percent);
|
||||||
try {
|
try {
|
||||||
$profile->silence();
|
$profile->silence();
|
||||||
} catch(Exception $e) {
|
} catch (Exception $e) {
|
||||||
printfnq("Error: %s", $e->getMessage());
|
printfnq("Error: %s", $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,35 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data class for email summary status
|
* Data class for email summary status
|
||||||
*
|
*
|
||||||
* PHP version 5
|
* @category Data
|
||||||
*
|
* @package GNUsocial
|
||||||
* @category Data
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @package StatusNet
|
* @copyright 2010, StatusNet, Inc.
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 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/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||||
|
|
||||||
|
@ -38,19 +33,17 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||||
*
|
*
|
||||||
* Email summary information for users
|
* Email summary information for users
|
||||||
*
|
*
|
||||||
* @category Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @copyright 2010, StatusNet, Inc.
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
*
|
||||||
* @see DB_DataObject
|
* @see DB_DataObject
|
||||||
*/
|
*/
|
||||||
class Email_summary_status extends Managed_DataObject
|
class Email_summary_status extends Managed_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'email_summary_status'; // table name
|
public $__table = 'email_summary_status'; // table name
|
||||||
public $user_id; // int(4) primary_key not_null
|
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 $last_summary_id; // int(4) null
|
||||||
public $created; // datetime not_null
|
public $created; // datetime not_null
|
||||||
public $modified; // datetime not_null
|
public $modified; // datetime not_null
|
||||||
|
@ -60,9 +53,9 @@ class Email_summary_status extends Managed_DataObject
|
||||||
return array(
|
return array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
'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'),
|
'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'),
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
),
|
),
|
||||||
'primary key' => array('user_id'),
|
'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
|
* @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);
|
$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.
|
* @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);
|
$ess = Email_summary_status::getKV('user_id', $user_id);
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data class for counting greetings
|
* Data class for counting greetings
|
||||||
*
|
*
|
||||||
* PHP version 5
|
* @category Data
|
||||||
*
|
* @package GNUsocial
|
||||||
* @category Data
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @package StatusNet
|
* @copyright 2009, StatusNet, Inc.
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 2009, StatusNet, Inc.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
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,
|
* extension of DB_DataObject that provides caching, internationalization,
|
||||||
* and other bits of good functionality to StatusNet-specific data classes.
|
* and other bits of good functionality to StatusNet-specific data classes.
|
||||||
*
|
*
|
||||||
* @category Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @copyright 2009, StatusNet, Inc.
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
*
|
||||||
* @see DB_DataObject
|
* @see DB_DataObject
|
||||||
*/
|
*/
|
||||||
class User_followeveryone_prefs extends Managed_DataObject
|
class User_followeveryone_prefs extends Managed_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'user_followeveryone_prefs'; // table name
|
public $__table = 'user_followeveryone_prefs'; // table name
|
||||||
public $user_id; // int(4) primary_key not_null
|
public $user_id; // int(4) primary_key not_null
|
||||||
public $followeveryone; // tinyint(1)
|
public $followeveryone; // bool default_true
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null
|
||||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
|
@ -65,7 +58,7 @@ class User_followeveryone_prefs extends Managed_DataObject
|
||||||
return array(
|
return array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
'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'),
|
'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'),
|
'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);
|
$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);
|
$ufep = self::getKV('user_id', $user_id);
|
||||||
|
|
||||||
|
|
|
@ -1,52 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 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
|
* @category Moderation
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2012 StatusNet, Inc.
|
* @copyright 2012 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
// This check helps protect against security problems;
|
|
||||||
// your code file can't be executed directly from the web.
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moderation logging
|
* Moderation logging
|
||||||
*
|
*
|
||||||
* Shows a history of moderation for this user in the sidebar
|
* 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.
|
* @copyright 2012 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ModLogPlugin extends Plugin
|
class ModLogPlugin extends Plugin
|
||||||
{
|
{
|
||||||
const PLUGIN_VERSION = '2.0.0';
|
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.
|
* @return boolean hook value; true means continue processing, false means stop.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function onCheckSchema()
|
public function onCheckSchema()
|
||||||
{
|
{
|
||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
|
|
||||||
|
@ -72,7 +57,7 @@ class ModLogPlugin extends Plugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndGrantRole($profile, $role)
|
public function onEndGrantRole($profile, $role)
|
||||||
{
|
{
|
||||||
$modlog = new ModLog();
|
$modlog = new ModLog();
|
||||||
|
|
||||||
|
@ -86,7 +71,7 @@ class ModLogPlugin extends Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
$modlog->role = $role;
|
$modlog->role = $role;
|
||||||
$modlog->is_grant = 1;
|
$modlog->is_grant = true;
|
||||||
$modlog->created = common_sql_now();
|
$modlog->created = common_sql_now();
|
||||||
|
|
||||||
$modlog->insert();
|
$modlog->insert();
|
||||||
|
@ -94,7 +79,7 @@ class ModLogPlugin extends Plugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndRevokeRole($profile, $role)
|
public function onEndRevokeRole($profile, $role)
|
||||||
{
|
{
|
||||||
$modlog = new ModLog();
|
$modlog = new ModLog();
|
||||||
|
|
||||||
|
@ -109,7 +94,7 @@ class ModLogPlugin extends Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
$modlog->role = $role;
|
$modlog->role = $role;
|
||||||
$modlog->is_grant = 0;
|
$modlog->is_grant = false;
|
||||||
$modlog->created = common_sql_now();
|
$modlog->created = common_sql_now();
|
||||||
|
|
||||||
$modlog->insert();
|
$modlog->insert();
|
||||||
|
@ -117,7 +102,7 @@ class ModLogPlugin extends Plugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndShowSections(Action $action)
|
public function onEndShowSections(Action $action)
|
||||||
{
|
{
|
||||||
if (!$action instanceof ShowstreamAction) {
|
if (!$action instanceof ShowstreamAction) {
|
||||||
// early return for actions we're not interested in
|
// early return for actions we're not interested in
|
||||||
|
@ -140,7 +125,6 @@ class ModLogPlugin extends Plugin
|
||||||
$cnt = $ml->find();
|
$cnt = $ml->find();
|
||||||
|
|
||||||
if ($cnt > 0) {
|
if ($cnt > 0) {
|
||||||
|
|
||||||
$action->elementStart('div', array('id' => 'entity_mod_log',
|
$action->elementStart('div', array('id' => 'entity_mod_log',
|
||||||
'class' => 'section'));
|
'class' => 'section'));
|
||||||
|
|
||||||
|
@ -158,9 +142,14 @@ class ModLogPlugin extends Plugin
|
||||||
if (empty($mod)) {
|
if (empty($mod)) {
|
||||||
$action->text(_('[unknown]'));
|
$action->text(_('[unknown]'));
|
||||||
} else {
|
} else {
|
||||||
$action->element('a', array('href' => $mod->getUrl(),
|
$action->element(
|
||||||
'title' => $mod->getFullname()),
|
'a',
|
||||||
$mod->getNickname());
|
[
|
||||||
|
'href' => $mod->getUrl(),
|
||||||
|
'title' => $mod->getFullname(),
|
||||||
|
],
|
||||||
|
$mod->getNickname()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$action->text(_('[unknown]'));
|
$action->text(_('[unknown]'));
|
||||||
|
@ -175,7 +164,8 @@ class ModLogPlugin extends Plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUserRightsCheck($profile, $right, &$result) {
|
public function onUserRightsCheck($profile, $right, &$result)
|
||||||
|
{
|
||||||
switch ($right) {
|
switch ($right) {
|
||||||
case self::VIEWMODLOG:
|
case self::VIEWMODLOG:
|
||||||
$result = ($profile->hasRole(Profile_role::MODERATOR) || $profile->hasRole('modhelper'));
|
$result = ($profile->hasRole(Profile_role::MODERATOR) || $profile->hasRole('modhelper'));
|
||||||
|
|
|
@ -1,49 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
* Data object to store moderation logs
|
||||||
* 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/>.
|
|
||||||
*
|
*
|
||||||
* @category Moderation
|
* @category Moderation
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2012 StatusNet, Inc.
|
* @copyright 2012 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class comment here
|
* @copyright 2012 StatusNet, Inc.
|
||||||
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
*
|
*
|
||||||
* @category Category here
|
* @see DB_DataObject
|
||||||
* @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
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ModLog extends Managed_DataObject
|
class ModLog extends Managed_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'mod_log'; // table name
|
public $__table = 'mod_log'; // table name
|
||||||
|
@ -52,7 +40,7 @@ class ModLog extends Managed_DataObject
|
||||||
public $profile_id; // profile id
|
public $profile_id; // profile id
|
||||||
public $moderator_id; // profile id
|
public $moderator_id; // profile id
|
||||||
public $role; // the role
|
public $role; // the role
|
||||||
public $grant; // 1 = grant, 0 = revoke
|
public $is_grant; // true = grant, false = revoke
|
||||||
public $created; // datetime
|
public $created; // datetime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,9 +63,8 @@ class ModLog extends Managed_DataObject
|
||||||
'length' => 32,
|
'length' => 32,
|
||||||
'not null' => true,
|
'not null' => true,
|
||||||
'description' => 'role granted or revoked'),
|
'description' => 'role granted or revoked'),
|
||||||
'is_grant' => array('type' => 'int',
|
'is_grant' => array('type' => 'bool',
|
||||||
'size' => 'tiny',
|
'default' => true,
|
||||||
'default' => 1,
|
|
||||||
'description' => 'Was this a grant or revocation of a role'),
|
'description' => 'Was this a grant or revocation of a role'),
|
||||||
'created' => array('type' => 'datetime',
|
'created' => array('type' => 'datetime',
|
||||||
'not null' => true,
|
'not null' => true,
|
||||||
|
|
|
@ -1,35 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Settings for OpenID
|
* 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
|
* @category Settings
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2008-2009 StatusNet, Inc.
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/plugins/OpenID/openid.php';
|
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
|
* Lets users add, edit and delete OpenIDs from their account
|
||||||
*
|
*
|
||||||
* @category Settings
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @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/
|
|
||||||
*/
|
*/
|
||||||
class OpenidsettingsAction extends SettingsAction
|
class OpenidsettingsAction extends SettingsAction
|
||||||
{
|
{
|
||||||
|
@ -100,17 +92,26 @@ class OpenidsettingsAction extends SettingsAction
|
||||||
$this->elementStart('ul', 'form_data');
|
$this->elementStart('ul', 'form_data');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
// TRANS: Field label.
|
// TRANS: Field label.
|
||||||
$this->input('openid_url', _m('OpenID URL'), null,
|
$this->input(
|
||||||
// TRANS: Form guide.
|
'openid_url',
|
||||||
_m('An OpenID URL which identifies you.'),
|
_m('OpenID URL'),
|
||||||
null, true,
|
null,
|
||||||
['placeholder'=>'https://example.com/you']);
|
// TRANS: Form guide.
|
||||||
|
_m('An OpenID URL which identifies you.'),
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
['placeholder' => 'https://example.com/you']
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
// TRANS: Field label.
|
// TRANS: Field label.
|
||||||
$this->checkbox('openid-synch', _m('Synchronize Account'), false,
|
$this->checkbox(
|
||||||
// TRANS: Form guide.
|
'openid-synch',
|
||||||
_m('Synchronize GNU social profile with this OpenID identity.'));
|
_m('Synchronize Account'),
|
||||||
|
false,
|
||||||
|
// TRANS: Form guide.
|
||||||
|
_m('Synchronize GNU social profile with this OpenID identity.')
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementEnd('ul');
|
$this->elementEnd('ul');
|
||||||
// TRANS: Button text for adding an OpenID URL.
|
// TRANS: Button text for adding an OpenID URL.
|
||||||
|
@ -129,13 +130,16 @@ class OpenidsettingsAction extends SettingsAction
|
||||||
$this->element('h2', null, _m('HEADER', 'OpenID Actions'));
|
$this->element('h2', null, _m('HEADER', 'OpenID Actions'));
|
||||||
|
|
||||||
if ($cnt == 1 && !$this->scoped->hasPassword()) {
|
if ($cnt == 1 && !$this->scoped->hasPassword()) {
|
||||||
$this->element('p', 'form_guide',
|
$this->element(
|
||||||
// TRANS: Form guide.
|
'p',
|
||||||
_m('You can\'t remove your main OpenID account ' .
|
'form_guide',
|
||||||
'without either adding a password to your ' .
|
// TRANS: Form guide.
|
||||||
'GNU social account or another OpenID account. ' .
|
_m('You can\'t remove your main OpenID account ' .
|
||||||
'You can synchronize your profile with your ' .
|
'without either adding a password to your ' .
|
||||||
'OpenID by clicking the button labeled "Synchronize".'));
|
'GNU social account or another OpenID account. ' .
|
||||||
|
'You can synchronize your profile with your ' .
|
||||||
|
'OpenID by clicking the button labeled "Synchronize".')
|
||||||
|
);
|
||||||
|
|
||||||
if ($oid->fetch()) {
|
if ($oid->fetch()) {
|
||||||
$this->elementStart('form', ['method' => 'POST',
|
$this->elementStart('form', ['method' => 'POST',
|
||||||
|
@ -152,12 +156,15 @@ class OpenidsettingsAction extends SettingsAction
|
||||||
$this->elementEnd('form');
|
$this->elementEnd('form');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->element('p', 'form_guide',
|
$this->element(
|
||||||
// TRANS: Form guide.
|
'p',
|
||||||
_m('You can remove an OpenID from your account ' .
|
'form_guide',
|
||||||
'by clicking the button labeled "Remove". ' .
|
// TRANS: Form guide.
|
||||||
'You can synchronize your profile with an OpenID ' .
|
_m('You can remove an OpenID from your account ' .
|
||||||
'by clicking the button labeled "Synchronize".'));
|
'by clicking the button labeled "Remove". ' .
|
||||||
|
'You can synchronize your profile with an OpenID ' .
|
||||||
|
'by clicking the button labeled "Synchronize".')
|
||||||
|
);
|
||||||
$idx = 0;
|
$idx = 0;
|
||||||
|
|
||||||
while ($oid->fetch()) {
|
while ($oid->fetch()) {
|
||||||
|
@ -191,26 +198,38 @@ class OpenidsettingsAction extends SettingsAction
|
||||||
// TRANS: Fieldset legend.
|
// TRANS: Fieldset legend.
|
||||||
$this->element('legend', null, _m('OpenID Trusted Sites'));
|
$this->element('legend', null, _m('OpenID Trusted Sites'));
|
||||||
$this->hidden('token', common_session_token());
|
$this->hidden('token', common_session_token());
|
||||||
$this->element('p', 'form_guide',
|
$this->element(
|
||||||
// TRANS: Form guide.
|
'p',
|
||||||
_m('The following sites are allowed to access your ' .
|
'form_guide',
|
||||||
'identity and log you in. You can remove a site from ' .
|
// TRANS: Form guide.
|
||||||
'this list to deny it access to your OpenID.'));
|
_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');
|
$this->elementStart('ul', 'form_data');
|
||||||
$user_openid_trustroot = new User_openid_trustroot();
|
$user_openid_trustroot = new User_openid_trustroot();
|
||||||
$user_openid_trustroot->user_id = $this->scoped->getID();
|
$user_openid_trustroot->user_id = $this->scoped->getID();
|
||||||
if ($user_openid_trustroot->find()) {
|
if ($user_openid_trustroot->find()) {
|
||||||
while ($user_openid_trustroot->fetch()) {
|
while ($user_openid_trustroot->fetch()) {
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
$this->element('input', ['name' => 'openid_trustroot[]',
|
$this->element(
|
||||||
'type' => 'checkbox',
|
'input',
|
||||||
'class' => 'checkbox',
|
[
|
||||||
'value' => $user_openid_trustroot->trustroot,
|
'name' => 'openid_trustroot[]',
|
||||||
'id' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot)]);
|
'type' => 'checkbox',
|
||||||
$this->element('label',
|
'class' => 'checkbox',
|
||||||
['class'=>'checkbox',
|
'value' => $user_openid_trustroot->trustroot,
|
||||||
'for' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot)],
|
'id' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot),
|
||||||
$user_openid_trustroot->trustroot);
|
]
|
||||||
|
);
|
||||||
|
$this->element(
|
||||||
|
'label',
|
||||||
|
[
|
||||||
|
'class'=>'checkbox',
|
||||||
|
'for' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot),
|
||||||
|
],
|
||||||
|
$user_openid_trustroot->trustroot
|
||||||
|
);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,7 +382,7 @@ class OpenidsettingsAction extends SettingsAction
|
||||||
$orig = clone($prefs);
|
$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) {
|
if ($orig instanceof User_openid_prefs) {
|
||||||
$prefs->update($orig);
|
$prefs->update($orig);
|
||||||
|
|
|
@ -1,44 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data class to record user prefs for polls
|
* Data class to record user prefs for polls
|
||||||
*
|
*
|
||||||
* PHP version 5
|
* @category PollPlugin
|
||||||
*
|
* @package GNUsocial
|
||||||
* @category PollPlugin
|
* @author Brion Vibber <brion@status.net>
|
||||||
* @package StatusNet
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @copyright 2012, StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For storing the poll prefs
|
* For storing the poll prefs
|
||||||
*
|
*
|
||||||
* @category PollPlugin
|
* @copyright 2012, StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Brion Vibber <brion@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
*
|
||||||
* @see DB_DataObject
|
* @see DB_DataObject
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +39,7 @@ class User_poll_prefs extends Managed_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'user_poll_prefs'; // table name
|
public $__table = 'user_poll_prefs'; // table name
|
||||||
public $user_id; // int id
|
public $user_id; // int id
|
||||||
public $hide_responses; // boolean
|
public $hide_responses; // bool
|
||||||
public $created; // datetime
|
public $created; // datetime
|
||||||
public $modified; // datetime
|
public $modified; // datetime
|
||||||
|
|
||||||
|
@ -59,7 +52,7 @@ class User_poll_prefs extends Managed_DataObject
|
||||||
'description' => 'Record of user preferences for polls',
|
'description' => 'Record of user preferences for polls',
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
'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'),
|
'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'),
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,47 +1,36 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 2011, StatusNet, Inc.
|
|
||||||
*
|
|
||||||
* Close a question to further answers
|
* 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
|
* @category QnA
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2011 StatusNet, Inc.
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or late
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
if (!defined('STATUSNET')) {
|
|
||||||
// This check helps protect against security problems;
|
defined('GNUSOCIAL') || die();
|
||||||
// your code file can't be executed directly from the web.
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close a question to new answers
|
* Close a question to new answers
|
||||||
*
|
*
|
||||||
* @category QnA
|
|
||||||
* @package StatusNet
|
|
||||||
* @author Zach Copley <zach@status.net>
|
|
||||||
* @copyright 2010 StatusNet, Inc.
|
* @copyright 2010 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or late
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class QnaclosequestionAction extends Action
|
class QnaclosequestionAction extends Action
|
||||||
{
|
{
|
||||||
|
@ -57,7 +46,7 @@ class QnaclosequestionAction extends Action
|
||||||
*
|
*
|
||||||
* @return string Action title
|
* @return string Action title
|
||||||
*/
|
*/
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
// TRANS: Page title for close a question
|
// TRANS: Page title for close a question
|
||||||
return _m('Close question');
|
return _m('Close question');
|
||||||
|
@ -71,7 +60,7 @@ class QnaclosequestionAction extends Action
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
* @throws ClientException
|
* @throws ClientException
|
||||||
*/
|
*/
|
||||||
function prepare(array $args = [])
|
public function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
if ($this->boolean('ajax')) {
|
if ($this->boolean('ajax')) {
|
||||||
|
@ -107,7 +96,7 @@ class QnaclosequestionAction extends Action
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
parent::handle();
|
parent::handle();
|
||||||
|
|
||||||
|
@ -125,7 +114,7 @@ class QnaclosequestionAction extends Action
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function closeQuestion()
|
public function closeQuestion()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
|
@ -136,9 +125,8 @@ class QnaclosequestionAction extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$orig = clone($this->question);
|
$orig = clone($this->question);
|
||||||
$this->question->closed = 1;
|
$this->question->closed = true;
|
||||||
$this->question->update($orig);
|
$this->question->update($orig);
|
||||||
|
|
||||||
} catch (ClientException $ce) {
|
} catch (ClientException $ce) {
|
||||||
$this->error = $ce->getMessage();
|
$this->error = $ce->getMessage();
|
||||||
$this->showPage();
|
$this->showPage();
|
||||||
|
@ -166,7 +154,7 @@ class QnaclosequestionAction extends Action
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showContent()
|
public function showContent()
|
||||||
{
|
{
|
||||||
if (!empty($this->error)) {
|
if (!empty($this->error)) {
|
||||||
$this->element('p', 'error', $this->error);
|
$this->element('p', 'error', $this->error);
|
||||||
|
@ -184,7 +172,7 @@ class QnaclosequestionAction extends Action
|
||||||
*
|
*
|
||||||
* @return boolean is read only action?
|
* @return boolean is read only action?
|
||||||
*/
|
*/
|
||||||
function isReadOnly($args)
|
public function isReadOnly($args)
|
||||||
{
|
{
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||||
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
|
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
|
||||||
|
|
|
@ -1,47 +1,36 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
//
|
||||||
* Copyright (C) 2011, StatusNet, Inc.
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
*
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
* Revise an answer
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* PHP version 5
|
//
|
||||||
*
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// GNU Affero General Public License for more details.
|
||||||
* (at your option) any later version.
|
//
|
||||||
*
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
* This program is distributed in the hope that it will be useful,
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revise an answer
|
* Revise an answer
|
||||||
*
|
*
|
||||||
* @category QnA
|
* @category QnA
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Zach Copley <zach@status.net>
|
* @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.
|
* @copyright 2010 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class QnareviseanswerAction extends Action
|
class QnareviseanswerAction extends Action
|
||||||
{
|
{
|
||||||
|
@ -56,7 +45,7 @@ class QnareviseanswerAction extends Action
|
||||||
*
|
*
|
||||||
* @return string Action title
|
* @return string Action title
|
||||||
*/
|
*/
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
// TRANS: Page title for revising a question
|
// TRANS: Page title for revising a question
|
||||||
return _m('Revise answer');
|
return _m('Revise answer');
|
||||||
|
@ -70,7 +59,7 @@ class QnareviseanswerAction extends Action
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
* @throws ClientException
|
* @throws ClientException
|
||||||
*/
|
*/
|
||||||
function prepare(array $args = [])
|
public function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
if ($this->boolean('ajax')) {
|
if ($this->boolean('ajax')) {
|
||||||
|
@ -110,7 +99,7 @@ class QnareviseanswerAction extends Action
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
parent::handle();
|
parent::handle();
|
||||||
|
|
||||||
|
@ -119,7 +108,7 @@ class QnareviseanswerAction extends Action
|
||||||
if ($this->arg('revise')) {
|
if ($this->arg('revise')) {
|
||||||
$this->showContent();
|
$this->showContent();
|
||||||
return;
|
return;
|
||||||
} else if ($this->arg('best')) {
|
} elseif ($this->arg('best')) {
|
||||||
if ($this->user->id == $this->question->profile_id) {
|
if ($this->user->id == $this->question->profile_id) {
|
||||||
$this->markBest();
|
$this->markBest();
|
||||||
return;
|
return;
|
||||||
|
@ -138,7 +127,7 @@ class QnareviseanswerAction extends Action
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showContent()
|
public function showContent()
|
||||||
{
|
{
|
||||||
if (!empty($this->error)) {
|
if (!empty($this->error)) {
|
||||||
$this->element('p', 'error', $this->error);
|
$this->element('p', 'error', $this->error);
|
||||||
|
@ -154,7 +143,7 @@ class QnareviseanswerAction extends Action
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAjaxReviseForm()
|
public function showAjaxReviseForm()
|
||||||
{
|
{
|
||||||
$this->startHTML('text/xml;charset=utf-8');
|
$this->startHTML('text/xml;charset=utf-8');
|
||||||
$this->elementStart('head');
|
$this->elementStart('head');
|
||||||
|
@ -173,7 +162,7 @@ class QnareviseanswerAction extends Action
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function markBest()
|
public function markBest()
|
||||||
{
|
{
|
||||||
$question = $this->question;
|
$question = $this->question;
|
||||||
$answer = $this->answer;
|
$answer = $this->answer;
|
||||||
|
@ -181,12 +170,12 @@ class QnareviseanswerAction extends Action
|
||||||
try {
|
try {
|
||||||
// close the question to further answers
|
// close the question to further answers
|
||||||
$orig = clone($question);
|
$orig = clone($question);
|
||||||
$question->closed = 1;
|
$question->closed = true;
|
||||||
$result = $question->update($orig);
|
$result = $question->update($orig);
|
||||||
|
|
||||||
// mark this answer an the best answer
|
// mark this answer an the best answer
|
||||||
$orig = clone($answer);
|
$orig = clone($answer);
|
||||||
$answer->best = 1;
|
$answer->best = true;
|
||||||
$result = $answer->update($orig);
|
$result = $answer->update($orig);
|
||||||
} catch (ClientException $ce) {
|
} catch (ClientException $ce) {
|
||||||
$this->error = $ce->getMessage();
|
$this->error = $ce->getMessage();
|
||||||
|
@ -215,7 +204,7 @@ class QnareviseanswerAction extends Action
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function reviseAnswer()
|
public function reviseAnswer()
|
||||||
{
|
{
|
||||||
$answer = $this->answer;
|
$answer = $this->answer;
|
||||||
|
|
||||||
|
@ -255,7 +244,7 @@ class QnareviseanswerAction extends Action
|
||||||
*
|
*
|
||||||
* @return boolean is read only action?
|
* @return boolean is read only action?
|
||||||
*/
|
*/
|
||||||
function isReadOnly($args)
|
public function isReadOnly($args)
|
||||||
{
|
{
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||||
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
|
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
|
||||||
|
|
|
@ -1,46 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data class to save answers to questions
|
* Data class to save answers to questions
|
||||||
*
|
*
|
||||||
* PHP version 5
|
* @category QnA
|
||||||
*
|
* @package GNUsocial
|
||||||
* @category QnA
|
* @author Zach Copley <zach@status.net>
|
||||||
* @package StatusNet
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @author Zach Copley <zach@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 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/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('STATUSNET') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For storing answers
|
* For storing answers
|
||||||
*
|
*
|
||||||
* @category QnA
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Zach Copley <zach@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
*
|
||||||
* @see DB_DataObject
|
* @see DB_DataObject
|
||||||
*/
|
*/
|
||||||
class QnA_Answer extends Managed_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 $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $question_id; // char(36) -> question.id UUID
|
public $question_id; // char(36) -> question.id UUID
|
||||||
public $profile_id; // int -> question.id
|
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 $revisions; // int -> count of revisions to this answer
|
||||||
public $content; // text -> response text
|
public $content; // text -> response text
|
||||||
public $created; // datetime
|
public $created; // datetime
|
||||||
|
@ -82,7 +74,7 @@ class QnA_Answer extends Managed_DataObject
|
||||||
'description' => 'UUID of question being responded to',
|
'description' => 'UUID of question being responded to',
|
||||||
),
|
),
|
||||||
'content' => array('type' => 'text'), // got a better name?
|
'content' => array('type' => 'text'), // got a better name?
|
||||||
'best' => array('type' => 'int', 'size' => 'tiny'),
|
'best' => array('type' => 'bool'),
|
||||||
'revisions' => array('type' => 'int'),
|
'revisions' => array('type' => 'int'),
|
||||||
'profile_id' => array('type' => 'int'),
|
'profile_id' => array('type' => 'int'),
|
||||||
'created' => array('type' => 'datetime', 'not null' => true),
|
'created' => array('type' => 'datetime', 'not null' => true),
|
||||||
|
@ -105,7 +97,7 @@ class QnA_Answer extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return QnA_Answer found response or null
|
* @return QnA_Answer found response or null
|
||||||
*/
|
*/
|
||||||
static function getByNotice($notice)
|
public static function getByNotice($notice)
|
||||||
{
|
{
|
||||||
$answer = self::getKV('uri', $notice->uri);
|
$answer = self::getKV('uri', $notice->uri);
|
||||||
if (empty($answer)) {
|
if (empty($answer)) {
|
||||||
|
@ -119,17 +111,17 @@ class QnA_Answer extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return Notice
|
* @return Notice
|
||||||
*/
|
*/
|
||||||
function getNotice()
|
public function getNotice()
|
||||||
{
|
{
|
||||||
return Notice::getKV('uri', $this->uri);
|
return Notice::getKV('uri', $this->uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function fromNotice($notice)
|
public static function fromNotice($notice)
|
||||||
{
|
{
|
||||||
return QnA_Answer::getKV('uri', $notice->uri);
|
return QnA_Answer::getKV('uri', $notice->uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUrl()
|
public function getUrl()
|
||||||
{
|
{
|
||||||
return $this->getNotice()->getUrl();
|
return $this->getNotice()->getUrl();
|
||||||
}
|
}
|
||||||
|
@ -139,29 +131,29 @@ class QnA_Answer extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return QnA_Question
|
* @return QnA_Question
|
||||||
*/
|
*/
|
||||||
function getQuestion()
|
public function getQuestion()
|
||||||
{
|
{
|
||||||
$question = QnA_Question::getKV('id', $this->question_id);
|
$question = QnA_Question::getKV('id', $this->question_id);
|
||||||
if (empty($question)) {
|
if (empty($question)) {
|
||||||
// TRANS: Exception thown when getting a question with a non-existing ID.
|
// TRANS: Exception thown when getting a question with a non-existing ID.
|
||||||
// TRANS: %s is the non-existing question 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;
|
return $question;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProfile()
|
public function getProfile()
|
||||||
{
|
{
|
||||||
$profile = Profile::getKV('id', $this->profile_id);
|
$profile = Profile::getKV('id', $this->profile_id);
|
||||||
if (empty($profile)) {
|
if (empty($profile)) {
|
||||||
// TRANS: Exception thown when getting a profile with a non-existing ID.
|
// TRANS: Exception thown when getting a profile with a non-existing ID.
|
||||||
// TRANS: %s is the non-existing profile 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;
|
return $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function asHTML()
|
public function asHTML()
|
||||||
{
|
{
|
||||||
return self::toHTML(
|
return self::toHTML(
|
||||||
$this->getProfile(),
|
$this->getProfile(),
|
||||||
|
@ -170,7 +162,7 @@ class QnA_Answer extends Managed_DataObject
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function asString()
|
public function asString()
|
||||||
{
|
{
|
||||||
return self::toString(
|
return self::toString(
|
||||||
$this->getProfile(),
|
$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();
|
$notice = $question->getNotice();
|
||||||
|
|
||||||
|
@ -201,7 +193,7 @@ class QnA_Answer extends Managed_DataObject
|
||||||
htmlspecialchars(
|
htmlspecialchars(
|
||||||
// Notification of how often an answer was revised.
|
// Notification of how often an answer was revised.
|
||||||
// TRANS: %s is the number of answer revisions.
|
// 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');
|
$out->elementEnd('span');
|
||||||
|
@ -212,7 +204,7 @@ class QnA_Answer extends Managed_DataObject
|
||||||
return $out->getString();
|
return $out->getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function toString($profile, $question, $answer)
|
public static function toString($profile, $question, $answer)
|
||||||
{
|
{
|
||||||
// @todo FIXME: unused variable?
|
// @todo FIXME: unused variable?
|
||||||
$notice = $question->getNotice();
|
$notice = $question->getNotice();
|
||||||
|
@ -237,7 +229,7 @@ class QnA_Answer extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return Notice saved notice
|
* @return Notice saved notice
|
||||||
*/
|
*/
|
||||||
static function saveNew($profile, $question, $text, $options = null)
|
public static function saveNew($profile, $question, $text, $options = null)
|
||||||
{
|
{
|
||||||
if (empty($options)) {
|
if (empty($options)) {
|
||||||
$options = array();
|
$options = array();
|
||||||
|
@ -248,7 +240,7 @@ class QnA_Answer extends Managed_DataObject
|
||||||
$answer->profile_id = $profile->id;
|
$answer->profile_id = $profile->id;
|
||||||
$answer->question_id = $question->id;
|
$answer->question_id = $question->id;
|
||||||
$answer->revisions = 0;
|
$answer->revisions = 0;
|
||||||
$answer->best = 0;
|
$answer->best = false;
|
||||||
$answer->content = $text;
|
$answer->content = $text;
|
||||||
$answer->created = common_sql_now();
|
$answer->created = common_sql_now();
|
||||||
$answer->uri = common_local_url(
|
$answer->uri = common_local_url(
|
||||||
|
|
|
@ -1,46 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data class to mark a notice as a question
|
* Data class to mark a notice as a question
|
||||||
*
|
*
|
||||||
* PHP version 5
|
* @category QnA
|
||||||
*
|
* @package GNUsocial
|
||||||
* @category QnA
|
* @author Zach Copley <zach@status.net>
|
||||||
* @package StatusNet
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @author Zach Copley <zach@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 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/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For storing a question
|
* For storing a question
|
||||||
*
|
*
|
||||||
* @category QnA
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Zach Copley <zach@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
*
|
||||||
* @see DB_DataObject
|
* @see DB_DataObject
|
||||||
*/
|
*/
|
||||||
class QnA_Question extends Managed_DataObject
|
class QnA_Question extends Managed_DataObject
|
||||||
{
|
{
|
||||||
|
@ -52,7 +44,7 @@ class QnA_Question extends Managed_DataObject
|
||||||
public $profile_id; // int -> profile.id
|
public $profile_id; // int -> profile.id
|
||||||
public $title; // text
|
public $title; // text
|
||||||
public $description; // text
|
public $description; // text
|
||||||
public $closed; // int (boolean) whether a question is closed
|
public $closed; // bool -> whether a question is closed
|
||||||
public $created; // datetime
|
public $created; // datetime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +68,7 @@ class QnA_Question extends Managed_DataObject
|
||||||
),
|
),
|
||||||
'profile_id' => array('type' => 'int'),
|
'profile_id' => array('type' => 'int'),
|
||||||
'title' => array('type' => 'text'),
|
'title' => array('type' => 'text'),
|
||||||
'closed' => array('type' => 'int', 'size' => 'tiny'),
|
'closed' => array('type' => 'bool'),
|
||||||
'description' => array('type' => 'text'),
|
'description' => array('type' => 'text'),
|
||||||
'created' => array(
|
'created' => array(
|
||||||
'type' => 'datetime',
|
'type' => 'datetime',
|
||||||
|
@ -97,28 +89,28 @@ class QnA_Question extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return Question found question or null
|
* @return Question found question or null
|
||||||
*/
|
*/
|
||||||
static function getByNotice($notice)
|
public static function getByNotice($notice)
|
||||||
{
|
{
|
||||||
return self::getKV('uri', $notice->uri);
|
return self::getKV('uri', $notice->uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotice()
|
public function getNotice()
|
||||||
{
|
{
|
||||||
return Notice::getKV('uri', $this->uri);
|
return Notice::getKV('uri', $this->uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUrl()
|
public function getUrl()
|
||||||
{
|
{
|
||||||
return $this->getNotice()->getUrl();
|
return $this->getNotice()->getUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProfile()
|
public function getProfile()
|
||||||
{
|
{
|
||||||
$profile = Profile::getKV('id', $this->profile_id);
|
$profile = Profile::getKV('id', $this->profile_id);
|
||||||
if (empty($profile)) {
|
if (empty($profile)) {
|
||||||
// TRANS: Exception trown when getting a profile for a non-existing ID.
|
// TRANS: Exception trown when getting a profile for a non-existing ID.
|
||||||
// TRANS: %s is the provided profile 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;
|
return $profile;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +122,7 @@ class QnA_Question extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return Answer object or null
|
* @return Answer object or null
|
||||||
*/
|
*/
|
||||||
function getAnswer(Profile $profile)
|
public function getAnswer(Profile $profile)
|
||||||
{
|
{
|
||||||
$a = new QnA_Answer();
|
$a = new QnA_Answer();
|
||||||
$a->question_id = $this->id;
|
$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 = new QnA_Answer();
|
||||||
$a->question_id = $this->id;
|
$a->question_id = $this->id;
|
||||||
|
@ -155,7 +147,7 @@ class QnA_Question extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function countAnswers()
|
public function countAnswers()
|
||||||
{
|
{
|
||||||
$a = new QnA_Answer();
|
$a = new QnA_Answer();
|
||||||
|
|
||||||
|
@ -164,22 +156,22 @@ class QnA_Question extends Managed_DataObject
|
||||||
return $a->count();
|
return $a->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function fromNotice($notice)
|
public static function fromNotice($notice)
|
||||||
{
|
{
|
||||||
return QnA_Question::getKV('uri', $notice->uri);
|
return QnA_Question::getKV('uri', $notice->uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
function asHTML()
|
public function asHTML()
|
||||||
{
|
{
|
||||||
return self::toHTML($this->getProfile(), $this);
|
return self::toHTML($this->getProfile(), $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function asString()
|
public function asString()
|
||||||
{
|
{
|
||||||
return self::toString($this->getProfile(), $this);
|
return self::toString($this->getProfile(), $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function toHTML($profile, $question)
|
public static function toHTML($profile, $question)
|
||||||
{
|
{
|
||||||
$notice = $question->getNotice();
|
$notice = $question->getNotice();
|
||||||
|
|
||||||
|
@ -205,7 +197,7 @@ class QnA_Question extends Managed_DataObject
|
||||||
$out->elementStart('span', 'answer-count');
|
$out->elementStart('span', 'answer-count');
|
||||||
// TRANS: Number of given answers to a question.
|
// TRANS: Number of given answers to a question.
|
||||||
// TRANS: %s is the number of given answers.
|
// 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');
|
$out->elementEnd('span');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +213,7 @@ class QnA_Question extends Managed_DataObject
|
||||||
return $out->getString();
|
return $out->getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function toString($profile, $question, $answers)
|
public static function toString($profile, $question, $answers)
|
||||||
{
|
{
|
||||||
return sprintf(htmlspecialchars($question->description));
|
return sprintf(htmlspecialchars($question->description));
|
||||||
}
|
}
|
||||||
|
@ -237,7 +229,7 @@ class QnA_Question extends Managed_DataObject
|
||||||
*
|
*
|
||||||
* @return Notice saved notice
|
* @return Notice saved notice
|
||||||
*/
|
*/
|
||||||
static function saveNew($profile, $title, $description, $options = array())
|
public static function saveNew($profile, $title, $description, $options = [])
|
||||||
{
|
{
|
||||||
$q = new QnA_Question();
|
$q = new QnA_Question();
|
||||||
|
|
||||||
|
|
|
@ -1,51 +1,72 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
class SensitiveContentSettingsAction extends SettingsAction
|
class SensitiveContentSettingsAction extends SettingsAction
|
||||||
{
|
{
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
return _m('Sensitive content settings');
|
return _m('Sensitive content settings');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInstructions()
|
public function getInstructions()
|
||||||
{
|
{
|
||||||
return _m('Set preferences for display of "sensitive" content');
|
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',
|
$this->elementStart('fieldset');
|
||||||
'id' => 'sensitivecontent',
|
$this->hidden('token', common_session_token());
|
||||||
'class' => 'form_settings',
|
$this->elementStart('ul', 'form_data');
|
||||||
'action' => common_local_url('sensitivecontentsettings')));
|
|
||||||
|
|
||||||
$this->elementStart('fieldset');
|
$this->elementStart('li');
|
||||||
$this->hidden('token', common_session_token());
|
$this->checkbox(
|
||||||
$this->elementStart('ul', 'form_data');
|
'hidesensitive',
|
||||||
|
_('Hide attachments in posts hashtagged #NSFW'),
|
||||||
$this->elementStart('li');
|
($this->arg('hidesensitive') ?
|
||||||
$this->checkbox('hidesensitive', _('Hide attachments in posts hashtagged #NSFW'),
|
$this->boolean('hidesensitive') : $this->scoped->getPref('MoonMan', 'hide_sensitive', 0))
|
||||||
($this->arg('hidesensitive')) ?
|
);
|
||||||
$this->boolean('hidesensitive') : $this->scoped->getPref('MoonMan','hide_sensitive',0));
|
$this->elementEnd('li');
|
||||||
$this->elementEnd('li');
|
|
||||||
|
|
||||||
|
|
||||||
$this->elementEnd('ul');
|
$this->elementEnd('ul');
|
||||||
$this->submit('save', _m('BUTTON','Save'));
|
$this->submit('save', _m('BUTTON', 'Save'));
|
||||||
|
|
||||||
$this->elementEnd('fieldset');
|
$this->elementEnd('fieldset');
|
||||||
$this->elementEnd('form');
|
$this->elementEnd('form');
|
||||||
}
|
}
|
||||||
|
|
||||||
function doPost()
|
public function doPost()
|
||||||
{
|
{
|
||||||
$hidesensitive = $this->booleanintstring('hidesensitive');
|
$hidesensitive = $this->boolean('hidesensitive') ? '1' : '0';
|
||||||
$this->scoped->setPref('MoonMan','hide_sensitive', $hidesensitive);
|
$this->scoped->setPref('MoonMan', 'hide_sensitive', $hidesensitive);
|
||||||
return _('Settings saved.');
|
return _('Settings saved.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Plugin
|
* @category Plugin
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @author Julien C <chaumond@gmail.com>
|
* @author Julien C <chaumond@gmail.com>
|
||||||
* @author Brion Vibber <brion@status.net>
|
* @author Brion Vibber <brion@status.net>
|
||||||
* @copyright 2009-2010 StatusNet, Inc.
|
* @copyright 2009-2010 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once dirname(__DIR__) . '/twitter.php';
|
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
|
* Is used by both the polling twitterstatusfetcher.php daemon, and the
|
||||||
* in-progress streaming import.
|
* in-progress streaming import.
|
||||||
*
|
*
|
||||||
* @category Plugin
|
* @copyright 2009-2010 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @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/
|
|
||||||
*/
|
*/
|
||||||
class TwitterImport
|
class TwitterImport
|
||||||
{
|
{
|
||||||
|
@ -74,12 +63,12 @@ class TwitterImport
|
||||||
return $notice;
|
return $notice;
|
||||||
}
|
}
|
||||||
|
|
||||||
function name()
|
public function name()
|
||||||
{
|
{
|
||||||
return get_class($this);
|
return get_class($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveStatus($status)
|
public function saveStatus($status)
|
||||||
{
|
{
|
||||||
$profile = $this->ensureProfile($status->user);
|
$profile = $this->ensureProfile($status->user);
|
||||||
|
|
||||||
|
@ -103,7 +92,7 @@ class TwitterImport
|
||||||
}
|
}
|
||||||
|
|
||||||
$dupe = Notice::getKV('uri', $statusUri);
|
$dupe = Notice::getKV('uri', $statusUri);
|
||||||
if($dupe instanceof Notice) {
|
if ($dupe instanceof Notice) {
|
||||||
// Add it to our record
|
// Add it to our record
|
||||||
Notice_to_status::saveNew($dupe->id, $statusId);
|
Notice_to_status::saveNew($dupe->id, $statusId);
|
||||||
common_log(
|
common_log(
|
||||||
|
@ -123,24 +112,29 @@ class TwitterImport
|
||||||
$author = $original->getProfile();
|
$author = $original->getProfile();
|
||||||
// TRANS: Message used to repeat a notice. RT is the abbreviation of 'retweet'.
|
// 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.
|
// TRANS: %1$s is the repeated user's name, %2$s is the repeated notice.
|
||||||
$content = sprintf(_m('RT @%1$s %2$s'),
|
$content = sprintf(
|
||||||
$author->nickname,
|
_m('RT @%1$s %2$s'),
|
||||||
$original->content);
|
$author->nickname,
|
||||||
|
$original->content
|
||||||
|
);
|
||||||
|
|
||||||
if (Notice::contentTooLong($content)) {
|
if (Notice::contentTooLong($content)) {
|
||||||
$contentlimit = Notice::maxContent();
|
$contentlimit = Notice::maxContent();
|
||||||
$content = mb_substr($content, 0, $contentlimit - 4) . ' ...';
|
$content = mb_substr($content, 0, $contentlimit - 4) . ' ...';
|
||||||
}
|
}
|
||||||
|
|
||||||
$repeat = Notice::saveNew($profile->id,
|
$repeat = Notice::saveNew(
|
||||||
$content,
|
$profile->id,
|
||||||
'twitter',
|
$content,
|
||||||
array('repeat_of' => $original->id,
|
'twitter',
|
||||||
'uri' => $statusUri,
|
[
|
||||||
'is_local' => Notice::GATEWAY,
|
'repeat_of' => $original->id,
|
||||||
'object_type' => ActivityObject::NOTE,
|
'uri' => $statusUri,
|
||||||
'verb' => ActivityVerb::POST
|
'is_local' => Notice::GATEWAY,
|
||||||
));
|
'object_type' => ActivityObject::NOTE,
|
||||||
|
'verb' => ActivityVerb::POST,
|
||||||
|
]
|
||||||
|
);
|
||||||
common_log(LOG_INFO, "Saved {$repeat->id} as a repeat of {$original->id}");
|
common_log(LOG_INFO, "Saved {$repeat->id} as a repeat of {$original->id}");
|
||||||
Notice_to_status::saveNew($repeat->id, $statusId);
|
Notice_to_status::saveNew($repeat->id, $statusId);
|
||||||
return $repeat;
|
return $repeat;
|
||||||
|
@ -183,11 +177,10 @@ class TwitterImport
|
||||||
|
|
||||||
$notice->is_local = Notice::GATEWAY;
|
$notice->is_local = Notice::GATEWAY;
|
||||||
|
|
||||||
$notice->content = html_entity_decode($this->linkify($status, FALSE), ENT_QUOTES, 'UTF-8');
|
$notice->content = html_entity_decode($this->linkify($status, false), ENT_QUOTES, 'UTF-8');
|
||||||
$notice->rendered = $this->linkify($status, TRUE);
|
$notice->rendered = $this->linkify($status, true);
|
||||||
|
|
||||||
if (Event::handle('StartNoticeSave', array(&$notice))) {
|
if (Event::handle('StartNoticeSave', array(&$notice))) {
|
||||||
|
|
||||||
if (empty($notice->conversation)) {
|
if (empty($notice->conversation)) {
|
||||||
$conv = Conversation::create();
|
$conv = Conversation::create();
|
||||||
common_log(LOG_INFO, "No known conversation for status {$statusId} so a new one ({$conv->getID()}) was created.");
|
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
|
* @return string URI
|
||||||
*/
|
*/
|
||||||
function makeStatusURI($username, $id)
|
public function makeStatusURI($username, $id)
|
||||||
{
|
{
|
||||||
return 'https://twitter.com/'
|
return 'https://twitter.com/'
|
||||||
. $username
|
. $username
|
||||||
|
@ -283,7 +276,7 @@ class TwitterImport
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
throw new Exception('Failed insert');
|
throw new Exception('Failed insert');
|
||||||
}
|
}
|
||||||
} catch(Exception $e) {
|
} catch (Exception $e) {
|
||||||
common_log(LOG_WARNING, __METHOD__ . " Couldn't insert profile: " . $e->getMessage());
|
common_log(LOG_WARNING, __METHOD__ . " Couldn't insert profile: " . $e->getMessage());
|
||||||
common_log_db_error($profile, 'INSERT', __FILE__);
|
common_log_db_error($profile, 'INSERT', __FILE__);
|
||||||
$profile->query("ROLLBACK");
|
$profile->query("ROLLBACK");
|
||||||
|
@ -314,8 +307,13 @@ class TwitterImport
|
||||||
if ($avatar->filename === $filename) {
|
if ($avatar->filename === $filename) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
common_debug(__METHOD__ . " - Updating profile avatar (profile_id={$profile->id}) " .
|
common_debug(sprintf(
|
||||||
"from {$avatar->filename} to {$filename}");
|
'%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
|
// else we continue with creating a new avatar
|
||||||
} catch (NoAvatarException $e) {
|
} catch (NoAvatarException $e) {
|
||||||
// Avatar was not found. We can catch NoAvatarException or FileNotFoundException
|
// Avatar was not found. We can catch NoAvatarException or FileNotFoundException
|
||||||
|
@ -367,7 +365,7 @@ class TwitterImport
|
||||||
|
|
||||||
$avatar = new Avatar();
|
$avatar = new Avatar();
|
||||||
$avatar->profile_id = $profile->id;
|
$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->mediatype = $mediatype;
|
||||||
$avatar->filename = $filename;
|
$avatar->filename = $filename;
|
||||||
$avatar->width = $this->avatarsize;
|
$avatar->width = $this->avatarsize;
|
||||||
|
@ -416,7 +414,7 @@ class TwitterImport
|
||||||
const HASHTAG = 2;
|
const HASHTAG = 2;
|
||||||
const MENTION = 3;
|
const MENTION = 3;
|
||||||
|
|
||||||
function linkify($status, $html = FALSE)
|
public function linkify($status, $html = false)
|
||||||
{
|
{
|
||||||
$text = $status->text;
|
$text = $status->text;
|
||||||
|
|
||||||
|
@ -424,10 +422,20 @@ class TwitterImport
|
||||||
$statusId = twitter_id($status);
|
$statusId = twitter_id($status);
|
||||||
common_log(LOG_WARNING, "No entities data for {$statusId}; trying to fake up links ourselves.");
|
common_log(LOG_WARNING, "No entities data for {$statusId}; trying to fake up links ourselves.");
|
||||||
$text = common_replace_urls_callback($text, 'common_linkify');
|
$text = common_replace_urls_callback($text, 'common_linkify');
|
||||||
$text = preg_replace_callback('/(^|\"\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/',
|
$text = preg_replace_callback(
|
||||||
function ($m) { return $m[1].'#'.TwitterStatusFetcher::tagLink($m[2]); }, $text);
|
'/(^|\"\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/',
|
||||||
$text = preg_replace_callback('/(^|\s+)@([a-z0-9A-Z_]{1,64})/',
|
function ($m) {
|
||||||
function ($m) { return $m[1].'@'.TwitterStatusFetcher::atLink($m[2]); }, $text);
|
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;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,21 +480,21 @@ class TwitterImport
|
||||||
$cursor = $start;
|
$cursor = $start;
|
||||||
}
|
}
|
||||||
$orig = $this->twitEscape(mb_substr($text, $start, $end - $start));
|
$orig = $this->twitEscape(mb_substr($text, $start, $end - $start));
|
||||||
switch($type) {
|
switch ($type) {
|
||||||
case self::URL:
|
case self::URL:
|
||||||
$linkText = $this->makeUrlLink($object, $orig, $html);
|
$linkText = $this->makeUrlLink($object, $orig, $html);
|
||||||
break;
|
break;
|
||||||
case self::HASHTAG:
|
case self::HASHTAG:
|
||||||
if ($html) {
|
if ($html) {
|
||||||
$linkText = $this->makeHashtagLink($object, $orig);
|
$linkText = $this->makeHashtagLink($object, $orig);
|
||||||
}else{
|
} else {
|
||||||
$linkText = $orig;
|
$linkText = $orig;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::MENTION:
|
case self::MENTION:
|
||||||
if ($html) {
|
if ($html) {
|
||||||
$linkText = $this->makeMentionLink($object, $orig);
|
$linkText = $this->makeMentionLink($object, $orig);
|
||||||
}else{
|
} else {
|
||||||
$linkText = $orig;
|
$linkText = $orig;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -503,7 +511,7 @@ class TwitterImport
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function twitEscape($str)
|
public function twitEscape($str)
|
||||||
{
|
{
|
||||||
// Twitter seems to preemptive turn < and > into < and >
|
// Twitter seems to preemptive turn < and > into < and >
|
||||||
// but doesn't for &, so while you may have some magic protection
|
// 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'));
|
return htmlspecialchars(html_entity_decode($str, ENT_COMPAT, 'UTF-8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeUrlLink($object, $orig, $html)
|
public function makeUrlLink($object, $orig, $html)
|
||||||
{
|
{
|
||||||
if ($html) {
|
if ($html) {
|
||||||
return '<a href="'.htmlspecialchars($object->expanded_url).'" class="extlink">'.htmlspecialchars($object->display_url).'</a>';
|
return '<a href="'.htmlspecialchars($object->expanded_url).'" class="extlink">'.htmlspecialchars($object->display_url).'</a>';
|
||||||
}else{
|
} else {
|
||||||
return htmlspecialchars($object->expanded_url);
|
return htmlspecialchars($object->expanded_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeHashtagLink($object, $orig)
|
public function makeHashtagLink($object, $orig)
|
||||||
{
|
{
|
||||||
return "#" . self::tagLink($object->text, substr($orig, 1));
|
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));
|
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>";
|
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)) {
|
if (!empty($fullName)) {
|
||||||
return "<a href='https://twitter.com/{$screenName}' title='{$fullName}'>{$orig}</a>";
|
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();
|
$mentions = array();
|
||||||
|
|
||||||
|
@ -582,7 +590,7 @@ class TwitterImport
|
||||||
* @param Notice $notice
|
* @param Notice $notice
|
||||||
* @param object $status
|
* @param object $status
|
||||||
*/
|
*/
|
||||||
function saveStatusAttachments(Notice $notice, $status)
|
public function saveStatusAttachments(Notice $notice, $status)
|
||||||
{
|
{
|
||||||
if (common_config('attachments', 'process_links')) {
|
if (common_config('attachments', 'process_links')) {
|
||||||
if (!empty($status->entities) && !empty($status->entities->urls)) {
|
if (!empty($status->entities) && !empty($status->entities->urls)) {
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
/*
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
* StatusNet - a distributed open-source microblogging tool
|
//
|
||||||
* Copyright (C) 2008, 2009, StatusNet, Inc.
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
*
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
// (at your option) any later version.
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
//
|
||||||
* (at your option) any later version.
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
*
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* This program is distributed in the hope that it will be useful,
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// GNU Affero General Public License for more details.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
//
|
||||||
* GNU Affero General Public License for more details.
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
*
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
/**
|
||||||
|
* @package GNUsocial
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @copyright 2008, 2009 StatusNet, Inc.
|
||||||
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('INSTALLDIR', dirname(__DIR__));
|
define('INSTALLDIR', dirname(__DIR__));
|
||||||
|
@ -44,7 +48,6 @@ if (empty($nickname) || empty($groupname)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$user = User::getKV('nickname', $nickname);
|
$user = User::getKV('nickname', $nickname);
|
||||||
|
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
|
@ -78,12 +81,11 @@ try {
|
||||||
|
|
||||||
$orig = clone($member);
|
$orig = clone($member);
|
||||||
|
|
||||||
$member->is_admin = 1;
|
$member->is_admin = true;
|
||||||
|
|
||||||
if (!$member->update($orig)) {
|
if (!$member->update($orig)) {
|
||||||
throw new Exception("Can't make '$nickname' admin of '$groupname'.");
|
throw new Exception("Can't make '$nickname' admin of '$groupname'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print $e->getMessage() . "\n";
|
print $e->getMessage() . "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -443,7 +443,7 @@ function initProfileLists()
|
||||||
|
|
||||||
$plist->tagger = $ptag->tagger;
|
$plist->tagger = $ptag->tagger;
|
||||||
$plist->tag = $ptag->tag;
|
$plist->tag = $ptag->tag;
|
||||||
$plist->private = 0;
|
$plist->private = false;
|
||||||
$plist->created = common_sql_now();
|
$plist->created = common_sql_now();
|
||||||
$plist->modified = $plist->created;
|
$plist->modified = $plist->created;
|
||||||
$plist->mainpage = common_local_url(
|
$plist->mainpage = common_local_url(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user