ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

rating_access.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class rating_access_1_0_0{
27
38 var $NativeTable = '`umx_rating`';
39
50 var $Database = false;
51 var $DatabaseAlgorithms = false;
52 var $Link = false;
53 var $Security = false;
54 var $SecurityParser = false;
55
66 function __construct()
67 {
68 try
69 {
70 $this->Database = get_package( 'database' , 'last' , __FILE__ );
71 $this->DatabaseAlgorithms = get_package( 'database::database_algorithms' , 'last' , __FILE__ );
72 $this->Link = get_package( 'link' , 'last' , __FILE__ );
73 $this->Security = get_package( 'security' , 'last' , __FILE__ );
74 $this->SecurityParser = get_package( 'security::security_parser' , 'last' , __FILE__ );
75 }
76 catch( Exception $e )
77 {
78 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
79 }
80 }
81
104 function unsafe_select( $Condition )
105 {
106 try
107 {
108 $this->Database->query_as( DB_OBJECT );
109
110 return( $this->Database->select( '*' , $this->NativeTable , $Condition ) );
111 }
112 catch( Exception $e )
113 {
114 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
115 }
116 }
117
140 function select_list( $id )
141 {
142 try
143 {
144 $id = $this->Security->get( $id , 'integer_list' );
145
146 return( $this->unsafe_select( $this->NativeTable.".id IN ( $id ) ORDER BY id DESC" ) );
147 }
148 catch( Exception $e )
149 {
150 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
151 }
152 }
153
172 private function rise_create_event( $id )
173 {
174 try
175 {
176 $EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
177 $EventManager->trigger_event( 'on_after_create_rating' , array( 'id' => $id ) );
178 }
179 catch( Exception $e )
180 {
181 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
182 }
183 }
184
207 function create( $Record )
208 {
209 try
210 {
211 $MasterLink = $this->SecurityParser->parse_parameters(
212 $Record , 'master_type:command;master_id:integer'
213 );
214
215 $Record = array( 'value' => 0 );
216
217 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
218
219 $id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
220
221 $Link = get_package( 'link' , 'last' , __FILE__ );
222 $Link->create_link(
223 get_field( $MasterLink , 'master_id' ) , $id ,
224 get_field( $MasterLink , 'master_type' ) , 'rating'
225 );
226
227 $this->rise_create_event( $id );
228
229 return( $id );
230 }
231 catch( Exception $e )
232 {
233 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
234 }
235 }
236
259 function update( $id , $Record )
260 {
261 try
262 {
263 $id = $this->Security->get( $id , 'integer_list' );
264 $Record = $this->SecurityParser->parse_parameters( $Record , 'value:float' , 'allow_not_set' );
265
266 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
267
268 if( isset( $Fields[ 0 ] ) )
269 {
270 $this->Database->update(
271 $this->NativeTable , $Fields , $Values , "( $this->AddLimitations ) AND id IN ( $id )"
272 );
273 $this->Database->commit();
274 }
275 }
276 catch( Exception $e )
277 {
278 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
279 }
280 }
281 }
282
283 ?>