]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/scripts/update_ostatus_profiles.php
Merged
[quix0rs-gnu-social.git] / plugins / OStatus / scripts / update_ostatus_profiles.php
old mode 100644 (file)
new mode 100755 (executable)
index dc8232e..1f70bac
@@ -20,8 +20,8 @@
 
 define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
 
-$shortoptions = 'u:a';
-$longoptions = array('uri=', 'all');
+$shortoptions = 'u:af';
+$longoptions = array('uri=', 'all', 'force');
 
 $helptext = <<<UPDATE_OSTATUS_PROFILES
 update_ostatus_profiles.php [options]
@@ -32,10 +32,11 @@ you have no backup.
     -u --uri OStatus profile URI to update
     -a --all update all
 
+    -f --force  Force update (despite identical avatar URLs etc.)
 
 UPDATE_OSTATUS_PROFILES;
 
-require_once INSTALLDIR . '/scripts/commandline.inc';
+require_once INSTALLDIR . '/scripts/commandline.inc.php';
 
 /*
  * Hacky class to remove some checks and get public access to
@@ -53,7 +54,7 @@ class LooseOstatusProfile extends Ostatus_profile
      * @throws Exception on various error conditions
      * @throws OStatusShadowException if this reference would obscure a local user/group
      */
-    public static function updateProfileURL($profile_url, $hints=array())
+    public static function updateProfileURL($profile_url, array $hints=array())
     {
         $oprofile = null;
 
@@ -206,10 +207,11 @@ class LooseOstatusProfile extends Ostatus_profile
 function pullOstatusProfile($uri) {
 
     $oprofile = null;
+    $validate = new Validate();
 
-    if (Validate::email($uri)) {
+    if ($validate->email($uri)) {
         $oprofile = LooseOstatusProfile::updateWebfinger($uri);
-    } else if (Validate::uri($uri)) {
+    } else if ($validate->uri($uri)) {
         $oprofile = LooseOstatusProfile::updateProfileURL($uri);
     } else {
         print "Sorry, we could not reach the address: $uri\n";
@@ -230,6 +232,8 @@ if (have_option('u', 'uri')) {
     exit(1);
 }
 
+$forceUpdates = have_option('f', 'force');
+
 $cnt = $lop->find();
 
 if (!empty($cnt)) {
@@ -252,7 +256,7 @@ while($lop->fetch()) {
             $orig = clone($lop);
             $lop->avatar = $oprofile->avatar;
             $lop->update($orig);
-            $lop->updateAvatar($oprofile->avatar);
+            $lop->updateAvatar($oprofile->avatar, $forceUpdates);
             if (!$quiet) { print "Done.\n"; }
         }
     } catch (Exception $e) {