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 include_once( "lib/ezdb/classes/ezdb.php" );
00037 include_once( "kernel/classes/ezpersistentobject.php" );
00038
00039 class eZContentClassGroup extends eZPersistentObject
00040 {
00041 function eZContentClassGroup( $row )
00042 {
00043 $this->eZPersistentObject( $row );
00044 }
00045
00046 function definition()
00047 {
00048 return array( "fields" => array( "id" => array( 'name' => 'ID',
00049 'datatype' => 'integer',
00050 'default' => 0,
00051 'required' => true ),
00052 "name" => array( 'name' => "Name",
00053 'datatype' => 'string',
00054 'default' => '',
00055 'required' => true ),
00056 "creator_id" => array( 'name' => "CreatorID",
00057 'datatype' => 'integer',
00058 'default' => 0,
00059 'required' => true,
00060 'foreign_class' => 'eZUser',
00061 'foreign_attribute' => 'contentobject_id',
00062 'multiplicity' => '1..*' ),
00063 "modifier_id" => array( 'name' => "ModifierID",
00064 'datatype' => 'integer',
00065 'default' => 0,
00066 'required' => true,
00067 'foreign_class' => 'eZUser',
00068 'foreign_attribute' => 'contentobject_id',
00069 'multiplicity' => '1..*' ),
00070 "created" => array( 'name' => "Created",
00071 'datatype' => 'integer',
00072 'default' => 0,
00073 'required' => true ),
00074 "modified" => array( 'name' => "Modified",
00075 'datatype' => 'integer',
00076 'default' => 0,
00077 'required' => true ) ),
00078 "keys" => array( "id" ),
00079 'function_attributes' => array( 'modifier' => 'modifier',
00080 'creator' => 'creator' ),
00081 "increment_key" => "id",
00082 "class_name" => "eZContentClassGroup",
00083 "sort" => array( "id" => "asc" ),
00084 "name" => "ezcontentclassgroup" );
00085 }
00086
00087 function create( $userID = false )
00088 {
00089 $dateTime = time();
00090 if ( !$userID )
00091 $userID = eZUser::currentUserID();
00092 $row = array(
00093 "id" => null,
00094 "name" => "",
00095 "creator_id" => $userID,
00096 "modifier_id" => $userID,
00097 "created" => $dateTime,
00098 "modified" => $dateTime );
00099 return new eZContentClassGroup( $row );
00100 }
00101
00102 function &modifier()
00103 {
00104 if ( isset( $this->ModifierID ) and $this->ModifierID )
00105 {
00106 include_once( "kernel/classes/datatypes/ezuser/ezuser.php" );
00107 $user = eZUser::fetch( $this->ModifierID );
00108 }
00109 else
00110 $user = null;
00111 return $user;
00112 }
00113
00114 function &creator()
00115 {
00116 if ( isset( $this->CreatorID ) and $this->CreatorID )
00117 {
00118 include_once( "kernel/classes/datatypes/ezuser/ezuser.php" );
00119 $user = eZUser::fetch( $this->CreatorID );
00120 }
00121 else
00122 $user = null;
00123 return $user;
00124 }
00125
00126
00127
00128
00129
00130 function removeSelected( $id )
00131 {
00132 eZPersistentObject::removeObject( eZContentClassGroup::definition(),
00133 array( "id" => $id ) );
00134 }
00135
00136
00137
00138
00139
00140
00141
00142 function fetchByName( $name, $asObject = true )
00143 {
00144 $conds = array( 'name' => $name );
00145 return eZPersistentObject::fetchObject( eZContentClassGroup::definition(),
00146 null,
00147 $conds,
00148 $asObject );
00149 }
00150
00151 function fetch( $id, $user_id = false, $asObject = true )
00152 {
00153 $conds = array( "id" => $id );
00154 if ( $user_id !== false and is_numeric( $user_id ) )
00155 $conds["creator_id"] = $user_id;
00156 return eZPersistentObject::fetchObject( eZContentClassGroup::definition(),
00157 null,
00158 $conds,
00159 $asObject );
00160 }
00161
00162 function fetchList( $user_id = false, $asObject = true )
00163 {
00164 $conds = array();
00165 if ( $user_id !== false and is_numeric( $user_id ) )
00166 $conds["creator_id"] = $user_id;
00167 return eZPersistentObject::fetchObjectList( eZContentClassGroup::definition(),
00168 null, $conds, null, null,
00169 $asObject );
00170 }
00171
00172
00173
00174
00175
00176
00177
00178 function &appendClass( &$class, $version = false )
00179 {
00180 if ( get_class( $class ) == 'ezcontentclass' )
00181 {
00182 $classID = $class->attribute( 'id' );
00183 $version = $class->attribute( 'version' );
00184 }
00185 else
00186 $classID = $class;
00187 $classGroupLink = eZContentClassClassGroup::create( $classID, $version,
00188 $this->attribute( 'id' ),
00189 $this->attribute( 'name' ) );
00190 $classGroupLink->store();
00191 return $classGroupLink;
00192 }
00193
00194 var $ID;
00195 var $Name;
00196 var $CreatorID;
00197 var $ModifierID;
00198 var $Created;
00199 var $Modified;
00200 }
00201
00202 ?>