00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 include_once( 'kernel/classes/ezpersistentobject.php' );
00041 include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
00042 include_once( 'lib/ezlocale/classes/ezdatetime.php' );
00043
00044 class eZCollaborationItemGroupLink extends eZPersistentObject
00045 {
00046
00047
00048
00049 function eZCollaborationItemGroupLink( $row )
00050 {
00051 $this->eZPersistentObject( $row );
00052 }
00053
00054 function definition()
00055 {
00056 return array( 'fields' => array( 'collaboration_id' => array( 'name' => 'CollaborationID',
00057 'datatype' => 'integer',
00058 'default' => 0,
00059 'required' => true,
00060 'foreign_class' => 'eZCollaborationItem',
00061 'foreign_attribute' => 'id',
00062 'multiplicity' => '1..*' ),
00063 'group_id' => array( 'name' => 'GroupID',
00064 'datatype' => 'integer',
00065 'default' => 0,
00066 'required' => true,
00067 'foreign_class' => 'eZCollaborationGroup',
00068 'foreign_attribute' => 'id',
00069 'multiplicity' => '1..*' ),
00070 'user_id' => array( 'name' => 'UserID',
00071 'datatype' => 'integer',
00072 'default' => 0,
00073 'required' => true,
00074 'foreign_class' => 'eZUser',
00075 'foreign_attribute' => 'contentobject_id',
00076 'multiplicity' => '1..*' ),
00077 'is_read' => array( 'name' => 'IsRead',
00078 'datatype' => 'integer',
00079 'default' => 0,
00080 'required' => true ),
00081 'is_active' => array( 'name' => 'IsActive',
00082 'datatype' => 'integer',
00083 'default' => 1,
00084 'required' => true ),
00085 'last_read' => array( 'name' => 'LastRead',
00086 'datatype' => 'integer',
00087 'default' => 0,
00088 'required' => true ),
00089 'created' => array( 'name' => 'Created',
00090 'datatype' => 'integer',
00091 'default' => 0,
00092 'required' => true ),
00093 'modified' => array( 'name' => 'Modified',
00094 'datatype' => 'integer',
00095 'default' => 0,
00096 'required' => true ) ),
00097 'keys' => array( 'collaboration_id', 'group_id', 'user_id' ),
00098 'function_attributes' => array( 'user' => 'user',
00099 'collaboration_item' => 'collaborationItem',
00100 'collaboration_group' => 'collaborationGroup' ),
00101 'class_name' => 'eZCollaborationItemGroupLink',
00102 'sort' => array( 'modified' => 'asc' ),
00103 'name' => 'ezcollab_item_group_link' );
00104 }
00105
00106 function create( $collaborationID, $groupID, $userID )
00107 {
00108 $date_time = time();
00109 $row = array(
00110 'collaboration_id' => $collaborationID,
00111 'group_id' => $groupID,
00112 'is_read' => false,
00113 'is_active' => true,
00114 'last_read' => 0,
00115 'user_id' => $userID,
00116 'created' => $date_time,
00117 'modified' => $date_time );
00118 return new eZCollaborationItemGroupLink( $row );
00119 }
00120
00121 function addItem( $groupID, $collaborationID, $userID )
00122 {
00123 $groupLink = eZCollaborationItemGroupLink::create( $collaborationID, $groupID, $userID );
00124
00125 $db =& eZDB::instance();
00126 $db->begin();
00127 $groupLink->store();
00128 $itemStatus = eZCollaborationItemStatus::create( $collaborationID, $userID );
00129 $itemStatus->store();
00130 $db->commit();
00131
00132 return $groupLink;
00133 }
00134
00135 function fetch( $collaborationID, $groupID, $userID = false, $asObject = true )
00136 {
00137 if ( $userID == false )
00138 $userID == eZUser::currentUserID();
00139 return eZPersistentObject::fetchObject( eZCollaborationItemGroupLink::definition(),
00140 null,
00141 array( 'collaboration_id' => $collaborationID,
00142 'group_id' => $groupID,
00143 'user_id' => $userID ),
00144 $asObject );
00145 }
00146
00147 function fetchList( $collaborationID, $userID = false, $asObject = true )
00148 {
00149 if ( $userID == false )
00150 $userID == eZUser::currentUserID();
00151 return eZPersistentObject::fetchObjectList( eZCollaborationItemGroupLink::definition(),
00152 null,
00153 array( 'collaboration_id' => $collaborationID,
00154 'user_id' => $userID ),
00155 null, null,
00156 $asObject );
00157 }
00158
00159 function &user()
00160 {
00161 if ( isset( $this->UserID ) and $this->UserID )
00162 {
00163 include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
00164 $user = eZUser::fetch( $this->UserID );
00165 }
00166 else
00167 $user = null;
00168 return $user;
00169 }
00170
00171 function &collaborationItem()
00172 {
00173 if ( isset( $this->CollaborationID ) and $this->CollaborationID )
00174 {
00175 include_once( 'kernel/classes/ezcollaborationitem.php' );
00176 $item = eZCollaborationItem::fetch( $this->CollaborationID, $this->UserID );
00177 }
00178 else
00179 $item = null;
00180 return $item;
00181 }
00182
00183 function &collaborationGroup()
00184 {
00185 if ( isset( $this->GroupID ) and $this->GroupID )
00186 {
00187 include_once( 'kernel/classes/ezcollaborationitem.php' );
00188 $group = eZCollaborationGroup::fetch( $this->GroupID, $this->UserID );
00189 }
00190 else
00191 $group = null;
00192 return $group;
00193 }
00194
00195
00196
00197 var $CollaborationID;
00198 var $GroupID;
00199 var $UserID;
00200 var $Created;
00201 var $Modified;
00202 }
00203
00204 ?>