ultimix
ad_banner_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 $AdBannerAccess = false;
39  var $Database = false;
40  var $DatabaseAlgorithms = false;
41  var $Security = false;
42 
53  function __construct()
54  {
55  try
56  {
57  $this->AdBannerAccess = get_package( 'ad::ad_banner::ad_banner_access' , 'last' , __FILE__ );
58  $this->Database = get_package( 'database' , 'last' , __FILE__ );
59  $this->DatabaseAlgorithms = get_package( 'database::database_algorithms' , 'last' , __FILE__ );
60  $this->Security = get_package( 'security' , 'last' , __FILE__ );
61  }
62  catch( Exception $e )
63  {
64  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
65  }
66  }
67 
90  function select_for_campaign( $cid )
91  {
92  try
93  {
94  $cid = $this->Security->get( $cid , 'integer_list' );
95 
96  return( $this->AdBannerAccess->unsafe_select( "campaign_id IN ( $cid )" ) );
97  }
98  catch( Exception $e )
99  {
100  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
101  }
102  }
103 
134  private function fetch_records( $uid , $AddCondition , $Limitation )
135  {
136  try
137  {
138  return(
139  $this->Database->select(
140  'umx_ad_banner.id , umx_ad_banner.direct_banner_id' , 'umx_ad_campaign , umx_ad_banner' ,
141  "umx_ad_campaign.creator = $uid AND umx_ad_campaign.id = ".
142  "umx_ad_banner.campaign_id$AddCondition".$Limitation
143  )
144  );
145  }
146  catch( Exception $e )
147  {
148  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
149  }
150  }
151 
186  function select_for_creator( $uid , $Start = false , $Limit = false , $CampaignId = false )
187  {
188  try
189  {
190  $uid = $this->Security->get( $uid , 'integer_list' );
191  $Limitation = '';
192 
193  if( $Start !== false && $Limit !== false )
194  {
195  $Start = $this->Security->get( $Start , 'integer' );
196  $Limit = $this->Security->get( $Limit , 'integer' );
197  $Limitation = " LIMIT $Start , $Limit";
198  }
199 
200  $AddCondition = '';
201 
202  if( $CampaignId !== false )
203  {
204  $AddCondition = " AND umx_ad_campaign.id = ".$this->Security->get( $CampaignId , 'integer' );
205  }
206 
207  return( $this->fetch_records( $uid , $AddCondition , $Limitation ) );
208  }
209  catch( Exception $e )
210  {
211  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
212  }
213  }
214  }
215 
216 ?>