Example #1
0
 private function membersToJSON($course, $members)
 {
     $json = array();
     foreach ($members as $member) {
         $url = $this->urlf('/user/%s', array($member->user_id));
         $avatar = \Avatar::getAvatar($member->user_id);
         $json[$url] = array('member' => User::getMiniUser($this, $member->user), 'status' => $member->status);
     }
     return $json;
 }
Example #2
0
 /**
  * Returns all data of this blubber that are relevant as a rest-resource
  * including reshares and html-content
  * @param  $posting BlubberPosting  the posting to transform
  * @return array of JSON data of this blubber.
  */
 private function blubberPostingtoJSON($posting)
 {
     $result = array('blubber_id' => $posting->getId(), 'root_id' => $posting['root_id'], 'author' => User::getMiniUser($this, $posting->getUser()), 'context_type' => $posting['context_type'], 'content' => $posting['description'], 'content_html' => formatReady($posting['description']));
     if ($posting->isThread()) {
         $sharer_ids = array();
         foreach ($posting->getSharingUsers() as $sharer) {
             $sharer_ids[] = $this->urlf('/user/%s', array($sharer['user_id']));
         }
         $result = array_merge($result, array('comments' => $this->urlf('/blubber/posting/%s/comments', array($posting->getId())), 'comments_count' => $posting->getNumberOfChildren(), 'reshares' => $sharer_ids, 'tags' => $posting->getTags()));
     }
     return $result;
 }
Example #3
0
 private function wikiPageToJson($page, $without = array())
 {
     $json = $page->toArray(words("range_id keyword chdate version"));
     // (pre-rendered) content
     if (!in_array("content", $without)) {
         $json['content'] = $page->body;
         $json['content_html'] = wikiReady($page->body);
     }
     if (!in_array("user", $without)) {
         $json['user'] = User::getMiniUser($this, $page->author);
     }
     foreach ($without as $key) {
         if (isset($json[$key])) {
             unset($json[$key]);
         }
     }
     // string to int conversions as SORM does not know about ints
     foreach (words("chdate mkdate filesize downloads") as $key) {
         if (isset($result[$key])) {
             $result[$key] = intval($result[$key]);
         }
     }
     return $json;
 }
Example #4
0
 private function contactsToJSON($contacts)
 {
     $result = array();
     foreach ($contacts as $contact) {
         $result[] = User::getMiniUser($this, $contact);
     }
     return $result;
 }