ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSEContentDetails.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
33 {
34 
35  public $senders = array();
36  public $receivers = array();
37  public $url = array();
38  public $content_type = array();
39  public $owner = 0;
40 
41  private $receiver_info = array();
42 
43 
47  public function __construct()
48  {
49 
50  }
51 
56  public function getSenders()
57  {
58  return (array) $this->senders;
59  }
60 
64  public function getFirstSender()
65  {
66  return isset($this->senders[0]) ? $this->senders[0] : 0;
67  }
68 
73  public function getReceivers()
74  {
75  return (array) $this->receivers;
76  }
77 
82  public function getReceiverInfo()
83  {
84  return (array) $this->receiver_info;
85  }
86 
91  public function getUrl()
92  {
93  return $this->url;
94  }
95 
96  public function getOwner()
97  {
98  return (int) $this->owner;
99  }
100 
101 
109  public function loadFromJson($json)
110  {
111  global $ilLog;
112 
113  if(!is_object($json))
114  {
115  include_once('./Services/WebServices/ECS/classes/class.ilECSReaderException.php');
116  $ilLog->write(__METHOD__.': Cannot load from JSON. No object given.');
117  throw new ilECSReaderException('Cannot parse ECS content details.');
118  }
119 
120  foreach((array) $json->senders as $sender)
121  {
122  $this->senders[] = $sender->mid;
123  }
124 
125  foreach((array) $json->receivers as $receiver)
126  {
127  $this->receivers[] = $receiver->mid;
128  }
129 
130  // Collect in one array
131  for($i = 0; $i < count($this->getReceivers()); ++$i)
132  {
133  $this->receiver_info[$this->sender[$i]] = $this->receivers[$i];
134  }
135 
136  if(is_object($json->owner))
137  {
138  $this->owner = (int) $json->owner->pid;
139  }
140 
141  $this->url = $json->url;
142  $this->content_type = $json->content_type;
143  return true;
144  }
145 }
146 ?>