Example #1
0
function notice_to_omb_notice($notice)
{
    /* Create an OMB_Notice for $notice. */
    $user = User::staticGet('id', $notice->profile_id);
    if (!$user) {
        return null;
    }
    $profile = $user->getProfile();
    $omb_notice = new OMB_Notice(profile_to_omb_profile($user->uri, $profile), $notice->uri, $notice->content);
    $omb_notice->setURL(common_local_url('shownotice', array('notice' => $notice->id)));
    $omb_notice->setLicenseURL(common_config('license', 'url'));
    return $omb_notice;
}
 /**
  * Inform the service about a new notice
  *
  * Sends a notice to the service.
  *
  * @param OMB_Notice $notice The notice
  *
  * @access public
  */
 public function postNotice($notice)
 {
     $params = $notice->asParameters();
     $params['omb_listenee'] = $notice->getAuthor()->getIdentifierURI();
     $this->performOMBAction(OMB_ENDPOINT_POSTNOTICE, $params, $params['omb_listenee']);
 }
 /**
  * Builds an OMB_Notice object from array
  *
  * The method builds an OMB_Notice object from the passed parameters array.
  * The array MUST provide a notice URI and content. The array fields HAVE TO
  * be named according to the OMB standard, i. e. omb_notice_* and
  * omb_seealso_*. Values are handled as not passed if the corresponding array
  * fields are not set or the empty string.
  *
  * @param object $author     An OMB_Profile object representing the author of
  *                           the notice.
  * @param string $parameters An array containing the notice parameters.
  *
  * @access public
  *
  * @returns OMB_Notice The built OMB_Notice.
  */
 public static function fromParameters($author, $parameters)
 {
     $notice = new OMB_Notice($author, $parameters['omb_notice'], $parameters['omb_notice_content']);
     if (isset($parameters['omb_notice_url'])) {
         $notice->setURL($parameters['omb_notice_url']);
     }
     if (isset($parameters['omb_notice_license'])) {
         $notice->setLicenseURL($parameters['omb_notice_license']);
     }
     if (isset($parameters['omb_seealso'])) {
         $notice->setSeealsoURL($parameters['omb_seealso']);
     }
     if (isset($parameters['omb_seealso_disposition'])) {
         $notice->setSeealsoDisposition($parameters['omb_seealso_disposition']);
     }
     if (isset($parameters['omb_seealso_mediatype'])) {
         $notice->setSeealsoMediatype($parameters['omb_seealso_mediatype']);
     }
     if (isset($parameters['omb_seealso_license'])) {
         $notice->setSeealsoLicenseURL($parameters['omb_seealso_license']);
     }
     return $notice;
 }
 /**
  * Handle a postnotice request
  *
  * Handles a postnotice request posted to this service. Saves the notice
  * through the OMB_Datastore.
  *
  * @access public
  *
  * @return OMB_Notice The received notice
  */
 public function handlePostNotice()
 {
     list($req, $profile) = $this->handleOMBRequest(OMB_ENDPOINT_POSTNOTICE);
     $notice = OMB_Notice::fromParameters($profile, $req->get_parameters());
     $this->datastore->saveNotice($notice);
     $this->finishOMBRequest();
     return $notice;
 }