Directory moved

This commit is contained in:
Michael 2017-11-18 07:59:30 +00:00
parent 2515d02e6d
commit 925d2d2383
10 changed files with 63 additions and 55 deletions

View File

@ -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']);

View File

@ -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());

View File

@ -1,45 +0,0 @@
<?php
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
function directory_run(&$argv, &$argc){
$dir = Config::get('system', 'directory');
if (!strlen($dir)) {
return;
}
if ($argc < 2) {
directory_update_all();
return;
}
$dir .= "/submit";
$arr = array('url' => $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']);
}
}
}

View File

@ -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() != "") {

View File

@ -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');

View File

@ -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());

View File

@ -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');

View File

@ -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);
}
}

View File

@ -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);
}
}

53
src/Worker/Directory.php Normal file
View File

@ -0,0 +1,53 @@
<?php
/**
* @file src/Worker/Directory.php
* @brief Sends updated profile data to the directory
*/
namespace Friendica\Worker;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
class Directory {
public static function execute($url = '') {
$dir = Config::get('system', 'directory');
if (!strlen($dir)) {
return;
}
if ($url == '') {
self::updateAll();
return;
}
$dir .= "/submit";
$arr = array('url' => $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']);
}
}
}
}