| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZCollaborationItemStatus class 4 // 5 // Created on: <30-Jan-2003 13:51:22 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 ezcollaborationitemstatus.php 30 */ 31 32 /*! 33 \class eZCollaborationItemStatus ezcollaborationitemstatus.php 34 \brief The class eZCollaborationItemStatus does 35 36 */ 37 38 include_once ( 'kernel/classes/ezpersistentobject.php' ); 39 include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' ); 40 41 class eZCollaborationItemStatus extends eZPersistentObject 42 { 43 /*! 44 Constructor 45 */ 46 function eZCollaborationItemStatus( $row ) 47 { 48 $this->eZPersistentObject( $row ); 49 } 50 51 function definition() 52 { 53 return array( 'fields' => array( 'collaboration_id' => array( 'name' => 'CollaborationID', 54 'datatype' => 'integer', 55 'default' => 0, 56 'required' => true, 57 'foreign_class' => 'eZCollaborationItem', 58 'foreign_attribute' => 'id', 59 'multiplicity' => '1..*' ), 60 'user_id' => array( 'name' => 'UserID', 61 'datatype' => 'integer', 62 'default' => 0, 63 'required' => true, 64 'foreign_class' => 'eZUser', 65 'foreign_attribute' => 'contentobject_id', 66 'multiplicity' => '1..*' ), 67 'is_read' => array( 'name' => 'IsRead', 68 'datatype' => 'integer', 69 'default' => 0, 70 'required' => true ), 71 'is_active' => array( 'name' => 'IsActive', 72 'datatype' => 'integer', 73 'default' => 1, 74 'required' => true ), 75 'last_read' => array( 'name' => 'LastRead', 76 'datatype' => 'integer', 77 'default' => 0, 78 'required' => true ) ), 79 'keys' => array( 'collaboration_id', 'user_id' ), 80 'class_name' => 'eZCollaborationItemStatus', 81 'name' => 'ezcollab_item_status' ); 82 } 83 84 function create( $collaborationID, $userID = false ) 85 { 86 if ( $userID === false ) 87 $userID = eZUser::currentUserID(); 88 $row = array( 89 'collaboration_id' => $collaborationID, 90 'user_id' => $userID, 91 'is_read' => false, 92 'is_active' => true, 93 'last_read' => 0 ); 94 $statusObject =& $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID]; 95 $statusObject = new eZCollaborationItemStatus( $row ); 96 return $statusObject; 97 } 98 99 function store() 100 { 101 $stored = eZPersistentObject::store(); 102 $this->updateCache(); 103 return $stored; 104 } 105 106 function updateCache() 107 { 108 $userID = $this->UserID; 109 $collaborationID = $this->CollaborationID; 110 $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID] =& $this; 111 } 112 113 function &fetch( $collaborationID, $userID = false, $asObject = true ) 114 { 115 if ( $userID === false ) 116 $userID = eZUser::currentUserID(); 117 $statusObject =& $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID]; 118 if ( isset( $statusObject ) and $statusObject ) 119 return $statusObject; 120 121 $conditions = array( 'collaboration_id' => $collaborationID, 122 'user_id' => $userID ); 123 $statusObject = eZPersistentObject::fetchObject( eZCollaborationItemStatus::definition(), 124 null, 125 $conditions, 126 $asObject ); 127 return $statusObject; 128 } 129 130 function setLastRead( $collaborationID, $userID = false, $timestamp = false ) 131 { 132 if ( $timestamp === false ) 133 $timestamp = time(); 134 135 eZCollaborationItemStatus::updateFields( $collaborationID, $userID, array( 'last_read' => $timestamp, 136 'is_read' => 1 ) ); 137 } 138 139 function updateFields( $collaborationID, $userID = false, $fields ) 140 { 141 if ( $userID === false ) 142 $userID = eZUser::currentUserID(); 143 144 eZPersistentObject::updateObjectList( array( 'definition' => eZCollaborationItemStatus::definition(), 145 'update_fields' => $fields, 146 'conditions' => array( 'collaboration_id' => $collaborationID, 147 'user_id' => $userID ) ) ); 148 $statusObject =& $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID]; 149 if ( isset( $statusObject ) ) 150 { 151 foreach ( $fields as $field => $value ) 152 { 153 $statusObject->setAttribute( $field, $value ); 154 } 155 } 156 } 157 158 } 159 160 ?>
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 |