ultimix
site_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 
27 
38  var $Security = false;
39  var $SiteAccess = false;
40 
51  function __construct()
52  {
53  try
54  {
55  $this->Security = get_package( 'security' , 'last' , __FILE__ );
56  $this->SiteAccess = get_package( 'site::site_access' , 'last' , __FILE__ );
57  }
58  catch( Exception $e )
59  {
60  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
61  }
62  }
63 
86  function get_by_id( $id )
87  {
88  try
89  {
90  $id = $this->Security->get( $id , 'integer' );
91 
92  $Sites = $this->SiteAccess->unsafe_select( $this->SiteAccess->NativeTable.".id = $id" );
93 
94  if( count( $Sites ) === 0 || count( $Sites ) > 1 )
95  {
96  throw( new Exception( 'Site with id '.$id.' was not found' ) );
97  }
98  else
99  {
100  return( $Sites[ 0 ] );
101  }
102  }
103  catch( Exception $e )
104  {
105  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
106  }
107  }
108  }
109 
110 ?>