Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eztipafriendrequest.php
Go to the documentation of this file.
1 <?php
16 class eZTipafriendRequest extends eZPersistentObject
17 {
18 static function definition()
19 {
20 return array( "fields" => array( 'email_receiver' => array( 'name' => 'EmailReceiver',
21 'datatype' => 'string',
22 'default' => '',
23 'required' => true ),
24 'created' => array( 'name' => 'Created',
25 'datatype' => 'integer',
26 'default' => 0,
27 'required' => true ) ),
28 'keys' => array( 'email_receiver' ),
29 'class_name' => 'eZTipafriendRequest',
30 'sort' => array( 'created' => 'desc' ),
31 'name' => 'eztipafriend_request' );
32 }
33
34 static function create( $receiver )
35 {
36 $row = array( "email_receiver" => $receiver,
37 "created" => time() );
38 return new eZTipafriendRequest( $row );
39 }
40
41 static function checkReceiver( $receiver )
42 {
43 eZTipafriendRequest::cleanup();
44 $ini = eZINI::instance();
45 $timeFrame = 1;
46 if ( $ini->hasVariable( 'TipAFriend', 'TimeFrame' ) )
47 $timeFrame = $ini->variable( 'TipAFriend', 'TimeFrame' );
48 $time = time() - $timeFrame * 3600;
49 $requestsPerTimeframe = 1;
50 if ( $ini->hasVariable( 'TipAFriend', 'MaxRequestsPerTimeframe' ) )
51 $requestsPerTimeframe = $ini->variable( 'TipAFriend', 'MaxRequestsPerTimeframe' );
52
53 $db = eZDB::instance();
54 $receiver = $db->escapeString( $receiver );
55 $countResult = $db->arrayQuery( "SELECT count(*) as count
56 FROM eztipafriend_request
57 WHERE email_receiver = '$receiver'
58 AND created > $time " );
59 $count = 0;
60 if ( isset( $countResult[0]['count'] ) )
61 $count = $countResult[0]['count'];
62 if ( $count >= $requestsPerTimeframe )
63 return false;
64 return true;
65 }
66
71 static function cleanup()
72 {
73 $ini = eZINI::instance();
74 $db = eZDB::instance();
75 $timeFrame = 1;
76 if ( $ini->hasVariable( 'TipAFriend', 'TimeFrame' ) )
77 $timeFrame = $ini->variable( 'TipAFriend', 'TimeFrame' );
78 $time = time() - $timeFrame * 3600;
79
80 $db->query( "DELETE FROM eztipafriend_request
81 WHERE created < $time " );
82 }
83
84 }
85
86 ?>
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZPersistentObject
Definition: ezpersistentobject.php:33
eZTipafriendRequest
The class eZTipafriendRequest does.
Definition: eztipafriendrequest.php:17
eZTipafriendRequest\definition
static definition()
Definition: eztipafriendrequest.php:18
eZTipafriendRequest\cleanup
static cleanup()
Definition: eztipafriendrequest.php:71
eZTipafriendRequest\checkReceiver
static checkReceiver( $receiver)
Definition: eztipafriendrequest.php:41
eZTipafriendRequest\create
static create( $receiver)
Definition: eztipafriendrequest.php:34
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.