Comparar commits
33 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| abc2315af6 | |||
| 67a08833ef | |||
| b7ec6811cf | |||
| e498c04e4d | |||
| 5d62118dc2 | |||
| fb13624d6e | |||
| 3fc86e6535 | |||
| 3ebf4db632 | |||
| 91f5a9e442 | |||
| 1e63aeb4f2 | |||
| 7c93c34d66 | |||
| 3bdba42c08 | |||
| bdde933224 | |||
| ca8312b592 | |||
| 7c4f254881 | |||
| e88f99b3e1 | |||
| 57dd6ff9e7 | |||
| 7abfb17ac4 | |||
| 6a8d4893fc | |||
| 4f78b89b90 | |||
| e35c351c62 | |||
| 7c1a4c5e69 | |||
| c62c3051d1 | |||
| 72e685dfb9 | |||
| d56659beec | |||
| dd01794049 | |||
| 6aec5e00ba | |||
| 9fe1cae1ac | |||
| 6c92c6dac2 | |||
| 3b61c399ee | |||
| 90487bd67c | |||
| fb2ef68910 | |||
| ff406a9526 |
+2
-2
@@ -16,11 +16,11 @@ Load and Storage:
|
||||
- Improved memcached support
|
||||
|
||||
Federation:
|
||||
- Added ActivityPub support
|
||||
- Add ActivityPub support
|
||||
- RemoteFollow: Remote follow ActivityPub and OStatus remote actors via the click of a button
|
||||
- ActorLists: Allow to create collections of Actors and to interact with them - supports both OStatus and ActivityPub
|
||||
- The Free Network: Automagically migrate internal remote profiles between Free Network protocols
|
||||
- Enabled the search box to import remote notices and profiles
|
||||
- Enable the search box to import remote notices and profiles
|
||||
- Improvements on Nodeinfo (and new route)
|
||||
|
||||
General:
|
||||
|
||||
+2
-1
@@ -46,7 +46,7 @@ Additional Contributors
|
||||
* Blaine Cook
|
||||
* Henry Story
|
||||
* Melvin Carvalho
|
||||
* Stéphane Bérubé
|
||||
* chimo
|
||||
* Akio
|
||||
* Maiyannah Bishop
|
||||
* Bob Mottram
|
||||
@@ -55,6 +55,7 @@ Additional Contributors
|
||||
* Moonman
|
||||
* Normandy
|
||||
* Verius
|
||||
* Alexei Sorokin
|
||||
* Daniel Supernault
|
||||
|
||||
Credits for StatusNet
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
GNU social Coding Style
|
||||
===========================
|
||||
|
||||
Please comply with [PSR-12](https://www.php-fig.org/psr/psr-12/) and the following standard when working on GNU social
|
||||
Please comply with [PSR-2](https://www.php-fig.org/psr/psr-2/) and the following standard when working on GNU social
|
||||
if you want your patches accepted and modules included in supported releases.
|
||||
|
||||
If you see code which doesn't comply with the below, please fix it :)
|
||||
@@ -118,7 +118,7 @@ Some short hands are evil:
|
||||
|
||||
Naming conventions
|
||||
-------------------------------------------------------------------------------
|
||||
Respect PSR-12 first.
|
||||
Respect PSR2 first.
|
||||
|
||||
- Classes use PascalCase (e.g. MyClass).
|
||||
- Functions/Methods use camelCase (e.g. myFunction).
|
||||
@@ -145,29 +145,11 @@ Also, whereever possible, avoid ambiguous terms. For example, don't use text
|
||||
as a term for a variable. Call back to "contents" above.
|
||||
|
||||
|
||||
Arrays
|
||||
-------------------------------------------------------------------------------
|
||||
Even though PSR-12 doesn't specifically specify rules for array formatting, it
|
||||
is in the spirit of it to have every array element on a new line like is done
|
||||
for function and class method arguments and condition expressions, if there is
|
||||
more than one element.
|
||||
In this case, even the last element should end on a comma, to ease later
|
||||
element addition.
|
||||
|
||||
$foo = ['first' => 'unu'];
|
||||
$bar = [
|
||||
'first' => 'once',
|
||||
'second' => 'twice',
|
||||
'third' => 'thrice',
|
||||
];
|
||||
|
||||
|
||||
Comparisons
|
||||
-------------------------------------------------------------------------------
|
||||
Always use symbol based comparison operators (&&, ||) instead of text based
|
||||
operators (and, or) in an "if" clause as they are evaluated in different order
|
||||
and at different speeds.
|
||||
This is will prevent any confusion or strange results.
|
||||
operators (AND, OR) as they are evaluated in different orders and at different
|
||||
speeds. This is will prevent any confusion or strange results.
|
||||
|
||||
|
||||
Use English
|
||||
|
||||
@@ -1447,7 +1447,7 @@ CreateFileImageThumbnailSource: Hook to create image thumbnail source from a Fil
|
||||
|
||||
StartResizeImageFile: Hook to resize an image and output it to a file. No matching End event yet.
|
||||
- $imagefile: ImageFile object we're resizing.
|
||||
- $outpath: string with output filepath
|
||||
- $outpath: string with output filepath
|
||||
- $box: array with size ('width', 'height') and boundary box('x', 'y', 'w', 'h').
|
||||
|
||||
FillImageFileMetadata: Get more metadata about the ImageFile if it is perhaps not a real local file
|
||||
@@ -1496,16 +1496,3 @@ StartDocNav: Before outputting the docs Nav
|
||||
|
||||
EndDocNav: After outputting the docs Nav
|
||||
- $nav: The DoclNav widget
|
||||
|
||||
StartNoticeSearch: Before finding notices that match the given query
|
||||
- string $query: The text query
|
||||
|
||||
StartNoticeSearchShowResults: Before displaying notices matching the query
|
||||
- $out: HTMLOutputter used to output
|
||||
- $query: The text query
|
||||
- $notices: Array of DB notice objects
|
||||
|
||||
EndNoticeSearchShowResults: After displaying notices matching the query
|
||||
- $out: HTMLOutputter used to output
|
||||
- $query: The text query
|
||||
- $notices: Array of DB notice objects
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class AwesomenessPlugin extends Plugin
|
||||
'name' => 'Awesomeness',
|
||||
'version' => self::PLUGIN_VERSION,
|
||||
'author' => 'Jeroen De Dauw',
|
||||
'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/Awesomeness',
|
||||
'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/Awesomeness',
|
||||
// TRANS: Plugin description for a sample plugin.
|
||||
'rawdescription' => _m('The Awesomeness plugin adds additional awesomeness ' .
|
||||
'to a GNU social installation.')
|
||||
|
||||
+5
@@ -17,8 +17,13 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
<<<<<<< HEAD
|
||||
#. TRANS: Plugin description for a sample plugin.
|
||||
#: AwesomenessPlugin.php:55
|
||||
=======
|
||||
#. TRANS: Module description for a sample plugin.
|
||||
#: AwesomenessModule.php:67
|
||||
>>>>>>> 6b0ad03771... [PLUGINS] Removed GeoURL as the service doesn't exist anymore
|
||||
msgid ""
|
||||
"The Awesomeness plugin adds additional awesomeness to a GNU social "
|
||||
"installation."
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ class BlankAdPlugin extends UAPPlugin
|
||||
$versions[] = array('name' => 'BlankAd',
|
||||
'version' => self::PLUGIN_VERSION,
|
||||
'author' => 'Evan Prodromou',
|
||||
'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/BlankAdPlugin',
|
||||
'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/BlankAdPlugin',
|
||||
'rawdescription' =>
|
||||
// TRANS: Plugin description.
|
||||
_m('Plugin for testing ad layout.'));
|
||||
|
||||
@@ -236,7 +236,7 @@ class SamplePlugin extends Plugin
|
||||
'name' => 'Sample',
|
||||
'version' => self::PLUGIN_VERSION,
|
||||
'author' => 'Brion Vibber, Evan Prodromou',
|
||||
'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/Sample',
|
||||
'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/Sample',
|
||||
'rawdescription' =>
|
||||
// TRANS: Plugin description.
|
||||
_m('A sample plugin to show basics of development for new hackers.')
|
||||
|
||||
+8
-8
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Data class for counting greetings
|
||||
*
|
||||
* @package GNUsocial
|
||||
* @package GNU social
|
||||
* @author Brion Vibber <brionv@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
@@ -36,20 +36,20 @@ defined('GNUSOCIAL') || die();
|
||||
* and other bits of good functionality to StatusNet-specific data classes.
|
||||
*
|
||||
* @category Action
|
||||
* @package GNUsocial
|
||||
* @package GNU social
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
class User_greeting_count extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'user_greeting_count'; // table name
|
||||
public $user_id; // int(4) primary_key not_null
|
||||
public $user_id; // int(4) primary_key not_null
|
||||
public $greeting_count; // int(4)
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -57,8 +57,8 @@ class User_greeting_count extends Managed_DataObject
|
||||
'fields' => [
|
||||
'user_id' => ['type' => 'int', 'not null' => true, 'description' => 'user id'],
|
||||
'greeting_count' => ['type' => 'int', 'not null' => true, 'description' => 'the greeting count'],
|
||||
'created' => ['type' => 'datetime', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['user_id'],
|
||||
'foreign keys' => [
|
||||
|
||||
@@ -164,9 +164,10 @@ The ones that you may want to set are listed below for clarity.
|
||||
|
||||
* `database` (string, required, default null): a DSN (Data Source Name) for your
|
||||
GNU social database. This is in the format
|
||||
'protocol://username:password@hostname/databasename', where 'protocol' is
|
||||
'mysqli' or 'pgsql' or 'mysql', 'username' is the username, 'password' is
|
||||
the password, and etc.
|
||||
'protocol://username:password@hostname/databasename', where 'protocol' is '
|
||||
mysql' or 'mysqli' (or possibly 'postgresql', if you really know what
|
||||
you're doing), 'username' is the username, 'password' is the password,
|
||||
and etc.
|
||||
|
||||
* `ini_yourdbname` (string, default null): if your database is not named 'statusnet',
|
||||
you'll need to set this to point to the location of the statusnet.ini file.
|
||||
@@ -177,9 +178,12 @@ The ones that you may want to set are listed below for clarity.
|
||||
'MDB2' to use the other driver type for DB_DataObject, but note that it
|
||||
breaks the OpenID libraries, which only support PEAR::DB.
|
||||
|
||||
* `type` (enum["mysql", "pgsql"], default 'mysql'): Used for certain
|
||||
database-specific optimization code. Assumes mysql if not set. "mysql"
|
||||
covers MariaDB, Oracle MySQL, mysqli or otherwise.
|
||||
* `quote_identifiers`(boolean, default false): Set this to true if you're using
|
||||
postgresql.
|
||||
|
||||
* `type` (enum["mysql", "postgresql"], default 'mysql'): Used for certain
|
||||
database-specific optimization code. Assumes mysql if not set. MySQL also
|
||||
covers MySQLi and MariaDB.
|
||||
|
||||
* `mirror` (array, default null): you can set this to an array of DSNs, in the
|
||||
format of the above 'database' value. If it's set, certain read-only
|
||||
@@ -228,7 +232,7 @@ sending out SMS email or XMPP messages, for off-line processing. See
|
||||
|
||||
* `enabled` (boolean, default false): Whether to uses queues.
|
||||
|
||||
* `daemon` (boolean, default false): Whether to use queuedaemon. False means
|
||||
* `daemon` (boolean, default false): Wather to use queuedaemon. False means
|
||||
you'll use OpportunisticQM plugin.
|
||||
|
||||
* `subsystem` (enum["db", "stomp"], default 'db'): Which kind of queueserver to
|
||||
@@ -744,9 +748,11 @@ search
|
||||
Some stuff for search.
|
||||
|
||||
* `type`: type of search. Ignored if PostgreSQL or Sphinx are enabled. Can either
|
||||
be 'like' or 'fulltext' (default). The latter is faster and more efficient
|
||||
but if your storage engine of choice does not support it, then feel free to
|
||||
choose 'like', but it could be miserably slow on large databases.
|
||||
be 'fulltext' or 'like' (default). The former is faster and more efficient
|
||||
but requires the lame old MyISAM engine for MySQL. The latter
|
||||
will work with InnoDB but could be miserably slow on large
|
||||
systems. We'll probably add another type sometime in the future,
|
||||
with our own indexing system (maybe like MediaWiki's).
|
||||
|
||||
|
||||
sessions
|
||||
|
||||
@@ -6,15 +6,7 @@ server {
|
||||
server_name social.example.org;
|
||||
|
||||
# redirect all traffic to HTTPS
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
map $sent_http_content_type $gnusocial_expires_policy {
|
||||
default off;
|
||||
text/css 30d;
|
||||
application/javascript 30d;
|
||||
~image/ 30d;
|
||||
~video/ 30d;
|
||||
rewrite ^ https://$host$request_uri? permanent;
|
||||
}
|
||||
|
||||
server {
|
||||
@@ -39,36 +31,22 @@ server {
|
||||
# Index
|
||||
index index.php;
|
||||
|
||||
# Enable browser caching for JS, CSS, images, audio, video
|
||||
expires $gnusocial_expires_policy;
|
||||
|
||||
# X-Accel/X-Sendfile. Still needs to be enabled in the config
|
||||
location ^~ /file {
|
||||
location /file {
|
||||
internal;
|
||||
# FIXME: Change "/path/to/gnusocial/root/" to the folder where
|
||||
# attachments are stored (normally the same as the site root)
|
||||
root /path/to/gnusocial/root/;
|
||||
|
||||
# Enable compression for images, audio, video to save bandwidth
|
||||
# gzip on;
|
||||
# gzip_comp_level 4;
|
||||
}
|
||||
|
||||
# PHP
|
||||
# FIXME: Change "php7.X" to your version of fpm
|
||||
location ~ ^/(index|install)\.php(/.*)?$ {
|
||||
#location ^~ /index.php {
|
||||
include fastcgi_params;
|
||||
include snippets/fastcgi-php.conf;
|
||||
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
set $path_info $fastcgi_path_info;
|
||||
try_files $fastcgi_script_name =404;
|
||||
|
||||
fastcgi_pass unix:/run/php/php7.X-fpm.sock;
|
||||
fastcgi_index index.php;
|
||||
|
||||
fastcgi_param PATH_INFO $path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_pass unix:/run/php/php-fpm.sock;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
|
||||
# Don't allow any PHP file other than index.php to be executed
|
||||
@@ -83,11 +61,6 @@ server {
|
||||
try_files $uri $uri/ @index_handler;
|
||||
}
|
||||
|
||||
# If avatars are located at /path/to/gnusocial/root/file (default)
|
||||
location ^~ /avatar {
|
||||
rewrite ^(.*)$ /file/$1 last;
|
||||
}
|
||||
|
||||
# Fancy URLs
|
||||
error_page 404 @index_handler;
|
||||
location @index_handler {
|
||||
@@ -112,4 +85,13 @@ server {
|
||||
# client_max_body_size 15M;
|
||||
# client_body_buffer_size 128k;
|
||||
# gzip_vary on;
|
||||
#
|
||||
# location ~* \.(?:css|js|woff|svg|gif|png|webp|ttf|ico|jpe?g)$ {
|
||||
# gzip on;
|
||||
# gzip_comp_level 4;
|
||||
# add_header Cache-Control "public";
|
||||
# expires 30d;
|
||||
# access_log off;
|
||||
# log_not_found off;
|
||||
# }
|
||||
}
|
||||
|
||||
+3
-5
@@ -121,11 +121,9 @@ In the current phase of development it is probably
|
||||
recommended to use git as a means to stay up to date
|
||||
with the source code. You can choose between these
|
||||
branches:
|
||||
* 1.20.x "oldstable", few updates, well tested coded ( **recommended** )
|
||||
* master "stable", usually working well (should be safe)
|
||||
* nightly "testing", most updates, not always working as expected (can be dangerous)
|
||||
|
||||
**IMPORTANT: We force push to the nightly branch, the nightly branch is intended for GNU social developers only.**
|
||||
* 1.20.x "oldstable", few updates, well tested coded
|
||||
* master "stable", usually working well
|
||||
* nightly "testing", most updates, not always working as expected
|
||||
|
||||
To keep it up-to-date, use `git pull`. Watch for conflicts!
|
||||
|
||||
|
||||
+19
-10
@@ -1,15 +1,24 @@
|
||||
# TODO
|
||||
|
||||
Hi! Thank you for your interest in contributing, please refer to
|
||||
[DOCUMENTATION/DEVELOPERS](https://notabug.org/diogo/gnu-social/src/nightly/DOCUMENTATION/DEVELOPERS)
|
||||
to learn how you can contribute.
|
||||
Load and Storage:
|
||||
- Upgrade STOMP queue
|
||||
- Port PEAR DB_DataObject to PDO_DataObject
|
||||
|
||||
Our roadmap is available in the following Kanban board:
|
||||
[Kanban Board](https://kanban.diogo.site/?controller=BoardViewController&action=readonly&token=03795efb8138c4e7661a900c234c0df1bc3fc03cdfcda8619cd5d0e666de).
|
||||
Network:
|
||||
- Port PEAR HTTP to Guzzle
|
||||
- Port PEAR Mail to PHPSendMail
|
||||
- Add OAuth2 support (deprecate OAuth1?)
|
||||
|
||||
There are more pending tasks/ideas to implement in this
|
||||
[repo's issues](https://notabug.org/diogo/gnu-social/issues).
|
||||
General:
|
||||
- Fix failling unit tests
|
||||
- Improve Cronish
|
||||
- Run session garbage collection
|
||||
- Cleanup Email Registration
|
||||
- Refactoring of confirmation codes
|
||||
- Refactoring of Exceptions
|
||||
|
||||
So consider the issue tracker to be the full backlog, in the kanban board it's just what the
|
||||
[development team](https://notabug.org/diogo/gnu-social/src/nightly/CREDITS.md)
|
||||
is working on.
|
||||
Modules:
|
||||
- Introduce new metadata for plugins (category and thumb)
|
||||
- Add plugin management tool as a install step
|
||||
- Allow to install remote plugins and suggest popular trusted ones
|
||||
- Replace SimpleCaptcha by FacileCaptcha once the latter is ready
|
||||
|
||||
@@ -1,38 +1,42 @@
|
||||
<?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
|
||||
*
|
||||
* Site access administration panel
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Administer site access settings
|
||||
*
|
||||
* @category Admin
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Admin
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class AccessadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -41,7 +45,7 @@ class AccessadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Page title for Access admin panel that allows configuring site access.
|
||||
return _('Access');
|
||||
@@ -52,7 +56,7 @@ class AccessadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Page notice.
|
||||
return _('Site access settings');
|
||||
@@ -63,7 +67,7 @@ class AccessadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showForm()
|
||||
function showForm()
|
||||
{
|
||||
$form = new AccessAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -75,7 +79,7 @@ class AccessadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function saveSettings()
|
||||
function saveSettings()
|
||||
{
|
||||
static $booleans = array('site' => array('private', 'inviteonly', 'closed'),
|
||||
'public' => array('localonly'));
|
||||
@@ -88,7 +92,7 @@ class AccessadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('START TRANSACTION');
|
||||
$config->query('BEGIN');
|
||||
|
||||
foreach ($booleans as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -109,7 +113,7 @@ class AccessAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
public function id()
|
||||
function id()
|
||||
{
|
||||
return 'form_site_admin_panel';
|
||||
}
|
||||
@@ -119,7 +123,7 @@ class AccessAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
public function formClass()
|
||||
function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -129,7 +133,7 @@ class AccessAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
public function action()
|
||||
function action()
|
||||
{
|
||||
return common_local_url('accessadminpanel');
|
||||
}
|
||||
@@ -139,7 +143,7 @@ class AccessAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formData()
|
||||
function formData()
|
||||
{
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_admin_account_access'));
|
||||
// TRANS: Form legend for registration form.
|
||||
@@ -150,24 +154,18 @@ class AccessAdminPanelForm extends AdminForm
|
||||
// TRANS: Checkbox instructions for admin setting "Invite only".
|
||||
$instructions = _('Make registration invitation only.');
|
||||
// TRANS: Checkbox label for configuring site as invite only.
|
||||
$this->out->checkbox(
|
||||
'inviteonly',
|
||||
_('Invite only'),
|
||||
(bool) $this->value('inviteonly'),
|
||||
$instructions
|
||||
);
|
||||
$this->out->checkbox('inviteonly', _('Invite only'),
|
||||
(bool) $this->value('inviteonly'),
|
||||
$instructions);
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
// TRANS: Checkbox instructions for admin setting "Closed" (no new registrations).
|
||||
$instructions = _('Disable new registrations.');
|
||||
// TRANS: Checkbox label for disabling new user registrations.
|
||||
$this->out->checkbox(
|
||||
'closed',
|
||||
_('Closed'),
|
||||
(bool) $this->value('closed'),
|
||||
$instructions
|
||||
);
|
||||
$this->out->checkbox('closed', _('Closed'),
|
||||
(bool) $this->value('closed'),
|
||||
$instructions);
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@@ -175,32 +173,26 @@ class AccessAdminPanelForm extends AdminForm
|
||||
|
||||
|
||||
// Public access settings (login requirements for feeds etc.)
|
||||
$this->out->elementStart('fieldset', ['id' => 'settings_admin_public_access']);
|
||||
// TRANS: Form legend for registration form.
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_admin_public_access'));
|
||||
// TRANS: Form legend for registration form.
|
||||
$this->out->element('legend', null, _('Feed access'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
$this->li();
|
||||
// TRANS: Checkbox instructions for admin setting "Private".
|
||||
$instructions = _('Prohibit anonymous users (not logged in) from viewing site?');
|
||||
// TRANS: Checkbox label for prohibiting anonymous users from viewing site.
|
||||
$this->out->checkbox(
|
||||
'private',
|
||||
_m('LABEL', 'Private'),
|
||||
(bool) $this->value('private'),
|
||||
$instructions
|
||||
);
|
||||
$this->out->checkbox('private', _m('LABEL', 'Private'),
|
||||
(bool) $this->value('private'),
|
||||
$instructions);
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
// TRANS: Description of the full network notice stream views..
|
||||
$instructions = _('The full network view includes (public) remote notices which may be unrelated to local conversations.');
|
||||
// TRANS: Checkbox label for hiding remote network posts if they have not been interacted with locally.
|
||||
$this->out->checkbox(
|
||||
'localonly',
|
||||
_('Restrict full network view to accounts'),
|
||||
(bool) $this->value('localonly', 'public'),
|
||||
$instructions
|
||||
);
|
||||
$this->out->checkbox('localonly', _('Restrict full network view to accounts'),
|
||||
(bool) $this->value('localonly', 'public'),
|
||||
$instructions);
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@@ -212,7 +204,7 @@ class AccessAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formActions()
|
||||
function formActions()
|
||||
{
|
||||
// TRANS: Button title to save access settings in site admin panel.
|
||||
$title = _('Save access settings.');
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/togglepeopletag.php';
|
||||
require_once INSTALLDIR . '/lib/togglepeopletag.php';
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,45 +1,55 @@
|
||||
<?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
|
||||
*
|
||||
* Show the newest groups
|
||||
*
|
||||
* 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 API
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns of the lastest 20 groups for the site
|
||||
*
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category API
|
||||
* @package StatusNet
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||
{
|
||||
public $groups = null;
|
||||
var $groups = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
@@ -48,7 +58,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
public function prepare(array $args = [])
|
||||
function prepare(array $args = array())
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
@@ -67,7 +77,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
function handle()
|
||||
{
|
||||
parent::handle();
|
||||
|
||||
@@ -80,7 +90,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||
// TRANS: Message is used as a subtitle when listing the latest 20 groups. %s is a site name.
|
||||
$subtitle = sprintf(_("groups on %s"), $sitename);
|
||||
|
||||
switch ($this->format) {
|
||||
switch($this->format) {
|
||||
case 'xml':
|
||||
$this->showXmlGroups($this->groups);
|
||||
break;
|
||||
@@ -118,20 +128,21 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return array groups
|
||||
*/
|
||||
public function getGroups()
|
||||
function getGroups()
|
||||
{
|
||||
$group = new User_group();
|
||||
|
||||
$qry = 'SELECT user_group.* '.
|
||||
'from user_group join local_group on user_group.id = local_group.group_id '.
|
||||
'order by created desc ';
|
||||
$offset = intval($this->page - 1) * intval($this->count);
|
||||
$limit = intval($this->count);
|
||||
if (common_config('db', 'type') == 'pgsql') {
|
||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||
} else {
|
||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
||||
}
|
||||
$group = new User_group();
|
||||
|
||||
$group->query(
|
||||
'SELECT user_group.* '.
|
||||
'FROM user_group INNER JOIN local_group ' .
|
||||
'ON user_group.id = local_group.group_id '.
|
||||
'ORDER BY created DESC ' .
|
||||
'LIMIT ' . $limit . ' OFFSET ' . $offset
|
||||
);
|
||||
$group->query($qry);
|
||||
|
||||
$groups = array();
|
||||
while ($group->fetch()) {
|
||||
@@ -148,7 +159,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
public function isReadOnly($args)
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -158,7 +169,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return string datestamp of the site's latest group
|
||||
*/
|
||||
public function lastModified()
|
||||
function lastModified()
|
||||
{
|
||||
if (!empty($this->groups) && (count($this->groups) > 0)) {
|
||||
return strtotime($this->groups[0]->created);
|
||||
@@ -175,9 +186,10 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return string etag
|
||||
*/
|
||||
public function etag()
|
||||
function etag()
|
||||
{
|
||||
if (!empty($this->groups) && (count($this->groups) > 0)) {
|
||||
|
||||
$last = count($this->groups) - 1;
|
||||
|
||||
return '"' . implode(
|
||||
|
||||
@@ -1,38 +1,44 @@
|
||||
<?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
|
||||
*
|
||||
* Update a group's profile
|
||||
*
|
||||
* 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 API
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* API analog to the group edit page
|
||||
*
|
||||
* @category API
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category API
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
{
|
||||
@@ -94,21 +100,20 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
$this->clientError(_('You must be an admin to edit the group.'), 403);
|
||||
}
|
||||
|
||||
$this->group->query('START TRANSACTION');
|
||||
$this->group->query('BEGIN');
|
||||
|
||||
$orig = clone($this->group);
|
||||
|
||||
try {
|
||||
|
||||
if (common_config('profile', 'changenick') == true && $this->group->nickname !== $this->nickname) {
|
||||
try {
|
||||
$this->group->nickname = Nickname::normalize($this->nickname, true);
|
||||
} catch (NicknameException $e) {
|
||||
throw new ApiValidationException($e->getMessage());
|
||||
}
|
||||
$this->group->mainpage = common_local_url(
|
||||
'showgroup',
|
||||
['nickname' => $this->group->nickname]
|
||||
);
|
||||
$this->group->mainpage = common_local_url('showgroup',
|
||||
array('nickname' => $this->group->nickname));
|
||||
}
|
||||
|
||||
if (!empty($this->fullname)) {
|
||||
@@ -130,6 +135,7 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
$this->validateLocation();
|
||||
$this->group->location = $this->location;
|
||||
}
|
||||
|
||||
} catch (ApiValidationException $ave) {
|
||||
$this->clientError($ave->getMessage(), 400);
|
||||
}
|
||||
@@ -161,7 +167,7 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
|
||||
$this->group->query('COMMIT');
|
||||
|
||||
switch ($this->format) {
|
||||
switch($this->format) {
|
||||
case 'xml':
|
||||
$this->showSingleXmlGroup($this->group);
|
||||
break;
|
||||
@@ -174,7 +180,7 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
}
|
||||
}
|
||||
|
||||
public function validateHomepage()
|
||||
function validateHomepage()
|
||||
{
|
||||
if (!is_null($this->homepage)
|
||||
&& (strlen($this->homepage) > 0)
|
||||
@@ -186,7 +192,7 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
}
|
||||
}
|
||||
|
||||
public function validateFullname()
|
||||
function validateFullname()
|
||||
{
|
||||
if (!is_null($this->fullname) && mb_strlen($this->fullname) > 255) {
|
||||
throw new ApiValidationException(
|
||||
@@ -196,21 +202,19 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
}
|
||||
}
|
||||
|
||||
public function validateDescription()
|
||||
function validateDescription()
|
||||
{
|
||||
if (User_group::descriptionTooLong($this->description)) {
|
||||
// TRANS: API validation exception thrown when description does not validate.
|
||||
// TRANS: %d is the maximum description length and used for plural.
|
||||
throw new ApiValidationException(sprintf(
|
||||
_m('Description is too long (maximum %d character).',
|
||||
'Description is too long (maximum %d characters).',
|
||||
User_group::maxDescription()),
|
||||
User_group::maxDescription()
|
||||
));
|
||||
throw new ApiValidationException(sprintf(_m('Description is too long (maximum %d character).',
|
||||
'Description is too long (maximum %d characters).',
|
||||
User_group::maxDescription()),
|
||||
User_group::maxDescription()));
|
||||
}
|
||||
}
|
||||
|
||||
public function validateLocation()
|
||||
function validateLocation()
|
||||
{
|
||||
if (!is_null($this->location) && mb_strlen($this->location) > 255) {
|
||||
throw new ApiValidationException(
|
||||
@@ -220,13 +224,11 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
}
|
||||
}
|
||||
|
||||
public function validateAliases()
|
||||
function validateAliases()
|
||||
{
|
||||
try {
|
||||
$aliases = array_map(
|
||||
['Nickname', 'normalize'],
|
||||
array_unique(preg_split('/[\s,]+/', $this->aliasstring))
|
||||
);
|
||||
$aliases = array_map(array('Nickname', 'normalize'),
|
||||
array_unique(preg_split('/[\s,]+/', $this->aliasstring)));
|
||||
} catch (NicknameException $e) {
|
||||
throw new ApiValidationException(sprintf('Error processing aliases: %s', $e->getMessage()));
|
||||
}
|
||||
@@ -234,12 +236,10 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
if (count($aliases) > common_config('group', 'maxaliases')) {
|
||||
// TRANS: API validation exception thrown when aliases do not validate.
|
||||
// TRANS: %d is the maximum number of aliases and used for plural.
|
||||
throw new ApiValidationException(sprintf(
|
||||
_m('Too many aliases! Maximum %d allowed.',
|
||||
'Too many aliases! Maximum %d allowed.',
|
||||
common_config('group', 'maxaliases')),
|
||||
common_config('group', 'maxaliases')
|
||||
));
|
||||
throw new ApiValidationException(sprintf(_m('Too many aliases! Maximum %d allowed.',
|
||||
'Too many aliases! Maximum %d allowed.',
|
||||
common_config('group', 'maxaliases')),
|
||||
common_config('group', 'maxaliases')));
|
||||
}
|
||||
|
||||
return $aliases;
|
||||
|
||||
@@ -30,7 +30,7 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/api/apilistusers.php';
|
||||
require_once INSTALLDIR . '/lib/apilistusers.php';
|
||||
|
||||
class ApiListMembersAction extends ApiListUsersAction
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/api/apilistusers.php';
|
||||
require_once INSTALLDIR . '/lib/apilistusers.php';
|
||||
|
||||
class ApiListSubscribersAction extends ApiListUsersAction
|
||||
{
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
<?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
|
||||
*
|
||||
* Show a notice (as a Twitter-style status)
|
||||
*
|
||||
* 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 API
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
@@ -28,29 +30,31 @@
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Returns the notice specified by id as a Twitter-style status and inline user
|
||||
*
|
||||
* @category API
|
||||
* @package GNUsocial
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
* @author Tom Blankenship <mac65@mac65.com>
|
||||
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
||||
* @author Robin Millette <robin@millette.info>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category API
|
||||
* @package StatusNet
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
* @author Tom Blankenship <mac65@mac65.com>
|
||||
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
||||
* @author Robin Millette <robin@millette.info>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
{
|
||||
public $notice_id = null;
|
||||
public $notice = null;
|
||||
var $notice_id = null;
|
||||
var $notice = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
@@ -127,7 +131,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showNotice()
|
||||
function showNotice()
|
||||
{
|
||||
switch ($this->format) {
|
||||
case 'xml':
|
||||
@@ -154,9 +158,9 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
public function isReadOnly($args)
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return in_array($_SERVER['REQUEST_METHOD'], ['GET', 'HEAD']);
|
||||
return ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +168,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return string datestamp of the latest notice in the stream
|
||||
*/
|
||||
public function lastModified()
|
||||
function lastModified()
|
||||
{
|
||||
return strtotime($this->notice->created);
|
||||
}
|
||||
@@ -177,7 +181,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return string etag
|
||||
*/
|
||||
public function etag()
|
||||
function etag()
|
||||
{
|
||||
return '"' . implode(
|
||||
':',
|
||||
@@ -190,7 +194,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
. '"';
|
||||
}
|
||||
|
||||
public function deleteNotice()
|
||||
function deleteNotice()
|
||||
{
|
||||
if ($this->format != 'atom') {
|
||||
// TRANS: Client error displayed when trying to delete a notice not using the Atom format.
|
||||
@@ -211,7 +215,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
|
||||
// @fixme is there better output we could do here?
|
||||
|
||||
http_response_code(200);
|
||||
header('HTTP/1.1 200 OK');
|
||||
header('Content-Type: text/plain');
|
||||
// TRANS: Confirmation of notice deletion in API. %d is the ID (number) of the deleted notice.
|
||||
print(sprintf(_('Deleted notice %d'), $this->notice->id));
|
||||
|
||||
@@ -35,7 +35,7 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/feeds/atomlistnoticefeed.php';
|
||||
require_once INSTALLDIR . '/lib/atomlistnoticefeed.php';
|
||||
|
||||
/**
|
||||
* Returns the most recent notices (default 20) posted to the list specified by ID
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
<?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
|
||||
*
|
||||
* Show a user's timeline
|
||||
*
|
||||
* 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 API
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
@@ -28,26 +30,30 @@
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the most recent notices (default 20) posted by the authenticating
|
||||
* user. Another user's timeline can be requested via the id parameter. This
|
||||
* is the API equivalent of the user profile web page.
|
||||
*
|
||||
* @category API
|
||||
* @package GNUsocial
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
* @author mac65 <mac65@mac65.com>
|
||||
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
||||
* @author Robin Millette <robin@millette.info>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category API
|
||||
* @package StatusNet
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
* @author mac65 <mac65@mac65.com>
|
||||
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
||||
* @author Robin Millette <robin@millette.info>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
{
|
||||
@@ -95,14 +101,16 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
if (!empty($this->notices) && (count($this->notices) > 0)) {
|
||||
$last = count($this->notices) - 1;
|
||||
|
||||
return '"' . implode(':', [
|
||||
$this->arg('action'),
|
||||
common_user_cache_hash($this->scoped),
|
||||
common_language(),
|
||||
$this->target->getID(),
|
||||
strtotime($this->notices[0]->created),
|
||||
strtotime($this->notices[$last]->created),
|
||||
]) . '"';
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->scoped),
|
||||
common_language(),
|
||||
$this->target->getID(),
|
||||
strtotime($this->notices[0]->created),
|
||||
strtotime($this->notices[$last]->created))
|
||||
)
|
||||
. '"';
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -242,7 +250,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
}
|
||||
Event::handle('EndAtomPubNewActivity', array($activity, $this->target, $stored));
|
||||
|
||||
http_response_code(201);
|
||||
header('HTTP/1.1 201 Created');
|
||||
header("Location: " . common_local_url('ApiStatusesShow', array('id' => $stored->getID(),
|
||||
'format' => 'atom')));
|
||||
$this->showSingleAtomStatus($stored);
|
||||
|
||||
+88
-58
@@ -1,20 +1,33 @@
|
||||
<?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
|
||||
*
|
||||
* Show notice attachments
|
||||
*
|
||||
* 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 Personal
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Show notice attachments
|
||||
@@ -30,13 +43,7 @@ class AttachmentAction extends ManagedAction
|
||||
/**
|
||||
* Attachment File object to show
|
||||
*/
|
||||
public $attachment = null;
|
||||
|
||||
public $filehash = null;
|
||||
public $filepath = null;
|
||||
public $filesize = null;
|
||||
public $mimetype = null;
|
||||
public $filename = null;
|
||||
var $attachment = null;
|
||||
|
||||
/**
|
||||
* Load attributes based on database arguments
|
||||
@@ -45,48 +52,41 @@ class AttachmentAction extends ManagedAction
|
||||
*
|
||||
* @param array $args $_REQUEST array
|
||||
*
|
||||
* @return bool flag
|
||||
* @throws ClientException
|
||||
* @throws FileNotFoundException
|
||||
* @throws FileNotStoredLocallyException
|
||||
* @throws InvalidFilenameException
|
||||
* @throws ServerException
|
||||
* @return success flag
|
||||
*/
|
||||
protected function prepare(array $args = [])
|
||||
|
||||
protected function prepare(array $args=array())
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
try {
|
||||
if (!empty($id = $this->trimmed('attachment'))) {
|
||||
$this->attachment = File::getByID($id);
|
||||
} elseif (!empty($this->filehash = $this->trimmed('filehash'))) {
|
||||
$this->attachment = File::getByHash($this->filehash);
|
||||
} elseif (!empty($filehash = $this->trimmed('filehash'))) {
|
||||
$this->attachment = File::getByHash($filehash);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// Not found
|
||||
}
|
||||
if (!$this->attachment instanceof File) {
|
||||
// TRANS: Client error displayed trying to get a non-existing attachment.
|
||||
$this->clientError(_m('No such attachment.'), 404);
|
||||
$this->clientError(_('No such attachment.'), 404);
|
||||
}
|
||||
|
||||
$this->filepath = $this->attachment->getFileOrThumbnailPath();
|
||||
if (empty($this->filepath)) {
|
||||
$this->clientError(_m('Requested local URL for a file that is not stored locally.'), 404);
|
||||
}
|
||||
$this->filesize = $this->attachment->getFileOrThumbnailSize();
|
||||
$this->mimetype = $this->attachment->getFileOrThumbnailMimetype();
|
||||
$this->filename = MediaFile::getDisplayName($this->attachment);
|
||||
$filename = $this->attachment->getFileOrThumbnailPath();
|
||||
|
||||
if (empty($filename)) {
|
||||
$this->clientError(_('Requested local URL for a file that is not stored locally.'), 404);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this action read-only?
|
||||
*
|
||||
* @return bool true
|
||||
* @return boolean true
|
||||
*/
|
||||
public function isReadOnly($args): bool
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -96,15 +96,15 @@ class AttachmentAction extends ManagedAction
|
||||
*
|
||||
* @return string title of the page
|
||||
*/
|
||||
public function title(): string
|
||||
function title()
|
||||
{
|
||||
$a = new Attachment($this->attachment);
|
||||
return $a->title();
|
||||
}
|
||||
|
||||
public function showPage(): void
|
||||
public function showPage()
|
||||
{
|
||||
if (empty($this->filepath)) {
|
||||
if (empty($this->attachment->getFileOrThumbnailPath())) {
|
||||
// if it's not a local file, gtfo
|
||||
common_redirect($this->attachment->getUrl(), 303);
|
||||
}
|
||||
@@ -119,10 +119,10 @@ class AttachmentAction extends ManagedAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showContent(): void
|
||||
function showContent()
|
||||
{
|
||||
$ali = new Attachment($this->attachment, $this);
|
||||
$ali->show();
|
||||
$cnt = $ali->show();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ class AttachmentAction extends ManagedAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showPageNoticeBlock(): void
|
||||
function showPageNoticeBlock()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -139,8 +139,7 @@ class AttachmentAction extends ManagedAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showSections(): void
|
||||
{
|
||||
function showSections() {
|
||||
$ns = new AttachmentNoticeSection($this);
|
||||
$ns->show();
|
||||
}
|
||||
@@ -149,14 +148,13 @@ class AttachmentAction extends ManagedAction
|
||||
* Last-modified date for file
|
||||
*
|
||||
* @return int last-modified date as unix timestamp
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function lastModified(): ?int
|
||||
public function lastModified()
|
||||
{
|
||||
if (common_config('site', 'use_x_sendfile')) {
|
||||
return null;
|
||||
}
|
||||
$path = $this->filepath;
|
||||
$path = $this->attachment->getFileOrThumbnailPath();
|
||||
if (!empty($path)) {
|
||||
return filemtime($path);
|
||||
} else {
|
||||
@@ -171,26 +169,26 @@ class AttachmentAction extends ManagedAction
|
||||
* but in decimal instead of hex.
|
||||
*
|
||||
* @return string etag http header
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function etag(): ?string
|
||||
function etag()
|
||||
{
|
||||
if (common_config('site', 'use_x_sendfile')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$path = $this->filepath;
|
||||
$path = $this->attachment->getFileOrThumbnailPath();
|
||||
|
||||
$cache = Cache::instance();
|
||||
if ($cache) {
|
||||
if($cache) {
|
||||
if (empty($path)) {
|
||||
return null;
|
||||
}
|
||||
$key = Cache::key('attachments:etag:' . $path);
|
||||
$etag = $cache->get($key);
|
||||
if ($etag === false) {
|
||||
if($etag === false) {
|
||||
$etag = crc32(file_get_contents($path));
|
||||
$cache->set($key, $etag);
|
||||
$cache->set($key,$etag);
|
||||
}
|
||||
return $etag;
|
||||
}
|
||||
@@ -202,4 +200,36 @@ class AttachmentAction extends ManagedAction
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Include $filepath in the response, for viewing and downloading.
|
||||
* If provided, $filesize is used to size the HTTP request,
|
||||
* otherwise it's value is calculated
|
||||
* @param string $filepath the absolute path to the file to send
|
||||
* @param $filesize optional, calculated if unkown
|
||||
*/
|
||||
static function sendFile(string $filepath, $filesize) {
|
||||
if (is_string(common_config('site', 'x-static-delivery'))) {
|
||||
$tmp = explode(INSTALLDIR, $filepath);
|
||||
$relative_path = end($tmp);
|
||||
common_debug("Using Static Delivery with header: '" .
|
||||
common_config('site', 'x-static-delivery') . ": {$relative_path}'");
|
||||
header(common_config('site', 'x-static-delivery') . ": {$relative_path}");
|
||||
} else {
|
||||
if (empty($filesize)) {
|
||||
$filesize = filesize($filepath);
|
||||
}
|
||||
header("Content-Length: {$filesize}");
|
||||
// header('Cache-Control: private, no-transform, no-store, must-revalidate');
|
||||
|
||||
$ret = @readfile($filepath);
|
||||
|
||||
if ($ret === false) {
|
||||
common_log(LOG_ERR, "Couldn't read file at {$filepath}.");
|
||||
} elseif ($ret !== $filesize) {
|
||||
common_log(LOG_ERR, "The lengths of the file as recorded on the DB (or on disk) for the file " .
|
||||
"{$filepath} differ from what was sent to the user ({$filesize} vs {$ret}).");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,30 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
*/
|
||||
class Attachment_downloadAction extends AttachmentAction
|
||||
{
|
||||
public function showPage(): void
|
||||
public function showPage()
|
||||
{
|
||||
// Checks file exists or throws FileNotFoundException
|
||||
$filepath = $this->attachment->getFileOrThumbnailPath();
|
||||
$filesize = $this->attachment->getFileOrThumbnailSize();
|
||||
$mimetype = $this->attachment->getFileOrThumbnailMimetype();
|
||||
|
||||
if (empty($filepath)) {
|
||||
$this->clientError(_('No such attachment'), 404);
|
||||
}
|
||||
|
||||
$filename = MediaFile::getDisplayName($this->attachment);
|
||||
|
||||
// Disable errors, to not mess with the file contents (suppress errors in case access to this
|
||||
// function is blocked, like in some shared hosts). Automatically reset at the end of the
|
||||
// script execution, and we don't want to have any more errors until then, so don't reset it
|
||||
@ini_set('display_errors', 0);
|
||||
|
||||
common_send_file($this->filepath, $this->mimetype, $this->filename, 'attachment');
|
||||
header("Content-Description: File Transfer");
|
||||
header("Content-Type: {$mimetype}");
|
||||
header("Content-Disposition: attachment; filename=\"{$filename}\"");
|
||||
header('Expires: 0');
|
||||
header('Content-Transfer-Encoding: binary'); // FIXME? Can this be different?
|
||||
|
||||
AttachmentAction::sendFile($filepath, $filesize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,33 @@
|
||||
<?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
|
||||
*
|
||||
* Show notice attachments
|
||||
*
|
||||
* 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 Personal
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Show notice attachments
|
||||
@@ -45,12 +58,10 @@ class Attachment_thumbnailAction extends AttachmentAction
|
||||
* requested in the GET variables (read in the constructor). Tries
|
||||
* to send the most appropriate file with the correct size and
|
||||
* headers or displays an error if it's not possible.
|
||||
* @throws ClientException
|
||||
* @throws ReflectionException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function showPage(): void
|
||||
public function showPage()
|
||||
{
|
||||
|
||||
// Returns a File_thumbnail object or throws exception if not available
|
||||
try {
|
||||
$thumbnail = $this->attachment->getThumbnail($this->thumb_w, $this->thumb_h, $this->thumb_c);
|
||||
@@ -58,15 +69,27 @@ class Attachment_thumbnailAction extends AttachmentAction
|
||||
} catch (UseFileAsThumbnailException $e) {
|
||||
// With this exception, the file exists locally
|
||||
$file = $e->file;
|
||||
} catch (FileNotFoundException $e) {
|
||||
$this->clientError(_m('No such attachment'), 404);
|
||||
} catch(FileNotFoundException $e) {
|
||||
$this->clientError(_('No such attachment'), 404);
|
||||
}
|
||||
|
||||
// Checks file exists or throws FileNotFoundException
|
||||
$filepath = $file->getFileOrThumbnailPath($thumbnail);
|
||||
$filesize = $this->attachment->getFileOrThumbnailSize($thumbnail);
|
||||
$mimetype = $file->getFileOrThumbnailMimetype($thumbnail);
|
||||
$filename = MediaFile::getDisplayName($file);
|
||||
|
||||
// Disable errors, to not mess with the file contents (suppress errors in case access to this
|
||||
// function is blocked, like in some shared hosts). Automatically reset at the end of the
|
||||
// script execution, and we don't want to have any more errors until then, so don't reset it
|
||||
@ini_set('display_errors', 0);
|
||||
|
||||
common_send_file($this->filepath, $this->mimetype, $this->filename, 'inline');
|
||||
header("Content-Description: File Transfer");
|
||||
header("Content-Type: {$mimetype}");
|
||||
header("Content-Disposition: inline; filename=\"{$filename}\"");
|
||||
header('Expires: 0');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
AttachmentAction::sendFile($filepath, $filesize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
<?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();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* View notice attachment
|
||||
@@ -25,14 +11,34 @@ defined('GNUSOCIAL') || die();
|
||||
*/
|
||||
class Attachment_viewAction extends AttachmentAction
|
||||
{
|
||||
public function showPage(): void
|
||||
public function showPage()
|
||||
{
|
||||
// Checks file exists or throws FileNotFoundException
|
||||
$filepath = $this->attachment->getFileOrThumbnailPath();
|
||||
$filesize = $this->attachment->getFileOrThumbnailSize();
|
||||
$mimetype = $this->attachment->getFileOrThumbnailMimetype();
|
||||
|
||||
if (empty($filepath)) {
|
||||
$this->clientError(_('No such attachment'), 404);
|
||||
}
|
||||
|
||||
$filename = MediaFile::getDisplayName($this->attachment);
|
||||
|
||||
// Disable errors, to not mess with the file contents (suppress errors in case access to this
|
||||
// function is blocked, like in some shared hosts). Automatically reset at the end of the
|
||||
// script execution, and we don't want to have any more errors until then, so don't reset it
|
||||
@ini_set('display_errors', 0);
|
||||
|
||||
$disposition = in_array(common_get_mime_media($this->mimetype), ['image', 'video']) ? 'inline' : 'attachment';
|
||||
common_send_file($this->filepath, $this->mimetype, $this->filename, $disposition);
|
||||
header("Content-Description: File Transfer");
|
||||
header("Content-Type: {$mimetype}");
|
||||
if (in_array(common_get_mime_media($mimetype), ['image', 'video'])) {
|
||||
header("Content-Disposition: inline; filename=\"{$filename}\"");
|
||||
} else {
|
||||
header("Content-Disposition: attachment; filename=\"{$filename}\"");
|
||||
}
|
||||
header('Expires: 0');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
AttachmentAction::sendFile($filepath, $filesize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Retrieve user avatar by filename action class.
|
||||
*
|
||||
* @category Action
|
||||
* @package GNUsocial
|
||||
*
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
*/
|
||||
defined('GNUSOCIAL') || die;
|
||||
|
||||
/**
|
||||
* Retrieve user avatar by filename action class.
|
||||
*
|
||||
* @category Action
|
||||
* @package GNUsocial
|
||||
*
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @author Hugo Sales <hugo@fc.up.pt>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
*
|
||||
* @see http://www.gnu.org/software/social/
|
||||
*/
|
||||
class AvatarAction extends Action
|
||||
{
|
||||
public $filename = null;
|
||||
public $filepath = null;
|
||||
public $mimetype = null;
|
||||
|
||||
protected function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
$this->filename = File::tryFilename($this->trimmed('file'));
|
||||
$this->filepath = File::path($this->filename, common_config('avatar', 'dir'), false);
|
||||
if (!file_exists($this->filepath)) {
|
||||
// TRANS: Client error displayed trying to get a non-existing avatar.
|
||||
$this->clientError(_m('No such avatar.'), 404);
|
||||
}
|
||||
$this->mimetype = (new ImageFile(-1, $this->filepath))->mimetype;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function handle()
|
||||
{
|
||||
parent::handle();
|
||||
|
||||
common_send_file($this->filepath, $this->mimetype, $this->filename, 'inline');
|
||||
}
|
||||
}
|
||||
+145
-190
@@ -1,32 +1,34 @@
|
||||
<?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
|
||||
*
|
||||
* Upload an avatar
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
* @copyright 2008-2009, 2020 Free Software Foundation http://fsf.org
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
defined('GNUSOCIAL') || die;
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Upload an avatar
|
||||
@@ -35,26 +37,24 @@ defined('GNUSOCIAL') || die;
|
||||
*
|
||||
* @category Settings
|
||||
* @package StatusNet
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @see http://status.net/
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class AvatarsettingsAction extends SettingsAction
|
||||
{
|
||||
public $mode;
|
||||
public $imagefile;
|
||||
public $filename;
|
||||
var $mode = null;
|
||||
var $imagefile = null;
|
||||
var $filename = null;
|
||||
|
||||
public function prepare(array $args = [])
|
||||
function prepare(array $args=array())
|
||||
{
|
||||
$avatarpath = Avatar::path('');
|
||||
|
||||
if (!is_writable($avatarpath)) {
|
||||
throw new Exception(_m("The administrator of your site needs to
|
||||
throw new Exception(_("The administrator of your site needs to
|
||||
add write permissions on the avatar upload folder before
|
||||
you're able to set one."));
|
||||
}
|
||||
@@ -67,30 +67,24 @@ class AvatarsettingsAction extends SettingsAction
|
||||
* Title of the page
|
||||
*
|
||||
* @return string Title of the page
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for avatar upload page.
|
||||
return _m('Avatar');
|
||||
return _('Avatar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructions for use
|
||||
*
|
||||
* @return string instructions for use
|
||||
* @throws Exception
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instruction for avatar upload page.
|
||||
// TRANS: %s is the maximum file size, for example "500b", "10kB" or "2MB".
|
||||
return sprintf(
|
||||
_m('You can upload your personal avatar. The maximum file size is %s.'),
|
||||
ImageFile::maxFileSize()
|
||||
);
|
||||
return sprintf(_('You can upload your personal avatar. The maximum file size is %s.'),
|
||||
ImageFile::maxFileSize());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +95,7 @@ class AvatarsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
if ($this->mode == 'crop') {
|
||||
$this->showCropForm();
|
||||
@@ -110,37 +104,33 @@ class AvatarsettingsAction extends SettingsAction
|
||||
}
|
||||
}
|
||||
|
||||
public function showUploadForm()
|
||||
function showUploadForm()
|
||||
{
|
||||
// If we detect that the user didn't finish setting a new avatar, remove the temporary file.
|
||||
if (isset($_SESSION['FILEDATA'])) {
|
||||
@unlink($_SESSION['FILEDATA']['filepath']);
|
||||
unset($_SESSION['FILEDATA']);
|
||||
}
|
||||
$this->elementStart('form', ['enctype' => 'multipart/form-data',
|
||||
'method' => 'post',
|
||||
'id' => 'form_settings_avatar',
|
||||
'class' => 'form_settings',
|
||||
'action' => common_local_url('avatarsettings'),]);
|
||||
$this->elementStart('form', array('enctype' => 'multipart/form-data',
|
||||
'method' => 'post',
|
||||
'id' => 'form_settings_avatar',
|
||||
'class' => 'form_settings',
|
||||
'action' =>
|
||||
common_local_url('avatarsettings')));
|
||||
$this->elementStart('fieldset');
|
||||
// TRANS: Avatar upload page form legend.
|
||||
$this->element('legend', null, _m('Avatar settings'));
|
||||
$this->element('legend', null, _('Avatar settings'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
if (Event::handle('StartAvatarFormData', [$this])) {
|
||||
if (Event::handle('StartAvatarFormData', array($this))) {
|
||||
$this->elementStart('ul', 'form_data');
|
||||
try {
|
||||
$original = Avatar::getUploaded($this->scoped);
|
||||
|
||||
$this->elementStart('li', ['id' => 'avatar_original',
|
||||
'class' => 'avatar_view',]);
|
||||
$this->elementStart('li', array('id' => 'avatar_original',
|
||||
'class' => 'avatar_view'));
|
||||
// TRANS: Header on avatar upload page for thumbnail of originally uploaded avatar (h2).
|
||||
$this->element('h2', null, _m('Original'));
|
||||
$this->elementStart('div', ['id' => 'avatar_original_view']);
|
||||
$this->element('img', ['src' => $original->displayUrl(),
|
||||
'width' => $original->width,
|
||||
'height' => $original->height,
|
||||
'alt' => $this->scoped->getNickname(),]);
|
||||
$this->element('h2', null, _("Original"));
|
||||
$this->elementStart('div', array('id'=>'avatar_original_view'));
|
||||
$this->element('img', array('src' => $original->displayUrl(),
|
||||
'width' => $original->width,
|
||||
'height' => $original->height,
|
||||
'alt' => $this->scoped->getNickname()));
|
||||
$this->elementEnd('div');
|
||||
$this->elementEnd('li');
|
||||
} catch (NoAvatarException $e) {
|
||||
@@ -149,100 +139,97 @@ class AvatarsettingsAction extends SettingsAction
|
||||
|
||||
try {
|
||||
$avatar = $this->scoped->getAvatar(AVATAR_PROFILE_SIZE);
|
||||
$this->elementStart('li', ['id' => 'avatar_preview',
|
||||
'class' => 'avatar_view',]);
|
||||
$this->elementStart('li', array('id' => 'avatar_preview',
|
||||
'class' => 'avatar_view'));
|
||||
// TRANS: Header on avatar upload page for thumbnail of to be used rendition of uploaded avatar (h2).
|
||||
$this->element('h2', null, _m('Preview'));
|
||||
$this->elementStart('div', ['id' => 'avatar_preview_view']);
|
||||
$this->element('img', ['src' => $avatar->displayUrl(),
|
||||
'width' => AVATAR_PROFILE_SIZE,
|
||||
'height' => AVATAR_PROFILE_SIZE,
|
||||
'alt' => $this->scoped->getNickname(),]);
|
||||
$this->element('h2', null, _("Preview"));
|
||||
$this->elementStart('div', array('id'=>'avatar_preview_view'));
|
||||
$this->element('img', array('src' => $avatar->displayUrl(),
|
||||
'width' => AVATAR_PROFILE_SIZE,
|
||||
'height' => AVATAR_PROFILE_SIZE,
|
||||
'alt' => $this->scoped->getNickname()));
|
||||
$this->elementEnd('div');
|
||||
if (!empty($avatar->filename)) {
|
||||
// TRANS: Button on avatar upload page to delete current avatar.
|
||||
$this->submit('delete', _m('BUTTON', 'Delete'));
|
||||
$this->submit('delete', _m('BUTTON','Delete'));
|
||||
}
|
||||
$this->elementEnd('li');
|
||||
} catch (NoAvatarException $e) {
|
||||
// No previously uploaded avatar to preview.
|
||||
}
|
||||
|
||||
$this->elementStart('li', ['id' => 'settings_attach']);
|
||||
$this->element('input', ['name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt(),]);
|
||||
$this->element('input', ['name' => 'avatarfile',
|
||||
'type' => 'file',
|
||||
'id' => 'avatarfile',]);
|
||||
$this->elementStart('li', array ('id' => 'settings_attach'));
|
||||
$this->element('input', array('name' => 'MAX_FILE_SIZE',
|
||||
'type' => 'hidden',
|
||||
'id' => 'MAX_FILE_SIZE',
|
||||
'value' => ImageFile::maxFileSizeInt()));
|
||||
$this->element('input', array('name' => 'avatarfile',
|
||||
'type' => 'file',
|
||||
'id' => 'avatarfile'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
|
||||
$this->elementStart('ul', 'form_actions');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Button on avatar upload page to upload an avatar.
|
||||
$this->submit('upload', _m('BUTTON', 'Upload'));
|
||||
// TRANS: Button on avatar upload page to upload an avatar.
|
||||
$this->submit('upload', _m('BUTTON','Upload'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
}
|
||||
Event::handle('EndAvatarFormData', [$this]);
|
||||
Event::handle('EndAvatarFormData', array($this));
|
||||
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
|
||||
public function showCropForm()
|
||||
function showCropForm()
|
||||
{
|
||||
$this->elementStart('form', ['method' => 'post',
|
||||
'id' => 'form_settings_avatar',
|
||||
'class' => 'form_settings',
|
||||
'action' => common_local_url('avatarsettings'),]);
|
||||
$this->elementStart('form', array('method' => 'post',
|
||||
'id' => 'form_settings_avatar',
|
||||
'class' => 'form_settings',
|
||||
'action' =>
|
||||
common_local_url('avatarsettings')));
|
||||
$this->elementStart('fieldset');
|
||||
// TRANS: Avatar upload page crop form legend.
|
||||
$this->element('legend', null, _m('Avatar settings'));
|
||||
$this->element('legend', null, _('Avatar settings'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
$this->elementStart('ul', 'form_data');
|
||||
|
||||
$this->elementStart(
|
||||
'li',
|
||||
['id' => 'avatar_original',
|
||||
'class' => 'avatar_view',]
|
||||
);
|
||||
$this->elementStart('li',
|
||||
array('id' => 'avatar_original',
|
||||
'class' => 'avatar_view'));
|
||||
// TRANS: Header on avatar upload crop form for thumbnail of originally uploaded avatar (h2).
|
||||
$this->element('h2', null, _m('Original'));
|
||||
$this->elementStart('div', ['id' => 'avatar_original_view']);
|
||||
$this->element('img', ['src' => Avatar::url($this->filedata['filename']),
|
||||
'width' => $this->filedata['width'],
|
||||
'height' => $this->filedata['height'],
|
||||
'alt' => $this->scoped->getNickname(),]);
|
||||
$this->element('h2', null, _('Original'));
|
||||
$this->elementStart('div', array('id'=>'avatar_original_view'));
|
||||
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
|
||||
'width' => $this->filedata['width'],
|
||||
'height' => $this->filedata['height'],
|
||||
'alt' => $this->scoped->getNickname()));
|
||||
$this->elementEnd('div');
|
||||
$this->elementEnd('li');
|
||||
|
||||
$this->elementStart(
|
||||
'li',
|
||||
['id' => 'avatar_preview',
|
||||
'class' => 'avatar_view',]
|
||||
);
|
||||
$this->elementStart('li',
|
||||
array('id' => 'avatar_preview',
|
||||
'class' => 'avatar_view'));
|
||||
// TRANS: Header on avatar upload crop form for thumbnail of to be used rendition of uploaded avatar (h2).
|
||||
$this->element('h2', null, _m('Preview'));
|
||||
$this->elementStart('div', ['id' => 'avatar_preview_view']);
|
||||
$this->element('img', ['src' => Avatar::url($this->filedata['filename']),
|
||||
'width' => AVATAR_PROFILE_SIZE,
|
||||
'height' => AVATAR_PROFILE_SIZE,
|
||||
'alt' => $this->scoped->getNickname(),]);
|
||||
$this->element('h2', null, _('Preview'));
|
||||
$this->elementStart('div', array('id'=>'avatar_preview_view'));
|
||||
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
|
||||
'width' => AVATAR_PROFILE_SIZE,
|
||||
'height' => AVATAR_PROFILE_SIZE,
|
||||
'alt' => $this->scoped->getNickname()));
|
||||
$this->elementEnd('div');
|
||||
|
||||
foreach (['avatar_crop_x', 'avatar_crop_y',
|
||||
'avatar_crop_w', 'avatar_crop_h',] as $crop_info) {
|
||||
$this->element('input', ['name' => $crop_info,
|
||||
'type' => 'hidden',
|
||||
'id' => $crop_info,]);
|
||||
foreach (array('avatar_crop_x', 'avatar_crop_y',
|
||||
'avatar_crop_w', 'avatar_crop_h') as $crop_info) {
|
||||
$this->element('input', array('name' => $crop_info,
|
||||
'type' => 'hidden',
|
||||
'id' => $crop_info));
|
||||
}
|
||||
|
||||
// TRANS: Button on avatar upload crop form to confirm a selected crop as avatar.
|
||||
$this->submit('crop', _m('BUTTON', 'Crop'));
|
||||
$this->submit('crop', _m('BUTTON','Crop'));
|
||||
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
@@ -250,31 +237,20 @@ class AvatarsettingsAction extends SettingsAction
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws NoResultException
|
||||
* @throws NoUploadedMediaException
|
||||
* @throws ServerException
|
||||
* @throws UnsupportedMediaException
|
||||
* @throws UseFileAsThumbnailException
|
||||
* @throws Exception
|
||||
*
|
||||
* @throws ClientException
|
||||
*/
|
||||
protected function doPost()
|
||||
{
|
||||
if (Event::handle('StartAvatarSaveForm', [$this])) {
|
||||
if (Event::handle('StartAvatarSaveForm', array($this))) {
|
||||
if ($this->trimmed('upload')) {
|
||||
return $this->uploadAvatar();
|
||||
} elseif ($this->trimmed('crop')) {
|
||||
} else if ($this->trimmed('crop')) {
|
||||
return $this->cropAvatar();
|
||||
} elseif ($this->trimmed('delete')) {
|
||||
} else if ($this->trimmed('delete')) {
|
||||
return $this->deleteAvatar();
|
||||
} else {
|
||||
// TRANS: Unexpected validation error on avatar upload form.
|
||||
throw new ClientException(_m('Unexpected form submission.'));
|
||||
throw new ClientException(_('Unexpected form submission.'));
|
||||
}
|
||||
Event::handle('EndAvatarSaveForm', [$this]);
|
||||
Event::handle('EndAvatarSaveForm', array($this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,39 +260,28 @@ class AvatarsettingsAction extends SettingsAction
|
||||
* Does all the magic for handling an image upload, and crops the
|
||||
* image by default.
|
||||
*
|
||||
* @return string
|
||||
* @throws NoResultException
|
||||
* @throws NoUploadedMediaException
|
||||
* @throws ServerException
|
||||
* @throws UnsupportedMediaException
|
||||
* @throws UseFileAsThumbnailException
|
||||
*
|
||||
* @throws ClientException
|
||||
* @return void
|
||||
*/
|
||||
public function uploadAvatar(): string
|
||||
function uploadAvatar()
|
||||
{
|
||||
// ImageFile throws exception if something goes wrong, which we'll
|
||||
// pick up and show as an error message above the form.
|
||||
$imagefile = ImageFile::fromUpload('avatarfile');
|
||||
|
||||
$type = $imagefile->preferredType();
|
||||
$filename = Avatar::filename(
|
||||
$this->scoped->getID(),
|
||||
image_type_to_extension($type),
|
||||
null,
|
||||
'tmp' . common_timestamp()
|
||||
);
|
||||
$filename = Avatar::filename($this->scoped->getID(),
|
||||
image_type_to_extension($type),
|
||||
null,
|
||||
'tmp'.common_timestamp());
|
||||
|
||||
$filepath = Avatar::path($filename);
|
||||
$imagefile = $imagefile->copyTo($filepath);
|
||||
|
||||
$filedata = [
|
||||
'filename' => $filename,
|
||||
'filepath' => $filepath,
|
||||
'width' => $imagefile->width,
|
||||
'height' => $imagefile->height,
|
||||
'type' => $type,
|
||||
];
|
||||
$filedata = array('filename' => $filename,
|
||||
'filepath' => $filepath,
|
||||
'width' => $imagefile->width,
|
||||
'height' => $imagefile->height,
|
||||
'type' => $type);
|
||||
|
||||
$_SESSION['FILEDATA'] = $filedata;
|
||||
|
||||
@@ -325,18 +290,13 @@ class AvatarsettingsAction extends SettingsAction
|
||||
$this->mode = 'crop';
|
||||
|
||||
// TRANS: Avatar upload form instruction after uploading a file.
|
||||
return _m('Pick a square area of the image to be your avatar.');
|
||||
return _('Pick a square area of the image to be your avatar.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the results of jcrop.
|
||||
*
|
||||
* @return string
|
||||
* @throws NoResultException
|
||||
* @throws ServerException
|
||||
* @throws UnsupportedMediaException
|
||||
*
|
||||
* @throws ClientException
|
||||
* @return void
|
||||
*/
|
||||
public function cropAvatar()
|
||||
{
|
||||
@@ -344,34 +304,30 @@ class AvatarsettingsAction extends SettingsAction
|
||||
|
||||
if (empty($filedata)) {
|
||||
// TRANS: Server error displayed if an avatar upload went wrong somehow server side.
|
||||
throw new ServerException(_m('Lost our file data.'));
|
||||
throw new ServerException(_('Lost our file data.'));
|
||||
}
|
||||
|
||||
$file_d = min($filedata['width'], $filedata['height']);
|
||||
$file_d = min($filedata['width'], $filedata['height']);
|
||||
|
||||
$dest_x = $this->arg('avatar_crop_x') ? $this->arg('avatar_crop_x') : 0;
|
||||
$dest_y = $this->arg('avatar_crop_y') ? $this->arg('avatar_crop_y') : 0;
|
||||
$dest_w = $this->arg('avatar_crop_w') ? $this->arg('avatar_crop_w') : $file_d;
|
||||
$dest_h = $this->arg('avatar_crop_h') ? $this->arg('avatar_crop_h') : $file_d;
|
||||
$size = (int)(min($dest_w, $dest_h, common_config('avatar', 'maxsize')));
|
||||
$dest_x = $this->arg('avatar_crop_x') ? $this->arg('avatar_crop_x'):0;
|
||||
$dest_y = $this->arg('avatar_crop_y') ? $this->arg('avatar_crop_y'):0;
|
||||
$dest_w = $this->arg('avatar_crop_w') ? $this->arg('avatar_crop_w'):$file_d;
|
||||
$dest_h = $this->arg('avatar_crop_h') ? $this->arg('avatar_crop_h'):$file_d;
|
||||
$size = intval(min($dest_w, $dest_h, common_config('avatar', 'maxsize')));
|
||||
|
||||
$box = ['width' => $size, 'height' => $size,
|
||||
'x' => $dest_x, 'y' => $dest_y,
|
||||
'w' => $dest_w, 'h' => $dest_h,];
|
||||
$box = array('width' => $size, 'height' => $size,
|
||||
'x' => $dest_x, 'y' => $dest_y,
|
||||
'w' => $dest_w, 'h' => $dest_h);
|
||||
|
||||
$imagefile = new ImageFile(-1, $filedata['filepath']);
|
||||
$filename = Avatar::filename(
|
||||
$this->scoped->getID(),
|
||||
image_type_to_extension($imagefile->preferredType()),
|
||||
$size,
|
||||
common_timestamp()
|
||||
);
|
||||
$imagefile = new ImageFile(null, $filedata['filepath']);
|
||||
$filename = Avatar::filename($this->scoped->getID(), image_type_to_extension($imagefile->preferredType()),
|
||||
$size, common_timestamp());
|
||||
try {
|
||||
$imagefile->resizeTo(Avatar::path($filename), $box);
|
||||
} catch (UseFileAsThumbnailException $e) {
|
||||
common_debug('Using uploaded avatar directly without resizing, copying it to: ' . $filename);
|
||||
common_debug('Using uploaded avatar directly without resizing, copying it to: '.$filename);
|
||||
if (!copy($filedata['filepath'], Avatar::path($filename))) {
|
||||
common_debug('Tried to copy image file ' . $filedata['filepath'] . ' to destination ' . Avatar::path($filename));
|
||||
common_debug('Tried to copy image file '.$filedata['filepath'].' to destination '.Avatar::path($filename));
|
||||
throw new ServerException('Could not copy file to destination.');
|
||||
}
|
||||
}
|
||||
@@ -381,26 +337,24 @@ class AvatarsettingsAction extends SettingsAction
|
||||
unset($_SESSION['FILEDATA']);
|
||||
$this->mode = 'upload';
|
||||
// TRANS: Success message for having updated a user avatar.
|
||||
return _m('Avatar updated.');
|
||||
return _('Avatar updated.');
|
||||
}
|
||||
|
||||
// TRANS: Error displayed on the avatar upload page if the avatar could not be updated for an unknown reason.
|
||||
throw new ServerException(_m('Failed updating avatar.'));
|
||||
throw new ServerException(_('Failed updating avatar.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rid of the current avatar.
|
||||
*
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteAvatar()
|
||||
function deleteAvatar()
|
||||
{
|
||||
Avatar::deleteFromProfile($this->scoped);
|
||||
|
||||
// TRANS: Success message for deleting a user avatar.
|
||||
return _m('Avatar deleted.');
|
||||
return _('Avatar deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,10 +362,11 @@ class AvatarsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showStylesheets()
|
||||
|
||||
function showStylesheets()
|
||||
{
|
||||
parent::showStylesheets();
|
||||
$this->cssLink('js/extlib/jquery-jcrop/css/jcrop.css', 'base', 'screen, projection, tv');
|
||||
$this->cssLink('js/extlib/jquery-jcrop/css/jcrop.css','base','screen, projection, tv');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -419,7 +374,7 @@ class AvatarsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showScripts()
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
|
||||
|
||||
+75
-84
@@ -1,44 +1,50 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Block a user action class.
|
||||
*
|
||||
* @category Action
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @copyright 2008, 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 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/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Block a user action class.
|
||||
*
|
||||
* @category Action
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class BlockAction extends ProfileFormAction
|
||||
{
|
||||
public $profile = null;
|
||||
var $profile = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
@@ -47,7 +53,7 @@ class BlockAction extends ProfileFormAction
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
public function prepare(array $args = []): bool
|
||||
function prepare(array $args = array())
|
||||
{
|
||||
if (!parent::prepare($args)) {
|
||||
return false;
|
||||
@@ -72,7 +78,7 @@ class BlockAction extends ProfileFormAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
function handle()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if ($this->arg('no')) {
|
||||
@@ -88,19 +94,16 @@ class BlockAction extends ProfileFormAction
|
||||
}
|
||||
}
|
||||
|
||||
public function showContent(): void
|
||||
{
|
||||
function showContent() {
|
||||
$this->areYouSureForm();
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
function title() {
|
||||
// TRANS: Title for block user page.
|
||||
return _('Block user');
|
||||
}
|
||||
|
||||
public function showNoticeForm(): void
|
||||
{
|
||||
function showNoticeForm() {
|
||||
// nop
|
||||
}
|
||||
|
||||
@@ -111,7 +114,7 @@ class BlockAction extends ProfileFormAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function areYouSureForm()
|
||||
function areYouSureForm()
|
||||
{
|
||||
// @fixme if we ajaxify the confirmation form, skip the preview on ajax hits
|
||||
$profile = new ArrayWrapper(array($this->profile));
|
||||
@@ -128,44 +131,35 @@ class BlockAction extends ProfileFormAction
|
||||
$this->hidden('token', common_session_token());
|
||||
// TRANS: Legend for block user form.
|
||||
$this->element('legend', _('Block user'));
|
||||
$this->element(
|
||||
'p',
|
||||
null,
|
||||
// TRANS: Explanation of consequences when blocking a user on the block user page.
|
||||
_('Are you sure you want to block this user? '
|
||||
. 'Afterwards, they will be unsubscribed from you, '
|
||||
. 'unable to subscribe to you in the future, and '
|
||||
. 'you will not be notified of any @-replies from them.')
|
||||
);
|
||||
$this->element('input', [
|
||||
'id' => 'blockto-' . $id,
|
||||
'name' => 'profileid',
|
||||
'type' => 'hidden',
|
||||
'value' => $id
|
||||
]);
|
||||
$this->element('p', null,
|
||||
// TRANS: Explanation of consequences when blocking a user on the block user page.
|
||||
_('Are you sure you want to block this user? '.
|
||||
'Afterwards, they will be unsubscribed from you, '.
|
||||
'unable to subscribe to you in the future, and '.
|
||||
'you will not be notified of any @-replies from them.'));
|
||||
$this->element('input', array('id' => 'blockto-' . $id,
|
||||
'name' => 'profileid',
|
||||
'type' => 'hidden',
|
||||
'value' => $id));
|
||||
foreach ($this->args as $k => $v) {
|
||||
if (substr($k, 0, 9) == 'returnto-') {
|
||||
$this->hidden($k, $v);
|
||||
}
|
||||
}
|
||||
$this->submit(
|
||||
'form_action-no',
|
||||
// TRANS: Button label on the user block form.
|
||||
_m('BUTTON', 'No'),
|
||||
'submit form_action-primary',
|
||||
'no',
|
||||
// TRANS: Submit button title for 'No' when blocking a user.
|
||||
_('Do not block this user.')
|
||||
);
|
||||
$this->submit(
|
||||
'form_action-yes',
|
||||
// TRANS: Button label on the user block form.
|
||||
_m('BUTTON', 'Yes'),
|
||||
'submit form_action-secondary',
|
||||
'yes',
|
||||
// TRANS: Submit button title for 'Yes' when blocking a user.
|
||||
_('Block this user.')
|
||||
);
|
||||
$this->submit('form_action-no',
|
||||
// TRANS: Button label on the user block form.
|
||||
_m('BUTTON','No'),
|
||||
'submit form_action-primary',
|
||||
'no',
|
||||
// TRANS: Submit button title for 'No' when blocking a user.
|
||||
_('Do not block this user.'));
|
||||
$this->submit('form_action-yes',
|
||||
// TRANS: Button label on the user block form.
|
||||
_m('BUTTON','Yes'),
|
||||
'submit form_action-secondary',
|
||||
'yes',
|
||||
// TRANS: Submit button title for 'Yes' when blocking a user.
|
||||
_('Block this user.'));
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
@@ -176,7 +170,7 @@ class BlockAction extends ProfileFormAction
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function handlePost(): void
|
||||
function handlePost()
|
||||
{
|
||||
$cur = common_current_user();
|
||||
|
||||
@@ -193,7 +187,7 @@ class BlockAction extends ProfileFormAction
|
||||
}
|
||||
}
|
||||
|
||||
public function showScripts(): void
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
$this->autofocus('form_action-yes');
|
||||
@@ -207,14 +201,13 @@ class BlockAction extends ProfileFormAction
|
||||
* @throws ClientException if token is bad on POST request or if we have
|
||||
* confirmation parameters which could trigger something.
|
||||
*/
|
||||
public function checkSessionToken(): void
|
||||
function checkSessionToken()
|
||||
{
|
||||
if (
|
||||
$_SERVER['REQUEST_METHOD'] === 'POST'
|
||||
|| $this->arg('yes')
|
||||
|| $this->arg('no')
|
||||
) {
|
||||
parent::checkSessionToken();
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST' ||
|
||||
$this->arg('yes') ||
|
||||
$this->arg('no')) {
|
||||
|
||||
return parent::checkSessionToken();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,14 +217,12 @@ class BlockAction extends ProfileFormAction
|
||||
*
|
||||
* @return string URL
|
||||
*/
|
||||
public function defaultReturnTo()
|
||||
function defaultReturnTo()
|
||||
{
|
||||
$user = common_current_user();
|
||||
if ($user) {
|
||||
return common_local_url(
|
||||
'subscribers',
|
||||
['nickname' => $user->nickname]
|
||||
);
|
||||
return common_local_url('subscribers',
|
||||
array('nickname' => $user->nickname));
|
||||
} else {
|
||||
return common_local_url('public');
|
||||
}
|
||||
|
||||
@@ -1,30 +1,33 @@
|
||||
<?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
|
||||
*
|
||||
* Confirm an address
|
||||
*
|
||||
* 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 Confirm
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Confirm an address
|
||||
@@ -33,10 +36,11 @@ defined('GNUSOCIAL') || die();
|
||||
* a confirmation code to make sure the owner of that address approves. This class
|
||||
* accepts those codes.
|
||||
*
|
||||
* @category Confirm
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Confirm
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ConfirmaddressAction extends ManagedAction
|
||||
{
|
||||
@@ -84,7 +88,7 @@ class ConfirmaddressAction extends ManagedAction
|
||||
|
||||
$cur = $this->scoped->getUser();
|
||||
|
||||
$cur->query('START TRANSACTION');
|
||||
$cur->query('BEGIN');
|
||||
if (in_array($type, array('email', 'sms'))) {
|
||||
common_debug("Confirming {$type} address for user {$this->scoped->getID()}");
|
||||
if ($cur->$type == $confirm->address) {
|
||||
@@ -110,12 +114,14 @@ class ConfirmaddressAction extends ManagedAction
|
||||
if ($type == 'email') {
|
||||
$cur->emailChanged();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$user_im_prefs = new User_im_prefs();
|
||||
$user_im_prefs->transport = $confirm->address_type;
|
||||
$user_im_prefs->user_id = $cur->id;
|
||||
if ($user_im_prefs->find() && $user_im_prefs->fetch()) {
|
||||
if ($user_im_prefs->screenname === $confirm->address) {
|
||||
if($user_im_prefs->screenname == $confirm->address){
|
||||
// Already verified, so delete the confirm_address entry
|
||||
$confirm->delete();
|
||||
// TRANS: Client error for an already confirmed IM address.
|
||||
@@ -129,7 +135,7 @@ class ConfirmaddressAction extends ManagedAction
|
||||
// TRANS: Server error displayed when updating IM preferences fails.
|
||||
throw new ServerException(_('Could not update user IM preferences.'));
|
||||
}
|
||||
} else {
|
||||
}else{
|
||||
$user_im_prefs = new User_im_prefs();
|
||||
$user_im_prefs->screenname = $confirm->address;
|
||||
$user_im_prefs->transport = $confirm->address_type;
|
||||
@@ -143,6 +149,7 @@ class ConfirmaddressAction extends ManagedAction
|
||||
throw new ServerException(_('Could not insert user IM preferences.'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$confirm->delete();
|
||||
@@ -155,7 +162,7 @@ class ConfirmaddressAction extends ManagedAction
|
||||
*
|
||||
* @return string title
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for the contact address confirmation action.
|
||||
return _('Confirm address');
|
||||
@@ -166,17 +173,13 @@ class ConfirmaddressAction extends ManagedAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
$this->element(
|
||||
'p',
|
||||
null,
|
||||
// TRANS: Success message for the contact address confirmation action.
|
||||
// TRANS: %s can be 'email', 'jabber', or 'sms'.
|
||||
sprintf(
|
||||
_('The address "%s" has been confirmed for your account.'),
|
||||
$this->address
|
||||
)
|
||||
);
|
||||
$this->element('p', null,
|
||||
// TRANS: Success message for the contact address confirmation action.
|
||||
// TRANS: %s can be 'email', 'jabber', or 'sms'.
|
||||
sprintf(_('The address "%s" has been '.
|
||||
'confirmed for your account.'),
|
||||
$this->address));
|
||||
}
|
||||
}
|
||||
|
||||
+31
-25
@@ -1,44 +1,50 @@
|
||||
<?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
|
||||
*
|
||||
* Edit an existing group
|
||||
*
|
||||
* 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 Group
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA') && !defined('GNUSOCIAL')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new group
|
||||
*
|
||||
* This is the form for adding a new group
|
||||
*
|
||||
* @category Group
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Alexei Sorokin <sor.alexei@meowr.ru>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Group
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Alexei Sorokin <sor.alexei@meowr.ru>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class EditgroupAction extends GroupAction
|
||||
{
|
||||
@@ -236,7 +242,7 @@ class EditgroupAction extends GroupAction
|
||||
return;
|
||||
}
|
||||
|
||||
$this->group->query('START TRANSACTION');
|
||||
$this->group->query('BEGIN');
|
||||
|
||||
$orig = clone($this->group);
|
||||
|
||||
|
||||
+73
-92
@@ -1,46 +1,50 @@
|
||||
<?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
|
||||
*
|
||||
* Edit an existing group
|
||||
*
|
||||
* 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 Group
|
||||
* @package GNUsocial
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @package StatusNet
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new group
|
||||
*
|
||||
* This is the form for adding a new group
|
||||
*
|
||||
* @category Group
|
||||
* @package GNUsocial
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Group
|
||||
* @package StatusNet
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class EditpeopletagAction extends Action
|
||||
{
|
||||
public $msg;
|
||||
public $confirm;
|
||||
public $confirm_args = [];
|
||||
var $msg, $confirm, $confirm_args=array();
|
||||
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $this->boolean('delete')) {
|
||||
// TRANS: Title for edit list page after deleting a tag.
|
||||
@@ -56,7 +60,7 @@ class EditpeopletagAction extends Action
|
||||
* Prepare to run
|
||||
*/
|
||||
|
||||
public function prepare(array $args = [])
|
||||
function prepare(array $args = array())
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
@@ -131,7 +135,7 @@ class EditpeopletagAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
function handle()
|
||||
{
|
||||
parent::handle();
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
@@ -141,30 +145,21 @@ class EditpeopletagAction extends Action
|
||||
}
|
||||
}
|
||||
|
||||
public function showConfirm($msg = null, $fwd = null)
|
||||
function showConfirm($msg=null, $fwd=null)
|
||||
{
|
||||
$this->confirm = $msg;
|
||||
$this->confirm_args = $fwd;
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
public function showConfirmForm()
|
||||
function showConfirmForm()
|
||||
{
|
||||
$this->elementStart(
|
||||
'form',
|
||||
[
|
||||
'id' => 'form_peopletag_edit_confirm',
|
||||
'class' => 'form_settings',
|
||||
'method' => 'post',
|
||||
'action' => common_local_url(
|
||||
'editpeopletag',
|
||||
[
|
||||
'tagger' => $this->tagger->nickname,
|
||||
'tag' => $this->peopletag->tag,
|
||||
]
|
||||
),
|
||||
]
|
||||
);
|
||||
$this->elementStart('form', array('id' => 'form_peopletag_edit_confirm',
|
||||
'class' => 'form_settings',
|
||||
'method' => 'post',
|
||||
'action' => common_local_url('editpeopletag',
|
||||
array('tagger' => $this->tagger->nickname,
|
||||
'tag' => $this->peopletag->tag))));
|
||||
$this->elementStart('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->hidden('id', $this->arg('id'));
|
||||
@@ -173,35 +168,31 @@ class EditpeopletagAction extends Action
|
||||
$this->hidden($key, $val);
|
||||
}
|
||||
|
||||
$this->submit(
|
||||
'form_action-no',
|
||||
_m('BUTTON', 'No'),
|
||||
'submit form_action-primary',
|
||||
'cancel'
|
||||
);
|
||||
$this->submit(
|
||||
'form_action-yes',
|
||||
_m('BUTTON', 'Yes'),
|
||||
'submit form_action-secondary',
|
||||
'confirm'
|
||||
);
|
||||
$this->submit('form_action-no',
|
||||
_m('BUTTON','No'),
|
||||
'submit form_action-primary',
|
||||
'cancel');
|
||||
$this->submit('form_action-yes',
|
||||
_m('BUTTON','Yes'),
|
||||
'submit form_action-secondary',
|
||||
'confirm');
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
|
||||
public function showForm($msg = null)
|
||||
function showForm($msg=null)
|
||||
{
|
||||
$this->msg = $msg;
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
public function showObjectNav()
|
||||
function showObjectNav()
|
||||
{
|
||||
$nav = new PeopletagGroupNav($this, $this->peopletag);
|
||||
$nav->show();
|
||||
}
|
||||
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
if ($this->confirm) {
|
||||
$this->showConfirmForm();
|
||||
@@ -214,29 +205,26 @@ class EditpeopletagAction extends Action
|
||||
$form->showProfileList();
|
||||
}
|
||||
|
||||
public function showPageNotice()
|
||||
function showPageNotice()
|
||||
{
|
||||
if ($this->msg) {
|
||||
$this->element('p', 'error', $this->msg);
|
||||
} elseif ($this->confirm) {
|
||||
} else if ($this->confirm) {
|
||||
$this->element('p', 'instructions', $this->confirm);
|
||||
} else {
|
||||
$this->element(
|
||||
'p',
|
||||
'instructions',
|
||||
// TRANS: Form instruction for edit list form.
|
||||
_('Use this form to edit the list.')
|
||||
);
|
||||
$this->element('p', 'instructions',
|
||||
// TRANS: Form instruction for edit list form.
|
||||
_('Use this form to edit the list.'));
|
||||
}
|
||||
}
|
||||
|
||||
public function showScripts()
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
$this->autofocus('tag');
|
||||
}
|
||||
|
||||
public function trySave()
|
||||
function trySave()
|
||||
{
|
||||
$tag = common_canonical_tag($this->trimmed('tag'));
|
||||
$description = $this->trimmed('description');
|
||||
@@ -259,26 +247,25 @@ class EditpeopletagAction extends Action
|
||||
'all its subscription and membership records. ' .
|
||||
'Do you still want to continue?'), array('delete' => 1));
|
||||
return;
|
||||
} elseif (common_valid_tag($tag)) {
|
||||
} else if (common_valid_tag($tag)) {
|
||||
// TRANS: Form validation error displayed if a given tag is invalid.
|
||||
$this->showForm(_('Invalid tag.'));
|
||||
return;
|
||||
} elseif ($tag != $this->peopletag->tag && $this->tagExists($tag)) {
|
||||
} else if ($tag != $this->peopletag->tag && $this->tagExists($tag)) {
|
||||
// TRANS: Form validation error displayed if a given tag is already present.
|
||||
// TRANS: %s is the already present tag.
|
||||
$this->showForm(sprintf(_('You already have a tag named %s.'), $tag));
|
||||
return;
|
||||
} elseif (Profile_list::descriptionTooLong($description)) {
|
||||
} else if (Profile_list::descriptionTooLong($description)) {
|
||||
$this->showForm(sprintf(
|
||||
// TRANS: Client error shown when providing too long a description when editing a list.
|
||||
// TRANS: %d is the maximum number of allowed characters.
|
||||
_m('Description is too long (maximum %d character).',
|
||||
'Description is too long (maximum %d characters).',
|
||||
Profile_list::maxDescription()),
|
||||
Profile_list::maxDescription()
|
||||
));
|
||||
// TRANS: Client error shown when providing too long a description when editing a list.
|
||||
// TRANS: %d is the maximum number of allowed characters.
|
||||
_m('Description is too long (maximum %d character).',
|
||||
'Description is too long (maximum %d characters).',
|
||||
Profile_list::maxDescription()),
|
||||
Profile_list::maxDescription()));
|
||||
return;
|
||||
} elseif ($set_private && !$confirm && !$cancel) {
|
||||
} else if ($set_private && !$confirm && !$cancel) {
|
||||
$fwd = array('tag' => $tag,
|
||||
'description' => $description,
|
||||
'private' => (int) $private);
|
||||
@@ -298,7 +285,7 @@ class EditpeopletagAction extends Action
|
||||
common_redirect(common_local_url('all', array('nickname' => $this->tagger->getNickname())), 303);
|
||||
}
|
||||
|
||||
$this->peopletag->query('START TRANSACTION');
|
||||
$this->peopletag->query('BEGIN');
|
||||
|
||||
$orig = clone($this->peopletag);
|
||||
|
||||
@@ -323,23 +310,17 @@ class EditpeopletagAction extends Action
|
||||
}
|
||||
|
||||
if ($tag != $orig->tag) {
|
||||
common_redirect(
|
||||
common_local_url(
|
||||
'editpeopletag',
|
||||
[
|
||||
'tagger' => $this->tagger->nickname,
|
||||
'tag' => $tag,
|
||||
]
|
||||
),
|
||||
303
|
||||
);
|
||||
common_redirect(common_local_url('editpeopletag',
|
||||
array('tagger' => $this->tagger->nickname,
|
||||
'tag' => $tag)),
|
||||
303);
|
||||
} else {
|
||||
// TRANS: Edit list form success message.
|
||||
$this->showForm(_('Options saved.'));
|
||||
}
|
||||
}
|
||||
|
||||
public function tagExists($tag)
|
||||
function tagExists($tag)
|
||||
{
|
||||
$args = array('tagger' => $this->tagger->id, 'tag' => $tag);
|
||||
$ptag = Profile_list::pkeyGet($args);
|
||||
|
||||
+104
-114
@@ -1,40 +1,48 @@
|
||||
<?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 email
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Settings for email
|
||||
*
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Settings
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*
|
||||
* @see Widget
|
||||
*/
|
||||
|
||||
class EmailsettingsAction extends SettingsAction
|
||||
{
|
||||
/**
|
||||
@@ -42,7 +50,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for e-mail settings.
|
||||
return _('Email settings');
|
||||
@@ -53,7 +61,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// XXX: For consistency of parameters in messages, this should be a
|
||||
// regular parameters, replaced with sprintf().
|
||||
@@ -62,7 +70,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
return _('Manage how you get email from %%site.name%%.');
|
||||
}
|
||||
|
||||
public function showScripts()
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
$this->script('emailsettings.js');
|
||||
@@ -77,7 +85,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
@@ -92,64 +100,56 @@ class EmailsettingsAction extends SettingsAction
|
||||
$this->element('legend', null, _('Email address'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
if (!$user->isNull('email')) {
|
||||
if ($user->email) {
|
||||
$this->element('p', array('id' => 'form_confirmed'), $user->email);
|
||||
// TRANS: Form note in e-mail settings form.
|
||||
$this->element('p', array('class' => 'form_note'), _('Current confirmed email address.'));
|
||||
$this->hidden('email', $user->email);
|
||||
// TRANS: Button label to remove a confirmed e-mail address.
|
||||
$this->submit('remove', _m('BUTTON', 'Remove'));
|
||||
$this->submit('remove', _m('BUTTON','Remove'));
|
||||
} else {
|
||||
try {
|
||||
$confirm = $this->getConfirmation();
|
||||
$this->element('p', array('id' => 'form_unconfirmed'), $confirm->address);
|
||||
$this->element(
|
||||
'p',
|
||||
['class' => 'form_note'],
|
||||
// TRANS: Form note in e-mail settings form.
|
||||
_('Awaiting confirmation on this address. '.
|
||||
'Check your inbox (and spam box!) for a message '.
|
||||
'with further instructions.')
|
||||
);
|
||||
$this->element('p', array('class' => 'form_note'),
|
||||
// TRANS: Form note in e-mail settings form.
|
||||
_('Awaiting confirmation on this address. '.
|
||||
'Check your inbox (and spam box!) for a message '.
|
||||
'with further instructions.'));
|
||||
$this->hidden('email', $confirm->address);
|
||||
// TRANS: Button label to cancel an e-mail address confirmation procedure.
|
||||
$this->submit('cancel', _m('BUTTON', 'Cancel'));
|
||||
$this->submit('cancel', _m('BUTTON','Cancel'));
|
||||
} catch (NoResultException $e) {
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label for e-mail address input in e-mail settings form.
|
||||
$this->input(
|
||||
'email',
|
||||
_('Email address'),
|
||||
$this->trimmed('email') ?: null,
|
||||
// TRANS: Instructions for e-mail address input form. Do not translate
|
||||
// TRANS: "example.org". It is one of the domain names reserved for
|
||||
// TRANS: use in examples by http://www.rfc-editor.org/rfc/rfc2606.txt.
|
||||
// TRANS: Any other domain may be owned by a legitimate person or
|
||||
// TRANS: organization.
|
||||
_('Email address, like "UserName@example.org"')
|
||||
);
|
||||
$this->input('email', _('Email address'),
|
||||
$this->trimmed('email') ?: null,
|
||||
// TRANS: Instructions for e-mail address input form. Do not translate
|
||||
// TRANS: "example.org". It is one of the domain names reserved for
|
||||
// TRANS: use in examples by http://www.rfc-editor.org/rfc/rfc2606.txt.
|
||||
// TRANS: Any other domain may be owned by a legitimate person or
|
||||
// TRANS: organization.
|
||||
_('Email address, like "UserName@example.org"'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
// TRANS: Button label for adding an e-mail address in e-mail settings form.
|
||||
$this->submit('add', _m('BUTTON', 'Add'));
|
||||
$this->submit('add', _m('BUTTON','Add'));
|
||||
}
|
||||
}
|
||||
$this->elementEnd('fieldset');
|
||||
|
||||
if (common_config('emailpost', 'enabled') && $user->email) {
|
||||
if (common_config('emailpost', 'enabled') && $user->email) {
|
||||
$this->elementStart('fieldset', array('id' => 'settings_email_incoming'));
|
||||
// TRANS: Form legend for incoming e-mail settings form.
|
||||
$this->element('legend', null, _('Incoming email'));
|
||||
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
$this->checkbox(
|
||||
'emailpost',
|
||||
// TRANS: Checkbox label in e-mail preferences form.
|
||||
_('I want to post notices by email.'),
|
||||
$user->emailpost
|
||||
);
|
||||
$this->checkbox('emailpost',
|
||||
// TRANS: Checkbox label in e-mail preferences form.
|
||||
_('I want to post notices by email.'),
|
||||
$user->emailpost);
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
|
||||
@@ -163,24 +163,21 @@ class EmailsettingsAction extends SettingsAction
|
||||
|
||||
$this->elementStart('div', array('id' => 'emailincoming'));
|
||||
|
||||
if (!$user->isNull('incomingemail')) {
|
||||
if ($user->incomingemail) {
|
||||
$this->elementStart('p');
|
||||
$this->element('span', 'address', $user->incomingemail);
|
||||
// @todo XXX: Looks a little awkward in the UI.
|
||||
// Something like "xxxx@identi.ca Send email ..". Needs improvement.
|
||||
$this->element(
|
||||
'span',
|
||||
'input_instructions',
|
||||
// TRANS: Form instructions for incoming e-mail form in e-mail settings.
|
||||
_('Send email to this address to post new notices.')
|
||||
);
|
||||
$this->element('span', 'input_instructions',
|
||||
// TRANS: Form instructions for incoming e-mail form in e-mail settings.
|
||||
_('Send email to this address to post new notices.'));
|
||||
$this->elementEnd('p');
|
||||
// TRANS: Button label for removing a set sender e-mail address to post notices from.
|
||||
$this->submit('removeincoming', _m('BUTTON', 'Remove'));
|
||||
$this->submit('removeincoming', _m('BUTTON','Remove'));
|
||||
}
|
||||
|
||||
$this->elementStart('p');
|
||||
if (!$user->isNull('incomingemail')) {
|
||||
if ($user->incomingemail) {
|
||||
// TRANS: Instructions for incoming e-mail address input form, when an address has already been assigned.
|
||||
$msg = _('Make a new email address for posting to; '.
|
||||
'cancels the old one.');
|
||||
@@ -192,7 +189,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
$this->elementEnd('p');
|
||||
|
||||
// TRANS: Button label for adding an e-mail address to send notices from.
|
||||
$this->submit('newincoming', _m('BUTTON', 'New'));
|
||||
$this->submit('newincoming', _m('BUTTON','New'));
|
||||
|
||||
$this->elementEnd('div'); // div#emailincoming
|
||||
|
||||
@@ -207,42 +204,34 @@ class EmailsettingsAction extends SettingsAction
|
||||
|
||||
if (Event::handle('StartEmailFormData', array($this, $this->scoped))) {
|
||||
$this->elementStart('li');
|
||||
$this->checkbox(
|
||||
'emailnotifysub',
|
||||
// TRANS: Checkbox label in e-mail preferences form.
|
||||
_('Send me notices of new subscriptions through email.'),
|
||||
$user->emailnotifysub
|
||||
);
|
||||
$this->checkbox('emailnotifysub',
|
||||
// TRANS: Checkbox label in e-mail preferences form.
|
||||
_('Send me notices of new subscriptions through email.'),
|
||||
$user->emailnotifysub);
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->checkbox(
|
||||
'emailnotifymsg',
|
||||
// TRANS: Checkbox label in e-mail preferences form.
|
||||
_('Send me email when someone sends me a private message.'),
|
||||
$user->emailnotifymsg
|
||||
);
|
||||
$this->checkbox('emailnotifymsg',
|
||||
// TRANS: Checkbox label in e-mail preferences form.
|
||||
_('Send me email when someone sends me a private message.'),
|
||||
$user->emailnotifymsg);
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->checkbox(
|
||||
'emailnotifyattn',
|
||||
// TRANS: Checkbox label in e-mail preferences form.
|
||||
_('Send me email when someone sends me an "@-reply".'),
|
||||
$user->emailnotifyattn
|
||||
);
|
||||
$this->checkbox('emailnotifyattn',
|
||||
// TRANS: Checkbox label in e-mail preferences form.
|
||||
_('Send me email when someone sends me an "@-reply".'),
|
||||
$user->emailnotifyattn);
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->checkbox(
|
||||
'emailnotifynudge',
|
||||
// TRANS: Checkbox label in e-mail preferences form.
|
||||
_('Allow friends to nudge me and send me an email.'),
|
||||
$user->emailnotifynudge
|
||||
);
|
||||
$this->checkbox('emailnotifynudge',
|
||||
// TRANS: Checkbox label in e-mail preferences form.
|
||||
_('Allow friends to nudge me and send me an email.'),
|
||||
$user->emailnotifynudge);
|
||||
$this->elementEnd('li');
|
||||
Event::handle('EndEmailFormData', array($this, $this->scoped));
|
||||
}
|
||||
$this->elementEnd('ul');
|
||||
// TRANS: Button label to save e-mail preferences.
|
||||
$this->submit('save', _m('BUTTON', 'Save'));
|
||||
$this->submit('save', _m('BUTTON','Save'));
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
@@ -253,7 +242,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return Confirm_address Email address confirmation for user, or null
|
||||
*/
|
||||
public function getConfirmation()
|
||||
function getConfirmation()
|
||||
{
|
||||
$confirm = new Confirm_address();
|
||||
|
||||
@@ -271,15 +260,15 @@ class EmailsettingsAction extends SettingsAction
|
||||
{
|
||||
if ($this->arg('save')) {
|
||||
return $this->savePreferences();
|
||||
} elseif ($this->arg('add')) {
|
||||
} else if ($this->arg('add')) {
|
||||
return $this->addAddress();
|
||||
} elseif ($this->arg('cancel')) {
|
||||
} else if ($this->arg('cancel')) {
|
||||
return $this->cancelConfirmation();
|
||||
} elseif ($this->arg('remove')) {
|
||||
} else if ($this->arg('remove')) {
|
||||
return $this->removeAddress();
|
||||
} elseif ($this->arg('removeincoming')) {
|
||||
} else if ($this->arg('removeincoming')) {
|
||||
return $this->removeIncoming();
|
||||
} elseif ($this->arg('newincoming')) {
|
||||
} else if ($this->arg('newincoming')) {
|
||||
return $this->newIncoming();
|
||||
}
|
||||
|
||||
@@ -292,17 +281,17 @@ class EmailsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function savePreferences()
|
||||
function savePreferences()
|
||||
{
|
||||
if (Event::handle('StartEmailSaveForm', array($this, $this->scoped))) {
|
||||
$emailnotifysub = $this->boolean('emailnotifysub');
|
||||
$emailnotifymsg = $this->boolean('emailnotifymsg');
|
||||
$emailnotifynudge = $this->boolean('emailnotifynudge');
|
||||
$emailnotifyattn = $this->boolean('emailnotifyattn');
|
||||
$emailpost = $this->boolean('emailpost');
|
||||
$emailnotifysub = $this->booleanintstring('emailnotifysub');
|
||||
$emailnotifymsg = $this->booleanintstring('emailnotifymsg');
|
||||
$emailnotifynudge = $this->booleanintstring('emailnotifynudge');
|
||||
$emailnotifyattn = $this->booleanintstring('emailnotifyattn');
|
||||
$emailpost = $this->booleanintstring('emailpost');
|
||||
|
||||
$user = $this->scoped->getUser();
|
||||
$user->query('START TRANSACTION');
|
||||
$user->query('BEGIN');
|
||||
$original = clone($user);
|
||||
|
||||
$user->emailnotifysub = $emailnotifysub;
|
||||
@@ -333,7 +322,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addAddress()
|
||||
function addAddress()
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
@@ -355,15 +344,16 @@ class EmailsettingsAction extends SettingsAction
|
||||
if (!Validate::email($email, common_config('email', 'check_domain'))) {
|
||||
// TRANS: Message given saving e-mail address that not valid.
|
||||
throw new ClientException(_('Not a valid email address.'));
|
||||
} elseif ($user->email === $email) {
|
||||
} else if ($user->email == $email) {
|
||||
// TRANS: Message given saving e-mail address that is already set.
|
||||
throw new ClientException(_('That is already your email address.'));
|
||||
} elseif ($this->emailExists($email)) {
|
||||
} else if ($this->emailExists($email)) {
|
||||
// TRANS: Message given saving e-mail address that is already set for another user.
|
||||
throw new ClientException(_('That email address already belongs to another user.'));
|
||||
}
|
||||
|
||||
if (Event::handle('StartAddEmailAddress', array($user, $email))) {
|
||||
|
||||
$confirm = new Confirm_address();
|
||||
|
||||
$confirm->address = $email;
|
||||
@@ -395,7 +385,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cancelConfirmation()
|
||||
function cancelConfirmation()
|
||||
{
|
||||
$email = $this->trimmed('email');
|
||||
|
||||
@@ -421,7 +411,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeAddress()
|
||||
function removeAddress()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
@@ -435,7 +425,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
}
|
||||
|
||||
$original = clone($user);
|
||||
$user->email = $user->sqlValue('NULL');
|
||||
$user->email = null;
|
||||
// Throws exception on failure. Also performs it within a transaction.
|
||||
$user->updateWithKeys($original);
|
||||
|
||||
@@ -448,7 +438,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeIncoming()
|
||||
function removeIncoming()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
@@ -458,8 +448,8 @@ class EmailsettingsAction extends SettingsAction
|
||||
}
|
||||
|
||||
$orig = clone($user);
|
||||
$user->incomingemail = $user->sqlValue('NULL');
|
||||
$user->emailpost = false;
|
||||
$user->incomingemail = null;
|
||||
$user->emailpost = 0;
|
||||
// Throws exception on failure. Also performs it within a transaction.
|
||||
$user->updateWithKeys($orig);
|
||||
|
||||
@@ -472,12 +462,12 @@ class EmailsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function newIncoming()
|
||||
function newIncoming()
|
||||
{
|
||||
$user = common_current_user();
|
||||
$orig = clone($user);
|
||||
$user->incomingemail = mail_new_incoming_address();
|
||||
$user->emailpost = true;
|
||||
$user->emailpost = 1;
|
||||
// Throws exception on failure. Also performs it within a transaction.
|
||||
$user->updateWithKeys($orig);
|
||||
|
||||
@@ -495,7 +485,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
* @return boolean Whether the email already exists.
|
||||
*/
|
||||
|
||||
public function emailExists($email)
|
||||
function emailExists($email)
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
|
||||
+45
-41
@@ -1,51 +1,60 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* List of featured users
|
||||
*
|
||||
* 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 Public
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/profilelist.php';
|
||||
require_once INSTALLDIR . '/lib/groups/publicgroupnav.php';
|
||||
require_once INSTALLDIR.'/lib/profilelist.php';
|
||||
require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
||||
|
||||
/**
|
||||
* List of featured users
|
||||
*
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Public
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @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 FeaturedAction extends Action
|
||||
{
|
||||
public $page = null;
|
||||
var $page = null;
|
||||
|
||||
public function isReadOnly($args)
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function prepare(array $args = [])
|
||||
function prepare(array $args = array())
|
||||
{
|
||||
parent::prepare($args);
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
@@ -53,7 +62,7 @@ class FeaturedAction extends Action
|
||||
return true;
|
||||
}
|
||||
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
// TRANS: Page title for first page of featured users.
|
||||
@@ -65,14 +74,14 @@ class FeaturedAction extends Action
|
||||
}
|
||||
}
|
||||
|
||||
public function handle()
|
||||
function handle()
|
||||
{
|
||||
parent::handle();
|
||||
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
public function showPageNotice()
|
||||
function showPageNotice()
|
||||
{
|
||||
$instr = $this->getInstructions();
|
||||
$output = common_markup_to_html($instr);
|
||||
@@ -81,16 +90,14 @@ class FeaturedAction extends Action
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Description on page displaying featured users.
|
||||
return sprintf(
|
||||
_('A selection of some great users on %s.'),
|
||||
common_config('site', 'name')
|
||||
);
|
||||
return sprintf(_('A selection of some great users on %s.'),
|
||||
common_config('site', 'name'));
|
||||
}
|
||||
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
// XXX: Note I'm doing it this two-stage way because a raw query
|
||||
// with a JOIN was *not* working. --Zach
|
||||
@@ -98,6 +105,7 @@ class FeaturedAction extends Action
|
||||
$featured_nicks = common_config('nickname', 'featured');
|
||||
|
||||
if (count($featured_nicks) > 0) {
|
||||
|
||||
$quoted = array();
|
||||
|
||||
foreach ($featured_nicks as $nick) {
|
||||
@@ -107,7 +115,7 @@ class FeaturedAction extends Action
|
||||
$user = new User;
|
||||
$user->whereAdd(sprintf('nickname IN (%s)', implode(',', $quoted)));
|
||||
$user->limit(($this->page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
|
||||
$user->orderBy($user->escapedTableName() . '.nickname ASC');
|
||||
$user->orderBy(common_database_tablename('user') .'.nickname ASC');
|
||||
|
||||
$user->find();
|
||||
|
||||
@@ -130,12 +138,8 @@ class FeaturedAction extends Action
|
||||
|
||||
$profile->free();
|
||||
|
||||
$this->pagination(
|
||||
$this->page > 1,
|
||||
$cnt > PROFILES_PER_PAGE,
|
||||
$this->page,
|
||||
'featured'
|
||||
);
|
||||
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
|
||||
$this->page, 'featured');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+36
-51
@@ -1,25 +1,23 @@
|
||||
<?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/>.
|
||||
|
||||
/*
|
||||
* @copyright 2008, 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 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/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
define('LISTENER', 1);
|
||||
define('LISTENEE', -1);
|
||||
@@ -28,7 +26,7 @@ define('BOTH', 0);
|
||||
// @todo XXX: Documentation missing.
|
||||
class FoafAction extends ManagedAction
|
||||
{
|
||||
public function isReadOnly($args)
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -47,13 +45,9 @@ class FoafAction extends ManagedAction
|
||||
// Permanent redirect on non-canonical nickname
|
||||
|
||||
if ($nickname_arg != $this->nickname) {
|
||||
common_redirect(
|
||||
common_local_url(
|
||||
'foaf',
|
||||
['nickname' => $this->nickname]
|
||||
),
|
||||
301
|
||||
);
|
||||
common_redirect(common_local_url('foaf',
|
||||
array('nickname' => $this->nickname)),
|
||||
301);
|
||||
}
|
||||
|
||||
$this->user = User::getKV('nickname', $this->nickname);
|
||||
@@ -158,27 +152,22 @@ class FoafAction extends ManagedAction
|
||||
// No avatar for this user!
|
||||
}
|
||||
|
||||
$person = $this->showMicrobloggingAccount(
|
||||
$this->profile,
|
||||
common_root_url(),
|
||||
$this->user->getUri(),
|
||||
// $fetchSubscriptions
|
||||
true,
|
||||
// $isSubscriber
|
||||
false
|
||||
);
|
||||
$person = $this->showMicrobloggingAccount($this->profile,
|
||||
common_root_url(), $this->user->getUri(),
|
||||
/*$fetchSubscriptions*/true,
|
||||
/*$isSubscriber*/false);
|
||||
|
||||
// Get people who subscribe to user
|
||||
|
||||
$sub = new Subscription();
|
||||
$sub->subscribed = $this->profile->id;
|
||||
$sub->whereAdd('subscriber <> subscribed');
|
||||
$sub->whereAdd('subscriber != subscribed');
|
||||
|
||||
if ($sub->find()) {
|
||||
while ($sub->fetch()) {
|
||||
$profile = Profile::getKV('id', $sub->subscriber);
|
||||
if (!$profile instanceof Profile) {
|
||||
common_debug('Got a bad subscription: ' . print_r($sub, true));
|
||||
common_debug('Got a bad subscription: '.print_r($sub,true));
|
||||
continue;
|
||||
}
|
||||
$other_uri = $profile->getUri();
|
||||
@@ -217,15 +206,11 @@ class FoafAction extends ManagedAction
|
||||
if ($type == BOTH) {
|
||||
$this->element('knows', array('rdf:resource' => $this->user->getUri()));
|
||||
}
|
||||
$this->showMicrobloggingAccount(
|
||||
$profile,
|
||||
($local === 'local') ? common_root_url() : null,
|
||||
$uri,
|
||||
// $fetchSubscriptions
|
||||
false,
|
||||
// $isSubscriber
|
||||
($type == LISTENER || $type == BOTH)
|
||||
);
|
||||
$this->showMicrobloggingAccount($profile,
|
||||
($local == 'local') ? common_root_url() : null,
|
||||
$uri,
|
||||
/*$fetchSubscriptions*/false,
|
||||
/*$isSubscriber*/($type == LISTENER || $type == BOTH));
|
||||
if ($foaf_url) {
|
||||
$this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url));
|
||||
}
|
||||
@@ -242,7 +227,7 @@ class FoafAction extends ManagedAction
|
||||
$this->endXML();
|
||||
}
|
||||
|
||||
public function showPpd($foaf_url, $person_uri)
|
||||
function showPpd($foaf_url, $person_uri)
|
||||
{
|
||||
$this->elementStart('PersonalProfileDocument', array('rdf:about' => $foaf_url));
|
||||
$this->element('maker', array('rdf:resource' => $person_uri));
|
||||
@@ -263,7 +248,7 @@ class FoafAction extends ManagedAction
|
||||
* @return array if $fetchSubscribers is set, return a list of info on those
|
||||
* subscriptions.
|
||||
*/
|
||||
public function showMicrobloggingAccount($profile, $service = null, $useruri = null, $fetchSubscriptions = false, $isSubscriber = false)
|
||||
function showMicrobloggingAccount($profile, $service=null, $useruri=null, $fetchSubscriptions=false, $isSubscriber=false)
|
||||
{
|
||||
$attr = array();
|
||||
if ($useruri) {
|
||||
@@ -289,13 +274,13 @@ class FoafAction extends ManagedAction
|
||||
// Get people user is subscribed to
|
||||
$sub = new Subscription();
|
||||
$sub->subscriber = $profile->id;
|
||||
$sub->whereAdd('subscriber <> subscribed');
|
||||
$sub->whereAdd('subscriber != subscribed');
|
||||
|
||||
if ($sub->find()) {
|
||||
while ($sub->fetch()) {
|
||||
$profile = Profile::getKV('id', $sub->subscribed);
|
||||
if (empty($profile)) {
|
||||
common_debug('Got a bad subscription: ' . print_r($sub, true));
|
||||
common_debug('Got a bad subscription: '.print_r($sub,true));
|
||||
continue;
|
||||
}
|
||||
$other_uri = $profile->getUri();
|
||||
@@ -309,7 +294,7 @@ class FoafAction extends ManagedAction
|
||||
}
|
||||
|
||||
unset($sub);
|
||||
} elseif ($isSubscriber) {
|
||||
} else if ($isSubscriber) {
|
||||
// Just declare that they follow the user whose FOAF we're showing.
|
||||
$this->element('sioc:follows', array('rdf:resource' => $this->user->getUri() . '#acct'));
|
||||
}
|
||||
|
||||
+49
-50
@@ -1,82 +1,85 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* List of group members
|
||||
*
|
||||
* 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 Group
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* List of group members
|
||||
*
|
||||
* @category Group
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Group
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class GroupmembersAction extends GroupAction
|
||||
{
|
||||
public $page = null;
|
||||
var $page = null;
|
||||
|
||||
public function isReadOnly($args)
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
// TRANS: Title of the page showing group members.
|
||||
// TRANS: %s is the name of the group.
|
||||
return sprintf(
|
||||
_('%s group members'),
|
||||
$this->group->nickname
|
||||
);
|
||||
return sprintf(_('%s group members'),
|
||||
$this->group->nickname);
|
||||
} else {
|
||||
// TRANS: Title of the page showing group members.
|
||||
// TRANS: %1$s is the name of the group, %2$d is the page number of the members list.
|
||||
return sprintf(
|
||||
_('%1$s group members, page %2$d'),
|
||||
$this->group->nickname,
|
||||
$this->page
|
||||
);
|
||||
return sprintf(_('%1$s group members, page %2$d'),
|
||||
$this->group->nickname,
|
||||
$this->page);
|
||||
}
|
||||
}
|
||||
|
||||
public function showPageNotice()
|
||||
protected function handle()
|
||||
{
|
||||
$this->element(
|
||||
'p',
|
||||
'instructions',
|
||||
// TRANS: Page notice for group members page.
|
||||
_('A list of the users in this group.')
|
||||
);
|
||||
parent::handle();
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
public function showContent()
|
||||
function showPageNotice()
|
||||
{
|
||||
$this->element('p', 'instructions',
|
||||
// TRANS: Page notice for group members page.
|
||||
_('A list of the users in this group.'));
|
||||
}
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$offset = ($this->page-1) * PROFILES_PER_PAGE;
|
||||
$limit = PROFILES_PER_PAGE + 1;
|
||||
$limit = PROFILES_PER_PAGE + 1;
|
||||
|
||||
$cnt = 0;
|
||||
|
||||
@@ -87,12 +90,8 @@ class GroupmembersAction extends GroupAction
|
||||
$cnt = $member_list->show();
|
||||
}
|
||||
|
||||
$this->pagination(
|
||||
$this->page > 1,
|
||||
$cnt > PROFILES_PER_PAGE,
|
||||
$this->page,
|
||||
'groupmembers',
|
||||
['nickname' => $this->group->nickname]
|
||||
);
|
||||
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
|
||||
$this->page, 'groupmembers',
|
||||
array('nickname' => $this->group->nickname));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/profilelist.php';
|
||||
require_once INSTALLDIR . '/lib/groups/publicgroupnav.php';
|
||||
require_once(INSTALLDIR.'/lib/profilelist.php');
|
||||
require_once INSTALLDIR.'/lib/publicgroupnav.php';
|
||||
|
||||
/**
|
||||
* List of group members
|
||||
|
||||
@@ -32,7 +32,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/groups/grouplist.php';
|
||||
require_once INSTALLDIR.'/lib/grouplist.php';
|
||||
|
||||
/**
|
||||
* Latest groups
|
||||
|
||||
@@ -32,8 +32,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/search/searchaction.php';
|
||||
require_once INSTALLDIR . '/lib/profile/profilelist.php';
|
||||
//require_once INSTALLDIR.'/lib/searchaction.php';
|
||||
//require_once INSTALLDIR.'/lib/profilelist.php';
|
||||
|
||||
/**
|
||||
* Group search action class.
|
||||
|
||||
+97
-93
@@ -1,25 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Settings for Jabber/XMPP integration
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Settings for Jabber/XMPP integration
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Settings
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*
|
||||
* @see SettingsAction
|
||||
* @see SettingsAction
|
||||
*/
|
||||
|
||||
class ImsettingsAction extends SettingsAction
|
||||
@@ -29,7 +48,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for Instant Messaging settings.
|
||||
return _('IM settings');
|
||||
@@ -40,7 +59,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instant messaging settings page instructions.
|
||||
// TRANS: [instant messages] is link text, "(%%doc.im%%)" is the link.
|
||||
@@ -59,112 +78,94 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
$transports = array();
|
||||
Event::handle('GetImTransports', array(&$transports));
|
||||
if (! $transports) {
|
||||
$this->element(
|
||||
'div',
|
||||
['class' => 'error'],
|
||||
// TRANS: Message given in the IM settings if IM is not enabled on the site.
|
||||
_('IM is not available.')
|
||||
);
|
||||
$this->element('div', array('class' => 'error'),
|
||||
// TRANS: Message given in the IM settings if IM is not enabled on the site.
|
||||
_('IM is not available.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$user = common_current_user();
|
||||
|
||||
$user_im_prefs_by_transport = array();
|
||||
|
||||
foreach ($transports as $transport => $transport_info) {
|
||||
$this->elementStart(
|
||||
'form',
|
||||
[
|
||||
'method' => 'post',
|
||||
'id' => 'form_settings_im',
|
||||
'class' => 'form_settings',
|
||||
'action' => common_local_url('imsettings'),
|
||||
]
|
||||
);
|
||||
|
||||
foreach($transports as $transport=>$transport_info)
|
||||
{
|
||||
$this->elementStart('form', array('method' => 'post',
|
||||
'id' => 'form_settings_im',
|
||||
'class' => 'form_settings',
|
||||
'action' =>
|
||||
common_local_url('imsettings')));
|
||||
$this->elementStart('fieldset', array('id' => 'settings_im_address'));
|
||||
// TRANS: Form legend for IM settings form.
|
||||
$this->element('legend', null, $transport_info['display']);
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->hidden('transport', $transport);
|
||||
|
||||
if ($user_im_prefs = User_im_prefs::pkeyGet(['transport' => $transport, 'user_id' => $user->id])) {
|
||||
if ($user_im_prefs = User_im_prefs::pkeyGet( array('transport' => $transport, 'user_id' => $user->id) )) {
|
||||
$user_im_prefs_by_transport[$transport] = $user_im_prefs;
|
||||
$this->element('p', 'form_confirmed', $user_im_prefs->screenname);
|
||||
$this->element(
|
||||
'p',
|
||||
'form_note',
|
||||
// TRANS: Form note in IM settings form. %s is the type of IM address that was confirmed.
|
||||
sprintf(_('Current confirmed %s address.'), $transport_info['display'])
|
||||
);
|
||||
$this->element('p', 'form_note',
|
||||
// TRANS: Form note in IM settings form. %s is the type of IM address that was confirmed.
|
||||
sprintf(_('Current confirmed %s address.'),$transport_info['display']));
|
||||
$this->hidden('screenname', $user_im_prefs->screenname);
|
||||
// TRANS: Button label to remove a confirmed IM address.
|
||||
$this->submit('remove', _m('BUTTON', 'Remove'));
|
||||
$this->submit('remove', _m('BUTTON','Remove'));
|
||||
} else {
|
||||
try {
|
||||
$confirm = $this->getConfirmation($transport);
|
||||
$this->element('p', 'form_unconfirmed', $confirm->address);
|
||||
// TRANS: Form note in IM settings form.
|
||||
$this->element(
|
||||
'p',
|
||||
'form_note',
|
||||
// TRANS: Form note in IM settings form.
|
||||
// TRANS: %s is the IM service name, %2$s is the IM address set.
|
||||
sprintf(
|
||||
_('Awaiting confirmation on this address. '
|
||||
. 'Check your %1$s account for a '
|
||||
. 'message with further instructions. '
|
||||
. '(Did you add %2$s to your buddy list?)'),
|
||||
$transport_info['display'],
|
||||
$transport_info['daemonScreenname']
|
||||
)
|
||||
);
|
||||
$this->element('p', 'form_note',
|
||||
// TRANS: Form note in IM settings form.
|
||||
// TRANS: %s is the IM service name, %2$s is the IM address set.
|
||||
sprintf(_('Awaiting confirmation on this address. '.
|
||||
'Check your %1$s account for a '.
|
||||
'message with further instructions. '.
|
||||
'(Did you add %2$s to your buddy list?)'),
|
||||
$transport_info['display'],
|
||||
$transport_info['daemonScreenname']));
|
||||
$this->hidden('screenname', $confirm->address);
|
||||
// TRANS: Button label to cancel an IM address confirmation procedure.
|
||||
$this->submit('cancel', _m('BUTTON', 'Cancel'));
|
||||
$this->submit('cancel', _m('BUTTON','Cancel'));
|
||||
} catch (NoResultException $e) {
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label for IM address.
|
||||
$this->input(
|
||||
'screenname',
|
||||
_('IM address'),
|
||||
($this->arg('screenname')) ? $this->arg('screenname') : null,
|
||||
// TRANS: Field title for IM address. %s is the IM service name.
|
||||
sprintf(_('%s screenname.'), $transport_info['display'])
|
||||
);
|
||||
$this->input('screenname', _('IM address'),
|
||||
($this->arg('screenname')) ? $this->arg('screenname') : null,
|
||||
// TRANS: Field title for IM address. %s is the IM service name.
|
||||
sprintf(_('%s screenname.'),
|
||||
$transport_info['display']));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
// TRANS: Button label for adding an IM address in IM settings form.
|
||||
$this->submit('add', _m('BUTTON', 'Add'));
|
||||
$this->submit('add', _m('BUTTON','Add'));
|
||||
}
|
||||
}
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
|
||||
if ($user_im_prefs_by_transport) {
|
||||
$this->elementStart(
|
||||
'form',
|
||||
[
|
||||
'method' => 'post',
|
||||
'id' => 'form_settings_im',
|
||||
'class' => 'form_settings',
|
||||
'action' => common_local_url('imsettings'),
|
||||
]
|
||||
);
|
||||
if($user_im_prefs_by_transport)
|
||||
{
|
||||
$this->elementStart('form', array('method' => 'post',
|
||||
'id' => 'form_settings_im',
|
||||
'class' => 'form_settings',
|
||||
'action' =>
|
||||
common_local_url('imsettings')));
|
||||
$this->elementStart('fieldset', array('id' => 'settings_im_preferences'));
|
||||
// TRANS: Header for IM preferences form.
|
||||
$this->element('legend', null, _('IM Preferences'));
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->elementStart('table');
|
||||
$this->elementStart('tr');
|
||||
foreach ($user_im_prefs_by_transport as $transport => $user_im_prefs) {
|
||||
foreach($user_im_prefs_by_transport as $transport=>$user_im_prefs)
|
||||
{
|
||||
$this->element('th', null, $transports[$transport]['display']);
|
||||
}
|
||||
$this->elementEnd('tr');
|
||||
@@ -177,23 +178,23 @@ class ImsettingsAction extends SettingsAction
|
||||
array('name'=>'replies', 'description'=>_('Send me replies '.
|
||||
'from people I\'m not subscribed to.')),
|
||||
);
|
||||
foreach ($preferences as $preference) {
|
||||
foreach($preferences as $preference)
|
||||
{
|
||||
$this->elementStart('tr');
|
||||
foreach ($user_im_prefs_by_transport as $transport => $user_im_prefs) {
|
||||
foreach($user_im_prefs_by_transport as $transport=>$user_im_prefs)
|
||||
{
|
||||
$preference_name = $preference['name'];
|
||||
$this->elementStart('td');
|
||||
$this->checkbox(
|
||||
$transport . '_' . $preference['name'],
|
||||
$preference['description'],
|
||||
$user_im_prefs->$preference_name
|
||||
);
|
||||
$this->checkbox($transport . '_' . $preference['name'],
|
||||
$preference['description'],
|
||||
$user_im_prefs->$preference_name);
|
||||
$this->elementEnd('td');
|
||||
}
|
||||
$this->elementEnd('tr');
|
||||
}
|
||||
$this->elementEnd('table');
|
||||
// TRANS: Button label to save IM preferences.
|
||||
$this->submit('save', _m('BUTTON', 'Save'));
|
||||
$this->submit('save', _m('BUTTON','Save'));
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
@@ -204,7 +205,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return Confirm_address address object for this user
|
||||
*/
|
||||
public function getConfirmation($transport)
|
||||
function getConfirmation($transport)
|
||||
{
|
||||
$confirm = new Confirm_address();
|
||||
|
||||
@@ -222,11 +223,11 @@ class ImsettingsAction extends SettingsAction
|
||||
{
|
||||
if ($this->arg('save')) {
|
||||
return $this->savePreferences();
|
||||
} elseif ($this->arg('add')) {
|
||||
} else if ($this->arg('add')) {
|
||||
return $this->addAddress();
|
||||
} elseif ($this->arg('cancel')) {
|
||||
} else if ($this->arg('cancel')) {
|
||||
return $this->cancelConfirmation();
|
||||
} elseif ($this->arg('remove')) {
|
||||
} else if ($this->arg('remove')) {
|
||||
return $this->removeAddress();
|
||||
}
|
||||
// TRANS: Message given submitting a form with an unknown action in Instant Messaging settings.
|
||||
@@ -241,17 +242,20 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function savePreferences()
|
||||
function savePreferences()
|
||||
{
|
||||
$user_im_prefs = new User_im_prefs();
|
||||
$user_im_prefs->query('START TRANSACTION');
|
||||
$user_im_prefs->query('BEGIN');
|
||||
$user_im_prefs->user_id = $this->scoped->getID();
|
||||
if ($user_im_prefs->find() && $user_im_prefs->fetch()) {
|
||||
if($user_im_prefs->find() && $user_im_prefs->fetch())
|
||||
{
|
||||
$preferences = array('notify', 'updatefrompresence', 'replies');
|
||||
do {
|
||||
do
|
||||
{
|
||||
$original = clone($user_im_prefs);
|
||||
$new = clone($user_im_prefs);
|
||||
foreach ($preferences as $preference) {
|
||||
foreach($preferences as $preference)
|
||||
{
|
||||
$new->$preference = $this->boolean($new->transport . '_' . $preference);
|
||||
}
|
||||
$result = $new->update($original);
|
||||
@@ -261,7 +265,7 @@ class ImsettingsAction extends SettingsAction
|
||||
// TRANS: Server error thrown on database error updating IM preferences.
|
||||
throw new ServerException(_('Could not update IM preferences.'));
|
||||
}
|
||||
} while ($user_im_prefs->fetch());
|
||||
}while($user_im_prefs->fetch());
|
||||
}
|
||||
$user_im_prefs->query('COMMIT');
|
||||
// TRANS: Confirmation message for successful IM preferences save.
|
||||
@@ -276,7 +280,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addAddress()
|
||||
function addAddress()
|
||||
{
|
||||
$screenname = $this->trimmed('screenname');
|
||||
$transport = $this->trimmed('transport');
|
||||
@@ -304,7 +308,7 @@ class ImsettingsAction extends SettingsAction
|
||||
if (!$valid) {
|
||||
// TRANS: Message given saving IM address that not valid.
|
||||
throw new ClientException(_('Not a valid screenname.'));
|
||||
} elseif ($this->screennameExists($transport, $screenname)) {
|
||||
} else if ($this->screennameExists($transport, $screenname)) {
|
||||
// TRANS: Message given saving IM address that is already set for another user.
|
||||
throw new ClientException(_('Screenname already belongs to another user.'));
|
||||
}
|
||||
@@ -339,7 +343,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cancelConfirmation()
|
||||
function cancelConfirmation()
|
||||
{
|
||||
$screenname = $this->trimmed('screenname');
|
||||
$transport = $this->trimmed('transport');
|
||||
@@ -368,7 +372,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeAddress()
|
||||
function removeAddress()
|
||||
{
|
||||
$screenname = $this->trimmed('screenname');
|
||||
$transport = $this->trimmed('transport');
|
||||
@@ -409,7 +413,7 @@ class ImsettingsAction extends SettingsAction
|
||||
* @return boolean whether the screenname exists
|
||||
*/
|
||||
|
||||
public function screennameExists($transport, $screenname)
|
||||
function screennameExists($transport, $screenname)
|
||||
{
|
||||
$user_im_prefs = new User_im_prefs();
|
||||
$user_im_prefs->transport = $transport;
|
||||
|
||||
@@ -1,38 +1,44 @@
|
||||
<?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
|
||||
*
|
||||
* License administration panel
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* License settings
|
||||
*
|
||||
* @category Admin
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Admin
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class LicenseadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -42,7 +48,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
* @return string page title
|
||||
*/
|
||||
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: User admin panel title
|
||||
return _m('TITLE', 'License');
|
||||
@@ -53,7 +59,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Form instructions for the site license admin panel.
|
||||
return _('License for this StatusNet site');
|
||||
@@ -64,7 +70,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showForm()
|
||||
function showForm()
|
||||
{
|
||||
$form = new LicenseAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -76,7 +82,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function saveSettings()
|
||||
function saveSettings()
|
||||
{
|
||||
static $settings = array(
|
||||
'license' => array('type', 'owner', 'url', 'title', 'image')
|
||||
@@ -98,7 +104,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('START TRANSACTION');
|
||||
$config->query('BEGIN');
|
||||
|
||||
foreach ($settings as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -118,7 +124,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
public function validate(&$values)
|
||||
function validate(&$values)
|
||||
{
|
||||
// Validate license type (shouldn't have to do it, but just in case)
|
||||
|
||||
@@ -189,7 +195,7 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
public function id()
|
||||
function id()
|
||||
{
|
||||
return 'licenseadminpanel';
|
||||
}
|
||||
@@ -199,7 +205,7 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
public function formClass()
|
||||
function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -210,7 +216,7 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
public function action()
|
||||
function action()
|
||||
{
|
||||
return common_local_url('licenseadminpanel');
|
||||
}
|
||||
@@ -221,11 +227,10 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function formData()
|
||||
function formData()
|
||||
{
|
||||
$this->out->elementStart(
|
||||
'fieldset',
|
||||
['id' => 'settings_license-selection']
|
||||
'fieldset', array('id' => 'settings_license-selection')
|
||||
);
|
||||
// TRANS: Form legend in the license admin panel.
|
||||
$this->out->element('legend', null, _('License selection'));
|
||||
@@ -302,8 +307,7 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
$this->li();
|
||||
$this->input(
|
||||
// TRANS: Field label in the license admin panel.
|
||||
'image',
|
||||
_('License Image URL'),
|
||||
'image', _('License Image URL'),
|
||||
// TRANS: Field title in the license admin panel.
|
||||
_('URL for an image to display with the license.'),
|
||||
'license'
|
||||
@@ -319,12 +323,12 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formActions()
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit(
|
||||
'submit',
|
||||
// TRANS: Button text in the license admin panel.
|
||||
_m('BUTTON', 'Save'),
|
||||
_m('BUTTON','Save'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Button title in the license admin panel.
|
||||
|
||||
+57
-57
@@ -1,41 +1,50 @@
|
||||
<?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/>.
|
||||
/**
|
||||
* Make another user an admin of a group
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 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('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make another user an admin of a group
|
||||
*
|
||||
* @category Action
|
||||
* @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
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
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
|
||||
{
|
||||
public $profile = null;
|
||||
public $group = null;
|
||||
var $profile = null;
|
||||
var $group = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
@@ -45,7 +54,7 @@ class MakeadminAction extends RedirectingAction
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
public function prepare(array $args = [])
|
||||
function prepare(array $args = array())
|
||||
{
|
||||
parent::prepare($args);
|
||||
if (!common_logged_in()) {
|
||||
@@ -86,14 +95,10 @@ class MakeadminAction extends RedirectingAction
|
||||
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: %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->profile->getBestName(),
|
||||
$this->group->getBestName()
|
||||
),
|
||||
401
|
||||
);
|
||||
$this->clientError(sprintf(_('%1$s is already an admin for group "%2$s".'),
|
||||
$this->profile->getBestName(),
|
||||
$this->group->getBestName()),
|
||||
401);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -106,7 +111,7 @@ class MakeadminAction extends RedirectingAction
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function handle()
|
||||
function handle()
|
||||
{
|
||||
parent::handle();
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
@@ -120,7 +125,7 @@ class MakeadminAction extends RedirectingAction
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function makeAdmin()
|
||||
function makeAdmin()
|
||||
{
|
||||
$member = Group_member::pkeyGet(array('group_id' => $this->group->id,
|
||||
'profile_id' => $this->profile->id));
|
||||
@@ -129,16 +134,14 @@ class MakeadminAction extends RedirectingAction
|
||||
// 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: %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->profile->getBestName(),
|
||||
$this->group->getBestName()
|
||||
);
|
||||
$this->serverError(_('Can\'t get membership record for %1$s in group %2$s.'),
|
||||
$this->profile->getBestName(),
|
||||
$this->group->getBestName());
|
||||
}
|
||||
|
||||
$orig = clone($member);
|
||||
|
||||
$member->is_admin = true;
|
||||
$member->is_admin = 1;
|
||||
|
||||
$result = $member->update($orig);
|
||||
|
||||
@@ -147,11 +150,9 @@ class MakeadminAction extends RedirectingAction
|
||||
// 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: %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->profile->getBestName(),
|
||||
$this->group->getBestName()
|
||||
);
|
||||
$this->serverError(_('Can\'t make %1$s an admin for group %2$s.'),
|
||||
$this->profile->getBestName(),
|
||||
$this->group->getBestName());
|
||||
}
|
||||
|
||||
$this->returnToPrevious();
|
||||
@@ -160,14 +161,13 @@ class MakeadminAction extends RedirectingAction
|
||||
/**
|
||||
* If we reached this form without returnto arguments, default to
|
||||
* the top of the group's member list.
|
||||
*
|
||||
*
|
||||
* @return string URL
|
||||
*/
|
||||
public function defaultReturnTo()
|
||||
function defaultReturnTo()
|
||||
{
|
||||
return common_local_url(
|
||||
'groupmembers',
|
||||
['nickname' => $this->group->nickname]
|
||||
);
|
||||
return common_local_url('groupmembers',
|
||||
array('nickname' => $this->group->nickname));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,45 +1,49 @@
|
||||
<?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
|
||||
*
|
||||
* Register a new OAuth Application
|
||||
*
|
||||
* 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 Applications
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @copyright 2013 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Add a new application
|
||||
*
|
||||
* This is the form for adding a new application
|
||||
*
|
||||
* @category Application
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Application
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class NewApplicationAction extends SettingsAction
|
||||
{
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: This is the title of the form for adding a new application.
|
||||
return _('New application');
|
||||
@@ -83,7 +87,7 @@ class NewApplicationAction extends SettingsAction
|
||||
if (empty($name)) {
|
||||
// TRANS: Validation error shown when not providing a name in the "New application" form.
|
||||
$this->clientError(_('Name is required.'));
|
||||
} elseif ($this->nameExists($name)) {
|
||||
} else if ($this->nameExists($name)) {
|
||||
// TRANS: Validation error shown when providing a name for an application that already exists in the "New application" form.
|
||||
$this->clientError(_('Name already in use. Try another one.'));
|
||||
} elseif (mb_strlen($name) > 255) {
|
||||
@@ -99,8 +103,7 @@ class NewApplicationAction extends SettingsAction
|
||||
_m('Description is too long (maximum %d character).',
|
||||
'Description is too long (maximum %d characters).',
|
||||
Oauth_application::maxDesc()),
|
||||
Oauth_application::maxDesc()
|
||||
));
|
||||
Oauth_application::maxDesc()));
|
||||
} elseif (empty($source_url)) {
|
||||
// TRANS: Validation error shown when not providing a source URL in the "New application" form.
|
||||
$this->clientError(_('Source URL is required.'));
|
||||
@@ -132,7 +135,7 @@ class NewApplicationAction extends SettingsAction
|
||||
|
||||
$app = new Oauth_application();
|
||||
|
||||
$app->query('START TRANSACTION');
|
||||
$app->query('BEGIN');
|
||||
|
||||
$app->name = $name;
|
||||
$app->owner = $this->scoped->getID();
|
||||
@@ -202,7 +205,7 @@ class NewApplicationAction extends SettingsAction
|
||||
*
|
||||
* @return boolean true if the name already exists
|
||||
*/
|
||||
public function nameExists($name)
|
||||
function nameExists($name)
|
||||
{
|
||||
$app = Oauth_application::getKV('name', $name);
|
||||
return !empty($app);
|
||||
|
||||
@@ -33,7 +33,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/search/searchaction.php';
|
||||
require_once INSTALLDIR.'/lib/searchaction.php';
|
||||
|
||||
/**
|
||||
* Notice search action class.
|
||||
@@ -65,8 +65,6 @@ class NoticesearchAction extends SearchAction
|
||||
|
||||
if (!empty($this->q)) {
|
||||
|
||||
Event::handle('StartNoticeSearch', [$this->q]);
|
||||
|
||||
$stream = new SearchNoticeStream($this->q, $this->scoped);
|
||||
$page = $this->trimmed('page');
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/util/mail.php';
|
||||
require_once INSTALLDIR.'/lib/mail.php';
|
||||
|
||||
/**
|
||||
* Nudge a user action class.
|
||||
|
||||
@@ -1,38 +1,42 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* List the OAuth applications that a user has registered with this instance
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Show a user's registered OAuth applications
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Settings
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*
|
||||
* @see SettingsAction
|
||||
*/
|
||||
@@ -52,7 +56,7 @@ class OauthappssettingsAction extends SettingsAction
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Page title for OAuth applications
|
||||
return _('OAuth applications');
|
||||
@@ -64,20 +68,20 @@ class OauthappssettingsAction extends SettingsAction
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Page instructions for OAuth applications
|
||||
return _('Applications you have registered');
|
||||
}
|
||||
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
$offset = ($this->page - 1) * APPS_PER_PAGE;
|
||||
$limit = APPS_PER_PAGE + 1;
|
||||
|
||||
$application = new Oauth_application();
|
||||
$application->owner = $this->scoped->getID();
|
||||
$application->whereAdd("name <> 'anonymous'");
|
||||
$application->whereAdd("name != 'anonymous'");
|
||||
$application->limit($offset, $limit);
|
||||
$application->orderBy('created DESC');
|
||||
$application->find();
|
||||
@@ -92,16 +96,13 @@ class OauthappssettingsAction extends SettingsAction
|
||||
}
|
||||
}
|
||||
|
||||
$this->elementStart('p', ['id' => 'application_register']);
|
||||
$this->element(
|
||||
'a',
|
||||
[
|
||||
'href' => common_local_url('newapplication'),
|
||||
'class' => 'more',
|
||||
],
|
||||
$this->elementStart('p', array('id' => 'application_register'));
|
||||
$this->element('a',
|
||||
array('href' => common_local_url('newapplication'),
|
||||
'class' => 'more'
|
||||
),
|
||||
// TRANS: Link description to add a new OAuth application.
|
||||
'Register a new application'
|
||||
);
|
||||
'Register a new application');
|
||||
$this->elementEnd('p');
|
||||
|
||||
$this->pagination(
|
||||
@@ -112,7 +113,7 @@ class OauthappssettingsAction extends SettingsAction
|
||||
);
|
||||
}
|
||||
|
||||
public function showEmptyListMessage()
|
||||
function showEmptyListMessage()
|
||||
{
|
||||
// TRANS: Empty list message on page with OAuth applications. Markup allowed
|
||||
$message = sprintf(_('You have not registered any applications yet.'));
|
||||
|
||||
+172
-217
@@ -1,42 +1,48 @@
|
||||
<?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
|
||||
*
|
||||
* Paths administration panel
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paths settings
|
||||
*
|
||||
* @category Admin
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Admin
|
||||
* @package StatusNet
|
||||
* @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 PathsadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -46,7 +52,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
* @return string page title
|
||||
*/
|
||||
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for Paths admin panel.
|
||||
return _('Paths');
|
||||
@@ -57,7 +63,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Form instructions for Path admin panel.
|
||||
return _('Path and server settings for this StatusNet site');
|
||||
@@ -68,7 +74,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showForm()
|
||||
function showForm()
|
||||
{
|
||||
$form = new PathsAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -80,14 +86,14 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function saveSettings()
|
||||
function saveSettings()
|
||||
{
|
||||
static $settings = [
|
||||
'site' => ['path', 'locale_path', 'ssl', 'sslserver'],
|
||||
'theme' => ['server', 'dir', 'path', 'sslserver', 'sslpath'],
|
||||
'avatar' => ['server', 'dir', 'path'],
|
||||
'attachments' => ['server', 'dir', 'path', 'sslserver', 'sslpath'],
|
||||
];
|
||||
static $settings = array(
|
||||
'site' => array('path', 'locale_path', 'ssl', 'sslserver'),
|
||||
'theme' => array('server', 'dir', 'path', 'sslserver', 'sslpath'),
|
||||
'avatar' => array('server', 'dir', 'path'),
|
||||
'attachments' => array('server', 'dir', 'path', 'sslserver', 'sslpath')
|
||||
);
|
||||
|
||||
// XXX: If we're only going to have one boolean on thi page we
|
||||
// can remove some of the boolean processing code --Z
|
||||
@@ -114,7 +120,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('START TRANSACTION');
|
||||
$config->query('BEGIN');
|
||||
|
||||
foreach ($settings as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -138,7 +144,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function validate(&$values)
|
||||
function validate(&$values)
|
||||
{
|
||||
// Validate theme dir
|
||||
|
||||
@@ -183,7 +189,7 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
public function id()
|
||||
function id()
|
||||
{
|
||||
return 'form_paths_admin_panel';
|
||||
}
|
||||
@@ -193,7 +199,7 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
public function formClass()
|
||||
function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -203,7 +209,7 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
public function action()
|
||||
function action()
|
||||
{
|
||||
return common_local_url('pathsadminpanel');
|
||||
}
|
||||
@@ -213,7 +219,7 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formData()
|
||||
function formData()
|
||||
{
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_paths_locale'));
|
||||
// TRANS: Fieldset legend in Paths admin panel.
|
||||
@@ -221,45 +227,37 @@ class PathsAdminPanelForm extends AdminForm
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'server',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Server'),
|
||||
// TRANS: Field title in Paths admin panel.
|
||||
_('Site\'s server hostname.')
|
||||
);
|
||||
$this->input('server',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Server'),
|
||||
// TRANS: Field title in Paths admin panel.
|
||||
_('Site\'s server hostname.'));
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'path',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Path'),
|
||||
// TRANS: Field title in Paths admin panel.
|
||||
_('Site path.')
|
||||
);
|
||||
$this->input('path',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Path'),
|
||||
// TRANS: Field title in Paths admin panel.
|
||||
_('Site path.'));
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'locale_path',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Locale directory'),
|
||||
// TRANS: Field title in Paths admin panel.
|
||||
_('Directory path to locales.'),
|
||||
'site'
|
||||
);
|
||||
$this->input('locale_path',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Locale directory'),
|
||||
// TRANS: Field title in Paths admin panel.
|
||||
_('Directory path to locales.'),
|
||||
'site');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->out->checkbox(
|
||||
'fancy',
|
||||
// TRANS: Checkbox label in Paths admin panel.
|
||||
_('Fancy URLs'),
|
||||
(bool) $this->value('fancy'),
|
||||
// TRANS: Field title in Paths admin panel.
|
||||
_('Use fancy URLs (more readable and memorable)?')
|
||||
);
|
||||
$this->out->checkbox('fancy',
|
||||
// TRANS: Checkbox label in Paths admin panel.
|
||||
_('Fancy URLs'),
|
||||
(bool) $this->value('fancy'),
|
||||
// TRANS: Field title in Paths admin panel.
|
||||
_('Use fancy URLs (more readable and memorable)?'));
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@@ -267,176 +265,145 @@ class PathsAdminPanelForm extends AdminForm
|
||||
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_paths_theme'));
|
||||
// TRANS: Fieldset legend in Paths admin panel.
|
||||
$this->out->element('legend', null, _m('LEGEND', 'Theme'));
|
||||
$this->out->element('legend', null, _m('LEGEND','Theme'));
|
||||
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'server',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Server for themes.'),
|
||||
'theme'
|
||||
);
|
||||
$this->input('server',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Server for themes.'),
|
||||
'theme');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'path',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Path'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Web path to themes.'),
|
||||
'theme'
|
||||
);
|
||||
$this->input('path',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Path'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Web path to themes.'),
|
||||
'theme');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'sslserver',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('SSL server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('SSL server for themes (default: SSL server).'),
|
||||
'theme'
|
||||
);
|
||||
$this->input('sslserver',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('SSL server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('SSL server for themes (default: SSL server).'),
|
||||
'theme');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'sslpath',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('SSL path'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('SSL path to themes (default: /theme/).'),
|
||||
'theme'
|
||||
);
|
||||
$this->input('sslpath',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('SSL path'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('SSL path to themes (default: /theme/).'),
|
||||
'theme');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'dir',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Directory'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Directory where themes are located.'),
|
||||
'theme'
|
||||
);
|
||||
$this->input('dir',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Directory'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Directory where themes are located.'),
|
||||
'theme');
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
|
||||
$this->out->elementEnd('fieldset');
|
||||
$this->out->elementStart(
|
||||
'fieldset',
|
||||
['id' => 'settings_avatar-paths']
|
||||
);
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_avatar-paths'));
|
||||
// TRANS: Fieldset legend in Paths admin panel.
|
||||
$this->out->element('legend', null, _('Avatars'));
|
||||
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'server',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Avatar server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Server for avatars.'),
|
||||
'avatar'
|
||||
);
|
||||
$this->input('server',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Avatar server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Server for avatars.'),
|
||||
'avatar');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'path',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Avatar path'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Web path to avatars.'),
|
||||
'avatar'
|
||||
);
|
||||
$this->input('path',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Avatar path'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Web path to avatars.'),
|
||||
'avatar');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'dir',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Avatar directory'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Directory where avatars are located.'),
|
||||
'avatar'
|
||||
);
|
||||
$this->input('dir',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Avatar directory'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Directory where avatars are located.'),
|
||||
'avatar');
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
|
||||
$this->out->elementEnd('fieldset');
|
||||
|
||||
$this->out->elementStart(
|
||||
'fieldset',
|
||||
['id' => 'settings_attachments-paths']
|
||||
);
|
||||
$this->out->elementStart('fieldset', array('id' =>
|
||||
'settings_attachments-paths'));
|
||||
|
||||
// TRANS: Fieldset legens in Paths admin panel.
|
||||
$this->out->element('legend', null, _('Attachments'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'server',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Server for attachments.'),
|
||||
'attachments'
|
||||
);
|
||||
$this->input('server',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Server for attachments.'),
|
||||
'attachments');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'path',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Path'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Web path to attachments.'),
|
||||
'attachments'
|
||||
);
|
||||
$this->input('path',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Path'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Web path to attachments.'),
|
||||
'attachments');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'sslserver',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('SSL server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Server for attachments on SSL pages.'),
|
||||
'attachments'
|
||||
);
|
||||
$this->input('sslserver',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('SSL server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Server for attachments on SSL pages.'),
|
||||
'attachments');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'sslpath',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('SSL path'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Web path to attachments on SSL pages.'),
|
||||
'attachments'
|
||||
);
|
||||
$this->input('sslpath',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('SSL path'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Web path to attachments on SSL pages.'),
|
||||
'attachments');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'dir',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Directory'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Directory where attachments are located.'),
|
||||
'attachments'
|
||||
);
|
||||
$this->input('dir',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('Directory'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Directory where attachments are located.'),
|
||||
'attachments');
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@@ -444,38 +411,31 @@ class PathsAdminPanelForm extends AdminForm
|
||||
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_admin_ssl'));
|
||||
// TRANS: Fieldset legend in Paths admin panel.
|
||||
$this->out->element('legend', null, _m('LEGEND', 'SSL'));
|
||||
$this->out->element('legend', null, _m('LEGEND','SSL'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
$this->li();
|
||||
|
||||
// TRANS: Drop down option in Paths admin panel (option for "When to use SSL").
|
||||
$ssl = [
|
||||
'never' => _('Never'),
|
||||
// TRANS: Drop down option in Paths admin panel (option for "When to use SSL").
|
||||
'always' => _('Always'),
|
||||
];
|
||||
$ssl = array('never' => _('Never'),
|
||||
// TRANS: Drop down option in Paths admin panel (option for "When to use SSL").
|
||||
'always' => _('Always'));
|
||||
|
||||
$this->out->dropdown(
|
||||
'site-ssl',
|
||||
// TRANS: Drop down label in Paths admin panel.
|
||||
_('Use SSL'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
$ssl,
|
||||
_('When to use SSL.'),
|
||||
false,
|
||||
$this->value('ssl', 'site')
|
||||
);
|
||||
$this->out->dropdown('site-ssl',
|
||||
// TRANS: Drop down label in Paths admin panel.
|
||||
_('Use SSL'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
$ssl, _('When to use SSL.'),
|
||||
false,
|
||||
$this->value('ssl', 'site'));
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'sslserver',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('SSL server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Server to direct SSL requests to.'),
|
||||
'site'
|
||||
);
|
||||
$this->input('sslserver',
|
||||
// TRANS: Field label in Paths admin panel.
|
||||
_('SSL server'),
|
||||
// TRANS: Tooltip for field label in Paths admin panel.
|
||||
_('Server to direct SSL requests to.'),
|
||||
'site');
|
||||
$this->unli();
|
||||
$this->out->elementEnd('ul');
|
||||
$this->out->elementEnd('fieldset');
|
||||
@@ -486,17 +446,12 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formActions()
|
||||
function formActions()
|
||||
{
|
||||
// TRANS: Button text to store form data in the Paths admin panel.
|
||||
$this->out->submit(
|
||||
'save',
|
||||
_m('BUTTON', 'Save'),
|
||||
'submit',
|
||||
// TRANS: Button title text to store form data in the Paths admin panel.
|
||||
'save',
|
||||
_('Save path settings.')
|
||||
);
|
||||
$this->out->submit('save', _m('BUTTON','Save'), 'submit',
|
||||
// TRANS: Button title text to store form data in the Paths admin panel.
|
||||
'save', _('Save path settings.'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -512,7 +467,7 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function input($setting, $title, $instructions, $section='site')
|
||||
function input($setting, $title, $instructions, $section='site')
|
||||
{
|
||||
$this->out->input("$section-$setting", $title, $this->value($setting, $section), $instructions);
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/search/searchaction.php';
|
||||
require_once INSTALLDIR . '/lib/profile/profilelist.php';
|
||||
require_once INSTALLDIR.'/lib/searchaction.php';
|
||||
require_once INSTALLDIR.'/lib/profilelist.php';
|
||||
|
||||
/**
|
||||
* People search action class.
|
||||
|
||||
+42
-46
@@ -1,48 +1,55 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Lists by a user
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Personal
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Shashi Gowda <connect2shashi@gmail.com>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/peopletaglist.php';
|
||||
require_once INSTALLDIR.'/lib/peopletaglist.php';
|
||||
// cache 3 pages
|
||||
define('PEOPLETAG_CACHE_WINDOW', PEOPLETAGS_PER_PAGE*3 + 1);
|
||||
|
||||
class PeopletagAction extends Action
|
||||
{
|
||||
public $page = null;
|
||||
public $tag = null;
|
||||
var $page = null;
|
||||
var $tag = null;
|
||||
|
||||
public function isReadOnly($args)
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
// TRANS: Title for list page.
|
||||
@@ -55,7 +62,7 @@ class PeopletagAction extends Action
|
||||
}
|
||||
}
|
||||
|
||||
public function prepare(array $args = [])
|
||||
function prepare(array $args = array())
|
||||
{
|
||||
parent::prepare($args);
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
@@ -77,19 +84,19 @@ class PeopletagAction extends Action
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
function handle()
|
||||
{
|
||||
parent::handle();
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
public function showLocalNav()
|
||||
function showLocalNav()
|
||||
{
|
||||
$nav = new PublicGroupNav($this);
|
||||
$nav->show();
|
||||
}
|
||||
|
||||
public function showAnonymousMessage()
|
||||
function showAnonymousMessage()
|
||||
{
|
||||
$notice =
|
||||
// TRANS: Message for anonymous users on list page.
|
||||
@@ -99,13 +106,13 @@ class PeopletagAction extends Action
|
||||
'(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
|
||||
'You can then easily keep track of what they ' .
|
||||
"are doing by subscribing to the list's timeline.");
|
||||
'are doing by subscribing to the list\'s timeline.' );
|
||||
$this->elementStart('div', array('id' => 'anon_notice'));
|
||||
$this->raw(common_markup_to_html($notice));
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
$offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
|
||||
$limit = PEOPLETAGS_PER_PAGE + 1;
|
||||
@@ -136,15 +143,9 @@ class PeopletagAction extends Action
|
||||
$ptags->find();
|
||||
}
|
||||
} else {
|
||||
$ptags->whereAdd(sprintf(
|
||||
<<<'END'
|
||||
(
|
||||
(profile_list.tagger = %d AND profile_list.private IS TRUE)
|
||||
OR profile_list.private IS NOT TRUE
|
||||
)
|
||||
END,
|
||||
$user->getID()
|
||||
));
|
||||
$ptags->whereAdd('(profile_list.private = false OR (' .
|
||||
' profile_list.tagger =' . $user->id .
|
||||
' AND profile_list.private = true) )');
|
||||
|
||||
$ptags->orderBy('profile_list.modified DESC');
|
||||
$ptags->find();
|
||||
@@ -153,16 +154,11 @@ class PeopletagAction extends Action
|
||||
$pl = new PeopletagList($ptags, $this);
|
||||
$cnt = $pl->show();
|
||||
|
||||
$this->pagination(
|
||||
($this->page > 1),
|
||||
($cnt > PEOPLETAGS_PER_PAGE),
|
||||
$this->page,
|
||||
'peopletag',
|
||||
['tag' => $this->tag]
|
||||
);
|
||||
$this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
|
||||
$this->page, 'peopletag', array('tag' => $this->tag));
|
||||
}
|
||||
|
||||
public function showSections()
|
||||
function showSections()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/profilelist.php';
|
||||
require_once(INSTALLDIR.'/lib/profilelist.php');
|
||||
|
||||
/**
|
||||
* List of people tagged by the user with a tag
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/peopletaglist.php';
|
||||
require_once INSTALLDIR.'/lib/peopletaglist.php';
|
||||
|
||||
class PeopletagsbyuserAction extends Action
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/peopletaglist.php';
|
||||
require_once INSTALLDIR.'/lib/peopletaglist.php';
|
||||
|
||||
class PeopletagsforuserAction extends Action
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/profilelist.php';
|
||||
require_once(INSTALLDIR.'/lib/profilelist.php');
|
||||
|
||||
/**
|
||||
* List of peopletag subscribers
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/peopletaglist.php';
|
||||
require_once INSTALLDIR.'/lib/peopletaglist.php';
|
||||
|
||||
class PeopletagsubscriptionsAction extends Action
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
defined('STATUSNET') || die();
|
||||
|
||||
require_once INSTALLDIR . '/lib/util/deletetree.php';
|
||||
require_once INSTALLDIR . '/lib/deletetree.php';
|
||||
|
||||
/**
|
||||
* Form for deleting a plugin
|
||||
|
||||
@@ -38,52 +38,6 @@ defined('STATUSNET') || die();
|
||||
*/
|
||||
class PlugindisableAction extends PluginenableAction
|
||||
{
|
||||
/**
|
||||
* Handle request
|
||||
*
|
||||
* Disables the plugin and returns results.
|
||||
*
|
||||
* @return void
|
||||
* @throws ClientException
|
||||
*/
|
||||
function handle()
|
||||
{
|
||||
if (PluginList::isPluginLoaded($this->plugin)) {
|
||||
$config_file = INSTALLDIR . DIRECTORY_SEPARATOR . 'config.php';
|
||||
$config_lines = file($config_file, FILE_IGNORE_NEW_LINES);
|
||||
foreach($config_lines as $key => $line) {
|
||||
// We are doing it this way to avoid deleting things we shouldn't
|
||||
$line = str_replace('addPlugin(\''.$this->plugin.'\');', '', $line);
|
||||
$config_lines[$key] = $line;
|
||||
if($line === ' // Added by sysadmin\'s Plugin UI.') {
|
||||
unset($config_lines[$key]);
|
||||
}
|
||||
}
|
||||
$new_config_data = implode(PHP_EOL, $config_lines);
|
||||
if (!file_put_contents($config_file, $new_config_data)) {
|
||||
$this->clientError(_m('No permissions for writing to config.php'));
|
||||
}
|
||||
}
|
||||
$key = 'disable-' . $this->plugin;
|
||||
Config::save('plugins', $key, $this->overrideValue());
|
||||
|
||||
// @fixme this is a pretty common pattern and should be refactored down
|
||||
if ($this->boolean('ajax')) {
|
||||
$this->startHTML('text/xml;charset=utf-8');
|
||||
$this->elementStart('head');
|
||||
$this->element('title', null, $this->successShortTitle());
|
||||
$this->elementEnd('head');
|
||||
$this->elementStart('body');
|
||||
$form = $this->successNextForm();
|
||||
$form->show();
|
||||
$this->elementEnd('body');
|
||||
$this->endHTML();
|
||||
} else {
|
||||
$url = common_local_url('pluginsadminpanel');
|
||||
common_redirect($url, 303);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Value to save into $config['plugins']['disable-<name>']
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
defined('STATUSNET') || die();
|
||||
|
||||
require_once INSTALLDIR . '/lib/util/deletetree.php';
|
||||
require_once INSTALLDIR . '/lib/deletetree.php';
|
||||
|
||||
/**
|
||||
* Plugin install action.
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/peopletageditform.php';
|
||||
require_once INSTALLDIR . '/lib/peopletageditform.php';
|
||||
|
||||
/**
|
||||
* Subscription action
|
||||
|
||||
+133
-172
@@ -1,38 +1,46 @@
|
||||
<?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
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Change profile settings
|
||||
*
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Settings
|
||||
* @package StatusNet
|
||||
* @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
|
||||
{
|
||||
@@ -41,7 +49,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Page title for profile settings.
|
||||
return _('Profile settings');
|
||||
@@ -52,14 +60,14 @@ class ProfilesettingsAction extends SettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Usage instructions for profile settings.
|
||||
return _('You can update your personal profile info here '.
|
||||
'so people know more about you.');
|
||||
}
|
||||
|
||||
public function showScripts()
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
$this->autofocus('fullname');
|
||||
@@ -72,7 +80,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
@@ -90,40 +98,29 @@ class ProfilesettingsAction extends SettingsAction
|
||||
if (Event::handle('StartProfileFormData', array($this))) {
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label in form for profile settings.
|
||||
$this->input(
|
||||
'nickname',
|
||||
_('Nickname'),
|
||||
$this->trimmed('nickname') ?: $this->scoped->getNickname(),
|
||||
// TRANS: Tooltip for field label in form for profile settings.
|
||||
_('1-64 lowercase letters or numbers, no punctuation or spaces.'),
|
||||
null,
|
||||
false, // "name" (will be set to id), then "required"
|
||||
(common_config('profile', 'changenick')
|
||||
? ['placeholder' => null]
|
||||
: ['disabled' => 'disabled', 'placeholder' => null])
|
||||
);
|
||||
$this->input('nickname', _('Nickname'),
|
||||
$this->trimmed('nickname') ?: $this->scoped->getNickname(),
|
||||
// TRANS: Tooltip for field label in form for profile settings.
|
||||
_('1-64 lowercase letters or numbers, no punctuation or spaces.'),
|
||||
null, false, // "name" (will be set to id), then "required"
|
||||
!common_config('profile', 'changenick')
|
||||
? array('disabled' => 'disabled', 'placeholder' => null)
|
||||
: array('placeholder' => null));
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label in form for profile settings.
|
||||
$this->input(
|
||||
'fullname',
|
||||
_('Full name'),
|
||||
$this->trimmed('fullname') ?: $this->scoped->getFullname(),
|
||||
// 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->input('fullname', _('Full name'),
|
||||
$this->trimmed('fullname') ?: $this->scoped->getFullname(),
|
||||
// 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->elementStart('li');
|
||||
// TRANS: Field label in form for profile settings.
|
||||
$this->input(
|
||||
'homepage',
|
||||
_('Homepage'),
|
||||
$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->input('homepage', _('Homepage'),
|
||||
$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->elementStart('li');
|
||||
$maxBio = Profile::maxBio();
|
||||
@@ -131,129 +128,97 @@ class ProfilesettingsAction extends SettingsAction
|
||||
// TRANS: Tooltip for field label in form for profile settings. Plural
|
||||
// TRANS: is decided by the number of characters available for the
|
||||
// TRANS: biography (%d).
|
||||
$bioInstr = sprintf(
|
||||
_m('Describe yourself and your interests in %d character.',
|
||||
'Describe yourself and your interests in %d characters.',
|
||||
$maxBio),
|
||||
$maxBio
|
||||
);
|
||||
$bioInstr = sprintf(_m('Describe yourself and your interests in %d character.',
|
||||
'Describe yourself and your interests in %d characters.',
|
||||
$maxBio),
|
||||
$maxBio);
|
||||
} else {
|
||||
// TRANS: Tooltip for field label in form for profile settings.
|
||||
$bioInstr = _('Describe yourself and your interests.');
|
||||
}
|
||||
// TRANS: Text area label in form for profile settings where users can provide
|
||||
// TRANS: their biography.
|
||||
$this->textarea(
|
||||
'bio',
|
||||
_('Bio'),
|
||||
($this->trimmed('bio') ?: $this->scoped->getDescription()),
|
||||
$bioInstr
|
||||
);
|
||||
$this->textarea('bio', _('Bio'),
|
||||
$this->trimmed('bio') ?: $this->scoped->getDescription(),
|
||||
$bioInstr);
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label in form for profile settings.
|
||||
$this->input(
|
||||
'location',
|
||||
_('Location'),
|
||||
($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->input('location', _('Location'),
|
||||
$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');
|
||||
if (common_config('location', 'share') == 'user') {
|
||||
$this->elementStart('li');
|
||||
// TRANS: Checkbox label in form for profile settings.
|
||||
$this->checkbox(
|
||||
'sharelocation',
|
||||
_('Share my current location when posting notices'),
|
||||
($this->arg('sharelocation') ?
|
||||
$this->boolean('sharelocation') : $this->scoped->shareLocation())
|
||||
);
|
||||
$this->checkbox('sharelocation', _('Share my current location when posting notices'),
|
||||
($this->arg('sharelocation')) ?
|
||||
$this->boolean('sharelocation') : $this->scoped->shareLocation());
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
Event::handle('EndProfileFormData', array($this));
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label in form for profile settings.
|
||||
$this->input(
|
||||
'tags',
|
||||
_('Tags'),
|
||||
($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->input('tags', _('Tags'),
|
||||
$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->elementStart('li');
|
||||
$language = common_language();
|
||||
// TRANS: Dropdownlist label in form for profile settings.
|
||||
$this->dropdown(
|
||||
'language',
|
||||
_('Language'),
|
||||
// TRANS: Tooltip for dropdown list label in form for profile settings.
|
||||
get_nice_language_list(),
|
||||
_('Preferred language.'),
|
||||
false,
|
||||
$language
|
||||
);
|
||||
$this->dropdown('language', _('Language'),
|
||||
// TRANS: Tooltip for dropdown list label in form for profile settings.
|
||||
get_nice_language_list(), _('Preferred language.'),
|
||||
false, $language);
|
||||
$this->elementEnd('li');
|
||||
$timezone = common_timezone();
|
||||
$timezones = array();
|
||||
foreach (DateTimeZone::listIdentifiers() as $k => $v) {
|
||||
foreach(DateTimeZone::listIdentifiers() as $k => $v) {
|
||||
$timezones[$v] = $v;
|
||||
}
|
||||
$this->elementStart('li');
|
||||
// TRANS: Dropdownlist label in form for profile settings.
|
||||
$this->dropdown(
|
||||
'timezone',
|
||||
_('Timezone'),
|
||||
// TRANS: Tooltip for dropdown list label in form for profile settings.
|
||||
$timezones,
|
||||
_('What timezone are you normally in?'),
|
||||
true,
|
||||
$timezone
|
||||
);
|
||||
$this->dropdown('timezone', _('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->elementStart('li');
|
||||
$this->checkbox(
|
||||
'autosubscribe',
|
||||
// TRANS: Checkbox label in form for profile settings.
|
||||
_('Automatically subscribe to whoever '.
|
||||
'subscribes to me (best for non-humans)'),
|
||||
($this->arg('autosubscribe') ?
|
||||
$this->boolean('autosubscribe') : $user->autosubscribe)
|
||||
);
|
||||
$this->checkbox('autosubscribe',
|
||||
// TRANS: Checkbox label in form for profile settings.
|
||||
_('Automatically subscribe to whoever '.
|
||||
'subscribes to me (best for non-humans)'),
|
||||
($this->arg('autosubscribe')) ?
|
||||
$this->boolean('autosubscribe') : $user->autosubscribe);
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->dropdown(
|
||||
'subscribe_policy',
|
||||
// TRANS: Dropdown field label on profile settings, for what policies to apply when someone else tries to subscribe to your updates.
|
||||
_('Subscription policy'),
|
||||
[
|
||||
// TRANS: Dropdown field option for following policy.
|
||||
User::SUBSCRIBE_POLICY_OPEN => _('Let anyone follow me'),
|
||||
// TRANS: Dropdown field option for following policy.
|
||||
User::SUBSCRIBE_POLICY_MODERATE => _('Ask me first'),
|
||||
],
|
||||
// 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->dropdown('subscribe_policy',
|
||||
// TRANS: Dropdown field label on profile settings, for what policies to apply when someone else tries to subscribe to your updates.
|
||||
_('Subscription policy'),
|
||||
// TRANS: Dropdown field option for following policy.
|
||||
array(User::SUBSCRIBE_POLICY_OPEN => _('Let anyone follow me'),
|
||||
// TRANS: Dropdown field option for following policy.
|
||||
User::SUBSCRIBE_POLICY_MODERATE => _('Ask me first')),
|
||||
// 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');
|
||||
}
|
||||
if (common_config('profile', 'allowprivate') || $user->private_stream) {
|
||||
$this->elementStart('li');
|
||||
$this->checkbox(
|
||||
'private_stream',
|
||||
// TRANS: Checkbox label in profile settings.
|
||||
_('Make updates visible only to my followers'),
|
||||
($this->arg('private_stream') ?
|
||||
$this->boolean('private_stream') : $user->private_stream)
|
||||
);
|
||||
$this->checkbox('private_stream',
|
||||
// TRANS: Checkbox label in profile settings.
|
||||
_('Make updates visible only to my followers'),
|
||||
($this->arg('private_stream')) ?
|
||||
$this->boolean('private_stream') : $user->private_stream);
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
$this->elementEnd('ul');
|
||||
// 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('form');
|
||||
@@ -290,7 +255,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||
$homepage = $this->trimmed('homepage');
|
||||
$bio = $this->trimmed('bio');
|
||||
$location = $this->trimmed('location');
|
||||
$autosubscribe = $this->boolean('autosubscribe');
|
||||
$autosubscribe = $this->booleanintstring('autosubscribe');
|
||||
$subscribe_policy = $this->trimmed('subscribe_policy');
|
||||
$language = $this->trimmed('language');
|
||||
$timezone = $this->trimmed('timezone');
|
||||
@@ -301,26 +266,24 @@ class ProfilesettingsAction extends SettingsAction
|
||||
!common_valid_http_url($homepage)) {
|
||||
// TRANS: Validation error in form for profile settings.
|
||||
throw new ClientException(_('Homepage is not a valid URL.'));
|
||||
} elseif (!is_null($fullname) && mb_strlen($fullname) > 191) {
|
||||
} else if (!is_null($fullname) && mb_strlen($fullname) > 191) {
|
||||
// TRANS: Validation error in form for profile settings.
|
||||
throw new ClientException(_('Full name is too long (maximum 191 characters).'));
|
||||
} elseif (Profile::bioTooLong($bio)) {
|
||||
} else if (Profile::bioTooLong($bio)) {
|
||||
// TRANS: Validation error in form for profile settings.
|
||||
// TRANS: Plural form is used based on the maximum number of allowed
|
||||
// TRANS: characters for the biography (%d).
|
||||
throw new ClientException(sprintf(
|
||||
_m('Bio is too long (maximum %d character).',
|
||||
'Bio is too long (maximum %d characters).',
|
||||
Profile::maxBio()),
|
||||
Profile::maxBio()
|
||||
));
|
||||
} elseif (!is_null($location) && mb_strlen($location) > 191) {
|
||||
throw new ClientException(sprintf(_m('Bio is too long (maximum %d character).',
|
||||
'Bio is too long (maximum %d characters).',
|
||||
Profile::maxBio()),
|
||||
Profile::maxBio()));
|
||||
} else if (!is_null($location) && mb_strlen($location) > 191) {
|
||||
// TRANS: Validation error in form for profile settings.
|
||||
throw new ClientException(_('Location is too long (maximum 191 characters).'));
|
||||
} elseif (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
|
||||
} else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
|
||||
// TRANS: Validation error in form for profile settings.
|
||||
throw new ClientException(_('Timezone not selected.'));
|
||||
} elseif (!is_null($language) && strlen($language) > 50) {
|
||||
} else if (!is_null($language) && strlen($language) > 50) {
|
||||
// TRANS: Validation error in form for profile settings.
|
||||
throw new ClientException(_('Language is too long (maximum 50 characters).'));
|
||||
}
|
||||
@@ -328,6 +291,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||
$tags = array();
|
||||
$tag_priv = array();
|
||||
if (is_string($tagstring) && strlen($tagstring) > 0) {
|
||||
|
||||
$tags = preg_split('/[\s,]+/', $tagstring);
|
||||
|
||||
foreach ($tags as &$tag) {
|
||||
@@ -345,24 +309,26 @@ class ProfilesettingsAction extends SettingsAction
|
||||
}
|
||||
|
||||
$user = $this->scoped->getUser();
|
||||
$user->query('START TRANSACTION');
|
||||
$user->query('BEGIN');
|
||||
|
||||
// Only allow setting private_stream if site policy allows it
|
||||
// (or user already _has_ a private stream, then you can unset it)
|
||||
if (common_config('profile', 'allowprivate') || $user->private_stream) {
|
||||
$private_stream = $this->boolean('private_stream');
|
||||
$private_stream = $this->booleanintstring('private_stream');
|
||||
} else {
|
||||
// if not allowed, we set to the existing value
|
||||
$private_stream = (bool) $user->private_stream;
|
||||
$private_stream = $user->private_stream;
|
||||
}
|
||||
|
||||
// $user->nickname is updated through Profile->update();
|
||||
|
||||
if ((bool) $user->autosubscribe != $autosubscribe
|
||||
|| (bool) $user->private_stream != $private_stream
|
||||
// XXX: XOR
|
||||
if (($user->autosubscribe ^ $autosubscribe)
|
||||
|| ($user->private_stream ^ $private_stream)
|
||||
|| $user->timezone != $timezone
|
||||
|| $user->language != $language
|
||||
|| $user->subscribe_policy != $subscribe_policy) {
|
||||
|
||||
$original = clone($user);
|
||||
|
||||
$user->autosubscribe = $autosubscribe;
|
||||
@@ -412,6 +378,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||
}
|
||||
|
||||
if (common_config('location', 'share') == 'user') {
|
||||
|
||||
$exists = false;
|
||||
|
||||
$prefs = User_location_prefs::getKV('user_id', $this->scoped->getID());
|
||||
@@ -426,7 +393,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||
$orig = clone($prefs);
|
||||
}
|
||||
|
||||
$prefs->share_location = $this->boolean('sharelocation');
|
||||
$prefs->share_location = $this->booleanintstring('sharelocation');
|
||||
|
||||
if ($exists) {
|
||||
$result = $prefs->update($orig);
|
||||
@@ -462,11 +429,11 @@ class ProfilesettingsAction extends SettingsAction
|
||||
|
||||
// TRANS: Confirmation shown when user profile settings are saved.
|
||||
return _('Settings saved.');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function showAside()
|
||||
{
|
||||
function showAside() {
|
||||
$this->elementStart('div', array('id' => 'aside_primary',
|
||||
'class' => 'aside'));
|
||||
|
||||
@@ -476,32 +443,26 @@ class ProfilesettingsAction extends SettingsAction
|
||||
if (Event::handle('StartProfileSettingsActions', array($this))) {
|
||||
if ($this->scoped->hasRight(Right::BACKUPACCOUNT)) {
|
||||
$this->elementStart('li');
|
||||
$this->element(
|
||||
'a',
|
||||
['href' => common_local_url('backupaccount')],
|
||||
// TRANS: Option in profile settings to create a backup of the account of the currently logged in user.
|
||||
_('Backup account')
|
||||
);
|
||||
$this->element('a',
|
||||
array('href' => common_local_url('backupaccount')),
|
||||
// TRANS: Option in profile settings to create a backup of the account of the currently logged in user.
|
||||
_('Backup account'));
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
if ($this->scoped->hasRight(Right::DELETEACCOUNT)) {
|
||||
$this->elementStart('li');
|
||||
$this->element(
|
||||
'a',
|
||||
['href' => common_local_url('deleteaccount')],
|
||||
// TRANS: Option in profile settings to delete the account of the currently logged in user.
|
||||
_('Delete account')
|
||||
);
|
||||
$this->element('a',
|
||||
array('href' => common_local_url('deleteaccount')),
|
||||
// TRANS: Option in profile settings to delete the account of the currently logged in user.
|
||||
_('Delete account'));
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
if ($this->scoped->hasRight(Right::RESTOREACCOUNT)) {
|
||||
$this->elementStart('li');
|
||||
$this->element(
|
||||
'a',
|
||||
['href' => common_local_url('restoreaccount')],
|
||||
// TRANS: Option in profile settings to restore the account of the currently logged in user from a backup.
|
||||
_('Restore account')
|
||||
);
|
||||
$this->element('a',
|
||||
array('href' => common_local_url('restoreaccount')),
|
||||
// TRANS: Option in profile settings to restore the account of the currently logged in user from a backup.
|
||||
_('Restore account'));
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
Event::handle('EndProfileSettingsActions', array($this));
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/account/togglepeopletag.php';
|
||||
require_once INSTALLDIR . '/lib/togglepeopletag.php';
|
||||
|
||||
/**
|
||||
* Subscription action
|
||||
|
||||
+75
-73
@@ -1,45 +1,53 @@
|
||||
<?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
|
||||
*
|
||||
* Action for showing profiles self-tagged with a given tag
|
||||
*
|
||||
* 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
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* This class outputs a paginated list of profiles self-tagged with a given tag
|
||||
*
|
||||
* @category Output
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Output
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*
|
||||
* @see Action
|
||||
* @see Action
|
||||
*/
|
||||
class SelftagAction extends Action
|
||||
{
|
||||
public $tag = null;
|
||||
public $page = null;
|
||||
var $tag = null;
|
||||
var $page = null;
|
||||
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
@@ -49,7 +57,7 @@ class SelftagAction extends Action
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
public function prepare(array $args = [])
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
@@ -58,10 +66,8 @@ class SelftagAction extends Action
|
||||
if (!common_valid_profile_tag($this->tag)) {
|
||||
// TRANS: Client error displayed when trying to list a profile with an invalid list.
|
||||
// TRANS: %s is the invalid list name.
|
||||
$this->clientError(sprintf(
|
||||
_('Not a valid list: %s.'),
|
||||
$this->tag
|
||||
));
|
||||
$this->clientError(sprintf(_('Not a valid list: %s.'),
|
||||
$this->tag));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -77,7 +83,7 @@ class SelftagAction extends Action
|
||||
*
|
||||
* @return void is read only action?
|
||||
*/
|
||||
public function handle()
|
||||
function handle()
|
||||
{
|
||||
parent::handle();
|
||||
$this->showPage();
|
||||
@@ -88,50 +94,49 @@ class SelftagAction extends Action
|
||||
* people tag and page, initalizes a ProfileList widget, and displays
|
||||
* it to the user.
|
||||
*/
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
$profile = new Profile();
|
||||
|
||||
$profile->_join .= "\n" . <<<'END'
|
||||
INNER JOIN profile_list ON profile.id = profile_list.tagger
|
||||
LEFT JOIN profile_role ON profile.id = profile_role.profile_id
|
||||
END;
|
||||
|
||||
$profile->whereAdd(sprintf(
|
||||
"profile_list.tag = '%s'",
|
||||
$profile->escape($this->tag)
|
||||
));
|
||||
$profile->whereAdd("COALESCE(profile_role.role, '') <> 'silenced'");
|
||||
|
||||
$user = common_current_user();
|
||||
if (!empty($user)) {
|
||||
$profile->whereAdd(sprintf(
|
||||
'profile_list.tagger = %d OR profile_list.private IS NOT TRUE',
|
||||
$user->getID()
|
||||
));
|
||||
} else {
|
||||
$profile->whereAdd('profile_list.private IS NOT TRUE');
|
||||
}
|
||||
|
||||
$profile->orderBy('profile_list.modified DESC');
|
||||
|
||||
$offset = ($this->page - 1) * PROFILES_PER_PAGE;
|
||||
$limit = PROFILES_PER_PAGE + 1;
|
||||
|
||||
$profile->limit($offset, $limit);
|
||||
if (common_config('db', 'type') == 'pgsql') {
|
||||
$lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||
} else {
|
||||
$lim = ' LIMIT ' . $offset . ', ' . $limit;
|
||||
}
|
||||
|
||||
$profile->find();
|
||||
// XXX: memcached this
|
||||
|
||||
$qry = 'SELECT profile.* ' .
|
||||
'FROM profile JOIN ( profile_tag, profile_list ) ' .
|
||||
'ON profile.id = profile_tag.tagger ' .
|
||||
'AND profile_tag.tagger = profile_list.tagger ' .
|
||||
'AND profile_list.tag = profile_tag.tag ' .
|
||||
'WHERE profile_tag.tagger = profile_tag.tagged ' .
|
||||
"AND profile_tag.tag = '%s' ";
|
||||
|
||||
$user = common_current_user();
|
||||
if (empty($user)) {
|
||||
$qry .= 'AND profile_list.private = false ';
|
||||
} else {
|
||||
$qry .= 'AND (profile_list.tagger = ' . $user->id .
|
||||
' OR profile_list.private = false) ';
|
||||
}
|
||||
|
||||
$qry .= 'ORDER BY profile_tag.modified DESC%s';
|
||||
|
||||
$profile->query(sprintf($qry, $this->tag, $lim));
|
||||
|
||||
$ptl = new SelfTagProfileList($profile, $this); // pass the ammunition
|
||||
$cnt = $ptl->show();
|
||||
|
||||
$this->pagination(
|
||||
$this->page > 1,
|
||||
$cnt > PROFILES_PER_PAGE,
|
||||
$this->page,
|
||||
'selftag',
|
||||
['tag' => $this->tag]
|
||||
);
|
||||
$this->pagination($this->page > 1,
|
||||
$cnt > PROFILES_PER_PAGE,
|
||||
$this->page,
|
||||
'selftag',
|
||||
array('tag' => $this->tag));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,21 +144,18 @@ class SelftagAction extends Action
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Page title for page showing self tags.
|
||||
// TRANS: %1$s is a tag, %2$d is a page number.
|
||||
return sprintf(
|
||||
_('Users self-tagged with %1$s, page %2$d'),
|
||||
$this->tag,
|
||||
$this->page
|
||||
);
|
||||
return sprintf(_('Users self-tagged with %1$s, page %2$d'),
|
||||
$this->tag, $this->page);
|
||||
}
|
||||
}
|
||||
|
||||
class SelfTagProfileList extends ProfileList
|
||||
{
|
||||
public function newListItem(Profile $target)
|
||||
function newListItem(Profile $target)
|
||||
{
|
||||
return new SelfTagProfileListItem($target, $this->action);
|
||||
}
|
||||
@@ -161,7 +163,7 @@ class SelfTagProfileList extends ProfileList
|
||||
|
||||
class SelfTagProfileListItem extends ProfileListItem
|
||||
{
|
||||
public function linkAttributes()
|
||||
function linkAttributes()
|
||||
{
|
||||
$aAttrs = parent::linkAttributes();
|
||||
|
||||
@@ -172,7 +174,7 @@ class SelfTagProfileListItem extends ProfileListItem
|
||||
return $aAttrs;
|
||||
}
|
||||
|
||||
public function homepageAttributes()
|
||||
function homepageAttributes()
|
||||
{
|
||||
$aAttrs = parent::linkAttributes();
|
||||
|
||||
@@ -183,7 +185,7 @@ class SelfTagProfileListItem extends ProfileListItem
|
||||
return $aAttrs;
|
||||
}
|
||||
|
||||
public function showTags()
|
||||
function showTags()
|
||||
{
|
||||
$selftags = new SelfTagsWidget($this->out, $this->profile, $this->profile);
|
||||
$selftags->show();
|
||||
|
||||
@@ -1,38 +1,44 @@
|
||||
<?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
|
||||
*
|
||||
* Sessions administration panel
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin site sessions
|
||||
*
|
||||
* @category Admin
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Admin
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class SessionsadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -41,10 +47,10 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for the sessions administration panel.
|
||||
return _m('TITLE', 'Sessions');
|
||||
return _m('TITLE','Sessions');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +58,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for the sessions administration panel.
|
||||
return _('Session settings for this StatusNet site');
|
||||
@@ -63,7 +69,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showForm()
|
||||
function showForm()
|
||||
{
|
||||
$form = new SessionsAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -75,7 +81,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function saveSettings()
|
||||
function saveSettings()
|
||||
{
|
||||
static $booleans = array('sessions' => array('handle', 'debug'));
|
||||
|
||||
@@ -95,7 +101,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('START TRANSACTION');
|
||||
$config->query('BEGIN');
|
||||
|
||||
foreach ($booleans as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -108,7 +114,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
return;
|
||||
}
|
||||
|
||||
public function validate(&$values)
|
||||
function validate(&$values)
|
||||
{
|
||||
// stub
|
||||
}
|
||||
@@ -122,7 +128,7 @@ class SessionsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
public function id()
|
||||
function id()
|
||||
{
|
||||
return 'sessionsadminpanel';
|
||||
}
|
||||
@@ -132,7 +138,7 @@ class SessionsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
public function formClass()
|
||||
function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -142,7 +148,7 @@ class SessionsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
public function action()
|
||||
function action()
|
||||
{
|
||||
return common_local_url('sessionsadminpanel');
|
||||
}
|
||||
@@ -152,37 +158,31 @@ class SessionsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formData()
|
||||
function formData()
|
||||
{
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_user_sessions'));
|
||||
// TRANS: Fieldset legend on the sessions administration panel.
|
||||
$this->out->element('legend', null, _m('LEGEND', 'Sessions'));
|
||||
$this->out->element('legend', null, _m('LEGEND','Sessions'));
|
||||
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
// TRANS: Checkbox title on the sessions administration panel.
|
||||
// TRANS: Indicates if StatusNet should handle session administration.
|
||||
$this->out->checkbox(
|
||||
'handle',
|
||||
_('Handle sessions'),
|
||||
(bool) $this->value('handle', 'sessions'),
|
||||
// TRANS: Checkbox title on the sessions administration panel.
|
||||
// TRANS: Indicates if StatusNet should handle session administration.
|
||||
_('Handle sessions ourselves.')
|
||||
);
|
||||
$this->out->checkbox('handle', _('Handle sessions'),
|
||||
(bool) $this->value('handle', 'sessions'),
|
||||
// TRANS: Checkbox title on the sessions administration panel.
|
||||
// TRANS: Indicates if StatusNet should handle session administration.
|
||||
_('Handle sessions ourselves.'));
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
// TRANS: Checkbox label on the sessions administration panel.
|
||||
// TRANS: Indicates if StatusNet should write session debugging output.
|
||||
$this->out->checkbox(
|
||||
'debug',
|
||||
_('Session debugging'),
|
||||
(bool) $this->value('debug', 'sessions'),
|
||||
// TRANS: Checkbox title on the sessions administration panel.
|
||||
_('Enable debugging output for sessions.')
|
||||
);
|
||||
$this->out->checkbox('debug', _('Session debugging'),
|
||||
(bool) $this->value('debug', 'sessions'),
|
||||
// TRANS: Checkbox title on the sessions administration panel.
|
||||
_('Enable debugging output for sessions.'));
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@@ -195,16 +195,14 @@ class SessionsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formActions()
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit(
|
||||
'submit',
|
||||
// TRANS: Submit button text on the sessions administration panel.
|
||||
_m('BUTTON', 'Save'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Title for submit button on the sessions administration panel.
|
||||
_('Save session settings')
|
||||
);
|
||||
$this->out->submit('submit',
|
||||
// TRANS: Submit button text on the sessions administration panel.
|
||||
_m('BUTTON','Save'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Title for submit button on the sessions administration panel.
|
||||
_('Save session settings'));
|
||||
}
|
||||
}
|
||||
|
||||
+87
-128
@@ -1,54 +1,60 @@
|
||||
<?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
|
||||
*
|
||||
* Show an OAuth application
|
||||
*
|
||||
* 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 Application
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an OAuth application
|
||||
*
|
||||
* @category Application
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Application
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ShowApplicationAction extends Action
|
||||
{
|
||||
/**
|
||||
* Application to show
|
||||
*/
|
||||
public $application = null;
|
||||
var $application = null;
|
||||
|
||||
/**
|
||||
* User who owns the app
|
||||
*/
|
||||
public $owner = null;
|
||||
var $owner = null;
|
||||
|
||||
public $msg = null;
|
||||
var $msg = null;
|
||||
|
||||
public $success = null;
|
||||
var $success = null;
|
||||
|
||||
/**
|
||||
* Load attributes based on database arguments
|
||||
@@ -59,7 +65,7 @@ class ShowApplicationAction extends Action
|
||||
*
|
||||
* @return success flag
|
||||
*/
|
||||
public function prepare(array $args = [])
|
||||
function prepare(array $args = array())
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
@@ -95,7 +101,7 @@ class ShowApplicationAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
function handle()
|
||||
{
|
||||
parent::handle();
|
||||
|
||||
@@ -121,21 +127,21 @@ class ShowApplicationAction extends Action
|
||||
*
|
||||
* @return string title of the page
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
if (!empty($this->application->name)) {
|
||||
return 'Application: ' . $this->application->name;
|
||||
}
|
||||
}
|
||||
|
||||
public function showPageNotice()
|
||||
function showPageNotice()
|
||||
{
|
||||
if (!empty($this->msg)) {
|
||||
$this->element('div', ($this->success) ? 'success' : 'error', $this->msg);
|
||||
}
|
||||
}
|
||||
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
$cur = common_current_user();
|
||||
|
||||
@@ -145,38 +151,21 @@ class ShowApplicationAction extends Action
|
||||
// TRANS: Header on the OAuth application page.
|
||||
$this->element('h2', null, _('Application profile'));
|
||||
if (!empty($this->application->icon)) {
|
||||
$this->element(
|
||||
'img',
|
||||
[
|
||||
'src' => $this->application->icon,
|
||||
'class' => 'u-photo logo entity_depiction',
|
||||
]
|
||||
);
|
||||
$this->element('img', array('src' => $this->application->icon,
|
||||
'class' => 'u-photo logo entity_depiction'));
|
||||
}
|
||||
|
||||
$this->element(
|
||||
'a',
|
||||
[
|
||||
'href' => $this->application->source_url,
|
||||
'class' => 'u-url p-name entity_fn',
|
||||
],
|
||||
$this->application->name
|
||||
);
|
||||
$this->element('a', array('href' => $this->application->source_url,
|
||||
'class' => 'u-url p-name entity_fn'),
|
||||
$this->application->name);
|
||||
|
||||
$this->element(
|
||||
'a',
|
||||
[
|
||||
'href' => $this->application->homepage,
|
||||
'class' => 'u-url entity_org',
|
||||
],
|
||||
$this->application->organization
|
||||
);
|
||||
$this->element('a', array('href' => $this->application->homepage,
|
||||
'class' => 'u-url entity_org'),
|
||||
$this->application->organization);
|
||||
|
||||
$this->element(
|
||||
'div',
|
||||
'note entity_note',
|
||||
$this->application->description
|
||||
);
|
||||
$this->element('div',
|
||||
'note entity_note',
|
||||
$this->application->description);
|
||||
|
||||
$this->elementStart('div', 'entity_statistics');
|
||||
$defaultAccess = ($this->application->access_type & Oauth_application::$writeAccess)
|
||||
@@ -194,10 +183,10 @@ class ShowApplicationAction extends Action
|
||||
_m('Created by %1$s - %2$s access by default - %3$d user',
|
||||
'Created by %1$s - %2$s access by default - %3$d users',
|
||||
$userCnt),
|
||||
$profile->getBestName(),
|
||||
$defaultAccess,
|
||||
$userCnt
|
||||
));
|
||||
$profile->getBestName(),
|
||||
$defaultAccess,
|
||||
$userCnt
|
||||
));
|
||||
$this->elementEnd('div');
|
||||
|
||||
$this->elementEnd('div');
|
||||
@@ -207,70 +196,47 @@ class ShowApplicationAction extends Action
|
||||
$this->element('h2', null, _('Application actions'));
|
||||
$this->elementStart('ul');
|
||||
$this->elementStart('li', 'entity_edit');
|
||||
$this->element(
|
||||
'a',
|
||||
[
|
||||
'href' => common_local_url(
|
||||
'editapplication',
|
||||
['id' => $this->application->id]
|
||||
)
|
||||
],
|
||||
// TRANS: Link text to edit application on the OAuth application page.
|
||||
_m('EDITAPP', 'Edit')
|
||||
);
|
||||
$this->element('a',
|
||||
array('href' => common_local_url('editapplication',
|
||||
array('id' => $this->application->id))),
|
||||
// TRANS: Link text to edit application on the OAuth application page.
|
||||
_m('EDITAPP','Edit'));
|
||||
$this->elementEnd('li');
|
||||
|
||||
$this->elementStart('li', 'entity_reset_keysecret');
|
||||
$this->elementStart(
|
||||
'form',
|
||||
[
|
||||
'id' => 'form_reset_key',
|
||||
'class' => 'form_reset_key',
|
||||
'method' => 'POST',
|
||||
'action' => common_local_url(
|
||||
'showapplication',
|
||||
['id' => $this->application->id]
|
||||
),
|
||||
]
|
||||
);
|
||||
$this->elementStart('form', array(
|
||||
'id' => 'form_reset_key',
|
||||
'class' => 'form_reset_key',
|
||||
'method' => 'POST',
|
||||
'action' => common_local_url('showapplication',
|
||||
array('id' => $this->application->id))));
|
||||
$this->elementStart('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
$this->element(
|
||||
'input',
|
||||
[
|
||||
'type' => 'submit',
|
||||
'id' => 'reset',
|
||||
'name' => 'reset',
|
||||
'class' => 'submit',
|
||||
// TRANS: Button text on the OAuth application page.
|
||||
// TRANS: Resets the OAuth consumer key and secret.
|
||||
'value' => _('Reset key & secret'),
|
||||
'onClick' => 'return confirmReset()',
|
||||
]
|
||||
);
|
||||
$this->element('input', array('type' => 'submit',
|
||||
'id' => 'reset',
|
||||
'name' => 'reset',
|
||||
'class' => 'submit',
|
||||
// TRANS: Button text on the OAuth application page.
|
||||
// TRANS: Resets the OAuth consumer key and secret.
|
||||
'value' => _('Reset key & secret'),
|
||||
'onClick' => 'return confirmReset()'));
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
$this->elementEnd('li');
|
||||
|
||||
$this->elementStart('li', 'entity_delete');
|
||||
$this->elementStart(
|
||||
'form',
|
||||
[
|
||||
'id' => 'form_delete_application',
|
||||
'class' => 'form_delete_application',
|
||||
'method' => 'POST',
|
||||
'action' => common_local_url(
|
||||
'deleteapplication',
|
||||
['id' => $this->application->id]
|
||||
),
|
||||
]
|
||||
);
|
||||
$this->elementStart('form', array(
|
||||
'id' => 'form_delete_application',
|
||||
'class' => 'form_delete_application',
|
||||
'method' => 'POST',
|
||||
'action' => common_local_url('deleteapplication',
|
||||
array('id' => $this->application->id))));
|
||||
|
||||
$this->elementStart('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
// TRANS: Submit button text the OAuth application page to delete an application.
|
||||
$this->submit('delete', _m('BUTTON', 'Delete'));
|
||||
$this->submit('delete', _m('BUTTON','Delete'));
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
$this->elementEnd('li');
|
||||
@@ -300,23 +266,16 @@ class ShowApplicationAction extends Action
|
||||
$this->element('dd', null, common_local_url('ApiOAuthAuthorize'));
|
||||
$this->elementEnd('dl');
|
||||
|
||||
$this->element(
|
||||
'p',
|
||||
'note',
|
||||
$this->element('p', 'note',
|
||||
// TRANS: Note on the OAuth application page about signature support.
|
||||
_('Note: HMAC-SHA1 signatures are supported. The plaintext signature method is not supported.')
|
||||
);
|
||||
_('Note: HMAC-SHA1 signatures are supported. The plaintext signature method is not supported.'));
|
||||
$this->elementEnd('div');
|
||||
|
||||
$this->elementStart('p', array('id' => 'application_action'));
|
||||
$this->element(
|
||||
'a',
|
||||
[
|
||||
'href' => common_local_url('oauthappssettings'),
|
||||
'class' => 'more',
|
||||
],
|
||||
'View your applications'
|
||||
);
|
||||
$this->element('a',
|
||||
array('href' => common_local_url('oauthappssettings'),
|
||||
'class' => 'more'),
|
||||
'View your applications');
|
||||
$this->elementEnd('p');
|
||||
}
|
||||
|
||||
@@ -325,7 +284,7 @@ class ShowApplicationAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showScripts()
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
|
||||
@@ -346,9 +305,9 @@ class ShowApplicationAction extends Action
|
||||
* XXX: Should this be moved to its own page with a confirm?
|
||||
*
|
||||
*/
|
||||
public function resetKey()
|
||||
function resetKey()
|
||||
{
|
||||
$this->application->query('START TRANSACTION');
|
||||
$this->application->query('BEGIN');
|
||||
|
||||
$oauser = new Oauth_application_user();
|
||||
$oauser->application_id = $this->application->id;
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!defined('GNUSOCIAL')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/notices/noticelist.php';
|
||||
require_once INSTALLDIR.'/lib/noticelist.php';
|
||||
|
||||
/**
|
||||
* Show a single notice
|
||||
|
||||
+117
-192
@@ -1,31 +1,34 @@
|
||||
<?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
|
||||
*
|
||||
* User profile page
|
||||
*
|
||||
* 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 Personal
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* User profile page
|
||||
@@ -36,10 +39,11 @@ defined('GNUSOCIAL') || die();
|
||||
* It shows a stream of the user's posts, plus lots of profile info, links
|
||||
* to subscriptions and stuff, etc.
|
||||
*
|
||||
* @category Personal
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Personal
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ShowstreamAction extends NoticestreamAction
|
||||
{
|
||||
@@ -54,7 +58,7 @@ class ShowstreamAction extends NoticestreamAction
|
||||
return $stream;
|
||||
}
|
||||
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
$base = $this->target->getFancyName();
|
||||
if (!empty($this->tag)) {
|
||||
@@ -73,11 +77,9 @@ class ShowstreamAction extends NoticestreamAction
|
||||
} else {
|
||||
// TRANS: Extended page title showing tagged notices in one user's timeline.
|
||||
// TRANS: %1$s is the username, %2$d is the page number.
|
||||
return sprintf(
|
||||
_('Notices by %1$s, page %2$d'),
|
||||
$base,
|
||||
$this->page
|
||||
);
|
||||
return sprintf(_('Notices by %1$s, page %2$d'),
|
||||
$base,
|
||||
$this->page);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,120 +89,79 @@ class ShowstreamAction extends NoticestreamAction
|
||||
$this->showNotices();
|
||||
}
|
||||
|
||||
public function showProfileBlock()
|
||||
function showProfileBlock()
|
||||
{
|
||||
$block = new AccountProfileBlock($this, $this->target);
|
||||
$block->show();
|
||||
}
|
||||
|
||||
public function showPageNoticeBlock()
|
||||
function showPageNoticeBlock()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public function getFeeds()
|
||||
function getFeeds()
|
||||
{
|
||||
if (!empty($this->tag)) {
|
||||
return [new Feed(
|
||||
Feed::RSS1,
|
||||
common_local_url(
|
||||
'userrss',
|
||||
[
|
||||
'nickname' => $this->target->getNickname(),
|
||||
'tag' => $this->tag,
|
||||
]
|
||||
),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %1$s is a user nickname, %2$s is a hashtag.
|
||||
sprintf(
|
||||
_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
|
||||
$this->target->getNickname(),
|
||||
$this->tag
|
||||
)
|
||||
)];
|
||||
return array(new Feed(Feed::RSS1,
|
||||
common_local_url('userrss',
|
||||
array('nickname' => $this->target->getNickname(),
|
||||
'tag' => $this->tag)),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %1$s is a user nickname, %2$s is a hashtag.
|
||||
sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
|
||||
$this->target->getNickname(), $this->tag)));
|
||||
}
|
||||
|
||||
if (!$this->target->isLocal()) {
|
||||
// remote profiles at least have Atom, but we can't guarantee anything else
|
||||
return [new Feed(
|
||||
Feed::ATOM,
|
||||
$this->target->getAtomFeed(),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(
|
||||
_('Notice feed for %s (Atom)'),
|
||||
$this->target->getNickname()
|
||||
)
|
||||
)];
|
||||
return array(
|
||||
new Feed(Feed::ATOM,
|
||||
$this->target->getAtomFeed(),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(_('Notice feed for %s (Atom)'),
|
||||
$this->target->getNickname()))
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
new Feed(
|
||||
Feed::JSON,
|
||||
common_local_url(
|
||||
'ApiTimelineUser',
|
||||
[
|
||||
'id' => $this->target->getID(),
|
||||
'format' => 'as',
|
||||
]
|
||||
),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(
|
||||
_('Notice feed for %s (Activity Streams JSON)'),
|
||||
$this->target->getNickname()
|
||||
)
|
||||
),
|
||||
new Feed(
|
||||
Feed::RSS1,
|
||||
common_local_url(
|
||||
'userrss',
|
||||
['nickname' => $this->target->getNickname()]
|
||||
),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(
|
||||
_('Notice feed for %s (RSS 1.0)'),
|
||||
$this->target->getNickname()
|
||||
)
|
||||
),
|
||||
new Feed(
|
||||
Feed::RSS2,
|
||||
common_local_url(
|
||||
'ApiTimelineUser',
|
||||
[
|
||||
'id' => $this->target->getID(),
|
||||
'format' => 'rss',
|
||||
]
|
||||
),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(
|
||||
_('Notice feed for %s (RSS 2.0)'),
|
||||
$this->target->getNickname()
|
||||
)
|
||||
),
|
||||
new Feed(
|
||||
Feed::ATOM,
|
||||
$this->target->getAtomFeed(),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(
|
||||
_('Notice feed for %s (Atom)'),
|
||||
$this->target->getNickname()
|
||||
)
|
||||
),
|
||||
new Feed(
|
||||
Feed::FOAF,
|
||||
common_local_url(
|
||||
'foaf',
|
||||
['nickname' => $this->target->getNickname()]
|
||||
),
|
||||
// TRANS: Title for link to notice feed. FOAF stands for Friend of a Friend.
|
||||
// TRANS: More information at http://www.foaf-project.org. %s is a user nickname.
|
||||
sprintf(_('FOAF for %s'), $this->target->getNickname())
|
||||
)
|
||||
];
|
||||
return array(new Feed(Feed::JSON,
|
||||
common_local_url('ApiTimelineUser',
|
||||
array(
|
||||
'id' => $this->target->getID(),
|
||||
'format' => 'as')),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(_('Notice feed for %s (Activity Streams JSON)'),
|
||||
$this->target->getNickname())),
|
||||
new Feed(Feed::RSS1,
|
||||
common_local_url('userrss',
|
||||
array('nickname' => $this->target->getNickname())),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(_('Notice feed for %s (RSS 1.0)'),
|
||||
$this->target->getNickname())),
|
||||
new Feed(Feed::RSS2,
|
||||
common_local_url('ApiTimelineUser',
|
||||
array(
|
||||
'id' => $this->target->getID(),
|
||||
'format' => 'rss')),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(_('Notice feed for %s (RSS 2.0)'),
|
||||
$this->target->getNickname())),
|
||||
new Feed(Feed::ATOM,
|
||||
$this->target->getAtomFeed(),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(_('Notice feed for %s (Atom)'),
|
||||
$this->target->getNickname())),
|
||||
new Feed(Feed::FOAF,
|
||||
common_local_url('foaf', array('nickname' =>
|
||||
$this->target->getNickname())),
|
||||
// TRANS: Title for link to notice feed. FOAF stands for Friend of a Friend.
|
||||
// TRANS: More information at http://www.foaf-project.org. %s is a user nickname.
|
||||
sprintf(_('FOAF for %s'), $this->target->getNickname())));
|
||||
}
|
||||
|
||||
public function extraHeaders()
|
||||
@@ -209,60 +170,33 @@ class ShowstreamAction extends NoticestreamAction
|
||||
// Publish all the rel="me" in the HTTP headers on our main profile page
|
||||
if (get_class($this) == 'ShowstreamAction') {
|
||||
foreach ($this->target->getRelMes() as $relMe) {
|
||||
header('Link: <' . htmlspecialchars($relMe['href']) . '>; rel="me"', false);
|
||||
header('Link: <'.htmlspecialchars($relMe['href']).'>; rel="me"', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function extraHead()
|
||||
function extraHead()
|
||||
{
|
||||
if ($this->target->isSilenced() || !$this->target->isLocal()) {
|
||||
$this->element(
|
||||
'meta',
|
||||
[
|
||||
'name' => 'robots',
|
||||
'content' => 'noindex',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->target->bio) {
|
||||
$this->element(
|
||||
'meta',
|
||||
[
|
||||
'name' => 'description',
|
||||
'content' => $this->target->getDescription(),
|
||||
]
|
||||
);
|
||||
$this->element('meta', array('name' => 'description',
|
||||
'content' => $this->target->getDescription()));
|
||||
}
|
||||
|
||||
$rsd = common_local_url(
|
||||
'rsd',
|
||||
['nickname' => $this->target->getNickname()]
|
||||
);
|
||||
$rsd = common_local_url('rsd',
|
||||
array('nickname' => $this->target->getNickname()));
|
||||
|
||||
// RSD, http://tales.phrasewise.com/rfc/rsd
|
||||
$this->element(
|
||||
'link',
|
||||
[
|
||||
'rel' => 'EditURI',
|
||||
'type' => 'application/rsd+xml',
|
||||
'href' => $rsd,
|
||||
]
|
||||
);
|
||||
$this->element('link', array('rel' => 'EditURI',
|
||||
'type' => 'application/rsd+xml',
|
||||
'href' => $rsd));
|
||||
|
||||
if ($this->page != 1) {
|
||||
$this->element(
|
||||
'link',
|
||||
[
|
||||
'rel' => 'canonical',
|
||||
'href' => $this->target->getUrl(),
|
||||
]
|
||||
);
|
||||
$this->element('link', array('rel' => 'canonical',
|
||||
'href' => $this->target->getUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
public function showEmptyListMessage()
|
||||
function showEmptyListMessage()
|
||||
{
|
||||
// TRANS: First sentence of empty list message for a timeline. $1%s is a user nickname.
|
||||
$message = sprintf(_('This is the timeline for %1$s, but %1$s hasn\'t posted anything yet.'), $this->target->getNickname()) . ' ';
|
||||
@@ -276,7 +210,8 @@ class ShowstreamAction extends NoticestreamAction
|
||||
// TRANS: This message contains a Markdown link. Keep "](" together.
|
||||
$message .= sprintf(_('You can try to nudge %1$s or [post something to them](%%%%action.newnotice%%%%?status_textarea=%2$s).'), $this->target->getNickname(), '@' . $this->target->getNickname());
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// TRANS: Second sentence of empty message for anonymous users. %s is a user nickname.
|
||||
// TRANS: This message contains a Markdown link. Keep "](" together.
|
||||
$message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->getNickname());
|
||||
@@ -287,7 +222,7 @@ class ShowstreamAction extends NoticestreamAction
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
public function showNotices()
|
||||
function showNotices()
|
||||
{
|
||||
$pnl = new PrimaryNoticeList($this->notice, $this);
|
||||
$cnt = $pnl->show();
|
||||
@@ -297,51 +232,41 @@ class ShowstreamAction extends NoticestreamAction
|
||||
|
||||
// either nickname or id will be used, depending on which action (showstream, userbyid...)
|
||||
$args = array('nickname' => $this->target->getNickname(), 'id' => $this->target->getID());
|
||||
if (!empty($this->tag)) {
|
||||
if (!empty($this->tag))
|
||||
{
|
||||
$args['tag'] = $this->tag;
|
||||
}
|
||||
$this->pagination(
|
||||
$this->page > 1,
|
||||
$cnt > NOTICES_PER_PAGE,
|
||||
$this->page,
|
||||
$this->getActionName(),
|
||||
$args
|
||||
);
|
||||
$this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
|
||||
$this->getActionName(), $args);
|
||||
}
|
||||
|
||||
public function showAnonymousMessage()
|
||||
function showAnonymousMessage()
|
||||
{
|
||||
if (!(common_config('site', 'closed') || common_config('site', 'inviteonly'))) {
|
||||
if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
|
||||
// TRANS: Announcement for anonymous users showing a timeline if site registrations are open.
|
||||
// TRANS: This message contains a Markdown link. Keep "](" together.
|
||||
$m = sprintf(
|
||||
_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
|
||||
'[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
|
||||
$this->target->getNickname(),
|
||||
$this->target->getNickname()
|
||||
);
|
||||
$m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
|
||||
'[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
|
||||
$this->target->getNickname(), $this->target->getNickname());
|
||||
} else {
|
||||
// TRANS: Announcement for anonymous users showing a timeline if site registrations are closed or invite only.
|
||||
// TRANS: This message contains a Markdown link. Keep "](" together.
|
||||
$m = sprintf(
|
||||
_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
'based on the Free Software [StatusNet](http://status.net/) tool.'),
|
||||
$this->target->getNickname(),
|
||||
$this->target->getNickname()
|
||||
);
|
||||
$m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
'based on the Free Software [StatusNet](http://status.net/) tool.'),
|
||||
$this->target->getNickname(), $this->target->getNickname());
|
||||
}
|
||||
$this->elementStart('div', array('id' => 'anon_notice'));
|
||||
$this->raw(common_markup_to_html($m));
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
public function noticeFormOptions()
|
||||
function noticeFormOptions()
|
||||
{
|
||||
$options = parent::noticeFormOptions();
|
||||
|
||||
if (!$this->scoped instanceof Profile || !$this->scoped->sameAs($this->target)) {
|
||||
$options['to_profile'] = $this->target;
|
||||
$options['to_profile'] = $this->target;
|
||||
}
|
||||
|
||||
return $options;
|
||||
|
||||
+96
-120
@@ -1,42 +1,48 @@
|
||||
<?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
|
||||
*
|
||||
* Site administration panel
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Administer site settings
|
||||
*
|
||||
* @category Admin
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Admin
|
||||
* @package StatusNet
|
||||
* @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 SiteadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -45,10 +51,10 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for site administration panel.
|
||||
return _m('TITLE', 'Site');
|
||||
return _m('TITLE','Site');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +62,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for site administration panel.
|
||||
return _m('Basic settings for this StatusNet site');
|
||||
@@ -67,7 +73,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showForm()
|
||||
function showForm()
|
||||
{
|
||||
$form = new SiteAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -79,7 +85,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function saveSettings()
|
||||
function saveSettings()
|
||||
{
|
||||
static $settings = array(
|
||||
'site' => array(
|
||||
@@ -113,7 +119,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('START TRANSACTION');
|
||||
$config->query('BEGIN');
|
||||
|
||||
foreach ($settings as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -126,7 +132,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
return;
|
||||
}
|
||||
|
||||
public function validate(&$values)
|
||||
function validate(&$values)
|
||||
{
|
||||
// Validate site name
|
||||
|
||||
@@ -202,7 +208,7 @@ class SiteAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
public function id()
|
||||
function id()
|
||||
{
|
||||
return 'form_site_admin_panel';
|
||||
}
|
||||
@@ -212,7 +218,7 @@ class SiteAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
public function formClass()
|
||||
function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -222,7 +228,7 @@ class SiteAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
public function action()
|
||||
function action()
|
||||
{
|
||||
return common_local_url('siteadminpanel');
|
||||
}
|
||||
@@ -232,49 +238,37 @@ class SiteAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formData()
|
||||
function formData()
|
||||
{
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_admin_general'));
|
||||
// TRANS: Fieldset legend on site settings panel.
|
||||
$this->out->element('legend', null, _m('LEGEND', 'General'));
|
||||
$this->out->element('legend', null, _m('LEGEND','General'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
$this->li();
|
||||
// TRANS: Field label on site settings panel.
|
||||
$this->input(
|
||||
'name',
|
||||
_m('LABEL', 'Site name'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('The name of your site, like "Yourcompany Microblog".')
|
||||
);
|
||||
$this->input('name', _m('LABEL','Site name'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('The name of your site, like "Yourcompany Microblog".'));
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label on site settings panel.
|
||||
$this->input(
|
||||
'broughtby',
|
||||
_m('Brought by'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('Text used for credits link in footer of each page.')
|
||||
);
|
||||
$this->input('broughtby', _m('Brought by'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('Text used for credits link in footer of each page.'));
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label on site settings panel.
|
||||
$this->input(
|
||||
'broughtbyurl',
|
||||
_m('Brought by URL'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('URL used for credits link in footer of each page.')
|
||||
);
|
||||
$this->input('broughtbyurl', _m('Brought by URL'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('URL used for credits link in footer of each page.'));
|
||||
$this->unli();
|
||||
$this->li();
|
||||
// TRANS: Field label on site settings panel.
|
||||
$this->input(
|
||||
'email',
|
||||
_m('Email'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('Contact email address for your site.')
|
||||
);
|
||||
$this->input('email', _m('Email'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('Contact email address for your site.'));
|
||||
$this->unli();
|
||||
$this->out->elementEnd('ul');
|
||||
$this->out->elementEnd('fieldset');
|
||||
@@ -283,7 +277,7 @@ class SiteAdminPanelForm extends AdminForm
|
||||
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_admin_local'));
|
||||
// TRANS: Fieldset legend on site settings panel.
|
||||
$this->out->element('legend', null, _m('LEGEND', 'Local'));
|
||||
$this->out->element('legend', null, _m('LEGEND','Local'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
$timezones = [];
|
||||
|
||||
@@ -295,28 +289,20 @@ class SiteAdminPanelForm extends AdminForm
|
||||
|
||||
$this->li();
|
||||
// TRANS: Dropdown label on site settings panel.
|
||||
$this->out->dropdown(
|
||||
'timezone',
|
||||
_m('Default timezone'),
|
||||
// TRANS: Dropdown title on site settings panel.
|
||||
$timezones,
|
||||
_m('Default timezone for the site; usually UTC.'),
|
||||
true,
|
||||
$this->value('timezone')
|
||||
);
|
||||
$this->out->dropdown('timezone', _m('Default timezone'),
|
||||
// TRANS: Dropdown title on site settings panel.
|
||||
$timezones, _m('Default timezone for the site; usually UTC.'),
|
||||
true, $this->value('timezone'));
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->out->dropdown(
|
||||
'language',
|
||||
// TRANS: Dropdown label on site settings panel.
|
||||
_m('Default language'),
|
||||
get_nice_language_list(),
|
||||
// TRANS: Dropdown title on site settings panel.
|
||||
_m('The site language when autodetection from browser settings is not available.'),
|
||||
false,
|
||||
$this->value('language')
|
||||
);
|
||||
$this->out->dropdown('language',
|
||||
// TRANS: Dropdown label on site settings panel.
|
||||
_m('Default language'),
|
||||
get_nice_language_list(),
|
||||
// TRANS: Dropdown title on site settings panel.
|
||||
_m('The site language when autodetection from browser settings is not available.'),
|
||||
false, $this->value('language'));
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@@ -324,32 +310,28 @@ class SiteAdminPanelForm extends AdminForm
|
||||
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_admin_limits'));
|
||||
// TRANS: Fieldset legend on site settings panel.
|
||||
$this->out->element('legend', null, _m('LEGEND', 'Limits'));
|
||||
$this->out->element('legend', null, _m('LEGEND','Limits'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
$this->li();
|
||||
$this->input(
|
||||
'textlimit',
|
||||
// TRANS: Field label on site settings panel.
|
||||
_m('Text limit'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('Maximum number of characters for notices.')
|
||||
);
|
||||
$this->input('textlimit',
|
||||
// TRANS: Field label on site settings panel.
|
||||
_m('Text limit'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('Maximum number of characters for notices.'));
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'dupelimit',
|
||||
// TRANS: Field label on site settings panel.
|
||||
_m('Dupe limit'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('How long users must wait (in seconds) to post the same thing again.')
|
||||
);
|
||||
$this->input('dupelimit',
|
||||
// TRANS: Field label on site settings panel.
|
||||
_m('Dupe limit'),
|
||||
// TRANS: Field title on site settings panel.
|
||||
_m('How long users must wait (in seconds) to post the same thing again.'));
|
||||
$this->unli();
|
||||
$this->out->elementEnd('ul');
|
||||
$this->out->elementEnd('fieldset');
|
||||
}
|
||||
|
||||
public function showLogo()
|
||||
function showLogo()
|
||||
{
|
||||
$this->out->elementStart('fieldset', ['id' => 'settings_site_logo']);
|
||||
// TRANS: Fieldset legend for form to change logo.
|
||||
@@ -358,23 +340,19 @@ class SiteAdminPanelForm extends AdminForm
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'logo',
|
||||
// TRANS: Field label for GNU social site logo.
|
||||
_m('Site logo'),
|
||||
// TRANS: Title for field label for GNU social site logo.
|
||||
'Logo for the site (full URL).'
|
||||
);
|
||||
$this->input('logo',
|
||||
// TRANS: Field label for GNU social site logo.
|
||||
_m('Site logo'),
|
||||
// TRANS: Title for field label for GNU social site logo.
|
||||
'Logo for the site (full URL).');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'ssllogo',
|
||||
// TRANS: Field label for SSL GNU social site logo.
|
||||
_m('SSL logo'),
|
||||
// TRANS: Title for field label for SSL GNU social site logo.
|
||||
'Logo to show on SSL pages (full URL).'
|
||||
);
|
||||
$this->input('ssllogo',
|
||||
// TRANS: Field label for SSL GNU social site logo.
|
||||
_m('SSL logo'),
|
||||
// TRANS: Title for field label for SSL GNU social site logo.
|
||||
'Logo to show on SSL pages (full URL).');
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@@ -387,16 +365,14 @@ class SiteAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formActions()
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit(
|
||||
'submit',
|
||||
// TRANS: Button text for saving site settings.
|
||||
_m('BUTTON', 'Save'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Button title for saving site settings.
|
||||
_m('Save the site settings.')
|
||||
);
|
||||
$this->out->submit('submit',
|
||||
// TRANS: Button text for saving site settings.
|
||||
_m('BUTTON','Save'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Button title for saving site settings.
|
||||
_m('Save the site settings.'));
|
||||
}
|
||||
}
|
||||
|
||||
+117
-149
@@ -1,39 +1,46 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Settings for SMS.
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* @category Setting
|
||||
* @package GNUsocial
|
||||
* Settings for SMS
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Settings for SMS
|
||||
*
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Settings
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*
|
||||
* @see SettingsAction
|
||||
* @see SettingsAction
|
||||
*/
|
||||
|
||||
class SmssettingsAction extends SettingsAction
|
||||
{
|
||||
protected function doPreparation()
|
||||
@@ -49,7 +56,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title for SMS settings.
|
||||
return _('SMS settings');
|
||||
@@ -60,7 +67,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// XXX: For consistency of parameters in messages, this should be a
|
||||
// regular parameters, replaced with sprintf().
|
||||
@@ -69,7 +76,7 @@ class SmssettingsAction extends SettingsAction
|
||||
return _('You can receive SMS messages through email from %%site.name%%.');
|
||||
}
|
||||
|
||||
public function showScripts()
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
$this->autofocus('sms');
|
||||
@@ -83,7 +90,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
@@ -98,107 +105,82 @@ class SmssettingsAction extends SettingsAction
|
||||
$this->element('legend', null, _('SMS address'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
if (!$user->isNull('sms')) {
|
||||
if ($user->sms) {
|
||||
$carrier = $user->getCarrier();
|
||||
$this->element(
|
||||
'p',
|
||||
'form_confirmed',
|
||||
$user->sms . ' (' . $carrier->name . ')'
|
||||
);
|
||||
$this->element(
|
||||
'p',
|
||||
'form_guide',
|
||||
// TRANS: Form guide in SMS settings form.
|
||||
_('Current confirmed SMS-enabled phone number.')
|
||||
);
|
||||
$this->element('p', 'form_confirmed',
|
||||
$user->sms . ' (' . $carrier->name . ')');
|
||||
$this->element('p', 'form_guide',
|
||||
// TRANS: Form guide in SMS settings form.
|
||||
_('Current confirmed SMS-enabled phone number.'));
|
||||
$this->hidden('sms', $user->sms);
|
||||
$this->hidden('carrier', $user->carrier);
|
||||
// TRANS: Button label to remove a confirmed SMS address.
|
||||
$this->submit('remove', _m('BUTTON', 'Remove'));
|
||||
$this->submit('remove', _m('BUTTON','Remove'));
|
||||
} else {
|
||||
try {
|
||||
$confirm = $this->getConfirmation();
|
||||
$carrier = Sms_carrier::getKV($confirm->address_extra);
|
||||
$this->element(
|
||||
'p',
|
||||
'form_unconfirmed',
|
||||
$confirm->address . ' (' . $carrier->name . ')'
|
||||
);
|
||||
$this->element(
|
||||
'p',
|
||||
'form_guide',
|
||||
// TRANS: Form guide in IM settings form.
|
||||
_('Awaiting confirmation on this phone number.')
|
||||
);
|
||||
$this->element('p', 'form_unconfirmed',
|
||||
$confirm->address . ' (' . $carrier->name . ')');
|
||||
$this->element('p', 'form_guide',
|
||||
// TRANS: Form guide in IM settings form.
|
||||
_('Awaiting confirmation on this phone number.'));
|
||||
$this->hidden('sms', $confirm->address);
|
||||
$this->hidden('carrier', $confirm->address_extra);
|
||||
// TRANS: Button label to cancel a SMS address confirmation procedure.
|
||||
$this->submit('cancel', _m('BUTTON', 'Cancel'));
|
||||
$this->submit('cancel', _m('BUTTON','Cancel'));
|
||||
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label for SMS address input in SMS settings form.
|
||||
$this->input(
|
||||
'code',
|
||||
_('Confirmation code'),
|
||||
null,
|
||||
// TRANS: Form field instructions in SMS settings form.
|
||||
_('Enter the code you received on your phone.')
|
||||
);
|
||||
$this->input('code', _('Confirmation code'), null,
|
||||
// TRANS: Form field instructions in SMS settings form.
|
||||
_('Enter the code you received on your phone.'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
// TRANS: Button label to confirm SMS confirmation code in SMS settings.
|
||||
$this->submit('confirm', _m('BUTTON', 'Confirm'));
|
||||
$this->submit('confirm', _m('BUTTON','Confirm'));
|
||||
} catch (NoResultException $e) {
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
// TRANS: Field label for SMS phone number input in SMS settings form.
|
||||
$this->input(
|
||||
'sms',
|
||||
_('SMS phone number'),
|
||||
($this->arg('sms') ?: null),
|
||||
// TRANS: SMS phone number input field instructions in SMS settings form.
|
||||
_('Phone number, no punctuation or spaces, ' .
|
||||
'with area code.')
|
||||
);
|
||||
$this->input('sms', _('SMS phone number'),
|
||||
($this->arg('sms')) ? $this->arg('sms') : null,
|
||||
// TRANS: SMS phone number input field instructions in SMS settings form.
|
||||
_('Phone number, no punctuation or spaces, '.
|
||||
'with area code.'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
$this->carrierSelect();
|
||||
// TRANS: Button label for adding a SMS phone number in SMS settings form.
|
||||
$this->submit('add', _m('BUTTON', 'Add'));
|
||||
$this->submit('add', _m('BUTTON','Add'));
|
||||
}
|
||||
}
|
||||
$this->elementEnd('fieldset');
|
||||
|
||||
if (!$user->isNull('sms')) {
|
||||
$this->elementStart('fieldset', ['id' => 'settings_sms_incoming_email']);
|
||||
if ($user->sms) {
|
||||
$this->elementStart('fieldset', array('id' => 'settings_sms_incoming_email'));
|
||||
// XXX: Confused! This is about SMS. Should this message be updated?
|
||||
// TRANS: Form legend for incoming SMS settings form.
|
||||
$this->element('legend', null, _('Incoming email'));
|
||||
|
||||
if (!$user->isNull('incomingemail')) {
|
||||
if ($user->incomingemail) {
|
||||
$this->element('p', 'form_unconfirmed', $user->incomingemail);
|
||||
$this->element(
|
||||
'p',
|
||||
'form_note',
|
||||
// XXX: Confused! This is about SMS. Should this message be updated?
|
||||
// TRANS: Form instructions for incoming SMS e-mail address form in SMS settings.
|
||||
_('Send email to this address to post new notices.')
|
||||
);
|
||||
$this->element('p', 'form_note',
|
||||
// XXX: Confused! This is about SMS. Should this message be updated?
|
||||
// TRANS: Form instructions for incoming SMS e-mail address form in SMS settings.
|
||||
_('Send email to this address to post new notices.'));
|
||||
// TRANS: Button label for removing a set sender SMS e-mail address to post notices from.
|
||||
$this->submit('removeincoming', _m('BUTTON', 'Remove'));
|
||||
$this->submit('removeincoming', _m('BUTTON','Remove'));
|
||||
}
|
||||
|
||||
$this->element(
|
||||
'p',
|
||||
'form_guide',
|
||||
// XXX: Confused! This is about SMS. Should this message be updated?
|
||||
// TRANS: Instructions for incoming SMS e-mail address input form.
|
||||
_('Make a new email address for posting to; ' .
|
||||
'cancels the old one.')
|
||||
);
|
||||
$this->element('p', 'form_guide',
|
||||
// XXX: Confused! This is about SMS. Should this message be updated?
|
||||
// TRANS: Instructions for incoming SMS e-mail address input form.
|
||||
_('Make a new email address for posting to; '.
|
||||
'cancels the old one.'));
|
||||
// TRANS: Button label for adding an SMS e-mail address to send notices from.
|
||||
$this->submit('newincoming', _m('BUTTON', 'New'));
|
||||
$this->submit('newincoming', _m('BUTTON','New'));
|
||||
$this->elementEnd('fieldset');
|
||||
}
|
||||
|
||||
@@ -208,19 +190,17 @@ class SmssettingsAction extends SettingsAction
|
||||
|
||||
$this->elementStart('ul', 'form_data');
|
||||
$this->elementStart('li');
|
||||
$this->checkbox(
|
||||
'smsnotify',
|
||||
// TRANS: Checkbox label in SMS preferences form.
|
||||
_('Send me notices through SMS; ' .
|
||||
'I understand I may incur ' .
|
||||
'exorbitant charges from my carrier.'),
|
||||
$user->smsnotify
|
||||
);
|
||||
$this->checkbox('smsnotify',
|
||||
// TRANS: Checkbox label in SMS preferences form.
|
||||
_('Send me notices through SMS; '.
|
||||
'I understand I may incur '.
|
||||
'exorbitant charges from my carrier.'),
|
||||
$user->smsnotify);
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
|
||||
// TRANS: Button label to save SMS preferences.
|
||||
$this->submit('save', _m('BUTTON', 'Save'));
|
||||
$this->submit('save', _m('BUTTON','Save'));
|
||||
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
@@ -233,7 +213,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @todo very similar to EmailsettingsAction::getConfirmation(); refactor?
|
||||
*/
|
||||
public function getConfirmation()
|
||||
function getConfirmation()
|
||||
{
|
||||
$confirm = new Confirm_address();
|
||||
|
||||
@@ -249,19 +229,20 @@ class SmssettingsAction extends SettingsAction
|
||||
|
||||
protected function doPost()
|
||||
{
|
||||
|
||||
if ($this->arg('save')) {
|
||||
return $this->savePreferences();
|
||||
} elseif ($this->arg('add')) {
|
||||
} else if ($this->arg('add')) {
|
||||
return $this->addAddress();
|
||||
} elseif ($this->arg('cancel')) {
|
||||
} else if ($this->arg('cancel')) {
|
||||
return $this->cancelConfirmation();
|
||||
} elseif ($this->arg('remove')) {
|
||||
} else if ($this->arg('remove')) {
|
||||
return $this->removeAddress();
|
||||
} elseif ($this->arg('removeincoming')) {
|
||||
} else if ($this->arg('removeincoming')) {
|
||||
return $this->removeIncoming();
|
||||
} elseif ($this->arg('newincoming')) {
|
||||
} else if ($this->arg('newincoming')) {
|
||||
return $this->newIncoming();
|
||||
} elseif ($this->arg('confirm')) {
|
||||
} else if ($this->arg('confirm')) {
|
||||
return $this->confirmCode();
|
||||
}
|
||||
// TRANS: Message given submitting a form with an unknown action in SMS settings.
|
||||
@@ -275,11 +256,11 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function savePreferences()
|
||||
function savePreferences()
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
$user->query('START TRANSACTION');
|
||||
$user->query('BEGIN');
|
||||
|
||||
$original = clone($user);
|
||||
|
||||
@@ -307,7 +288,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addAddress()
|
||||
function addAddress()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
@@ -331,7 +312,7 @@ class SmssettingsAction extends SettingsAction
|
||||
if ($user->sms === $sms) {
|
||||
// TRANS: Message given saving SMS phone number that is already set.
|
||||
throw new AlreadyFulfilledException(_('That is already your phone number.'));
|
||||
} elseif ($this->smsExists($sms)) {
|
||||
} else if ($this->smsExists($sms)) {
|
||||
// TRANS: Message given saving SMS phone number that is already set for another user.
|
||||
throw new ClientException(_('That phone number already belongs to another user.'));
|
||||
}
|
||||
@@ -354,11 +335,9 @@ class SmssettingsAction extends SettingsAction
|
||||
|
||||
$carrier = Sms_carrier::getKV($carrier_id);
|
||||
|
||||
mail_confirm_sms(
|
||||
$confirm->code,
|
||||
$user->nickname,
|
||||
$carrier->toEmailAddress($sms)
|
||||
);
|
||||
mail_confirm_sms($confirm->code,
|
||||
$user->nickname,
|
||||
$carrier->toEmailAddress($sms));
|
||||
|
||||
// TRANS: Message given saving valid SMS phone number that is to be confirmed.
|
||||
return _('A confirmation code was sent to the phone number you added. '.
|
||||
@@ -373,7 +352,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cancelConfirmation()
|
||||
function cancelConfirmation()
|
||||
{
|
||||
$sms = $this->trimmed('sms');
|
||||
$carrier = $this->trimmed('carrier');
|
||||
@@ -400,7 +379,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeAddress()
|
||||
function removeAddress()
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
@@ -417,9 +396,9 @@ class SmssettingsAction extends SettingsAction
|
||||
|
||||
$original = clone($user);
|
||||
|
||||
$user->sms = $user->sqlValue('NULL');
|
||||
$user->carrier = $user->sqlValue('NULL');
|
||||
$user->smsemail = $user->sqlValue('NULL');
|
||||
$user->sms = null;
|
||||
$user->carrier = null;
|
||||
$user->smsemail = null;
|
||||
|
||||
// Throws exception on failure. Also performs it within a transaction.
|
||||
$user->updateWithKeys($original);
|
||||
@@ -437,7 +416,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return boolean does the number exist
|
||||
*/
|
||||
public function smsExists($sms)
|
||||
function smsExists($sms)
|
||||
{
|
||||
$other = User::getKV('sms', $sms);
|
||||
|
||||
@@ -453,7 +432,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function carrierSelect()
|
||||
function carrierSelect()
|
||||
{
|
||||
$carrier = new Sms_carrier();
|
||||
|
||||
@@ -465,33 +444,22 @@ class SmssettingsAction extends SettingsAction
|
||||
$this->element('label', array('for' => 'carrier'), _('Mobile carrier'));
|
||||
$this->elementStart('select', array('name' => 'carrier',
|
||||
'id' => 'carrier'));
|
||||
$this->element(
|
||||
'option',
|
||||
['value' => 0],
|
||||
// TRANS: Default option for mobile carrier dropdown menu in SMS settings.
|
||||
_('Select a carrier')
|
||||
);
|
||||
$this->element('option', array('value' => 0),
|
||||
// TRANS: Default option for mobile carrier dropdown menu in SMS settings.
|
||||
_('Select a carrier'));
|
||||
while ($carrier->fetch()) {
|
||||
$this->element(
|
||||
'option',
|
||||
['value' => $carrier->id],
|
||||
$carrier->name
|
||||
);
|
||||
$this->element('option', array('value' => $carrier->id),
|
||||
$carrier->name);
|
||||
}
|
||||
$this->elementEnd('select');
|
||||
$this->element(
|
||||
'p',
|
||||
'form_guide',
|
||||
// TRANS: Form instructions for mobile carrier dropdown menu in SMS settings.
|
||||
// TRANS: %s is an administrative contact's e-mail address.
|
||||
sprintf(
|
||||
_('Mobile carrier for your phone. ' .
|
||||
'If you know a carrier that accepts ' .
|
||||
'SMS over email but isn\'t listed here, ' .
|
||||
'send email to let us know at %s.'),
|
||||
common_config('site', 'email')
|
||||
)
|
||||
);
|
||||
$this->element('p', 'form_guide',
|
||||
// TRANS: Form instructions for mobile carrier dropdown menu in SMS settings.
|
||||
// TRANS: %s is an administrative contact's e-mail address.
|
||||
sprintf(_('Mobile carrier for your phone. '.
|
||||
'If you know a carrier that accepts ' .
|
||||
'SMS over email but isn\'t listed here, ' .
|
||||
'send email to let us know at %s.'),
|
||||
common_config('site', 'email')));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
}
|
||||
@@ -503,7 +471,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function confirmCode()
|
||||
function confirmCode()
|
||||
{
|
||||
$code = $this->trimmed('code');
|
||||
|
||||
@@ -520,7 +488,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeIncoming()
|
||||
function removeIncoming()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
@@ -531,7 +499,7 @@ class SmssettingsAction extends SettingsAction
|
||||
|
||||
$orig = clone($user);
|
||||
|
||||
$user->incomingemail = $user->sqlValue('NULL');
|
||||
$user->incomingemail = null;
|
||||
|
||||
// Throws exception on failure. Also performs it within a transaction.
|
||||
$user->updateWithKeys($orig);
|
||||
@@ -547,7 +515,7 @@ class SmssettingsAction extends SettingsAction
|
||||
*
|
||||
* @see Emailsettings::newIncoming
|
||||
*/
|
||||
public function newIncoming()
|
||||
function newIncoming()
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
|
||||
+35
-32
@@ -1,25 +1,28 @@
|
||||
<?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) 2008, 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/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
// @todo FIXME: documentation needed.
|
||||
class SupAction extends Action
|
||||
{
|
||||
public function handle()
|
||||
function handle()
|
||||
{
|
||||
parent::handle();
|
||||
|
||||
@@ -40,23 +43,21 @@ class SupAction extends Action
|
||||
'updates' => $updates));
|
||||
}
|
||||
|
||||
public function availablePeriods()
|
||||
function availablePeriods()
|
||||
{
|
||||
static $periods = array(86400, 43200, 21600, 7200,
|
||||
3600, 1800, 600, 300, 120,
|
||||
60, 30, 15);
|
||||
$available = array();
|
||||
foreach ($periods as $period) {
|
||||
$available[$period] = common_local_url(
|
||||
'sup',
|
||||
['seconds' => $period]
|
||||
);
|
||||
$available[$period] = common_local_url('sup',
|
||||
array('seconds' => $period));
|
||||
}
|
||||
|
||||
return $available;
|
||||
}
|
||||
|
||||
public function getUpdates($seconds)
|
||||
function getUpdates($seconds)
|
||||
{
|
||||
$notice = new Notice();
|
||||
|
||||
@@ -65,23 +66,25 @@ class SupAction extends Action
|
||||
|
||||
$divider = common_sql_date(time() - $seconds);
|
||||
|
||||
$notice->selectAdd();
|
||||
$notice->selectAdd('profile_id, MAX(id) AS max_id');
|
||||
$notice->whereAdd("created > TIMESTAMP '{$divider}'");
|
||||
$notice->groupBy('profile_id');
|
||||
$notice->query('SELECT profile_id, max(id) AS max_id ' .
|
||||
'FROM ( ' .
|
||||
'SELECT profile_id, id FROM notice ' .
|
||||
((common_config('db','type') == 'pgsql') ?
|
||||
'WHERE extract(epoch from created) > (extract(epoch from now()) - ' . $seconds . ') ' :
|
||||
'WHERE created > "'.$divider.'" ' ) .
|
||||
') AS latest ' .
|
||||
'GROUP BY profile_id');
|
||||
|
||||
$updates = [];
|
||||
$updates = array();
|
||||
|
||||
if ($notice->find()) {
|
||||
while ($notice->fetch()) {
|
||||
$updates[] = [$notice->profile_id, $notice->max_id];
|
||||
}
|
||||
while ($notice->fetch()) {
|
||||
$updates[] = array($notice->profile_id, $notice->max_id);
|
||||
}
|
||||
|
||||
return $updates;
|
||||
}
|
||||
|
||||
public function isReadOnly($args)
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
+53
-55
@@ -1,42 +1,46 @@
|
||||
<?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
|
||||
*
|
||||
* Miscellaneous 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
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Miscellaneous settings actions
|
||||
*
|
||||
* Currently this just manages URL shortening.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Settings
|
||||
* @package StatusNet
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class UrlsettingsAction extends SettingsAction
|
||||
{
|
||||
@@ -45,7 +49,7 @@ class UrlsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: Title of URL settings tab in profile settings.
|
||||
return _('URL settings');
|
||||
@@ -56,13 +60,13 @@ class UrlsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for tab "Other" in user profile settings.
|
||||
return _('Manage various other options.');
|
||||
}
|
||||
|
||||
public function showScripts()
|
||||
function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
$this->autofocus('urlshorteningservice');
|
||||
@@ -75,7 +79,7 @@ class UrlsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showContent()
|
||||
function showContent()
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
@@ -94,7 +98,8 @@ class UrlsettingsAction extends SettingsAction
|
||||
|
||||
$services = array();
|
||||
|
||||
foreach ($shorteners as $name => $value) {
|
||||
foreach ($shorteners as $name => $value)
|
||||
{
|
||||
$services[$name] = $name;
|
||||
if ($value['freeService']) {
|
||||
// TRANS: Used as a suffix for free URL shorteners in a dropdown list in the tab "Other" of a
|
||||
@@ -116,40 +121,33 @@ class UrlsettingsAction extends SettingsAction
|
||||
|
||||
$this->elementStart('li');
|
||||
// TRANS: Label for dropdown with URL shortener services.
|
||||
$this->dropdown(
|
||||
'urlshorteningservice',
|
||||
_('Shorten URLs with'),
|
||||
// TRANS: Tooltip for for dropdown with URL shortener services.
|
||||
$services,
|
||||
_('Automatic shortening service to use.'),
|
||||
false,
|
||||
$user->urlshorteningservice
|
||||
);
|
||||
$this->dropdown('urlshorteningservice', _('Shorten URLs with'),
|
||||
// TRANS: Tooltip for for dropdown with URL shortener services.
|
||||
$services, _('Automatic shortening service to use.'),
|
||||
false, $user->urlshorteningservice);
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
$this->elementStart('li');
|
||||
$this->input(
|
||||
'maxurllength',
|
||||
// TRANS: Field label in URL settings in profile.
|
||||
_('URL longer than'),
|
||||
($this->arg('maxurllength') ?? User_urlshortener_prefs::maxUrlLength($user)),
|
||||
// TRANS: Field title in URL settings in profile.
|
||||
_('URLs longer than this will be shortened, -1 means never shorten because a URL is long.')
|
||||
);
|
||||
$this->input('maxurllength',
|
||||
// TRANS: Field label in URL settings in profile.
|
||||
_('URL longer than'),
|
||||
(!is_null($this->arg('maxurllength'))) ?
|
||||
$this->arg('maxurllength') : User_urlshortener_prefs::maxUrlLength($user),
|
||||
// TRANS: Field title in URL settings in profile.
|
||||
_('URLs longer than this will be shortened, -1 means never shorten because a URL is long.'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$this->input(
|
||||
'maxnoticelength',
|
||||
// TRANS: Field label in URL settings in profile.
|
||||
_('Text longer than'),
|
||||
($this->arg('maxnoticelength') ?? User_urlshortener_prefs::maxNoticeLength($user)),
|
||||
// TRANS: Field title in URL settings in profile.
|
||||
_('URLs in notices longer than this will always be shortened, -1 means only shorten if the full post exceeds maximum length.')
|
||||
);
|
||||
$this->input('maxnoticelength',
|
||||
// TRANS: Field label in URL settings in profile.
|
||||
_('Text longer than'),
|
||||
(!is_null($this->arg('maxnoticelength'))) ?
|
||||
$this->arg('maxnoticelength') : User_urlshortener_prefs::maxNoticeLength($user),
|
||||
// TRANS: Field title in URL settings in profile.
|
||||
_('URLs in notices longer than this will always be shortened, -1 means only shorten if the full post exceeds maximum length.'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
// TRANS: Button text for saving "Other settings" in profile.
|
||||
$this->submit('save', _m('BUTTON', 'Save'));
|
||||
$this->submit('save', _m('BUTTON','Save'));
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
@@ -179,7 +177,7 @@ class UrlsettingsAction extends SettingsAction
|
||||
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
$user->query('START TRANSACTION');
|
||||
$user->query('BEGIN');
|
||||
|
||||
$original = clone($user);
|
||||
|
||||
|
||||
@@ -1,42 +1,49 @@
|
||||
<?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
|
||||
*
|
||||
* User administration panel
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
*
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2008-2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Administer user settings
|
||||
*
|
||||
* @category Admin
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Admin
|
||||
* @package StatusNet
|
||||
* @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 UseradminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -45,7 +52,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
public function title()
|
||||
function title()
|
||||
{
|
||||
// TRANS: User admin panel title.
|
||||
return _m('TITLE', 'User');
|
||||
@@ -56,7 +63,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
public function getInstructions()
|
||||
function getInstructions()
|
||||
{
|
||||
// TRANS: Instruction for user admin panel.
|
||||
return _('User settings for this StatusNet site');
|
||||
@@ -67,7 +74,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showForm()
|
||||
function showForm()
|
||||
{
|
||||
$form = new UserAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -79,7 +86,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function saveSettings()
|
||||
function saveSettings()
|
||||
{
|
||||
static $settings = array(
|
||||
'profile' => array('biolimit'),
|
||||
@@ -112,7 +119,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('START TRANSACTION');
|
||||
$config->query('BEGIN');
|
||||
|
||||
foreach ($settings as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -131,7 +138,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
return;
|
||||
}
|
||||
|
||||
public function validate(&$values)
|
||||
function validate(&$values)
|
||||
{
|
||||
// Validate biolimit
|
||||
|
||||
@@ -173,7 +180,7 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
public function id()
|
||||
function id()
|
||||
{
|
||||
return 'useradminpanel';
|
||||
}
|
||||
@@ -183,7 +190,7 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
public function formClass()
|
||||
function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -193,7 +200,7 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
public function action()
|
||||
function action()
|
||||
{
|
||||
return common_local_url('useradminpanel');
|
||||
}
|
||||
@@ -203,22 +210,19 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formData()
|
||||
function formData()
|
||||
{
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_user-profile'));
|
||||
// TRANS: Fieldset legend in user administration panel.
|
||||
$this->out->element('legend', null, _m('LEGEND', 'Profile'));
|
||||
$this->out->element('legend', null, _m('LEGEND','Profile'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label in user admin panel for setting the character limit for the bio field.
|
||||
$this->input(
|
||||
'biolimit',
|
||||
_('Bio Limit'),
|
||||
// TRANS: Tooltip in user admin panel for setting the character limit for the bio field.
|
||||
_('Maximum length of a profile bio in characters.'),
|
||||
'profile'
|
||||
);
|
||||
$this->input('biolimit', _('Bio Limit'),
|
||||
// TRANS: Tooltip in user admin panel for setting the character limit for the bio field.
|
||||
_('Maximum length of a profile bio in characters.'),
|
||||
'profile');
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@@ -231,24 +235,18 @@ class UserAdminPanelForm extends AdminForm
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label in user admin panel for setting new user welcome text.
|
||||
$this->input(
|
||||
'welcome',
|
||||
_('New user welcome'),
|
||||
// TRANS: Tooltip in user admin panel for setting new user welcome text.
|
||||
_('Welcome text for new users (maximum 255 characters).'),
|
||||
'newuser'
|
||||
);
|
||||
$this->input('welcome', _('New user welcome'),
|
||||
// TRANS: Tooltip in user admin panel for setting new user welcome text.
|
||||
_('Welcome text for new users (maximum 255 characters).'),
|
||||
'newuser');
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
// TRANS: Field label in user admin panel for setting default subscription for new users.
|
||||
$this->input(
|
||||
'default',
|
||||
_('Default subscription'),
|
||||
// TRANS: Tooltip in user admin panel for setting default subscription for new users.
|
||||
_('Automatically subscribe new users to this user.'),
|
||||
'newuser'
|
||||
);
|
||||
$this->input('default', _('Default subscription'),
|
||||
// TRANS: Tooltip in user admin panel for setting default subscription for new users.
|
||||
_('Automatically subscribe new users to this user.'),
|
||||
'newuser');
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@@ -263,13 +261,10 @@ class UserAdminPanelForm extends AdminForm
|
||||
$this->li();
|
||||
|
||||
// TRANS: Field label for checkbox in user admin panel for allowing users to invite friend using site e-mail.
|
||||
$this->out->checkbox(
|
||||
'invite-enabled',
|
||||
_('Invitations enabled'),
|
||||
(bool) $this->value('enabled', 'invite'),
|
||||
// TRANS: Tooltip for checkbox in user admin panel for allowing users to invite friend using site e-mail.
|
||||
_('Whether to allow users to invite new users.')
|
||||
);
|
||||
$this->out->checkbox('invite-enabled', _('Invitations enabled'),
|
||||
(bool) $this->value('enabled', 'invite'),
|
||||
// TRANS: Tooltip for checkbox in user admin panel for allowing users to invite friend using site e-mail.
|
||||
_('Whether to allow users to invite new users.'));
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@@ -288,7 +283,7 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function input($setting, $title, $instructions, $section='site')
|
||||
function input($setting, $title, $instructions, $section='site')
|
||||
{
|
||||
$this->out->input("$section-$setting", $title, $this->value($setting, $section), $instructions);
|
||||
}
|
||||
@@ -298,16 +293,14 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function formActions()
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit(
|
||||
'submit',
|
||||
// TRANS: Button text to save user settings in user admin panel.
|
||||
_m('BUTTON', 'Save'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Button title to save user settings in user admin panel.
|
||||
_('Save user settings.')
|
||||
);
|
||||
$this->out->submit('submit',
|
||||
// TRANS: Button text to save user settings in user admin panel.
|
||||
_m('BUTTON','Save'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Button title to save user settings in user admin panel.
|
||||
_('Save user settings.'));
|
||||
}
|
||||
}
|
||||
|
||||
+35
-33
@@ -1,40 +1,44 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* User by ID action class.
|
||||
*
|
||||
* @category Action
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 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/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* User by ID action class.
|
||||
*
|
||||
* @category Action
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class UserbyidAction extends ShowstreamAction
|
||||
{
|
||||
@@ -52,12 +56,10 @@ class UserbyidAction extends ShowstreamAction
|
||||
// ensure that only user-agents who specifically ask for RDF get it.
|
||||
$page_prefs = 'text/html,application/xhtml+xml,application/rdf+xml,application/xml;q=0.3,text/xml;q=0.2';
|
||||
$httpaccept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null;
|
||||
$type = common_negotiate_type(
|
||||
common_accept_to_prefs($httpaccept),
|
||||
common_accept_to_prefs($page_prefs)
|
||||
);
|
||||
$page = ($type === 'application/rdf+xml') ? 'foaf' : 'showstream';
|
||||
$url = common_local_url($page, ['nickname' => $this->target->getNickname()]);
|
||||
$type = common_negotiate_type(common_accept_to_prefs($httpaccept),
|
||||
common_accept_to_prefs($page_prefs));
|
||||
$page = $type === 'application/rdf+xml' ? 'foaf' : 'showstream';
|
||||
$url = common_local_url($page, array('nickname' => $this->target->getNickname()));
|
||||
common_redirect($url, 303);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/groups/grouplist.php';
|
||||
require_once INSTALLDIR.'/lib/grouplist.php';
|
||||
|
||||
/**
|
||||
* User groups page
|
||||
|
||||
+20
-27
@@ -1,38 +1,30 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* Data class for Attentions
|
||||
* GNU social - a federating social network
|
||||
* Copyright (C) 2014, Free Software Foundation, Inc.
|
||||
*
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @copyright 2014 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Attention extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'attention'; // table name
|
||||
public $notice_id; // int(4) primary_key not_null
|
||||
public $profile_id; // int(4) primary_key not_null
|
||||
public $reason; // varchar(191)
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $reason; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -42,8 +34,8 @@ class Attention extends Managed_DataObject
|
||||
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice_id to give attention'),
|
||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile_id for feed receiver'),
|
||||
'reason' => array('type' => 'varchar', 'length' => 191, 'description' => 'Optional reason why this was brought to the attention of profile_id'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('notice_id', 'profile_id'),
|
||||
'foreign keys' => array(
|
||||
@@ -51,6 +43,7 @@ class Attention extends Managed_DataObject
|
||||
'attention_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'attention_notice_id_idx' => array('notice_id'),
|
||||
'attention_profile_id_idx' => array('profile_id'),
|
||||
),
|
||||
);
|
||||
|
||||
+28
-52
@@ -1,20 +1,6 @@
|
||||
<?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();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Table Definition for avatar
|
||||
@@ -24,26 +10,26 @@ class Avatar extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'avatar'; // table name
|
||||
public $profile_id; // int(4) primary_key not_null
|
||||
public $original; // bool default_false
|
||||
public $original; // tinyint(1)
|
||||
public $width; // int(4) primary_key not_null
|
||||
public $height; // int(4) primary_key not_null
|
||||
public $mediatype; // varchar(32) not_null
|
||||
public $filename; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
return array(
|
||||
'fields' => array(
|
||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
|
||||
'original' => array('type' => 'bool', 'default' => false, 'description' => 'uploaded by user or generated?'),
|
||||
'original' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'uploaded by user or generated?'),
|
||||
'width' => array('type' => 'int', 'not null' => true, 'description' => 'image width'),
|
||||
'height' => array('type' => 'int', 'not null' => true, 'description' => 'image height'),
|
||||
'mediatype' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'file type'),
|
||||
'filename' => array('type' => 'varchar', 'length' => 191, 'description' => 'local filename, if local'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('profile_id', 'width', 'height'),
|
||||
'unique keys' => array(
|
||||
@@ -52,11 +38,14 @@ class Avatar extends Managed_DataObject
|
||||
'foreign keys' => array(
|
||||
'avatar_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'avatar_profile_id_idx' => array('profile_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// We clean up the file, too
|
||||
public function delete($useWhere = false)
|
||||
function delete($useWhere=false)
|
||||
{
|
||||
$filename = $this->filename;
|
||||
if (file_exists(Avatar::path($filename))) {
|
||||
@@ -68,12 +57,11 @@ class Avatar extends Managed_DataObject
|
||||
|
||||
/*
|
||||
* Deletes all avatars (but may spare the original) from a profile.
|
||||
*
|
||||
*
|
||||
* @param Profile $target The profile we're deleting avatars of.
|
||||
* @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 {
|
||||
$avatars = self::getProfileAvatars($target);
|
||||
foreach ($avatars as $avatar) {
|
||||
@@ -89,7 +77,7 @@ class Avatar extends Managed_DataObject
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static $_avatars = [];
|
||||
static protected $_avatars = array();
|
||||
|
||||
/*
|
||||
* Get an avatar by profile. Currently can't call newSize with $height
|
||||
@@ -105,7 +93,7 @@ class Avatar extends Managed_DataObject
|
||||
$size = "{$width}x{$height}";
|
||||
if (!isset(self::$_avatars[$target->id])) {
|
||||
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];
|
||||
}
|
||||
|
||||
@@ -149,8 +137,7 @@ class Avatar extends Managed_DataObject
|
||||
return $avatar;
|
||||
}
|
||||
|
||||
public static function getProfileAvatars(Profile $target)
|
||||
{
|
||||
public static function getProfileAvatars(Profile $target) {
|
||||
$avatar = new Avatar();
|
||||
$avatar->profile_id = $target->id;
|
||||
if (!$avatar->find()) {
|
||||
@@ -161,13 +148,8 @@ class Avatar extends Managed_DataObject
|
||||
|
||||
/**
|
||||
* Where should the avatar go for this user?
|
||||
* @param int $id user id
|
||||
* @param string $extension file extension
|
||||
* @param int|null $size file size
|
||||
* @param string|null $extra extra bit for the filename
|
||||
* @return string
|
||||
*/
|
||||
public static function filename(int $id, string $extension, ?int $size = null, ?string $extra = null)
|
||||
static function filename($id, $extension, $size=null, $extra=null)
|
||||
{
|
||||
if ($size) {
|
||||
return $id . '-' . $size . (($extra) ? ('-' . $extra) : '') . $extension;
|
||||
@@ -176,7 +158,7 @@ class Avatar extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public static function path($filename)
|
||||
static function path($filename)
|
||||
{
|
||||
$dir = common_config('avatar', 'dir');
|
||||
|
||||
@@ -187,9 +169,9 @@ class Avatar extends Managed_DataObject
|
||||
return $dir . $filename;
|
||||
}
|
||||
|
||||
public static function url($filename)
|
||||
static function url($filename)
|
||||
{
|
||||
$path = common_config('avatar', 'url_base');
|
||||
$path = common_config('avatar', 'path');
|
||||
|
||||
if ($path[strlen($path)-1] != '/') {
|
||||
$path .= '/';
|
||||
@@ -212,21 +194,20 @@ class Avatar extends Managed_DataObject
|
||||
return $protocol.'://'.$server.$path.$filename;
|
||||
}
|
||||
|
||||
public function displayUrl()
|
||||
function displayUrl()
|
||||
{
|
||||
return Avatar::url($this->filename);
|
||||
}
|
||||
|
||||
public static function urlByProfile(Profile $target, $width = null, $height = null)
|
||||
{
|
||||
static function urlByProfile(Profile $target, $width=null, $height=null) {
|
||||
try {
|
||||
return self::byProfile($target, $width, $height)->displayUrl();
|
||||
return self::byProfile($target, $width, $height)->displayUrl();
|
||||
} catch (Exception $e) {
|
||||
return self::defaultImage($width);
|
||||
}
|
||||
}
|
||||
|
||||
public static function defaultImage($size = null)
|
||||
static function defaultImage($size=null)
|
||||
{
|
||||
if (is_null($size)) {
|
||||
$size = AVATAR_PROFILE_SIZE;
|
||||
@@ -237,8 +218,7 @@ class Avatar extends Managed_DataObject
|
||||
return Theme::path('default-avatar-'.$sizenames[$size].'.png');
|
||||
}
|
||||
|
||||
public static function newSize(Profile $target, $width)
|
||||
{
|
||||
static function newSize(Profile $target, $width) {
|
||||
$width = intval($width);
|
||||
if ($width < 1 || $width > common_config('avatar', 'maxsize')) {
|
||||
// TRANS: An error message when avatar size is unreasonable
|
||||
@@ -251,12 +231,8 @@ class Avatar extends Managed_DataObject
|
||||
$original = Avatar::getUploaded($target);
|
||||
|
||||
$imagefile = new ImageFile(null, Avatar::path($original->filename));
|
||||
$filename = Avatar::filename(
|
||||
$target->getID(),
|
||||
image_type_to_extension($imagefile->preferredType()),
|
||||
$width,
|
||||
common_timestamp()
|
||||
);
|
||||
$filename = Avatar::filename($target->getID(), image_type_to_extension($imagefile->preferredType()),
|
||||
$width, common_timestamp());
|
||||
$imagefile->resizeTo(Avatar::path($filename), array('width'=>$width, 'height'=>$height));
|
||||
|
||||
$scaled = clone($original);
|
||||
|
||||
@@ -1,61 +1,41 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for confirm_address
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Confirm_address extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'confirm_address'; // table name
|
||||
public $code; // varchar(32) primary_key not_null
|
||||
public $user_id; // int()
|
||||
public $user_id; // int(4) not_null
|
||||
public $address; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||
public $address_extra; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||
public $address_type; // varchar(8) not_null
|
||||
public $claimed; // datetime()
|
||||
public $sent; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
return array(
|
||||
'fields' => array(
|
||||
'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'),
|
||||
'user_id' => array('type' => 'int', 'description' => 'user who requested confirmation'),
|
||||
'user_id' => array('type' => 'int', 'default' => 0, 'description' => 'user who requested confirmation'),
|
||||
'address' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'address (email, xmpp, SMS, etc.)'),
|
||||
'address_extra' => array('type' => 'varchar', 'length' => 191, 'description' => 'carrier ID, for SMS'),
|
||||
'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'),
|
||||
'claimed' => array('type' => 'datetime', 'description' => 'date this was claimed for queueing'),
|
||||
'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('code'),
|
||||
'foreign keys' => array(
|
||||
'confirm_address_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'confirm_address_user_id_idx' => array('user_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getByAddress($address, $addressType)
|
||||
static function getByAddress($address, $addressType)
|
||||
{
|
||||
$ca = new Confirm_address();
|
||||
|
||||
@@ -69,7 +49,7 @@ class Confirm_address extends Managed_DataObject
|
||||
return $ca;
|
||||
}
|
||||
|
||||
public static function saveNew($user, $address, $addressType, $extra = null)
|
||||
static function saveNew($user, $address, $addressType, $extra=null)
|
||||
{
|
||||
$ca = new Confirm_address();
|
||||
|
||||
@@ -119,16 +99,16 @@ class Confirm_address extends Managed_DataObject
|
||||
* sitename Name we sign the email with (defaults to sitename, but can be any string)
|
||||
* url The confirmation address URL.
|
||||
*/
|
||||
public function sendConfirmation(array $args = [])
|
||||
public function sendConfirmation(array $args=array())
|
||||
{
|
||||
common_debug('Sending confirmation URL for user '._ve($this->user_id).' using '._ve($this->address_type));
|
||||
|
||||
$defaults = [
|
||||
'headers' => [],
|
||||
'nickname' => $this->getProfile()->getNickname(),
|
||||
'sitename' => common_config('site', 'name'),
|
||||
'url' => $this->getUrl(),
|
||||
];
|
||||
'headers' => array(),
|
||||
'nickname' => $this->getProfile()->getNickname(),
|
||||
'sitename' => common_config('site', 'name'),
|
||||
'url' => $this->getUrl(),
|
||||
];
|
||||
foreach (array_keys($defaults) as $key) {
|
||||
if (!isset($args[$key])) {
|
||||
$args[$key] = $defaults[$key];
|
||||
@@ -144,7 +124,7 @@ class Confirm_address extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public function sendEmailConfirmation(array $args = [])
|
||||
public function sendEmailConfirmation(array $args=array())
|
||||
{
|
||||
// TRANS: Subject for address confirmation email.
|
||||
$subject = _('Email address confirmation');
|
||||
@@ -152,23 +132,21 @@ class Confirm_address extends Managed_DataObject
|
||||
// TRANS: Body for address confirmation email.
|
||||
// TRANS: %1$s is the addressed user's nickname, %2$s is the StatusNet sitename,
|
||||
// TRANS: %3$s is the URL to confirm at.
|
||||
$body = sprintf(
|
||||
_("Hey, %1\$s.\n\n" .
|
||||
"Someone just entered this email address on %2\$s.\n\n" .
|
||||
"If it was you, and you want to confirm your entry, ".
|
||||
"use the URL below:\n\n\t%3\$s\n\n" .
|
||||
"If not, just ignore this message.\n\n".
|
||||
"Thanks for your time, \n%2\$s\n"),
|
||||
$args['nickname'],
|
||||
$args['sitename'],
|
||||
$args['url']
|
||||
);
|
||||
$body = sprintf(_("Hey, %1\$s.\n\n".
|
||||
"Someone just entered this email address on %2\$s.\n\n" .
|
||||
"If it was you, and you want to confirm your entry, ".
|
||||
"use the URL below:\n\n\t%3\$s\n\n" .
|
||||
"If not, just ignore this message.\n\n".
|
||||
"Thanks for your time, \n%2\$s\n"),
|
||||
$args['nickname'],
|
||||
$args['sitename'],
|
||||
$args['url']);
|
||||
|
||||
require_once INSTALLDIR . '/lib/util/mail.php';
|
||||
require_once(INSTALLDIR . '/lib/mail.php');
|
||||
return mail_to_user($this->getProfile()->getUser(), $subject, $body, $args['headers'], $this->getAddress());
|
||||
}
|
||||
|
||||
public function delete($useWhere = false)
|
||||
public function delete($useWhere=false)
|
||||
{
|
||||
$result = parent::delete($useWhere);
|
||||
|
||||
|
||||
+11
-27
@@ -1,24 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for consumer
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Consumer extends Managed_DataObject
|
||||
{
|
||||
@@ -29,8 +13,8 @@ class Consumer extends Managed_DataObject
|
||||
public $consumer_key; // varchar(191) primary_key not_null not 255 because utf8mb4 takes more space
|
||||
public $consumer_secret; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||
public $seed; // char(32) not_null
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -43,14 +27,14 @@ class Consumer extends Managed_DataObject
|
||||
'consumer_key' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'unique identifier, root URL'),
|
||||
'consumer_secret' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'secret value'),
|
||||
'seed' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'seed for new tokens by this consumer'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('consumer_key'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function generateNew()
|
||||
static function generateNew()
|
||||
{
|
||||
$cons = new Consumer();
|
||||
$rand = common_random_hexstr(16);
|
||||
@@ -69,24 +53,24 @@ class Consumer extends Managed_DataObject
|
||||
* XXX: Should this happen in an OAuthDataStore instead?
|
||||
*
|
||||
*/
|
||||
public function delete($useWhere = false)
|
||||
function delete($useWhere=false)
|
||||
{
|
||||
// XXX: Is there any reason NOT to do this kind of cleanup?
|
||||
|
||||
$this->deleteTokens();
|
||||
$this->deleteNonces();
|
||||
$this->_deleteTokens();
|
||||
$this->_deleteNonces();
|
||||
|
||||
return parent::delete($useWhere);
|
||||
}
|
||||
|
||||
private function deleteTokens()
|
||||
function _deleteTokens()
|
||||
{
|
||||
$token = new Token();
|
||||
$token->consumer_key = $this->consumer_key;
|
||||
$token->delete();
|
||||
}
|
||||
|
||||
private function deleteNonces()
|
||||
function _deleteNonces()
|
||||
{
|
||||
$nonce = new Nonce();
|
||||
$nonce->consumer_key = $this->consumer_key;
|
||||
|
||||
+35
-37
@@ -1,32 +1,35 @@
|
||||
<?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 Conversations
|
||||
*
|
||||
* 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
|
||||
* @package GNUsocial
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2010 StatusNet Inc.
|
||||
* @copyright 2009-2014 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class Conversation extends Managed_DataObject
|
||||
{
|
||||
@@ -34,8 +37,8 @@ class Conversation extends Managed_DataObject
|
||||
public $id; // int(4) primary_key not_null auto_increment
|
||||
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||
public $url; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -44,8 +47,8 @@ class Conversation extends Managed_DataObject
|
||||
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'Unique identifier, (again) unrelated to notice id since 2016-01-06'),
|
||||
'uri' => array('type' => 'varchar', 'not null'=>true, 'length' => 191, 'description' => 'URI of the conversation'),
|
||||
'url' => array('type' => 'varchar', 'length' => 191, 'description' => 'Resolvable URL, preferrably remote (local can be generated on the fly)'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
@@ -54,14 +57,14 @@ class Conversation extends Managed_DataObject
|
||||
);
|
||||
}
|
||||
|
||||
public static function beforeSchemaUpdate()
|
||||
static public function beforeSchemaUpdate()
|
||||
{
|
||||
$table = strtolower(get_called_class());
|
||||
$schema = Schema::get();
|
||||
$schemadef = $schema->getTableDef($table);
|
||||
|
||||
// 2016-01-06 We have to make sure there is no conversation with id==0 since it will screw up auto increment resequencing
|
||||
if ($schemadef['fields']['id']['auto_increment'] ?? false) {
|
||||
if ($schemadef['fields']['id']['auto_increment']) {
|
||||
// since we already have auto incrementing ('serial') we can continue
|
||||
return;
|
||||
}
|
||||
@@ -88,7 +91,7 @@ class Conversation extends Managed_DataObject
|
||||
*
|
||||
* @return Conversation the new conversation DO
|
||||
*/
|
||||
public static function create(ActivityContext $ctx = null, $created = null)
|
||||
static function create(ActivityContext $ctx=null, $created=null)
|
||||
{
|
||||
// Be aware that the Notice does not have an id yet since it's not inserted!
|
||||
$conv = new Conversation();
|
||||
@@ -97,16 +100,11 @@ class Conversation extends Managed_DataObject
|
||||
$conv->uri = $ctx->conversation;
|
||||
$conv->url = $ctx->conversation_url;
|
||||
} else {
|
||||
$conv->uri = sprintf(
|
||||
'%s%s=%s:%s=%s',
|
||||
TagURI::mint(),
|
||||
'objectType',
|
||||
'thread',
|
||||
'nonce',
|
||||
common_random_hexstr(8)
|
||||
);
|
||||
// locally generated Conversation objects don't get static URLs stored
|
||||
$conv->url = $conv->sqlValue('NULL');
|
||||
$conv->uri = sprintf('%s%s=%s:%s=%s',
|
||||
TagURI::mint(),
|
||||
'objectType', 'thread',
|
||||
'nonce', common_random_hexstr(8));
|
||||
$conv->url = null; // locally generated Conversation objects don't get static URLs stored
|
||||
}
|
||||
// This insert throws exceptions on failure
|
||||
$conv->insert();
|
||||
@@ -114,7 +112,7 @@ class Conversation extends Managed_DataObject
|
||||
return $conv;
|
||||
}
|
||||
|
||||
public static function noticeCount($id)
|
||||
static function noticeCount($id)
|
||||
{
|
||||
$keypart = sprintf('conversation:notice_count:%d', $id);
|
||||
|
||||
@@ -134,7 +132,7 @@ class Conversation extends Managed_DataObject
|
||||
return $cnt;
|
||||
}
|
||||
|
||||
public static function getUrlFromNotice(Notice $notice, $anchor = true)
|
||||
static public function getUrlFromNotice(Notice $notice, $anchor=true)
|
||||
{
|
||||
$conv = Conversation::getByID($notice->conversation);
|
||||
return $conv->getUrl($anchor ? $notice->getID() : null);
|
||||
|
||||
+71
-101
@@ -1,26 +1,29 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* GNU social - a federating social network
|
||||
*
|
||||
* Abstraction for files
|
||||
*
|
||||
* 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 Files
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @author Miguel Dantas <biodantas@gmail.com>
|
||||
* @copyright 2008-2009, 2019 Free Software Foundation http://fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link https://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
@@ -43,7 +46,7 @@ class File extends Managed_DataObject
|
||||
public $filename; // text()
|
||||
public $width; // int(4)
|
||||
public $height; // int(4)
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
const URLHASH_ALG = 'sha256';
|
||||
const FILEHASH_ALG = 'sha256';
|
||||
@@ -64,7 +67,7 @@ class File extends Managed_DataObject
|
||||
'filename' => array('type' => 'text', 'description' => 'if file is stored locally (too) this is the filename'),
|
||||
'width' => array('type' => 'int', 'description' => 'width in pixels, if it can be described as such and data is available'),
|
||||
'height' => array('type' => 'int', 'description' => 'height in pixels, if it can be described as such and data is available'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
@@ -245,14 +248,14 @@ class File extends Managed_DataObject
|
||||
// TRANS: gettext support multiple plurals in the same message, unfortunately...
|
||||
throw new ClientException(
|
||||
sprintf(
|
||||
_m(
|
||||
_m(
|
||||
'No file may be larger than %1$d byte and the file you sent was %2$s. Try to upload a smaller version.',
|
||||
'No file may be larger than %1$d bytes and the file you sent was %2$s. Try to upload a smaller version.',
|
||||
$fileQuota
|
||||
),
|
||||
$fileQuota,
|
||||
$fileSizeText
|
||||
)
|
||||
$fileQuota,
|
||||
$fileSizeText
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -274,17 +277,16 @@ class File extends Managed_DataObject
|
||||
// TRANS: %d (number) is the user quota in bytes and is used for plural.
|
||||
throw new ClientException(
|
||||
sprintf(
|
||||
_m(
|
||||
_m(
|
||||
'A file this large would exceed your user quota of %d byte.',
|
||||
'A file this large would exceed your user quota of %d bytes.',
|
||||
common_config('attachments', 'user_quota')
|
||||
),
|
||||
common_config('attachments', 'user_quota')
|
||||
)
|
||||
common_config('attachments', 'user_quota')
|
||||
)
|
||||
);
|
||||
}
|
||||
$query .= ' AND EXTRACT(MONTH FROM file.modified) = EXTRACT(MONTH FROM CURRENT_DATE)'
|
||||
. ' AND EXTRACT(YEAR FROM file.modified) = EXTRACT(YEAR FROM CURRENT_DATE)';
|
||||
$query .= ' AND EXTRACT(month FROM file.modified) = EXTRACT(month FROM now()) AND EXTRACT(year FROM file.modified) = EXTRACT(year FROM now())';
|
||||
$file->query($query);
|
||||
$file->fetch();
|
||||
$total = $file->total + $fileSize;
|
||||
@@ -293,13 +295,13 @@ class File extends Managed_DataObject
|
||||
// TRANS: $d (number) is the monthly user quota in bytes and is used for plural.
|
||||
throw new ClientException(
|
||||
sprintf(
|
||||
_m(
|
||||
_m(
|
||||
'A file this large would exceed your monthly quota of %d byte.',
|
||||
'A file this large would exceed your monthly quota of %d bytes.',
|
||||
common_config('attachments', 'monthly_quota')
|
||||
),
|
||||
common_config('attachments', 'monthly_quota')
|
||||
)
|
||||
common_config('attachments', 'monthly_quota')
|
||||
)
|
||||
);
|
||||
}
|
||||
return true;
|
||||
@@ -310,9 +312,9 @@ class File extends Managed_DataObject
|
||||
return self::tryFilename($this->filename);
|
||||
}
|
||||
|
||||
public function getSize(): int
|
||||
public function getSize()
|
||||
{
|
||||
return (int)$this->size;
|
||||
return intval($this->size);
|
||||
}
|
||||
|
||||
// where should the file go?
|
||||
@@ -342,11 +344,9 @@ class File extends Managed_DataObject
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @return null|string|bool Value from the 'extblacklist' array, in the config
|
||||
* @throws ServerException
|
||||
* @return string|bool Value from the 'extblacklist' array, in the config
|
||||
*/
|
||||
public static function getSafeExtension(string $filename)
|
||||
{
|
||||
public static function getSafeExtension(string $filename) {
|
||||
if (preg_match('/^.+?\.([A-Za-z0-9]+)$/', $filename, $matches) === 1) {
|
||||
// we matched on a file extension, so let's see if it means something.
|
||||
$ext = mb_strtolower($matches[1]);
|
||||
@@ -375,7 +375,6 @@ class File extends Managed_DataObject
|
||||
* @param $filename string An optional filename which we can use on failure.
|
||||
* @return mixed|string
|
||||
* @throws ClientException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public static function guessMimeExtension($mimetype, $filename=null)
|
||||
{
|
||||
@@ -413,7 +412,7 @@ class File extends Managed_DataObject
|
||||
|
||||
/**
|
||||
* Validation for as-saved base filenames
|
||||
* @param mixed $filename
|
||||
* @param $filename
|
||||
* @return false|int
|
||||
*/
|
||||
public static function validFilename($filename)
|
||||
@@ -421,12 +420,7 @@ class File extends Managed_DataObject
|
||||
return preg_match('/^[A-Za-z0-9._-]+$/', $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $filename
|
||||
* @return string
|
||||
* @throws InvalidFilenameException
|
||||
*/
|
||||
public static function tryFilename($filename): string
|
||||
public static function tryFilename($filename)
|
||||
{
|
||||
if (!self::validFilename($filename)) {
|
||||
throw new InvalidFilenameException($filename);
|
||||
@@ -436,22 +430,15 @@ class File extends Managed_DataObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a path
|
||||
*
|
||||
* @param mixed $filename Will be tested by tryFilename
|
||||
* @param string|null $dir Attachments directory by default
|
||||
* @param bool $test_filename
|
||||
* @param $filename
|
||||
* @return string
|
||||
* @throws InvalidFilenameException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public static function path($filename, ?string $dir = null, bool $test_filename = true)
|
||||
public static function path($filename)
|
||||
{
|
||||
if ($test_filename) {
|
||||
self::tryFilename($filename);
|
||||
}
|
||||
self::tryFilename($filename);
|
||||
|
||||
$dir = $dir ?? common_config('attachments', 'dir');
|
||||
$dir = common_config('attachments', 'dir');
|
||||
|
||||
if (!in_array($dir[mb_strlen($dir)-1], ['/', '\\'])) {
|
||||
$dir .= DIRECTORY_SEPARATOR;
|
||||
@@ -576,7 +563,7 @@ class File extends Managed_DataObject
|
||||
* @throws UnsupportedMediaException if, despite trying, we can't understand how to make a thumbnail for this format
|
||||
* @throws ServerException on various other errors
|
||||
*/
|
||||
public function getThumbnail($width = null, $height = null, $crop = false, $force_still = true, $upscale = null): File_thumbnail
|
||||
public function getThumbnail($width=null, $height=null, $crop=false, $force_still=true, $upscale=null)
|
||||
{
|
||||
// Get some more information about this file through our ImageFile class
|
||||
$image = ImageFile::fromFileObject($this);
|
||||
@@ -615,14 +602,13 @@ class File extends Managed_DataObject
|
||||
* Returns the path to either a file, or it's thumbnail if the file doesn't exist.
|
||||
* This is useful in case the original file is deleted, or, as is the case for Embed
|
||||
* thumbnails, we only have a thumbnail and not a file
|
||||
* @param File_thumbnail|null $thumbnail
|
||||
* @return string Path
|
||||
* @throws FileNotFoundException
|
||||
* @throws FileNotStoredLocallyException
|
||||
* @throws InvalidFilenameException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function getFileOrThumbnailPath(?File_thumbnail $thumbnail = null): string
|
||||
public function getFileOrThumbnailPath($thumbnail = null) : string
|
||||
{
|
||||
if (!empty($thumbnail)) {
|
||||
return $thumbnail->getPath();
|
||||
@@ -646,15 +632,13 @@ class File extends Managed_DataObject
|
||||
|
||||
/**
|
||||
* Return the mime type of the thumbnail if we have it, or, if not, of the File
|
||||
* @param File_thumbnail|null $thumbnail
|
||||
* @return string
|
||||
* @throws FileNotFoundException
|
||||
* @throws NoResultException
|
||||
* @throws ServerException
|
||||
* @throws UnsupportedMediaException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getFileOrThumbnailMimetype(?File_thumbnail $thumbnail = null) : string
|
||||
public function getFileOrThumbnailMimetype($thumbnail = null) : string
|
||||
{
|
||||
if (!empty($thumbnail)) {
|
||||
$filepath = $thumbnail->getPath();
|
||||
@@ -674,18 +658,17 @@ class File extends Managed_DataObject
|
||||
|
||||
/**
|
||||
* Return the size of the thumbnail if we have it, or, if not, of the File
|
||||
* @param File_thumbnail|null $thumbnail
|
||||
* @return int
|
||||
* @throws FileNotFoundException
|
||||
* @throws NoResultException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function getFileOrThumbnailSize(?File_thumbnail $thumbnail = null) : int
|
||||
public function getFileOrThumbnailSize($thumbnail = null) : int
|
||||
{
|
||||
if (!empty($thumbnail)) {
|
||||
return filesize($thumbnail->getPath());
|
||||
} elseif (!empty($this->filename)) {
|
||||
return $this->getSize();
|
||||
return $this->size;
|
||||
} else {
|
||||
return filesize(File_thumbnail::byFile($this)->getPath());
|
||||
}
|
||||
@@ -760,12 +743,9 @@ class File extends Managed_DataObject
|
||||
if ($file instanceof File) {
|
||||
throw new ServerException('URL already exists in DB');
|
||||
}
|
||||
$sql = 'UPDATE %1$s SET urlhash=%2$s, url=%3$s WHERE urlhash=%4$s;';
|
||||
$result = $this->query(sprintf(
|
||||
<<<'END'
|
||||
UPDATE %1$s
|
||||
SET urlhash = %2$s, url = %3$s, modified = CURRENT_TIMESTAMP
|
||||
WHERE urlhash = %4$s;
|
||||
END,
|
||||
$sql,
|
||||
$this->tableName(),
|
||||
$this->_quote((string)self::hashurl($url)),
|
||||
$this->_quote((string)$url),
|
||||
@@ -818,7 +798,7 @@ class File extends Managed_DataObject
|
||||
public function noticeCount()
|
||||
{
|
||||
$cacheKey = sprintf('file:notice-count:%d', $this->id);
|
||||
|
||||
|
||||
$count = self::cacheGet($cacheKey);
|
||||
|
||||
if ($count === false) {
|
||||
@@ -850,19 +830,20 @@ class File extends Managed_DataObject
|
||||
}
|
||||
|
||||
// Clear out related things in the database and filesystem, such as thumbnails
|
||||
$related = [
|
||||
'File_redirection',
|
||||
'File_thumbnail',
|
||||
'File_to_post',
|
||||
];
|
||||
Event::handle('FileDeleteRelated', [$this, &$related]);
|
||||
if (Event::handle('FileDeleteRelated', array($this))) {
|
||||
$thumbs = new File_thumbnail();
|
||||
$thumbs->file_id = $this->id;
|
||||
if ($thumbs->find()) {
|
||||
while ($thumbs->fetch()) {
|
||||
$thumbs->delete();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($related as $cls) {
|
||||
$inst = new $cls();
|
||||
$inst->file_id = $this->id;
|
||||
if ($inst->find()) {
|
||||
while ($inst->fetch()) {
|
||||
$inst->delete();
|
||||
$f2p = new File_to_post();
|
||||
$f2p->file_id = $this->id;
|
||||
if ($f2p->find()) {
|
||||
while ($f2p->fetch()) {
|
||||
$f2p->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -907,11 +888,7 @@ class File extends Managed_DataObject
|
||||
echo "\nFound old $table table, upgrading it to contain 'urlhash' field...";
|
||||
|
||||
$file = new File();
|
||||
$file->query(sprintf(
|
||||
'SELECT id, LEFT(url, 191) AS shortenedurl, COUNT(*) FROM %1$s ' .
|
||||
'WHERE LENGTH(url) > 191 GROUP BY id, shortenedurl HAVING COUNT(*) > 1',
|
||||
common_database_tablename($table)
|
||||
));
|
||||
$file->query(sprintf('SELECT id, LEFT(url, 191) AS shortenedurl, COUNT(*) AS c FROM %1$s WHERE LENGTH(url)>191 GROUP BY shortenedurl HAVING c > 1', $schema->quoteIdentifier($table)));
|
||||
print "\nFound {$file->N} URLs with too long entries in file table\n";
|
||||
while ($file->fetch()) {
|
||||
// We've got a URL that is too long for our future file table
|
||||
@@ -941,7 +918,7 @@ class File extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
echo "...and now all the non-duplicates which are longer than 191 characters...\n";
|
||||
$file->query('UPDATE file SET url = LEFT(url, 191) WHERE LENGTH(url) > 191');
|
||||
$file->query('UPDATE file SET url=LEFT(url, 191) WHERE LENGTH(url)>191');
|
||||
|
||||
echo "\n...now running hacky pre-schemaupdate change for $table:";
|
||||
// We have to create a urlhash that is _not_ the primary key,
|
||||
@@ -964,20 +941,13 @@ class File extends Managed_DataObject
|
||||
$tablefix = new $classname;
|
||||
// urlhash is hash('sha256', $url) in the File table
|
||||
echo "Updating urlhash fields in $table table...";
|
||||
switch (common_config('db', 'type')) {
|
||||
case 'pgsql':
|
||||
$url_sha256 = 'encode(sha256(CAST("url" AS bytea)), \'hex\')';
|
||||
break;
|
||||
case 'mysql':
|
||||
$url_sha256 = 'sha2(`url`, 256)';
|
||||
break;
|
||||
default:
|
||||
throw new ServerException('Unknown DB type selected.');
|
||||
}
|
||||
// Maybe very MySQL specific :(
|
||||
$tablefix->query(sprintf(
|
||||
'UPDATE %1$s SET urlhash = %2$s, modified = CURRENT_TIMESTAMP;',
|
||||
$tablefix->escapedTableName(),
|
||||
$url_sha256
|
||||
'UPDATE %1$s SET %2$s=%3$s;',
|
||||
$schema->quoteIdentifier($table),
|
||||
'urlhash',
|
||||
// The line below is "result of sha256 on column `url`"
|
||||
'SHA2(url, 256)'
|
||||
));
|
||||
echo "DONE.\n";
|
||||
echo "Resuming core schema upgrade...";
|
||||
|
||||
+84
-120
@@ -1,24 +1,28 @@
|
||||
<?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) 2008, 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/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Table Definition for file_redirection
|
||||
*/
|
||||
|
||||
class File_redirection extends Managed_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
@@ -30,7 +34,7 @@ class File_redirection extends Managed_DataObject
|
||||
public $file_id; // int(4)
|
||||
public $redirections; // int(4)
|
||||
public $httpcode; // int(4)
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -46,25 +50,21 @@ class File_redirection extends Managed_DataObject
|
||||
'file_id' => array('type' => 'int', 'description' => 'short URL for what URL/file'),
|
||||
'redirections' => array('type' => 'int', 'description' => 'redirect count'),
|
||||
'httpcode' => array('type' => 'int', 'description' => 'HTTP status code (20x, 30x, etc.)'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('urlhash'),
|
||||
'foreign keys' => array(
|
||||
'file_redirection_file_id_fkey' => array('file', array('file_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'file_redirection_file_id_idx' => array('file_id'),
|
||||
'file_redirection_file_id_fkey' => array('file' => array('file_id' => 'id')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getByUrl($url)
|
||||
static public function getByUrl($url)
|
||||
{
|
||||
return self::getByPK(array('urlhash' => File::hashurl($url)));
|
||||
}
|
||||
|
||||
public static function _commonHttp($url, $redirs)
|
||||
{
|
||||
static function _commonHttp($url, $redirs) {
|
||||
$request = new HTTPClient($url);
|
||||
$request->setConfig(array(
|
||||
'connect_timeout' => 10, // # seconds to wait
|
||||
@@ -96,13 +96,10 @@ class File_redirection extends Managed_DataObject
|
||||
* size (optional): byte size from Content-Length header
|
||||
* time (optional): timestamp from Last-Modified header
|
||||
*/
|
||||
public static function lookupWhere($short_url, $redirs = 10, $protected = false)
|
||||
{
|
||||
if ($redirs < 0) {
|
||||
return false;
|
||||
}
|
||||
static function lookupWhere($short_url, $redirs = 10, $protected = false) {
|
||||
if ($redirs < 0) return false;
|
||||
|
||||
if (strpos($short_url, '://') === false) {
|
||||
if(strpos($short_url,'://') === false){
|
||||
return $short_url;
|
||||
}
|
||||
try {
|
||||
@@ -131,13 +128,13 @@ class File_redirection extends Managed_DataObject
|
||||
common_log(LOG_ERR, "Error while following redirects for $short_url: " . $e->getMessage());
|
||||
return $short_url;
|
||||
}
|
||||
|
||||
// if last url after all redirections is protected,
|
||||
// use the url before it in the redirection chain
|
||||
|
||||
// if last url after all redirections is protected,
|
||||
// use the url before it in the redirection chain
|
||||
if ($response->getRedirectCount() && File::isProtected($response->getEffectiveUrl())) {
|
||||
$return_url = $response->redirUrls[$response->getRedirectCount() - 1];
|
||||
$return_url = $response->redirUrls[$response->getRedirectCount()-1];
|
||||
} else {
|
||||
$return_url = $response->getEffectiveUrl();
|
||||
$return_url = $response->getEffectiveUrl();
|
||||
}
|
||||
|
||||
$ret = array('code' => $response->getStatus()
|
||||
@@ -145,20 +142,12 @@ class File_redirection extends Managed_DataObject
|
||||
, 'url' => $return_url);
|
||||
|
||||
$type = $response->getHeader('Content-Type');
|
||||
if ($type) {
|
||||
$ret['type'] = $type;
|
||||
}
|
||||
if ($protected) {
|
||||
$ret['protected'] = true;
|
||||
}
|
||||
if ($type) $ret['type'] = $type;
|
||||
if ($protected) $ret['protected'] = true;
|
||||
$size = $response->getHeader('Content-Length'); // @fixme bytes?
|
||||
if ($size) {
|
||||
$ret['size'] = $size;
|
||||
}
|
||||
if ($size) $ret['size'] = $size;
|
||||
$time = $response->getHeader('Last-Modified');
|
||||
if ($time) {
|
||||
$ret['time'] = strtotime($time);
|
||||
}
|
||||
if ($time) $ret['time'] = strtotime($time);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@@ -175,8 +164,7 @@ class File_redirection extends Managed_DataObject
|
||||
* @param boolean $discover true to attempt dereferencing the redirect if we don't know it already
|
||||
* @return File_redirection
|
||||
*/
|
||||
public static function where($in_url, $discover = true)
|
||||
{
|
||||
static function where($in_url, $discover=true) {
|
||||
$redir = new File_redirection();
|
||||
$redir->url = $in_url;
|
||||
$redir->urlhash = File::hashurl($redir->url);
|
||||
@@ -191,16 +179,14 @@ class File_redirection extends Managed_DataObject
|
||||
$r->redir_url = $f->url;
|
||||
} catch (NoResultException $e) {
|
||||
// Invalid entry, delete and run again
|
||||
common_log(
|
||||
LOG_ERR,
|
||||
'Could not find File with id=' . $r->file_id . ' referenced in File_redirection, deleting File redirection entry and and trying again...'
|
||||
);
|
||||
common_log(LOG_ERR, "Could not find File with id=".$r->file_id." referenced in File_redirection, deleting File redirection entry and and trying again...");
|
||||
$r->delete();
|
||||
return self::where($in_url);
|
||||
return self::where($in_url);
|
||||
}
|
||||
|
||||
// File_redirecion and File record found, return both
|
||||
return $r;
|
||||
|
||||
} catch (NoResultException $e) {
|
||||
// File_redirecion record not found, but this might be a direct link to a file
|
||||
try {
|
||||
@@ -208,15 +194,15 @@ class File_redirection extends Managed_DataObject
|
||||
$redir->file_id = $f->id;
|
||||
$redir->file = $f;
|
||||
return $redir;
|
||||
} catch (NoResultException $e) {
|
||||
} catch (NoResultException $e) {
|
||||
// nope, this was not a direct link to a file either, let's keep going
|
||||
}
|
||||
}
|
||||
|
||||
if ($discover) {
|
||||
// try to follow redirects and get the final url
|
||||
if ($discover) {
|
||||
// try to follow redirects and get the final url
|
||||
$redir_info = File_redirection::lookupWhere($in_url);
|
||||
if (is_string($redir_info)) {
|
||||
if(is_string($redir_info)) {
|
||||
$redir_info = array('url' => $redir_info);
|
||||
}
|
||||
|
||||
@@ -226,32 +212,29 @@ class File_redirection extends Managed_DataObject
|
||||
try {
|
||||
$r = File_redirection::getByUrl($redir_info['url']);
|
||||
|
||||
$f = File::getKV('id', $r->file_id);
|
||||
$f = File::getKV('id',$r->file_id);
|
||||
|
||||
if ($f instanceof File) {
|
||||
if($f instanceof File) {
|
||||
$redir->file = $f;
|
||||
$redir->redir_url = $f->url;
|
||||
$redir->redir_url = $f->url;
|
||||
} else {
|
||||
// Invalid entry in File_redirection, delete and run again
|
||||
common_log(
|
||||
LOG_ERR,
|
||||
'Could not find File with id=' . $r->file_id . ' referenced in File_redirection, deleting File_redirection entry and trying again...'
|
||||
);
|
||||
common_log(LOG_ERR, "Could not find File with id=".$r->file_id." referenced in File_redirection, deleting File_redirection entry and trying again...");
|
||||
$r->delete();
|
||||
return self::where($in_url);
|
||||
return self::where($in_url);
|
||||
}
|
||||
} catch (NoResultException $e) {
|
||||
// save the file now when we know that we don't have it in File_redirection
|
||||
try {
|
||||
$redir->file = File::saveNew($redir_info, $redir_info['url']);
|
||||
$redir->file = File::saveNew($redir_info,$redir_info['url']);
|
||||
} catch (ServerException $e) {
|
||||
common_log(LOG_ERR, $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this is a redirection and we have a file to redirect to, save it
|
||||
// (if it doesn't exist in File_redirection already)
|
||||
if ($redir->file instanceof File && $redir_info['url'] != $in_url) {
|
||||
// (if it doesn't exist in File_redirection already)
|
||||
if($redir->file instanceof File && $redir_info['url'] != $in_url) {
|
||||
try {
|
||||
$file_redir = File_redirection::getByUrl($in_url);
|
||||
} catch (NoResultException $e) {
|
||||
@@ -260,12 +243,12 @@ class File_redirection extends Managed_DataObject
|
||||
$file_redir->url = $in_url;
|
||||
$file_redir->file_id = $redir->file->getID();
|
||||
$file_redir->insert();
|
||||
$file_redir->redir_url = $redir->file->url;
|
||||
}
|
||||
$file_redir->redir_url = $redir->file->url;
|
||||
}
|
||||
|
||||
$file_redir->file = $redir->file;
|
||||
return $file_redir;
|
||||
}
|
||||
$file_redir->file = $redir->file;
|
||||
return $file_redir;
|
||||
}
|
||||
}
|
||||
|
||||
return $redir;
|
||||
@@ -285,7 +268,7 @@ class File_redirection extends Managed_DataObject
|
||||
* @param User $user whose shortening options to use; defaults to the current web session user
|
||||
* @return string
|
||||
*/
|
||||
public static function makeShort($long_url, $user = null)
|
||||
static function makeShort($long_url, $user=null)
|
||||
{
|
||||
$canon = File_redirection::_canonUrl($long_url);
|
||||
|
||||
@@ -310,7 +293,7 @@ class File_redirection extends Managed_DataObject
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public static function forceShort($long_url, $user)
|
||||
static function forceShort($long_url, $user)
|
||||
{
|
||||
$canon = File_redirection::_canonUrl($long_url);
|
||||
|
||||
@@ -320,8 +303,7 @@ class File_redirection extends Managed_DataObject
|
||||
return !empty($short_url) ? $short_url : $long_url;
|
||||
}
|
||||
|
||||
public static function _userMakeShort($long_url, User $user = null, $force = false)
|
||||
{
|
||||
static function _userMakeShort($long_url, User $user=null, $force = false) {
|
||||
$short_url = common_shorten_url($long_url, $user, $force);
|
||||
if (!empty($short_url) && $short_url != $long_url) {
|
||||
$short_url = (string)$short_url;
|
||||
@@ -361,11 +343,8 @@ class File_redirection extends Managed_DataObject
|
||||
* @param string $default_scheme if given a bare link; defaults to 'http://'
|
||||
* @return string
|
||||
*/
|
||||
public static function _canonUrl($in_url, $default_scheme = 'http://')
|
||||
{
|
||||
if (empty($in_url)) {
|
||||
return false;
|
||||
}
|
||||
static function _canonUrl($in_url, $default_scheme = 'http://') {
|
||||
if (empty($in_url)) return false;
|
||||
$out_url = $in_url;
|
||||
$p = parse_url($out_url);
|
||||
if (empty($p['host']) || empty($p['scheme'])) {
|
||||
@@ -398,17 +377,13 @@ class File_redirection extends Managed_DataObject
|
||||
default:
|
||||
$out_url = $default_scheme . ltrim($out_url, '/');
|
||||
$p = parse_url($out_url);
|
||||
if (empty($p['scheme'])) {
|
||||
return false;
|
||||
}
|
||||
if (empty($p['scheme'])) return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (('ftp' == $p['scheme']) || ('ftps' == $p['scheme']) || ('http' == $p['scheme']) || ('https' == $p['scheme'])) {
|
||||
if (empty($p['host'])) {
|
||||
return false;
|
||||
}
|
||||
if (empty($p['host'])) return false;
|
||||
if (empty($p['path'])) {
|
||||
$out_url .= '/';
|
||||
}
|
||||
@@ -417,8 +392,7 @@ class File_redirection extends Managed_DataObject
|
||||
return $out_url;
|
||||
}
|
||||
|
||||
public static function saveNew($data, $file_id, $url)
|
||||
{
|
||||
static function saveNew($data, $file_id, $url) {
|
||||
$file_redir = new File_redirection;
|
||||
$file_redir->urlhash = File::hashurl($url);
|
||||
$file_redir->url = $url;
|
||||
@@ -428,7 +402,7 @@ class File_redirection extends Managed_DataObject
|
||||
$file_redir->insert();
|
||||
}
|
||||
|
||||
public static function beforeSchemaUpdate()
|
||||
static public function beforeSchemaUpdate()
|
||||
{
|
||||
$table = strtolower(get_called_class());
|
||||
$schema = Schema::get();
|
||||
@@ -442,16 +416,16 @@ class File_redirection extends Managed_DataObject
|
||||
echo "\nFound old $table table, upgrading it to contain 'urlhash' field...";
|
||||
// We have to create a urlhash that is _not_ the primary key,
|
||||
// transfer data and THEN run checkSchema
|
||||
$schemadef['fields']['urlhash'] = [
|
||||
'type' => 'varchar',
|
||||
'length' => 64,
|
||||
'not null' => true,
|
||||
'description' => 'sha256 hash of the URL',
|
||||
];
|
||||
$schemadef['fields']['url'] = [
|
||||
'type' => 'text',
|
||||
'description' => 'short URL (or any other kind of redirect) for file (id)',
|
||||
];
|
||||
$schemadef['fields']['urlhash'] = array (
|
||||
'type' => 'varchar',
|
||||
'length' => 64,
|
||||
'not null' => true,
|
||||
'description' => 'sha256 hash of the URL',
|
||||
);
|
||||
$schemadef['fields']['url'] = array (
|
||||
'type' => 'text',
|
||||
'description' => 'short URL (or any other kind of redirect) for file (id)',
|
||||
);
|
||||
unset($schemadef['primary key']);
|
||||
$schema->ensureTable($table, $schemadef);
|
||||
echo "DONE.\n";
|
||||
@@ -460,27 +434,17 @@ class File_redirection extends Managed_DataObject
|
||||
$tablefix = new $classname;
|
||||
// urlhash is hash('sha256', $url) in the File table
|
||||
echo "Updating urlhash fields in $table table...";
|
||||
switch (common_config('db', 'type')) {
|
||||
case 'pgsql':
|
||||
$url_sha256 = 'encode(sha256(CAST("url" AS bytea)), \'hex\')';
|
||||
break;
|
||||
case 'mysql':
|
||||
$url_sha256 = 'sha2(`url`, 256)';
|
||||
break;
|
||||
default:
|
||||
throw new ServerException('Unknown DB type selected.');
|
||||
}
|
||||
$tablefix->query(sprintf(
|
||||
'UPDATE %1$s SET urlhash = %2$s, modified = CURRENT_TIMESTAMP;',
|
||||
$tablefix->escapedTableName(),
|
||||
$url_sha256
|
||||
));
|
||||
// Maybe very MySQL specific :(
|
||||
$tablefix->query(sprintf('UPDATE %1$s SET %2$s=%3$s;',
|
||||
$schema->quoteIdentifier($table),
|
||||
'urlhash',
|
||||
// The line below is "result of sha256 on column `url`"
|
||||
'SHA2(url, 256)'));
|
||||
echo "DONE.\n";
|
||||
echo "Resuming core schema upgrade...";
|
||||
}
|
||||
|
||||
public function getFile()
|
||||
{
|
||||
public function getFile() {
|
||||
if (!$this->file instanceof File) {
|
||||
$this->file = File::getByID($this->file_id);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
<?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/>.
|
||||
|
||||
/*
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 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/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Table Definition for file_thumbnail
|
||||
*/
|
||||
|
||||
class File_thumbnail extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'file_thumbnail'; // table name
|
||||
@@ -33,7 +32,7 @@ class File_thumbnail extends Managed_DataObject
|
||||
public $filename; // text
|
||||
public $width; // int(4) primary_key
|
||||
public $height; // int(4) primary_key
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
const URLHASH_ALG = 'sha256';
|
||||
|
||||
@@ -45,12 +44,13 @@ class File_thumbnail extends Managed_DataObject
|
||||
'urlhash' => array('type' => 'varchar', 'length' => 64, 'description' => 'sha256 of url field if non-empty'),
|
||||
'url' => array('type' => 'text', 'description' => 'URL of thumbnail'),
|
||||
'filename' => array('type' => 'text', 'description' => 'if stored locally, filename is put here'),
|
||||
'width' => array('type' => 'int', 'not null' => true, 'description' => 'width of thumbnail'),
|
||||
'height' => array('type' => 'int', 'not null' => true, 'description' => 'height of thumbnail'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'width' => array('type' => 'int', 'description' => 'width of thumbnail'),
|
||||
'height' => array('type' => 'int', 'description' => 'height of thumbnail'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('file_id', 'width', 'height'),
|
||||
'indexes' => array(
|
||||
'file_thumbnail_file_id_idx' => array('file_id'),
|
||||
'file_thumbnail_urlhash_idx' => array('urlhash'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
@@ -65,26 +65,21 @@ class File_thumbnail extends Managed_DataObject
|
||||
* @param object $data
|
||||
* @param int $file_id
|
||||
*/
|
||||
public static function saveNew($data, $file_id)
|
||||
{
|
||||
public static function saveNew($data, $file_id) {
|
||||
if (!empty($data->thumbnail_url)) {
|
||||
// Non-photo types such as video will usually
|
||||
// show us a thumbnail, though it's not required.
|
||||
self::saveThumbnail(
|
||||
$file_id,
|
||||
$data->thumbnail_url,
|
||||
$data->thumbnail_width,
|
||||
$data->thumbnail_height
|
||||
);
|
||||
} elseif ($data->type == 'photo') {
|
||||
self::saveThumbnail($file_id,
|
||||
$data->thumbnail_url,
|
||||
$data->thumbnail_width,
|
||||
$data->thumbnail_height);
|
||||
} else if ($data->type == 'photo') {
|
||||
// The inline photo URL given should also fit within
|
||||
// our requested thumbnail size, per oEmbed spec.
|
||||
self::saveThumbnail(
|
||||
$file_id,
|
||||
$data->url,
|
||||
$data->width,
|
||||
$data->height
|
||||
);
|
||||
self::saveThumbnail($file_id,
|
||||
$data->url,
|
||||
$data->width,
|
||||
$data->height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,8 +92,7 @@ class File_thumbnail extends Managed_DataObject
|
||||
* @return File_thumbnail
|
||||
* @throws NoResultException if no File_thumbnail matched the criteria
|
||||
*/
|
||||
public static function byFile(File $file, $notNullUrl = true)
|
||||
{
|
||||
static function byFile(File $file, $notNullUrl=true) {
|
||||
$thumb = new File_thumbnail();
|
||||
$thumb->file_id = $file->getID();
|
||||
if ($notNullUrl) {
|
||||
@@ -122,7 +116,7 @@ class File_thumbnail extends Managed_DataObject
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
*/
|
||||
public static function saveThumbnail($file_id, $url, $width, $height, $filename = null)
|
||||
static function saveThumbnail($file_id, $url, $width, $height, $filename=null)
|
||||
{
|
||||
$tn = new File_thumbnail;
|
||||
$tn->file_id = $file_id;
|
||||
@@ -134,7 +128,7 @@ class File_thumbnail extends Managed_DataObject
|
||||
return $tn;
|
||||
}
|
||||
|
||||
public static function path($filename)
|
||||
static function path($filename)
|
||||
{
|
||||
File::tryFilename($filename);
|
||||
|
||||
@@ -148,7 +142,7 @@ class File_thumbnail extends Managed_DataObject
|
||||
return $dir . $filename;
|
||||
}
|
||||
|
||||
public static function url($filename)
|
||||
static function url($filename)
|
||||
{
|
||||
File::tryFilename($filename);
|
||||
|
||||
@@ -282,7 +276,7 @@ class File_thumbnail extends Managed_DataObject
|
||||
return $this->file_id;
|
||||
}
|
||||
|
||||
public static function hashurl($url)
|
||||
static public function hashurl($url)
|
||||
{
|
||||
if (!mb_strlen($url)) {
|
||||
throw new Exception('No URL provided to hash algorithm.');
|
||||
|
||||
+26
-26
@@ -1,28 +1,28 @@
|
||||
<?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) 2008, 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('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Table Definition for file_to_post
|
||||
*
|
||||
* @copyright 2008, 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class File_to_post extends Managed_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
@@ -31,7 +31,7 @@ class File_to_post extends Managed_DataObject
|
||||
public $__table = 'file_to_post'; // table name
|
||||
public $file_id; // int(4) primary_key not_null
|
||||
public $post_id; // int(4) primary_key not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -42,7 +42,7 @@ class File_to_post extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'file_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of URL/file'),
|
||||
'post_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the notice it belongs to'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('file_id', 'post_id'),
|
||||
'foreign keys' => array(
|
||||
@@ -50,13 +50,13 @@ class File_to_post extends Managed_DataObject
|
||||
'file_to_post_post_id_fkey' => array('notice', array('post_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'file_to_post_post_id_idx' => array('post_id'),
|
||||
'file_id_idx' => array('file_id'),
|
||||
'post_id_idx' => array('post_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function processNew(File $file, Notice $notice)
|
||||
{
|
||||
static function processNew(File $file, Notice $notice) {
|
||||
static $seen = array();
|
||||
|
||||
$file_id = $file->getID();
|
||||
@@ -82,7 +82,7 @@ class File_to_post extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public static function getNoticeIDsByFile(File $file)
|
||||
static function getNoticeIDsByFile(File $file)
|
||||
{
|
||||
$f2p = new File_to_post();
|
||||
|
||||
@@ -100,7 +100,7 @@ class File_to_post extends Managed_DataObject
|
||||
return $f2p->fetchAll('post_id');
|
||||
}
|
||||
|
||||
public function delete($useWhere = false)
|
||||
function delete($useWhere=false)
|
||||
{
|
||||
try {
|
||||
$f = File::getByID($this->file_id);
|
||||
|
||||
+21
-39
@@ -1,24 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for foreign_link
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Foreign_link extends Managed_DataObject
|
||||
{
|
||||
@@ -29,14 +13,14 @@ class Foreign_link extends Managed_DataObject
|
||||
public $user_id; // int(4) primary_key not_null
|
||||
public $foreign_id; // bigint(8) primary_key not_null unsigned
|
||||
public $service; // int(4) primary_key not_null
|
||||
public $credentials; // blob
|
||||
public $credentials; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $noticesync; // tinyint(1) not_null default_1
|
||||
public $friendsync; // tinyint(1) not_null default_2
|
||||
public $profilesync; // tinyint(1) not_null default_1
|
||||
public $last_noticesync; // datetime()
|
||||
public $last_friendsync; // datetime()
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -46,31 +30,30 @@ class Foreign_link extends Managed_DataObject
|
||||
return array(
|
||||
'fields' => array(
|
||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'link to user on this system, if exists'),
|
||||
'foreign_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'link to user on foreign service, if exists'),
|
||||
'foreign_id' => array('type' => 'int', 'size' => 'big', 'unsigned' => true, 'not null' => true, 'description' => 'link to user on foreign service, if exists'),
|
||||
'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'),
|
||||
'credentials' => array('type' => 'blob', 'description' => 'authc credentials, typically a password'),
|
||||
'credentials' => array('type' => 'varchar', 'length' => 191, 'description' => 'authc credentials, typically a password'),
|
||||
'noticesync' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'notice synchronization, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies'),
|
||||
'friendsync' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 2, 'description' => 'friend synchronization, bit 1 = sync outgoing, bit 2 = sync incoming'),
|
||||
'profilesync' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming'),
|
||||
'last_noticesync' => array('type' => 'datetime', 'description' => 'last time notices were imported'),
|
||||
'last_friendsync' => array('type' => 'datetime', 'description' => 'last time friends were imported'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('user_id', 'foreign_id', 'service'),
|
||||
'foreign keys' => array(
|
||||
'foreign_link_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||
'foreign_link_foreign_id_service_fkey' => array('foreign_user', array('foreign_id' => 'id', 'service' => 'service')),
|
||||
'foreign_link_foreign_id_fkey' => array('foreign_user', array('foreign_id' => 'id', 'service' => 'service')),
|
||||
'foreign_link_service_fkey' => array('foreign_service', array('service' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'foreign_link_foreign_id_service_idx' => array('foreign_id', 'service'),
|
||||
'foreign_link_service_idx' => array('service'),
|
||||
'foreign_user_user_id_idx' => array('user_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getByUserID($user_id, $service)
|
||||
static function getByUserID($user_id, $service)
|
||||
{
|
||||
if (empty($user_id) || empty($service)) {
|
||||
throw new ServerException('Empty user_id or service for Foreign_link::getByUserID');
|
||||
@@ -88,7 +71,7 @@ class Foreign_link extends Managed_DataObject
|
||||
return $flink;
|
||||
}
|
||||
|
||||
public static function getByForeignID($foreign_id, $service)
|
||||
static function getByForeignID($foreign_id, $service)
|
||||
{
|
||||
if (empty($foreign_id) || empty($service)) {
|
||||
throw new ServerException('Empty foreign_id or service for Foreign_link::getByForeignID');
|
||||
@@ -106,7 +89,7 @@ class Foreign_link extends Managed_DataObject
|
||||
return $flink;
|
||||
}
|
||||
|
||||
public function set_flags($noticesend, $noticerecv, $replysync, $repeatsync, $friendsync)
|
||||
function set_flags($noticesend, $noticerecv, $replysync, $repeatsync, $friendsync)
|
||||
{
|
||||
if ($noticesend) {
|
||||
$this->noticesync |= FOREIGN_NOTICE_SEND;
|
||||
@@ -142,7 +125,7 @@ class Foreign_link extends Managed_DataObject
|
||||
}
|
||||
|
||||
// Convenience methods
|
||||
public function getForeignUser()
|
||||
function getForeignUser()
|
||||
{
|
||||
$fuser = new Foreign_user();
|
||||
$fuser->service = $this->service;
|
||||
@@ -157,30 +140,29 @@ class Foreign_link extends Managed_DataObject
|
||||
return $fuser;
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
function getUser()
|
||||
{
|
||||
return Profile::getByID($this->user_id)->getUser();
|
||||
}
|
||||
|
||||
public function getProfile()
|
||||
function getProfile()
|
||||
{
|
||||
return Profile::getByID($this->user_id);
|
||||
}
|
||||
|
||||
// Make sure we only ever delete one record at a time
|
||||
public function safeDelete()
|
||||
function safeDelete()
|
||||
{
|
||||
if (!empty($this->user_id)
|
||||
&& !empty($this->foreign_id)
|
||||
&& !empty($this->service)) {
|
||||
&& !empty($this->service))
|
||||
{
|
||||
return $this->delete();
|
||||
} else {
|
||||
common_debug(
|
||||
LOG_WARNING,
|
||||
common_debug(LOG_WARNING,
|
||||
'Foreign_link::safeDelete() tried to delete a '
|
||||
. 'Foreign_link without a fully specified compound key: '
|
||||
. var_export($this, true)
|
||||
);
|
||||
. var_export($this, true));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for foreign_service
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Foreign_service extends Managed_DataObject
|
||||
{
|
||||
@@ -29,8 +13,8 @@ class Foreign_service extends Managed_DataObject
|
||||
public $id; // int(4) primary_key not_null
|
||||
public $name; // varchar(32) unique_key not_null
|
||||
public $description; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -42,8 +26,8 @@ class Foreign_service extends Managed_DataObject
|
||||
'id' => array('type' => 'int', 'not null' => true, 'description' => 'numeric key for service'),
|
||||
'name' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'name of the service'),
|
||||
'description' => array('type' => 'varchar', 'length' => 191, 'description' => 'description'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
|
||||
@@ -1,24 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for foreign_subscription
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Foreign_subscription extends Managed_DataObject
|
||||
{
|
||||
@@ -29,7 +13,7 @@ class Foreign_subscription extends Managed_DataObject
|
||||
public $service; // int(4) primary_key not_null
|
||||
public $subscriber; // int(4) primary_key not_null
|
||||
public $subscribed; // int(4) primary_key not_null
|
||||
public $created; // datetime()
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -42,18 +26,17 @@ class Foreign_subscription extends Managed_DataObject
|
||||
'service' => array('type' => 'int', 'not null' => true, 'description' => 'service where relationship happens'),
|
||||
'subscriber' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscriber on foreign service'),
|
||||
'subscribed' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscribed user'),
|
||||
'created' => array('type' => 'datetime', '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'),
|
||||
),
|
||||
'primary key' => array('service', 'subscriber', 'subscribed'),
|
||||
'foreign keys' => array(
|
||||
'foreign_subscription_service_fkey' => array('foreign_service', array('service' => 'id')),
|
||||
'foreign_subscription_subscriber_service_fkey' => array('foreign_user', array('subscriber' => 'id', 'service' => 'service')),
|
||||
'foreign_subscription_subscribed_service_fkey' => array('foreign_user', array('subscribed' => 'id', 'service' => 'service')),
|
||||
'foreign_subscription_subscriber_fkey' => array('foreign_user', array('subscriber' => 'id', 'service' => 'service')),
|
||||
'foreign_subscription_subscribed_fkey' => array('foreign_user', array('subscribed' => 'id', 'service' => 'service')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'foreign_subscription_subscriber_service_idx' => array('subscriber', 'service'),
|
||||
'foreign_subscription_subscribed_service_idx' => array('subscribed', 'service'),
|
||||
'foreign_subscription_service_subscribed_idx' => array('service', 'subscribed'),
|
||||
'foreign_subscription_subscriber_idx' => array('service', 'subscriber'),
|
||||
'foreign_subscription_subscribed_idx' => array('service', 'subscribed'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for foreign_user
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Foreign_user extends Managed_DataObject
|
||||
{
|
||||
@@ -30,8 +14,8 @@ class Foreign_user extends Managed_DataObject
|
||||
public $service; // int(4) primary_key not_null
|
||||
public $uri; // varchar(191) unique_key not_null not 255 because utf8mb4 takes more space
|
||||
public $nickname; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -44,8 +28,8 @@ class Foreign_user extends Managed_DataObject
|
||||
'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'),
|
||||
'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'identifying URI'),
|
||||
'nickname' => array('type' => 'varchar', 'length' => 191, 'description' => 'nickname on foreign service'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('id', 'service'),
|
||||
'foreign keys' => array(
|
||||
@@ -54,13 +38,10 @@ class Foreign_user extends Managed_DataObject
|
||||
'unique keys' => array(
|
||||
'foreign_user_uri_key' => array('uri'),
|
||||
),
|
||||
'indexes' => array(
|
||||
'foreign_user_service_idx' => array('service'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getForeignUser($id, $service)
|
||||
static function getForeignUser($id, $service)
|
||||
{
|
||||
if (empty($id) || empty($service)) {
|
||||
throw new ServerException('Empty foreign user id or service for Foreign_user::getForeignUser');
|
||||
@@ -78,7 +59,7 @@ class Foreign_user extends Managed_DataObject
|
||||
return $fuser;
|
||||
}
|
||||
|
||||
public static function getByNickname($nickname, $service)
|
||||
static function getByNickname($nickname, $service)
|
||||
{
|
||||
if (empty($nickname) || empty($service)) {
|
||||
throw new ServerException('Empty nickname or service for Foreign_user::getByNickname');
|
||||
|
||||
+20
-20
@@ -1,27 +1,27 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for group_alias
|
||||
*
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Group_alias extends Managed_DataObject
|
||||
{
|
||||
@@ -31,7 +31,7 @@ class Group_alias extends Managed_DataObject
|
||||
public $__table = 'group_alias'; // table name
|
||||
public $alias; // varchar(64) primary_key not_null
|
||||
public $group_id; // int(4) not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -42,7 +42,7 @@ class Group_alias extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'alias' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'),
|
||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date alias was created'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date alias was created'),
|
||||
),
|
||||
'primary key' => array('alias'),
|
||||
'foreign keys' => array(
|
||||
|
||||
+26
-34
@@ -1,29 +1,27 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for group_block
|
||||
*
|
||||
* @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
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 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/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Group_block extends Managed_DataObject
|
||||
{
|
||||
@@ -34,7 +32,7 @@ class Group_block extends Managed_DataObject
|
||||
public $group_id; // int(4) primary_key not_null
|
||||
public $blocked; // int(4) primary_key not_null
|
||||
public $blocker; // int(4) not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -46,7 +44,7 @@ class Group_block extends Managed_DataObject
|
||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'),
|
||||
'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'),
|
||||
'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date of blocking'),
|
||||
),
|
||||
'primary key' => array('group_id', 'blocked'),
|
||||
'foreign keys' => array(
|
||||
@@ -54,29 +52,23 @@ class Group_block extends Managed_DataObject
|
||||
'group_block_blocked_fkey' => array('profile', array('blocked' => 'id')),
|
||||
'group_block_blocker_fkey' => array('user', array('blocker' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'group_block_blocked_idx' => array('blocked'),
|
||||
'group_block_blocker_idx' => array('blocker'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function isBlocked($group, $profile)
|
||||
static function isBlocked($group, $profile)
|
||||
{
|
||||
$block = Group_block::pkeyGet([
|
||||
'group_id' => $group->id,
|
||||
'blocked' => $profile->id,
|
||||
]);
|
||||
$block = Group_block::pkeyGet(array('group_id' => $group->id,
|
||||
'blocked' => $profile->id));
|
||||
return !empty($block);
|
||||
}
|
||||
|
||||
public static function blockProfile($group, $profile, $blocker)
|
||||
static function blockProfile($group, $profile, $blocker)
|
||||
{
|
||||
// Insert the block
|
||||
|
||||
$block = new Group_block();
|
||||
|
||||
$block->query('START TRANSACTION');
|
||||
$block->query('BEGIN');
|
||||
|
||||
$block->group_id = $group->id;
|
||||
$block->blocked = $profile->id;
|
||||
@@ -111,7 +103,7 @@ class Group_block extends Managed_DataObject
|
||||
return $block;
|
||||
}
|
||||
|
||||
public static function unblockProfile($group, $profile)
|
||||
static function unblockProfile($group, $profile)
|
||||
{
|
||||
$block = Group_block::pkeyGet(array('group_id' => $group->id,
|
||||
'blocked' => $profile->id));
|
||||
|
||||
@@ -1,25 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for group_inbox
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Group_inbox extends Managed_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
@@ -28,7 +11,7 @@ class Group_inbox extends Managed_DataObject
|
||||
public $__table = 'group_inbox'; // table name
|
||||
public $group_id; // int(4) primary_key not_null
|
||||
public $notice_id; // int(4) primary_key not_null
|
||||
public $created; // datetime()
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -40,7 +23,7 @@ class Group_inbox extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group receiving the message'),
|
||||
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date the notice was created'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the notice was created'),
|
||||
),
|
||||
'primary key' => array('group_id', 'notice_id'),
|
||||
'foreign keys' => array(
|
||||
|
||||
@@ -1,24 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for request_queue
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Group_join_queue extends Managed_DataObject
|
||||
{
|
||||
@@ -39,8 +23,8 @@ class Group_join_queue extends Managed_DataObject
|
||||
'description' => 'Holder for group join requests awaiting moderation.',
|
||||
'fields' => array(
|
||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'),
|
||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local group to join, if any'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'group_id' => array('type' => 'int', 'description' => 'remote or local group to join, if any'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
),
|
||||
'primary key' => array('profile_id', 'group_id'),
|
||||
'indexes' => array(
|
||||
@@ -64,27 +48,27 @@ class Group_join_queue extends Managed_DataObject
|
||||
return $rq;
|
||||
}
|
||||
|
||||
public function getMember()
|
||||
function getMember()
|
||||
{
|
||||
$member = Profile::getKV('id', $this->profile_id);
|
||||
|
||||
if (empty($member)) {
|
||||
// TRANS: Exception thrown providing an 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;
|
||||
}
|
||||
|
||||
public function getGroup()
|
||||
function getGroup()
|
||||
{
|
||||
$group = User_group::getKV('id', $this->group_id);
|
||||
|
||||
if (empty($group)) {
|
||||
// TRANS: Exception thrown providing an 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;
|
||||
@@ -93,7 +77,7 @@ class Group_join_queue extends Managed_DataObject
|
||||
/**
|
||||
* Abort the pending group join...
|
||||
*/
|
||||
public function abort()
|
||||
function abort()
|
||||
{
|
||||
$profile = $this->getMember();
|
||||
$group = $this->getGroup();
|
||||
@@ -109,7 +93,7 @@ class Group_join_queue extends Managed_DataObject
|
||||
*
|
||||
* @return Group_member object on success
|
||||
*/
|
||||
public function complete()
|
||||
function complete()
|
||||
{
|
||||
$join = null;
|
||||
$profile = $this->getMember();
|
||||
|
||||
+27
-50
@@ -1,21 +1,4 @@
|
||||
<?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
|
||||
*/
|
||||
@@ -28,10 +11,10 @@ class Group_member extends Managed_DataObject
|
||||
public $__table = 'group_member'; // table name
|
||||
public $group_id; // int(4) primary_key not_null
|
||||
public $profile_id; // int(4) primary_key not_null
|
||||
public $is_admin; // bool default_false
|
||||
public $is_admin; // tinyint(1)
|
||||
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -42,10 +25,10 @@ class Group_member extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'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'),
|
||||
'is_admin' => array('type' => 'bool', 'default' => false, 'description' => 'is this user an admin?'),
|
||||
'is_admin' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this user an admin?'),
|
||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('group_id', 'profile_id'),
|
||||
'unique keys' => array(
|
||||
@@ -56,6 +39,8 @@ class Group_member extends Managed_DataObject
|
||||
'group_member_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
// @fixme probably we want a (profile_id, created) index here?
|
||||
'group_member_profile_id_idx' => array('profile_id'),
|
||||
'group_member_created_idx' => array('created'),
|
||||
'group_member_profile_id_created_idx' => array('profile_id', 'created'),
|
||||
'group_member_group_id_created_idx' => array('group_id', 'created'),
|
||||
@@ -69,22 +54,20 @@ class Group_member extends Managed_DataObject
|
||||
*
|
||||
* @param integer $group_id Group to add to
|
||||
* @param integer $profile_id Profile being added
|
||||
*
|
||||
*
|
||||
* @return Group_member new membership object
|
||||
*/
|
||||
|
||||
public static function join($group_id, $profile_id)
|
||||
static function join($group_id, $profile_id)
|
||||
{
|
||||
$member = new Group_member();
|
||||
|
||||
$member->group_id = $group_id;
|
||||
$member->profile_id = $profile_id;
|
||||
$member->created = common_sql_now();
|
||||
$member->uri = self::newUri(
|
||||
Profile::getByID($profile_id),
|
||||
User_group::getByID($group_id),
|
||||
$member->created
|
||||
);
|
||||
$member->uri = self::newUri(Profile::getByID($profile_id),
|
||||
User_group::getByID($group_id),
|
||||
$member->created);
|
||||
|
||||
$result = $member->insert();
|
||||
|
||||
@@ -97,7 +80,7 @@ class Group_member extends Managed_DataObject
|
||||
return $member;
|
||||
}
|
||||
|
||||
public static function leave($group_id, $profile_id)
|
||||
static function leave($group_id, $profile_id)
|
||||
{
|
||||
$member = Group_member::pkeyGet(array('group_id' => $group_id,
|
||||
'profile_id' => $profile_id));
|
||||
@@ -118,27 +101,27 @@ class Group_member extends Managed_DataObject
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getMember()
|
||||
function getMember()
|
||||
{
|
||||
$member = Profile::getKV('id', $this->profile_id);
|
||||
|
||||
if (empty($member)) {
|
||||
// TRANS: Exception thrown providing an 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;
|
||||
}
|
||||
|
||||
public function getGroup()
|
||||
function getGroup()
|
||||
{
|
||||
$group = User_group::getKV('id', $this->group_id);
|
||||
|
||||
if (empty($group)) {
|
||||
// TRANS: Exception thrown providing an 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;
|
||||
@@ -154,7 +137,7 @@ class Group_member extends Managed_DataObject
|
||||
* @return Group_member stream of memberships, use fetch() to iterate
|
||||
*/
|
||||
|
||||
public static function byMember($memberId, $offset = 0, $limit = GROUPS_PER_PAGE)
|
||||
static function byMember($memberId, $offset=0, $limit=GROUPS_PER_PAGE)
|
||||
{
|
||||
$membership = new Group_member();
|
||||
|
||||
@@ -169,7 +152,7 @@ class Group_member extends Managed_DataObject
|
||||
return $membership;
|
||||
}
|
||||
|
||||
public function asActivity()
|
||||
function asActivity()
|
||||
{
|
||||
$member = $this->getMember();
|
||||
|
||||
@@ -197,19 +180,13 @@ class Group_member extends Managed_DataObject
|
||||
|
||||
// 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.
|
||||
$act->content = sprintf(
|
||||
_('%1$s has joined group %2$s.'),
|
||||
$member->getBestName(),
|
||||
$group->getBestName()
|
||||
);
|
||||
$act->content = sprintf(_('%1$s has joined group %2$s.'),
|
||||
$member->getBestName(),
|
||||
$group->getBestName());
|
||||
|
||||
$url = common_local_url(
|
||||
'AtomPubShowMembership',
|
||||
[
|
||||
'profile' => $member->id,
|
||||
'group' => $group->id,
|
||||
]
|
||||
);
|
||||
$url = common_local_url('AtomPubShowMembership',
|
||||
array('profile' => $member->id,
|
||||
'group' => $group->id));
|
||||
|
||||
$act->selfLink = $url;
|
||||
$act->editLink = $url;
|
||||
@@ -226,7 +203,7 @@ class Group_member extends Managed_DataObject
|
||||
mail_notify_group_join($this->getGroup(), $this->getMember());
|
||||
}
|
||||
|
||||
public function getUri()
|
||||
function getUri()
|
||||
{
|
||||
return $this->uri ?: self::newUri($this->getMember(), $this->getGroup()->getProfile(), $this->created);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for invitation
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Invitation extends Managed_DataObject
|
||||
{
|
||||
@@ -31,12 +15,12 @@ class Invitation extends Managed_DataObject
|
||||
public $address; // varchar(191) multiple_key not_null not 255 because utf8mb4 takes more space
|
||||
public $address_type; // varchar(8) multiple_key not_null
|
||||
public $registered_user_id; // int(4) not_null
|
||||
public $created; // datetime()
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
public function convert($user)
|
||||
function convert($user)
|
||||
{
|
||||
$orig = clone($this);
|
||||
$this->registered_user_id = $user->id;
|
||||
@@ -52,7 +36,7 @@ class Invitation extends Managed_DataObject
|
||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'who sent the invitation'),
|
||||
'address' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'invitation sent to'),
|
||||
'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'),
|
||||
'created' => array('type' => 'datetime', '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'),
|
||||
'registered_user_id' => array('type' => 'int', 'not null' => false, 'description' => 'if the invitation is converted, who the new user is'),
|
||||
),
|
||||
'primary key' => array('code'),
|
||||
@@ -61,7 +45,7 @@ class Invitation extends Managed_DataObject
|
||||
'invitation_registered_user_id_fkey' => array('user', array('registered_user_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'invitation_address_address_type_idx' => array('address', 'address_type'),
|
||||
'invitation_address_idx' => array('address', 'address_type'),
|
||||
'invitation_user_id_idx' => array('user_id'),
|
||||
'invitation_registered_user_id_idx' => array('registered_user_id'),
|
||||
),
|
||||
|
||||
@@ -1,25 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for local_group
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Local_group extends Managed_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
@@ -28,8 +11,8 @@ class Local_group extends Managed_DataObject
|
||||
public $__table = 'local_group'; // table name
|
||||
public $group_id; // int(4) primary_key not_null
|
||||
public $nickname; // varchar(64) unique_key
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -41,8 +24,8 @@ class Local_group extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group represented'),
|
||||
'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'group represented'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('group_id'),
|
||||
'foreign keys' => array(
|
||||
@@ -71,23 +54,16 @@ class Local_group extends Managed_DataObject
|
||||
return $group;
|
||||
}
|
||||
|
||||
public function setNickname($nickname)
|
||||
function setNickname($nickname)
|
||||
{
|
||||
$this->decache();
|
||||
$modified = common_sql_now();
|
||||
$result = $this->query(sprintf(
|
||||
<<<'END'
|
||||
UPDATE local_group SET nickname = %1$s, modified = %2$s
|
||||
WHERE group_id = %3$d;
|
||||
END,
|
||||
$this->_quote($nickname),
|
||||
$this->_quote($modified),
|
||||
$this->group_id
|
||||
));
|
||||
$qry = 'UPDATE local_group set nickname = "'.$this->escape($nickname).'" where group_id = ' . $this->group_id;
|
||||
|
||||
$result = $this->query($qry);
|
||||
|
||||
if ($result) {
|
||||
$this->nickname = $nickname;
|
||||
$this->modified = $modified;
|
||||
$this->fixupTimestamps();
|
||||
$this->encache();
|
||||
} else {
|
||||
common_log_db_error($local, 'UPDATE', __FILE__);
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
<?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/>.
|
||||
|
||||
/*
|
||||
* Table Definition for location_namespace
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2009, StatusNet, Inc.
|
||||
*
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Table Definition for location_namespace
|
||||
*/
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Location_namespace extends Managed_DataObject
|
||||
{
|
||||
@@ -31,8 +33,8 @@ class Location_namespace extends Managed_DataObject
|
||||
public $__table = 'location_namespace'; // table name
|
||||
public $id; // int(4) primary_key not_null
|
||||
public $description; // varchar(191)
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -43,8 +45,8 @@ class Location_namespace extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'id' => array('type' => 'int', 'not null' => true, 'description' => 'identity for this namespace'),
|
||||
'description' => array('type' => 'varchar', 'length' => 191, 'description' => 'description of the namespace'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date the record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the record was created'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
);
|
||||
|
||||
+25
-27
@@ -1,27 +1,27 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for login_token
|
||||
*
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Login_token extends Managed_DataObject
|
||||
{
|
||||
@@ -31,8 +31,8 @@ class Login_token extends Managed_DataObject
|
||||
public $__table = 'login_token'; // table name
|
||||
public $user_id; // int(4) primary_key not_null
|
||||
public $token; // char(32) not_null
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -43,8 +43,8 @@ class Login_token extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user owning this token'),
|
||||
'token' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'token useable for logging in'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('user_id'),
|
||||
'foreign keys' => array(
|
||||
@@ -55,7 +55,7 @@ class Login_token extends Managed_DataObject
|
||||
|
||||
const TIMEOUT = 120; // seconds after which to timeout the token
|
||||
|
||||
public function makeNew($user)
|
||||
function makeNew($user)
|
||||
{
|
||||
$login_token = Login_token::getKV('user_id', $user->id);
|
||||
|
||||
@@ -75,10 +75,8 @@ class Login_token extends Managed_DataObject
|
||||
common_log_db_error($login_token, 'INSERT', __FILE__);
|
||||
// TRANS: Exception thrown when trying creating a login token failed.
|
||||
// TRANS: %s is the user nickname for which token creation failed.
|
||||
throw new Exception(sprintf(
|
||||
_('Could not create login token for %s'),
|
||||
$user->nickname
|
||||
));
|
||||
throw new Exception(sprintf(_('Could not create login token for %s'),
|
||||
$user->nickname));
|
||||
}
|
||||
|
||||
return $login_token;
|
||||
|
||||
@@ -1,31 +1,28 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
/*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrapper for Memcached_DataObject which knows its own schema definition.
|
||||
* Builds its own damn settings from a schema definition.
|
||||
*
|
||||
* @package GNUsocial
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @copyright 2010 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
abstract class Managed_DataObject extends Memcached_DataObject
|
||||
{
|
||||
/**
|
||||
@@ -45,7 +42,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* @return get_called_class() object if found, or null for no hits
|
||||
*
|
||||
*/
|
||||
public static function getKV($k, $v = null)
|
||||
static function getKV($k,$v=NULL)
|
||||
{
|
||||
return parent::getClassKV(get_called_class(), $k, $v);
|
||||
}
|
||||
@@ -62,12 +59,12 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* @return get_called_class() object if found, or null for no hits
|
||||
*
|
||||
*/
|
||||
public static function pkeyGet(array $kv)
|
||||
static function pkeyGet(array $kv)
|
||||
{
|
||||
return parent::pkeyGetClass(get_called_class(), $kv);
|
||||
}
|
||||
|
||||
public static function pkeyCols()
|
||||
static function pkeyCols()
|
||||
{
|
||||
return parent::pkeyColsClass(get_called_class());
|
||||
}
|
||||
@@ -81,10 +78,10 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
*
|
||||
* @return array Array of objects, in order
|
||||
*/
|
||||
public static function multiGet($keyCol, array $keyVals, $skipNulls = true)
|
||||
{
|
||||
return parent::multiGetClass(get_called_class(), $keyCol, $keyVals, $skipNulls);
|
||||
}
|
||||
static function multiGet($keyCol, array $keyVals, $skipNulls=true)
|
||||
{
|
||||
return parent::multiGetClass(get_called_class(), $keyCol, $keyVals, $skipNulls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get multiple items from the database by key
|
||||
@@ -95,10 +92,10 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
*
|
||||
* @return array Array mapping $keyVals to objects, or null if not found
|
||||
*/
|
||||
public static function pivotGet($keyCol, array $keyVals, array $otherCols = [])
|
||||
{
|
||||
return parent::pivotGetClass(get_called_class(), $keyCol, $keyVals, $otherCols);
|
||||
}
|
||||
static function pivotGet($keyCol, array $keyVals, array $otherCols=array())
|
||||
{
|
||||
return parent::pivotGetClass(get_called_class(), $keyCol, $keyVals, $otherCols);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a multi-instance object
|
||||
@@ -113,7 +110,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* Exception is thrown when no entries are found.
|
||||
*
|
||||
*/
|
||||
public static function listFind($keyCol, array $keyVals)
|
||||
static function listFind($keyCol, array $keyVals)
|
||||
{
|
||||
return parent::listFindClass(get_called_class(), $keyCol, $keyVals);
|
||||
}
|
||||
@@ -131,7 +128,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* @return array with an get_called_class() object for each $keyVals entry
|
||||
*
|
||||
*/
|
||||
public static function listGet($keyCol, array $keyVals)
|
||||
static function listGet($keyCol, array $keyVals)
|
||||
{
|
||||
return parent::listGetClass(get_called_class(), $keyCol, $keyVals);
|
||||
}
|
||||
@@ -152,11 +149,11 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* get/set an array of table primary keys
|
||||
*
|
||||
* Key info is pulled from the table definition array.
|
||||
*
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
public function keys()
|
||||
function keys()
|
||||
{
|
||||
return array_keys($this->keyTypes());
|
||||
}
|
||||
@@ -170,7 +167,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* @return array (column,use_native,sequence_name)
|
||||
*/
|
||||
|
||||
public function sequenceKey()
|
||||
function sequenceKey()
|
||||
{
|
||||
$table = static::schemaDef();
|
||||
foreach ($table['fields'] as $name => $column) {
|
||||
@@ -194,7 +191,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* @return array key definitions
|
||||
*/
|
||||
|
||||
public function keyTypes()
|
||||
function keyTypes()
|
||||
{
|
||||
$table = static::schemaDef();
|
||||
$keys = array();
|
||||
@@ -221,17 +218,16 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* @param array $column
|
||||
* @return int
|
||||
*/
|
||||
public function columnBitmap($column)
|
||||
function columnBitmap($column)
|
||||
{
|
||||
$type = $column['type'];
|
||||
|
||||
// For quoting style...
|
||||
$intTypes = [
|
||||
'int',
|
||||
'float',
|
||||
'serial',
|
||||
'numeric'
|
||||
];
|
||||
$intTypes = array('int',
|
||||
'integer',
|
||||
'float',
|
||||
'serial',
|
||||
'numeric');
|
||||
if (in_array($type, $intTypes)) {
|
||||
$style = DB_DATAOBJECT_INT;
|
||||
} else {
|
||||
@@ -239,14 +235,12 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
}
|
||||
|
||||
// Data type formatting style...
|
||||
$formatStyles = [
|
||||
'blob' => DB_DATAOBJECT_BLOB,
|
||||
'text' => DB_DATAOBJECT_TXT,
|
||||
'bool' => DB_DATAOBJECT_BOOL,
|
||||
'date' => DB_DATAOBJECT_DATE,
|
||||
'time' => DB_DATAOBJECT_TIME,
|
||||
'datetime' => DB_DATAOBJECT_DATE | DB_DATAOBJECT_TIME,
|
||||
];
|
||||
$formatStyles = array('blob' => DB_DATAOBJECT_BLOB,
|
||||
'text' => DB_DATAOBJECT_TXT,
|
||||
'date' => DB_DATAOBJECT_DATE,
|
||||
'time' => DB_DATAOBJECT_TIME,
|
||||
'datetime' => DB_DATAOBJECT_DATE | DB_DATAOBJECT_TIME,
|
||||
'timestamp' => DB_DATAOBJECT_MYSQLTIMESTAMP);
|
||||
|
||||
if (isset($formatStyles[$type])) {
|
||||
$style |= $formatStyles[$type];
|
||||
@@ -260,7 +254,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
return $style;
|
||||
}
|
||||
|
||||
public function links()
|
||||
function links()
|
||||
{
|
||||
$links = array();
|
||||
|
||||
@@ -282,10 +276,8 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* Memcached_DataObject doesn't have enough info to handle properly.
|
||||
*
|
||||
* @return array of strings
|
||||
* @throws MethodNotImplementedException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function _allCacheKeys()
|
||||
function _allCacheKeys()
|
||||
{
|
||||
$table = static::schemaDef();
|
||||
$ckeys = array();
|
||||
@@ -330,7 +322,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* @return Managed_DataObject of the get_called_class() type
|
||||
* @throws NoResultException if no object with that primary key
|
||||
*/
|
||||
public static function getByPK(array $vals)
|
||||
static function getByPK(array $vals)
|
||||
{
|
||||
$classname = get_called_class();
|
||||
|
||||
@@ -364,7 +356,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
* @return Managed_DataObject of the get_called_class() type
|
||||
* @throws NoResultException if no object with that primary key
|
||||
*/
|
||||
public static function getByKeys(array $vals)
|
||||
static function getByKeys(array $vals)
|
||||
{
|
||||
$classname = get_called_class();
|
||||
|
||||
@@ -389,7 +381,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
return $object;
|
||||
}
|
||||
|
||||
public static function getByID($id)
|
||||
static function getByID($id)
|
||||
{
|
||||
if (!property_exists(get_called_class(), 'id')) {
|
||||
throw new ServerException('Trying to get undefined property of dataobject class.');
|
||||
@@ -402,7 +394,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
return static::getByPK(array('id' => $id));
|
||||
}
|
||||
|
||||
public static function getByUri($uri)
|
||||
static function getByUri($uri)
|
||||
{
|
||||
if (!property_exists(get_called_class(), 'uri')) {
|
||||
throw new ServerException('Trying to get undefined property of dataobject class.');
|
||||
@@ -441,32 +433,6 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
return intval($this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the column is NULL in SQL
|
||||
*
|
||||
* @param string $key column property name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNull(string $key): bool
|
||||
{
|
||||
if (array_key_exists($key, get_object_vars($this))
|
||||
&& is_null($this->$key)) {
|
||||
// If there was no fetch, this is a false positive.
|
||||
return true;
|
||||
} elseif (is_object($this->$key)
|
||||
&& $this->$key instanceof DB_DataObject_Cast
|
||||
&& $this->$key->type === 'sql') {
|
||||
// This is cast to raw SQL, let's see if it's NULL.
|
||||
return (strcasecmp($this->$key->value, 'NULL') == 0);
|
||||
} elseif (DB_DataObject::_is_null($this, $key)) {
|
||||
// DataObject's NULL magic should be disabled,
|
||||
// this is just for completeness.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Only use this on Profile and Notice. We should probably do
|
||||
* this with traits/"implements" or whatever, but that's over the top
|
||||
@@ -521,37 +487,14 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
return $aliases;
|
||||
}
|
||||
|
||||
// 'update' won't write key columns, so we have to do it ourselves.
|
||||
// This also automatically calls "update" _before_ it sets the keys.
|
||||
// FIXME: This only works with single-column primary keys so far! Beware!
|
||||
/**
|
||||
* Set the attribute defined as "timestamp" to CURRENT_TIMESTAMP.
|
||||
* This is hooked in update() and updateWithKeys() to update "modified".
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
* @param DB_DataObject &$orig Must be "instanceof" $this
|
||||
* @param string $pid Primary ID column (no escaping is done on column name!)
|
||||
*/
|
||||
private function updateAutoTimestamps(): void
|
||||
{
|
||||
$table = static::schemaDef();
|
||||
foreach ($table['fields'] as $name => $col) {
|
||||
if ($col['type'] === 'timestamp'
|
||||
&& !array_key_exists('default', $col)
|
||||
&& !isset($this->$name)) {
|
||||
$this->$name = common_sql_now();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* update() won't write key columns, so we have to do it ourselves.
|
||||
* This also automatically calls "update" _before_ it sets the keys.
|
||||
* FIXME: This only works with single-column primary keys so far! Beware!
|
||||
*
|
||||
* @param Managed_DataObject $orig Must be "instanceof" $this
|
||||
* @param string $pid Primary ID column (no escaping is done on column name!)
|
||||
* @return bool|void
|
||||
* @throws MethodNotImplementedException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function updateWithKeys(Managed_DataObject $orig, ?string $pid = null)
|
||||
public function updateWithKeys(Managed_DataObject $orig, $pid=null)
|
||||
{
|
||||
if (!$orig instanceof $this) {
|
||||
throw new ServerException('Tried updating a DataObject with a different class than itself.');
|
||||
@@ -564,26 +507,12 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
$this->onUpdateKeys($orig);
|
||||
|
||||
// do it in a transaction
|
||||
$this->query('START TRANSACTION');
|
||||
$this->query('BEGIN');
|
||||
|
||||
// ON UPDATE CURRENT_TIMESTAMP behaviour
|
||||
// @fixme Should the value be reverted back if transaction failed?
|
||||
$this->updateAutoTimestamps();
|
||||
|
||||
$parts = [];
|
||||
$parts = array();
|
||||
foreach ($this->keys() as $k) {
|
||||
$v = $this->table()[$k];
|
||||
if ($this->$k !== $orig->$k) {
|
||||
if (is_object($this->$k) && $this->$k instanceof DB_DataObject_Cast) {
|
||||
$value = $this->$k->toString($v, $this->getDatabaseConnection());
|
||||
} elseif (DB_DataObject::_is_null($this, $k)) {
|
||||
$value = 'NULL';
|
||||
} elseif ($v & DB_DATAOBJECT_STR) { // if a string
|
||||
$value = $this->_quote((string) $this->$k);
|
||||
} else {
|
||||
$value = (int) $this->$k;
|
||||
}
|
||||
$parts[] = "{$k} = {$value}";
|
||||
if (strcmp($this->$k, $orig->$k) != 0) {
|
||||
$parts[] = $k . ' = ' . $this->_quote($this->$k);
|
||||
}
|
||||
}
|
||||
if (count($parts) == 0) {
|
||||
@@ -608,20 +537,18 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
$pid = $schema['primary key'];
|
||||
unset($schema);
|
||||
}
|
||||
$pidWhere = [];
|
||||
foreach ((array) $pid as $pidCol) {
|
||||
$pidWhere = array();
|
||||
foreach((array)$pid as $pidCol) {
|
||||
$pidWhere[] = sprintf('%1$s = %2$s', $pidCol, $this->_quote($orig->$pidCol));
|
||||
}
|
||||
if (empty($pidWhere)) {
|
||||
throw new ServerException('No primary ID column(s) set for updateWithKeys');
|
||||
}
|
||||
|
||||
$qry = sprintf(
|
||||
'UPDATE %1$s SET %2$s WHERE %3$s',
|
||||
$this->escapedTableName(),
|
||||
implode(', ', $parts),
|
||||
implode(' AND ', $pidWhere)
|
||||
);
|
||||
$qry = sprintf('UPDATE %1$s SET %2$s WHERE %3$s',
|
||||
common_database_tablename($this->tableName()),
|
||||
implode(', ', $parts),
|
||||
implode(' AND ', $pidWhere));
|
||||
|
||||
$result = $this->query($qry);
|
||||
if ($result === false) {
|
||||
@@ -649,23 +576,21 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function beforeSchemaUpdate()
|
||||
static public function beforeSchemaUpdate()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public static function newUri(Profile $actor, Managed_DataObject $object, $created = null)
|
||||
static function newUri(Profile $actor, Managed_DataObject $object, $created=null)
|
||||
{
|
||||
if (is_null($created)) {
|
||||
$created = common_sql_now();
|
||||
}
|
||||
return TagURI::mint(
|
||||
strtolower(get_called_class()) . ':%d:%s:%d:%s',
|
||||
$actor->getID(),
|
||||
ActivityUtils::resolveUri($object->getObjectType(), true),
|
||||
$object->getID(),
|
||||
common_date_iso8601($created)
|
||||
);
|
||||
return TagURI::mint(strtolower(get_called_class()).':%d:%s:%d:%s',
|
||||
$actor->getID(),
|
||||
ActivityUtils::resolveUri($object->getObjectType(), true),
|
||||
$object->getID(),
|
||||
common_date_iso8601($created));
|
||||
}
|
||||
|
||||
protected function onInsert()
|
||||
@@ -686,25 +611,12 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
public function insert()
|
||||
{
|
||||
$this->onInsert();
|
||||
$result = parent::insert();
|
||||
|
||||
// Make this object aware of the changed "modified" attribute.
|
||||
// Sets it approximately to the same value as DEFAULT CURRENT_TIMESTAMP
|
||||
// just did (@fixme).
|
||||
if ($result) {
|
||||
$this->updateAutoTimestamps();
|
||||
}
|
||||
return $result;
|
||||
return parent::insert();
|
||||
}
|
||||
|
||||
public function update($dataObject = false)
|
||||
public function update($dataObject=false)
|
||||
{
|
||||
$this->onUpdate($dataObject);
|
||||
|
||||
// ON UPDATE CURRENT_TIMESTAMP behaviour
|
||||
// @fixme Should the value be reverted back if transaction failed?
|
||||
$this->updateAutoTimestamps();
|
||||
|
||||
return parent::update($dataObject);
|
||||
}
|
||||
}
|
||||
|
||||
+119
-156
@@ -1,25 +1,23 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* @copyright 2008, 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
/*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 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/>.
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class Memcached_DataObject extends Safe_DataObject
|
||||
{
|
||||
@@ -32,7 +30,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
* @param mixed $v key field value, or leave out for primary key lookup
|
||||
* @return mixed Memcached_DataObject subtype or false
|
||||
*/
|
||||
public static function getClassKV($cls, $k, $v = null)
|
||||
static function getClassKV($cls, $k, $v=null)
|
||||
{
|
||||
if (is_null($v)) {
|
||||
$v = $k;
|
||||
@@ -73,7 +71,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
*
|
||||
* @return array Array of objects, in order
|
||||
*/
|
||||
public static function multiGetClass($cls, $keyCol, array $keyVals, $skipNulls = true)
|
||||
static function multiGetClass($cls, $keyCol, array $keyVals, $skipNulls=true)
|
||||
{
|
||||
$obj = new $cls;
|
||||
|
||||
@@ -87,7 +85,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
|
||||
if ($skipNulls) {
|
||||
foreach ($keyVals as $key => $val) {
|
||||
foreach ($keyVals as $key=>$val) {
|
||||
if (is_null($val)) {
|
||||
unset($keyVals[$key]);
|
||||
}
|
||||
@@ -97,54 +95,13 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
$obj->whereAddIn($keyCol, $keyVals, $colType);
|
||||
|
||||
// Since we're inputting straight to a query: format and escape
|
||||
foreach ($keyVals as $key => $val) {
|
||||
foreach ($keyVals as $key=>$val) {
|
||||
settype($val, $colType);
|
||||
$keyVals[$key] = $obj->escape($val);
|
||||
}
|
||||
|
||||
// Check if values are ordered, makes sorting in SQL easier
|
||||
$prev_val = reset($keyVals);
|
||||
$order_asc = $order_desc = true;
|
||||
foreach ($keyVals as $val) {
|
||||
if ($val < $prev_val) {
|
||||
$order_asc = false;
|
||||
}
|
||||
if ($val > $prev_val) {
|
||||
$order_desc = false;
|
||||
}
|
||||
if ($order_asc === false && $order_desc === false) {
|
||||
break;
|
||||
}
|
||||
$prev_val = $val;
|
||||
}
|
||||
|
||||
if ($order_asc) {
|
||||
$obj->orderBy($keyCol);
|
||||
} elseif ($order_desc) {
|
||||
$obj->orderBy("{$keyCol} DESC");
|
||||
} else {
|
||||
switch (common_config('db', 'type')) {
|
||||
case 'pgsql':
|
||||
// "position" will make sure we keep the desired order
|
||||
$obj->orderBy(sprintf(
|
||||
"position(',' || CAST(%s AS text) || ',' IN ',%s,')",
|
||||
$keyCol,
|
||||
implode(',', $keyVals)
|
||||
));
|
||||
break;
|
||||
case 'mysql':
|
||||
// "find_in_set" will make sure we keep the desired order
|
||||
$obj->orderBy(sprintf(
|
||||
"find_in_set(%s, '%s')",
|
||||
$keyCol,
|
||||
implode(',', $keyVals)
|
||||
));
|
||||
break;
|
||||
default:
|
||||
throw new ServerException('Unknown DB type selected.');
|
||||
}
|
||||
}
|
||||
|
||||
// FIND_IN_SET will make sure we keep the desired order
|
||||
$obj->orderBy(sprintf("FIND_IN_SET(%s, '%s')", $keyCol, implode(',', $keyVals)));
|
||||
$obj->find();
|
||||
|
||||
return $obj;
|
||||
@@ -160,20 +117,10 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
*
|
||||
* @return array Array mapping $keyVals to objects, or null if not found
|
||||
*/
|
||||
public static function pivotGetClass(
|
||||
$cls,
|
||||
$keyCol,
|
||||
array $keyVals,
|
||||
array $otherCols = []
|
||||
) {
|
||||
static function pivotGetClass($cls, $keyCol, array $keyVals, array $otherCols = array())
|
||||
{
|
||||
if (is_array($keyCol)) {
|
||||
foreach ($keyVals as $keyVal) {
|
||||
if (!is_array($keyVal)) {
|
||||
throw new ServerException(
|
||||
'keyVals passed to pivotGet must be an array of arrays '
|
||||
. 'if keyCol is an array'
|
||||
);
|
||||
}
|
||||
$result[implode(',', $keyVal)] = null;
|
||||
}
|
||||
} else {
|
||||
@@ -183,6 +130,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
$toFetch = array();
|
||||
|
||||
foreach ($keyVals as $keyVal) {
|
||||
|
||||
if (is_array($keyCol)) {
|
||||
$kv = array_combine($keyCol, $keyVal);
|
||||
} else {
|
||||
@@ -199,7 +147,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
} else {
|
||||
$result[$keyVal] = $i;
|
||||
}
|
||||
} elseif (!empty($keyVal)) {
|
||||
} else if (!empty($keyVal)) {
|
||||
$toFetch[] = $keyVal;
|
||||
}
|
||||
}
|
||||
@@ -259,7 +207,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function _inMultiKey($i, $cols, $values)
|
||||
static function _inMultiKey($i, $cols, $values)
|
||||
{
|
||||
$types = array();
|
||||
|
||||
@@ -307,7 +255,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $query;
|
||||
}
|
||||
|
||||
public static function pkeyColsClass($cls)
|
||||
static function pkeyColsClass($cls)
|
||||
{
|
||||
$i = new $cls;
|
||||
$types = $i->keyTypes();
|
||||
@@ -324,7 +272,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $pkey;
|
||||
}
|
||||
|
||||
public static function listFindClass($cls, $keyCol, array $keyVals)
|
||||
static function listFindClass($cls, $keyCol, array $keyVals)
|
||||
{
|
||||
$i = new $cls;
|
||||
$i->whereAddIn($keyCol, $keyVals, $i->columnType($keyCol));
|
||||
@@ -335,7 +283,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $i;
|
||||
}
|
||||
|
||||
public static function listGetClass($cls, $keyCol, array $keyVals)
|
||||
static function listGetClass($cls, $keyCol, array $keyVals)
|
||||
{
|
||||
$pkeyMap = array_fill_keys($keyVals, array());
|
||||
$result = array_fill_keys($keyVals, array());
|
||||
@@ -348,7 +296,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
// We only cache keys -- not objects!
|
||||
|
||||
foreach ($keyVals as $keyVal) {
|
||||
$l = self::cacheGet(sprintf('%s:list-ids:%s:%s', strtolower($cls), $keyCol, $keyVal));
|
||||
$l = self::cacheGet(sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal));
|
||||
if ($l !== false) {
|
||||
$pkeyMap[$keyVal] = $l;
|
||||
foreach ($l as $pkey) {
|
||||
@@ -364,7 +312,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
|
||||
foreach ($pkeyMap as $keyVal => $pkeyList) {
|
||||
foreach ($pkeyList as $pkeyVal) {
|
||||
$i = $keyResults[implode(',', $pkeyVal)];
|
||||
$i = $keyResults[implode(',',$pkeyVal)];
|
||||
if (!empty($i)) {
|
||||
$result[$keyVal][] = $i;
|
||||
}
|
||||
@@ -390,17 +338,15 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
// no results found for our keyVals, so we leave them as empty arrays
|
||||
}
|
||||
foreach ($toFetch as $keyVal) {
|
||||
self::cacheSet(
|
||||
sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal),
|
||||
$pkeyMap[$keyVal]
|
||||
);
|
||||
self::cacheSet(sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal),
|
||||
$pkeyMap[$keyVal]);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function columnType($columnName)
|
||||
function columnType($columnName)
|
||||
{
|
||||
$keys = $this->table();
|
||||
if (!array_key_exists($columnName, $keys)) {
|
||||
@@ -419,7 +365,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
/**
|
||||
* @todo FIXME: Should this return false on lookup fail to match getKV?
|
||||
*/
|
||||
public static function pkeyGetClass($cls, array $kv)
|
||||
static function pkeyGetClass($cls, array $kv)
|
||||
{
|
||||
$i = self::multicache($cls, $kv);
|
||||
if ($i !== false) { // false == cache miss
|
||||
@@ -449,40 +395,40 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public function insert()
|
||||
function insert()
|
||||
{
|
||||
$result = parent::insert();
|
||||
if ($result) {
|
||||
$this->fixupTimestamps();
|
||||
$this->encache(); // in case of cached negative lookups
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function update($dataObject = false)
|
||||
function update($dataObject=false)
|
||||
{
|
||||
if (is_object($dataObject) && $dataObject instanceof Memcached_DataObject) {
|
||||
$dataObject->decache(); # might be different keys
|
||||
}
|
||||
$result = parent::update($dataObject);
|
||||
if ($result !== false) {
|
||||
$this->fixupTimestamps();
|
||||
$this->encache();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function delete($useWhere = false)
|
||||
function delete($useWhere=false)
|
||||
{
|
||||
$this->decache(); # while we still have the values!
|
||||
return parent::delete($useWhere);
|
||||
}
|
||||
|
||||
public static function memcache()
|
||||
{
|
||||
static function memcache() {
|
||||
return Cache::instance();
|
||||
}
|
||||
|
||||
public static function cacheKey($cls, $k, $v)
|
||||
{
|
||||
static function cacheKey($cls, $k, $v) {
|
||||
if (is_object($cls) || is_object($k) || (is_object($v) && !($v instanceof DB_DataObject_Cast))) {
|
||||
$e = new Exception();
|
||||
common_log(LOG_ERR, __METHOD__ . ' object in param: ' .
|
||||
@@ -492,8 +438,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return Cache::key(strtolower($cls).':'.$k.':'.$vstr);
|
||||
}
|
||||
|
||||
public static function getcached($cls, $k, $v)
|
||||
{
|
||||
static function getcached($cls, $k, $v) {
|
||||
$c = self::memcache();
|
||||
if (!$c) {
|
||||
return false;
|
||||
@@ -511,7 +456,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public function keyTypes()
|
||||
function keyTypes()
|
||||
{
|
||||
// ini-based classes return number-indexed arrays. handbuilt
|
||||
// classes return column => keytype. Make this uniform.
|
||||
@@ -527,17 +472,18 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
global $_DB_DATAOBJECT;
|
||||
if (!isset($_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()."__keys"])) {
|
||||
$this->databaseStructure();
|
||||
|
||||
}
|
||||
return $_DB_DATAOBJECT['INI'][$this->_database][$this->tableName()."__keys"];
|
||||
}
|
||||
|
||||
public function encache()
|
||||
function encache()
|
||||
{
|
||||
$c = self::memcache();
|
||||
|
||||
if (!$c) {
|
||||
return false;
|
||||
} elseif ($this->tableName() === 'user' && is_object($this->id)) {
|
||||
} else if ($this->tableName() == 'user' && is_object($this->id)) {
|
||||
// Special case for User bug
|
||||
$e = new Exception();
|
||||
common_log(LOG_ERR, __METHOD__ . ' caching user with User object as ID ' .
|
||||
@@ -552,7 +498,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public function decache()
|
||||
function decache()
|
||||
{
|
||||
$c = self::memcache();
|
||||
|
||||
@@ -567,7 +513,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public function _allCacheKeys()
|
||||
function _allCacheKeys()
|
||||
{
|
||||
$ckeys = array();
|
||||
|
||||
@@ -578,6 +524,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
$pval = array();
|
||||
|
||||
foreach ($types as $key => $type) {
|
||||
|
||||
assert(!empty($key));
|
||||
|
||||
if ($type == 'U') {
|
||||
@@ -585,7 +532,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
continue;
|
||||
}
|
||||
$ckeys[] = self::cacheKey($this->tableName(), $key, self::valueString($this->$key));
|
||||
} elseif (in_array($type, ['K', 'N'])) {
|
||||
} else if ($type == 'K' || $type == 'N') {
|
||||
$pkey[] = $key;
|
||||
$pval[] = self::valueString($this->$key);
|
||||
} else {
|
||||
@@ -605,7 +552,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $ckeys;
|
||||
}
|
||||
|
||||
public static function multicache($cls, array $kv)
|
||||
static function multicache($cls, $kv)
|
||||
{
|
||||
ksort($kv);
|
||||
$c = self::memcache();
|
||||
@@ -616,7 +563,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public static function multicacheKey($cls, array $kv)
|
||||
static function multicacheKey($cls, $kv)
|
||||
{
|
||||
ksort($kv);
|
||||
$pkeys = implode(',', array_keys($kv));
|
||||
@@ -624,35 +571,30 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return self::cacheKey($cls, $pkeys, $pvals);
|
||||
}
|
||||
|
||||
public function getSearchEngine($table)
|
||||
function getSearchEngine($table)
|
||||
{
|
||||
require_once INSTALLDIR . '/lib/search/search_engines.php';
|
||||
require_once INSTALLDIR.'/lib/search_engines.php';
|
||||
|
||||
if (Event::handle('GetSearchEngine', [$this, $table, &$search_engine])) {
|
||||
$type = common_config('search', 'type');
|
||||
if ($type === 'like') {
|
||||
$search_engine = new SQLLikeSearch($this, $table);
|
||||
} elseif ($type === 'fulltext') {
|
||||
switch (common_config('db', 'type')) {
|
||||
case 'pgsql':
|
||||
$search_engine = new PostgreSQLSearch($this, $table);
|
||||
break;
|
||||
case 'mysql':
|
||||
$search_engine = new MySQLSearch($this, $table);
|
||||
break;
|
||||
default:
|
||||
throw new ServerException('Unknown DB type selected.');
|
||||
if (Event::handle('GetSearchEngine', array($this, $table, &$search_engine))) {
|
||||
if ('mysql' === common_config('db', 'type')) {
|
||||
$type = common_config('search', 'type');
|
||||
if ($type == 'like') {
|
||||
$search_engine = new MySQLLikeSearch($this, $table);
|
||||
} else if ($type == 'fulltext') {
|
||||
$search_engine = new MySQLSearch($this, $table);
|
||||
} else {
|
||||
// Low level exception. No need for i18n as discussed with Brion.
|
||||
throw new ServerException('Unknown search type: ' . $type);
|
||||
}
|
||||
} else {
|
||||
// Low level exception. No need for i18n as discussed with Brion.
|
||||
throw new ServerException('Unknown search type: ' . $type);
|
||||
$search_engine = new PGSearch($this, $table);
|
||||
}
|
||||
}
|
||||
|
||||
return $search_engine;
|
||||
}
|
||||
|
||||
public static function cachedQuery($cls, $qry, $expiry = 3600)
|
||||
static function cachedQuery($cls, $qry, $expiry=3600)
|
||||
{
|
||||
$c = self::memcache();
|
||||
if (!$c) {
|
||||
@@ -689,13 +631,13 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
* @access private
|
||||
* @return mixed none or PEAR_Error
|
||||
*/
|
||||
public function _query($string)
|
||||
function _query($string)
|
||||
{
|
||||
if (common_config('db', 'annotate_queries')) {
|
||||
$string = $this->annotateQuery($string);
|
||||
}
|
||||
|
||||
$start = hrtime(true);
|
||||
$start = microtime(true);
|
||||
$fail = false;
|
||||
$result = null;
|
||||
if (Event::handle('StartDBQuery', array($this, $string, &$result))) {
|
||||
@@ -707,7 +649,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
Event::handle('EndDBQuery', array($this, $string, &$result));
|
||||
}
|
||||
$delta = (hrtime(true) - $start) / 1000000000;
|
||||
$delta = microtime(true) - $start;
|
||||
|
||||
$limit = common_config('db', 'log_slow_queries');
|
||||
if (($limit > 0 && $delta >= $limit) || common_config('db', 'log_queries')) {
|
||||
@@ -738,7 +680,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
* @param string $string SQL query string
|
||||
* @return string SQL query string, with a comment in it
|
||||
*/
|
||||
public function annotateQuery($string)
|
||||
function annotateQuery($string)
|
||||
{
|
||||
$ignore = array('annotateQuery',
|
||||
'_query',
|
||||
@@ -765,7 +707,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
$here = $frame['class'] . '::' . $func;
|
||||
break;
|
||||
} elseif (isset($frame['type']) && $frame['type'] === '->') {
|
||||
} else if (isset($frame['type']) && $frame['type'] == '->') {
|
||||
if ($frame['object'] === $this && in_array($func, $ignore)) {
|
||||
continue;
|
||||
}
|
||||
@@ -794,7 +736,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
|
||||
// Sanitize a query for logging
|
||||
// @fixme don't trim spaces in string literals
|
||||
public function sanitizeQuery($string)
|
||||
function sanitizeQuery($string)
|
||||
{
|
||||
$string = preg_replace('/\s+/', ' ', $string);
|
||||
$string = trim($string);
|
||||
@@ -804,7 +746,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
// We overload so that 'SET NAMES "utf8mb4"' is called for
|
||||
// each connection
|
||||
|
||||
public function _connect()
|
||||
function _connect()
|
||||
{
|
||||
global $_DB_DATAOBJECT, $_PEAR;
|
||||
|
||||
@@ -815,7 +757,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
$exists = true;
|
||||
} else {
|
||||
$exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
// @fixme horrible evil hack!
|
||||
//
|
||||
@@ -845,11 +787,21 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
$result = parent::_connect();
|
||||
|
||||
if ($result && !$exists) {
|
||||
$DB = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
|
||||
if (common_config('db', 'type') == 'mysql' &&
|
||||
common_config('db', 'utf8')) {
|
||||
$conn = $DB->connection;
|
||||
if (!empty($conn)) {
|
||||
if ($DB instanceof DB_mysqli || $DB instanceof MDB2_Driver_mysqli) {
|
||||
mysqli_set_charset($conn, 'utf8mb4');
|
||||
} else if ($DB instanceof DB_mysql || $DB instanceof MDB2_Driver_mysql) {
|
||||
mysql_set_charset('utf8mb4', $conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Needed to make timestamp values usefully comparable.
|
||||
if (common_config('db', 'type') !== 'mysql') {
|
||||
parent::_query("SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE");
|
||||
} else {
|
||||
parent::_query("SET time_zone = '+0:00'");
|
||||
if (common_config('db', 'type') == 'mysql') {
|
||||
parent::_query("set time_zone='+0:00'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,7 +810,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
|
||||
// XXX: largely cadged from DB_DataObject
|
||||
|
||||
public function _getDbDsnMD5()
|
||||
function _getDbDsnMD5()
|
||||
{
|
||||
if ($this->_database_dsn_md5) {
|
||||
return $this->_database_dsn_md5;
|
||||
@@ -876,7 +828,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $sum;
|
||||
}
|
||||
|
||||
public function _getDbDsn()
|
||||
function _getDbDsn()
|
||||
{
|
||||
global $_DB_DATAOBJECT;
|
||||
|
||||
@@ -891,13 +843,14 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
$dsn = isset($this->_database_dsn) ? $this->_database_dsn : null;
|
||||
|
||||
if (!$dsn) {
|
||||
|
||||
if (!$this->_database) {
|
||||
$this->_database = isset($options["table_{$this->tableName()}"]) ? $options["table_{$this->tableName()}"] : null;
|
||||
}
|
||||
|
||||
if ($this->_database && !empty($options["database_{$this->_database}"])) {
|
||||
if ($this->_database && !empty($options["database_{$this->_database}"])) {
|
||||
$dsn = $options["database_{$this->_database}"];
|
||||
} elseif (!empty($options['database'])) {
|
||||
} else if (!empty($options['database'])) {
|
||||
$dsn = $options['database'];
|
||||
}
|
||||
}
|
||||
@@ -910,7 +863,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $dsn;
|
||||
}
|
||||
|
||||
public static function blow()
|
||||
static function blow()
|
||||
{
|
||||
$c = self::memcache();
|
||||
|
||||
@@ -929,7 +882,23 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $c->delete($cacheKey);
|
||||
}
|
||||
|
||||
public function raiseError($message, $type = null, $behavior = null)
|
||||
function fixupTimestamps()
|
||||
{
|
||||
// Fake up timestamp columns
|
||||
$columns = $this->table();
|
||||
foreach ($columns as $name => $type) {
|
||||
if ($type & DB_DATAOBJECT_MYSQLTIMESTAMP) {
|
||||
$this->$name = common_sql_now();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function debugDump()
|
||||
{
|
||||
common_debug("debugDump: " . common_log_objstring($this));
|
||||
}
|
||||
|
||||
function raiseError($message, $type = null, $behaviour = null)
|
||||
{
|
||||
$id = get_class($this);
|
||||
if (!empty($this->id)) {
|
||||
@@ -942,7 +911,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
throw new ServerException("[$id] DB_DataObject error [$type]: $message");
|
||||
}
|
||||
|
||||
public static function cacheGet($keyPart)
|
||||
static function cacheGet($keyPart)
|
||||
{
|
||||
$c = self::memcache();
|
||||
|
||||
@@ -955,7 +924,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $c->get($cacheKey);
|
||||
}
|
||||
|
||||
public static function cacheSet($keyPart, $value, $flag = null, $expiry = null)
|
||||
static function cacheSet($keyPart, $value, $flag=null, $expiry=null)
|
||||
{
|
||||
$c = self::memcache();
|
||||
|
||||
@@ -968,23 +937,17 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $c->set($cacheKey, $value, $flag, $expiry);
|
||||
}
|
||||
|
||||
public static function valueString($v)
|
||||
static function valueString($v)
|
||||
{
|
||||
$vstr = null;
|
||||
if (is_object($v) && $v instanceof DB_DataObject_Cast) {
|
||||
switch ($v->type) {
|
||||
case 'date':
|
||||
$vstr = "{$v->year} - {$v->month} - {$v->day}";
|
||||
$vstr = $v->year . '-' . $v->month . '-' . $v->day;
|
||||
break;
|
||||
case 'sql':
|
||||
if (strcasecmp($v->value, 'NULL') == 0) {
|
||||
// Very selectively handling NULLs.
|
||||
$vstr = '';
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
case 'blob':
|
||||
case 'string':
|
||||
case 'sql':
|
||||
case 'datetime':
|
||||
case 'time':
|
||||
// Low level exception. No need for i18n as discussed with Brion.
|
||||
|
||||
+6
-22
@@ -1,24 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for nonce
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Nonce extends Managed_DataObject
|
||||
{
|
||||
@@ -30,8 +14,8 @@ class Nonce extends Managed_DataObject
|
||||
public $tok; // char(32)
|
||||
public $nonce; // char(32) primary_key not_null
|
||||
public $ts; // datetime() primary_key not_null
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -45,7 +29,7 @@ class Nonce extends Managed_DataObject
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
public function links()
|
||||
function links()
|
||||
{
|
||||
return array('consumer_key,token' => 'token:consumer_key,token');
|
||||
}
|
||||
@@ -59,8 +43,8 @@ class Nonce extends Managed_DataObject
|
||||
'tok' => array('type' => 'char', 'length' => 32, 'description' => 'buggy old value, ignored'),
|
||||
'nonce' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'nonce'),
|
||||
'ts' => array('type' => 'datetime', 'not null' => true, 'description' => 'timestamp sent'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('consumer_key', 'ts', 'nonce'),
|
||||
);
|
||||
|
||||
+299
-327
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,25 +1,8 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Table Definition for notice_location
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Notice_location extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'notice_location'; // table name
|
||||
@@ -28,7 +11,7 @@ class Notice_location extends Managed_DataObject
|
||||
public $lon; // decimal(10,7)
|
||||
public $location_id; // int(4)
|
||||
public $location_ns; // int(4)
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -39,7 +22,7 @@ class Notice_location extends Managed_DataObject
|
||||
'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'),
|
||||
'location_id' => array('type' => 'int', 'description' => 'location id if possible'),
|
||||
'location_ns' => array('type' => 'int', 'description' => 'namespace for location'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('notice_id'),
|
||||
'foreign keys' => array(
|
||||
@@ -49,9 +32,9 @@ class Notice_location extends Managed_DataObject
|
||||
'notice_location_location_id_idx' => array('location_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function locFromStored(Notice $stored)
|
||||
static function locFromStored(Notice $stored)
|
||||
{
|
||||
$loc = new Notice_location();
|
||||
$loc->notice_id = $stored->getID();
|
||||
@@ -61,7 +44,7 @@ class Notice_location extends Managed_DataObject
|
||||
return $loc->asLocation();
|
||||
}
|
||||
|
||||
public static function fromLocation(Location $location)
|
||||
static function fromLocation(Location $location)
|
||||
{
|
||||
$notloc = new Notice_location();
|
||||
$notloc->lat = $location->lat;
|
||||
|
||||
+39
-42
@@ -1,32 +1,32 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* GNU social
|
||||
*
|
||||
* Data class for Notice 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
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
* @copyright 2013 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://www.gnu.org/software/social/
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Notice_prefs extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'notice_prefs'; // table name
|
||||
@@ -34,8 +34,8 @@ class Notice_prefs extends Managed_DataObject
|
||||
public $namespace; // varchar(191) not_null
|
||||
public $topic; // varchar(191) not_null
|
||||
public $data; // text
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -45,17 +45,20 @@ class Notice_prefs extends Managed_DataObject
|
||||
'namespace' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'namespace, like pluginname or category'),
|
||||
'topic' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'preference key, i.e. description, age...'),
|
||||
'data' => array('type' => 'blob', 'description' => 'topic data, may be anything'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'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'),
|
||||
),
|
||||
'primary key' => array('notice_id', 'namespace', 'topic'),
|
||||
'foreign keys' => array(
|
||||
'notice_prefs_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'notice_prefs_notice_id_idx' => array('notice_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getNamespacePrefs(Notice $notice, $namespace, array $topic = [])
|
||||
static function getNamespacePrefs(Notice $notice, $namespace, array $topic=array())
|
||||
{
|
||||
if (empty($topic)) {
|
||||
$prefs = new Notice_prefs();
|
||||
@@ -73,13 +76,13 @@ class Notice_prefs extends Managed_DataObject
|
||||
return $prefs;
|
||||
}
|
||||
|
||||
public static function getNamespace(Notice $notice, $namespace, array $topic = [])
|
||||
static function getNamespace(Notice $notice, $namespace, array $topic=array())
|
||||
{
|
||||
$prefs = self::getNamespacePrefs($notice, $namespace, $topic);
|
||||
return $prefs->fetchAll();
|
||||
}
|
||||
|
||||
public static function getAll(Notice $notice)
|
||||
static function getAll(Notice $notice)
|
||||
{
|
||||
try {
|
||||
$prefs = self::listFind('notice_id', array($notice->getID()));
|
||||
@@ -97,17 +100,13 @@ class Notice_prefs extends Managed_DataObject
|
||||
return $list;
|
||||
}
|
||||
|
||||
public static function getTopic(Notice $notice, $namespace, $topic)
|
||||
{
|
||||
return self::getByPK([
|
||||
'notice_id' => $notice->getID(),
|
||||
'namespace' => $namespace,
|
||||
'topic' => $topic,
|
||||
]);
|
||||
static function getTopic(Notice $notice, $namespace, $topic) {
|
||||
return self::getByPK(array('notice_id' => $notice->getID(),
|
||||
'namespace' => $namespace,
|
||||
'topic' => $topic));
|
||||
}
|
||||
|
||||
public static function getData(Notice $notice, $namespace, $topic, $def = null)
|
||||
{
|
||||
static function getData(Notice $notice, $namespace, $topic, $def=null) {
|
||||
try {
|
||||
$pref = self::getTopic($notice, $namespace, $topic);
|
||||
} catch (NoResultException $e) {
|
||||
@@ -121,8 +120,7 @@ class Notice_prefs extends Managed_DataObject
|
||||
return $pref->data;
|
||||
}
|
||||
|
||||
public static function getConfigData(Notice $notice, $namespace, $topic)
|
||||
{
|
||||
static function getConfigData(Notice $notice, $namespace, $topic) {
|
||||
try {
|
||||
$data = self::getData($notice, $namespace, $topic);
|
||||
} catch (NoResultException $e) {
|
||||
@@ -142,15 +140,14 @@ class Notice_prefs extends Managed_DataObject
|
||||
* @return true if changes are made, false if no action taken
|
||||
* @throws ServerException if preference could not be saved
|
||||
*/
|
||||
public static function setData(Notice $notice, $namespace, $topic, $data = null)
|
||||
{
|
||||
static function setData(Notice $notice, $namespace, $topic, $data=null) {
|
||||
try {
|
||||
$pref = self::getTopic($notice, $namespace, $topic);
|
||||
if (is_null($data)) {
|
||||
$pref->delete();
|
||||
} else {
|
||||
$orig = clone($pref);
|
||||
$pref->data = DB_DataObject_Cast::blob($data);
|
||||
$pref->data = $data;
|
||||
$pref->update($orig);
|
||||
}
|
||||
return true;
|
||||
@@ -164,7 +161,7 @@ class Notice_prefs extends Managed_DataObject
|
||||
$pref->notice_id = $notice->getID();
|
||||
$pref->namespace = $namespace;
|
||||
$pref->topic = $topic;
|
||||
$pref->data = DB_DataObject_Cast::blob($data);
|
||||
$pref->data = $data;
|
||||
$pref->created = common_sql_now();
|
||||
|
||||
if ($pref->insert() === false) {
|
||||
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário