|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZCollaborationItemGroupLink class 00004 // 00005 // Created on: <22-Jan-2003 15:51:09 amos> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! \file ezcollaborationitemgrouplink.php 00032 */ 00033 00034 /*! 00035 \class eZCollaborationItemGroupLink ezcollaborationitemgrouplink.php 00036 \brief The class eZCollaborationItemGroupLink does 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 Constructor 00048 */ 00049 function eZCollaborationItemGroupLink( $row ) 00050 { 00051 $this->eZPersistentObject( $row ); 00052 } 00053 00054 static 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 static 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 static 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 return eZUser::fetch( $this->UserID ); 00165 } 00166 return null; 00167 } 00168 00169 function collaborationItem() 00170 { 00171 if ( isset( $this->CollaborationID ) and $this->CollaborationID ) 00172 { 00173 //include_once( 'kernel/classes/ezcollaborationitem.php' ); 00174 return eZCollaborationItem::fetch( $this->CollaborationID, $this->UserID ); 00175 } 00176 return null; 00177 } 00178 00179 function collaborationGroup() 00180 { 00181 if ( isset( $this->GroupID ) and $this->GroupID ) 00182 { 00183 //include_once( 'kernel/classes/ezcollaborationitem.php' ); 00184 return eZCollaborationGroup::fetch( $this->GroupID, $this->UserID ); 00185 } 00186 return null; 00187 } 00188 00189 00190 /// \privatesection 00191 public $CollaborationID; 00192 public $GroupID; 00193 public $UserID; 00194 public $Created; 00195 public $Modified; 00196 } 00197 00198 ?>