ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

review_algorithms.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 review_algorithms_1_0_0{
27
38 var $FileInputAccess = false;
39 var $LinkUtilities = false;
40 var $ReviewAccess = false;
41 var $Security = false;
42 var $UserAlgorithms = false;
43
54 var $Cache = array();
55
66 function __construct()
67 {
68 try
69 {
70 $this->FileInputAccess = get_package( 'file_input::file_input_access' , 'last' , __FILE__ );
71 $this->LinkUtilities = get_package( 'link::link_utilities' , 'last' , __FILE__ );
72 $this->ReviewAccess = get_package( 'review::review_access' , 'last' , __FILE__ );
73 $this->Security = get_package( 'security' , 'last' , __FILE__ );
74 $this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
75 }
76 catch( Exception $e )
77 {
78 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
79 }
80 }
81
104 function object_exists( $id )
105 {
106 try
107 {
108 $id = $this->Security->get( $id , 'integer' );
109
110 $Records = $this->ReviewAccess->unsafe_select( $this->ReviewAccess->NativeTable.".id = $id" );
111
112 return( count( $Records ) === 1 );
113 }
114 catch( Exception $e )
115 {
116 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
117 }
118 }
119
142 function get_by_id( $id )
143 {
144 try
145 {
146 $id = $this->Security->get( $id , 'integer' );
147
148 $Records = $this->ReviewAccess->unsafe_select( $this->ReviewAccess->NativeTable.".id = $id" );
149
150 if( count( $Records ) == 0 )
151 {
152 throw( new Exception( 'Record was not found' ) );
153 }
154
155 return( $Records[ 0 ] );
156 }
157 catch( Exception $e )
158 {
159 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
160 }
161 }
162
189 function get_records_for_object( $MasterId , $MasterType )
190 {
191 try
192 {
193 if( isset( $this->Cache[ "$MasterId.$MasterType" ] ) )
194 {
195 return( $this->Cache[ "$MasterId.$MasterType" ] );
196 }
197
198 $this->Cache[ "$MasterId.$MasterType" ] = $this->LinkUtilities->get_dependent_objects(
199 $MasterId , $MasterType , 'review' , $this->ReviewAccess
200 );
201
202 return( $this->Cache[ "$MasterId.$MasterType" ] );
203 }
204 catch( Exception $e )
205 {
206 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
207 }
208 }
209
236 function create( &$Record , &$Options )
237 {
238 try
239 {
240 $MasterId = $Options->get_setting( 'master_id' );
241 $MasterType = $Options->get_setting( 'master_type' );
242
243 return( $this->ReviewAccess->create( $Record ) );
244 }
245 catch( Exception $e )
246 {
247 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
248 }
249 }
250
277 function get_reviews_newer_than( $Author , $Time )
278 {
279 try
280 {
281 $Author = $this->Security->get( $Author , 'integer' );
282 $Time = $this->Security->get( $Time , 'integer' );
283
284 $Records = $this->ReviewAccess->unsafe_select(
285 $this->ReviewAccess->NativeTable.".author = $Author AND ".
286 "DATE_ADD( creation_date , INTERVAL $Time SECOND ) > NOW()"
287 );
288
289 return( $Records );
290 }
291 catch( Exception $e )
292 {
293 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
294 }
295 }
296 }
297
298 ?>