Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezcollaborationitemstatus.php
Go to the documentation of this file.
1 <?php
17 class eZCollaborationItemStatus extends eZPersistentObject
18 {
19 public $CollaborationID;
20 static function definition()
21 {
22 return array( 'fields' => array( 'collaboration_id' => array( 'name' => 'CollaborationID',
23 'datatype' => 'integer',
24 'default' => 0,
25 'required' => true,
26 'foreign_class' => 'eZCollaborationItem',
27 'foreign_attribute' => 'id',
28 'multiplicity' => '1..*' ),
29 'user_id' => array( 'name' => 'UserID',
30 'datatype' => 'integer',
31 'default' => 0,
32 'required' => true,
33 'foreign_class' => 'eZUser',
34 'foreign_attribute' => 'contentobject_id',
35 'multiplicity' => '1..*' ),
36 'is_read' => array( 'name' => 'IsRead',
37 'datatype' => 'integer',
38 'default' => 0,
39 'required' => true ),
40 'is_active' => array( 'name' => 'IsActive',
41 'datatype' => 'integer',
42 'default' => 1,
43 'required' => true ),
44 'last_read' => array( 'name' => 'LastRead',
45 'datatype' => 'integer',
46 'default' => 0,
47 'required' => true ) ),
48 'keys' => array( 'collaboration_id', 'user_id' ),
49 'class_name' => 'eZCollaborationItemStatus',
50 'name' => 'ezcollab_item_status' );
51 }
52
53 static function create( $collaborationID, $userID = false )
54 {
55 if ( $userID === false )
56 $userID = eZUser::currentUserID();
57 $row = array(
58 'collaboration_id' => $collaborationID,
59 'user_id' => $userID,
60 'is_read' => false,
61 'is_active' => true,
62 'last_read' => 0 );
63 return $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID] = new eZCollaborationItemStatus( $row );
64 }
65
66 function store( $fieldFilters = null )
67 {
68 parent::store( $fieldFilters );
69 $this->updateCache();
70 return true;
71 }
72
73 function updateCache()
74 {
75 $userID = $this->UserID;
76 $collaborationID = $this->CollaborationID;
77 $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID] = $this;
78 }
79
80 static function fetch( $collaborationID, $userID = false, $asObject = true )
81 {
82 if ( $userID === false )
83 {
84 $userID = eZUser::currentUserID();
85 }
86 if ( !isset( $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID] ) )
87 {
88 $conditions = array( 'collaboration_id' => $collaborationID,
89 'user_id' => $userID );
90 $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID] = eZPersistentObject::fetchObject(
91 eZCollaborationItemStatus::definition(),
92 null,
93 $conditions,
94 $asObject );
95 }
96 return $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID];
97 }
98
99 static function setLastRead( $collaborationID, $userID = false, $timestamp = false )
100 {
101 if ( $timestamp === false )
102 $timestamp = time();
103
104 eZCollaborationItemStatus::updateFields( $collaborationID, $userID, array( 'last_read' => $timestamp,
105 'is_read' => 1 ) );
106 }
107
108 static function updateFields( $collaborationID, $userID = false, $fields )
109 {
110 if ( $userID === false )
111 $userID = eZUser::currentUserID();
112
113 eZPersistentObject::updateObjectList( array( 'definition' => eZCollaborationItemStatus::definition(),
114 'update_fields' => $fields,
115 'conditions' => array( 'collaboration_id' => $collaborationID,
116 'user_id' => $userID ) ) );
117 $statusObject =& $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID];
118 if ( isset( $statusObject ) )
119 {
120 foreach ( $fields as $field => $value )
121 {
122 $statusObject->setAttribute( $field, $value );
123 }
124 }
125 }
126
127 }
128
129 ?>
eZCollaborationItemStatus
The class eZCollaborationItemStatus does.
Definition: ezcollaborationitemstatus.php:18
eZCollaborationItemStatus\updateCache
updateCache()
Definition: ezcollaborationitemstatus.php:73
eZCollaborationItemStatus\$CollaborationID
$CollaborationID
Definition: ezcollaborationitemstatus.php:19
eZCollaborationItemStatus\setLastRead
static setLastRead( $collaborationID, $userID=false, $timestamp=false)
Definition: ezcollaborationitemstatus.php:99
eZCollaborationItemStatus\create
static create( $collaborationID, $userID=false)
Definition: ezcollaborationitemstatus.php:53
eZCollaborationItemStatus\store
store( $fieldFilters=null)
Definition: ezcollaborationitemstatus.php:66
eZCollaborationItemStatus\updateFields
static updateFields( $collaborationID, $userID=false, $fields)
Definition: ezcollaborationitemstatus.php:108
eZCollaborationItemStatus\fetch
static fetch( $collaborationID, $userID=false, $asObject=true)
Definition: ezcollaborationitemstatus.php:80
eZCollaborationItemStatus\definition
static definition()
Definition: ezcollaborationitemstatus.php:20
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\updateObjectList
static updateObjectList( $parameters)
Definition: ezpersistentobject.php:1209
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZPersistentObject\$UserID
$UserID
Definition: ezpersistentobject.php:1474
eZUser\currentUserID
static currentUserID()
Definition: ezuser.php:1731
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.