Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezproductpermission.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezproductpermission.php 7382 2001-09-21 14:28:49Z jhe $
5 //
6 // Definition of eZProductPermission class
7 //
8 // Created on: <06-Aug-2001 10:01:09 jhe>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 // Copyright (C) 1999-2001 eZ systems as
12 //
13 // This program is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU General Public License
15 // as published by the Free Software Foundation; either version 2
16 // of the License, or (at your option) any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
26 //
27
30
34 // include_once( "classes/ezdb.php" );
35
36 class eZProductPermission
37 {
38 function hasPermission( $productID, $user = false )
39 {
40 $db =& eZDB::globalDatabase();
41
42 if ( is_a( $user, "eZUser" ) )
43 {
44 $user =& eZUser::currentUser();
45 }
46
47 if ( !$user )
48 return false;
49 $ret = false;
50
51 $groups =& $user->groups( false );
52 foreach ( $groups as $groupItem )
53 {
54 $db->array_query( $permissions, "SELECT * FROM eZTrade_ProductPermissionLink
55 WHERE GroupID='" . $groupItem ."'" );
56 if ( count( $permissions ) > 0 )
57 {
58 $ret = true;
59 }
60 }
61 return $ret;
62 }
63
64 function getPermissionList( $productID )
65 {
66 $db =& eZDB::globalDatabase();
67 $db->array_query( $list, "SELECT * FROM eZTrade_ProductPermissionLink
68 WHERE ProductID='$productID'" );
69 $ret = array();
70 foreach ( $list as $element )
71 {
72 $ret[] = $element[$db->fieldName( "GroupID" )];
73 }
74 return $ret;
75 }
76
77 function setPermission( $productID, $groupID )
78 {
79 $db =& eZDB::globalDatabase();
80 $db->begin();
81 $db->lock( "eZTrade_ProductPermissionLink" );
82 $nextID = $db->nextID( "eZTrade_ProductPermissionLink" );
83 $res[] = $db->query( "INSERT INTO eZTrade_ProductPermissionLink (ID, ProductID, GroupID)
84 VALUES ('$nextID', '$productID', '$groupID')" );
85 $db->unlock();
86 eZDB::finish( $res, $db );
87 }
88
89 function removePermissions( $productID )
90 {
91 $db =& eZDB::globalDatabase();
92
93 $db->begin();
94 $res[] = $db->query( "DELETE FROM eZTrade_ProductPermissionLink
95 WHERE ProductID='$productID'" );
96 eZDB::finish( $res, $db );
97 }
98 }
99
100 ?>
101
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZProductPermission
Definition: ezproductpermission.php:37
eZProductPermission\getPermissionList
getPermissionList( $productID)
Definition: ezproductpermission.php:64
eZProductPermission\setPermission
setPermission( $productID, $groupID)
Definition: ezproductpermission.php:77
eZProductPermission\removePermissions
removePermissions( $productID)
Definition: ezproductpermission.php:89
eZProductPermission\hasPermission
hasPermission( $productID, $user=false)
Definition: ezproductpermission.php:38
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$db
$db
Definition: ezarticle/user/authorlist.php:53
$groups
if( $CategoryID !=0) $groups
Definition: ezbulkmail/admin/categoryedit.php:108
$groupID
$groupID
Definition: ezgroupeventcalendar/user/dayview.php:90
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$element
if(! $parent) $element
Definition: folder.php:64
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.