ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

comment_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 comment_algorithms_1_0_0{
27
38 var $CommentAccess = false;
39 var $Link = false;
40 var $LinkUtilities = false;
41 var $Security = false;
42
43 var $Cache = array();
44
55 function __construct()
56 {
57 try
58 {
59 $this->CommentAccess = get_package( 'comment::comment_access' , 'last' , __FILE__ );
60 $this->Link = get_package( 'link' , 'last' , __FILE__ );
61 $this->LinkUtilities = get_package( 'link::link_utilities' , 'last' , __FILE__ );
62 $this->Security = get_package( 'security' , 'last' , __FILE__ );
63 }
64 catch( Exception $e )
65 {
66 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
67 }
68 }
69
92 function object_exists( $id )
93 {
94 try
95 {
96 $id = $this->Security->get( $id , 'integer' );
97
98 $Records = $this->CommentAccess->unsafe_select( $this->CommentAccess->NativeTable.".id = $id" );
99
100 return( count( $Records ) === 1 );
101 }
102 catch( Exception $e )
103 {
104 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
105 }
106 }
107
130 function get_by_id( $id )
131 {
132 try
133 {
134 $id = $this->Security->get( $id , 'integer' );
135
136 $Records = $this->CommentAccess->unsafe_select( $this->CommentAccess->NativeTable.".id = $id" );
137
138 if( count( $Records ) == 0 )
139 {
140 throw( new Exception( 'Record was not found' ) );
141 }
142
143 return( $Records[ 0 ] );
144 }
145 catch( Exception $e )
146 {
147 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
148 }
149 }
150
177 function get_records_for_object( $MasterId , $MasterType )
178 {
179 try
180 {
181 if( isset( $this->Cache[ "$MasterId.$MasterType" ] ) )
182 {
183 return( $this->Cache[ "$MasterId.$MasterType" ] );
184 }
185
186 $this->Cache[ "$MasterId.$MasterType" ] = $this->LinkUtilities->get_dependent_objects(
187 $MasterId , $MasterType , 'comment' , $this->CommentAccess
188 );
189
190 return( $this->Cache[ "$MasterId.$MasterType" ] );
191 }
192 catch( Exception $e )
193 {
194 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
195 }
196 }
197
224 function get_comments_newer_than( $Author , $Time )
225 {
226 try
227 {
228 $Author = $this->Security->get( $Author , 'integer' );
229 $Time = $this->Security->get( $Time , 'integer' );
230
231 $Records = $this->CommentAccess->unsafe_select(
232 $this->CommentAccess->NativeTable.".author = $Author AND ".
233 "DATE_ADD( creation_date , INTERVAL $Time SECOND ) > NOW()"
234 );
235
236 return( $Records );
237 }
238 catch( Exception $e )
239 {
240 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
241 }
242 }
243 }
244
245 ?>