Comparar commits
219 Commits
active-orm
...
nightly
| Autor | SHA1 | Data | |
|---|---|---|---|
| f0a09e7216 | |||
| 7fe19686f2 | |||
| 8e3b6314ea | |||
| 11a7182594 | |||
| 817074a787 | |||
| c75bf1a19d | |||
| 11ebb98919 | |||
| e4093343c2 | |||
| 101ea554ef | |||
| ef6a986dc6 | |||
| db593496a7 | |||
| 00c492891e | |||
| 0e81f9c726 | |||
| b419c5cf7c | |||
| 20e5a6d1f3 | |||
| 99a9a5d850 | |||
| a15d51c3d8 | |||
| b01974b665 | |||
| be5bec9887 | |||
| 27045f03f5 | |||
| 071baf04fd | |||
| 341e34b766 | |||
| 5c21816b22 | |||
| afd18db381 | |||
| 6c8cd4c9f8 | |||
| 255d395f1d | |||
| 2f845e98e8 | |||
| 1371e3efb8 | |||
| 8a2c1658a8 | |||
| b65c200922 | |||
| 33caf31237 | |||
| cb7effca05 | |||
| 8745a3e824 | |||
| ac6510d481 | |||
| 2109c7b830 | |||
| 629857d3ef | |||
| 60eed202dd | |||
| 14e2621a05 | |||
| 99da7963d1 | |||
| 2abe910ff5 | |||
| 15f7941daf | |||
| 535b87bb64 | |||
| e63c0d1b03 | |||
| 8bc714a2b1 | |||
| 07b0aa8f52 | |||
| ce665baa88 | |||
| 8c41663175 | |||
| 7cb10b71bb | |||
| 47cacf5f1a | |||
| 042e4b070c | |||
| f84dbb369f | |||
| 34ec165bff | |||
| b20c0bdec7 | |||
| c527ad0803 | |||
| 0a6bb5190f | |||
| cf353f8829 | |||
| 2bd7c021fd | |||
| 46f788d1eb | |||
| 5ea5d30075 | |||
| 22d650469b | |||
| 849ad494d8 | |||
| 7a2bb38331 | |||
| 1428ac2cb0 | |||
| efdc7d9ba0 | |||
| e4e41bb595 | |||
| 379fbb6e5d | |||
| 09c3236afc | |||
| 7d52440461 | |||
| e206995268 | |||
| ab4120721f | |||
| a9c365a5eb | |||
| 8ad928d48d | |||
| ebf5efe9f2 | |||
| c7055341f9 | |||
| 34c5be5c42 | |||
| 1675916fda | |||
| a38c608420 | |||
| 20be1d179a | |||
| 1870f38099 | |||
| 96eced9845 | |||
| 92e8c40c55 | |||
| 0bfa747382 | |||
| be3c4263b3 | |||
| f00852a619 | |||
| 83df8848c8 | |||
| 99183ce4e2 | |||
| 434ce56e33 | |||
| ec86de2bc4 | |||
| 341f3d0ea5 | |||
| 579120df70 | |||
| 63eb323e8b | |||
| 2861ae2823 | |||
| 0b947ce2c7 | |||
| 2222d6d173 | |||
| 33e9b57b78 | |||
| 62f4dfdc7a | |||
| 7e01fd9c38 | |||
| eefaf7a2b4 | |||
| 31dcf99e61 | |||
| 0def5f1dca | |||
| ac94374f48 | |||
| 9f72b6e2c0 | |||
| f9e38c1a8d | |||
| 6db56cc949 | |||
| 7081720ecb | |||
| f7ded4d87b | |||
| 67780ca4a9 | |||
| 871f3c4bfe | |||
| 395fe8cb10 | |||
| af936f6f8e | |||
| 5512e95e0a | |||
| 5e14f18c83 | |||
| 5adb971d9a | |||
| f51e5ba19d | |||
| 488bddb02a | |||
| 3a2ec3ef9c | |||
| 08283f6c54 | |||
| f7d3f58318 | |||
| 89e84e9b1b | |||
| 9226cce151 | |||
| 6526bdc824 | |||
| 1967f46a69 | |||
| e504d13120 | |||
| 2f284f4274 | |||
| 4d171b27a4 | |||
| fe4a9a6189 | |||
| c862589dcf | |||
| 61765b0e33 | |||
| 78a111b57d | |||
| 9a515b9234 | |||
| b924c180ae | |||
| 737f3eb553 | |||
| 6e3954f3bb | |||
| 4544f29832 | |||
| 477c357f11 | |||
| 7869a7c1b0 | |||
| edc7159ef6 | |||
| 1db6943702 | |||
| e8dff6c4a0 | |||
| 23ed816035 | |||
| 324b7f38a9 | |||
| aa7aff3f6b | |||
| 236929a166 | |||
| 953e243639 | |||
| 338d53c982 | |||
| 37ebcc509b | |||
| f9be6f9a85 | |||
| 2cc2b5b856 | |||
| 194976135f | |||
| ef17f3ea7d | |||
| 0eec6fcfb6 | |||
| 09a772419a | |||
| 6c035d01d4 | |||
| 97bddc4537 | |||
| 684675bd84 | |||
| b8c0fa9fa0 | |||
| 9e7794cd66 | |||
| 92ad44abf9 | |||
| 7e83ddf80e | |||
| a9be720f09 | |||
| d7906f113e | |||
| 01dcaefcfb | |||
| cfba91ea43 | |||
| 134b6f6478 | |||
| 64104cb182 | |||
| 9aedcc7997 | |||
| 35547e28ea | |||
| c6543e1f95 | |||
| 2183875e9e | |||
| e5ee069f4a | |||
| 6c844315aa | |||
| 872bb1388d | |||
| 42aa255152 | |||
| e58188d136 | |||
| bb32c0af3b | |||
| 63fd2c7037 | |||
| 520a2ba202 | |||
| 13e8445083 | |||
| d1c70cb13b | |||
| 6898cff623 | |||
| f4558e3c41 | |||
| d24075b1c5 | |||
| a8c2a9da3a | |||
| 8041df7d41 | |||
| 073a181778 | |||
| bec6fdc66a | |||
| 6833c9f1c2 | |||
| 18ade30185 | |||
| e7ab305335 | |||
| 110d3a453a | |||
| f5aeab39b4 | |||
| e7738895ce | |||
| 60446dfc20 | |||
| dc211c9c44 | |||
| 27babac6dc | |||
| 3e2b7cddc8 | |||
| 80ba2b3ccc | |||
| b730582336 | |||
| 1b429dd2e5 | |||
| 448404e45c | |||
| 562d84c375 | |||
| f09e3362aa | |||
| 51b5b1c08c | |||
| ca2dde9a41 | |||
| 6674d1ed0f | |||
| 2a10dffff8 | |||
| e0b17fc97d | |||
| 52800c3a65 | |||
| 9124617055 | |||
| b312712d1b | |||
| 5bc1b8695e | |||
| d921f3dadb | |||
| c154712012 | |||
| 3634af3fdc | |||
| 1df9ec9f0f | |||
| ae54a94d41 | |||
| 69add504e6 | |||
| a0d30b6872 | |||
| a06b33be66 |
+2
-2
@@ -16,11 +16,11 @@ Load and Storage:
|
||||
- Improved memcached support
|
||||
|
||||
Federation:
|
||||
- Add ActivityPub support
|
||||
- Added 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
|
||||
- Enable the search box to import remote notices and profiles
|
||||
- Enabled the search box to import remote notices and profiles
|
||||
- Improvements on Nodeinfo (and new route)
|
||||
|
||||
General:
|
||||
|
||||
+1
-2
@@ -46,7 +46,7 @@ Additional Contributors
|
||||
* Blaine Cook
|
||||
* Henry Story
|
||||
* Melvin Carvalho
|
||||
* chimo
|
||||
* Stéphane Bérubé
|
||||
* Akio
|
||||
* Maiyannah Bishop
|
||||
* Bob Mottram
|
||||
@@ -55,7 +55,6 @@ Additional Contributors
|
||||
* Moonman
|
||||
* Normandy
|
||||
* Verius
|
||||
* Alexei Sorokin
|
||||
* Daniel Supernault
|
||||
|
||||
Credits for StatusNet
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
GNU social Coding Style
|
||||
===========================
|
||||
|
||||
Please comply with [PSR-2](https://www.php-fig.org/psr/psr-2/) and the following standard when working on GNU social
|
||||
Please comply with [PSR-12](https://www.php-fig.org/psr/psr-12/) 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 PSR2 first.
|
||||
Respect PSR-12 first.
|
||||
|
||||
- Classes use PascalCase (e.g. MyClass).
|
||||
- Functions/Methods use camelCase (e.g. myFunction).
|
||||
@@ -145,11 +145,29 @@ 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) as they are evaluated in different orders and at different
|
||||
speeds. This is will prevent any confusion or strange results.
|
||||
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.
|
||||
|
||||
|
||||
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
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class AwesomenessPlugin extends Plugin
|
||||
'name' => 'Awesomeness',
|
||||
'version' => self::PLUGIN_VERSION,
|
||||
'author' => 'Jeroen De Dauw',
|
||||
'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/Awesomeness',
|
||||
'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/Awesomeness',
|
||||
// TRANS: Plugin description for a sample plugin.
|
||||
'rawdescription' => _m('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' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/BlankAdPlugin',
|
||||
'homepage' => GNUSOCIAL_ENGINE_REPO_URL . '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' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/Sample',
|
||||
'homepage' => GNUSOCIAL_ENGINE_REPO_URL . '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 GNU social
|
||||
* @package GNUsocial
|
||||
* @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 GNU social
|
||||
* @package GNUsocial
|
||||
* @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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() 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', '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'],
|
||||
'created' => ['type' => 'datetime', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['user_id'],
|
||||
'foreign keys' => [
|
||||
|
||||
@@ -228,7 +228,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): Wather to use queuedaemon. False means
|
||||
* `daemon` (boolean, default false): Whether to use queuedaemon. False means
|
||||
you'll use OpportunisticQM plugin.
|
||||
|
||||
* `subsystem` (enum["db", "stomp"], default 'db'): Which kind of queueserver to
|
||||
@@ -744,11 +744,9 @@ search
|
||||
Some stuff for search.
|
||||
|
||||
* `type`: type of search. Ignored if PostgreSQL or Sphinx are enabled. Can either
|
||||
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).
|
||||
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.
|
||||
|
||||
|
||||
sessions
|
||||
|
||||
@@ -6,7 +6,15 @@ server {
|
||||
server_name social.example.org;
|
||||
|
||||
# redirect all traffic to HTTPS
|
||||
rewrite ^ https://$host$request_uri? permanent;
|
||||
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;
|
||||
}
|
||||
|
||||
server {
|
||||
@@ -31,15 +39,23 @@ 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;
|
||||
@@ -67,6 +83,11 @@ 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 {
|
||||
@@ -91,13 +112,4 @@ 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;
|
||||
# }
|
||||
}
|
||||
|
||||
+5
-3
@@ -121,9 +121,11 @@ 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
|
||||
* master "stable", usually working well
|
||||
* nightly "testing", most updates, not always working as expected
|
||||
* 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.**
|
||||
|
||||
To keep it up-to-date, use `git pull`. Watch for conflicts!
|
||||
|
||||
|
||||
+10
-19
@@ -1,24 +1,15 @@
|
||||
# TODO
|
||||
|
||||
Load and Storage:
|
||||
- Upgrade STOMP queue
|
||||
- Port PEAR DB_DataObject to PDO_DataObject
|
||||
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.
|
||||
|
||||
Network:
|
||||
- Port PEAR HTTP to Guzzle
|
||||
- Port PEAR Mail to PHPSendMail
|
||||
- Add OAuth2 support (deprecate OAuth1?)
|
||||
Our roadmap is available in the following Kanban board:
|
||||
[Kanban Board](https://kanban.diogo.site/?controller=BoardViewController&action=readonly&token=03795efb8138c4e7661a900c234c0df1bc3fc03cdfcda8619cd5d0e666de).
|
||||
|
||||
General:
|
||||
- Fix failling unit tests
|
||||
- Improve Cronish
|
||||
- Run session garbage collection
|
||||
- Cleanup Email Registration
|
||||
- Refactoring of confirmation codes
|
||||
- Refactoring of Exceptions
|
||||
There are more pending tasks/ideas to implement in this
|
||||
[repo's issues](https://notabug.org/diogo/gnu-social/issues).
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
@@ -1,42 +1,38 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Administer site access settings
|
||||
*
|
||||
* @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/
|
||||
* @category Admin
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class AccessadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -45,7 +41,7 @@ class AccessadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Page title for Access admin panel that allows configuring site access.
|
||||
return _('Access');
|
||||
@@ -56,7 +52,7 @@ class AccessadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
function getInstructions()
|
||||
public function getInstructions()
|
||||
{
|
||||
// TRANS: Page notice.
|
||||
return _('Site access settings');
|
||||
@@ -67,7 +63,7 @@ class AccessadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showForm()
|
||||
public function showForm()
|
||||
{
|
||||
$form = new AccessAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -79,7 +75,7 @@ class AccessadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function saveSettings()
|
||||
public function saveSettings()
|
||||
{
|
||||
static $booleans = array('site' => array('private', 'inviteonly', 'closed'),
|
||||
'public' => array('localonly'));
|
||||
@@ -92,7 +88,7 @@ class AccessadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('BEGIN');
|
||||
$config->query('START TRANSACTION');
|
||||
|
||||
foreach ($booleans as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -113,7 +109,7 @@ class AccessAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
function id()
|
||||
public function id()
|
||||
{
|
||||
return 'form_site_admin_panel';
|
||||
}
|
||||
@@ -123,7 +119,7 @@ class AccessAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
function formClass()
|
||||
public function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -133,7 +129,7 @@ class AccessAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
function action()
|
||||
public function action()
|
||||
{
|
||||
return common_local_url('accessadminpanel');
|
||||
}
|
||||
@@ -143,7 +139,7 @@ class AccessAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formData()
|
||||
public function formData()
|
||||
{
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_admin_account_access'));
|
||||
// TRANS: Form legend for registration form.
|
||||
@@ -154,18 +150,24 @@ 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');
|
||||
@@ -173,26 +175,32 @@ class AccessAdminPanelForm extends AdminForm
|
||||
|
||||
|
||||
// Public access settings (login requirements for feeds etc.)
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_admin_public_access'));
|
||||
// TRANS: Form legend for registration form.
|
||||
$this->out->elementStart('fieldset', ['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');
|
||||
@@ -204,7 +212,7 @@ class AccessAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formActions()
|
||||
public function formActions()
|
||||
{
|
||||
// TRANS: Button title to save access settings in site admin panel.
|
||||
$title = _('Save access settings.');
|
||||
|
||||
@@ -1,44 +1,38 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* API analog to the group edit page
|
||||
*
|
||||
* @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/
|
||||
* @category API
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
{
|
||||
@@ -100,20 +94,21 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
$this->clientError(_('You must be an admin to edit the group.'), 403);
|
||||
}
|
||||
|
||||
$this->group->query('BEGIN');
|
||||
$this->group->query('START TRANSACTION');
|
||||
|
||||
$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',
|
||||
array('nickname' => $this->group->nickname));
|
||||
$this->group->mainpage = common_local_url(
|
||||
'showgroup',
|
||||
['nickname' => $this->group->nickname]
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($this->fullname)) {
|
||||
@@ -135,7 +130,6 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
$this->validateLocation();
|
||||
$this->group->location = $this->location;
|
||||
}
|
||||
|
||||
} catch (ApiValidationException $ave) {
|
||||
$this->clientError($ave->getMessage(), 400);
|
||||
}
|
||||
@@ -167,7 +161,7 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
|
||||
$this->group->query('COMMIT');
|
||||
|
||||
switch($this->format) {
|
||||
switch ($this->format) {
|
||||
case 'xml':
|
||||
$this->showSingleXmlGroup($this->group);
|
||||
break;
|
||||
@@ -180,7 +174,7 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
}
|
||||
}
|
||||
|
||||
function validateHomepage()
|
||||
public function validateHomepage()
|
||||
{
|
||||
if (!is_null($this->homepage)
|
||||
&& (strlen($this->homepage) > 0)
|
||||
@@ -192,7 +186,7 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
}
|
||||
}
|
||||
|
||||
function validateFullname()
|
||||
public function validateFullname()
|
||||
{
|
||||
if (!is_null($this->fullname) && mb_strlen($this->fullname) > 255) {
|
||||
throw new ApiValidationException(
|
||||
@@ -202,19 +196,21 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
}
|
||||
}
|
||||
|
||||
function validateDescription()
|
||||
public 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()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
function validateLocation()
|
||||
public function validateLocation()
|
||||
{
|
||||
if (!is_null($this->location) && mb_strlen($this->location) > 255) {
|
||||
throw new ApiValidationException(
|
||||
@@ -224,11 +220,13 @@ class ApiGroupProfileUpdateAction extends ApiAuthAction
|
||||
}
|
||||
}
|
||||
|
||||
function validateAliases()
|
||||
public function validateAliases()
|
||||
{
|
||||
try {
|
||||
$aliases = array_map(array('Nickname', 'normalize'),
|
||||
array_unique(preg_split('/[\s,]+/', $this->aliasstring)));
|
||||
$aliases = array_map(
|
||||
['Nickname', 'normalize'],
|
||||
array_unique(preg_split('/[\s,]+/', $this->aliasstring))
|
||||
);
|
||||
} catch (NicknameException $e) {
|
||||
throw new ApiValidationException(sprintf('Error processing aliases: %s', $e->getMessage()));
|
||||
}
|
||||
@@ -236,10 +234,12 @@ 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;
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
<?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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
@@ -30,31 +28,29 @@
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Returns the notice specified by id as a Twitter-style status and inline user
|
||||
*
|
||||
* @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/
|
||||
* @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
|
||||
*/
|
||||
class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
{
|
||||
var $notice_id = null;
|
||||
var $notice = null;
|
||||
public $notice_id = null;
|
||||
public $notice = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
@@ -131,7 +127,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showNotice()
|
||||
public function showNotice()
|
||||
{
|
||||
switch ($this->format) {
|
||||
case 'xml':
|
||||
@@ -158,9 +154,9 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
public function isReadOnly($args)
|
||||
{
|
||||
return ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
|
||||
return in_array($_SERVER['REQUEST_METHOD'], ['GET', 'HEAD']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +164,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return string datestamp of the latest notice in the stream
|
||||
*/
|
||||
function lastModified()
|
||||
public function lastModified()
|
||||
{
|
||||
return strtotime($this->notice->created);
|
||||
}
|
||||
@@ -181,7 +177,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
*
|
||||
* @return string etag
|
||||
*/
|
||||
function etag()
|
||||
public function etag()
|
||||
{
|
||||
return '"' . implode(
|
||||
':',
|
||||
@@ -194,7 +190,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
. '"';
|
||||
}
|
||||
|
||||
function deleteNotice()
|
||||
public function deleteNotice()
|
||||
{
|
||||
if ($this->format != 'atom') {
|
||||
// TRANS: Client error displayed when trying to delete a notice not using the Atom format.
|
||||
@@ -215,7 +211,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
|
||||
// @fixme is there better output we could do here?
|
||||
|
||||
header('HTTP/1.1 200 OK');
|
||||
http_response_code(200);
|
||||
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));
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
<?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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
@@ -30,30 +28,26 @@
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* 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 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/
|
||||
* @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
|
||||
*/
|
||||
class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
{
|
||||
@@ -101,16 +95,14 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
if (!empty($this->notices) && (count($this->notices) > 0)) {
|
||||
$last = count($this->notices) - 1;
|
||||
|
||||
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 '"' . 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 null;
|
||||
@@ -250,7 +242,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
}
|
||||
Event::handle('EndAtomPubNewActivity', array($activity, $this->target, $stored));
|
||||
|
||||
header('HTTP/1.1 201 Created');
|
||||
http_response_code(201);
|
||||
header("Location: " . common_local_url('ApiStatusesShow', array('id' => $stored->getID(),
|
||||
'format' => 'atom')));
|
||||
$this->showSingleAtomStatus($stored);
|
||||
|
||||
@@ -173,7 +173,7 @@ class AttachmentAction extends ManagedAction
|
||||
* @return string etag http header
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function etag(): string
|
||||
public function etag(): ?string
|
||||
{
|
||||
if (common_config('site', 'use_x_sendfile')) {
|
||||
return null;
|
||||
@@ -202,36 +202,4 @@ 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
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function sendFile(): void
|
||||
{
|
||||
if (is_string(common_config('site', 'x-static-delivery'))) {
|
||||
$tmp = explode(INSTALLDIR, $this->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($this->filesize)) {
|
||||
$this->filesize = filesize($this->filepath);
|
||||
}
|
||||
header("Content-Length: {$this->filesize}");
|
||||
// header('Cache-Control: private, no-transform, no-store, must-revalidate');
|
||||
|
||||
$ret = @readfile($this->filepath);
|
||||
|
||||
if ($ret === false) {
|
||||
common_log(LOG_ERR, "Couldn't read file at {$this->filepath}.");
|
||||
} elseif ($ret !== $this->filesize) {
|
||||
common_log(LOG_ERR, "The lengths of the file as recorded on the DB (or on disk) for the file " .
|
||||
"{$this->filepath} differ from what was sent to the user ({$this->filesize} vs {$ret}).");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,6 @@ class Attachment_downloadAction extends AttachmentAction
|
||||
// script execution, and we don't want to have any more errors until then, so don't reset it
|
||||
@ini_set('display_errors', 0);
|
||||
|
||||
header("Content-Description: File Transfer");
|
||||
header("Content-Type: {$this->mimetype}");
|
||||
header("Content-Disposition: attachment; filename=\"{$this->filename}\"");
|
||||
header('Expires: 0');
|
||||
header('Content-Transfer-Encoding: binary'); // FIXME? Can this be different?
|
||||
|
||||
parent::sendFile();
|
||||
common_send_file($this->filepath, $this->mimetype, $this->filename, 'attachment');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,12 +67,6 @@ class Attachment_thumbnailAction extends AttachmentAction
|
||||
// script execution, and we don't want to have any more errors until then, so don't reset it
|
||||
@ini_set('display_errors', 0);
|
||||
|
||||
header("Content-Description: File Transfer");
|
||||
header("Content-Type: {$this->mimetype}");
|
||||
header("Content-Disposition: inline; filename=\"{$this->filename}\"");
|
||||
header('Expires: 0');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
parent::sendFile();
|
||||
common_send_file($this->filepath, $this->mimetype, $this->filename, 'inline');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,16 +32,7 @@ class Attachment_viewAction extends AttachmentAction
|
||||
// script execution, and we don't want to have any more errors until then, so don't reset it
|
||||
@ini_set('display_errors', 0);
|
||||
|
||||
header("Content-Description: File Transfer");
|
||||
header("Content-Type: {$this->mimetype}");
|
||||
if (in_array(common_get_mime_media($this->mimetype), ['image', 'video'])) {
|
||||
header("Content-Disposition: inline; filename=\"{$this->filename}\"");
|
||||
} else {
|
||||
header("Content-Disposition: attachment; filename=\"{$this->filename}\"");
|
||||
}
|
||||
header('Expires: 0');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
parent::sendFile();
|
||||
$disposition = in_array(common_get_mime_media($this->mimetype), ['image', 'video']) ? 'inline' : 'attachment';
|
||||
common_send_file($this->filepath, $this->mimetype, $this->filename, $disposition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
}
|
||||
+190
-145
@@ -1,34 +1,32 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Upload an avatar
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Settings
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
*
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
* @copyright 2008-2009, 2020 Free Software Foundation http://fsf.org
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die;
|
||||
|
||||
/**
|
||||
* Upload an avatar
|
||||
@@ -37,24 +35,26 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
*
|
||||
* @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/
|
||||
*
|
||||
* @see http://status.net/
|
||||
*/
|
||||
class AvatarsettingsAction extends SettingsAction
|
||||
{
|
||||
var $mode = null;
|
||||
var $imagefile = null;
|
||||
var $filename = null;
|
||||
public $mode;
|
||||
public $imagefile;
|
||||
public $filename;
|
||||
|
||||
function prepare(array $args=array())
|
||||
public function prepare(array $args = [])
|
||||
{
|
||||
$avatarpath = Avatar::path('');
|
||||
|
||||
if (!is_writable($avatarpath)) {
|
||||
throw new Exception(_("The administrator of your site needs to
|
||||
throw new Exception(_m("The administrator of your site needs to
|
||||
add write permissions on the avatar upload folder before
|
||||
you're able to set one."));
|
||||
}
|
||||
@@ -67,24 +67,30 @@ class AvatarsettingsAction extends SettingsAction
|
||||
* Title of the page
|
||||
*
|
||||
* @return string Title of the page
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title for avatar upload page.
|
||||
return _('Avatar');
|
||||
return _m('Avatar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructions for use
|
||||
*
|
||||
* @return instructions for use
|
||||
* @return string instructions for use
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
function getInstructions()
|
||||
public function getInstructions()
|
||||
{
|
||||
// TRANS: Instruction for avatar upload page.
|
||||
// TRANS: %s is the maximum file size, for example "500b", "10kB" or "2MB".
|
||||
return sprintf(_('You can upload your personal avatar. The maximum file size is %s.'),
|
||||
ImageFile::maxFileSize());
|
||||
return sprintf(
|
||||
_m('You can upload your personal avatar. The maximum file size is %s.'),
|
||||
ImageFile::maxFileSize()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +101,7 @@ class AvatarsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
if ($this->mode == 'crop') {
|
||||
$this->showCropForm();
|
||||
@@ -104,33 +110,37 @@ class AvatarsettingsAction extends SettingsAction
|
||||
}
|
||||
}
|
||||
|
||||
function showUploadForm()
|
||||
public function showUploadForm()
|
||||
{
|
||||
$this->elementStart('form', array('enctype' => 'multipart/form-data',
|
||||
'method' => 'post',
|
||||
'id' => 'form_settings_avatar',
|
||||
'class' => 'form_settings',
|
||||
'action' =>
|
||||
common_local_url('avatarsettings')));
|
||||
// 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('fieldset');
|
||||
// TRANS: Avatar upload page form legend.
|
||||
$this->element('legend', null, _('Avatar settings'));
|
||||
$this->element('legend', null, _m('Avatar settings'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
if (Event::handle('StartAvatarFormData', array($this))) {
|
||||
if (Event::handle('StartAvatarFormData', [$this])) {
|
||||
$this->elementStart('ul', 'form_data');
|
||||
try {
|
||||
$original = Avatar::getUploaded($this->scoped);
|
||||
|
||||
$this->elementStart('li', array('id' => 'avatar_original',
|
||||
'class' => 'avatar_view'));
|
||||
$this->elementStart('li', ['id' => 'avatar_original',
|
||||
'class' => 'avatar_view',]);
|
||||
// TRANS: Header on avatar upload page for thumbnail of originally uploaded avatar (h2).
|
||||
$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->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->elementEnd('div');
|
||||
$this->elementEnd('li');
|
||||
} catch (NoAvatarException $e) {
|
||||
@@ -139,97 +149,100 @@ class AvatarsettingsAction extends SettingsAction
|
||||
|
||||
try {
|
||||
$avatar = $this->scoped->getAvatar(AVATAR_PROFILE_SIZE);
|
||||
$this->elementStart('li', array('id' => 'avatar_preview',
|
||||
'class' => 'avatar_view'));
|
||||
$this->elementStart('li', ['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, _("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->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->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', 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->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->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', array($this));
|
||||
Event::handle('EndAvatarFormData', [$this]);
|
||||
|
||||
$this->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
}
|
||||
|
||||
function showCropForm()
|
||||
public function showCropForm()
|
||||
{
|
||||
$this->elementStart('form', array('method' => 'post',
|
||||
'id' => 'form_settings_avatar',
|
||||
'class' => 'form_settings',
|
||||
'action' =>
|
||||
common_local_url('avatarsettings')));
|
||||
$this->elementStart('form', ['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, _('Avatar settings'));
|
||||
$this->element('legend', null, _m('Avatar settings'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
$this->elementStart('ul', 'form_data');
|
||||
|
||||
$this->elementStart('li',
|
||||
array('id' => 'avatar_original',
|
||||
'class' => 'avatar_view'));
|
||||
$this->elementStart(
|
||||
'li',
|
||||
['id' => 'avatar_original',
|
||||
'class' => 'avatar_view',]
|
||||
);
|
||||
// TRANS: Header on avatar upload crop form for thumbnail of originally uploaded avatar (h2).
|
||||
$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->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->elementEnd('div');
|
||||
$this->elementEnd('li');
|
||||
|
||||
$this->elementStart('li',
|
||||
array('id' => 'avatar_preview',
|
||||
'class' => 'avatar_view'));
|
||||
$this->elementStart(
|
||||
'li',
|
||||
['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, _('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->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->elementEnd('div');
|
||||
|
||||
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));
|
||||
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,]);
|
||||
}
|
||||
|
||||
// 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');
|
||||
@@ -237,20 +250,31 @@ 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', array($this))) {
|
||||
if (Event::handle('StartAvatarSaveForm', [$this])) {
|
||||
if ($this->trimmed('upload')) {
|
||||
return $this->uploadAvatar();
|
||||
} else if ($this->trimmed('crop')) {
|
||||
} elseif ($this->trimmed('crop')) {
|
||||
return $this->cropAvatar();
|
||||
} else if ($this->trimmed('delete')) {
|
||||
} elseif ($this->trimmed('delete')) {
|
||||
return $this->deleteAvatar();
|
||||
} else {
|
||||
// TRANS: Unexpected validation error on avatar upload form.
|
||||
throw new ClientException(_('Unexpected form submission.'));
|
||||
throw new ClientException(_m('Unexpected form submission.'));
|
||||
}
|
||||
Event::handle('EndAvatarSaveForm', array($this));
|
||||
Event::handle('EndAvatarSaveForm', [$this]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,28 +284,39 @@ class AvatarsettingsAction extends SettingsAction
|
||||
* Does all the magic for handling an image upload, and crops the
|
||||
* image by default.
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
* @throws NoResultException
|
||||
* @throws NoUploadedMediaException
|
||||
* @throws ServerException
|
||||
* @throws UnsupportedMediaException
|
||||
* @throws UseFileAsThumbnailException
|
||||
*
|
||||
* @throws ClientException
|
||||
*/
|
||||
function uploadAvatar()
|
||||
public function uploadAvatar(): string
|
||||
{
|
||||
// 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 = array('filename' => $filename,
|
||||
'filepath' => $filepath,
|
||||
'width' => $imagefile->width,
|
||||
'height' => $imagefile->height,
|
||||
'type' => $type);
|
||||
$filedata = [
|
||||
'filename' => $filename,
|
||||
'filepath' => $filepath,
|
||||
'width' => $imagefile->width,
|
||||
'height' => $imagefile->height,
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
$_SESSION['FILEDATA'] = $filedata;
|
||||
|
||||
@@ -290,13 +325,18 @@ class AvatarsettingsAction extends SettingsAction
|
||||
$this->mode = 'crop';
|
||||
|
||||
// TRANS: Avatar upload form instruction after uploading a file.
|
||||
return _('Pick a square area of the image to be your avatar.');
|
||||
return _m('Pick a square area of the image to be your avatar.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the results of jcrop.
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
* @throws NoResultException
|
||||
* @throws ServerException
|
||||
* @throws UnsupportedMediaException
|
||||
*
|
||||
* @throws ClientException
|
||||
*/
|
||||
public function cropAvatar()
|
||||
{
|
||||
@@ -304,30 +344,34 @@ class AvatarsettingsAction extends SettingsAction
|
||||
|
||||
if (empty($filedata)) {
|
||||
// TRANS: Server error displayed if an avatar upload went wrong somehow server side.
|
||||
throw new ServerException(_('Lost our file data.'));
|
||||
throw new ServerException(_m('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 = intval(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 = (int)(min($dest_w, $dest_h, common_config('avatar', 'maxsize')));
|
||||
|
||||
$box = array('width' => $size, 'height' => $size,
|
||||
'x' => $dest_x, 'y' => $dest_y,
|
||||
'w' => $dest_w, 'h' => $dest_h);
|
||||
$box = ['width' => $size, 'height' => $size,
|
||||
'x' => $dest_x, 'y' => $dest_y,
|
||||
'w' => $dest_w, 'h' => $dest_h,];
|
||||
|
||||
$imagefile = new ImageFile(null, $filedata['filepath']);
|
||||
$filename = Avatar::filename($this->scoped->getID(), image_type_to_extension($imagefile->preferredType()),
|
||||
$size, common_timestamp());
|
||||
$imagefile = new ImageFile(-1, $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.');
|
||||
}
|
||||
}
|
||||
@@ -337,24 +381,26 @@ class AvatarsettingsAction extends SettingsAction
|
||||
unset($_SESSION['FILEDATA']);
|
||||
$this->mode = 'upload';
|
||||
// TRANS: Success message for having updated a user avatar.
|
||||
return _('Avatar updated.');
|
||||
return _m('Avatar updated.');
|
||||
}
|
||||
|
||||
// TRANS: Error displayed on the avatar upload page if the avatar could not be updated for an unknown reason.
|
||||
throw new ServerException(_('Failed updating avatar.'));
|
||||
throw new ServerException(_m('Failed updating avatar.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rid of the current avatar.
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
function deleteAvatar()
|
||||
public function deleteAvatar()
|
||||
{
|
||||
Avatar::deleteFromProfile($this->scoped);
|
||||
|
||||
// TRANS: Success message for deleting a user avatar.
|
||||
return _('Avatar deleted.');
|
||||
return _m('Avatar deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,11 +408,10 @@ class AvatarsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showStylesheets()
|
||||
public 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');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,7 +419,7 @@ class AvatarsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showScripts()
|
||||
public function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
|
||||
|
||||
+84
-75
@@ -1,50 +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/>.
|
||||
|
||||
/**
|
||||
* Block a user action class.
|
||||
*
|
||||
* 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/>.
|
||||
* @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
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Block a user action class.
|
||||
*
|
||||
* @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/
|
||||
* @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
|
||||
*/
|
||||
class BlockAction extends ProfileFormAction
|
||||
{
|
||||
var $profile = null;
|
||||
public $profile = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
@@ -53,7 +47,7 @@ class BlockAction extends ProfileFormAction
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
function prepare(array $args = array())
|
||||
public function prepare(array $args = []): bool
|
||||
{
|
||||
if (!parent::prepare($args)) {
|
||||
return false;
|
||||
@@ -78,7 +72,7 @@ class BlockAction extends ProfileFormAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if ($this->arg('no')) {
|
||||
@@ -94,16 +88,19 @@ class BlockAction extends ProfileFormAction
|
||||
}
|
||||
}
|
||||
|
||||
function showContent() {
|
||||
public function showContent(): void
|
||||
{
|
||||
$this->areYouSureForm();
|
||||
}
|
||||
|
||||
function title() {
|
||||
public function title(): string
|
||||
{
|
||||
// TRANS: Title for block user page.
|
||||
return _('Block user');
|
||||
}
|
||||
|
||||
function showNoticeForm() {
|
||||
public function showNoticeForm(): void
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
@@ -114,7 +111,7 @@ class BlockAction extends ProfileFormAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function areYouSureForm()
|
||||
public function areYouSureForm()
|
||||
{
|
||||
// @fixme if we ajaxify the confirmation form, skip the preview on ajax hits
|
||||
$profile = new ArrayWrapper(array($this->profile));
|
||||
@@ -131,35 +128,44 @@ 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', array('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', [
|
||||
'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');
|
||||
}
|
||||
@@ -170,7 +176,7 @@ class BlockAction extends ProfileFormAction
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handlePost()
|
||||
public function handlePost(): void
|
||||
{
|
||||
$cur = common_current_user();
|
||||
|
||||
@@ -187,7 +193,7 @@ class BlockAction extends ProfileFormAction
|
||||
}
|
||||
}
|
||||
|
||||
function showScripts()
|
||||
public function showScripts(): void
|
||||
{
|
||||
parent::showScripts();
|
||||
$this->autofocus('form_action-yes');
|
||||
@@ -201,13 +207,14 @@ class BlockAction extends ProfileFormAction
|
||||
* @throws ClientException if token is bad on POST request or if we have
|
||||
* confirmation parameters which could trigger something.
|
||||
*/
|
||||
function checkSessionToken()
|
||||
public function checkSessionToken(): void
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST' ||
|
||||
$this->arg('yes') ||
|
||||
$this->arg('no')) {
|
||||
|
||||
return parent::checkSessionToken();
|
||||
if (
|
||||
$_SERVER['REQUEST_METHOD'] === 'POST'
|
||||
|| $this->arg('yes')
|
||||
|| $this->arg('no')
|
||||
) {
|
||||
parent::checkSessionToken();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,12 +224,14 @@ class BlockAction extends ProfileFormAction
|
||||
*
|
||||
* @return string URL
|
||||
*/
|
||||
function defaultReturnTo()
|
||||
public function defaultReturnTo()
|
||||
{
|
||||
$user = common_current_user();
|
||||
if ($user) {
|
||||
return common_local_url('subscribers',
|
||||
array('nickname' => $user->nickname));
|
||||
return common_local_url(
|
||||
'subscribers',
|
||||
['nickname' => $user->nickname]
|
||||
);
|
||||
} else {
|
||||
return common_local_url('public');
|
||||
}
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Confirm an address
|
||||
@@ -36,11 +33,10 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
* a confirmation code to make sure the owner of that address approves. This class
|
||||
* accepts those codes.
|
||||
*
|
||||
* @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/
|
||||
* @category Confirm
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class ConfirmaddressAction extends ManagedAction
|
||||
{
|
||||
@@ -88,7 +84,7 @@ class ConfirmaddressAction extends ManagedAction
|
||||
|
||||
$cur = $this->scoped->getUser();
|
||||
|
||||
$cur->query('BEGIN');
|
||||
$cur->query('START TRANSACTION');
|
||||
if (in_array($type, array('email', 'sms'))) {
|
||||
common_debug("Confirming {$type} address for user {$this->scoped->getID()}");
|
||||
if ($cur->$type == $confirm->address) {
|
||||
@@ -114,14 +110,12 @@ 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.
|
||||
@@ -135,7 +129,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;
|
||||
@@ -149,7 +143,6 @@ class ConfirmaddressAction extends ManagedAction
|
||||
throw new ServerException(_('Could not insert user IM preferences.'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$confirm->delete();
|
||||
@@ -162,7 +155,7 @@ class ConfirmaddressAction extends ManagedAction
|
||||
*
|
||||
* @return string title
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title for the contact address confirmation action.
|
||||
return _('Confirm address');
|
||||
@@ -173,13 +166,17 @@ class ConfirmaddressAction extends ManagedAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showContent()
|
||||
public 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
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+25
-31
@@ -1,50 +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
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA') && !defined('GNUSOCIAL')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Add a new group
|
||||
*
|
||||
* This is the form for adding a new group
|
||||
*
|
||||
* @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/
|
||||
* @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
|
||||
*/
|
||||
class EditgroupAction extends GroupAction
|
||||
{
|
||||
@@ -242,7 +236,7 @@ class EditgroupAction extends GroupAction
|
||||
return;
|
||||
}
|
||||
|
||||
$this->group->query('BEGIN');
|
||||
$this->group->query('START TRANSACTION');
|
||||
|
||||
$orig = clone($this->group);
|
||||
|
||||
|
||||
+92
-73
@@ -1,50 +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
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @package GNUsocial
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Add a new group
|
||||
*
|
||||
* This is the form for adding a new group
|
||||
*
|
||||
* @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/
|
||||
* @category Group
|
||||
* @package GNUsocial
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
class EditpeopletagAction extends Action
|
||||
{
|
||||
var $msg, $confirm, $confirm_args=array();
|
||||
public $msg;
|
||||
public $confirm;
|
||||
public $confirm_args = [];
|
||||
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $this->boolean('delete')) {
|
||||
// TRANS: Title for edit list page after deleting a tag.
|
||||
@@ -60,7 +56,7 @@ class EditpeopletagAction extends Action
|
||||
* Prepare to run
|
||||
*/
|
||||
|
||||
function prepare(array $args = array())
|
||||
public function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
@@ -135,7 +131,7 @@ class EditpeopletagAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle()
|
||||
public function handle()
|
||||
{
|
||||
parent::handle();
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
@@ -145,21 +141,30 @@ class EditpeopletagAction extends Action
|
||||
}
|
||||
}
|
||||
|
||||
function showConfirm($msg=null, $fwd=null)
|
||||
public function showConfirm($msg = null, $fwd = null)
|
||||
{
|
||||
$this->confirm = $msg;
|
||||
$this->confirm_args = $fwd;
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
function showConfirmForm()
|
||||
public function showConfirmForm()
|
||||
{
|
||||
$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(
|
||||
'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('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
$this->hidden('id', $this->arg('id'));
|
||||
@@ -168,31 +173,35 @@ 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');
|
||||
}
|
||||
|
||||
function showForm($msg=null)
|
||||
public function showForm($msg = null)
|
||||
{
|
||||
$this->msg = $msg;
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
function showObjectNav()
|
||||
public function showObjectNav()
|
||||
{
|
||||
$nav = new PeopletagGroupNav($this, $this->peopletag);
|
||||
$nav->show();
|
||||
}
|
||||
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
if ($this->confirm) {
|
||||
$this->showConfirmForm();
|
||||
@@ -205,26 +214,29 @@ class EditpeopletagAction extends Action
|
||||
$form->showProfileList();
|
||||
}
|
||||
|
||||
function showPageNotice()
|
||||
public function showPageNotice()
|
||||
{
|
||||
if ($this->msg) {
|
||||
$this->element('p', 'error', $this->msg);
|
||||
} else if ($this->confirm) {
|
||||
} elseif ($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.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function showScripts()
|
||||
public function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
$this->autofocus('tag');
|
||||
}
|
||||
|
||||
function trySave()
|
||||
public function trySave()
|
||||
{
|
||||
$tag = common_canonical_tag($this->trimmed('tag'));
|
||||
$description = $this->trimmed('description');
|
||||
@@ -247,25 +259,26 @@ class EditpeopletagAction extends Action
|
||||
'all its subscription and membership records. ' .
|
||||
'Do you still want to continue?'), array('delete' => 1));
|
||||
return;
|
||||
} else if (common_valid_tag($tag)) {
|
||||
} elseif (common_valid_tag($tag)) {
|
||||
// TRANS: Form validation error displayed if a given tag is invalid.
|
||||
$this->showForm(_('Invalid tag.'));
|
||||
return;
|
||||
} else if ($tag != $this->peopletag->tag && $this->tagExists($tag)) {
|
||||
} elseif ($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;
|
||||
} else if (Profile_list::descriptionTooLong($description)) {
|
||||
} elseif (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;
|
||||
} else if ($set_private && !$confirm && !$cancel) {
|
||||
} elseif ($set_private && !$confirm && !$cancel) {
|
||||
$fwd = array('tag' => $tag,
|
||||
'description' => $description,
|
||||
'private' => (int) $private);
|
||||
@@ -285,7 +298,7 @@ class EditpeopletagAction extends Action
|
||||
common_redirect(common_local_url('all', array('nickname' => $this->tagger->getNickname())), 303);
|
||||
}
|
||||
|
||||
$this->peopletag->query('BEGIN');
|
||||
$this->peopletag->query('START TRANSACTION');
|
||||
|
||||
$orig = clone($this->peopletag);
|
||||
|
||||
@@ -310,17 +323,23 @@ class EditpeopletagAction extends Action
|
||||
}
|
||||
|
||||
if ($tag != $orig->tag) {
|
||||
common_redirect(common_local_url('editpeopletag',
|
||||
array('tagger' => $this->tagger->nickname,
|
||||
'tag' => $tag)),
|
||||
303);
|
||||
common_redirect(
|
||||
common_local_url(
|
||||
'editpeopletag',
|
||||
[
|
||||
'tagger' => $this->tagger->nickname,
|
||||
'tag' => $tag,
|
||||
]
|
||||
),
|
||||
303
|
||||
);
|
||||
} else {
|
||||
// TRANS: Edit list form success message.
|
||||
$this->showForm(_('Options saved.'));
|
||||
}
|
||||
}
|
||||
|
||||
function tagExists($tag)
|
||||
public function tagExists($tag)
|
||||
{
|
||||
$args = array('tagger' => $this->tagger->id, 'tag' => $tag);
|
||||
$ptag = Profile_list::pkeyGet($args);
|
||||
|
||||
@@ -92,7 +92,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
$this->element('legend', null, _('Email address'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
if ($user->email) {
|
||||
if (!$user->isNull('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.'));
|
||||
@@ -163,7 +163,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
|
||||
$this->elementStart('div', array('id' => 'emailincoming'));
|
||||
|
||||
if ($user->incomingemail) {
|
||||
if (!$user->isNull('incomingemail')) {
|
||||
$this->elementStart('p');
|
||||
$this->element('span', 'address', $user->incomingemail);
|
||||
// @todo XXX: Looks a little awkward in the UI.
|
||||
@@ -180,7 +180,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
}
|
||||
|
||||
$this->elementStart('p');
|
||||
if ($user->incomingemail) {
|
||||
if (!$user->isNull('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.');
|
||||
@@ -302,7 +302,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
$emailpost = $this->boolean('emailpost');
|
||||
|
||||
$user = $this->scoped->getUser();
|
||||
$user->query('BEGIN');
|
||||
$user->query('START TRANSACTION');
|
||||
$original = clone($user);
|
||||
|
||||
$user->emailnotifysub = $emailnotifysub;
|
||||
@@ -435,7 +435,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
}
|
||||
|
||||
$original = clone($user);
|
||||
$user->email = DB_DataObject_Cast::sql('NULL');
|
||||
$user->email = $user->sqlValue('NULL');
|
||||
// Throws exception on failure. Also performs it within a transaction.
|
||||
$user->updateWithKeys($original);
|
||||
|
||||
@@ -458,7 +458,7 @@ class EmailsettingsAction extends SettingsAction
|
||||
}
|
||||
|
||||
$orig = clone($user);
|
||||
$user->incomingemail = DB_DataObject_Cast::sql('NULL');
|
||||
$user->incomingemail = $user->sqlValue('NULL');
|
||||
$user->emailpost = false;
|
||||
// Throws exception on failure. Also performs it within a transaction.
|
||||
$user->updateWithKeys($orig);
|
||||
|
||||
+51
-36
@@ -1,23 +1,25 @@
|
||||
<?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/>.
|
||||
* @copyright 2008, 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
define('LISTENER', 1);
|
||||
define('LISTENEE', -1);
|
||||
@@ -26,7 +28,7 @@ define('BOTH', 0);
|
||||
// @todo XXX: Documentation missing.
|
||||
class FoafAction extends ManagedAction
|
||||
{
|
||||
function isReadOnly($args)
|
||||
public function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -45,9 +47,13 @@ class FoafAction extends ManagedAction
|
||||
// Permanent redirect on non-canonical nickname
|
||||
|
||||
if ($nickname_arg != $this->nickname) {
|
||||
common_redirect(common_local_url('foaf',
|
||||
array('nickname' => $this->nickname)),
|
||||
301);
|
||||
common_redirect(
|
||||
common_local_url(
|
||||
'foaf',
|
||||
['nickname' => $this->nickname]
|
||||
),
|
||||
301
|
||||
);
|
||||
}
|
||||
|
||||
$this->user = User::getKV('nickname', $this->nickname);
|
||||
@@ -152,22 +158,27 @@ 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();
|
||||
@@ -206,11 +217,15 @@ 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));
|
||||
}
|
||||
@@ -227,7 +242,7 @@ class FoafAction extends ManagedAction
|
||||
$this->endXML();
|
||||
}
|
||||
|
||||
function showPpd($foaf_url, $person_uri)
|
||||
public function showPpd($foaf_url, $person_uri)
|
||||
{
|
||||
$this->elementStart('PersonalProfileDocument', array('rdf:about' => $foaf_url));
|
||||
$this->element('maker', array('rdf:resource' => $person_uri));
|
||||
@@ -248,7 +263,7 @@ class FoafAction extends ManagedAction
|
||||
* @return array if $fetchSubscribers is set, return a list of info on those
|
||||
* subscriptions.
|
||||
*/
|
||||
function showMicrobloggingAccount($profile, $service=null, $useruri=null, $fetchSubscriptions=false, $isSubscriber=false)
|
||||
public function showMicrobloggingAccount($profile, $service = null, $useruri = null, $fetchSubscriptions = false, $isSubscriber = false)
|
||||
{
|
||||
$attr = array();
|
||||
if ($useruri) {
|
||||
@@ -274,13 +289,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();
|
||||
@@ -294,7 +309,7 @@ class FoafAction extends ManagedAction
|
||||
}
|
||||
|
||||
unset($sub);
|
||||
} else if ($isSubscriber) {
|
||||
} elseif ($isSubscriber) {
|
||||
// Just declare that they follow the user whose FOAF we're showing.
|
||||
$this->element('sioc:follows', array('rdf:resource' => $this->user->getUri() . '#acct'));
|
||||
}
|
||||
|
||||
+50
-49
@@ -1,85 +1,82 @@
|
||||
<?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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* List of group members
|
||||
*
|
||||
* @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/
|
||||
* @category Group
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class GroupmembersAction extends GroupAction
|
||||
{
|
||||
var $page = null;
|
||||
public $page = null;
|
||||
|
||||
function isReadOnly($args)
|
||||
public function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function title()
|
||||
public 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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function handle()
|
||||
public function showPageNotice()
|
||||
{
|
||||
parent::handle();
|
||||
$this->showPage();
|
||||
$this->element(
|
||||
'p',
|
||||
'instructions',
|
||||
// TRANS: Page notice for group members page.
|
||||
_('A list of the users in this group.')
|
||||
);
|
||||
}
|
||||
|
||||
function showPageNotice()
|
||||
{
|
||||
$this->element('p', 'instructions',
|
||||
// TRANS: Page notice for group members page.
|
||||
_('A list of the users in this group.'));
|
||||
}
|
||||
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
$offset = ($this->page-1) * PROFILES_PER_PAGE;
|
||||
$limit = PROFILES_PER_PAGE + 1;
|
||||
$limit = PROFILES_PER_PAGE + 1;
|
||||
|
||||
$cnt = 0;
|
||||
|
||||
@@ -90,8 +87,12 @@ class GroupmembersAction extends GroupAction
|
||||
$cnt = $member_list->show();
|
||||
}
|
||||
|
||||
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
|
||||
$this->page, 'groupmembers',
|
||||
array('nickname' => $this->group->nickname));
|
||||
$this->pagination(
|
||||
$this->page > 1,
|
||||
$cnt > PROFILES_PER_PAGE,
|
||||
$this->page,
|
||||
'groupmembers',
|
||||
['nickname' => $this->group->nickname]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+93
-97
@@ -1,44 +1,25 @@
|
||||
<?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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Settings for Jabber/XMPP integration
|
||||
*
|
||||
* @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/
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see SettingsAction
|
||||
* @see SettingsAction
|
||||
*/
|
||||
|
||||
class ImsettingsAction extends SettingsAction
|
||||
@@ -48,7 +29,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title for Instant Messaging settings.
|
||||
return _('IM settings');
|
||||
@@ -59,7 +40,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
function getInstructions()
|
||||
public function getInstructions()
|
||||
{
|
||||
// TRANS: Instant messaging settings page instructions.
|
||||
// TRANS: [instant messages] is link text, "(%%doc.im%%)" is the link.
|
||||
@@ -78,94 +59,112 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
$transports = array();
|
||||
Event::handle('GetImTransports', array(&$transports));
|
||||
if (! $transports) {
|
||||
$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.'));
|
||||
$this->element(
|
||||
'div',
|
||||
['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', array('method' => 'post',
|
||||
'id' => 'form_settings_im',
|
||||
'class' => 'form_settings',
|
||||
'action' =>
|
||||
common_local_url('imsettings')));
|
||||
|
||||
foreach ($transports as $transport => $transport_info) {
|
||||
$this->elementStart(
|
||||
'form',
|
||||
[
|
||||
'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( array('transport' => $transport, 'user_id' => $user->id) )) {
|
||||
if ($user_im_prefs = User_im_prefs::pkeyGet(['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', array('method' => 'post',
|
||||
'id' => 'form_settings_im',
|
||||
'class' => 'form_settings',
|
||||
'action' =>
|
||||
common_local_url('imsettings')));
|
||||
if ($user_im_prefs_by_transport) {
|
||||
$this->elementStart(
|
||||
'form',
|
||||
[
|
||||
'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');
|
||||
@@ -178,23 +177,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');
|
||||
}
|
||||
@@ -205,7 +204,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return Confirm_address address object for this user
|
||||
*/
|
||||
function getConfirmation($transport)
|
||||
public function getConfirmation($transport)
|
||||
{
|
||||
$confirm = new Confirm_address();
|
||||
|
||||
@@ -223,11 +222,11 @@ class ImsettingsAction extends SettingsAction
|
||||
{
|
||||
if ($this->arg('save')) {
|
||||
return $this->savePreferences();
|
||||
} else if ($this->arg('add')) {
|
||||
} elseif ($this->arg('add')) {
|
||||
return $this->addAddress();
|
||||
} else if ($this->arg('cancel')) {
|
||||
} elseif ($this->arg('cancel')) {
|
||||
return $this->cancelConfirmation();
|
||||
} else if ($this->arg('remove')) {
|
||||
} elseif ($this->arg('remove')) {
|
||||
return $this->removeAddress();
|
||||
}
|
||||
// TRANS: Message given submitting a form with an unknown action in Instant Messaging settings.
|
||||
@@ -242,20 +241,17 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function savePreferences()
|
||||
public function savePreferences()
|
||||
{
|
||||
$user_im_prefs = new User_im_prefs();
|
||||
$user_im_prefs->query('BEGIN');
|
||||
$user_im_prefs->query('START TRANSACTION');
|
||||
$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);
|
||||
@@ -265,7 +261,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.
|
||||
@@ -280,7 +276,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function addAddress()
|
||||
public function addAddress()
|
||||
{
|
||||
$screenname = $this->trimmed('screenname');
|
||||
$transport = $this->trimmed('transport');
|
||||
@@ -308,7 +304,7 @@ class ImsettingsAction extends SettingsAction
|
||||
if (!$valid) {
|
||||
// TRANS: Message given saving IM address that not valid.
|
||||
throw new ClientException(_('Not a valid screenname.'));
|
||||
} else if ($this->screennameExists($transport, $screenname)) {
|
||||
} elseif ($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.'));
|
||||
}
|
||||
@@ -343,7 +339,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function cancelConfirmation()
|
||||
public function cancelConfirmation()
|
||||
{
|
||||
$screenname = $this->trimmed('screenname');
|
||||
$transport = $this->trimmed('transport');
|
||||
@@ -372,7 +368,7 @@ class ImsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function removeAddress()
|
||||
public function removeAddress()
|
||||
{
|
||||
$screenname = $this->trimmed('screenname');
|
||||
$transport = $this->trimmed('transport');
|
||||
@@ -413,7 +409,7 @@ class ImsettingsAction extends SettingsAction
|
||||
* @return boolean whether the screenname exists
|
||||
*/
|
||||
|
||||
function screennameExists($transport, $screenname)
|
||||
public function screennameExists($transport, $screenname)
|
||||
{
|
||||
$user_im_prefs = new User_im_prefs();
|
||||
$user_im_prefs->transport = $transport;
|
||||
|
||||
@@ -1,44 +1,38 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* License settings
|
||||
*
|
||||
* @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/
|
||||
* @category Admin
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class LicenseadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -48,7 +42,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
* @return string page title
|
||||
*/
|
||||
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: User admin panel title
|
||||
return _m('TITLE', 'License');
|
||||
@@ -59,7 +53,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
function getInstructions()
|
||||
public function getInstructions()
|
||||
{
|
||||
// TRANS: Form instructions for the site license admin panel.
|
||||
return _('License for this StatusNet site');
|
||||
@@ -70,7 +64,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showForm()
|
||||
public function showForm()
|
||||
{
|
||||
$form = new LicenseAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -82,7 +76,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function saveSettings()
|
||||
public function saveSettings()
|
||||
{
|
||||
static $settings = array(
|
||||
'license' => array('type', 'owner', 'url', 'title', 'image')
|
||||
@@ -104,7 +98,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('BEGIN');
|
||||
$config->query('START TRANSACTION');
|
||||
|
||||
foreach ($settings as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -124,7 +118,7 @@ class LicenseadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function validate(&$values)
|
||||
public function validate(&$values)
|
||||
{
|
||||
// Validate license type (shouldn't have to do it, but just in case)
|
||||
|
||||
@@ -195,7 +189,7 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
function id()
|
||||
public function id()
|
||||
{
|
||||
return 'licenseadminpanel';
|
||||
}
|
||||
@@ -205,7 +199,7 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
function formClass()
|
||||
public function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -216,7 +210,7 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
public function action()
|
||||
{
|
||||
return common_local_url('licenseadminpanel');
|
||||
}
|
||||
@@ -227,10 +221,11 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
public function formData()
|
||||
{
|
||||
$this->out->elementStart(
|
||||
'fieldset', array('id' => 'settings_license-selection')
|
||||
'fieldset',
|
||||
['id' => 'settings_license-selection']
|
||||
);
|
||||
// TRANS: Form legend in the license admin panel.
|
||||
$this->out->element('legend', null, _('License selection'));
|
||||
@@ -307,7 +302,8 @@ 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'
|
||||
@@ -323,12 +319,12 @@ class LicenseAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formActions()
|
||||
public 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.
|
||||
|
||||
@@ -1,49 +1,45 @@
|
||||
<?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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @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/
|
||||
* @copyright 2013 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Add a new application
|
||||
*
|
||||
* This is the form for adding a new application
|
||||
*
|
||||
* @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/
|
||||
* @category Application
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class NewApplicationAction extends SettingsAction
|
||||
{
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: This is the title of the form for adding a new application.
|
||||
return _('New application');
|
||||
@@ -87,7 +83,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.'));
|
||||
} else if ($this->nameExists($name)) {
|
||||
} elseif ($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) {
|
||||
@@ -103,7 +99,8 @@ 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.'));
|
||||
@@ -135,7 +132,7 @@ class NewApplicationAction extends SettingsAction
|
||||
|
||||
$app = new Oauth_application();
|
||||
|
||||
$app->query('BEGIN');
|
||||
$app->query('START TRANSACTION');
|
||||
|
||||
$app->name = $name;
|
||||
$app->owner = $this->scoped->getID();
|
||||
@@ -205,7 +202,7 @@ class NewApplicationAction extends SettingsAction
|
||||
*
|
||||
* @return boolean true if the name already exists
|
||||
*/
|
||||
function nameExists($name)
|
||||
public function nameExists($name)
|
||||
{
|
||||
$app = Oauth_application::getKV('name', $name);
|
||||
return !empty($app);
|
||||
|
||||
@@ -1,42 +1,38 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Show a user's registered OAuth applications
|
||||
*
|
||||
* @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/
|
||||
* @category Settings
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see SettingsAction
|
||||
*/
|
||||
@@ -56,7 +52,7 @@ class OauthappssettingsAction extends SettingsAction
|
||||
* @return string Title of the page
|
||||
*/
|
||||
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Page title for OAuth applications
|
||||
return _('OAuth applications');
|
||||
@@ -68,20 +64,20 @@ class OauthappssettingsAction extends SettingsAction
|
||||
* @return instructions for use
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
public function getInstructions()
|
||||
{
|
||||
// TRANS: Page instructions for OAuth applications
|
||||
return _('Applications you have registered');
|
||||
}
|
||||
|
||||
function showContent()
|
||||
public 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();
|
||||
@@ -96,13 +92,16 @@ class OauthappssettingsAction extends SettingsAction
|
||||
}
|
||||
}
|
||||
|
||||
$this->elementStart('p', array('id' => 'application_register'));
|
||||
$this->element('a',
|
||||
array('href' => common_local_url('newapplication'),
|
||||
'class' => 'more'
|
||||
),
|
||||
$this->elementStart('p', ['id' => 'application_register']);
|
||||
$this->element(
|
||||
'a',
|
||||
[
|
||||
'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(
|
||||
@@ -113,7 +112,7 @@ class OauthappssettingsAction extends SettingsAction
|
||||
);
|
||||
}
|
||||
|
||||
function showEmptyListMessage()
|
||||
public function showEmptyListMessage()
|
||||
{
|
||||
// TRANS: Empty list message on page with OAuth applications. Markup allowed
|
||||
$message = sprintf(_('You have not registered any applications yet.'));
|
||||
|
||||
+217
-172
@@ -1,48 +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
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Paths settings
|
||||
*
|
||||
* @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/
|
||||
* @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
|
||||
*/
|
||||
class PathsadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -52,7 +46,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
* @return string page title
|
||||
*/
|
||||
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title for Paths admin panel.
|
||||
return _('Paths');
|
||||
@@ -63,7 +57,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
function getInstructions()
|
||||
public function getInstructions()
|
||||
{
|
||||
// TRANS: Form instructions for Path admin panel.
|
||||
return _('Path and server settings for this StatusNet site');
|
||||
@@ -74,7 +68,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showForm()
|
||||
public function showForm()
|
||||
{
|
||||
$form = new PathsAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -86,14 +80,14 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function saveSettings()
|
||||
public function saveSettings()
|
||||
{
|
||||
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')
|
||||
);
|
||||
static $settings = [
|
||||
'site' => ['path', 'locale_path', 'ssl', 'sslserver'],
|
||||
'theme' => ['server', 'dir', 'path', 'sslserver', 'sslpath'],
|
||||
'avatar' => ['server', 'dir', 'path'],
|
||||
'attachments' => ['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
|
||||
@@ -120,7 +114,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('BEGIN');
|
||||
$config->query('START TRANSACTION');
|
||||
|
||||
foreach ($settings as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -144,7 +138,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function validate(&$values)
|
||||
public function validate(&$values)
|
||||
{
|
||||
// Validate theme dir
|
||||
|
||||
@@ -189,7 +183,7 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
function id()
|
||||
public function id()
|
||||
{
|
||||
return 'form_paths_admin_panel';
|
||||
}
|
||||
@@ -199,7 +193,7 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
function formClass()
|
||||
public function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -209,7 +203,7 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
function action()
|
||||
public function action()
|
||||
{
|
||||
return common_local_url('pathsadminpanel');
|
||||
}
|
||||
@@ -219,7 +213,7 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formData()
|
||||
public function formData()
|
||||
{
|
||||
$this->out->elementStart('fieldset', array('id' => 'settings_paths_locale'));
|
||||
// TRANS: Fieldset legend in Paths admin panel.
|
||||
@@ -227,37 +221,45 @@ 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');
|
||||
@@ -265,145 +267,176 @@ 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', array('id' => 'settings_avatar-paths'));
|
||||
$this->out->elementStart(
|
||||
'fieldset',
|
||||
['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', array('id' =>
|
||||
'settings_attachments-paths'));
|
||||
$this->out->elementStart(
|
||||
'fieldset',
|
||||
['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');
|
||||
@@ -411,31 +444,38 @@ 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 = array('never' => _('Never'),
|
||||
// TRANS: Drop down option in Paths admin panel (option for "When to use SSL").
|
||||
'always' => _('Always'));
|
||||
$ssl = [
|
||||
'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');
|
||||
@@ -446,12 +486,17 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formActions()
|
||||
public 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.')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -467,7 +512,7 @@ class PathsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function input($setting, $title, $instructions, $section='site')
|
||||
public function input($setting, $title, $instructions, $section='site')
|
||||
{
|
||||
$this->out->input("$section-$setting", $title, $this->value($setting, $section), $instructions);
|
||||
}
|
||||
|
||||
+45
-41
@@ -1,39 +1,32 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Lists by a user
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Personal
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Shashi Gowda <connect2shashi@gmail.com>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once INSTALLDIR . '/lib/profile/peopletaglist.php';
|
||||
// cache 3 pages
|
||||
@@ -41,15 +34,15 @@ define('PEOPLETAG_CACHE_WINDOW', PEOPLETAGS_PER_PAGE*3 + 1);
|
||||
|
||||
class PeopletagAction extends Action
|
||||
{
|
||||
var $page = null;
|
||||
var $tag = null;
|
||||
public $page = null;
|
||||
public $tag = null;
|
||||
|
||||
function isReadOnly($args)
|
||||
public function isReadOnly($args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
// TRANS: Title for list page.
|
||||
@@ -62,7 +55,7 @@ class PeopletagAction extends Action
|
||||
}
|
||||
}
|
||||
|
||||
function prepare(array $args = array())
|
||||
public function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
@@ -84,19 +77,19 @@ class PeopletagAction extends Action
|
||||
return true;
|
||||
}
|
||||
|
||||
function handle()
|
||||
public function handle()
|
||||
{
|
||||
parent::handle();
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
function showLocalNav()
|
||||
public function showLocalNav()
|
||||
{
|
||||
$nav = new PublicGroupNav($this);
|
||||
$nav->show();
|
||||
}
|
||||
|
||||
function showAnonymousMessage()
|
||||
public function showAnonymousMessage()
|
||||
{
|
||||
$notice =
|
||||
// TRANS: Message for anonymous users on list page.
|
||||
@@ -106,13 +99,13 @@ class PeopletagAction extends Action
|
||||
'(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
|
||||
'You can then easily keep track of what they ' .
|
||||
'are doing by subscribing to the list\'s timeline.' );
|
||||
"are doing by subscribing to the list's timeline.");
|
||||
$this->elementStart('div', array('id' => 'anon_notice'));
|
||||
$this->raw(common_markup_to_html($notice));
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
$offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
|
||||
$limit = PEOPLETAGS_PER_PAGE + 1;
|
||||
@@ -143,9 +136,15 @@ class PeopletagAction extends Action
|
||||
$ptags->find();
|
||||
}
|
||||
} else {
|
||||
$ptags->whereAdd('(profile_list.private = false OR (' .
|
||||
' profile_list.tagger =' . $user->id .
|
||||
' AND profile_list.private = true) )');
|
||||
$ptags->whereAdd(sprintf(
|
||||
<<<'END'
|
||||
(
|
||||
(profile_list.tagger = %d AND profile_list.private IS TRUE)
|
||||
OR profile_list.private IS NOT TRUE
|
||||
)
|
||||
END,
|
||||
$user->getID()
|
||||
));
|
||||
|
||||
$ptags->orderBy('profile_list.modified DESC');
|
||||
$ptags->find();
|
||||
@@ -154,11 +153,16 @@ class PeopletagAction extends Action
|
||||
$pl = new PeopletagList($ptags, $this);
|
||||
$cnt = $pl->show();
|
||||
|
||||
$this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
|
||||
$this->page, 'peopletag', array('tag' => $this->tag));
|
||||
$this->pagination(
|
||||
($this->page > 1),
|
||||
($cnt > PEOPLETAGS_PER_PAGE),
|
||||
$this->page,
|
||||
'peopletag',
|
||||
['tag' => $this->tag]
|
||||
);
|
||||
}
|
||||
|
||||
function showSections()
|
||||
public function showSections()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ class ProfilesettingsAction extends SettingsAction
|
||||
}
|
||||
|
||||
$user = $this->scoped->getUser();
|
||||
$user->query('BEGIN');
|
||||
$user->query('START TRANSACTION');
|
||||
|
||||
// Only allow setting private_stream if site policy allows it
|
||||
// (or user already _has_ a private stream, then you can unset it)
|
||||
|
||||
+25
-21
@@ -92,31 +92,35 @@ class SelftagAction extends Action
|
||||
{
|
||||
$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;
|
||||
|
||||
// XXX: memcached this
|
||||
$profile->limit($offset, $limit);
|
||||
|
||||
$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 ' .
|
||||
'LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||
|
||||
$profile->query(sprintf($qry, $this->tag));
|
||||
$profile->find();
|
||||
|
||||
$ptl = new SelfTagProfileList($profile, $this); // pass the ammunition
|
||||
$cnt = $ptl->show();
|
||||
|
||||
@@ -1,44 +1,38 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Admin site sessions
|
||||
*
|
||||
* @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/
|
||||
* @category Admin
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class SessionsadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -47,10 +41,10 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title for the sessions administration panel.
|
||||
return _m('TITLE','Sessions');
|
||||
return _m('TITLE', 'Sessions');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +52,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
function getInstructions()
|
||||
public function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for the sessions administration panel.
|
||||
return _('Session settings for this StatusNet site');
|
||||
@@ -69,7 +63,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showForm()
|
||||
public function showForm()
|
||||
{
|
||||
$form = new SessionsAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -81,7 +75,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function saveSettings()
|
||||
public function saveSettings()
|
||||
{
|
||||
static $booleans = array('sessions' => array('handle', 'debug'));
|
||||
|
||||
@@ -101,7 +95,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('BEGIN');
|
||||
$config->query('START TRANSACTION');
|
||||
|
||||
foreach ($booleans as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -114,7 +108,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
return;
|
||||
}
|
||||
|
||||
function validate(&$values)
|
||||
public function validate(&$values)
|
||||
{
|
||||
// stub
|
||||
}
|
||||
@@ -128,7 +122,7 @@ class SessionsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
function id()
|
||||
public function id()
|
||||
{
|
||||
return 'sessionsadminpanel';
|
||||
}
|
||||
@@ -138,7 +132,7 @@ class SessionsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
function formClass()
|
||||
public function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -148,7 +142,7 @@ class SessionsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
function action()
|
||||
public function action()
|
||||
{
|
||||
return common_local_url('sessionsadminpanel');
|
||||
}
|
||||
@@ -158,31 +152,37 @@ class SessionsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formData()
|
||||
public 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,14 +195,16 @@ class SessionsAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formActions()
|
||||
public 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')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+128
-87
@@ -1,60 +1,54 @@
|
||||
<?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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Show an OAuth application
|
||||
*
|
||||
* @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/
|
||||
* @category Application
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class ShowApplicationAction extends Action
|
||||
{
|
||||
/**
|
||||
* Application to show
|
||||
*/
|
||||
var $application = null;
|
||||
public $application = null;
|
||||
|
||||
/**
|
||||
* User who owns the app
|
||||
*/
|
||||
var $owner = null;
|
||||
public $owner = null;
|
||||
|
||||
var $msg = null;
|
||||
public $msg = null;
|
||||
|
||||
var $success = null;
|
||||
public $success = null;
|
||||
|
||||
/**
|
||||
* Load attributes based on database arguments
|
||||
@@ -65,7 +59,7 @@ class ShowApplicationAction extends Action
|
||||
*
|
||||
* @return success flag
|
||||
*/
|
||||
function prepare(array $args = array())
|
||||
public function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
@@ -101,7 +95,7 @@ class ShowApplicationAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle()
|
||||
public function handle()
|
||||
{
|
||||
parent::handle();
|
||||
|
||||
@@ -127,21 +121,21 @@ class ShowApplicationAction extends Action
|
||||
*
|
||||
* @return string title of the page
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
if (!empty($this->application->name)) {
|
||||
return 'Application: ' . $this->application->name;
|
||||
}
|
||||
}
|
||||
|
||||
function showPageNotice()
|
||||
public function showPageNotice()
|
||||
{
|
||||
if (!empty($this->msg)) {
|
||||
$this->element('div', ($this->success) ? 'success' : 'error', $this->msg);
|
||||
}
|
||||
}
|
||||
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
$cur = common_current_user();
|
||||
|
||||
@@ -151,21 +145,38 @@ 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', array('src' => $this->application->icon,
|
||||
'class' => 'u-photo logo entity_depiction'));
|
||||
$this->element(
|
||||
'img',
|
||||
[
|
||||
'src' => $this->application->icon,
|
||||
'class' => 'u-photo logo entity_depiction',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$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->source_url,
|
||||
'class' => 'u-url p-name entity_fn',
|
||||
],
|
||||
$this->application->name
|
||||
);
|
||||
|
||||
$this->element('a', array('href' => $this->application->homepage,
|
||||
'class' => 'u-url entity_org'),
|
||||
$this->application->organization);
|
||||
$this->element(
|
||||
'a',
|
||||
[
|
||||
'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)
|
||||
@@ -183,10 +194,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');
|
||||
@@ -196,47 +207,70 @@ class ShowApplicationAction extends Action
|
||||
$this->element('h2', null, _('Application actions'));
|
||||
$this->elementStart('ul');
|
||||
$this->elementStart('li', 'entity_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->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->elementEnd('li');
|
||||
|
||||
$this->elementStart('li', 'entity_reset_keysecret');
|
||||
$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(
|
||||
'form',
|
||||
[
|
||||
'id' => 'form_reset_key',
|
||||
'class' => 'form_reset_key',
|
||||
'method' => 'POST',
|
||||
'action' => common_local_url(
|
||||
'showapplication',
|
||||
['id' => $this->application->id]
|
||||
),
|
||||
]
|
||||
);
|
||||
$this->elementStart('fieldset');
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
$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->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->elementEnd('fieldset');
|
||||
$this->elementEnd('form');
|
||||
$this->elementEnd('li');
|
||||
|
||||
$this->elementStart('li', 'entity_delete');
|
||||
$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(
|
||||
'form',
|
||||
[
|
||||
'id' => 'form_delete_application',
|
||||
'class' => 'form_delete_application',
|
||||
'method' => 'POST',
|
||||
'action' => common_local_url(
|
||||
'deleteapplication',
|
||||
['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');
|
||||
@@ -266,16 +300,23 @@ 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',
|
||||
array('href' => common_local_url('oauthappssettings'),
|
||||
'class' => 'more'),
|
||||
'View your applications');
|
||||
$this->element(
|
||||
'a',
|
||||
[
|
||||
'href' => common_local_url('oauthappssettings'),
|
||||
'class' => 'more',
|
||||
],
|
||||
'View your applications'
|
||||
);
|
||||
$this->elementEnd('p');
|
||||
}
|
||||
|
||||
@@ -284,7 +325,7 @@ class ShowApplicationAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showScripts()
|
||||
public function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
|
||||
@@ -305,9 +346,9 @@ class ShowApplicationAction extends Action
|
||||
* XXX: Should this be moved to its own page with a confirm?
|
||||
*
|
||||
*/
|
||||
function resetKey()
|
||||
public function resetKey()
|
||||
{
|
||||
$this->application->query('BEGIN');
|
||||
$this->application->query('START TRANSACTION');
|
||||
|
||||
$oauser = new Oauth_application_user();
|
||||
$oauser->application_id = $this->application->id;
|
||||
|
||||
+193
-118
@@ -1,34 +1,31 @@
|
||||
<?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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@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/
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* User profile page
|
||||
@@ -39,11 +36,10 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
* It shows a stream of the user's posts, plus lots of profile info, links
|
||||
* to subscriptions and stuff, etc.
|
||||
*
|
||||
* @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/
|
||||
* @category Personal
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class ShowstreamAction extends NoticestreamAction
|
||||
{
|
||||
@@ -58,7 +54,7 @@ class ShowstreamAction extends NoticestreamAction
|
||||
return $stream;
|
||||
}
|
||||
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
$base = $this->target->getFancyName();
|
||||
if (!empty($this->tag)) {
|
||||
@@ -77,9 +73,11 @@ 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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,79 +87,120 @@ class ShowstreamAction extends NoticestreamAction
|
||||
$this->showNotices();
|
||||
}
|
||||
|
||||
function showProfileBlock()
|
||||
public function showProfileBlock()
|
||||
{
|
||||
$block = new AccountProfileBlock($this, $this->target);
|
||||
$block->show();
|
||||
}
|
||||
|
||||
function showPageNoticeBlock()
|
||||
public function showPageNoticeBlock()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
function getFeeds()
|
||||
public function getFeeds()
|
||||
{
|
||||
if (!empty($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)));
|
||||
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
|
||||
)
|
||||
)];
|
||||
}
|
||||
|
||||
if (!$this->target->isLocal()) {
|
||||
// remote profiles at least have Atom, but we can't guarantee anything else
|
||||
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::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::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())));
|
||||
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())
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
public function extraHeaders()
|
||||
@@ -170,33 +209,60 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function extraHead()
|
||||
public function extraHead()
|
||||
{
|
||||
if ($this->target->bio) {
|
||||
$this->element('meta', array('name' => 'description',
|
||||
'content' => $this->target->getDescription()));
|
||||
if ($this->target->isSilenced() || !$this->target->isLocal()) {
|
||||
$this->element(
|
||||
'meta',
|
||||
[
|
||||
'name' => 'robots',
|
||||
'content' => 'noindex',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$rsd = common_local_url('rsd',
|
||||
array('nickname' => $this->target->getNickname()));
|
||||
if ($this->target->bio) {
|
||||
$this->element(
|
||||
'meta',
|
||||
[
|
||||
'name' => 'description',
|
||||
'content' => $this->target->getDescription(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$rsd = common_local_url(
|
||||
'rsd',
|
||||
['nickname' => $this->target->getNickname()]
|
||||
);
|
||||
|
||||
// RSD, http://tales.phrasewise.com/rfc/rsd
|
||||
$this->element('link', array('rel' => 'EditURI',
|
||||
'type' => 'application/rsd+xml',
|
||||
'href' => $rsd));
|
||||
$this->element(
|
||||
'link',
|
||||
[
|
||||
'rel' => 'EditURI',
|
||||
'type' => 'application/rsd+xml',
|
||||
'href' => $rsd,
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->page != 1) {
|
||||
$this->element('link', array('rel' => 'canonical',
|
||||
'href' => $this->target->getUrl()));
|
||||
$this->element(
|
||||
'link',
|
||||
[
|
||||
'rel' => 'canonical',
|
||||
'href' => $this->target->getUrl(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function showEmptyListMessage()
|
||||
public 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()) . ' ';
|
||||
@@ -210,8 +276,7 @@ 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());
|
||||
@@ -222,7 +287,7 @@ class ShowstreamAction extends NoticestreamAction
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
function showNotices()
|
||||
public function showNotices()
|
||||
{
|
||||
$pnl = new PrimaryNoticeList($this->notice, $this);
|
||||
$cnt = $pnl->show();
|
||||
@@ -232,41 +297,51 @@ 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
|
||||
);
|
||||
}
|
||||
|
||||
function showAnonymousMessage()
|
||||
public 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');
|
||||
}
|
||||
|
||||
function noticeFormOptions()
|
||||
public 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;
|
||||
|
||||
+120
-96
@@ -1,48 +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 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Administer site settings
|
||||
*
|
||||
* @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/
|
||||
* @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
|
||||
*/
|
||||
class SiteadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -51,10 +45,10 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title for site administration panel.
|
||||
return _m('TITLE','Site');
|
||||
return _m('TITLE', 'Site');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +56,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
function getInstructions()
|
||||
public function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for site administration panel.
|
||||
return _m('Basic settings for this StatusNet site');
|
||||
@@ -73,7 +67,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showForm()
|
||||
public function showForm()
|
||||
{
|
||||
$form = new SiteAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -85,7 +79,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function saveSettings()
|
||||
public function saveSettings()
|
||||
{
|
||||
static $settings = array(
|
||||
'site' => array(
|
||||
@@ -119,7 +113,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('BEGIN');
|
||||
$config->query('START TRANSACTION');
|
||||
|
||||
foreach ($settings as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -132,7 +126,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
||||
return;
|
||||
}
|
||||
|
||||
function validate(&$values)
|
||||
public function validate(&$values)
|
||||
{
|
||||
// Validate site name
|
||||
|
||||
@@ -208,7 +202,7 @@ class SiteAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
function id()
|
||||
public function id()
|
||||
{
|
||||
return 'form_site_admin_panel';
|
||||
}
|
||||
@@ -218,7 +212,7 @@ class SiteAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
function formClass()
|
||||
public function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -228,7 +222,7 @@ class SiteAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
function action()
|
||||
public function action()
|
||||
{
|
||||
return common_local_url('siteadminpanel');
|
||||
}
|
||||
@@ -238,37 +232,49 @@ class SiteAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formData()
|
||||
public 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');
|
||||
@@ -277,7 +283,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 = [];
|
||||
|
||||
@@ -289,20 +295,28 @@ 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');
|
||||
@@ -310,28 +324,32 @@ 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');
|
||||
}
|
||||
|
||||
function showLogo()
|
||||
public function showLogo()
|
||||
{
|
||||
$this->out->elementStart('fieldset', ['id' => 'settings_site_logo']);
|
||||
// TRANS: Fieldset legend for form to change logo.
|
||||
@@ -340,19 +358,23 @@ 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');
|
||||
@@ -365,14 +387,16 @@ class SiteAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formActions()
|
||||
public 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.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ defined('GNUSOCIAL') || die();
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see SettingsAction
|
||||
* @see SettingsAction
|
||||
*/
|
||||
class SmssettingsAction extends SettingsAction
|
||||
{
|
||||
@@ -98,7 +98,7 @@ class SmssettingsAction extends SettingsAction
|
||||
$this->element('legend', null, _('SMS address'));
|
||||
$this->hidden('token', common_session_token());
|
||||
|
||||
if ($user->sms) {
|
||||
if (!$user->isNull('sms')) {
|
||||
$carrier = $user->getCarrier();
|
||||
$this->element(
|
||||
'p',
|
||||
@@ -170,13 +170,13 @@ class SmssettingsAction extends SettingsAction
|
||||
}
|
||||
$this->elementEnd('fieldset');
|
||||
|
||||
if ($user->sms) {
|
||||
if (!$user->isNull('sms')) {
|
||||
$this->elementStart('fieldset', ['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->incomingemail) {
|
||||
if (!$user->isNull('incomingemail')) {
|
||||
$this->element('p', 'form_unconfirmed', $user->incomingemail);
|
||||
$this->element(
|
||||
'p',
|
||||
@@ -279,7 +279,7 @@ class SmssettingsAction extends SettingsAction
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
$user->query('BEGIN');
|
||||
$user->query('START TRANSACTION');
|
||||
|
||||
$original = clone($user);
|
||||
|
||||
@@ -417,9 +417,9 @@ class SmssettingsAction extends SettingsAction
|
||||
|
||||
$original = clone($user);
|
||||
|
||||
$user->sms = DB_DataObject_Cast::sql('NULL');
|
||||
$user->carrier = DB_DataObject_Cast::sql('NULL');
|
||||
$user->smsemail = DB_DataObject_Cast::sql('NULL');
|
||||
$user->sms = $user->sqlValue('NULL');
|
||||
$user->carrier = $user->sqlValue('NULL');
|
||||
$user->smsemail = $user->sqlValue('NULL');
|
||||
|
||||
// Throws exception on failure. Also performs it within a transaction.
|
||||
$user->updateWithKeys($original);
|
||||
@@ -531,7 +531,7 @@ class SmssettingsAction extends SettingsAction
|
||||
|
||||
$orig = clone($user);
|
||||
|
||||
$user->incomingemail = DB_DataObject_Cast::sql('NULL');
|
||||
$user->incomingemail = $user->sqlValue('NULL');
|
||||
|
||||
// Throws exception on failure. Also performs it within a transaction.
|
||||
$user->updateWithKeys($orig);
|
||||
|
||||
+9
-9
@@ -65,17 +65,17 @@ class SupAction extends Action
|
||||
|
||||
$divider = common_sql_date(time() - $seconds);
|
||||
|
||||
$notice->query('SELECT profile_id, max(id) AS max_id ' .
|
||||
'FROM ( ' .
|
||||
'SELECT profile_id, id FROM notice ' .
|
||||
"WHERE created > TIMESTAMP '" . $divider . "' " .
|
||||
') AS latest ' .
|
||||
'GROUP BY profile_id');
|
||||
$notice->selectAdd();
|
||||
$notice->selectAdd('profile_id, MAX(id) AS max_id');
|
||||
$notice->whereAdd("created > TIMESTAMP '{$divider}'");
|
||||
$notice->groupBy('profile_id');
|
||||
|
||||
$updates = array();
|
||||
$updates = [];
|
||||
|
||||
while ($notice->fetch()) {
|
||||
$updates[] = array($notice->profile_id, $notice->max_id);
|
||||
if ($notice->find()) {
|
||||
while ($notice->fetch()) {
|
||||
$updates[] = [$notice->profile_id, $notice->max_id];
|
||||
}
|
||||
}
|
||||
|
||||
return $updates;
|
||||
|
||||
+55
-53
@@ -1,46 +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
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Miscellaneous settings actions
|
||||
*
|
||||
* Currently this just manages URL shortening.
|
||||
*
|
||||
* @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/
|
||||
* @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
|
||||
*/
|
||||
class UrlsettingsAction extends SettingsAction
|
||||
{
|
||||
@@ -49,7 +45,7 @@ class UrlsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return string Title of the page
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: Title of URL settings tab in profile settings.
|
||||
return _('URL settings');
|
||||
@@ -60,13 +56,13 @@ class UrlsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return instructions for use
|
||||
*/
|
||||
function getInstructions()
|
||||
public function getInstructions()
|
||||
{
|
||||
// TRANS: Instructions for tab "Other" in user profile settings.
|
||||
return _('Manage various other options.');
|
||||
}
|
||||
|
||||
function showScripts()
|
||||
public function showScripts()
|
||||
{
|
||||
parent::showScripts();
|
||||
$this->autofocus('urlshorteningservice');
|
||||
@@ -79,7 +75,7 @@ class UrlsettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
@@ -98,8 +94,7 @@ 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
|
||||
@@ -121,33 +116,40 @@ 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'),
|
||||
(!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->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->elementEnd('li');
|
||||
$this->elementStart('li');
|
||||
$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->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->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');
|
||||
}
|
||||
@@ -177,7 +179,7 @@ class UrlsettingsAction extends SettingsAction
|
||||
|
||||
$user = $this->scoped->getUser();
|
||||
|
||||
$user->query('BEGIN');
|
||||
$user->query('START TRANSACTION');
|
||||
|
||||
$original = clone($user);
|
||||
|
||||
|
||||
@@ -1,49 +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
|
||||
*
|
||||
* 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 StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2008-2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Administer user settings
|
||||
*
|
||||
* @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/
|
||||
* @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
|
||||
*/
|
||||
class UseradminpanelAction extends AdminPanelAction
|
||||
{
|
||||
@@ -52,7 +45,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
// TRANS: User admin panel title.
|
||||
return _m('TITLE', 'User');
|
||||
@@ -63,7 +56,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
function getInstructions()
|
||||
public function getInstructions()
|
||||
{
|
||||
// TRANS: Instruction for user admin panel.
|
||||
return _('User settings for this StatusNet site');
|
||||
@@ -74,7 +67,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showForm()
|
||||
public function showForm()
|
||||
{
|
||||
$form = new UserAdminPanelForm($this);
|
||||
$form->show();
|
||||
@@ -86,7 +79,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function saveSettings()
|
||||
public function saveSettings()
|
||||
{
|
||||
static $settings = array(
|
||||
'profile' => array('biolimit'),
|
||||
@@ -119,7 +112,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('BEGIN');
|
||||
$config->query('START TRANSACTION');
|
||||
|
||||
foreach ($settings as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
@@ -138,7 +131,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
return;
|
||||
}
|
||||
|
||||
function validate(&$values)
|
||||
public function validate(&$values)
|
||||
{
|
||||
// Validate biolimit
|
||||
|
||||
@@ -180,7 +173,7 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
function id()
|
||||
public function id()
|
||||
{
|
||||
return 'useradminpanel';
|
||||
}
|
||||
@@ -190,7 +183,7 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
function formClass()
|
||||
public function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
@@ -200,7 +193,7 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
function action()
|
||||
public function action()
|
||||
{
|
||||
return common_local_url('useradminpanel');
|
||||
}
|
||||
@@ -210,19 +203,22 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formData()
|
||||
public 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');
|
||||
@@ -235,18 +231,24 @@ 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');
|
||||
@@ -261,10 +263,13 @@ 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');
|
||||
@@ -283,7 +288,7 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function input($setting, $title, $instructions, $section='site')
|
||||
public function input($setting, $title, $instructions, $section='site')
|
||||
{
|
||||
$this->out->input("$section-$setting", $title, $this->value($setting, $section), $instructions);
|
||||
}
|
||||
@@ -293,14 +298,16 @@ class UserAdminPanelForm extends AdminForm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function formActions()
|
||||
public 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.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+33
-35
@@ -1,44 +1,40 @@
|
||||
<?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.
|
||||
*
|
||||
* 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/>.
|
||||
* @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
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* User by ID action class.
|
||||
*
|
||||
* @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/
|
||||
* @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
|
||||
*/
|
||||
class UserbyidAction extends ShowstreamAction
|
||||
{
|
||||
@@ -56,10 +52,12 @@ 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, array('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, ['nickname' => $this->target->getNickname()]);
|
||||
common_redirect($url, 303);
|
||||
}
|
||||
}
|
||||
|
||||
+27
-20
@@ -1,30 +1,38 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* GNU social - a federating social network
|
||||
* Copyright (C) 2014, Free Software Foundation, Inc.
|
||||
* Data class for Attentions
|
||||
*
|
||||
* 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
|
||||
* @copyright 2014 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
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) 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 $reason; // varchar(191)
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -34,8 +42,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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('notice_id', 'profile_id'),
|
||||
'foreign keys' => array(
|
||||
@@ -43,7 +51,6 @@ 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'),
|
||||
),
|
||||
);
|
||||
|
||||
+11
-9
@@ -29,8 +29,8 @@ class Avatar extends Managed_DataObject
|
||||
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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -42,8 +42,8 @@ class Avatar extends Managed_DataObject
|
||||
'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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('profile_id', 'width', 'height'),
|
||||
'unique keys' => array(
|
||||
@@ -52,9 +52,6 @@ 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'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -164,8 +161,13 @@ 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($id, $extension, $size = null, $extra = null)
|
||||
public static function filename(int $id, string $extension, ?int $size = null, ?string $extra = null)
|
||||
{
|
||||
if ($size) {
|
||||
return $id . '-' . $size . (($extra) ? ('-' . $extra) : '') . $extension;
|
||||
@@ -187,7 +189,7 @@ class Avatar extends Managed_DataObject
|
||||
|
||||
public static function url($filename)
|
||||
{
|
||||
$path = common_config('avatar', 'path');
|
||||
$path = common_config('avatar', 'url_base');
|
||||
|
||||
if ($path[strlen($path)-1] != '/') {
|
||||
$path .= '/';
|
||||
|
||||
@@ -1,41 +1,61 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* 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(4) not_null
|
||||
public $user_id; // int()
|
||||
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; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() 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', 'default' => 0, 'description' => 'user who requested confirmation'),
|
||||
'user_id' => array('type' => 'int', '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' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, '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'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static function getByAddress($address, $addressType)
|
||||
public static function getByAddress($address, $addressType)
|
||||
{
|
||||
$ca = new Confirm_address();
|
||||
|
||||
@@ -49,7 +69,7 @@ class Confirm_address extends Managed_DataObject
|
||||
return $ca;
|
||||
}
|
||||
|
||||
static function saveNew($user, $address, $addressType, $extra=null)
|
||||
public static function saveNew($user, $address, $addressType, $extra = null)
|
||||
{
|
||||
$ca = new Confirm_address();
|
||||
|
||||
@@ -99,16 +119,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=array())
|
||||
public function sendConfirmation(array $args = [])
|
||||
{
|
||||
common_debug('Sending confirmation URL for user '._ve($this->user_id).' using '._ve($this->address_type));
|
||||
|
||||
$defaults = [
|
||||
'headers' => array(),
|
||||
'nickname' => $this->getProfile()->getNickname(),
|
||||
'sitename' => common_config('site', 'name'),
|
||||
'url' => $this->getUrl(),
|
||||
];
|
||||
'headers' => [],
|
||||
'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];
|
||||
@@ -124,7 +144,7 @@ class Confirm_address extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public function sendEmailConfirmation(array $args=array())
|
||||
public function sendEmailConfirmation(array $args = [])
|
||||
{
|
||||
// TRANS: Subject for address confirmation email.
|
||||
$subject = _('Email address confirmation');
|
||||
@@ -132,21 +152,23 @@ 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';
|
||||
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);
|
||||
|
||||
|
||||
+27
-11
@@ -1,8 +1,24 @@
|
||||
<?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
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Consumer extends Managed_DataObject
|
||||
{
|
||||
@@ -13,8 +29,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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -27,14 +43,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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('consumer_key'),
|
||||
);
|
||||
}
|
||||
|
||||
static function generateNew()
|
||||
public static function generateNew()
|
||||
{
|
||||
$cons = new Consumer();
|
||||
$rand = common_random_hexstr(16);
|
||||
@@ -53,24 +69,24 @@ class Consumer extends Managed_DataObject
|
||||
* XXX: Should this happen in an OAuthDataStore instead?
|
||||
*
|
||||
*/
|
||||
function delete($useWhere=false)
|
||||
public 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);
|
||||
}
|
||||
|
||||
function _deleteTokens()
|
||||
private function deleteTokens()
|
||||
{
|
||||
$token = new Token();
|
||||
$token->consumer_key = $this->consumer_key;
|
||||
$token->delete();
|
||||
}
|
||||
|
||||
function _deleteNonces()
|
||||
private function deleteNonces()
|
||||
{
|
||||
$nonce = new Nonce();
|
||||
$nonce->consumer_key = $this->consumer_key;
|
||||
|
||||
@@ -34,8 +34,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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -44,8 +44,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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
@@ -106,7 +106,7 @@ class Conversation extends Managed_DataObject
|
||||
common_random_hexstr(8)
|
||||
);
|
||||
// locally generated Conversation objects don't get static URLs stored
|
||||
$conv->url = DB_DataObject_Cast::sql('NULL');
|
||||
$conv->url = $conv->sqlValue('NULL');
|
||||
}
|
||||
// This insert throws exceptions on failure
|
||||
$conv->insert();
|
||||
|
||||
+41
-27
@@ -43,7 +43,7 @@ class File extends Managed_DataObject
|
||||
public $filename; // text()
|
||||
public $width; // int(4)
|
||||
public $height; // int(4)
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
const URLHASH_ALG = 'sha256';
|
||||
const FILEHASH_ALG = 'sha256';
|
||||
@@ -64,7 +64,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' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
@@ -283,7 +283,8 @@ class File extends Managed_DataObject
|
||||
)
|
||||
);
|
||||
}
|
||||
$query .= ' AND EXTRACT(month FROM file.modified) = EXTRACT(month FROM now()) AND EXTRACT(year FROM file.modified) = EXTRACT(year FROM now())';
|
||||
$query .= ' AND EXTRACT(MONTH FROM file.modified) = EXTRACT(MONTH FROM CURRENT_DATE)'
|
||||
. ' AND EXTRACT(YEAR FROM file.modified) = EXTRACT(YEAR FROM CURRENT_DATE)';
|
||||
$file->query($query);
|
||||
$file->fetch();
|
||||
$total = $file->total + $fileSize;
|
||||
@@ -341,7 +342,7 @@ class File extends Managed_DataObject
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @return string|bool Value from the 'extblacklist' array, in the config
|
||||
* @return null|string|bool Value from the 'extblacklist' array, in the config
|
||||
* @throws ServerException
|
||||
*/
|
||||
public static function getSafeExtension(string $filename)
|
||||
@@ -412,7 +413,7 @@ class File extends Managed_DataObject
|
||||
|
||||
/**
|
||||
* Validation for as-saved base filenames
|
||||
* @param $filename
|
||||
* @param mixed $filename
|
||||
* @return false|int
|
||||
*/
|
||||
public static function validFilename($filename)
|
||||
@@ -420,7 +421,12 @@ class File extends Managed_DataObject
|
||||
return preg_match('/^[A-Za-z0-9._-]+$/', $filename);
|
||||
}
|
||||
|
||||
public static function tryFilename($filename)
|
||||
/**
|
||||
* @param mixed $filename
|
||||
* @return string
|
||||
* @throws InvalidFilenameException
|
||||
*/
|
||||
public static function tryFilename($filename): string
|
||||
{
|
||||
if (!self::validFilename($filename)) {
|
||||
throw new InvalidFilenameException($filename);
|
||||
@@ -430,16 +436,22 @@ class File extends Managed_DataObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filename
|
||||
* Construct a path
|
||||
*
|
||||
* @param mixed $filename Will be tested by tryFilename
|
||||
* @param string|null $dir Attachments directory by default
|
||||
* @param bool $test_filename
|
||||
* @return string
|
||||
* @throws InvalidFilenameException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public static function path($filename)
|
||||
public static function path($filename, ?string $dir = null, bool $test_filename = true)
|
||||
{
|
||||
self::tryFilename($filename);
|
||||
if ($test_filename) {
|
||||
self::tryFilename($filename);
|
||||
}
|
||||
|
||||
$dir = common_config('attachments', 'dir');
|
||||
$dir = $dir ?? common_config('attachments', 'dir');
|
||||
|
||||
if (!in_array($dir[mb_strlen($dir)-1], ['/', '\\'])) {
|
||||
$dir .= DIRECTORY_SEPARATOR;
|
||||
@@ -748,9 +760,12 @@ 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(
|
||||
$sql,
|
||||
<<<'END'
|
||||
UPDATE %1$s
|
||||
SET urlhash = %2$s, url = %3$s, modified = CURRENT_TIMESTAMP
|
||||
WHERE urlhash = %4$s;
|
||||
END,
|
||||
$this->tableName(),
|
||||
$this->_quote((string)self::hashurl($url)),
|
||||
$this->_quote((string)$url),
|
||||
@@ -835,20 +850,19 @@ class File extends Managed_DataObject
|
||||
}
|
||||
|
||||
// Clear out related things in the database and filesystem, such as thumbnails
|
||||
if (Event::handle('FileDeleteRelated', array($this))) {
|
||||
$thumbs = new File_thumbnail();
|
||||
$thumbs->file_id = $this->id;
|
||||
if ($thumbs->find()) {
|
||||
while ($thumbs->fetch()) {
|
||||
$thumbs->delete();
|
||||
}
|
||||
}
|
||||
$related = [
|
||||
'File_redirection',
|
||||
'File_thumbnail',
|
||||
'File_to_post',
|
||||
];
|
||||
Event::handle('FileDeleteRelated', [$this, &$related]);
|
||||
|
||||
$f2p = new File_to_post();
|
||||
$f2p->file_id = $this->id;
|
||||
if ($f2p->find()) {
|
||||
while ($f2p->fetch()) {
|
||||
$f2p->delete();
|
||||
foreach ($related as $cls) {
|
||||
$inst = new $cls();
|
||||
$inst->file_id = $this->id;
|
||||
if ($inst->find()) {
|
||||
while ($inst->fetch()) {
|
||||
$inst->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -927,7 +941,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,
|
||||
@@ -961,7 +975,7 @@ class File extends Managed_DataObject
|
||||
throw new ServerException('Unknown DB type selected.');
|
||||
}
|
||||
$tablefix->query(sprintf(
|
||||
'UPDATE %1$s SET urlhash = %2$s;',
|
||||
'UPDATE %1$s SET urlhash = %2$s, modified = CURRENT_TIMESTAMP;',
|
||||
$tablefix->escapedTableName(),
|
||||
$url_sha256
|
||||
));
|
||||
|
||||
@@ -30,7 +30,7 @@ class File_redirection extends Managed_DataObject
|
||||
public $file_id; // int(4)
|
||||
public $redirections; // int(4)
|
||||
public $httpcode; // int(4)
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -46,12 +46,15 @@ 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' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, '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'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -468,7 +471,7 @@ class File_redirection extends Managed_DataObject
|
||||
throw new ServerException('Unknown DB type selected.');
|
||||
}
|
||||
$tablefix->query(sprintf(
|
||||
'UPDATE %1$s SET urlhash = %2$s;',
|
||||
'UPDATE %1$s SET urlhash = %2$s, modified = CURRENT_TIMESTAMP;',
|
||||
$tablefix->escapedTableName(),
|
||||
$url_sha256
|
||||
));
|
||||
|
||||
@@ -33,7 +33,7 @@ class File_thumbnail extends Managed_DataObject
|
||||
public $filename; // text
|
||||
public $width; // int(4) primary_key
|
||||
public $height; // int(4) primary_key
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
const URLHASH_ALG = 'sha256';
|
||||
|
||||
@@ -47,11 +47,10 @@ class File_thumbnail extends Managed_DataObject
|
||||
'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' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, '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(
|
||||
|
||||
+26
-26
@@ -1,28 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
* 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); }
|
||||
// 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 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; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() 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' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, '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_id_idx' => array('file_id'),
|
||||
'post_id_idx' => array('post_id'),
|
||||
'file_to_post_post_id_idx' => array('post_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static function processNew(File $file, Notice $notice) {
|
||||
public 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
|
||||
}
|
||||
}
|
||||
|
||||
static function getNoticeIDsByFile(File $file)
|
||||
public 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');
|
||||
}
|
||||
|
||||
function delete($useWhere=false)
|
||||
public function delete($useWhere = false)
|
||||
{
|
||||
try {
|
||||
$f = File::getByID($this->file_id);
|
||||
|
||||
+39
-21
@@ -1,8 +1,24 @@
|
||||
<?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
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Foreign_link extends Managed_DataObject
|
||||
{
|
||||
@@ -13,14 +29,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; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $credentials; // blob
|
||||
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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -30,30 +46,31 @@ 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', 'unsigned' => true, 'not null' => true, 'description' => 'link to user on foreign service, if exists'),
|
||||
'foreign_id' => array('type' => 'int', 'size' => 'big', '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' => 'varchar', 'length' => 191, 'description' => 'authc credentials, typically a password'),
|
||||
'credentials' => array('type' => 'blob', '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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, '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_fkey' => array('foreign_user', array('foreign_id' => 'id', 'service' => 'service')),
|
||||
'foreign_link_foreign_id_service_fkey' => array('foreign_user', array('foreign_id' => 'id', 'service' => 'service')),
|
||||
'foreign_link_service_fkey' => array('foreign_service', array('service' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'foreign_user_user_id_idx' => array('user_id'),
|
||||
'foreign_link_foreign_id_service_idx' => array('foreign_id', 'service'),
|
||||
'foreign_link_service_idx' => array('service'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static function getByUserID($user_id, $service)
|
||||
public static function getByUserID($user_id, $service)
|
||||
{
|
||||
if (empty($user_id) || empty($service)) {
|
||||
throw new ServerException('Empty user_id or service for Foreign_link::getByUserID');
|
||||
@@ -71,7 +88,7 @@ class Foreign_link extends Managed_DataObject
|
||||
return $flink;
|
||||
}
|
||||
|
||||
static function getByForeignID($foreign_id, $service)
|
||||
public static function getByForeignID($foreign_id, $service)
|
||||
{
|
||||
if (empty($foreign_id) || empty($service)) {
|
||||
throw new ServerException('Empty foreign_id or service for Foreign_link::getByForeignID');
|
||||
@@ -89,7 +106,7 @@ class Foreign_link extends Managed_DataObject
|
||||
return $flink;
|
||||
}
|
||||
|
||||
function set_flags($noticesend, $noticerecv, $replysync, $repeatsync, $friendsync)
|
||||
public function set_flags($noticesend, $noticerecv, $replysync, $repeatsync, $friendsync)
|
||||
{
|
||||
if ($noticesend) {
|
||||
$this->noticesync |= FOREIGN_NOTICE_SEND;
|
||||
@@ -125,7 +142,7 @@ class Foreign_link extends Managed_DataObject
|
||||
}
|
||||
|
||||
// Convenience methods
|
||||
function getForeignUser()
|
||||
public function getForeignUser()
|
||||
{
|
||||
$fuser = new Foreign_user();
|
||||
$fuser->service = $this->service;
|
||||
@@ -140,29 +157,30 @@ class Foreign_link extends Managed_DataObject
|
||||
return $fuser;
|
||||
}
|
||||
|
||||
function getUser()
|
||||
public function getUser()
|
||||
{
|
||||
return Profile::getByID($this->user_id)->getUser();
|
||||
}
|
||||
|
||||
function getProfile()
|
||||
public function getProfile()
|
||||
{
|
||||
return Profile::getByID($this->user_id);
|
||||
}
|
||||
|
||||
// Make sure we only ever delete one record at a time
|
||||
function safeDelete()
|
||||
public 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,8 +1,24 @@
|
||||
<?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
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Foreign_service extends Managed_DataObject
|
||||
{
|
||||
@@ -13,8 +29,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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -26,8 +42,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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
<?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
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Foreign_subscription extends Managed_DataObject
|
||||
{
|
||||
@@ -13,7 +29,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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -26,17 +42,18 @@ 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', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', '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_fkey' => array('foreign_user', array('subscriber' => 'id', 'service' => 'service')),
|
||||
'foreign_subscription_subscribed_fkey' => array('foreign_user', array('subscribed' => 'id', 'service' => 'service')),
|
||||
'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')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'foreign_subscription_subscriber_idx' => array('service', 'subscriber'),
|
||||
'foreign_subscription_subscribed_idx' => array('service', 'subscribed'),
|
||||
'foreign_subscription_subscriber_service_idx' => array('subscriber', 'service'),
|
||||
'foreign_subscription_subscribed_service_idx' => array('subscribed', 'service'),
|
||||
'foreign_subscription_service_subscribed_idx' => array('service', 'subscribed'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
<?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
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Foreign_user extends Managed_DataObject
|
||||
{
|
||||
@@ -14,8 +30,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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -28,8 +44,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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id', 'service'),
|
||||
'foreign keys' => array(
|
||||
@@ -38,10 +54,13 @@ class Foreign_user extends Managed_DataObject
|
||||
'unique keys' => array(
|
||||
'foreign_user_uri_key' => array('uri'),
|
||||
),
|
||||
'indexes' => array(
|
||||
'foreign_user_service_idx' => array('service'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static function getForeignUser($id, $service)
|
||||
public static function getForeignUser($id, $service)
|
||||
{
|
||||
if (empty($id) || empty($service)) {
|
||||
throw new ServerException('Empty foreign user id or service for Foreign_user::getForeignUser');
|
||||
@@ -59,7 +78,7 @@ class Foreign_user extends Managed_DataObject
|
||||
return $fuser;
|
||||
}
|
||||
|
||||
static function getByNickname($nickname, $service)
|
||||
public 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
|
||||
*
|
||||
* 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/>.
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
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; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() 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' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date alias was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date alias was created'),
|
||||
),
|
||||
'primary key' => array('alias'),
|
||||
'foreign keys' => array(
|
||||
|
||||
+34
-26
@@ -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 group_block
|
||||
*
|
||||
* 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/>.
|
||||
* @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
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Group_block extends Managed_DataObject
|
||||
{
|
||||
@@ -32,7 +34,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; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -44,7 +46,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' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date of blocking'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'),
|
||||
),
|
||||
'primary key' => array('group_id', 'blocked'),
|
||||
'foreign keys' => array(
|
||||
@@ -52,23 +54,29 @@ 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'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static function isBlocked($group, $profile)
|
||||
public static function isBlocked($group, $profile)
|
||||
{
|
||||
$block = Group_block::pkeyGet(array('group_id' => $group->id,
|
||||
'blocked' => $profile->id));
|
||||
$block = Group_block::pkeyGet([
|
||||
'group_id' => $group->id,
|
||||
'blocked' => $profile->id,
|
||||
]);
|
||||
return !empty($block);
|
||||
}
|
||||
|
||||
static function blockProfile($group, $profile, $blocker)
|
||||
public static function blockProfile($group, $profile, $blocker)
|
||||
{
|
||||
// Insert the block
|
||||
|
||||
$block = new Group_block();
|
||||
|
||||
$block->query('BEGIN');
|
||||
$block->query('START TRANSACTION');
|
||||
|
||||
$block->group_id = $group->id;
|
||||
$block->blocked = $profile->id;
|
||||
@@ -103,7 +111,7 @@ class Group_block extends Managed_DataObject
|
||||
return $block;
|
||||
}
|
||||
|
||||
static function unblockProfile($group, $profile)
|
||||
public static function unblockProfile($group, $profile)
|
||||
{
|
||||
$block = Group_block::pkeyGet(array('group_id' => $group->id,
|
||||
'blocked' => $profile->id));
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
<?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
|
||||
@@ -11,7 +28,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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -23,7 +40,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', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the notice was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date the notice was created'),
|
||||
),
|
||||
'primary key' => array('group_id', 'notice_id'),
|
||||
'foreign keys' => array(
|
||||
|
||||
@@ -14,12 +14,11 @@
|
||||
// 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 request_queue
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Group_join_queue extends Managed_DataObject
|
||||
{
|
||||
@@ -41,7 +40,7 @@ class Group_join_queue extends Managed_DataObject
|
||||
'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', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
),
|
||||
'primary key' => array('profile_id', 'group_id'),
|
||||
'indexes' => array(
|
||||
|
||||
@@ -30,8 +30,8 @@ class Group_member extends Managed_DataObject
|
||||
public $profile_id; // int(4) primary_key not_null
|
||||
public $is_admin; // bool default_false
|
||||
public $uri; // 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 $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -44,8 +44,8 @@ class Group_member extends Managed_DataObject
|
||||
'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?'),
|
||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('group_id', 'profile_id'),
|
||||
'unique keys' => array(
|
||||
@@ -56,8 +56,6 @@ 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'),
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
<?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
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Invitation extends Managed_DataObject
|
||||
{
|
||||
@@ -15,12 +31,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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
function convert($user)
|
||||
public function convert($user)
|
||||
{
|
||||
$orig = clone($this);
|
||||
$this->registered_user_id = $user->id;
|
||||
@@ -36,7 +52,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', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', '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'),
|
||||
@@ -45,7 +61,7 @@ class Invitation extends Managed_DataObject
|
||||
'invitation_registered_user_id_fkey' => array('user', array('registered_user_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'invitation_address_idx' => array('address', 'address_type'),
|
||||
'invitation_address_address_type_idx' => array('address', 'address_type'),
|
||||
'invitation_user_id_idx' => array('user_id'),
|
||||
'invitation_registered_user_id_idx' => array('registered_user_id'),
|
||||
),
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
<?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
|
||||
@@ -11,8 +28,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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -24,8 +41,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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('group_id'),
|
||||
'foreign keys' => array(
|
||||
@@ -54,16 +71,23 @@ class Local_group extends Managed_DataObject
|
||||
return $group;
|
||||
}
|
||||
|
||||
function setNickname($nickname)
|
||||
public function setNickname($nickname)
|
||||
{
|
||||
$this->decache();
|
||||
$qry = 'UPDATE local_group set nickname = "'.$this->escape($nickname).'" where group_id = ' . $this->group_id;
|
||||
|
||||
$result = $this->query($qry);
|
||||
$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
|
||||
));
|
||||
|
||||
if ($result) {
|
||||
$this->nickname = $nickname;
|
||||
$this->fixupTimestamps();
|
||||
$this->modified = $modified;
|
||||
$this->encache();
|
||||
} else {
|
||||
common_log_db_error($local, 'UPDATE', __FILE__);
|
||||
|
||||
@@ -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/>.
|
||||
|
||||
/*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2009, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Table Definition for location_namespace
|
||||
*
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Location_namespace extends Managed_DataObject
|
||||
{
|
||||
@@ -33,8 +31,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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -45,8 +43,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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date the record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
);
|
||||
|
||||
+27
-25
@@ -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
|
||||
*
|
||||
* 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/>.
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() 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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, '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
|
||||
|
||||
function makeNew($user)
|
||||
public function makeNew($user)
|
||||
{
|
||||
$login_token = Login_token::getKV('user_id', $user->id);
|
||||
|
||||
@@ -75,8 +75,10 @@ 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;
|
||||
|
||||
@@ -246,7 +246,6 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
'date' => DB_DATAOBJECT_DATE,
|
||||
'time' => DB_DATAOBJECT_TIME,
|
||||
'datetime' => DB_DATAOBJECT_DATE | DB_DATAOBJECT_TIME,
|
||||
'timestamp' => DB_DATAOBJECT_MYSQLTIMESTAMP,
|
||||
];
|
||||
|
||||
if (isset($formatStyles[$type])) {
|
||||
@@ -283,6 +282,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()
|
||||
{
|
||||
@@ -440,6 +441,32 @@ 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
|
||||
@@ -494,14 +521,37 @@ 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!
|
||||
/**
|
||||
* @param DB_DataObject &$orig Must be "instanceof" $this
|
||||
* @param string $pid Primary ID column (no escaping is done on column name!)
|
||||
* Set the attribute defined as "timestamp" to CURRENT_TIMESTAMP.
|
||||
* This is hooked in update() and updateWithKeys() to update "modified".
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
public function updateWithKeys(Managed_DataObject $orig, $pid=null)
|
||||
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)
|
||||
{
|
||||
if (!$orig instanceof $this) {
|
||||
throw new ServerException('Tried updating a DataObject with a different class than itself.');
|
||||
@@ -514,12 +564,26 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
$this->onUpdateKeys($orig);
|
||||
|
||||
// do it in a transaction
|
||||
$this->query('BEGIN');
|
||||
$this->query('START TRANSACTION');
|
||||
|
||||
$parts = array();
|
||||
// ON UPDATE CURRENT_TIMESTAMP behaviour
|
||||
// @fixme Should the value be reverted back if transaction failed?
|
||||
$this->updateAutoTimestamps();
|
||||
|
||||
$parts = [];
|
||||
foreach ($this->keys() as $k) {
|
||||
if (strcmp($this->$k, $orig->$k) != 0) {
|
||||
$parts[] = $k . ' = ' . $this->_quote($this->$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 (count($parts) == 0) {
|
||||
@@ -622,12 +686,25 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
public function insert()
|
||||
{
|
||||
$this->onInsert();
|
||||
return parent::insert();
|
||||
$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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,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,30 +97,52 @@ 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);
|
||||
}
|
||||
|
||||
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)
|
||||
));
|
||||
// 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;
|
||||
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.');
|
||||
}
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
|
||||
$obj->find();
|
||||
@@ -138,10 +160,20 @@ 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 = [])
|
||||
{
|
||||
public static function pivotGetClass(
|
||||
$cls,
|
||||
$keyCol,
|
||||
array $keyVals,
|
||||
array $otherCols = []
|
||||
) {
|
||||
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 {
|
||||
@@ -421,7 +453,6 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
{
|
||||
$result = parent::insert();
|
||||
if ($result) {
|
||||
$this->fixupTimestamps();
|
||||
$this->encache(); // in case of cached negative lookups
|
||||
}
|
||||
return $result;
|
||||
@@ -434,7 +465,6 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
$result = parent::update($dataObject);
|
||||
if ($result !== false) {
|
||||
$this->fixupTimestamps();
|
||||
$this->encache();
|
||||
}
|
||||
return $result;
|
||||
@@ -575,7 +605,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $ckeys;
|
||||
}
|
||||
|
||||
public static function multicache($cls, $kv)
|
||||
public static function multicache($cls, array $kv)
|
||||
{
|
||||
ksort($kv);
|
||||
$c = self::memcache();
|
||||
@@ -586,7 +616,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public static function multicacheKey($cls, $kv)
|
||||
public static function multicacheKey($cls, array $kv)
|
||||
{
|
||||
ksort($kv);
|
||||
$pkeys = implode(',', array_keys($kv));
|
||||
@@ -665,7 +695,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
$string = $this->annotateQuery($string);
|
||||
}
|
||||
|
||||
$start = microtime(true);
|
||||
$start = hrtime(true);
|
||||
$fail = false;
|
||||
$result = null;
|
||||
if (Event::handle('StartDBQuery', array($this, $string, &$result))) {
|
||||
@@ -677,7 +707,7 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
}
|
||||
Event::handle('EndDBQuery', array($this, $string, &$result));
|
||||
}
|
||||
$delta = microtime(true) - $start;
|
||||
$delta = (hrtime(true) - $start) / 1000000000;
|
||||
|
||||
$limit = common_config('db', 'log_slow_queries');
|
||||
if (($limit > 0 && $delta >= $limit) || common_config('db', 'log_queries')) {
|
||||
@@ -815,21 +845,11 @@ 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');
|
||||
} elseif ($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='+0:00'");
|
||||
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'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -909,22 +929,6 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $c->delete($cacheKey);
|
||||
}
|
||||
|
||||
public function fixupTimestamps()
|
||||
{
|
||||
// Fake up timestamp columns
|
||||
$columns = $this->table();
|
||||
foreach ($columns as $name => $type) {
|
||||
if ($type & DB_DATAOBJECT_MYSQLTIMESTAMP) {
|
||||
$this->$name = common_sql_now();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function debugDump()
|
||||
{
|
||||
common_debug("debugDump: " . common_log_objstring($this));
|
||||
}
|
||||
|
||||
public function raiseError($message, $type = null, $behavior = null)
|
||||
{
|
||||
$id = get_class($this);
|
||||
@@ -970,11 +974,17 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
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.
|
||||
|
||||
+22
-6
@@ -1,8 +1,24 @@
|
||||
<?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
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Nonce extends Managed_DataObject
|
||||
{
|
||||
@@ -14,8 +30,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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -29,7 +45,7 @@ class Nonce extends Managed_DataObject
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
function links()
|
||||
public function links()
|
||||
{
|
||||
return array('consumer_key,token' => 'token:consumer_key,token');
|
||||
}
|
||||
@@ -43,8 +59,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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('consumer_key', 'ts', 'nonce'),
|
||||
);
|
||||
|
||||
+39
-24
@@ -57,9 +57,9 @@ class Notice extends Managed_DataObject
|
||||
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||
public $content; // text
|
||||
public $rendered; // text
|
||||
public $url; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $created; // datetime() multiple_key not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $url; // text
|
||||
public $created; // datetime() multiple_key
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $reply_to; // int(4)
|
||||
public $is_local; // int(4)
|
||||
public $source; // varchar(32)
|
||||
@@ -79,11 +79,11 @@ class Notice extends Managed_DataObject
|
||||
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
|
||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'who made the update'),
|
||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier, usually a tag URI'),
|
||||
'content' => array('type' => 'text', 'description' => 'update content', 'collate' => 'utf8mb4_general_ci'),
|
||||
'content' => array('type' => 'text', 'description' => 'update content', 'collate' => 'utf8_general_ci'),
|
||||
'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'),
|
||||
'url' => array('type' => 'varchar', 'length' => 191, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'),
|
||||
'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'),
|
||||
'url' => array('type' => 'text', 'description' => 'URL of any attachment (image, video, bookmark, whatever)'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'reply_to' => array('type' => 'int', 'description' => 'notice replied to (usually a guess)'),
|
||||
'is_local' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'notice was generated by a user'),
|
||||
'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'),
|
||||
@@ -105,22 +105,22 @@ class Notice extends Managed_DataObject
|
||||
'notice_repeat_of_fkey' => array('notice', array('repeat_of' => 'id')), # @fixme: what about repeats of deleted notices?
|
||||
),
|
||||
'indexes' => array(
|
||||
'notice_created_id_is_local_idx' => array('created', 'id', 'is_local'),
|
||||
'notice_profile_id_idx' => array('profile_id', 'created', 'id'),
|
||||
'notice_is_local_created_id_idx' => array('is_local', 'created', 'id'),
|
||||
'notice_profile_id_created_id_idx' => array('profile_id', 'created', 'id'),
|
||||
'notice_profile_id_verb_scope_created_id_idx' => array('profile_id', 'verb', 'scope', 'created', 'id'),
|
||||
'notice_is_local_created_profile_id_idx' => array('is_local', 'created', 'profile_id'),
|
||||
'notice_repeat_of_created_id_idx' => array('repeat_of', 'created', 'id'),
|
||||
'notice_conversation_created_id_idx' => array('conversation', 'created', 'id'),
|
||||
'notice_object_type_idx' => array('object_type'),
|
||||
'notice_verb_idx' => array('verb'),
|
||||
'notice_profile_id_verb_idx' => array('profile_id', 'verb'),
|
||||
'notice_url_idx' => array('url'), // Qvitter wants this
|
||||
'notice_replyto_idx' => array('reply_to')
|
||||
)
|
||||
'notice_url_idx' => array(array('url', 191)), // Qvitter wants this
|
||||
'notice_reply_to_idx' => array('reply_to')
|
||||
),
|
||||
'fulltext indexes' => array(
|
||||
'notice_fulltext_idx' => array('content'),
|
||||
),
|
||||
);
|
||||
|
||||
if (common_config('search', 'type') == 'fulltext') {
|
||||
$def['fulltext indexes'] = array('content' => array('content'));
|
||||
}
|
||||
|
||||
return $def;
|
||||
}
|
||||
|
||||
@@ -184,6 +184,7 @@ class Notice extends Managed_DataObject
|
||||
// Clear related records
|
||||
$this->clearReplies();
|
||||
$this->clearLocation();
|
||||
$this->clearPrefs();
|
||||
$this->clearRepeats();
|
||||
$this->clearTags();
|
||||
$this->clearGroupInboxes();
|
||||
@@ -230,12 +231,12 @@ class Notice extends Managed_DataObject
|
||||
return $notice;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param $root boolean If true, link to just the conversation root.
|
||||
/**
|
||||
* @param bool $anchor If false, link to just the conversation root.
|
||||
*
|
||||
* @return URL to conversation
|
||||
* @return string URL to conversation
|
||||
*/
|
||||
public function getConversationUrl($anchor=true)
|
||||
public function getConversationUrl(bool $anchor = true): string
|
||||
{
|
||||
return Conversation::getUrlFromNotice($this, $anchor);
|
||||
}
|
||||
@@ -2451,7 +2452,7 @@ class Notice extends Managed_DataObject
|
||||
if ($replyNotice->find()) {
|
||||
while ($replyNotice->fetch()) {
|
||||
$orig = clone($replyNotice);
|
||||
$replyNotice->reply_to = null;
|
||||
$replyNotice->reply_to = $replyNotice->sqlValue('NULL');
|
||||
$replyNotice->update($orig);
|
||||
}
|
||||
}
|
||||
@@ -2481,6 +2482,16 @@ class Notice extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
private function clearPrefs(): void
|
||||
{
|
||||
$prefs = new Notice_prefs();
|
||||
$prefs->notice_id = $this->id;
|
||||
|
||||
if ($prefs->find()) {
|
||||
$prefs->delete();
|
||||
}
|
||||
}
|
||||
|
||||
public function clearFiles()
|
||||
{
|
||||
$f2p = new File_to_post();
|
||||
@@ -2506,7 +2517,7 @@ class Notice extends Managed_DataObject
|
||||
if ($repeatNotice->find()) {
|
||||
while ($repeatNotice->fetch()) {
|
||||
$orig = clone($repeatNotice);
|
||||
$repeatNotice->repeat_of = null;
|
||||
$repeatNotice->repeat_of = $repeatNotice->sqlValue('NULL');
|
||||
$repeatNotice->update($orig);
|
||||
}
|
||||
}
|
||||
@@ -3242,7 +3253,11 @@ class Notice extends Managed_DataObject
|
||||
unset($notice);
|
||||
$notice = new Notice();
|
||||
$notice->query(sprintf(
|
||||
'UPDATE %1$s SET %2$s = NULL WHERE id IN (%3$s)',
|
||||
<<<'END'
|
||||
UPDATE %1$s
|
||||
SET %2$s = NULL, modified = CURRENT_TIMESTAMP
|
||||
WHERE id IN (%3$s)
|
||||
END,
|
||||
$notice->escapedTableName(),
|
||||
$field,
|
||||
implode(',', $ids)
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
<?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
|
||||
@@ -11,7 +28,7 @@ class Notice_location extends Managed_DataObject
|
||||
public $lon; // decimal(10,7)
|
||||
public $location_id; // int(4)
|
||||
public $location_ns; // int(4)
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -22,7 +39,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' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('notice_id'),
|
||||
'foreign keys' => array(
|
||||
@@ -32,9 +49,9 @@ class Notice_location extends Managed_DataObject
|
||||
'notice_location_location_id_idx' => array('location_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static function locFromStored(Notice $stored)
|
||||
public static function locFromStored(Notice $stored)
|
||||
{
|
||||
$loc = new Notice_location();
|
||||
$loc->notice_id = $stored->getID();
|
||||
@@ -44,7 +61,7 @@ class Notice_location extends Managed_DataObject
|
||||
return $loc->asLocation();
|
||||
}
|
||||
|
||||
static function fromLocation(Location $location)
|
||||
public static function fromLocation(Location $location)
|
||||
{
|
||||
$notloc = new Notice_location();
|
||||
$notloc->lat = $location->lat;
|
||||
|
||||
@@ -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() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -45,16 +45,13 @@ 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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, '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'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,12 @@
|
||||
// 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();
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
/**
|
||||
* Table Definition for notice_source
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Notice_source extends Managed_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
@@ -30,8 +29,8 @@ class Notice_source extends Managed_DataObject
|
||||
public $code; // varchar(32) primary_key not_null
|
||||
public $name; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||
public $url; // varchar(191) not_null 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 $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -43,9 +42,9 @@ class Notice_source extends Managed_DataObject
|
||||
'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'source code'),
|
||||
'name' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'name of the source'),
|
||||
'url' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'url to link to'),
|
||||
'notice_id' => array('type' => 'int', 'not null' => true, 'default' => 0, 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'notice_id' => array('type' => 'int', 'not null' => true, 'default' => 0, 'description' => 'notice id'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('code'),
|
||||
);
|
||||
|
||||
+46
-35
@@ -1,23 +1,25 @@
|
||||
<?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/>.
|
||||
* @copyright 2008, 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Notice_tag extends Managed_DataObject
|
||||
{
|
||||
@@ -27,7 +29,7 @@ class Notice_tag extends Managed_DataObject
|
||||
public $__table = 'notice_tag'; // table name
|
||||
public $tag; // varchar(64) primary_key not_null
|
||||
public $notice_id; // int(4) primary_key not_null
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -39,7 +41,7 @@ class Notice_tag extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'),
|
||||
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice tagged'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
),
|
||||
'primary key' => array('tag', 'notice_id'),
|
||||
'foreign keys' => array(
|
||||
@@ -52,16 +54,21 @@ class Notice_tag extends Managed_DataObject
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static function getStream($tag, $offset=0, $limit=20, $sinceId=0, $maxId=0)
|
||||
{
|
||||
|
||||
public static function getStream(
|
||||
$tag,
|
||||
$offset = 0,
|
||||
$limit = 20,
|
||||
$sinceId = 0,
|
||||
$maxId = 0
|
||||
) {
|
||||
// FIXME: Get the Profile::current value some other way
|
||||
// to avoid confusino between queue processing and session.
|
||||
$stream = new TagNoticeStream($tag, Profile::current());
|
||||
return $stream;
|
||||
}
|
||||
|
||||
function blowCache($blowLast=false)
|
||||
public function blowCache($blowLast = false)
|
||||
{
|
||||
self::blow('notice_tag:notice_ids:%s', Cache::keyize($this->tag));
|
||||
if ($blowLast) {
|
||||
@@ -69,18 +76,22 @@ class Notice_tag extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
static function url($tag)
|
||||
{
|
||||
if (common_config('singleuser', 'enabled')) {
|
||||
// regular TagAction isn't set up in 1user mode
|
||||
$nickname = User::singleUserNickname();
|
||||
$url = common_local_url('showstream',
|
||||
array('nickname' => $nickname,
|
||||
'tag' => $tag));
|
||||
} else {
|
||||
$url = common_local_url('tag', array('tag' => $tag));
|
||||
}
|
||||
public static function url($tag)
|
||||
{
|
||||
if (common_config('singleuser', 'enabled')) {
|
||||
// Regular TagAction isn't set up in 1user mode
|
||||
$nickname = User::singleUserNickname();
|
||||
$url = common_local_url(
|
||||
'showstream',
|
||||
[
|
||||
'nickname' => $nickname,
|
||||
'tag' => $tag,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$url = common_local_url('tag', ['tag' => $tag]);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
<?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 oauth_application
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Oauth_application extends Managed_DataObject
|
||||
{
|
||||
@@ -22,8 +38,8 @@ class Oauth_application extends Managed_DataObject
|
||||
public $callback_url; // varchar(191) not_null not 255 because utf8mb4 takes more space
|
||||
public $type; // tinyint(1)
|
||||
public $access_type; // tinyint(1)
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -35,12 +51,12 @@ class Oauth_application extends Managed_DataObject
|
||||
public static $browser = 1;
|
||||
public static $desktop = 2;
|
||||
|
||||
function getConsumer()
|
||||
public function getConsumer()
|
||||
{
|
||||
return Consumer::getKV('consumer_key', $this->consumer_key);
|
||||
}
|
||||
|
||||
static function maxDesc()
|
||||
public static function maxDesc()
|
||||
{
|
||||
// This used to default to textlimit or allow unlimited descriptions,
|
||||
// but this isn't part of a notice and the field's limited to 191 chars
|
||||
@@ -57,13 +73,13 @@ class Oauth_application extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
static function descriptionTooLong($desc)
|
||||
public static function descriptionTooLong($desc)
|
||||
{
|
||||
$desclimit = self::maxDesc();
|
||||
return ($desclimit > 0 && !empty($desc) && (mb_strlen($desc) > $desclimit));
|
||||
}
|
||||
|
||||
function setAccessFlags($read, $write)
|
||||
public function setAccessFlags($read, $write)
|
||||
{
|
||||
if ($read) {
|
||||
$this->access_type |= self::$readAccess;
|
||||
@@ -78,7 +94,7 @@ class Oauth_application extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
function setOriginal($filename)
|
||||
public function setOriginal($filename)
|
||||
{
|
||||
$imagefile = new ImageFile(null, Avatar::path($filename));
|
||||
|
||||
@@ -91,7 +107,7 @@ class Oauth_application extends Managed_DataObject
|
||||
return $this->update($orig);
|
||||
}
|
||||
|
||||
static function getByConsumerKey($key)
|
||||
public static function getByConsumerKey($key)
|
||||
{
|
||||
if (empty($key)) {
|
||||
return null;
|
||||
@@ -113,11 +129,9 @@ class Oauth_application extends Managed_DataObject
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function uploadLogo()
|
||||
public function uploadLogo()
|
||||
{
|
||||
if ($_FILES['app_icon']['error'] ==
|
||||
UPLOAD_ERR_OK) {
|
||||
|
||||
if ($_FILES['app_icon']['error'] == UPLOAD_ERR_OK) {
|
||||
try {
|
||||
$imagefile = ImageFile::fromUpload('app_icon');
|
||||
} catch (Exception $e) {
|
||||
@@ -126,10 +140,12 @@ class Oauth_application extends Managed_DataObject
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = Avatar::filename($this->id,
|
||||
image_type_to_extension($imagefile->type),
|
||||
null,
|
||||
'oauth-app-icon-'.common_timestamp());
|
||||
$filename = Avatar::filename(
|
||||
$this->id,
|
||||
image_type_to_extension($imagefile->type),
|
||||
null,
|
||||
'oauth-app-icon-' . common_timestamp()
|
||||
);
|
||||
|
||||
$filepath = Avatar::path($filename);
|
||||
|
||||
@@ -139,9 +155,9 @@ class Oauth_application extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
function delete($useWhere=false)
|
||||
public function delete($useWhere = false)
|
||||
{
|
||||
$this->_deleteAppUsers();
|
||||
$this->deleteAppUsers();
|
||||
|
||||
$consumer = $this->getConsumer();
|
||||
$consumer->delete();
|
||||
@@ -149,7 +165,7 @@ class Oauth_application extends Managed_DataObject
|
||||
return parent::delete($useWhere);
|
||||
}
|
||||
|
||||
function _deleteAppUsers()
|
||||
private function deleteAppUsers()
|
||||
{
|
||||
$oauser = new Oauth_application_user();
|
||||
$oauser->application_id = $this->id;
|
||||
@@ -173,8 +189,8 @@ class Oauth_application extends Managed_DataObject
|
||||
'callback_url' => array('type' => 'varchar', 'length' => 191, 'description' => 'url to redirect to after authentication'),
|
||||
'type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'type of app, 1 = browser, 2 = desktop'),
|
||||
'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'default access type, bit 1 = read, bit 2 = write'),
|
||||
'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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
@@ -184,6 +200,10 @@ class Oauth_application extends Managed_DataObject
|
||||
'oauth_application_owner_fkey' => array('profile', array('owner' => 'id')), // Are remote users allowed to create oauth application records?
|
||||
'oauth_application_consumer_key_fkey' => array('consumer', array('consumer_key' => 'consumer_key')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'oauth_application_owner_idx' => array('owner'),
|
||||
'oauth_application_consumer_key_idx' => array('consumer_key'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,12 @@
|
||||
// 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();
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
/**
|
||||
* Table Definition for oauth_application_user
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Oauth_application_user extends Managed_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
@@ -31,8 +30,8 @@ class Oauth_application_user extends Managed_DataObject
|
||||
public $application_id; // int(4) primary_key not_null
|
||||
public $access_type; // tinyint(1)
|
||||
public $token; // 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 $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -45,14 +44,17 @@ class Oauth_application_user extends Managed_DataObject
|
||||
'application_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the application'),
|
||||
'access_type' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'access type, bit 1 = read, bit 2 = write'),
|
||||
'token' => array('type' => 'varchar', 'length' => 191, 'description' => 'request or access token'),
|
||||
'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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('profile_id', 'application_id'),
|
||||
'foreign keys' => array(
|
||||
'oauth_application_user_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
'oauth_application_user_application_id_fkey' => array('oauth_application', array('application_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'oauth_application_user_application_id_idx' => array('application_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,6 +89,7 @@ class Oauth_application_user extends Managed_DataObject
|
||||
return true;
|
||||
}
|
||||
$toupdate = implode(', ', $parts);
|
||||
$toupdate .= ', modified = CURRENT_TIMESTAMP';
|
||||
|
||||
$table = $this->tableName();
|
||||
$tableName = $this->escapedTableName();
|
||||
|
||||
@@ -14,13 +14,12 @@
|
||||
// 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();
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
|
||||
/**
|
||||
* Table Definition for oauth_association
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Oauth_token_association extends Managed_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
@@ -30,8 +29,8 @@ class Oauth_token_association extends Managed_DataObject
|
||||
public $profile_id; // int(4) primary_key not_null
|
||||
public $application_id; // int(4) primary_key not_null
|
||||
public $token; // varchar(191) primary key not null 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 $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -61,14 +60,17 @@ class Oauth_token_association extends Managed_DataObject
|
||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'associated user'),
|
||||
'application_id' => array('type' => 'int', 'not null' => true, 'description' => 'the application'),
|
||||
'token' => array('type' => 'varchar', 'length' => '191', 'not null' => true, 'description' => 'token used for this association'),
|
||||
'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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('profile_id', 'application_id', 'token'),
|
||||
'foreign keys' => array(
|
||||
'oauth_token_association_profile_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
'oauth_token_association_application_fkey' => array('oauth_application', array('application_id' => 'id')),
|
||||
)
|
||||
'oauth_token_association_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
'oauth_token_association_application_id_fkey' => array('oauth_application', array('application_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'oauth_token_association_application_id_idx' => array('application_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ class Old_school_prefs extends Managed_DataObject
|
||||
'stream_nicknames' => array('type' => 'bool',
|
||||
'default' => true,
|
||||
'description' => 'Show nicknames for authors and addressees in streams'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('user_id'),
|
||||
'foreign keys' => array(
|
||||
|
||||
+30
-30
@@ -15,15 +15,14 @@
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Table Definition for profile
|
||||
*
|
||||
* @copyright 2008-2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Table Definition for profile
|
||||
*/
|
||||
class Profile extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'profile'; // table name
|
||||
@@ -38,8 +37,8 @@ class Profile extends Managed_DataObject
|
||||
public $lon; // decimal(10,7)
|
||||
public $location_id; // int(4)
|
||||
public $location_ns; // int(4)
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -47,31 +46,28 @@ class Profile extends Managed_DataObject
|
||||
'description' => 'local and remote users have profiles',
|
||||
'fields' => array(
|
||||
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
|
||||
'nickname' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username', 'collate' => 'utf8mb4_general_ci'),
|
||||
'fullname' => array('type' => 'text', 'description' => 'display name', 'collate' => 'utf8mb4_general_ci'),
|
||||
'nickname' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username', 'collate' => 'utf8_general_ci'),
|
||||
'fullname' => array('type' => 'text', 'description' => 'display name', 'collate' => 'utf8_general_ci'),
|
||||
'profileurl' => array('type' => 'text', 'description' => 'URL, cached so we dont regenerate'),
|
||||
'homepage' => array('type' => 'text', 'description' => 'identifying URL', 'collate' => 'utf8mb4_general_ci'),
|
||||
'bio' => array('type' => 'text', 'description' => 'descriptive biography', 'collate' => 'utf8mb4_general_ci'),
|
||||
'location' => array('type' => 'text', 'description' => 'physical location', 'collate' => 'utf8mb4_general_ci'),
|
||||
'homepage' => array('type' => 'text', 'description' => 'identifying URL', 'collate' => 'utf8_general_ci'),
|
||||
'bio' => array('type' => 'text', 'description' => 'descriptive biography', 'collate' => 'utf8_general_ci'),
|
||||
'location' => array('type' => 'text', 'description' => 'physical location', 'collate' => 'utf8_general_ci'),
|
||||
'lat' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'latitude'),
|
||||
'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'),
|
||||
'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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'indexes' => array(
|
||||
'profile_nickname_idx' => array('nickname'),
|
||||
)
|
||||
),
|
||||
'fulltext indexes' => array(
|
||||
'profile_fulltext_idx' => array('nickname', 'fullname', 'location', 'bio', 'homepage'),
|
||||
),
|
||||
);
|
||||
|
||||
// Add a fulltext index
|
||||
|
||||
if (common_config('search', 'type') == 'fulltext') {
|
||||
$def['fulltext indexes'] = array('nickname' => array('nickname', 'fullname', 'location', 'bio', 'homepage'));
|
||||
}
|
||||
|
||||
return $def;
|
||||
}
|
||||
|
||||
@@ -337,6 +333,7 @@ class Profile extends Managed_DataObject
|
||||
$gm = new Group_member();
|
||||
|
||||
$gm->profile_id = $this->id;
|
||||
$gm->orderBy('created DESC');
|
||||
|
||||
if ($gm->find()) {
|
||||
while ($gm->fetch()) {
|
||||
@@ -504,13 +501,13 @@ class Profile extends Managed_DataObject
|
||||
|
||||
if (!is_null($scoped)) {
|
||||
$qry .= sprintf(
|
||||
'AND ( profile_list.private = false ' .
|
||||
'AND ( profile_list.private IS NOT TRUE ' .
|
||||
'OR ( profile_list.tagger = %d AND ' .
|
||||
'profile_list.private = TRUE ) )',
|
||||
'profile_list.private IS TRUE ) )',
|
||||
$scoped->getID()
|
||||
);
|
||||
} else {
|
||||
$qry .= 'AND profile_list.private = FALSE ';
|
||||
$qry .= 'AND profile_list.private IS NOT TRUE ';
|
||||
}
|
||||
|
||||
if ($since > 0) {
|
||||
@@ -978,6 +975,13 @@ class Profile extends Managed_DataObject
|
||||
$this->_deleteAttentions();
|
||||
Avatar::deleteFromProfile($this, true);
|
||||
|
||||
$this->grantRole(Profile_role::DELETED);
|
||||
|
||||
$localuser = User::getKV('id', $this->id);
|
||||
if ($localuser instanceof User) {
|
||||
$localuser->delete();
|
||||
}
|
||||
|
||||
// Warning: delete() will run on the batch objects,
|
||||
// not on individual objects.
|
||||
$related = [
|
||||
@@ -993,13 +997,6 @@ class Profile extends Managed_DataObject
|
||||
$inst->delete();
|
||||
}
|
||||
|
||||
$this->grantRole(Profile_role::DELETED);
|
||||
|
||||
$localuser = User::getKV('id', $this->id);
|
||||
if ($localuser instanceof User) {
|
||||
$localuser->delete();
|
||||
}
|
||||
|
||||
return parent::delete($useWhere);
|
||||
}
|
||||
|
||||
@@ -1165,7 +1162,10 @@ class Profile extends Managed_DataObject
|
||||
$role->role = $name;
|
||||
$role->created = common_sql_now();
|
||||
|
||||
$result = $role->insert();
|
||||
$result = $role->update();
|
||||
if ($result === 0 || $result === false) {
|
||||
$result = $role->insert();
|
||||
}
|
||||
|
||||
if (!$result) {
|
||||
throw new Exception("Can't save role '$name' for profile '{$this->id}'");
|
||||
|
||||
+24
-23
@@ -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/>.
|
||||
|
||||
/*
|
||||
* 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); }
|
||||
|
||||
/**
|
||||
* Table Definition for profile_block
|
||||
*
|
||||
* @copyright 2008, 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Profile_block extends Managed_DataObject
|
||||
{
|
||||
@@ -44,17 +42,20 @@ class Profile_block extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'),
|
||||
'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date of blocking'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'profile_block_blocker_fkey' => array('user', array('blocker' => 'id')),
|
||||
'profile_block_blocked_fkey' => array('profile', array('blocked' => 'id')),
|
||||
),
|
||||
'primary key' => array('blocker', 'blocked'),
|
||||
'indexes' => array(
|
||||
'profile_block_blocked_idx' => array('blocked'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static function exists(Profile $blocker, Profile $blocked)
|
||||
public static function exists(Profile $blocker, Profile $blocked)
|
||||
{
|
||||
return Profile_block::pkeyGet(array('blocker' => $blocker->id,
|
||||
'blocked' => $blocked->id));
|
||||
|
||||
@@ -32,8 +32,8 @@ class Profile_list extends Managed_DataObject
|
||||
public $tag; // varchar(64)
|
||||
public $description; // text
|
||||
public $private; // bool default_false
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||
public $mainpage; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $tagged_count; // smallint
|
||||
@@ -49,8 +49,8 @@ class Profile_list extends Managed_DataObject
|
||||
'description' => array('type' => 'text', 'description' => 'description of the people tag'),
|
||||
'private' => array('type' => 'bool', 'default' => false, 'description' => 'is this tag private'),
|
||||
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the tag was added'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date the tag was modified'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date the tag was added'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was modified'),
|
||||
|
||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
|
||||
'mainpage' => array('type' => 'varchar', 'length' => 191, 'description' => 'page to link to'),
|
||||
@@ -60,7 +60,6 @@ class Profile_list extends Managed_DataObject
|
||||
'primary key' => array('tagger', 'tag'),
|
||||
'unique keys' => array(
|
||||
'profile_list_id_key' => array('id'),
|
||||
'profile_list_tag_key' => array('tag'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'profile_list_tagger_fkey' => array('profile', array('tagger' => 'id')),
|
||||
@@ -68,7 +67,6 @@ class Profile_list extends Managed_DataObject
|
||||
'indexes' => array(
|
||||
'profile_list_modified_idx' => array('modified'),
|
||||
'profile_list_tag_idx' => array('tag'),
|
||||
'profile_list_tagger_tag_idx' => array('tagger', 'tag'),
|
||||
'profile_list_tagged_count_idx' => array('tagged_count'),
|
||||
'profile_list_subscriber_count_idx' => array('subscriber_count'),
|
||||
),
|
||||
@@ -610,7 +608,7 @@ class Profile_list extends Managed_DataObject
|
||||
|
||||
$ptag = new Profile_list();
|
||||
|
||||
$ptag->query('BEGIN');
|
||||
$ptag->query('START TRANSACTION');
|
||||
|
||||
if (empty($tagger)) {
|
||||
// TRANS: Server exception saving new tag without having a tagger specified.
|
||||
|
||||
@@ -33,8 +33,8 @@ class Profile_prefs extends Managed_DataObject
|
||||
public $namespace; // varchar(191) not_null
|
||||
public $topic; // varchar(191) not_null
|
||||
public $data; // text
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -44,16 +44,13 @@ class Profile_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', '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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('profile_id', 'namespace', 'topic'),
|
||||
'foreign keys' => array(
|
||||
'profile_prefs_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'profile_prefs_profile_id_idx' => array('profile_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+21
-25
@@ -1,31 +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/>.
|
||||
|
||||
/*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2009, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Table Definition for profile_role
|
||||
*
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Profile_role extends Managed_DataObject
|
||||
{
|
||||
@@ -35,7 +31,7 @@ class Profile_role extends Managed_DataObject
|
||||
public $__table = 'profile_role'; // table name
|
||||
public $profile_id; // int(4) primary_key not_null
|
||||
public $role; // varchar(32) primary_key not_null
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -46,7 +42,7 @@ class Profile_role extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'account having the role'),
|
||||
'role' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'string representing the role'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date the role was granted'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date the role was granted'),
|
||||
),
|
||||
'primary key' => array('profile_id', 'role'),
|
||||
'foreign keys' => array(
|
||||
|
||||
+14
-13
@@ -25,7 +25,7 @@ class Profile_tag extends Managed_DataObject
|
||||
public $tagger; // int(4) primary_key not_null
|
||||
public $tagged; // int(4) primary_key not_null
|
||||
public $tag; // varchar(64) primary_key not_null
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -35,13 +35,12 @@ class Profile_tag extends Managed_DataObject
|
||||
'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'),
|
||||
'tagged' => array('type' => 'int', 'not null' => true, 'description' => 'profile tagged'),
|
||||
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date the tag was added'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was added'),
|
||||
),
|
||||
'primary key' => array('tagger', 'tagged', 'tag'),
|
||||
'foreign keys' => array(
|
||||
'profile_tag_tagger_fkey' => array('profile', array('tagger' => 'id')),
|
||||
'profile_tag_tagged_fkey' => array('profile', array('tagged' => 'id')),
|
||||
'profile_tag_tag_fkey' => array('profile_list', array('tag' => 'tag')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'profile_tag_modified_idx' => array('modified'),
|
||||
@@ -96,7 +95,7 @@ class Profile_tag extends Managed_DataObject
|
||||
$qry = sprintf($qry, $tagger, $tagged);
|
||||
|
||||
if (!$include_priv) {
|
||||
$qry .= ' AND profile_list.private = FALSE';
|
||||
$qry .= ' AND profile_list.private IS NOT TRUE';
|
||||
}
|
||||
|
||||
$profile_list->query($qry);
|
||||
@@ -122,7 +121,7 @@ class Profile_tag extends Managed_DataObject
|
||||
);
|
||||
|
||||
if (!$scoped instanceof Profile || $scoped->getID() !== $tagger) {
|
||||
$qry .= 'AND profile_list.private = FALSE';
|
||||
$qry .= 'AND profile_list.private IS NOT TRUE';
|
||||
}
|
||||
|
||||
$tags = array();
|
||||
@@ -198,7 +197,7 @@ class Profile_tag extends Managed_DataObject
|
||||
}
|
||||
|
||||
$plist = new Profile_list();
|
||||
$plist->query('BEGIN');
|
||||
$plist->query('START TRANSACTION');
|
||||
|
||||
$profile_list = Profile_list::ensureTag($tagger, $tag, $desc, $private);
|
||||
|
||||
@@ -293,14 +292,16 @@ class Profile_tag extends Managed_DataObject
|
||||
public static function moveTag($orig, $new)
|
||||
{
|
||||
$tags = new Profile_tag();
|
||||
$qry = "UPDATE profile_tag SET tag = '%s', tagger = '%s' " .
|
||||
"WHERE tag = '%s' AND tagger = '%s'";
|
||||
$result = $tags->query(sprintf(
|
||||
$qry,
|
||||
$tags->escape($new->tag),
|
||||
$tags->escape($new->tagger),
|
||||
$tags->escape($orig->tag),
|
||||
$tags->escape($orig->tagger)
|
||||
<<<'END'
|
||||
UPDATE profile_tag
|
||||
SET tag = %1$s, tagger = %2$s, modified = CURRENT_TIMESTAMP
|
||||
WHERE tag = %3$s AND tagger = %4$s
|
||||
END,
|
||||
$tags->_quote($new->tag),
|
||||
$tags->_quote($new->tagger),
|
||||
$tags->_quote($orig->tag),
|
||||
$tags->_quote($orig->tagger)
|
||||
));
|
||||
|
||||
if ($result === false) {
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
<?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 profile_tag_subscription
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Profile_tag_subscription extends Managed_DataObject
|
||||
{
|
||||
@@ -12,8 +28,8 @@ class Profile_tag_subscription extends Managed_DataObject
|
||||
public $__table = 'profile_tag_subscription'; // table name
|
||||
public $profile_tag_id; // int(4) not_null
|
||||
public $profile_id; // int(4) not_null
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -25,12 +41,12 @@ class Profile_tag_subscription extends Managed_DataObject
|
||||
'profile_tag_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile_tag'),
|
||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
|
||||
|
||||
'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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('profile_tag_id', 'profile_id'),
|
||||
'foreign keys' => array(
|
||||
'profile_tag_subscription_profile_list_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')),
|
||||
'profile_tag_subscription_profile_tag_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')),
|
||||
'profile_tag_subscription_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
@@ -41,7 +57,7 @@ class Profile_tag_subscription extends Managed_DataObject
|
||||
);
|
||||
}
|
||||
|
||||
static function add($peopletag, $profile)
|
||||
public static function add($peopletag, $profile)
|
||||
{
|
||||
if ($peopletag->private) {
|
||||
return false;
|
||||
@@ -51,7 +67,7 @@ class Profile_tag_subscription extends Managed_DataObject
|
||||
$args = array('profile_tag_id' => $peopletag->id,
|
||||
'profile_id' => $profile->id);
|
||||
$existing = Profile_tag_subscription::pkeyGet($args);
|
||||
if(!empty($existing)) {
|
||||
if (!empty($existing)) {
|
||||
return $existing;
|
||||
}
|
||||
|
||||
@@ -76,7 +92,7 @@ class Profile_tag_subscription extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
static function remove($peopletag, $profile)
|
||||
public static function remove($peopletag, $profile)
|
||||
{
|
||||
$sub = Profile_tag_subscription::pkeyGet(array('profile_tag_id' => $peopletag->id,
|
||||
'profile_id' => $profile->id));
|
||||
@@ -103,12 +119,13 @@ class Profile_tag_subscription extends Managed_DataObject
|
||||
}
|
||||
|
||||
// called if a tag gets deleted / made private
|
||||
static function cleanup($profile_list) {
|
||||
public static function cleanup($profile_list)
|
||||
{
|
||||
$subs = new self();
|
||||
$subs->profile_tag_id = $profile_list->id;
|
||||
$subs->find();
|
||||
|
||||
while($subs->fetch()) {
|
||||
while ($subs->fetch()) {
|
||||
$profile = Profile::getKV('id', $subs->profile_id);
|
||||
Event::handle('StartUnsubscribePeopletag', array($profile_list, $profile));
|
||||
// Delete anyway
|
||||
@@ -117,22 +134,26 @@ class Profile_tag_subscription extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
function insert()
|
||||
public function insert()
|
||||
{
|
||||
$result = parent::insert();
|
||||
if ($result) {
|
||||
self::blow('profile_list:subscriber_count:%d',
|
||||
$this->profile_tag_id);
|
||||
self::blow(
|
||||
'profile_list:subscriber_count:%d',
|
||||
$this->profile_tag_id
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function delete($useWhere=false)
|
||||
public function delete($useWhere = false)
|
||||
{
|
||||
$result = parent::delete($useWhere);
|
||||
if ($result !== false) {
|
||||
self::blow('profile_list:subscriber_count:%d',
|
||||
$this->profile_tag_id);
|
||||
self::blow(
|
||||
'profile_list:subscriber_count:%d',
|
||||
$this->profile_tag_id
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
+43
-19
@@ -1,8 +1,24 @@
|
||||
<?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 queue_item
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Queue_item extends Managed_DataObject
|
||||
{
|
||||
@@ -13,7 +29,7 @@ class Queue_item extends Managed_DataObject
|
||||
public $id; // int(4) primary_key not_null
|
||||
public $frame; // blob not_null
|
||||
public $transport; // varchar(32)
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
public $claimed; // datetime()
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
@@ -26,7 +42,7 @@ class Queue_item extends Managed_DataObject
|
||||
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
|
||||
'frame' => array('type' => 'blob', 'not null' => true, 'description' => 'data: object reference or opaque string'),
|
||||
'transport' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'queue for what? "email", "xmpp", "sms", "irc", ...'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'claimed' => array('type' => 'datetime', 'description' => 'date this item was claimed'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
@@ -40,25 +56,29 @@ class Queue_item extends Managed_DataObject
|
||||
* @param mixed $transports name of a single queue or array of queues to pull from
|
||||
* If not specified, checks all queues in the system.
|
||||
*/
|
||||
static function top($transports=null, array $ignored_transports=array()) {
|
||||
|
||||
public static function top($transports = null, array $ignored_transports = [])
|
||||
{
|
||||
$qi = new Queue_item();
|
||||
if ($transports) {
|
||||
if (is_array($transports)) {
|
||||
// @fixme use safer escaping
|
||||
$list = implode("','", array_map(array($qi, 'escape'), $transports));
|
||||
$qi->whereAdd("transport in ('$list')");
|
||||
$qi->whereAddIn(
|
||||
'transport',
|
||||
$transports,
|
||||
$qi->columnType('transport')
|
||||
);
|
||||
} else {
|
||||
$qi->transport = $transports;
|
||||
}
|
||||
}
|
||||
if (!empty($ignored_transports)) {
|
||||
// @fixme use safer escaping
|
||||
$list = implode("','", array_map(array($qi, 'escape'), $ignored_transports));
|
||||
$qi->whereAdd("transport NOT IN ('$list')");
|
||||
$qi->whereAddIn(
|
||||
'!transport',
|
||||
$ignored_transports,
|
||||
$qi->columnType('transport')
|
||||
);
|
||||
}
|
||||
$qi->whereAdd('claimed IS NULL');
|
||||
$qi->orderBy('created');
|
||||
$qi->whereAdd('claimed is null');
|
||||
|
||||
$qi->limit(1);
|
||||
|
||||
@@ -79,20 +99,24 @@ class Queue_item extends Managed_DataObject
|
||||
common_log(LOG_ERR, 'claim of queue item id= ' . $qi->getID() . ' for transport ' . $qi->transport . ' failed.');
|
||||
}
|
||||
}
|
||||
$qi = null;
|
||||
unset($qi);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release a claimed item.
|
||||
*/
|
||||
function releaseClaim()
|
||||
public function releaseClaim()
|
||||
{
|
||||
// DB_DataObject doesn't let us save nulls right now
|
||||
$sql = sprintf("UPDATE queue_item SET claimed=NULL WHERE id=%d", $this->getID());
|
||||
$this->query($sql);
|
||||
// @fixme Consider $this->sqlValue('NULL')
|
||||
$ret = $this->query(sprintf(
|
||||
'UPDATE queue_item SET claimed = NULL WHERE id = %d',
|
||||
$this->getID()
|
||||
));
|
||||
|
||||
$this->claimed = null;
|
||||
$this->encache();
|
||||
if ($ret) {
|
||||
$this->claimed = null;
|
||||
$this->encache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
<?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 related_group
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Related_group extends Managed_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
@@ -11,7 +28,7 @@ class Related_group extends Managed_DataObject
|
||||
public $__table = 'related_group'; // table name
|
||||
public $group_id; // int(4) primary_key not_null
|
||||
public $related_group_id; // int(4) primary_key not_null
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -23,13 +40,16 @@ class Related_group extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'),
|
||||
'related_group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
),
|
||||
'primary key' => array('group_id', 'related_group_id'),
|
||||
'foreign keys' => array(
|
||||
'related_group_group_id_fkey' => array('user_group', array('group_id' => 'id')),
|
||||
'related_group_related_group_id_fkey' => array('user_group', array('related_group_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'related_group_related_group_id_idx' => array('related_group_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
<?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 remember_me
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Remember_me extends Managed_DataObject
|
||||
{
|
||||
@@ -12,7 +28,7 @@ class Remember_me extends Managed_DataObject
|
||||
public $__table = 'remember_me'; // table name
|
||||
public $code; // varchar(32) primary_key not_null
|
||||
public $user_id; // int(4) not_null
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -23,12 +39,15 @@ class Remember_me extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'),
|
||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who is logged in'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('code'),
|
||||
'foreign keys' => array(
|
||||
'remember_me_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'remember_me_user_id_idx' => array('user_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+29
-9
@@ -1,8 +1,24 @@
|
||||
<?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 reply
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Reply extends Managed_DataObject
|
||||
{
|
||||
@@ -12,7 +28,7 @@ class Reply extends Managed_DataObject
|
||||
public $__table = 'reply'; // table name
|
||||
public $notice_id; // int(4) primary_key not_null
|
||||
public $profile_id; // int(4) primary_key not_null
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $replied_id; // int(4)
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
@@ -24,7 +40,7 @@ class Reply extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the reply'),
|
||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile replied to'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
'replied_id' => array('type' => 'int', 'description' => 'notice replied to (not used, see notice.reply_to)'),
|
||||
),
|
||||
'primary key' => array('notice_id', 'profile_id'),
|
||||
@@ -33,18 +49,17 @@ class Reply extends Managed_DataObject
|
||||
'reply_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'reply_notice_id_idx' => array('notice_id'),
|
||||
'reply_profile_id_idx' => array('profile_id'),
|
||||
'reply_replied_id_idx' => array('replied_id'),
|
||||
'reply_profile_id_modified_notice_id_idx' => array('profile_id', 'modified', 'notice_id')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for record insertion to update related caches
|
||||
*/
|
||||
function insert()
|
||||
public function insert()
|
||||
{
|
||||
$result = parent::insert();
|
||||
|
||||
@@ -55,8 +70,13 @@ class Reply extends Managed_DataObject
|
||||
return $result;
|
||||
}
|
||||
|
||||
static function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||
{
|
||||
public static function stream(
|
||||
$user_id,
|
||||
$offset = 0,
|
||||
$limit = NOTICES_PER_PAGE,
|
||||
$since_id = 0,
|
||||
$max_id = 0
|
||||
) {
|
||||
// FIXME: Use some other method to get Profile::current() in order
|
||||
// to avoid confusion between background processing and session user.
|
||||
$stream = new ReplyNoticeStream($user_id, Profile::current());
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
<?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 schema_version
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Schema_version extends Managed_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
@@ -10,8 +27,8 @@ class Schema_version extends Managed_DataObject
|
||||
|
||||
public $__table = 'schema_version'; // table name
|
||||
public $table_name; // varchar(64) primary_key not_null
|
||||
public $checksum; // varchar(64) not_null
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $checksum; // varchar(128) not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -22,8 +39,8 @@ class Schema_version extends Managed_DataObject
|
||||
'description' => 'To avoid checking database structure all the time, we store a checksum of the expected schema info for each table here. If it has not changed since the last time we checked the table, we can leave it as is.',
|
||||
'fields' => array(
|
||||
'table_name' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Table name'),
|
||||
'checksum' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Checksum of schema array; a mismatch indicates we should check the table more thoroughly.'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'checksum' => array('type' => 'varchar', 'length' => '128', 'not null' => true, 'description' => 'Checksum of schema array; a mismatch indicates we should check the table more thoroughly.'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('table_name'),
|
||||
);
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
|
||||
/**
|
||||
* Superclass representing a saved session as it exists in the database.
|
||||
*
|
||||
@@ -45,8 +43,8 @@ class Session extends Managed_DataObject
|
||||
public $__table = 'session'; // table name
|
||||
public $id; // varchar(32) primary_key not_null
|
||||
public $session_data; // text()
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -60,10 +58,10 @@ class Session extends Managed_DataObject
|
||||
{
|
||||
return [
|
||||
'fields' => [
|
||||
'id' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'session ID'],
|
||||
'id' => ['type' => 'varchar', 'length' => 128, 'not null' => true, 'description' => 'session ID'],
|
||||
'session_data' => ['type' => 'text', 'description' => 'session data'],
|
||||
'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'],
|
||||
'created' => ['type' => 'datetime', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['id'],
|
||||
'indexes' => [
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
<?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 sms_carrier
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Sms_carrier extends Managed_DataObject
|
||||
{
|
||||
@@ -13,13 +29,13 @@ class Sms_carrier extends Managed_DataObject
|
||||
public $id; // int(4) primary_key not_null
|
||||
public $name; // varchar(64) unique_key
|
||||
public $email_pattern; // varchar(191) not_null 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 $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
function toEmailAddress($sms)
|
||||
public function toEmailAddress($sms)
|
||||
{
|
||||
return sprintf($this->email_pattern, $sms);
|
||||
}
|
||||
@@ -31,8 +47,8 @@ class Sms_carrier extends Managed_DataObject
|
||||
'id' => array('type' => 'int', 'not null' => true, 'description' => 'primary key for SMS carrier'),
|
||||
'name' => array('type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'),
|
||||
'email_pattern' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'sprintf pattern for making an email address from a phone number'),
|
||||
'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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
|
||||
@@ -1,25 +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 status_network
|
||||
*
|
||||
* 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/>.
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Status_network extends Safe_DataObject
|
||||
{
|
||||
@@ -39,12 +41,13 @@ class Status_network extends Safe_DataObject
|
||||
public $theme; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $logo; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* Static get */
|
||||
static function getKV($k,$v=NULL) {
|
||||
public static function getKV($k, $v = null)
|
||||
{
|
||||
// TODO: This must probably be turned into a non-static call
|
||||
$i = DB_DataObject::staticGet('Status_network',$k,$v);
|
||||
$i = DB_DataObject::staticGet('Status_network', $k, $v);
|
||||
|
||||
// Don't use local process cache; if we're fetching multiple
|
||||
// times it's because we're reloading it in a long-running
|
||||
@@ -60,8 +63,8 @@ class Status_network extends Safe_DataObject
|
||||
// XXX: made public so Status_network_tag can eff with it
|
||||
public static $cache = null;
|
||||
public static $cacheInitialized = false;
|
||||
static $base = null;
|
||||
static $wildcard = null;
|
||||
public static $base = null;
|
||||
public static $wildcard = null;
|
||||
|
||||
/**
|
||||
* @param string $dbhost
|
||||
@@ -70,8 +73,13 @@ class Status_network extends Safe_DataObject
|
||||
* @param string $dbname
|
||||
* @param array $servers memcached servers to use for caching config info
|
||||
*/
|
||||
static function setupDB($dbhost, $dbuser, $dbpass, $dbname, array $servers)
|
||||
{
|
||||
public static function setupDB(
|
||||
$dbhost,
|
||||
$dbuser,
|
||||
$dbpass,
|
||||
$dbname,
|
||||
array $servers
|
||||
) {
|
||||
global $config;
|
||||
|
||||
$config['db']['database_'.$dbname] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname";
|
||||
@@ -95,8 +103,8 @@ class Status_network extends Safe_DataObject
|
||||
$persist = php_sapi_name() != 'cli' || self::$cacheInitialized;
|
||||
if (!is_array($servers)) {
|
||||
$servers = array($servers);
|
||||
}
|
||||
foreach($servers as $server) {
|
||||
}
|
||||
foreach ($servers as $server) {
|
||||
$parts = explode(':', $server);
|
||||
$server = $parts[0];
|
||||
if (count($parts) > 1) {
|
||||
@@ -112,11 +120,12 @@ class Status_network extends Safe_DataObject
|
||||
self::$base = $dbname;
|
||||
}
|
||||
|
||||
static function cacheKey($k, $v) {
|
||||
public static function cacheKey($k, $v)
|
||||
{
|
||||
return 'gnusocial:' . self::$base . ':status_network:'.$k.':'.$v;
|
||||
}
|
||||
|
||||
static function memGet($k, $v)
|
||||
public static function memGet($k, $v)
|
||||
{
|
||||
if (!self::$cache) {
|
||||
return self::getKV($k, $v);
|
||||
@@ -136,7 +145,7 @@ class Status_network extends Safe_DataObject
|
||||
return $sn;
|
||||
}
|
||||
|
||||
function decache()
|
||||
public function decache()
|
||||
{
|
||||
if (self::$cache) {
|
||||
$keys = array('nickname', 'hostname', 'pathname');
|
||||
@@ -147,10 +156,11 @@ class Status_network extends Safe_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
function update($dataObject=false)
|
||||
public function update($dataObject = false)
|
||||
{
|
||||
if (is_object($dataObject)) {
|
||||
$dataObject->decache(); # might be different keys
|
||||
// might be different keys
|
||||
$dataObject->decache();
|
||||
}
|
||||
return parent::update($dataObject);
|
||||
}
|
||||
@@ -158,7 +168,7 @@ class Status_network extends Safe_DataObject
|
||||
/**
|
||||
* DB_DataObject doesn't allow updating keys (even non-primary)
|
||||
*/
|
||||
function updateKeys(&$orig)
|
||||
public function updateKeys(&$orig)
|
||||
{
|
||||
$this->_connect();
|
||||
foreach (array('hostname', 'pathname') as $k) {
|
||||
@@ -183,9 +193,10 @@ class Status_network extends Safe_DataObject
|
||||
return $result;
|
||||
}
|
||||
|
||||
function delete($useWhere=false)
|
||||
public function delete($useWhere = false)
|
||||
{
|
||||
$this->decache(); # while we still have the values!
|
||||
// while we still have the values!
|
||||
$this->decache();
|
||||
return parent::delete($useWhere);
|
||||
}
|
||||
|
||||
@@ -194,7 +205,7 @@ class Status_network extends Safe_DataObject
|
||||
* @param string $wildcard hostname suffix to match wildcard config
|
||||
* @return mixed Status_network or null
|
||||
*/
|
||||
static function getFromHostname($servername, $wildcard)
|
||||
public static function getFromHostname($servername, $wildcard)
|
||||
{
|
||||
$sn = null;
|
||||
if (0 == strncasecmp(strrev($wildcard), strrev($servername), strlen($wildcard))) {
|
||||
@@ -223,7 +234,7 @@ class Status_network extends Safe_DataObject
|
||||
* @param string $pathname URL base path
|
||||
* @param string $wildcard hostname suffix to match wildcard config
|
||||
*/
|
||||
static function setupSite($servername, $pathname, $wildcard)
|
||||
public static function setupSite($servername, $pathname, $wildcard)
|
||||
{
|
||||
global $config;
|
||||
|
||||
@@ -241,10 +252,14 @@ class Status_network extends Safe_DataObject
|
||||
empty($_SERVER['HTTPS']) &&
|
||||
0 != strcasecmp($sn->hostname, $servername)) {
|
||||
$sn->redirectTo('http://'.$sn->hostname.$_SERVER['REQUEST_URI']);
|
||||
} else if (!empty($_SERVER['HTTPS']) &&
|
||||
0 != strcasecmp($sn->hostname, $servername) &&
|
||||
0 != strcasecmp($sn->nickname.'.'.$wildcard, $servername)) {
|
||||
$sn->redirectTo('https://'.$sn->nickname.'.'.$wildcard.$_SERVER['REQUEST_URI']);
|
||||
} elseif (
|
||||
!empty($_SERVER['HTTPS'])
|
||||
&& strcasecmp($sn->hostname, $servername) !== 0
|
||||
&& strcasecmp($sn->nickname . '.' . $wildcard, $servername) !== 0
|
||||
) {
|
||||
$sn->redirectTo(
|
||||
"https://{$sn->nickname}.{$wildcard}{$_SERVER['REQUEST_URI']}"
|
||||
);
|
||||
}
|
||||
|
||||
$dbhost = (empty($sn->dbhost)) ? 'localhost' : $sn->dbhost;
|
||||
@@ -282,7 +297,7 @@ class Status_network extends Safe_DataObject
|
||||
// (C) 2006 by Heiko Richler http://www.richler.de/
|
||||
// LGPL
|
||||
|
||||
function redirectTo($destination)
|
||||
public function redirectTo($destination)
|
||||
{
|
||||
$old = 'http'.
|
||||
(($_SERVER['HTTPS'] == 'on') ? 'S' : '').
|
||||
@@ -295,15 +310,15 @@ class Status_network extends Safe_DataObject
|
||||
return false;
|
||||
}
|
||||
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header("Location: $destination");
|
||||
http_response_code(301);
|
||||
header("Location: {$destination}");
|
||||
|
||||
print "<a href='$destination'>$destination</a>\n";
|
||||
echo "<a href='{$destination}'>{$destination}</a>\n";
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
function getServerName()
|
||||
public function getServerName()
|
||||
{
|
||||
if (!empty($this->hostname)) {
|
||||
return $this->hostname;
|
||||
@@ -316,7 +331,7 @@ class Status_network extends Safe_DataObject
|
||||
* Return site meta-info tags as an array
|
||||
* @return array of strings
|
||||
*/
|
||||
function getTags()
|
||||
public function getTags()
|
||||
{
|
||||
return Status_network_tag::getTags($this->site_id);
|
||||
}
|
||||
@@ -326,7 +341,7 @@ class Status_network extends Safe_DataObject
|
||||
* @param array tags
|
||||
* @fixme only add/remove differentials
|
||||
*/
|
||||
function setTags(array $tags)
|
||||
public function setTags(array $tags)
|
||||
{
|
||||
$this->clearTags();
|
||||
foreach ($tags as $tag) {
|
||||
@@ -347,13 +362,13 @@ class Status_network extends Safe_DataObject
|
||||
return true;
|
||||
}
|
||||
|
||||
function clearTags()
|
||||
public function clearTags()
|
||||
{
|
||||
$tag = new Status_network_tag();
|
||||
$tag->site_id = $this->site_id;
|
||||
|
||||
if ($tag->find()) {
|
||||
while($tag->fetch()) {
|
||||
while ($tag->fetch()) {
|
||||
$tag->delete();
|
||||
}
|
||||
}
|
||||
@@ -366,7 +381,7 @@ class Status_network extends Safe_DataObject
|
||||
* @param string $tag
|
||||
* @return bool
|
||||
*/
|
||||
function hasTag($tag)
|
||||
public function hasTag($tag)
|
||||
{
|
||||
return in_array($tag, $this->getTags());
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @copyright 2008, 2009, StatusNet, Inc.
|
||||
* @copyright 2008, 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -37,8 +37,8 @@ class Subscription extends Managed_DataObject
|
||||
public $token; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $secret; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -51,16 +51,16 @@ class Subscription extends Managed_DataObject
|
||||
'token' => array('type' => 'varchar', 'length' => 191, 'description' => 'authorization token'),
|
||||
'secret' => array('type' => 'varchar', 'length' => 191, 'description' => 'token secret'),
|
||||
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier'),
|
||||
'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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('subscriber', 'subscribed'),
|
||||
'unique keys' => array(
|
||||
'subscription_uri_key' => array('uri'),
|
||||
),
|
||||
'indexes' => array(
|
||||
'subscription_subscriber_idx' => array('subscriber', 'created'),
|
||||
'subscription_subscribed_idx' => array('subscribed', 'created'),
|
||||
'subscription_subscriber_created_idx' => array('subscriber', 'created'),
|
||||
'subscription_subscribed_created_idx' => array('subscribed', 'created'),
|
||||
'subscription_token_idx' => array('token'),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
<?php
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Table Definition for subscription_queue
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Subscription_queue extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'subscription_queue'; // table name
|
||||
@@ -20,7 +34,7 @@ class Subscription_queue extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'subscriber' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'),
|
||||
'subscribed' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile being subscribed to'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
),
|
||||
'primary key' => array('subscriber', 'subscribed'),
|
||||
'indexes' => array(
|
||||
@@ -47,14 +61,14 @@ class Subscription_queue extends Managed_DataObject
|
||||
return $rq;
|
||||
}
|
||||
|
||||
static function exists(Profile $subscriber, Profile $other)
|
||||
public static function exists(Profile $subscriber, Profile $other)
|
||||
{
|
||||
$sub = Subscription_queue::pkeyGet(array('subscriber' => $subscriber->getID(),
|
||||
'subscribed' => $other->getID()));
|
||||
return ($sub instanceof Subscription_queue);
|
||||
}
|
||||
|
||||
static function getSubQueue(Profile $subscriber, Profile $other)
|
||||
public static function getSubQueue(Profile $subscriber, Profile $other)
|
||||
{
|
||||
// This is essentially a pkeyGet but we have an object to return in NoResultException
|
||||
$sub = new Subscription_queue();
|
||||
|
||||
+22
-6
@@ -1,8 +1,24 @@
|
||||
<?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 token
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class Token extends Managed_DataObject
|
||||
{
|
||||
@@ -17,8 +33,8 @@ class Token extends Managed_DataObject
|
||||
public $state; // tinyint(1)
|
||||
public $verifier; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $verified_callback; // 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 $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -34,12 +50,12 @@ class Token extends Managed_DataObject
|
||||
'state' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'for requests, 0 = initial, 1 = authorized, 2 = used'),
|
||||
'verifier' => array('type' => 'varchar', 'length' => 191, 'description' => 'verifier string for OAuth 1.0a'),
|
||||
'verified_callback' => array('type' => 'varchar', 'length' => 191, 'description' => 'verified callback URL for OAuth 1.0a'),
|
||||
'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'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('consumer_key', 'tok'),
|
||||
'foreign keys' => array(
|
||||
'token_consumer_key_fkey' => array('consumer', array('consumer_key'=> 'consumer_key')),
|
||||
'token_consumer_key_fkey' => array('consumer', array('consumer_key' => 'consumer_key')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,54 +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/>.
|
||||
|
||||
/**
|
||||
* Data class for unavailable status networks
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Data
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2011, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Keeps a list of unavailable status network names
|
||||
*
|
||||
* @category Data
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see Managed_DataObject
|
||||
*/
|
||||
|
||||
class Unavailable_status_network extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'unavailable_status_network'; // table name
|
||||
|
||||
public $nickname; // varchar(64) UUID
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
|
||||
/**
|
||||
* The One True Thingy that must be defined and declared.
|
||||
@@ -61,8 +55,7 @@ class Unavailable_status_network extends Managed_DataObject
|
||||
'nickname' => array('type' => 'varchar',
|
||||
'length' => 64,
|
||||
'not null' => true, 'description' => 'nickname not to use'),
|
||||
'created' => array('type' => 'datetime',
|
||||
'not null' => true, 'default' => '0000-00-00 00:00:00'),
|
||||
'created' => array('type' => 'datetime'),
|
||||
),
|
||||
'primary key' => array('nickname'),
|
||||
);
|
||||
|
||||
+11
-11
@@ -31,7 +31,7 @@ class User extends Managed_DataObject
|
||||
public $__table = 'user'; // table name
|
||||
public $id; // int(4) primary_key not_null
|
||||
public $nickname; // varchar(64) unique_key
|
||||
public $password; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $password; // text
|
||||
public $email; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||
public $incomingemail; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||
public $emailnotifysub; // bool default_true
|
||||
@@ -52,8 +52,8 @@ class User extends Managed_DataObject
|
||||
public $subscribe_policy; // tinyint(1)
|
||||
public $urlshorteningservice; // varchar(50) default_ur1.ca
|
||||
public $private_stream; // bool default_false
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -65,7 +65,7 @@ class User extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
|
||||
'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'nickname or username, duped in profile'),
|
||||
'password' => array('type' => 'varchar', 'length' => 191, 'description' => 'salted password, can be null for OpenID users'),
|
||||
'password' => array('type' => 'text', 'description' => 'salted password, can be null for OpenID users'),
|
||||
'email' => array('type' => 'varchar', 'length' => 191, 'description' => 'email address for password recovery etc.'),
|
||||
'incomingemail' => array('type' => 'varchar', 'length' => 191, 'description' => 'email address for post-by-email'),
|
||||
'emailnotifysub' => array('type' => 'bool', 'default' => true, 'description' => 'Notify by email of subscriptions'),
|
||||
@@ -86,8 +86,8 @@ class User extends Managed_DataObject
|
||||
'subscribe_policy' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'),
|
||||
'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'),
|
||||
'private_stream' => array('type' => 'bool', 'default' => false, 'description' => 'whether to limit all notices to followers only'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
@@ -102,6 +102,8 @@ class User extends Managed_DataObject
|
||||
'user_carrier_fkey' => array('sms_carrier', array('carrier' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'user_carrier_idx' => array('carrier'),
|
||||
'user_created_idx' => array('created'),
|
||||
'user_smsemail_idx' => array('smsemail'),
|
||||
),
|
||||
);
|
||||
@@ -274,7 +276,7 @@ class User extends Managed_DataObject
|
||||
$user->created = common_sql_now();
|
||||
|
||||
if (Event::handle('StartUserRegister', array($profile))) {
|
||||
$profile->query('BEGIN');
|
||||
$profile->query('START TRANSACTION');
|
||||
|
||||
$id = $profile->insert();
|
||||
if ($id === false) {
|
||||
@@ -503,9 +505,7 @@ class User extends Managed_DataObject
|
||||
|
||||
$block = new Profile_block();
|
||||
|
||||
// Begin a transaction
|
||||
|
||||
$block->query('BEGIN');
|
||||
$block->query('START TRANSACTION');
|
||||
|
||||
$block->blocker = $this->id;
|
||||
$block->blocked = $other->id;
|
||||
@@ -841,7 +841,7 @@ class User extends Managed_DataObject
|
||||
{
|
||||
$qry =
|
||||
'SELECT u.* ' .
|
||||
'FROM oauth_application_user u, oauth_application a ' .
|
||||
'FROM oauth_application_user AS u, oauth_application AS a ' .
|
||||
'WHERE u.profile_id = %d ' .
|
||||
'AND a.id = u.application_id ' .
|
||||
'AND u.access_type > 0 ' .
|
||||
|
||||
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