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/ezcollaborationgroup.php' );
00042
00043 class eZCollaborationProfile extends eZPersistentObject
00044 {
00045
00046
00047
00048 function eZCollaborationProfile( $row )
00049 {
00050 $this->eZPersistentObject( $row );
00051 }
00052
00053 function definition()
00054 {
00055 return array( 'fields' => array( 'id' => array( 'name' => 'ID',
00056 'datatype' => 'integer',
00057 'default' => 0,
00058 'required' => true ),
00059 'user_id' => array( 'name' => 'UserID',
00060 'datatype' => 'integer',
00061 'default' => 0,
00062 'required' => true,
00063 'foreign_class' => 'eZUser',
00064 'foreign_attribute' => 'contentobject_id',
00065 'multiplicity' => '1..*' ),
00066 'main_group' => array( 'name' => 'MainGroup',
00067 'datatype' => 'integer',
00068 'default' => 0,
00069 'required' => true,
00070 'foreign_class' => 'eZCollaborationGroup',
00071 'foreign_attribute' => 'id',
00072 'multiplicity' => '1..*' ),
00073 'data_text1' => array( 'name' => 'DataText1',
00074 'datatype' => 'text',
00075 'default' => '',
00076 'required' => true ),
00077 'created' => array( 'name' => 'Created',
00078 'datatype' => 'integer',
00079 'default' => 0,
00080 'required' => true ),
00081 'modified' => array( 'name' => 'Modified',
00082 'datatype' => 'integer',
00083 'default' => 0,
00084 'required' => true ) ),
00085 'keys' => array( 'id' ),
00086 'increment_key' => 'id',
00087 'class_name' => 'eZCollaborationProfile',
00088 'name' => 'ezcollab_profile' );
00089 }
00090
00091 function &create( $userID, $mainGroup = 0 )
00092 {
00093 $date_time = time();
00094 $row = array( 'id' => null,
00095 'user_id' => $userID,
00096 'main_group' => $mainGroup,
00097 'created' => $date_time,
00098 'modified' => $date_time );
00099 $newCollaborationProfile = new eZCollaborationProfile( $row );
00100 return $newCollaborationProfile;
00101 }
00102
00103 function fetch( $id, $asObject = true )
00104 {
00105 $conditions = array( "id" => $id );
00106 return eZPersistentObject::fetchObject( eZCollaborationProfile::definition(),
00107 null,
00108 $conditions,
00109 $asObject );
00110 }
00111
00112 function fetchByUser( $userID, $asObject = true )
00113 {
00114 $conditions = array( "user_id" => $userID );
00115 return eZPersistentObject::fetchObject( eZCollaborationProfile::definition(),
00116 null,
00117 $conditions,
00118 $asObject );
00119 }
00120
00121
00122
00123
00124
00125 function &instance( $userID = false )
00126 {
00127 if ( $userID === false )
00128 {
00129 $user =& eZUser::currentUser();
00130 $userID = $user->attribute( 'contentobject_id' );
00131 }
00132 $instance =& $GLOBALS["eZCollaborationProfile-$userID"];
00133 if ( !isset( $instance ) )
00134 {
00135 $instance = eZCollaborationProfile::fetchByUser( $userID );
00136 if ( $instance === null )
00137 {
00138 $group =& eZCollaborationGroup::instantiate( $userID, ezi18n( 'kernel/classes', 'Inbox' ) );
00139 $instance = eZCollaborationProfile::create( $userID, $group->attribute( 'id' ) );
00140 $instance->store();
00141 }
00142 }
00143 return $instance;
00144 }
00145
00146 }
00147
00148 ?>