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 include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
00040
00041 class eZCollaborationNotificationRule extends eZPersistentObject
00042 {
00043
00044
00045
00046 function eZCollaborationNotificationRule( $row )
00047 {
00048 $this->eZPersistentObject( $row );
00049 }
00050
00051 function definition()
00052 {
00053 return array( "fields" => array( "id" => array( 'name' => 'ID',
00054 'datatype' => 'integer',
00055 'default' => 0,
00056 'required' => true ),
00057 "user_id" => array( 'name' => "UserID",
00058 'datatype' => 'integer',
00059 'default' => 0,
00060 'required' => true,
00061 'foreign_class' => 'eZUser',
00062 'foreign_attribute' => 'contentobject_id',
00063 'multiplicity' => '1..*' ),
00064 "collab_identifier" => array( 'name' => "CollaborationIdentifier",
00065 'datatype' => 'string',
00066 'default' => '',
00067 'required' => true ) ),
00068 "keys" => array( "id" ),
00069 "function_attributes" => array( 'user' => 'user' ),
00070 "increment_key" => "id",
00071 "sort" => array( "id" => "asc" ),
00072 "class_name" => "eZCollaborationNotificationRule",
00073 "name" => "ezcollab_notification_rule" );
00074 }
00075
00076 function &user()
00077 {
00078 $user = eZUser::fetch( $this->attribute( 'user_id' ) );
00079 return $user;
00080 }
00081
00082 function create( $collaborationIdentifier, $userID = false )
00083 {
00084 if ( !$userID )
00085 $userID = eZUser::currentUserID();
00086 $rule = new eZCollaborationNotificationRule( array( 'user_id' => $userID,
00087 'collab_identifier' => $collaborationIdentifier ) );
00088 return $rule;
00089 }
00090
00091 function fetchList( $userID = false, $asObject = true )
00092 {
00093 if ( !$userID )
00094 $userID = eZUser::currentUserID();
00095 return eZPersistentObject::fetchObjectList( eZCollaborationNotificationRule::definition(),
00096 null, array( 'user_id' => $userID ),
00097 null, null, $asObject );
00098 }
00099
00100 function &fetchItemTypeList( $collaborationIdentifier, $userIDList, $asObject = true )
00101 {
00102 if ( is_array( $collaborationIdentifier ) )
00103 $collaborationIdentifier = array( $collaborationIdentifier );
00104 $objectList = eZPersistentObject::fetchObjectList( eZCollaborationNotificationRule::definition(),
00105 null, array( 'user_id' => array( $userIDList ),
00106 'collab_identifier' => $collaborationIdentifier ),
00107 null, null, $asObject );
00108 return $objectList;
00109 }
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 function removeByIdentifier( $collaborationIdentifier, $userID = false )
00130 {
00131 if ( !$userID )
00132 $userID = eZUser::currentUserID();
00133 eZPersistentObject::removeObject( eZCollaborationNotificationRule::definition(),
00134 array( 'collab_identifier' => $collaborationIdentifier,
00135 'user_id' => $userID ) );
00136 }
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 function removeByUserID( $userID )
00153 {
00154 eZPersistentObject::removeObject( eZCollaborationNotificationRule::definition(), array( 'user_id' => $userID ) );
00155 }
00156
00157
00158
00159
00160
00161 function cleanup()
00162 {
00163 $db =& eZDB::instance();
00164 $db->query( "DELETE FROM ezcollab_notification_rule" );
00165 }
00166 }
00167
00168 ?>