From 925d2d2383dc5c3a4adb07985bd4058cd79b0ee0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 18 Nov 2017 07:59:30 +0000 Subject: [PATCH] Directory moved --- include/Contact.php | 2 +- include/api.php | 2 +- include/directory.php | 45 ---------------------------------- mod/admin.php | 4 +-- mod/profile_photo.php | 4 +-- mod/profiles.php | 2 +- mod/register.php | 2 +- mod/regmod.php | 2 +- mod/settings.php | 2 +- src/Worker/Directory.php | 53 ++++++++++++++++++++++++++++++++++++++++ 10 files changed, 63 insertions(+), 55 deletions(-) delete mode 100644 include/directory.php create mode 100644 src/Worker/Directory.php diff --git a/include/Contact.php b/include/Contact.php index 60bef93a5a..636bbc4a7a 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -37,7 +37,7 @@ function user_remove($uid) { Worker::add(PRIORITY_HIGH, "notifier", "removeme", $uid); // Send an update to the directory - Worker::add(PRIORITY_LOW, "directory", $r['url']); + Worker::add(PRIORITY_LOW, "Directory", $r['url']); if($uid == local_user()) { unset($_SESSION['authenticated']); diff --git a/include/api.php b/include/api.php index 33624dcf6e..69569bdc18 100644 --- a/include/api.php +++ b/include/api.php @@ -3870,7 +3870,7 @@ function api_account_update_profile_image($type) //$user = api_get_user(get_app()); $url = System::baseUrl() . '/profile/' . get_app()->user['nickname']; if ($url && strlen(Config::get('system', 'directory'))) { - Worker::add(PRIORITY_LOW, "directory", $url); + Worker::add(PRIORITY_LOW, "Directory", $url); } Worker::add(PRIORITY_LOW, 'profile_update', api_user()); diff --git a/include/directory.php b/include/directory.php deleted file mode 100644 index f56e8dbaa4..0000000000 --- a/include/directory.php +++ /dev/null @@ -1,45 +0,0 @@ - $argv[1]); - - call_hooks('globaldir_update', $arr); - - logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG); - if (strlen($arr['url'])) { - fetch_url($dir . '?url=' . bin2hex($arr['url'])); - } - - return; -} - -function directory_update_all() { - $r = q("SELECT `url` FROM `contact` - INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid` - INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` - WHERE `contact`.`self` AND `profile`.`net-publish` AND `profile`.`is-default` AND - NOT `user`.`account_expired` AND `user`.`verified`"); - - if (DBM::is_result($r)) { - foreach ($r AS $user) { - Worker::add(PRIORITY_LOW, 'directory', $user['url']); - } - } -} diff --git a/mod/admin.php b/mod/admin.php index 78e37afef6..cda6d1a3b0 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -705,7 +705,7 @@ function admin_page_site_post(App $a) { check_form_security_token_redirectOnErr('/admin/site', 'admin_site'); if (!empty($_POST['republish_directory'])) { - Worker::add(PRIORITY_LOW, 'directory'); + Worker::add(PRIORITY_LOW, 'Directory'); return; } @@ -867,7 +867,7 @@ function admin_page_site_post(App $a) { // Has the directory url changed? If yes, then resubmit the existing profiles there if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) { Config::set('system', 'directory', $global_directory); - Worker::add(PRIORITY_LOW, 'directory'); + Worker::add(PRIORITY_LOW, 'Directory'); } if ($a->get_path() != "") { diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 5f52451414..3ef0118da0 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -132,7 +132,7 @@ function profile_photo_post(App $a) { // Update global directory in background $url = System::baseUrl() . '/profile/' . $a->user['nickname']; if ($url && strlen(Config::get('system','directory'))) { - Worker::add(PRIORITY_LOW, "directory", $url); + Worker::add(PRIORITY_LOW, "Directory", $url); } Worker::add(PRIORITY_LOW, 'profile_update', local_user()); @@ -232,7 +232,7 @@ function profile_photo_content(App $a) { // Update global directory in background $url = $_SESSION['my_url']; if ($url && strlen(Config::get('system','directory'))) { - Worker::add(PRIORITY_LOW, "directory", $url); + Worker::add(PRIORITY_LOW, "Directory", $url); } goaway(System::baseUrl() . '/profiles'); diff --git a/mod/profiles.php b/mod/profiles.php index 4263897d0b..545fb2fc78 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -503,7 +503,7 @@ function profiles_post(App $a) { // Update global directory in background $url = $_SESSION['my_url']; if ($url && strlen(Config::get('system', 'directory'))) { - Worker::add(PRIORITY_LOW, "directory", $url); + Worker::add(PRIORITY_LOW, "Directory", $url); } Worker::add(PRIORITY_LOW, 'profile_update', local_user()); diff --git a/mod/register.php b/mod/register.php index 4d0ef96485..cd6385144c 100644 --- a/mod/register.php +++ b/mod/register.php @@ -72,7 +72,7 @@ function register_post(App $a) { if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) { $url = System::baseUrl() . '/profile/' . $user['nickname']; - Worker::add(PRIORITY_LOW, "directory", $url); + Worker::add(PRIORITY_LOW, "Directory", $url); } $using_invites = Config::get('system','invitation_only'); diff --git a/mod/regmod.php b/mod/regmod.php index d6e122a286..6d76e7ea7e 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -45,7 +45,7 @@ function user_allow($hash) { if (DBM::is_result($r) && $r[0]['net-publish']) { $url = System::baseUrl() . '/profile/' . $user[0]['nickname']; if ($url && strlen(Config::get('system','directory'))) { - Worker::add(PRIORITY_LOW, "directory", $url); + Worker::add(PRIORITY_LOW, "Directory", $url); } } diff --git a/mod/settings.php b/mod/settings.php index e693f77595..c0b3d2cc16 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -645,7 +645,7 @@ function settings_post(App $a) { // Update global directory in background $url = $_SESSION['my_url']; if ($url && strlen(Config::get('system', 'directory'))) { - Worker::add(PRIORITY_LOW, "directory", $url); + Worker::add(PRIORITY_LOW, "Directory", $url); } } diff --git a/src/Worker/Directory.php b/src/Worker/Directory.php new file mode 100644 index 0000000000..8e5383ac0c --- /dev/null +++ b/src/Worker/Directory.php @@ -0,0 +1,53 @@ + $argv[1]); + + call_hooks('globaldir_update', $arr); + + logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG); + if (strlen($arr['url'])) { + fetch_url($dir . '?url=' . bin2hex($arr['url'])); + } + + return; + } + + private static function updateAll() { + $r = q("SELECT `url` FROM `contact` + INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid` + INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` + WHERE `contact`.`self` AND `profile`.`net-publish` AND `profile`.`is-default` AND + NOT `user`.`account_expired` AND `user`.`verified`"); + + if (DBM::is_result($r)) { + foreach ($r AS $user) { + Worker::add(PRIORITY_LOW, 'Directory', $user['url']); + } + } + } +}