Comparar commits
30 Commits
active-orm
...
aab
| Autor | SHA1 | Data | |
|---|---|---|---|
| 96c4e57ac0 | |||
| 38fd43b012 | |||
| 5b71085c60 | |||
| 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 |
@@ -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.')
|
||||
|
||||
@@ -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.')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.');
|
||||
@@ -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);
|
||||
|
||||
@@ -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',
|
||||
@@ -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);
|
||||
|
||||
|
Antes Largura: | Altura: | Tamanho: 6.1 KiB Depois Largura: | Altura: | Tamanho: 6.1 KiB |
@@ -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();
|
||||
|
||||
@@ -283,6 +283,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 +442,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 +522,18 @@ 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!)
|
||||
* 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, $pid=null)
|
||||
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.');
|
||||
@@ -516,10 +548,20 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||
// do it in a transaction
|
||||
$this->query('BEGIN');
|
||||
|
||||
$parts = array();
|
||||
$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) {
|
||||
|
||||
@@ -970,11 +970,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;
|
||||
}
|
||||
// fallthrough
|
||||
case 'blob':
|
||||
case 'string':
|
||||
case 'sql':
|
||||
case 'datetime':
|
||||
case 'time':
|
||||
// Low level exception. No need for i18n as discussed with Brion.
|
||||
|
||||
@@ -107,6 +107,7 @@ class Notice extends Managed_DataObject
|
||||
'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_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'),
|
||||
|
||||
@@ -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')),
|
||||
|
||||
@@ -41,7 +41,6 @@ class Profile_tag extends Managed_DataObject
|
||||
'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'),
|
||||
|
||||
@@ -102,6 +102,7 @@ class User extends Managed_DataObject
|
||||
'user_carrier_fkey' => array('sms_carrier', array('carrier' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'user_created_idx' => array('created'),
|
||||
'user_smsemail_idx' => array('smsemail'),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"require": {
|
||||
"php": "^7.3.0",
|
||||
"ext-bcmath": "*",
|
||||
"ext-ctype": "*",
|
||||
"ext-curl": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-gd": "*",
|
||||
@@ -16,7 +17,6 @@
|
||||
"ext-simplexml": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"ext-ctype": "*",
|
||||
"apereo/phpcas": "^1.3",
|
||||
"diogocomposer/xmpphp": "^3.0",
|
||||
"embed/embed": "^3.4",
|
||||
@@ -31,7 +31,9 @@
|
||||
"pear/console_getopt": "^1.4",
|
||||
"phpseclib/phpseclib": "dev-master#f815e43077da67d3dd5b4d18a45753f5b79c1ab9",
|
||||
"predis/predis": "^1.1",
|
||||
"stomp-php/stomp-php": "^4.5.1"
|
||||
"stomp-php/stomp-php": "^4.5.1",
|
||||
"cboden/ratchet": "0.3.*",
|
||||
"react/zmq": "0.2.*|0.3.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpdocumentor/phpdocumentor": "^2.9",
|
||||
|
||||
@@ -47,7 +47,7 @@ define('DB_DATAOBJECT_FETCHMODE_ASSOC', 2);
|
||||
|
||||
/**
|
||||
* these are constants for the get_table array
|
||||
* user to determine what type of escaping is required around the object vars.
|
||||
* used to determine what type of escaping is required around the object vars.
|
||||
*/
|
||||
define('DB_DATAOBJECT_INT', 1); // does not require ''
|
||||
define('DB_DATAOBJECT_STR', 2); // requires ''
|
||||
@@ -118,40 +118,11 @@ $GLOBALS['_DB_DATAOBJECT']['OVERLOADED'] = false;
|
||||
$GLOBALS['_DB_DATAOBJECT']['QUERYENDTIME'] = 0;
|
||||
|
||||
|
||||
// this will be horrifically slow!!!!
|
||||
// these two are BC/FC handlers for call in PHP4/5
|
||||
|
||||
|
||||
if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) {
|
||||
class DB_DataObject_Overload
|
||||
{
|
||||
public function __call($method, $args)
|
||||
{
|
||||
$return = null;
|
||||
$this->_call($method, $args, $return);
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
return array_keys(get_object_vars($this));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
class DB_DataObject_Overload
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* @package DB_DataObject
|
||||
* @author Alan Knowles <alan@akbkhome.com>
|
||||
* @since PHP 4.0
|
||||
*/
|
||||
|
||||
class DB_DataObject extends DB_DataObject_Overload
|
||||
/**
|
||||
* @package DB_DataObject
|
||||
* @author Alan Knowles <alan@akbkhome.com>
|
||||
*/
|
||||
class DB_DataObject
|
||||
{
|
||||
/**
|
||||
* The Version - use this to check feature changes
|
||||
@@ -274,7 +245,7 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
*
|
||||
* @param int $v level
|
||||
* @access public
|
||||
* @return int|none
|
||||
* @return int|void
|
||||
*/
|
||||
public static function debugLevel($v = null)
|
||||
{
|
||||
@@ -804,7 +775,7 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
$this->debug(print_r($dsn, true) . " {$this->_database_dsn_md5}", "CONNECT", 3);
|
||||
}
|
||||
|
||||
// Note this is verbose deliberatly!
|
||||
// Note this is verbose deliberately!
|
||||
|
||||
if ($db_driver == 'DB') {
|
||||
|
||||
@@ -856,7 +827,7 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
}
|
||||
}
|
||||
|
||||
// Oracle need to optimize for portibility - not sure exactly what this does though :)
|
||||
// Oracle needs to optimise for portability - not sure exactly what this does though :)
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -986,12 +957,12 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
* It should append to the table structure array
|
||||
*
|
||||
*
|
||||
* @param optional string name of database to assign / read
|
||||
* @param optional array structure of database, and keys
|
||||
* @param optional array table links
|
||||
* @param string optional name of database to assign / read
|
||||
* @param array optional structure of database, and keys
|
||||
* @param array optional table links
|
||||
*
|
||||
* @access public
|
||||
* @return true or PEAR:error on wrong paramenters.. or false if no file exists..
|
||||
* @return true or PEAR:error on wrong parameters.. or false if no file exists..
|
||||
* or the array(tablename => array(column_name=>type)) if called with 1 argument.. (databasename)
|
||||
*/
|
||||
public function databaseStructure()
|
||||
@@ -1109,7 +1080,7 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
}
|
||||
}
|
||||
}
|
||||
// are table name lowecased..
|
||||
// are table names lower-cased..
|
||||
if (!empty($_DB_DATAOBJECT['CONFIG']['portability']) && $_DB_DATAOBJECT['CONFIG']['portability'] & 1) {
|
||||
foreach ($_DB_DATAOBJECT['INI'][$this->_database] as $k => $v) {
|
||||
// results in duplicate cols.. but not a big issue..
|
||||
@@ -2631,33 +2602,40 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
|
||||
/**
|
||||
* Updates current objects variables into the database
|
||||
*
|
||||
* uses the keys() to decide how to update
|
||||
* Returns the true on success
|
||||
*
|
||||
* for example
|
||||
* WARNING: Be aware that this function doesn't update keys.
|
||||
*
|
||||
* Usage:
|
||||
* ```
|
||||
* $object = DB_DataObject::factory('mytable');
|
||||
* $object->get("ID",234);
|
||||
* $object->email="testing@test.com";
|
||||
* if(!$object->update())
|
||||
* if (!$object->update())
|
||||
* echo "UPDATE FAILED";
|
||||
* ```
|
||||
*
|
||||
* to only update changed items :
|
||||
* to only update changed items:
|
||||
* ```
|
||||
* $dataobject->get(132);
|
||||
* $original = $dataobject; // clone/copy it..
|
||||
* $dataobject->setFrom($_POST);
|
||||
* if ($dataobject->validate()) {
|
||||
* $dataobject->update($original);
|
||||
* } // otherwise an error...
|
||||
* ```
|
||||
*
|
||||
* performing global updates:
|
||||
* ```
|
||||
* $object = DB_DataObject::factory('mytable');
|
||||
* $object->status = "dead";
|
||||
* $object->whereAdd('age > 150');
|
||||
* $object->update(DB_DATAOBJECT_WHEREADD_ONLY);
|
||||
* ```
|
||||
*
|
||||
* @param bool $dataObject
|
||||
* @return int rows affected or false on failure
|
||||
* @param object|bool (optional) $dataObject|DB_DataObject::WHERE_ONLY - used to only update changed items.
|
||||
* @return int|bool Number rows affected (may be 0), true (if no difference between old/new), false on failure
|
||||
* @access public
|
||||
*/
|
||||
public function update($dataObject = false)
|
||||
@@ -2709,7 +2687,7 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
|
||||
foreach ($items as $k => $v) {
|
||||
|
||||
// I think this is ignoring empty vlalues
|
||||
// I think this is ignoring empty values
|
||||
if ((!isset($this->$k) || ($v == 1 && $this->$k === ''))
|
||||
&& $ignore_null
|
||||
) {
|
||||
@@ -2717,7 +2695,7 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
}
|
||||
// ignore stuff thats
|
||||
|
||||
// dont write things that havent changed..
|
||||
// don't write things that haven't changed..
|
||||
if (($dataObject !== false) && isset($dataObject->$k) && ($dataObject->$k === $this->$k)) {
|
||||
continue;
|
||||
}
|
||||
@@ -2756,7 +2734,7 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
continue;
|
||||
}
|
||||
// DATE is empty... on a col. that can be null..
|
||||
// note: this may be usefull for time as well..
|
||||
// note: this may be useful for time as well..
|
||||
if (!$this->$k &&
|
||||
(($v & DB_DATAOBJECT_DATE) || ($v & DB_DATAOBJECT_TIME)) &&
|
||||
!($v & DB_DATAOBJECT_NOTNULL)) {
|
||||
@@ -4190,8 +4168,7 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
$method = $value;
|
||||
$value = func_get_arg(1);
|
||||
}
|
||||
//require_once 'DB/DataObject/Cast.php';
|
||||
require_once 'Cast.php';
|
||||
require_once 'DB/DataObject/Cast.php';
|
||||
return call_user_func(array('DB_DataObject_Cast', $method), $value);
|
||||
}
|
||||
|
||||
@@ -4812,7 +4789,7 @@ class DB_DataObject extends DB_DataObject_Overload
|
||||
}
|
||||
}
|
||||
|
||||
// technially 4.3.2RC1 was broken!!
|
||||
// technically 4.3.2RC1 was broken!!
|
||||
// looks like 4.3.3 may have problems too....
|
||||
if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) {
|
||||
if ((phpversion() != '4.3.2-RC1') && (version_compare(phpversion(), "4.3.1") > 0)) {
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
* $data = DB_DataObject_Cast::sql('cast("123123",datetime)');
|
||||
* $data = DB_DataObject_Cast::sql('NULL');
|
||||
*
|
||||
* // int's/string etc. are proably pretty pointless..!!!!
|
||||
* // int's/string etc. are probably pretty pointless..!!!!
|
||||
*
|
||||
*
|
||||
* inside DB_DataObject,
|
||||
|
||||
|
Antes Largura: | Altura: | Tamanho: 1.4 KiB Depois Largura: | Altura: | Tamanho: 1.4 KiB |
@@ -56,8 +56,8 @@ $_perfCounters = array();
|
||||
// libraries are maintained through repositories)
|
||||
set_include_path('.'); // mainly fixes an issue where /usr/share/{pear,php*}/DB/DataObject.php is _old_ on various systems...
|
||||
|
||||
define('INSTALLDIR', dirname(__DIR__));
|
||||
define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
|
||||
define('INSTALLDIR', __DIR__);
|
||||
define('PUBLICDIR', INSTALLDIR);
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
define('INSTALLDIR', dirname(__DIR__));
|
||||
define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
|
||||
define('INSTALLDIR', __DIR__);
|
||||
define('PUBLICDIR', INSTALLDIR);
|
||||
|
||||
require INSTALLDIR . '/lib/util/installer.php';
|
||||
|
||||
|
Antes Largura: | Altura: | Tamanho: 212 B Depois Largura: | Altura: | Tamanho: 212 B |
|
Antes Largura: | Altura: | Tamanho: 208 B Depois Largura: | Altura: | Tamanho: 208 B |
|
Antes Largura: | Altura: | Tamanho: 335 B Depois Largura: | Altura: | Tamanho: 335 B |
|
Antes Largura: | Altura: | Tamanho: 207 B Depois Largura: | Altura: | Tamanho: 207 B |
|
Antes Largura: | Altura: | Tamanho: 262 B Depois Largura: | Altura: | Tamanho: 262 B |
|
Antes Largura: | Altura: | Tamanho: 262 B Depois Largura: | Altura: | Tamanho: 262 B |
|
Antes Largura: | Altura: | Tamanho: 332 B Depois Largura: | Altura: | Tamanho: 332 B |
|
Antes Largura: | Altura: | Tamanho: 280 B Depois Largura: | Altura: | Tamanho: 280 B |
|
Antes Largura: | Altura: | Tamanho: 6.8 KiB Depois Largura: | Altura: | Tamanho: 6.8 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.4 KiB Depois Largura: | Altura: | Tamanho: 4.4 KiB |
|
Antes Largura: | Altura: | Tamanho: 6.8 KiB Depois Largura: | Altura: | Tamanho: 6.8 KiB |
|
Antes Largura: | Altura: | Tamanho: 6.8 KiB Depois Largura: | Altura: | Tamanho: 6.8 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.4 KiB Depois Largura: | Altura: | Tamanho: 4.4 KiB |
@@ -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
|
||||
*
|
||||
* Base API action
|
||||
*
|
||||
* 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 Dan Moore <dan@moore.cx>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
@@ -29,8 +27,7 @@
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009-2010 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
|
||||
*/
|
||||
|
||||
/* External API usage documentation. Please update when you change how the API works. */
|
||||
@@ -94,9 +91,7 @@
|
||||
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
class ApiValidationException extends Exception
|
||||
{
|
||||
@@ -105,16 +100,15 @@ class ApiValidationException extends Exception
|
||||
/**
|
||||
* Contains most of the Twitter-compatible API output functions.
|
||||
*
|
||||
* @category API
|
||||
* @package StatusNet
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Dan Moore <dan@moore.cx>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
* @author Toby Inkster <mail@tobyinkster.co.uk>
|
||||
* @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 Dan Moore <dan@moore.cx>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Jeffery To <jeffery.to@gmail.com>
|
||||
* @author Toby Inkster <mail@tobyinkster.co.uk>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class ApiAction extends Action
|
||||
{
|
||||
@@ -1132,7 +1126,8 @@ class ApiAction extends Action
|
||||
$twitter_list = [];
|
||||
$twitter_list['id'] = $list->id;
|
||||
$twitter_list['name'] = $list->tag;
|
||||
$twitter_list['full_name'] = '@' . $profile->nickname . '/' . $list->tag;;
|
||||
$twitter_list['full_name'] = '@' . $profile->nickname . '/' . $list->tag;
|
||||
;
|
||||
$twitter_list['slug'] = $list->tag;
|
||||
$twitter_list['description'] = $list->description;
|
||||
$twitter_list['subscriber_count'] = $list->subscriberCount();
|
||||
@@ -1459,9 +1454,11 @@ class ApiAction extends Action
|
||||
} elseif ($this->arg('screen_name')) {
|
||||
$nickname = common_canonical_nickname($this->arg('screen_name'));
|
||||
return User::getKV('nickname', $nickname);
|
||||
} else {
|
||||
} elseif ($this->scoped instanceof Profile) {
|
||||
// Fall back to trying the currently authenticated user
|
||||
return $this->scoped->getUser();
|
||||
} else {
|
||||
throw new ClientException(_('No such user.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ class Atom10Feed extends XMLStringer
|
||||
|
||||
$this->element(
|
||||
'generator', array(
|
||||
'uri' => 'https://gnu.io/social',
|
||||
'uri' => GNUSOCIAL_ENGINE_URL,
|
||||
'version' => GNUSOCIAL_VERSION
|
||||
),
|
||||
'GNU social'
|
||||
|
||||
@@ -1,35 +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
|
||||
*
|
||||
* Superclass for plugins that do "real time" updates of timelines using Ajax
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Plugin
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @copyright 2014 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 2009-2019 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();
|
||||
|
||||
/**
|
||||
* Superclass for plugin to do realtime updates
|
||||
@@ -37,13 +33,12 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
* Based on experience with the Comet and Meteor plugins,
|
||||
* this superclass extracts out some of the common functionality
|
||||
*
|
||||
* Currently depends on Favorite plugin.
|
||||
* Currently depends on the Favorite module.
|
||||
*
|
||||
* @category Plugin
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @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/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class RealtimePlugin extends Plugin
|
||||
{
|
||||
@@ -53,15 +48,17 @@ class RealtimePlugin extends Plugin
|
||||
* When it's time to initialize the plugin, calculate and
|
||||
* pass the URLs we need.
|
||||
*/
|
||||
function onInitializePlugin()
|
||||
public function onInitializePlugin()
|
||||
{
|
||||
// FIXME: need to find a better way to pass this pattern in
|
||||
$this->showurl = common_local_url('shownotice',
|
||||
array('notice' => '0000000000'));
|
||||
$this->showurl = common_local_url(
|
||||
'shownotice',
|
||||
['notice' => '0000000000']
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
function onCheckSchema()
|
||||
public function onCheckSchema()
|
||||
{
|
||||
$schema = Schema::get();
|
||||
$schema->ensureTable('realtime_channel', Realtime_channel::schemaDef());
|
||||
@@ -72,20 +69,25 @@ class RealtimePlugin extends Plugin
|
||||
* Hook for RouterInitialized event.
|
||||
*
|
||||
* @param URLMapper $m path-to-action mapper
|
||||
* @return boolean hook return
|
||||
* @return bool hook return
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('main/channel/:channelkey/keepalive',
|
||||
['action' => 'keepalivechannel'],
|
||||
['channelkey' => '[a-z0-9]{32}']);
|
||||
$m->connect('main/channel/:channelkey/close',
|
||||
['action' => 'closechannel'],
|
||||
['channelkey' => '[a-z0-9]{32}']);
|
||||
$m->connect(
|
||||
'main/channel/:channelkey/keepalive',
|
||||
['action' => 'keepalivechannel'],
|
||||
['channelkey' => '[a-z0-9]{32}']
|
||||
);
|
||||
$m->connect(
|
||||
'main/channel/:channelkey/close',
|
||||
['action' => 'closechannel'],
|
||||
['channelkey' => '[a-z0-9]{32}']
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
function onEndShowScripts($action)
|
||||
public function onEndShowScripts(Action $action)
|
||||
{
|
||||
$channel = $this->_getChannel($action);
|
||||
|
||||
@@ -93,7 +95,7 @@ class RealtimePlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
$timeline = $this->_pathToChannel(array($channel->channel_key));
|
||||
$timeline = $this->_pathToChannel([$channel->channel_key]);
|
||||
|
||||
// If there's not a timeline on this page,
|
||||
// just return true
|
||||
@@ -125,11 +127,10 @@ class RealtimePlugin extends Plugin
|
||||
|
||||
if ($action->boolean('realtime')) {
|
||||
$realtimeUI = ' RealtimeUpdate.initPopupWindow();';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$pluginPath = common_path('plugins/Realtime/');
|
||||
$keepalive = common_local_url('keepalivechannel', array('channelkey' => $channel->channel_key));
|
||||
$close = common_local_url('closechannel', array('channelkey' => $channel->channel_key));
|
||||
$keepalive = common_local_url('keepalivechannel', ['channelkey' => $channel->channel_key]);
|
||||
$close = common_local_url('closechannel', ['channelkey' => $channel->channel_key]);
|
||||
$realtimeUI = ' RealtimeUpdate.initActions('.json_encode($url).', '.json_encode($timeline).', '.json_encode($pluginPath).', '.json_encode($keepalive).', '.json_encode($close).'); ';
|
||||
}
|
||||
|
||||
@@ -144,15 +145,17 @@ class RealtimePlugin extends Plugin
|
||||
|
||||
public function onEndShowStylesheets(Action $action)
|
||||
{
|
||||
$urlpath = self::staticPath(str_replace('Plugin','',__CLASS__),
|
||||
'css/realtimeupdate.css');
|
||||
$urlpath = self::staticPath(
|
||||
str_replace('Plugin', '', __CLASS__),
|
||||
'css/realtimeupdate.css'
|
||||
);
|
||||
$action->cssLink($urlpath, null, 'screen, projection, tv');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onHandleQueuedNotice(Notice $notice)
|
||||
{
|
||||
$paths = array();
|
||||
$paths = [];
|
||||
|
||||
// Add to the author's timeline
|
||||
|
||||
@@ -165,7 +168,7 @@ class RealtimePlugin extends Plugin
|
||||
|
||||
try {
|
||||
$user = $profile->getUser();
|
||||
$paths[] = array('showstream', $user->nickname, null);
|
||||
$paths[] = ['showstream', $user->nickname, null];
|
||||
} catch (NoSuchUserException $e) {
|
||||
// We really should handle the remote profile views too
|
||||
$user = null;
|
||||
@@ -176,7 +179,7 @@ class RealtimePlugin extends Plugin
|
||||
$is_local = intval($notice->is_local);
|
||||
if ($is_local === Notice::LOCAL_PUBLIC ||
|
||||
($is_local === Notice::REMOTE && !common_config('public', 'localonly'))) {
|
||||
$paths[] = array('public', null, null);
|
||||
$paths[] = ['public', null, null];
|
||||
}
|
||||
|
||||
// Add to the tags timeline
|
||||
@@ -185,7 +188,7 @@ class RealtimePlugin extends Plugin
|
||||
|
||||
if (!empty($tags)) {
|
||||
foreach ($tags as $tag) {
|
||||
$paths[] = array('tag', $tag, null);
|
||||
$paths[] = ['tag', $tag, null];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +199,7 @@ class RealtimePlugin extends Plugin
|
||||
|
||||
foreach (array_keys($ni) as $user_id) {
|
||||
$user = User::getKV('id', $user_id);
|
||||
$paths[] = array('all', $user->nickname, null);
|
||||
$paths[] = ['all', $user->getNickname(), null];
|
||||
}
|
||||
|
||||
// Add to the replies timeline
|
||||
@@ -208,7 +211,7 @@ class RealtimePlugin extends Plugin
|
||||
while ($reply->fetch()) {
|
||||
$user = User::getKV('id', $reply->profile_id);
|
||||
if (!empty($user)) {
|
||||
$paths[] = array('replies', $user->nickname, null);
|
||||
$paths[] = ['replies', $user->getNickname(), null];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,12 +225,11 @@ class RealtimePlugin extends Plugin
|
||||
if ($gi->find()) {
|
||||
while ($gi->fetch()) {
|
||||
$ug = User_group::getKV('id', $gi->group_id);
|
||||
$paths[] = array('showgroup', $ug->nickname, null);
|
||||
$paths[] = ['showgroup', $ug->getNickname(), null];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($paths) > 0) {
|
||||
|
||||
$json = $this->noticeAsJson($notice);
|
||||
|
||||
$this->_connect();
|
||||
@@ -236,13 +238,14 @@ class RealtimePlugin extends Plugin
|
||||
// new queue item for each path
|
||||
|
||||
foreach ($paths as $path) {
|
||||
|
||||
list($action, $arg1, $arg2) = $path;
|
||||
|
||||
$channels = Realtime_channel::getAllChannels($action, $arg1, $arg2);
|
||||
$this->log(LOG_INFO, sprintf(_("%d candidate channels for notice %d"),
|
||||
count($channels),
|
||||
$notice->id));
|
||||
$this->log(LOG_INFO, sprintf(
|
||||
_("%d candidate channels for notice %d"),
|
||||
count($channels),
|
||||
$notice->id
|
||||
));
|
||||
|
||||
foreach ($channels as $channel) {
|
||||
|
||||
@@ -255,14 +258,18 @@ class RealtimePlugin extends Plugin
|
||||
$profile = Profile::getKV('id', $channel->user_id);
|
||||
}
|
||||
if ($notice->inScope($profile)) {
|
||||
$this->log(LOG_INFO,
|
||||
sprintf(_("Delivering notice %d to channel (%s, %s, %s) for user '%s'"),
|
||||
$notice->id,
|
||||
$channel->action,
|
||||
$channel->arg1,
|
||||
$channel->arg2,
|
||||
($profile) ? ($profile->nickname) : "<public>"));
|
||||
$timeline = $this->_pathToChannel(array($channel->channel_key));
|
||||
$this->log(
|
||||
LOG_INFO,
|
||||
sprintf(
|
||||
_m("Delivering notice %d to channel (%s, %s, %s) for user '%s'"),
|
||||
$notice->id,
|
||||
$channel->action,
|
||||
$channel->arg1,
|
||||
$channel->arg2,
|
||||
($profile ? $profile->getNickname() : '<public>')
|
||||
)
|
||||
);
|
||||
$timeline = $this->_pathToChannel([$channel->channel_key]);
|
||||
$this->_publish($timeline, $json);
|
||||
}
|
||||
}
|
||||
@@ -274,18 +281,23 @@ class RealtimePlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
function onStartShowBody($action)
|
||||
public function onStartShowBody(Action $action)
|
||||
{
|
||||
$realtime = $action->boolean('realtime');
|
||||
if (!$realtime) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$action->elementStart('body',
|
||||
(common_current_user()) ? array('id' => $action->trimmed('action'),
|
||||
'class' => 'user_in realtime-popup')
|
||||
: array('id' => $action->trimmed('action'),
|
||||
'class'=> 'realtime-popup'));
|
||||
$action->elementStart(
|
||||
'body',
|
||||
(common_current_user() ? [
|
||||
'id' => $action->trimmed('action'),
|
||||
'class' => 'user_in realtime-popup',
|
||||
] : [
|
||||
'id' => $action->trimmed('action'),
|
||||
'class'=> 'realtime-popup',
|
||||
])
|
||||
);
|
||||
|
||||
// XXX hack to deal with JS that tries to get the
|
||||
// root url from page output
|
||||
@@ -294,14 +306,17 @@ class RealtimePlugin extends Plugin
|
||||
|
||||
if (common_config('singleuser', 'enabled')) {
|
||||
$user = User::singleUser();
|
||||
$url = common_local_url('showstream', array('nickname' => $user->nickname));
|
||||
$url = common_local_url('showstream', ['nickname' => $user->nickname]);
|
||||
} else {
|
||||
$url = common_local_url('public');
|
||||
}
|
||||
|
||||
$action->element('a', array('class' => 'url',
|
||||
'href' => $url),
|
||||
'');
|
||||
$action->element(
|
||||
'a',
|
||||
['class' => 'url',
|
||||
'href' => $url],
|
||||
''
|
||||
);
|
||||
|
||||
$action->elementEnd('address');
|
||||
|
||||
@@ -311,7 +326,7 @@ class RealtimePlugin extends Plugin
|
||||
return false; // No default processing
|
||||
}
|
||||
|
||||
function noticeAsJson(Notice $notice)
|
||||
public function noticeAsJson(Notice $notice)
|
||||
{
|
||||
// FIXME: this code should be abstracted to a neutral third
|
||||
// party, like Notice::asJson(). I'm not sure of the ethics
|
||||
@@ -347,7 +362,7 @@ class RealtimePlugin extends Plugin
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getNoticeTags(Notice $notice)
|
||||
public function getNoticeTags(Notice $notice)
|
||||
{
|
||||
$tags = null;
|
||||
|
||||
@@ -355,7 +370,7 @@ class RealtimePlugin extends Plugin
|
||||
$nt->notice_id = $notice->id;
|
||||
|
||||
if ($nt->find()) {
|
||||
$tags = array();
|
||||
$tags = [];
|
||||
while ($nt->fetch()) {
|
||||
$tags[] = $nt->tag;
|
||||
}
|
||||
@@ -367,11 +382,13 @@ class RealtimePlugin extends Plugin
|
||||
return $tags;
|
||||
}
|
||||
|
||||
function _getScripts()
|
||||
public function _getScripts(): array
|
||||
{
|
||||
$urlpath = self::staticPath(str_replace('Plugin','',__CLASS__),
|
||||
'js/realtimeupdate.js');
|
||||
return array($urlpath);
|
||||
$urlpath = self::staticPath(
|
||||
str_replace('Plugin', '', __CLASS__),
|
||||
'js/realtimeupdate.js'
|
||||
);
|
||||
return [$urlpath];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,9 +397,10 @@ class RealtimePlugin extends Plugin
|
||||
* @param Action $action
|
||||
* @param array $messages
|
||||
*
|
||||
* @return boolean hook return value
|
||||
* @return bool hook return value
|
||||
* @throws Exception
|
||||
*/
|
||||
function onEndScriptMessages($action, &$messages)
|
||||
public function onEndScriptMessages(Action $action, array &$messages)
|
||||
{
|
||||
// TRANS: Text label for realtime view "play" button, usually replaced by an icon.
|
||||
$messages['realtime_play'] = _m('BUTTON', 'Play');
|
||||
@@ -400,40 +418,40 @@ class RealtimePlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
function _updateInitialize($timeline, $user_id)
|
||||
public function _updateInitialize($timeline, int $user_id)
|
||||
{
|
||||
return "RealtimeUpdate.init($user_id, \"$this->showurl\"); ";
|
||||
}
|
||||
|
||||
function _connect()
|
||||
public function _connect()
|
||||
{
|
||||
}
|
||||
|
||||
function _publish($timeline, $json)
|
||||
public function _publish($timeline, $json)
|
||||
{
|
||||
}
|
||||
|
||||
function _disconnect()
|
||||
public function _disconnect()
|
||||
{
|
||||
}
|
||||
|
||||
function _pathToChannel($path)
|
||||
public function _pathToChannel(array $path): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
function _getTimeline($action)
|
||||
public function _getTimeline(Action $action)
|
||||
{
|
||||
$channel = $this->_getChannel($action);
|
||||
if (empty($channel)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->_pathToChannel(array($channel->channel_key));
|
||||
return $this->_pathToChannel([$channel->channel_key]);
|
||||
}
|
||||
|
||||
function _getChannel($action)
|
||||
public function _getChannel(Action $action)
|
||||
{
|
||||
$timeline = null;
|
||||
$arg1 = null;
|
||||
@@ -478,15 +496,17 @@ class RealtimePlugin extends Plugin
|
||||
|
||||
$user_id = (!empty($user)) ? $user->id : null;
|
||||
|
||||
$channel = Realtime_channel::getChannel($user_id,
|
||||
$action_name,
|
||||
$arg1,
|
||||
$arg2);
|
||||
$channel = Realtime_channel::getChannel(
|
||||
$user_id,
|
||||
$action_name,
|
||||
$arg1,
|
||||
$arg2
|
||||
);
|
||||
|
||||
return $channel;
|
||||
}
|
||||
|
||||
function onStartReadWriteTables(&$alwaysRW, &$rwdb)
|
||||
public function onStartReadWriteTables(&$alwaysRW, &$rwdb)
|
||||
{
|
||||
$alwaysRW[] = 'realtime_channel';
|
||||
return true;
|
||||
@@ -1,48 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2011, StatusNet, Inc.
|
||||
*
|
||||
* action to close a channel
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Realtime
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
// This check helps protect against security problems;
|
||||
// your code file can't be executed directly from the web.
|
||||
exit(1);
|
||||
}
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Action to close a channel
|
||||
*
|
||||
* @category Realtime
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Action to close a channel
|
||||
*
|
||||
* @category Realtime
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class ClosechannelAction extends Action
|
||||
{
|
||||
@@ -57,7 +47,7 @@ class ClosechannelAction extends Action
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare(array $args = [])
|
||||
public function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
@@ -88,7 +78,7 @@ class ClosechannelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
$this->channel->decrement();
|
||||
|
||||
@@ -104,9 +94,9 @@ class ClosechannelAction extends Action
|
||||
*
|
||||
* @param array $args other arguments
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
* @return bool is read only action?
|
||||
*/
|
||||
function isReadOnly($args)
|
||||
public function isReadOnly($args): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -54,10 +54,10 @@ class KeepalivechannelAction extends Action
|
||||
*
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @return bool true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare(array $args = [])
|
||||
public function prepare(array $args = []): bool
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
@@ -88,7 +88,7 @@ class KeepalivechannelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
$this->channel->touch();
|
||||
|
||||
@@ -104,9 +104,9 @@ class KeepalivechannelAction extends Action
|
||||
*
|
||||
* @param array $args other arguments
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
* @return bool is read only action?
|
||||
*/
|
||||
function isReadOnly($args)
|
||||
public function isReadOnly($args): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
* @category Realtime
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -32,10 +32,9 @@ defined('GNUSOCIAL') || die();
|
||||
/**
|
||||
* A channel for real-time browser data
|
||||
*
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
class Realtime_channel extends Managed_DataObject
|
||||
{
|
||||
@@ -57,64 +56,64 @@ class Realtime_channel extends Managed_DataObject
|
||||
*/
|
||||
public static function schemaDef()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'description' => 'A channel of realtime notice data',
|
||||
'fields' => array(
|
||||
'user_id' => array('type' => 'int',
|
||||
'not null' => false,
|
||||
'description' => 'user viewing page; can be null'),
|
||||
'action' => array('type' => 'varchar',
|
||||
'length' => 191,
|
||||
'not null' => true,
|
||||
'description' => 'page being viewed'),
|
||||
'arg1' => array('type' => 'varchar',
|
||||
'length' => 191,
|
||||
'not null' => false,
|
||||
'description' => 'page argument, like username or tag'),
|
||||
'arg2' => array('type' => 'varchar',
|
||||
'length' => 191,
|
||||
'not null' => false,
|
||||
'description' => 'second page argument, like tag for showstream'),
|
||||
'channel_key' => array('type' => 'varchar',
|
||||
'length' => 32,
|
||||
'not null' => true,
|
||||
'description' => 'shared secret key for this channel'),
|
||||
'audience' => array('type' => 'int',
|
||||
'not null' => true,
|
||||
'default' => 0,
|
||||
'description' => 'reference count'),
|
||||
'created' => array('type' => 'datetime',
|
||||
'not null' => true,
|
||||
'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'datetime',
|
||||
'not null' => true,
|
||||
'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('channel_key'),
|
||||
'unique keys' => array('realtime_channel_user_page_idx' => array('user_id', 'action', 'arg1', 'arg2')),
|
||||
'foreign keys' => array(
|
||||
'realtime_channel_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'realtime_channel_modified_idx' => array('modified'),
|
||||
'realtime_channel_page_idx' => array('action', 'arg1', 'arg2')
|
||||
),
|
||||
);
|
||||
'fields' => [
|
||||
'user_id' => ['type' => 'int',
|
||||
'not null' => false,
|
||||
'description' => 'user viewing page; can be null'],
|
||||
'action' => ['type' => 'varchar',
|
||||
'length' => 191,
|
||||
'not null' => true,
|
||||
'description' => 'page being viewed'],
|
||||
'arg1' => ['type' => 'varchar',
|
||||
'length' => 191,
|
||||
'not null' => false,
|
||||
'description' => 'page argument, like username or tag'],
|
||||
'arg2' => ['type' => 'varchar',
|
||||
'length' => 191,
|
||||
'not null' => false,
|
||||
'description' => 'second page argument, like tag for showstream'],
|
||||
'channel_key' => ['type' => 'varchar',
|
||||
'length' => 32,
|
||||
'not null' => true,
|
||||
'description' => 'shared secret key for this channel'],
|
||||
'audience' => ['type' => 'int',
|
||||
'not null' => true,
|
||||
'default' => 0,
|
||||
'description' => 'reference count'],
|
||||
'created' => ['type' => 'datetime',
|
||||
'not null' => true,
|
||||
'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'datetime',
|
||||
'not null' => true,
|
||||
'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['channel_key'],
|
||||
'unique keys' => ['realtime_channel_user_page_idx' => ['user_id', 'action', 'arg1', 'arg2']],
|
||||
'foreign keys' => [
|
||||
'realtime_channel_user_id_fkey' => ['user', ['user_id' => 'id']],
|
||||
],
|
||||
'indexes' => [
|
||||
'realtime_channel_modified_idx' => ['modified'],
|
||||
'realtime_channel_page_idx' => ['action', 'arg1', 'arg2']
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public static function saveNew($user_id, $action, $arg1, $arg2)
|
||||
public static function saveNew(int $user_id, Action $action, $arg1, $arg2): Realtime_channel
|
||||
{
|
||||
$channel = new Realtime_channel();
|
||||
|
||||
$channel->user_id = $user_id;
|
||||
$channel->action = $action;
|
||||
$channel->arg1 = $arg1;
|
||||
$channel->arg2 = $arg2;
|
||||
$channel->audience = 1;
|
||||
$channel->action = $action;
|
||||
$channel->arg1 = $arg1;
|
||||
$channel->arg2 = $arg2;
|
||||
$channel->audience = 1;
|
||||
|
||||
$channel->channel_key = common_random_hexstr(16); // 128-bit key, 32 hex chars
|
||||
|
||||
$channel->created = common_sql_now();
|
||||
$channel->created = common_sql_now();
|
||||
$channel->modified = $channel->created;
|
||||
|
||||
$channel->insert();
|
||||
@@ -122,7 +121,7 @@ class Realtime_channel extends Managed_DataObject
|
||||
return $channel;
|
||||
}
|
||||
|
||||
public static function getChannel($user_id, $action, $arg1, $arg2)
|
||||
public static function getChannel(int $user_id, Action $action, $arg1, $arg2): Realtime_channel
|
||||
{
|
||||
$channel = self::fetchChannel($user_id, $action, $arg1, $arg2);
|
||||
|
||||
@@ -143,7 +142,7 @@ class Realtime_channel extends Managed_DataObject
|
||||
return $channel;
|
||||
}
|
||||
|
||||
public static function getAllChannels($action, $arg1, $arg2)
|
||||
public static function getAllChannels(Action $action, $arg1, $arg2): array
|
||||
{
|
||||
$channel = new Realtime_channel();
|
||||
|
||||
@@ -172,7 +171,7 @@ class Realtime_channel extends Managed_DataObject
|
||||
return $channels;
|
||||
}
|
||||
|
||||
public static function fetchChannel($user_id, $action, $arg1, $arg2)
|
||||
public static function fetchChannel(int $user_id, Action $action, $arg1, $arg2): ?Realtime_channel
|
||||
{
|
||||
$channel = new Realtime_channel();
|
||||
|
||||
@@ -204,7 +203,7 @@ class Realtime_channel extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
public function increment()
|
||||
public function increment(): void
|
||||
{
|
||||
// XXX: race
|
||||
$orig = clone($this);
|
||||
@@ -213,7 +212,7 @@ class Realtime_channel extends Managed_DataObject
|
||||
$this->update($orig);
|
||||
}
|
||||
|
||||
public function touch()
|
||||
public function touch(): void
|
||||
{
|
||||
// XXX: race
|
||||
$orig = clone($this);
|
||||
@@ -221,7 +220,7 @@ class Realtime_channel extends Managed_DataObject
|
||||
$this->update($orig);
|
||||
}
|
||||
|
||||
public function decrement()
|
||||
public function decrement(): void
|
||||
{
|
||||
// XXX: race
|
||||
if ($this->audience == 1) {
|
||||