function handle($notice)
 {
     $mirror = new SubMirror();
     $mirror->subscribed = $notice->profile_id;
     if ($mirror->find()) {
         while ($mirror->fetch()) {
             $mirror->mirrorNotice($notice);
         }
     }
     return true;
 }
Пример #2
0
 /**
  * Show the form for OpenID management
  *
  * We have one form with a few different submit buttons to do different things.
  *
  * @return void
  */
 function showContent()
 {
     $user = common_current_user();
     $this->showAddFeedForm();
     $mirror = new SubMirror();
     $mirror->subscriber = $user->id;
     if ($mirror->find()) {
         while ($mirror->fetch()) {
             $this->showFeedForm($mirror);
         }
     }
 }
Пример #3
0
 function handle($notice)
 {
     $mirror = new SubMirror();
     $mirror->subscribed = $notice->profile_id;
     if ($mirror->find()) {
         while ($mirror->fetch()) {
             try {
                 $mirror->mirrorNotice($notice);
             } catch (Exception $e) {
                 common_log(LOG_ERR, "Exception trying to mirror notice {$notice->id} " . "for subscriber {$mirror->subscriber} ({$mirror->style}): " . $e->getMessage());
             }
         }
     }
     return true;
 }
Пример #4
0
 function __construct($action, $profile)
 {
     parent::__construct($action);
     $this->profile = clone $profile;
     $this->user = common_current_user();
     $this->mirror = SubMirror::pkeyGet(array('subscriber' => $this->user->id, 'subscribed' => $this->profile->id));
 }
Пример #5
0
 function saveMirror()
 {
     if ($this->oprofile->subscribe()) {
         SubMirror::saveMirror($this->user, $this->profile);
     } else {
         $this->serverError(_m("Could not subscribe to feed."));
     }
 }
Пример #6
0
 function saveMirror()
 {
     if ($this->oprofile->subscribe()) {
         SubMirror::saveMirror($this->user, $this->profile);
     } else {
         // TRANS: Exception thrown when a subscribing to a feed fails.
         $this->serverError(_m('Could not subscribe to feed.'));
     }
 }
Пример #7
0
 /**
  * Show the form for OpenID management
  *
  * We have one form with a few different submit buttons to do different things.
  *
  * @return void
  */
 function showContent()
 {
     $provider = $this->trimmed('provider');
     if (!empty($provider) || GNUsocial::isAjax()) {
         $this->showAddFeedForm($provider);
     } else {
         $this->elementStart('div', array('id' => 'add-mirror'));
         $this->showAddWizard();
         $this->elementEnd('div');
         $mirror = new SubMirror();
         $mirror->subscriber = $this->scoped->getID();
         if ($mirror->find()) {
             while ($mirror->fetch()) {
                 $this->showFeedForm($mirror);
             }
         }
     }
 }
Пример #8
0
 /**
  * Show the form for OpenID management
  *
  * We have one form with a few different submit buttons to do different things.
  *
  * @return void
  */
 function showContent()
 {
     $user = common_current_user();
     $provider = $this->trimmed('provider');
     if ($provider) {
         $this->showAddFeedForm($provider);
     } else {
         $this->elementStart('div', array('id' => 'add-mirror'));
         $this->showAddWizard();
         $this->elementEnd('div');
         $mirror = new SubMirror();
         $mirror->subscriber = $user->id;
         if ($mirror->find()) {
             while ($mirror->fetch()) {
                 $this->showFeedForm($mirror);
             }
         }
     }
 }
Пример #9
0
 function saveMirror()
 {
     $mirror = SubMirror::getMirror($this->user, $this->profile);
     if (!$mirror) {
         $this->clientError(_m('Requested edit of missing mirror'));
     }
     if ($this->delete) {
         $mirror->delete();
         $oprofile = Ostatus_profile::staticGet('profile_id', $this->profile->id);
         if ($oprofile) {
             $oprofile->garbageCollect();
         }
     } else {
         if ($this->style != $mirror->style) {
             $orig = clone $mirror;
             $mirror->style = $this->style;
             $mirror->modified = common_sql_now();
             $mirror->update($orig);
         }
     }
 }
Пример #10
0
 function saveMirror()
 {
     $mirror = SubMirror::getMirror($this->user, $this->profile);
     if (!$mirror) {
         // TRANS: Client error thrown when a mirror request is made and no result is retrieved.
         $this->clientError(_m('Requested edit of missing mirror.'));
     }
     if ($this->delete) {
         $mirror->delete();
         $oprofile = Ostatus_profile::staticGet('profile_id', $this->profile->id);
         if ($oprofile) {
             $oprofile->garbageCollect();
         }
     } else {
         if ($this->style != $mirror->style) {
             $orig = clone $mirror;
             $mirror->style = $this->style;
             $mirror->modified = common_sql_now();
             $mirror->update($orig);
         }
     }
 }
Пример #11
0
 /**
  * Add a count of mirrored feeds into a user's profile sidebar stats.
  *
  * @param Profile $profile
  * @param array $stats
  * @return boolean hook return value
  */
 function onProfileStats($profile, &$stats)
 {
     $cur = common_current_user();
     if (!empty($cur) && $cur->id == $profile->id) {
         $mirror = new SubMirror();
         $mirror->subscriber = $profile->id;
         $entry = array('id' => 'mirrors', 'label' => _m('Mirrored feeds'), 'link' => common_local_url('mirrorsettings'), 'value' => $mirror->count());
         $insertAt = count($stats);
         foreach ($stats as $i => $row) {
             if ($row['id'] == 'groups') {
                 // Slip us in after them.
                 $insertAt = $i + 1;
                 break;
             }
         }
         array_splice($stats, $insertAt, 0, array($entry));
     }
     return true;
 }
Пример #12
0
 /**
  * @param Profile $subscribed
  * @param Profile $subscribed
  * @return SubMirror
  * @throws ServerException
  */
 public static function saveMirror($subscriber, $subscribed, $style = 'repeat')
 {
     // @fixme make sure they're subscribed!
     $mirror = new SubMirror();
     $mirror->subscriber = $subscriber->id;
     $mirror->subscribed = $subscribed->id;
     $mirror->style = $style;
     $mirror->created = common_sql_now();
     $mirror->modified = common_sql_now();
     $mirror->insert();
     return $mirror;
 }
Пример #13
0
 /**
  * Let the OStatus subscription garbage collection know if we're
  * making use of a remote feed, so it doesn't get dropped out
  * from under us.
  *
  * @param Ostatus_profile $oprofile
  * @param int $count in/out
  * @return mixed hook return value
  */
 function onOstatus_profileSubscriberCount($oprofile, &$count)
 {
     if ($oprofile->profile_id) {
         $mirror = new SubMirror();
         $mirror->subscribed = $oprofile->profile_id;
         if ($mirror->find()) {
             while ($mirror->fetch()) {
                 $count++;
             }
         }
     }
     return true;
 }
Пример #14
0
 protected function saveMirror()
 {
     $this->oprofile->subscribe();
     SubMirror::saveMirror($this->user, $this->profile);
 }