Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezmessagemessagedefinition.php
Go to the documentation of this file.
1 <?php
4 // include_once( "classes/ezdb.php" );
5
6
7 class eZMessageDefinition
8 {
12 function eZMessageDefinition( $id=-1 )
13 {
14 if ( $id != -1 )
15 {
16 $this->ID = $id;
17 $this->get( $this->ID );
18 }
19 }
20
24 function store()
25 {
26 $db =& eZDB::globalDatabase();
27 $db->begin();
28
29 if ( !isset( $this->ID ) )
30 {
31 $db->lock( "eZMessage_MessageDefinition" );
32 $nextID = $db->nextID( "eZMessage_MessageDefinition", "ID" );
33 $res[] = $db->query( "INSERT INTO eZMessage_MessageDefinition
34 ( ID,
35 MessageID,
36 FromUserID,
37 ToUserID )
38 VALUES
39 ( '$nextID',
40 '$this->MessageID',
41 '$this->FromUserID',
42 '$this->ToUserID' )" );
43 $this->ID = $nextID;
44 }
45 else
46 {
47 $res[] = $db->query( "UPDATE eZMessage_MessageDefinition SET
48 MessageID='$this->MessageID',
49 FromUserID='$this->FromUserID',
50 ToUserID='$this->ToUserID'
51 WHERE ID='$this->ID'" );
52 }
53
54 eZDB::finish( $res, $db );
55 return true;
56 }
57
61 function delete()
62 {
63 $db =& eZDB::globalDatabase();
64 $db->begin();
65
66 if ( isset( $this->ID ) )
67 {
68 $res[] = $db->query( "DELETE FROM eZMessage_MessageDefinition WHERE ID='$this->ID'" );
69 }
70
71 eZDB::finish( $res, $db );
72 return true;
73 }
74
81 function &getMessageID( $id=-1 )
82 {
83 $db =& eZDB::globalDatabase();
84
85 $return_array = array();
86 $message_array = array();
87
88 $query ="SELECT * FROM eZMessage_MessageDefinition WHERE MessageID='$id'";
89
90 $db->array_query( $message_array, $query );
91 foreach ( $message_array as $message )
92 {
93 $return_array[] = new eZMessageDefinition( $message[0] );
94 }
95 return $return_array;
96 }
97
103 function get( $id=-1 )
104 {
105 $db =& eZDB::globalDatabase();
106
107 $ret = false;
108 if ( $id != "" )
109 {
110 $db->array_query( $message_array, "SELECT * FROM eZMessage_MessageDefinition WHERE ID='$id'" );
111 if( count( $message_array ) == 1 )
112 {
113 $this->ID =& $message_array[0][$db->fieldName( "ID" )];
114 $this->MessageID =& $message_array[0][$db->fieldName( "MessageID" )];
115 $this->FromUserID =& $message_array[0][$db->fieldName( "FromUserID" )];
116 $this->ToUserID =& $message_array[0][$db->fieldName( "ToUserID" )];
117 $ret = true;
118 }
119 elseif( count( $message_array ) == 1 )
120 {
121 $this->ID = 0;
122 }
123 }
124 return $ret;
125 }
126
127
131 function &getAll( )
132 {
133 $db =& eZDB::globalDatabase();
134
135 $return_array = array();
136 $message_array = array();
137
138
139 $db->array_query( $message_array, "SELECT ID FROM eZMessage_MessageDefinition
140 ORDER By Created" );
141
142 foreach ( $message_array as $message )
143 {
144 $return_array[] = new eZMessageDefinition( $message[0] );
145 }
146 return $return_array;
147 }
148
152 function &messagesToUser( $user )
153 {
154 $userID = $user->id();
155 $db =& eZDB::globalDatabase();
156
157 $return_array = array();
158 $message_array = array();
159
160
161 $db->array_query( $message_array, "SELECT ID FROM eZMessage_MessageDefinition
162 WHERE ToUserID='$userID'
163 ORDER By Created DESC" );
164
165 foreach ( $message_array as $message )
166 {
167 $return_array[] = new eZMessageDefinition( $message[0] );
168 }
169 return $return_array;
170 }
171
175 function id()
176 {
177 return $this->ID;
178 }
179
183 function setMessageID( $value )
184 {
185 $this->MessageID = $value;
186 }
187
191 function MessageID()
192 {
193 return $this->MessageID;
194 }
195
199 function setFromUserID( $user )
200 {
201 if ( get_class( $user ) == "eZUser" )
202 {
203 $this->FromUserID = $user->id();
204 }
205 }
206
210 function fromUserID()
211 {
212 return new eZUser( $this->FromUserID );
213 }
214
215
219 function &toUserID()
220 {
221 $ret = new eZUser( $this->ToUserID );
222 return $ret;
223 }
224
228 function setToUserID( $user )
229 {
230 if ( get_class( $user ) == "eZUser" )
231 {
232 $this->ToUserID = $user->id();
233 }
234 }
235
236 var $ID;
237 var $MessageID;
238 var $FromUserID;
239 var $ToUserID;
240 }
241
242 ?>
$message
$message
Definition: admin/message.php:51
$userID
else $userID
Definition: appointmentedit.php:121
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZMessageDefinition
Definition: ezmessagemessagedefinition.php:8
eZMessageDefinition\eZMessageDefinition
eZMessageDefinition( $id=-1)
Definition: ezmessagemessagedefinition.php:12
eZMessageDefinition\fromUserID
fromUserID()
Definition: ezmessagemessagedefinition.php:210
eZMessageDefinition\setFromUserID
setFromUserID( $user)
Definition: ezmessagemessagedefinition.php:199
eZMessageDefinition\MessageID
MessageID()
Definition: ezmessagemessagedefinition.php:191
eZMessageDefinition\$FromUserID
$FromUserID
Definition: ezmessagemessagedefinition.php:238
eZMessageDefinition\$ID
$ID
Definition: ezmessagemessagedefinition.php:236
eZMessageDefinition\getAll
& getAll()
Definition: ezmessagemessagedefinition.php:131
eZMessageDefinition\toUserID
& toUserID()
Definition: ezmessagemessagedefinition.php:219
eZMessageDefinition\id
id()
Definition: ezmessagemessagedefinition.php:175
eZMessageDefinition\store
store()
Definition: ezmessagemessagedefinition.php:24
eZMessageDefinition\setMessageID
setMessageID( $value)
Definition: ezmessagemessagedefinition.php:183
eZMessageDefinition\getMessageID
& getMessageID( $id=-1)
Definition: ezmessagemessagedefinition.php:81
eZMessageDefinition\setToUserID
setToUserID( $user)
Definition: ezmessagemessagedefinition.php:228
eZMessageDefinition\$ToUserID
$ToUserID
Definition: ezmessagemessagedefinition.php:239
eZMessageDefinition\messagesToUser
& messagesToUser( $user)
Definition: ezmessagemessagedefinition.php:152
eZMessageDefinition\$MessageID
$MessageID
Definition: ezmessagemessagedefinition.php:237
eZUser
Definition: ezuser.php:76
$id
$id
Definition: companytypelist.php:193
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.