[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/classes/ -> ezcollaborationitemmessagelink.php (source)

   1  <?php
   2  //
   3  // Definition of eZCollaborationItemMessageLink class
   4  //
   5  // Created on: <24-Jan-2003 15:11:23 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 ezcollaborationitemmessagelink.php
  30  */
  31  
  32  /*!
  33    \class eZCollaborationItemMessageLink ezcollaborationitemmessagelink.php
  34    \brief The class eZCollaborationItemMessageLink does
  35  
  36  */
  37  
  38  include_once ( 'kernel/classes/ezpersistentobject.php' );
  39  include_once ( "lib/ezdb/classes/ezdb.php" );
  40  
  41  class eZCollaborationItemMessageLink extends eZPersistentObject
  42  {
  43      /*!
  44       Constructor
  45      */
  46      function eZCollaborationItemMessageLink( $row )
  47      {
  48          $this->eZPersistentObject( $row );
  49      }
  50  
  51      function definition()
  52      {
  53          return array( 'fields' => array( 'id' => array( 'name' => 'ID',
  54                                                          'datatype' => 'integer',
  55                                                          'default' => 0,
  56                                                          'required' => true ),
  57                                           'collaboration_id' => array( 'name' => 'CollaborationID',
  58                                                                        'datatype' => 'integer',
  59                                                                        'default' => 0,
  60                                                                        'required' => true,
  61                                                                        'foreign_class' => 'eZCollaborationItem',
  62                                                                        'foreign_attribute' => 'id',
  63                                                                        'multiplicity' => '1..*' ),
  64                                           'message_id' => array( 'name' => 'MessageID',
  65                                                                  'datatype' => 'integer',
  66                                                                  'default' => 0,
  67                                                                  'required' => true,
  68                                                                  'foreign_class' => 'eZCollaborationSimpleMessage',
  69                                                                  'foreign_attribute' => 'id',
  70                                                                  'multiplicity' => '1..*' ),
  71                                           'message_type' => array( 'name' => 'MessageType',
  72                                                                    'datatype' => 'integer',
  73                                                                    'default' => 0,
  74                                                                    'required' => true ),
  75                                           'participant_id' => array( 'name' => 'ParticipantID',
  76                                                                      'datatype' => 'integer',
  77                                                                      'default' => 0,
  78                                                                      'required' => true,
  79                                                                      'foreign_class' => 'eZUser',
  80                                                                      'foreign_attribute' => 'contentobject_id',
  81                                                                      'multiplicity' => '1..*' ),
  82                                           'created' => array( 'name' => 'Created',
  83                                                               'datatype' => 'integer',
  84                                                               'default' => 0,
  85                                                               'required' => true ),
  86                                           'modified' => array( 'name' => 'Modified',
  87                                                                'datatype' => 'integer',
  88                                                                'default' => 0,
  89                                                                'required' => true ) ),
  90                        'keys' => array( 'id' ),
  91                        'function_attributes' => array( 'collaboration_item' => 'collaborationItem',
  92                                                        'participant' => 'participant',
  93                                                        'simple_message' => 'simpleMessage' ),
  94                        'increment_key' => 'id',
  95                        'class_name' => 'eZCollaborationItemMessageLink',
  96                        'name' => 'ezcollab_item_message_link' );
  97      }
  98  
  99      function create( $collaborationID, $messageID, $messageType, $participantID )
 100      {
 101          $dateTime = time();
 102          $row = array(
 103              'collaboration_id' => $collaborationID,
 104              'message_id' => $messageID,
 105              'message_type' => $messageType,
 106              'participant_id' => $participantID,
 107              'created' => $dateTime,
 108              'modified' => $dateTime );
 109          return new eZCollaborationItemMessageLink( $row );
 110      }
 111  
 112      /*!
 113       \note Transaction unsafe. If you call several transaction unsafe methods you must enclose
 114       the calls within a db transaction; thus within db->begin and db->commit.
 115       */
 116      function &addMessage( &$collaborationItem, &$message, $messageType, $participantID = false )
 117      {
 118          $messageID =& $message->attribute( 'id' );
 119          eZDebug::writeDebug( $message );
 120          eZDebug::writeDebug( $messageID );
 121          if ( !$messageID )
 122          {
 123              eZDebug::writeError( 'No message ID, cannot create link', 'eZCollaborationItemMessageLink::addMessage' );
 124              $retValue = null;
 125              return $retValue;
 126          }
 127          if ( $participantID === false )
 128          {
 129              include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
 130              $user =& eZUser::currentUser();
 131              $participantID =& $user->attribute( 'contentobject_id' );
 132          }
 133          $collaborationID = $collaborationItem->attribute( 'id' );
 134          $timestamp = time();
 135          $collaborationItem->setAttribute( 'modified', $timestamp );
 136  
 137          $db =& eZDB::instance();
 138          $db->begin();
 139          $collaborationItem->sync();
 140          $link = eZCollaborationItemMessageLink::create( $collaborationID, $messageID, $messageType, $participantID );
 141          $link->store();
 142          $db->commit();
 143  
 144          return $link;
 145      }
 146  
 147      function fetch( $id, $asObject = true )
 148      {
 149          return eZPersistentObject::fetchObject( eZCollaborationItemMessageLink::definition(),
 150                                                  null,
 151                                                  array( "id" => $id ),
 152                                                  null, null,
 153                                                  $asObject );
 154      }
 155  
 156      function fetchItemCount( $parameters )
 157      {
 158          $parameters = array_merge( array( 'item_id' => false,
 159                                            'conditions' => null ),
 160                                     $parameters );
 161          $itemID = $parameters['item_id'];
 162          $conditions = $parameters['conditions'];
 163          if ( $conditions === null )
 164              $conditions = array();
 165          $conditions['collaboration_id'] = $itemID;
 166  
 167          $objectList = eZPersistentObject::fetchObjectList( eZCollaborationItemMessageLink::definition(),
 168                                                              array(),
 169                                                              $conditions,
 170                                                              null, null,
 171                                                              false,
 172                                                              false,
 173                                                              array( array( 'operation' => 'count( id )',
 174                                                                            'name' => 'count' ) ) );
 175          return $objectList[0]['count'];
 176      }
 177  
 178      function fetchItemList( $parameters )
 179      {
 180          $parameters = array_merge( array( 'as_object' => true,
 181                                            'item_id' => false,
 182                                            'offset' => false,
 183                                            'limit' => false,
 184                                            'sort_by' => false ),
 185                                     $parameters );
 186          $itemID = $parameters['item_id'];
 187          $asObject = $parameters['as_object'];
 188          $offset = $parameters['offset'];
 189          $limit = $parameters['limit'];
 190          $limitArray = null;
 191          if ( $offset and $limit )
 192          {
 193              $limitArray = array( 'offset' => $offset,
 194                                   'limit' => $limit );
 195          }
 196  
 197          return eZPersistentObject::fetchObjectList( eZCollaborationItemMessageLink::definition(),
 198                                                      null,
 199                                                      array( "collaboration_id" => $itemID ),
 200                                                      null, $limitArray,
 201                                                      $asObject );
 202      }
 203  
 204  
 205      function &collaborationItem()
 206      {
 207          if ( isset( $this->CollaborationID ) and $this->CollaborationID )
 208          {
 209              include_once ( 'kernel/classes/ezcollaborationitem.php' );
 210              $item = eZCollaborationItem::fetch( $this->CollaborationID );
 211          }
 212          else
 213              $item = null;
 214          return $item;
 215      }
 216  
 217      function &participant()
 218      {
 219          $participantLink =& eZCollaborationItemParticipantLink::fetch( $this->CollaborationID, $this->ParticipantID );
 220          return $participantLink;
 221      }
 222  
 223      function &simpleMessage()
 224      {
 225          if ( isset( $this->MessageID ) and $this->MessageID )
 226          {
 227              include_once ( 'kernel/classes/ezcollaborationsimplemessage.php' );
 228              $message = eZCollaborationSimpleMessage::fetch( $this->MessageID );
 229          }
 230          else
 231              $message = null;
 232          return $message;
 233      }
 234  
 235      /// \privatesection
 236      var $CollaborationID;
 237      var $MessageID;
 238      var $ParticipantID;
 239      var $Created;
 240      var $Modified;
 241  }
 242  
 243  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7