| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZOrderStatusHistory class 4 // 5 // Created on: <07-Apr-2005 16:27:14 amos> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezorderstatushistory.php 30 */ 31 32 /*! 33 \class eZOrderStatusHistory ezorderstatushistory.php 34 \brief Handles a list of status changes to an order item. 35 36 This uses the database table ezorder_status_history to store changes 37 in status for an order item. 38 Each entry consists of the new status, the time it was done and the 39 person who did the change. 40 41 The \c order_id refers to the external ID of an order (\c order_nr) 42 and not the internal auto increment value. 43 44 To fetch a given history element use fetch() with the history ID. 45 If you intend to display the history elements for an order item use 46 the fetchListByOrder() function which returns the history sorted by 47 date (newest first). 48 If you are interested in the number of history elements for an order 49 use the fetchCount() function. 50 51 If you intend to create a new history element use the create() function. 52 53 */ 54 55 include_once ( "kernel/classes/ezpersistentobject.php" ); 56 57 class eZOrderStatusHistory extends eZPersistentObject 58 { 59 /*! 60 Initialises the persistent object with \a $row. 61 If \c status_name is present in \a $row it will cache it in the $StatusName variable. 62 */ 63 function eZOrderStatusHistory( $row ) 64 { 65 $this->eZPersistentObject( $row ); 66 $this->Modifier = null; 67 $this->StatusName = null; 68 if ( isset( $row['status_name'] ) ) 69 $this->StatusName = $row['status_name']; 70 } 71 72 /*! 73 \return the persistent object definition for the eZOrderStatusHistory class. 74 */ 75 function definition() 76 { 77 return array( "fields" => array( "id" => array( 'name' => 'ID', 78 'datatype' => 'integer', 79 'default' => 0, 80 'required' => true ), 81 "order_id" => array( 'name' => 'OrderID', 82 'datatype' => 'integer', 83 'default' => 0, 84 'required' => true, 85 'foreign_class' => 'eZOrder', 86 'foreign_attribute' => 'id', 87 'multiplicity' => '1..*' ), 88 "status_id" => array( 'name' => 'StatusID', 89 'datatype' => 'integer', 90 'default' => 0, 91 'required' => true, 92 'foreign_class' => 'eZOrderStatus', 93 'foreign_attribute' => 'id', 94 'multiplicity' => '1..*' ), 95 "modifier_id" => array( 'name' => "ModifierID", 96 'datatype' => 'integer', 97 'default' => 0, 98 'required' => true, 99 'foreign_class' => 'eZUser', 100 'foreign_attribute' => 'contentobject_id', 101 'multiplicity' => '1..*' ), 102 "modified" => array( 'name' => "Modified", 103 'datatype' => 'integer', 104 'default' => 0, 105 'required' => true ) ), 106 'function_attributes' => array( 'modifier' => 'modifier', 107 'status_name' => 'fetchOrderStatusName', 108 'status' => 'fetchOrderStatus' ), 109 "keys" => array( "id" ), 110 "increment_key" => "id", 111 "class_name" => "eZOrderStatusHistory", 112 "name" => "ezorder_status_history" ); 113 } 114 115 /*! 116 \return The user which modified the status, this is returned as a content object. 117 \note The field \c modified_id is used to find the user, this will contain 118 the content object ID of the user. 119 */ 120 function &modifier() 121 { 122 if ( $this->Modifier === null ) 123 { 124 include_once ( 'kernel/classes/ezcontentobject.php' ); 125 $this->Modifier =& eZContentObject::fetch( $this->ModifierID ); 126 } 127 return $this->Modifier; 128 } 129 130 /*! 131 \return The order status object for this history entry. 132 \sa fetchOrderStatusName() 133 */ 134 function &fetchOrderStatus() 135 { 136 include_once ( 'kernel/classes/ezorderstatus.php' ); 137 $statusList = eZOrderStatus::fetchMap( true, true ); 138 if ( isset( $statusList[$this->StatusID] ) ) 139 return $statusList[$this->StatusID]; 140 $retValue = false; 141 return $retValue; 142 } 143 144 /*! 145 \return The name of the order status for this history entry. 146 \sa fetchOrderStatus() 147 */ 148 function &fetchOrderStatusName() 149 { 150 if ( $this->StatusName === null ) 151 { 152 $status = $this->fetchOrderStatus(); 153 $this->StatusName = $status->attribute( 'name' ); 154 } 155 return $this->StatusName; 156 } 157 158 /*! 159 \static 160 \return the status history object with the given DB ID. 161 */ 162 function fetch( $id, $asObject = true ) 163 { 164 return eZPersistentObject::fetchObject( eZOrderStatusHistory::definition(), 165 null, 166 array( "id" => $id ), 167 $asObject ); 168 } 169 170 /*! 171 \static 172 \param $asObject If \c true return them as objects. 173 \return A list of defined orders sorted by status ID. 174 */ 175 function fetchListByOrder( $orderID, $asObject = true ) 176 { 177 $db =& eZDB::instance(); 178 179 $orderID = (int)$orderID; 180 $rows = $db->arrayQuery( "SELECT ezorder_status_history.*, ezorder_status.name AS status_name\n" . 181 "FROM ezorder_status_history, ezorder_status\n" . 182 "WHERE order_id = $orderID AND\n" . 183 " ezorder_status.status_id = ezorder_status_history.status_id\n" . 184 "ORDER BY ezorder_status_history.modified DESC" ); 185 186 return eZPersistentObject::handleRows( $rows, 'eZOrderStatusHistory', $asObject ); 187 } 188 189 /*! 190 \static 191 \param $asObject If \c true return them as objects. 192 \return A list of defined orders sorted by status ID. 193 */ 194 function fetchCount( $orderID, $asObject = true ) 195 { 196 $db =& eZDB::instance(); 197 198 $orderID = (int)$orderID; 199 $countArray = $db->arrayQuery( "SELECT count( * ) AS count FROM ezorder_status_history WHERE order_id = $orderID" ); 200 return $countArray[0]['count']; 201 } 202 203 /*! 204 \static 205 \return A new eZOrderStatusHistory object initialized with the input parameters. 206 */ 207 function create( $orderID, $statusID, $userID = false, $timestamp = false ) 208 { 209 if ( $timestamp === false ) 210 $timestamp = mktime(); 211 if ( $userID === false ) 212 $userID = eZUser::currentUserID(); 213 $row = array( 'id' => null, 214 'order_id' => $orderID, 215 'status_id' => $statusID, 216 'modifier_id' => $userID, 217 'modified' => $timestamp ); 218 return new eZOrderStatusHistory( $row ); 219 } 220 221 222 /// \privatesection 223 /// This is used for caching the current modifier, 224 /// it will either contain \c null (uncached) or a content object (cached). 225 var $Modifier; 226 } 227 228 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |