Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezbulkmailusersubscripter.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezbulkmailusersubscripter.php 8074 2001-10-29 15:54:16Z fh $
5 //
6 // eZBulkMailUserSubscription class
7 //
8 // Created on: <17-Apr-2001 13:21:53 fh>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
39 // include_once( "ezuser/classes/ezuser.php" );
40
41 class eZBulkMailUserSubscripter
42 {
45 function __construct( $user, $categoryID=false )
46 {
47 if ( get_class ( $user ) )
48 $this->setUser( $user );
49 else if ( is_numeric ( $user ) )
50 $this->setUser( new eZUser ( $user ) );
51
52 $this->CategoryID = $categoryID;
53 }
54
55 function setUser( $user )
56 {
57 if ( is_a( $user, "eZUser" ) )
58 {
59 $this->User = $user;
60 }
61 }
62
63 function user()
64 {
65 return $this->User;
66 }
67
71 function categoryID()
72 {
73 return $this->CategoryID;
74 }
75
79 function subscriptions( $asObjects = true )
80 {
81 $db =& eZDB::globalDatabase();
82 $final_result = array();
83 $userID = $this->User->id();
84 $db->array_query( $result_array, "SELECT CategoryID FROM eZBulkMail_UserCategoryLink WHERE UserID='$userID'" );
85 if( count( $result_array ) > 0 )
86 {
87 foreach( $result_array as $result )
88 $final_result[] = $asObjects ? new eZBulkMailCategory( $result[$db->fieldName( "CategoryID" )] ) : $result[$db->fieldName( "CategoryID" )];
89 }
90 return $final_result;
91 }
92
96 function subscribe( $categoryID )
97 {
98 if( is_a( $categoryID, "eZBulkMailCategory" ) )
99 $categoryID = $categoryID->id();
100
101 $userID = $this->User->id();
102 $db =& eZDB::globalDatabase();
103 $db->begin();
104 $db->lock( "eZBulkMail_UserCategoryLink" );
105 $db->array_query( $check, "SELECT UserID
106 FROM eZBulkMail_UserCategoryLink
107 WHERE CategoryID='$categoryID'
108 AND UserID='$userID'
109 " );
110 $result = false;
111 if ( count( $check ) == 0 )
112 {
113 $result = $db->query( "INSERT INTO eZBulkMail_UserCategoryLink ( UserID, CategoryID ) VALUES ( '$userID', '$categoryID' )" );
114
115 if ( $result == false )
116 $db->rollback( );
117 else
118 $db->commit();
119
120 $db->unlock();
121 return true;
122 }
123 else
124 {
125 $db->rollback( );
126 $db->unlock();
127 return false;
128 }
129 }
130
134 function unsubscribe( $category )
135 {
136 $db =& eZDB::globalDatabase();
137 $userID = $this->User->id();
138 if( is_a( $category, "eZBulkMailCategory" ) )
139 {
140 $categoryID = $category->id();
141 $db->query( "DELETE FROM eZBulkMail_UserCategoryLink WHERE UserID='$userID' AND CategoryID='$categoryID'" );
142 }
143 else if( $category == true )
144 {
145 $db->query( "DELETE FROM eZBulkMail_UserCategoryLink WHERE UserID='$userID'" );
146 }
147 }
148
152 function eMail()
153 {
154 $ret_val = "unknown";
155 if( is_a( $this->User, "eZUser" ) )
156 {
157 $ret_val = $this->User->eMail();
158 }
159 return $ret_val;
160 }
161
165 function addDelay( $category, $delay )
166 {
167 $db =& eZDB::globalDatabase();
168 $db->begin();
169 $db->lock( "eZBulkMail_UserCategorySettings" );
170 $userID = $this->User->id();
171
172 $res[] = $db->query( "DELETE FROM eZBulkMail_UserCategorySettings WHERE CategoryID='$category'" );
173 $nextID = $db->nextID( "eZBulkMail_UserCategorySettings", "ID" );
174 $res[] = $db->query( "INSERT INTO eZBulkMail_UserCategorySettings ( ID, CategoryID, UserID, Delay ) VALUES ( '$nextID','$category','$userID','$delay' )" );
175
176 $db->unlock();
177 if ( in_array( false, $res ) )
178 $db->rollback();
179 else
180 $db->commit();
181 }
182
183 var $ID;
184 var $CategoryID;
185 var $User;
186 }
187
188 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$userID
else $userID
Definition: appointmentedit.php:121
eZBulkMailUserSubscripter
Definition: ezbulkmailusersubscripter.php:42
eZBulkMailUserSubscripter\eMail
eMail()
Definition: ezbulkmailusersubscripter.php:152
eZBulkMailUserSubscripter\unsubscribe
unsubscribe( $category)
Definition: ezbulkmailusersubscripter.php:134
eZBulkMailUserSubscripter\$ID
$ID
Definition: ezbulkmailusersubscripter.php:183
eZBulkMailUserSubscripter\$CategoryID
$CategoryID
Definition: ezbulkmailusersubscripter.php:184
eZBulkMailUserSubscripter\user
user()
Definition: ezbulkmailusersubscripter.php:63
eZBulkMailUserSubscripter\setUser
setUser( $user)
Definition: ezbulkmailusersubscripter.php:55
eZBulkMailUserSubscripter\addDelay
addDelay( $category, $delay)
Definition: ezbulkmailusersubscripter.php:165
eZBulkMailUserSubscripter\subscribe
subscribe( $categoryID)
Definition: ezbulkmailusersubscripter.php:96
eZBulkMailUserSubscripter\categoryID
categoryID()
Definition: ezbulkmailusersubscripter.php:71
eZBulkMailUserSubscripter\subscriptions
subscriptions( $asObjects=true)
Definition: ezbulkmailusersubscripter.php:79
eZBulkMailUserSubscripter\__construct
__construct( $user, $categoryID=false)
Definition: ezbulkmailusersubscripter.php:45
eZBulkMailUserSubscripter\$User
$User
Definition: ezbulkmailusersubscripter.php:185
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZUser
Definition: ezuser.php:76
$result
$result
Definition: companysearch.php:94
$db
$db
Definition: ezarticle/user/authorlist.php:53
$res
$res
Definition: ezstats/admin/cron.php:45
$categoryID
else $categoryID
Definition: productview.php:66
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.