]> git.mxchange.org Git - friendica.git/blob - src/Worker/Directory.php
Use short form array syntax everywhere
[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\Config;
10 use Friendica\Core\Worker;
11 use Friendica\Database\DBM;
12
13 class Directory {
14         public static function execute($url = '') {
15                 $dir = Config::get('system', 'directory');
16
17                 if (!strlen($dir)) {
18                         return;
19                 }
20
21                 if ($url == '') {
22                         self::updateAll();
23                         return;
24                 }
25
26                 $dir .= "/submit";
27
28                 $arr = ['url' => $url];
29
30                 call_hooks('globaldir_update', $arr);
31
32                 logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
33                 if (strlen($arr['url'])) {
34                         fetch_url($dir . '?url=' . bin2hex($arr['url']));
35                 }
36
37                 return;
38         }
39
40         private static function updateAll() {
41                 $r = q("SELECT `url` FROM `contact`
42                         INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
43                         INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
44                                 WHERE `contact`.`self` AND `profile`.`net-publish` AND `profile`.`is-default` AND
45                                         NOT `user`.`account_expired` AND `user`.`verified`");
46
47                 if (DBM::is_result($r)) {
48                         foreach ($r AS $user) {
49                                 Worker::add(PRIORITY_LOW, 'Directory', $user['url']);
50                         }
51                 }
52         }
53 }