Exemplo n.º 1
0
 function saveNoticeFromActivity($activity, $actor, $options = array())
 {
     if (count($activity->objects) != 1) {
         // TRANS: Exception thrown when there are too many activity objects.
         throw new ClientException(_m('Too many activity objects.'));
     }
     $entryObj = $activity->objects[0];
     if ($entryObj->type != Blog_entry::TYPE) {
         // TRANS: Exception thrown when blog plugin comes across a non-event type object.
         throw new ClientException(_m('Wrong type for object.'));
     }
     $notice = null;
     switch ($activity->verb) {
         case ActivityVerb::POST:
             $notice = Blog_entry::saveNew($actor, $entryObj->title, $entryObj->content, $options);
             break;
         default:
             // TRANS: Exception thrown when blog plugin comes across a undefined verb.
             throw new ClientException(_m('Unknown verb for blog entries.'));
     }
     return $notice;
 }
Exemplo n.º 2
0
 /**
  * Handler method
  *
  * @param array $argarray is ignored since it's now passed in in prepare()
  *
  * @return void
  */
 function handle($argarray = null)
 {
     $options = array();
     // Does the heavy-lifting for getting "To:" information
     ToSelector::fillOptions($this, $options);
     $options['source'] = 'web';
     $profile = $this->user->getProfile();
     $saved = Blog_entry::saveNew($profile, $this->title, $this->content, $options);
     if ($this->boolean('ajax')) {
         header('Content-Type: text/xml; charset=utf-8');
         $this->xw->startDocument('1.0', 'UTF-8');
         $this->elementStart('html');
         $this->elementStart('head');
         // TRANS: Page title after sending a notice.
         $this->element('title', null, _m('Blog entry saved'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $nli = new NoticeListItem($saved, $this);
         $nli->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect($saved->bestUrl(), 303);
     }
 }