]> git.mxchange.org Git - friendica.git/commitdiff
Resubmit all profiles on directory change
authorMichael <heluecht@pirati.ca>
Mon, 17 Apr 2017 21:39:11 +0000 (21:39 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 17 Apr 2017 21:39:11 +0000 (21:39 +0000)
include/directory.php
mod/admin.php

index 088adbe789fd1fcfea3132cda0285fb8ccc88ab9..4a221fac0c3565ca2b598403e8131c0f084d7a6b 100644 (file)
@@ -2,16 +2,17 @@
 use \Friendica\Core\Config;
 
 function directory_run(&$argv, &$argc){
-       if ($argc != 2) {
-               return;
-       }
-
        $dir = get_config('system', 'directory');
 
        if (!strlen($dir)) {
                return;
        }
 
+       if ($argc < 2) {
+               directory_update_all();
+               return;
+       }
+
        $dir .= "/submit";
 
        $arr = array('url' => $argv[1]);
@@ -24,3 +25,17 @@ function directory_run(&$argv, &$argc){
        }
        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) {
+                       proc_run(PRIORITY_LOW, 'include/directory.php', $user['url']);
+               }
+       }
+}
index fb463d31c014d6dd94e030d5f5bd341c2ee16d0c..fe89faf4434d79649e1dba4a063518e297d11ef2 100644 (file)
@@ -668,6 +668,12 @@ function admin_page_site_post(App $a) {
        $worker_fastlane        =       ((x($_POST,'worker_fastlane'))          ? True                                          : False);
        $worker_frontend        =       ((x($_POST,'worker_frontend'))          ? True                                          : False);
 
+       // Has the directory url changed? If yes, then resubmit the existing profiles there
+       if ($global_directory != Config::get('system', 'directory') AND ($global_directory != '')) {
+               Config::set('system', 'directory', $global_directory);
+               proc_run(PRIORITY_LOW, 'include/directory.php');
+       }
+
        if ($a->get_path() != "") {
                $diaspora_enabled = false;
        }
@@ -771,7 +777,6 @@ function admin_page_site_post(App $a) {
        set_config('system', 'allowed_email', $allowed_email);
        set_config('system', 'block_public', $block_public);
        set_config('system', 'publish_all', $force_publish);
-       set_config('system', 'directory', $global_directory);
        set_config('system', 'thread_allow', $thread_allow);
        set_config('system', 'newuser_private', $newuser_private);
        set_config('system', 'enotify_no_content', $enotify_no_content);