eZ Publish  [4.0]
ezcollaborationnotificationrule.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZCollaborationNotificationRule class
00004 //
00005 // Created on: <09-Jul-2003 16:36:55 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 ezcollaborationnotificationrule.php
00032 */
00033 
00034 /*!
00035   \class eZCollaborationNotificationRule ezcollaborationnotificationrule.php
00036   \brief The class eZCollaborationNotificationRule does
00037 
00038 */
00039 //include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
00040 
00041 class eZCollaborationNotificationRule extends eZPersistentObject
00042 {
00043     /*!
00044      Constructor
00045     */
00046     function eZCollaborationNotificationRule( $row )
00047     {
00048         $this->eZPersistentObject( $row );
00049     }
00050 
00051     static function definition()
00052     {
00053         return array( "fields" => array( "id" => array( 'name' => 'ID',
00054                                                         'datatype' => 'integer',
00055                                                         'default' => 0,
00056                                                         'required' => true ),
00057                                          "user_id" => array( 'name' => "UserID",
00058                                                              'datatype' => 'integer',
00059                                                              'default' => 0,
00060                                                              'required' => true,
00061                                                              'foreign_class' => 'eZUser',
00062                                                              'foreign_attribute' => 'contentobject_id',
00063                                                              'multiplicity' => '1..*' ),
00064                                          "collab_identifier" => array( 'name' => "CollaborationIdentifier",
00065                                                                'datatype' => 'string',
00066                                                                'default' => '',
00067                                                                'required' => true ) ),
00068                       "keys" => array( "id" ),
00069                       "function_attributes" => array( 'user' => 'user' ),
00070                       "increment_key" => "id",
00071                       "sort" => array( "id" => "asc" ),
00072                       "class_name" => "eZCollaborationNotificationRule",
00073                       "name" => "ezcollab_notification_rule" );
00074     }
00075 
00076     function user()
00077     {
00078         return eZUser::fetch( $this->attribute( 'user_id' ) );
00079     }
00080 
00081     static function create( $collaborationIdentifier, $userID = false )
00082     {
00083         if ( !$userID )
00084             $userID = eZUser::currentUserID();
00085         return new eZCollaborationNotificationRule( array( 'user_id' => $userID,
00086                                                            'collab_identifier' => $collaborationIdentifier ) );
00087     }
00088 
00089     static function fetchList( $userID = false, $asObject = true )
00090     {
00091         if ( !$userID )
00092             $userID = eZUser::currentUserID();
00093         return eZPersistentObject::fetchObjectList( eZCollaborationNotificationRule::definition(),
00094                                                     null, array( 'user_id' => $userID ),
00095                                                     null, null, $asObject );
00096     }
00097 
00098     static function fetchItemTypeList( $collaborationIdentifier, $userIDList, $asObject = true )
00099     {
00100         if ( is_array( $collaborationIdentifier ) )
00101             $collaborationIdentifier = array( $collaborationIdentifier );
00102         return eZPersistentObject::fetchObjectList( eZCollaborationNotificationRule::definition(),
00103                                                     null, array( 'user_id' => array( $userIDList ),
00104                                                                  'collab_identifier' => $collaborationIdentifier ),
00105                                                     null, null, $asObject );
00106     }
00107 
00108     static function removeByIdentifier( $collaborationIdentifier, $userID = false )
00109     {
00110         if ( !$userID )
00111             $userID = eZUser::currentUserID();
00112         eZPersistentObject::removeObject( eZCollaborationNotificationRule::definition(),
00113                                           array( 'collab_identifier' => $collaborationIdentifier,
00114                                                  'user_id' => $userID ) );
00115     }
00116 
00117     /*!
00118      \static
00119 
00120      Remove notifications by user id
00121 
00122      \param userID
00123     */
00124     static function removeByUserID( $userID )
00125     {
00126         eZPersistentObject::removeObject( eZCollaborationNotificationRule::definition(), array( 'user_id' => $userID ) );
00127     }
00128 
00129     /*!
00130      \static
00131      Removes all notification rules for all collaboration items for all users.
00132     */
00133     static function cleanup()
00134     {
00135         $db = eZDB::instance();
00136         $db->query( "DELETE FROM ezcollab_notification_rule" );
00137     }
00138 }
00139 
00140 ?>