Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezgeneraldigestusersettings.php
Go to the documentation of this file.
1 <?php
17 class eZGeneralDigestUserSettings extends eZPersistentObject
18 {
19 const TYPE_NONE = 0;
20 const TYPE_WEEKLY = 1;
21 const TYPE_MONTHLY = 2;
22 const TYPE_DAILY = 3;
23
24 static function definition()
25 {
26 return array( "fields" => array( "id" => array( 'name' => 'ID',
27 'datatype' => 'integer',
28 'default' => 0,
29 'required' => true ),
30 "user_id" => array( 'name' => "UserID",
31 'datatype' => 'integer',
32 'default' => 0,
33 'required' => true ),
34 "receive_digest" => array( 'name' => "ReceiveDigest",
35 'datatype' => 'integer',
36 'default' => 0,
37 'required' => true ),
38 "digest_type" => array( 'name' => "DigestType",
39 'datatype' => 'integer',
40 'default' => 0,
41 'required' => true ),
42 "day" => array( 'name' => "Day",
43 'datatype' => 'string',
44 'default' => '',
45 'required' => true ),
46 "time" => array( 'name' => "Time",
47 'datatype' => 'string',
48 'default' => '',
49 'required' => true ) ),
50 "keys" => array( "id" ),
51 "function_attributes" => array(
52 "address" => "address"
53 ),
54 "increment_key" => "id",
55 "sort" => array( "id" => "asc" ),
56 "class_name" => "eZGeneralDigestUserSettings",
57 "name" => "ezgeneral_digest_user_settings" );
58 }
59
66 protected function address()
67 {
68 $user = eZUser::fetch( $this->UserID );
69 if ( $user instanceof eZUser )
70 {
71 return $user->attribute( 'email' );
72 }
73 return '';
74 }
75
76
77 static function create( $userID, $receiveDigest = 0, $digestType = self::TYPE_NONE, $day = '', $time = '' )
78 {
79 return new eZGeneralDigestUserSettings( array( 'user_id' => $userID,
80 'receive_digest' => $receiveDigest,
81 'digest_type' => $digestType,
82 'day' => $day,
83 'time' => $time ) );
84 }
85
93 static function fetchForUser( $address, $asObject = true )
94 {
95 eZDebug::writeStrict(
96 'Method ' . __METHOD__ . ' has been deprecated in 5.0',
97 'Deprecation'
98 );
99 $user = eZUser::fetchByEmail( $address );
100 if ( $user instanceof eZUser )
101 {
102 return self::fetchByUserId( $user->attribute( 'contentobject_id' ), $asObject );
103 }
104 return null;
105 }
106
115 static function fetchByUserId( $userId, $asObject = true )
116 {
117 return eZPersistentObject::fetchObject(
118 self::definition(), null,
119 array( 'user_id' => $userId ), $asObject
120 );
121 }
122
127 static function removeByAddress( $address )
128 {
129 eZDebug::writeStrict(
130 'Method ' . __METHOD__ . ' has been deprecated in 5.0',
131 'Deprecation'
132 );
133 $user = eZUser::fetchByEmail( $address );
134 if ( $user instanceof eZUser )
135 {
136 self::removeByUserID( $user->attribute( 'contentobject_id' ) );
137 }
138 }
139
146 static function removeByUserId( $id )
147 {
148 $db = eZDB::instance();
149 $db->query( "DELETE FROM ezgeneral_digest_user_settings WHERE user_id=" . (int)$id );
150 }
151
156 static function cleanup()
157 {
158 $db = eZDB::instance();
159 $db->query( "DELETE FROM ezgeneral_digest_user_settings" );
160 }
161 }
162
163 ?>
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZDebug\writeStrict
static writeStrict( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:414
eZGeneralDigestUserSettings
The class eZGeneralDigestUserSettings does.
Definition: ezgeneraldigestusersettings.php:18
eZGeneralDigestUserSettings\fetchForUser
static fetchForUser( $address, $asObject=true)
Definition: ezgeneraldigestusersettings.php:93
eZGeneralDigestUserSettings\create
static create( $userID, $receiveDigest=0, $digestType=self::TYPE_NONE, $day='', $time='')
Definition: ezgeneraldigestusersettings.php:77
eZGeneralDigestUserSettings\TYPE_NONE
const TYPE_NONE
Definition: ezgeneraldigestusersettings.php:19
eZGeneralDigestUserSettings\address
address()
Definition: ezgeneraldigestusersettings.php:66
eZGeneralDigestUserSettings\TYPE_WEEKLY
const TYPE_WEEKLY
Definition: ezgeneraldigestusersettings.php:20
eZGeneralDigestUserSettings\removeByAddress
static removeByAddress( $address)
Definition: ezgeneraldigestusersettings.php:127
eZGeneralDigestUserSettings\TYPE_DAILY
const TYPE_DAILY
Definition: ezgeneraldigestusersettings.php:22
eZGeneralDigestUserSettings\TYPE_MONTHLY
const TYPE_MONTHLY
Definition: ezgeneraldigestusersettings.php:21
eZGeneralDigestUserSettings\definition
static definition()
Definition: ezgeneraldigestusersettings.php:24
eZGeneralDigestUserSettings\cleanup
static cleanup()
Definition: ezgeneraldigestusersettings.php:156
eZGeneralDigestUserSettings\removeByUserId
static removeByUserId( $id)
Definition: ezgeneraldigestusersettings.php:146
eZGeneralDigestUserSettings\fetchByUserId
static fetchByUserId( $userId, $asObject=true)
Definition: ezgeneraldigestusersettings.php:115
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZUser
eZUser handles eZ Publish user accounts
Definition: ezuser.php:19
eZUser\fetch
static fetch( $id, $asObject=true)
Definition: ezuser.php:351
eZUser\fetchByEmail
static fetchByEmail( $email, $asObject=true)
Definition: ezuser.php:369
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.