|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZContentClassGroup class 00004 // 00005 // 00006 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00007 // SOFTWARE NAME: eZ Publish 00008 // SOFTWARE RELEASE: 4.0.x 00009 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00010 // SOFTWARE LICENSE: GNU General Public License v2.0 00011 // NOTICE: > 00012 // This program is free software; you can redistribute it and/or 00013 // modify it under the terms of version 2.0 of the GNU General 00014 // Public License as published by the Free Software Foundation. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of version 2.0 of the GNU General 00022 // Public License along with this program; if not, write to the Free 00023 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00024 // MA 02110-1301, USA. 00025 // 00026 // 00027 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00028 // 00029 00030 //!! eZKernel 00031 //! The class eZContentClassGroup 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 static 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 static 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 return eZUser::fetch( $this->ModifierID ); 00108 } 00109 return null; 00110 } 00111 00112 function creator() 00113 { 00114 if ( isset( $this->CreatorID ) and $this->CreatorID ) 00115 { 00116 //include_once( "kernel/classes/datatypes/ezuser/ezuser.php" ); 00117 return eZUser::fetch( $this->CreatorID ); 00118 } 00119 return null; 00120 } 00121 00122 /*! 00123 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 00124 the calls within a db transaction; thus within db->begin and db->commit. 00125 */ 00126 static function removeSelected( $id ) 00127 { 00128 eZPersistentObject::removeObject( eZContentClassGroup::definition(), 00129 array( "id" => $id ) ); 00130 } 00131 00132 /*! 00133 Fetch Class group by name, and return first result. 00134 00135 \param name 00136 \param asObject 00137 */ 00138 static function fetchByName( $name, $asObject = true ) 00139 { 00140 $conds = array( 'name' => $name ); 00141 return eZPersistentObject::fetchObject( eZContentClassGroup::definition(), 00142 null, 00143 $conds, 00144 $asObject ); 00145 } 00146 00147 static function fetch( $id, $user_id = false, $asObject = true ) 00148 { 00149 $conds = array( "id" => $id ); 00150 if ( $user_id !== false and is_numeric( $user_id ) ) 00151 $conds["creator_id"] = $user_id; 00152 return eZPersistentObject::fetchObject( eZContentClassGroup::definition(), 00153 null, 00154 $conds, 00155 $asObject ); 00156 } 00157 00158 static function fetchList( $user_id = false, $asObject = true ) 00159 { 00160 $conds = array(); 00161 if ( $user_id !== false and is_numeric( $user_id ) ) 00162 $conds["creator_id"] = $user_id; 00163 return eZPersistentObject::fetchObjectList( eZContentClassGroup::definition(), 00164 null, $conds, null, null, 00165 $asObject ); 00166 } 00167 00168 /*! 00169 Appends the class \a $class to this group. 00170 \param $class Can either be an eZContentClass object or a class ID. 00171 \return the class group link object. 00172 \note tranaction unsafe. 00173 */ 00174 function appendClass( $class, $version = false ) 00175 { 00176 if ( $class instanceof eZContentClass ) 00177 { 00178 $classID = $class->attribute( 'id' ); 00179 $version = $class->attribute( 'version' ); 00180 } 00181 else 00182 { 00183 $classID = $class; 00184 } 00185 $classGroupLink = eZContentClassClassGroup::create( $classID, 00186 $version, 00187 $this->attribute( 'id' ), 00188 $this->attribute( 'name' ) ); 00189 $classGroupLink->store(); 00190 return $classGroupLink; 00191 } 00192 00193 public $ID; 00194 public $Name; 00195 public $CreatorID; 00196 public $ModifierID; 00197 public $Created; 00198 public $Modified; 00199 } 00200 00201 ?>