]> git.mxchange.org Git - friendica.git/blob - src/Worker/Directory.php
Just some more fixed notice
[friendica.git] / src / Worker / Directory.php
1 <?php
2 /**
3  * @file src/Worker/Directory.php
4  * @brief Sends updated profile data to the directory
5  */
6
7 namespace Friendica\Worker;
8
9 use Friendica\Core\Addon;
10 use Friendica\Core\Config;
11 use Friendica\Core\Worker;
12 use Friendica\Database\DBM;
13 use Friendica\Util\Network;
14
15 class Directory
16 {
17         public static function execute($url = '')
18         {
19                 $dir = Config::get('system', 'directory');
20
21                 if (!strlen($dir)) {
22                         return;
23                 }
24
25                 if ($url == '') {
26                         self::updateAll();
27                         return;
28                 }
29
30                 $dir .= "/submit";
31
32                 $arr = ['url' => $url];
33
34                 Addon::callHooks('globaldir_update', $arr);
35
36                 logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
37                 if (strlen($arr['url'])) {
38                         Network::fetchUrl($dir . '?url=' . bin2hex($arr['url']));
39                 }
40
41                 return;
42         }
43
44         private static function updateAll() {
45                 $r = q("SELECT `url` FROM `contact`
46                         INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
47                         INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
48                                 WHERE `contact`.`self` AND `profile`.`net-publish` AND `profile`.`is-default` AND
49                                         NOT `user`.`account_expired` AND `user`.`verified`");
50
51                 if (DBM::is_result($r)) {
52                         foreach ($r AS $user) {
53                                 Worker::add(PRIORITY_LOW, 'Directory', $user['url']);
54                         }
55                 }
56         }
57 }