Browse Source

Directory moved

pull/3910/head
Michael 4 years ago
parent
commit
925d2d2383
  1. 2
      include/Contact.php
  2. 2
      include/api.php
  3. 45
      include/directory.php
  4. 4
      mod/admin.php
  5. 4
      mod/profile_photo.php
  6. 2
      mod/profiles.php
  7. 2
      mod/register.php
  8. 2
      mod/regmod.php
  9. 2
      mod/settings.php
  10. 53
      src/Worker/Directory.php

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

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

45
include/directory.php

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

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

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

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

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

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

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

53
src/Worker/Directory.php

@ -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']);
}
}
}
}
Loading…
Cancel
Save