From ed74a9f470dc96798680f6ae23664943838653ee Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 17 May 2014 17:14:58 +0200 Subject: [PATCH] Fixed scripts I haven't updated these in a loooong time... --- scripts/find-posts.php | 19 ++++++------------- scripts/process-detached-files.php | 12 +++++++----- scripts/process-old-users.php | 23 +++++++++++++++-------- src/Access.php | 4 ---- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/scripts/find-posts.php b/scripts/find-posts.php index 25fd64dc..c19b8fdc 100644 --- a/scripts/find-posts.php +++ b/scripts/find-posts.php @@ -1,26 +1,19 @@ id, - $post->name, - Model_Post::getFullPath($post->name), - $post->mimeType, + $post->getId(), + $post->getName(), + $post->tryGetWorkingFullPath(), + $post->getMimeType(), ]). PHP_EOL; } diff --git a/scripts/process-detached-files.php b/scripts/process-detached-files.php index 7ccdb058..8a9551a9 100644 --- a/scripts/process-detached-files.php +++ b/scripts/process-detached-files.php @@ -1,6 +1,8 @@ name; + $names []= $post->getName(); } $names = array_flip($names); -$config = getConfig(); +$config = Core::getConfig(); foreach (glob(TextHelper::absolutePath($config->main->filesPath) . DS . '*') as $name) { $name = basename($name); diff --git a/scripts/process-old-users.php b/scripts/process-old-users.php index 7bb227ea..95bbed06 100644 --- a/scripts/process-old-users.php +++ b/scripts/process-old-users.php @@ -1,6 +1,8 @@ id . PHP_EOL; - echo 'Name: ' . $user->name . PHP_EOL; - echo 'E-mail: ' . $user->email_unconfirmed . PHP_EOL; - echo 'Date joined: ' . date('Y-m-d H:i:s', $user->join_date) . PHP_EOL; + echo 'ID: ' . $user->getId() . PHP_EOL; + echo 'Name: ' . $user->getName() . PHP_EOL; + echo 'E-mail: ' . $user->getUnconfirmedEmail() . PHP_EOL; + echo 'Date joined: ' . date('Y-m-d H:i:s', $user->getJoinTime()) . PHP_EOL; echo PHP_EOL; } @@ -32,7 +34,7 @@ switch ($action) $func = function($user) { printUser($user); - Model_User::remove($user); + UserModel::remove($user); }; break; @@ -40,8 +42,13 @@ switch ($action) die('Unknown action' . PHP_EOL); } -$rows = R::find('user', 'email_confirmed IS NULL AND DATETIME(join_date) < DATETIME("now", "-21 days")'); -foreach ($rows as $user) +$users = UserSearchService::getEntities(null, null, null); +foreach ($users as $user) { - $func($user); + if (!$user->getConfirmedEmail() + and !$user->getLastLoginTime() + and ((time() - $user->getJoinTime()) > 21 * 24 * 60 * 60)) + { + $func($user); + } } diff --git a/src/Access.php b/src/Access.php index 574f9eb0..290a3230 100644 --- a/src/Access.php +++ b/src/Access.php @@ -25,10 +25,6 @@ class Access self::$privileges[$privilegeName][$subPrivilegeName] = $minAccessRank; } - - //todo: move to scripts etc. - #if (php_sapi_name() == 'cli') - # self::disablePrivilegeChecking(); } public static function check(Privilege $privilege, $user = null)