Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezcollaborationitemparticipantlink.php
Go to the documentation of this file.
1 <?php
17 class eZCollaborationItemParticipantLink extends eZPersistentObject
18 {
19 public $ParticipantRole;
20 const TYPE_USER = 1;
21 const TYPE_USERGROUP = 2;
22
23 // Everything from 1024 and above is considered custom and is specific per collaboration handler.
24 const TYPE_CUSTOM = 1024;
25
26 const ROLE_STANDARD = 1;
27 const ROLE_OBSERVER = 2;
28 const ROLE_OWNER = 3;
29 const ROLE_APPROVER = 4;
30 const ROLE_AUTHOR = 5;
31
32 // Everything from 1024 and above is considered custom and is specific per collaboration handler.
33 const ROLE_CUSTOM = 1024;
34
35 static function definition()
36 {
37 return array( 'fields' => array( 'collaboration_id' => array( 'name' => 'CollaborationID',
38 'datatype' => 'integer',
39 'default' => 0,
40 'required' => true,
41 'foreign_class' => 'eZCollaborationItem',
42 'foreign_attribute' => 'id',
43 'multiplicity' => '1..*' ),
44 'participant_id' => array( 'name' => 'ParticipantID',
45 'datatype' => 'integer',
46 'default' => 0,
47 'required' => true,
48 'foreign_class' => 'eZContentObject',
49 'foreign_attribute' => 'id',
50 'multiplicity' => '1..*' ),
51 'participant_type' => array( 'name' => 'ParticipantType',
52 'datatype' => 'integer',
53 'default' => 1,
54 'required' => true ),
55 'participant_role' => array( 'name' => 'ParticipantRole',
56 'datatype' => 'integer',
57 'default' => 1,
58 'required' => true ),
59 'last_read' => array( 'name' => 'LastRead',
60 'datatype' => 'integer',
61 'default' => 0,
62 'required' => true ),
63 'created' => array( 'name' => 'Created',
64 'datatype' => 'integer',
65 'default' => 0,
66 'required' => true ),
67 'modified' => array( 'name' => 'Modified',
68 'datatype' => 'integer',
69 'default' => 0,
70 'required' => true ) ),
71 'keys' => array( 'collaboration_id', 'participant_id' ),
72 'function_attributes' => array( 'collaboration_item' => 'collaborationItem',
73 'participant' => 'participant',
74 'participant_type_string' => 'participantTypeString',
75 'participant_role_string' => 'participantRoleString',
76 'is_builtin_type' => 'isBuiltinType',
77 'is_builtin_role' => 'isBuiltinRole' ),
78 'class_name' => 'eZCollaborationItemParticipantLink',
79 'name' => 'ezcollab_item_participant_link' );
80 }
81
82 static function create( $collaborationID, $participantID,
83 $participantRole = self::ROLE_STANDARD, $participantType = self::TYPE_USER )
84 {
85 $dateTime = time();
86 $row = array( 'collaboration_id' => $collaborationID,
87 'participant_id' => $participantID,
88 'participant_role' => $participantRole,
89 'participant_type' => $participantType,
90 'created' => $dateTime,
91 'modified' => $dateTime );
92 return new eZCollaborationItemParticipantLink( $row );
93 }
94
98 static function setLastRead( $collaborationID, $userID = false, $timestamp = false )
99 {
100 if ( $userID === false )
101 {
102 $userID = eZUser::currentUserID();
103 }
104 if ( $timestamp === false )
105 {
106 $timestamp = time();
107 }
108 $db = eZDB::instance();
109 $userID = (int) $userID;
110 $timestamp = (int) $timestamp;
111 $sql = "UPDATE ezcollab_item_participant_link set last_read='$timestamp'
112 WHERE collaboration_id='$collaborationID' AND participant_id='$userID'";
113 $db->query( $sql );
114 if ( !empty( $GLOBALS["eZCollaborationItemParticipantLinkCache"][$collaborationID][$userID] ) )
115 $GLOBALS["eZCollaborationItemParticipantLinkCache"][$collaborationID][$userID]->setAttribute( 'last_read', $timestamp );
116 }
117
118 static function fetch( $collaborationID, $participantID, $asObject = true )
119 {
120 if ( empty( $GLOBALS["eZCollaborationItemParticipantLinkCache"][$collaborationID][$participantID] ) )
121 {
122 $GLOBALS["eZCollaborationItemParticipantLinkCache"][$collaborationID][$participantID] =
123 eZPersistentObject::fetchObject( eZCollaborationItemParticipantLink::definition(),
124 null,
125 array( "collaboration_id" => $collaborationID,
126 'participant_id' => $participantID ),
127 $asObject );
128 }
129 return $GLOBALS["eZCollaborationItemParticipantLinkCache"][$collaborationID][$participantID];
130 }
131
132 static function fetchParticipantList( $parameters = array() )
133 {
134 $parameters = array_merge( array( 'as_object' => true,
135 'item_id' => false,
136 'offset' => false,
137 'limit' => false,
138 'sort_by' => false ),
139 $parameters );
140
141 $cacheHashKey = md5( serialize( $parameters ) );
142
143 if ( isset( $GLOBALS['eZCollaborationItemParticipantLinkListCache'][$cacheHashKey] ) )
144 {
145 return $GLOBALS['eZCollaborationItemParticipantLinkListCache'][$cacheHashKey];
146 }
147
148 $itemID = $parameters['item_id'];
149 $asObject = $parameters['as_object'];
150 $offset = $parameters['offset'];
151 $limit = $parameters['limit'];
152 $linkList = null;
153 $limitArray = null;
154
155 if ( $offset and $limit )
156 {
157 $limitArray = array( 'offset' => $offset, 'length' => $limit );
158 }
159
160 $linkList = eZPersistentObject::fetchObjectList( eZCollaborationItemParticipantLink::definition(),
161 null,
162 array( "collaboration_id" => $itemID ),
163 null, $limitArray,
164 $asObject );
165
166 foreach( $linkList as $linkItem )
167 {
168 if ( $asObject )
169 {
170 $participantID = $linkItem->attribute( 'participant_id' );
171 }
172 else
173 {
174 $participantID = $linkItem['participant_id'];
175 }
176 if ( !isset( $GLOBALS["eZCollaborationItemParticipantLinkCache"][$itemID][$participantID] ) )
177 {
178 $GLOBALS["eZCollaborationItemParticipantLinkCache"][$itemID][$participantID] = $linkItem;
179 }
180 }
181
182 return $GLOBALS['eZCollaborationItemParticipantLinkListCache'][$cacheHashKey] = $linkList;
183 }
184
185 static function fetchParticipantMap( $originalParameters = array() )
186 {
187 $parameters = array_merge( array( 'sort_field' => 'role' ),
188 $originalParameters );
189 $itemID = $parameters['item_id'];
190 $sortField = $parameters['sort_field'];
191 $list = eZCollaborationItemParticipantLink::fetchParticipantList( $originalParameters );
192 if ( $list === null )
193 {
194 $listMap = null;
195 return $listMap;
196 }
197
198 $listMap = array();
199 foreach ( $list as $listItem )
200 {
201 $sortKey = null;
202 if ( $sortField == 'role' )
203 {
204 $sortKey = $listItem->attribute( 'participant_role' );
205 }
206 if ( $sortKey !== null )
207 {
208 if ( !isset( $listMap[$sortKey] ) )
209 {
210 if ( $sortField == 'role' )
211 {
212 $sortName = eZCollaborationItemParticipantLink::roleName( $itemID, $sortKey );
213 }
214 $listMap[$sortKey] = array( 'name' => $sortName,
215 'items' => array() );
216 }
217 $listMap[$sortKey]['items'][] = $listItem;
218 }
219 }
220 return $listMap;
221 }
222
223 static function typeString( $participantType )
224 {
225 if ( !isset( $GLOBALS['eZCollaborationParticipantTypeMap'] ) )
226 {
227 $GLOBALS['eZCollaborationParticipantTypeMap'] = array( self::TYPE_USER => 'user',
228 self::TYPE_USERGROUP => 'usergroup' );
229 }
230 if ( isset( $GLOBALS['eZCollaborationParticipantTypeMap'][$participantType] ) )
231 {
232 return $GLOBALS['eZCollaborationParticipantTypeMap'][$participantType];
233 }
234 return null;
235 }
236
237 static function roleString( $participantRole )
238 {
239 if ( empty( $GLOBALS['eZCollaborationParticipantRoleMap'] ) )
240 {
241 $GLOBALS['eZCollaborationParticipantRoleMap'] =
242 array( self::ROLE_STANDARD => 'standard',
243 self::ROLE_OBSERVER => 'observer',
244 self::ROLE_OWNER => 'owner',
245 self::ROLE_APPROVER => 'approver',
246 self::ROLE_AUTHOR => 'author' );
247 }
248 $roleMap = $GLOBALS['eZCollaborationParticipantRoleMap'];
249 if ( isset( $roleMap[$participantRole] ) )
250 {
251 return $roleMap[$participantRole];
252 }
253
254 return null;
255 }
256
257 static function roleName( $collaborationID, $roleID )
258 {
259 if ( $roleID < self::TYPE_CUSTOM )
260 {
261 if ( empty( $GLOBALS['eZCollaborationParticipantRoleNameMap'] ) )
262 {
263
264 $GLOBALS['eZCollaborationParticipantRoleNameMap'] =
265 array( self::ROLE_STANDARD => ezpI18n::tr( 'kernel/classes', 'Standard' ),
266 self::ROLE_OBSERVER => ezpI18n::tr( 'kernel/classes', 'Observer' ),
267 self::ROLE_OWNER => ezpI18n::tr( 'kernel/classes', 'Owner' ),
268 self::ROLE_APPROVER => ezpI18n::tr( 'kernel/classes', 'Approver' ),
269 self::ROLE_AUTHOR => ezpI18n::tr( 'kernel/classes', 'Author' ) );
270 }
271 $roleNameMap = $GLOBALS['eZCollaborationParticipantRoleNameMap'];
272 if ( isset( $roleNameMap[$roleID] ) )
273 {
274 return $roleNameMap[$roleID];
275 }
276 return null;
277 }
278
279 $item = eZCollaborationItem::fetch( $collaborationID );
280 return $item->handler()->roleName( $collaborationID, $roleID );
281 }
282
283 function collaborationItem()
284 {
285 return eZCollaborationItem::fetch( $this->CollaborationID );
286 }
287
288 function participant()
289 {
290 if ( $this->ParticipantType == self::TYPE_USER )
291 {
292 return eZUser::fetch( $this->ParticipantID );
293 }
294 else if ( $this->ParticipantType == self::TYPE_USERGROUP )
295 {
296 return eZContentObject::fetch( $this->ParticipantID );
297 }
298 return null;
299 }
300
301 function participantTypeString()
302 {
303 if ( $this->ParticipantType < self::TYPE_CUSTOM )
304 {
305 return eZCollaborationItemParticipantLink::typeString( $this->ParticipantType );
306 }
307
308 $item = eZCollaborationItem::fetch( $this->CollaborationID );
309 return $item->attribute( 'type_identifier' ) . '_' . $item->handler()->participantTypeString( $this->ParticipantType );
310 }
311
312 function participantRoleString()
313 {
314 if ( $this->ParticipantRole < self::ROLE_CUSTOM )
315 {
316 return eZCollaborationItemParticipantLink::roleString( $this->ParticipantRole );
317 }
318
319 $item = eZCollaborationItem::fetch( $this->CollaborationID );
320 return $item->attribute( 'type_identifier' ) . '_' . $item->handler()->participantRoleString( $this->ParticipantRole );
321 }
322
323 function isBuiltinType()
324 {
325 return $this->ParticipantType < self::TYPE_CUSTOM;
326 }
327
328 function isBuiltinRole()
329 {
330 return $this->ParticipantRole < self::ROLE_CUSTOM;
331 }
332
334 public $CollaborationID;
335 public $ParticipantID;
336 public $ParticipantType;
337 public $IsRead;
338 public $IsActive;
339 public $Created;
340 public $Modified;
341 }
342
343 ?>
eZCollaborationItemParticipantLink
The class eZCollaborationItemParticipantLink does.
Definition: ezcollaborationitemparticipantlink.php:18
eZCollaborationItemParticipantLink\fetch
static fetch( $collaborationID, $participantID, $asObject=true)
Definition: ezcollaborationitemparticipantlink.php:118
eZCollaborationItemParticipantLink\setLastRead
static setLastRead( $collaborationID, $userID=false, $timestamp=false)
Definition: ezcollaborationitemparticipantlink.php:98
eZCollaborationItemParticipantLink\$ParticipantType
$ParticipantType
Definition: ezcollaborationitemparticipantlink.php:336
eZCollaborationItemParticipantLink\fetchParticipantList
static fetchParticipantList( $parameters=array())
Definition: ezcollaborationitemparticipantlink.php:132
eZCollaborationItemParticipantLink\TYPE_USER
const TYPE_USER
Definition: ezcollaborationitemparticipantlink.php:20
eZCollaborationItemParticipantLink\TYPE_CUSTOM
const TYPE_CUSTOM
Definition: ezcollaborationitemparticipantlink.php:24
eZCollaborationItemParticipantLink\definition
static definition()
Definition: ezcollaborationitemparticipantlink.php:35
eZCollaborationItemParticipantLink\$Created
$Created
Definition: ezcollaborationitemparticipantlink.php:339
eZCollaborationItemParticipantLink\ROLE_OBSERVER
const ROLE_OBSERVER
Definition: ezcollaborationitemparticipantlink.php:27
eZCollaborationItemParticipantLink\collaborationItem
collaborationItem()
Definition: ezcollaborationitemparticipantlink.php:283
eZCollaborationItemParticipantLink\ROLE_STANDARD
const ROLE_STANDARD
Definition: ezcollaborationitemparticipantlink.php:26
eZCollaborationItemParticipantLink\TYPE_USERGROUP
const TYPE_USERGROUP
Definition: ezcollaborationitemparticipantlink.php:21
eZCollaborationItemParticipantLink\roleName
static roleName( $collaborationID, $roleID)
Definition: ezcollaborationitemparticipantlink.php:257
eZCollaborationItemParticipantLink\ROLE_AUTHOR
const ROLE_AUTHOR
Definition: ezcollaborationitemparticipantlink.php:30
eZCollaborationItemParticipantLink\$ParticipantRole
$ParticipantRole
Definition: ezcollaborationitemparticipantlink.php:19
eZCollaborationItemParticipantLink\participantTypeString
participantTypeString()
Definition: ezcollaborationitemparticipantlink.php:301
eZCollaborationItemParticipantLink\create
static create( $collaborationID, $participantID, $participantRole=self::ROLE_STANDARD, $participantType=self::TYPE_USER)
Definition: ezcollaborationitemparticipantlink.php:82
eZCollaborationItemParticipantLink\participantRoleString
participantRoleString()
Definition: ezcollaborationitemparticipantlink.php:312
eZCollaborationItemParticipantLink\$CollaborationID
$CollaborationID
Definition: ezcollaborationitemparticipantlink.php:334
eZCollaborationItemParticipantLink\participant
participant()
Definition: ezcollaborationitemparticipantlink.php:288
eZCollaborationItemParticipantLink\ROLE_OWNER
const ROLE_OWNER
Definition: ezcollaborationitemparticipantlink.php:28
eZCollaborationItemParticipantLink\isBuiltinRole
isBuiltinRole()
Definition: ezcollaborationitemparticipantlink.php:328
eZCollaborationItemParticipantLink\ROLE_APPROVER
const ROLE_APPROVER
Definition: ezcollaborationitemparticipantlink.php:29
eZCollaborationItemParticipantLink\$Modified
$Modified
Definition: ezcollaborationitemparticipantlink.php:340
eZCollaborationItemParticipantLink\$ParticipantID
$ParticipantID
Definition: ezcollaborationitemparticipantlink.php:335
eZCollaborationItemParticipantLink\typeString
static typeString( $participantType)
Definition: ezcollaborationitemparticipantlink.php:223
eZCollaborationItemParticipantLink\$IsActive
$IsActive
Definition: ezcollaborationitemparticipantlink.php:338
eZCollaborationItemParticipantLink\$IsRead
$IsRead
Definition: ezcollaborationitemparticipantlink.php:337
eZCollaborationItemParticipantLink\roleString
static roleString( $participantRole)
Definition: ezcollaborationitemparticipantlink.php:237
eZCollaborationItemParticipantLink\ROLE_CUSTOM
const ROLE_CUSTOM
Definition: ezcollaborationitemparticipantlink.php:33
eZCollaborationItemParticipantLink\isBuiltinType
isBuiltinType()
Definition: ezcollaborationitemparticipantlink.php:323
eZCollaborationItemParticipantLink\fetchParticipantMap
static fetchParticipantMap( $originalParameters=array())
Definition: ezcollaborationitemparticipantlink.php:185
eZCollaborationItem\fetch
static fetch( $id, $creatorID=false, $asObject=true)
Definition: ezcollaborationitem.php:135
eZContentObject\fetch
static fetch( $id, $asObject=true)
Definition: ezcontentobject.php:885
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZPersistentObject\setAttribute
setAttribute( $attr, $val)
Definition: ezpersistentobject.php:1374
eZPersistentObject\fetchObjectList
static fetchObjectList( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
Definition: ezpersistentobject.php:806
eZUser\fetch
static fetch( $id, $asObject=true)
Definition: ezuser.php:351
eZUser\currentUserID
static currentUserID()
Definition: ezuser.php:1731
ezpI18n\tr
static tr( $context, $source, $comment=null, $arguments=null)
Definition: ezpi18n.php:86
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.