[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

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

   1  <?php
   2  //
   3  // Definition of eZCollaborationProfile class
   4  //
   5  // Created on: <28-Jan-2003 16:45:06 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 ezcollaborationprofile.php
  30  */
  31  
  32  /*!
  33    \class eZCollaborationProfile ezcollaborationprofile.php
  34    \brief The class eZCollaborationProfile does
  35  
  36  */
  37  
  38  include_once ( 'kernel/classes/ezpersistentobject.php' );
  39  include_once ( 'kernel/classes/ezcollaborationgroup.php' );
  40  
  41  class eZCollaborationProfile extends eZPersistentObject
  42  {
  43      /*!
  44       Constructor
  45      */
  46      function eZCollaborationProfile( $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                                           'user_id' => array( 'name' => 'UserID',
  58                                                               'datatype' => 'integer',
  59                                                               'default' => 0,
  60                                                               'required' => true,
  61                                                               'foreign_class' => 'eZUser',
  62                                                               'foreign_attribute' => 'contentobject_id',
  63                                                               'multiplicity' => '1..*' ),
  64                                           'main_group' => array( 'name' => 'MainGroup',
  65                                                                  'datatype' => 'integer',
  66                                                                  'default' => 0,
  67                                                                  'required' => true,
  68                                                                  'foreign_class' => 'eZCollaborationGroup',
  69                                                                  'foreign_attribute' => 'id',
  70                                                                  'multiplicity' => '1..*' ),
  71                                           'data_text1' => array( 'name' => 'DataText1',
  72                                                                  'datatype' => 'text',
  73                                                                  'default' => '',
  74                                                                  'required' => true ),
  75                                           'created' => array( 'name' => 'Created',
  76                                                               'datatype' => 'integer',
  77                                                               'default' => 0,
  78                                                               'required' => true ),
  79                                           'modified' => array( 'name' => 'Modified',
  80                                                                'datatype' => 'integer',
  81                                                                'default' => 0,
  82                                                                'required' => true ) ),
  83                        'keys' => array( 'id' ),
  84                        'increment_key' => 'id',
  85                        'class_name' => 'eZCollaborationProfile',
  86                        'name' => 'ezcollab_profile' );
  87      }
  88  
  89      function &create( $userID, $mainGroup = 0 )
  90      {
  91          $date_time = time();
  92          $row = array( 'id' => null,
  93                        'user_id' => $userID,
  94                        'main_group' => $mainGroup,
  95                        'created' => $date_time,
  96                        'modified' => $date_time );
  97          $newCollaborationProfile = new eZCollaborationProfile( $row );
  98          return $newCollaborationProfile;
  99      }
 100  
 101      function fetch( $id, $asObject = true )
 102      {
 103          $conditions = array( "id" => $id );
 104          return eZPersistentObject::fetchObject( eZCollaborationProfile::definition(),
 105                                                  null,
 106                                                  $conditions,
 107                                                  $asObject );
 108      }
 109  
 110      function fetchByUser( $userID, $asObject = true )
 111      {
 112          $conditions = array( "user_id" => $userID );
 113          return eZPersistentObject::fetchObject( eZCollaborationProfile::definition(),
 114                                                  null,
 115                                                  $conditions,
 116                                                  $asObject );
 117      }
 118  
 119      /*!
 120       \note Transaction unsafe. If you call several transaction unsafe methods you must enclose
 121       the calls within a db transaction; thus within db->begin and db->commit.
 122       */
 123      function &instance( $userID = false )
 124      {
 125          if ( $userID === false )
 126          {
 127              $user =& eZUser::currentUser();
 128              $userID = $user->attribute( 'contentobject_id' );
 129          }
 130          $instance =& $GLOBALS["eZCollaborationProfile-$userID"];
 131          if ( !isset( $instance ) )
 132          {
 133              $instance = eZCollaborationProfile::fetchByUser( $userID );
 134              if ( $instance === null )
 135              {
 136                  $group =& eZCollaborationGroup::instantiate( $userID, ezi18n( 'kernel/classes', 'Inbox' ) );
 137                  $instance = eZCollaborationProfile::create( $userID, $group->attribute( 'id' ) );
 138                  $instance->store();
 139              }
 140          }
 141          return $instance;
 142      }
 143  
 144  }
 145  
 146  ?>


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