mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-24 23:43:42 +00:00
Merge pull request #759 from MrPetovan/task/move-dbstructure-to-php
[various] Move dbstructure to php
This commit is contained in:
commit
229cf2304f
2 changed files with 8 additions and 10 deletions
|
@ -39,7 +39,6 @@ use Friendica\Content\Text\Markdown;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Cache;
|
use Friendica\Core\Cache;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBStructure;
|
use Friendica\Database\DBStructure;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
@ -47,7 +46,6 @@ use Friendica\Model\Term;
|
||||||
use Friendica\Module\Login;
|
use Friendica\Module\Login;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Security;
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Symfony\Component\ExpressionLanguage;
|
use Symfony\Component\ExpressionLanguage;
|
||||||
|
@ -91,7 +89,7 @@ function advancedcontentfilter_dbstructure_definition(App $a, &$database)
|
||||||
"expression" => ["type" => "mediumtext" , "not null" => "1", "comment" => "Expression text"],
|
"expression" => ["type" => "mediumtext" , "not null" => "1", "comment" => "Expression text"],
|
||||||
"serialized" => ["type" => "mediumtext" , "not null" => "1", "comment" => "Serialized parsed expression"],
|
"serialized" => ["type" => "mediumtext" , "not null" => "1", "comment" => "Serialized parsed expression"],
|
||||||
"active" => ["type" => "boolean" , "not null" => "1", "default" => "1", "comment" => "Whether the rule is active or not"],
|
"active" => ["type" => "boolean" , "not null" => "1", "default" => "1", "comment" => "Whether the rule is active or not"],
|
||||||
"created" => ["type" => "datetime" , "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
|
"created" => ["type" => "datetime" , "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Creation date"],
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
"PRIMARY" => ["id"],
|
"PRIMARY" => ["id"],
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
|
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Security;
|
|
||||||
|
|
||||||
function public_server_install()
|
function public_server_install()
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ function public_server_uninstall()
|
||||||
Addon::unregisterHook('logged_in', 'addon/public_server/public_server.php', 'public_server_login');
|
Addon::unregisterHook('logged_in', 'addon/public_server/public_server.php', 'public_server_login');
|
||||||
}
|
}
|
||||||
|
|
||||||
function public_server_load_config(\Friendica\App $a)
|
function public_server_load_config(App $a)
|
||||||
{
|
{
|
||||||
$a->loadConfigFile(__DIR__. '/config/public_server.ini.php');
|
$a->loadConfigFile(__DIR__. '/config/public_server.ini.php');
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ function public_server_cron($a, $b)
|
||||||
$r = q("SELECT * FROM `user` WHERE `account_expires_on` < UTC_TIMESTAMP() + INTERVAL 5 DAY AND
|
$r = q("SELECT * FROM `user` WHERE `account_expires_on` < UTC_TIMESTAMP() + INTERVAL 5 DAY AND
|
||||||
`account_expires_on` > '%s' AND
|
`account_expires_on` > '%s' AND
|
||||||
`expire_notification_sent` <= '%s'",
|
`expire_notification_sent` <= '%s'",
|
||||||
DBA::escape(NULL_DATE), DBA::escape(NULL_DATE));
|
DBA::NULL_DATETIME, DBA::NULL_DATETIME);
|
||||||
|
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
|
@ -83,7 +83,7 @@ function public_server_cron($a, $b)
|
||||||
$nologin = Config::get('public_server', 'nologin', false);
|
$nologin = Config::get('public_server', 'nologin', false);
|
||||||
if ($nologin) {
|
if ($nologin) {
|
||||||
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` <= '%s' AND `register_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s'",
|
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` <= '%s' AND `register_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s'",
|
||||||
DBA::escape(NULL_DATE), intval($nologin), DBA::escape(NULL_DATE));
|
DBA::NULL_DATETIME, intval($nologin), DBA::NULL_DATETIME);
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
||||||
|
@ -95,7 +95,7 @@ function public_server_cron($a, $b)
|
||||||
$flagusers = Config::get('public_server', 'flagusers', false);
|
$flagusers = Config::get('public_server', 'flagusers', false);
|
||||||
if ($flagusers) {
|
if ($flagusers) {
|
||||||
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s' AND `page-flags` = 0",
|
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s' AND `page-flags` = 0",
|
||||||
intval($flagusers), DBA::escape(NULL_DATE));
|
intval($flagusers), DBA::NULL_DATETIME);
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
||||||
|
@ -108,7 +108,7 @@ function public_server_cron($a, $b)
|
||||||
$flagpostsexpire = Config::get('public_server', 'flagpostsexpire');
|
$flagpostsexpire = Config::get('public_server', 'flagpostsexpire');
|
||||||
if ($flagposts && $flagpostsexpire) {
|
if ($flagposts && $flagpostsexpire) {
|
||||||
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s' and `expire` = 0 AND `page-flags` = 0",
|
$r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s' and `expire` = 0 AND `page-flags` = 0",
|
||||||
intval($flagposts), DBA::escape(NULL_DATE));
|
intval($flagposts), DBA::NULL_DATETIME);
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
DBA::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]);
|
DBA::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]);
|
||||||
|
@ -138,7 +138,7 @@ function public_server_login($a, $b)
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['account_expires_on' => DateTimeFormat::utc('now +' . $days . ' days')];
|
$fields = ['account_expires_on' => DateTimeFormat::utc('now +' . $days . ' days')];
|
||||||
$condition = ["`uid` = ? AND `account_expires_on` > ?", local_user(), NULL_DATE];
|
$condition = ["`uid` = ? AND `account_expires_on` > ?", local_user(), DBA::NULL_DATETIME];
|
||||||
DBA::update('user', $fields, $condition);
|
DBA::update('user', $fields, $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue