ultimix
user_markup.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 $CachedMultyFS = false;
39  var $MacroSettings = false;
40  var $PermitAlgorithms = false;
41  var $String = false;
42  var $UserAlgorithms = false;
43  var $UserView = false;
44 
56 
67  function __construct()
68  {
69  try
70  {
71  $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
72  $this->PermitAlgorithms = get_package( 'permit::permit_algorithms' , 'last' , __FILE__ );
73  $this->String = get_package( 'string' , 'last' , __FILE__ );
74  $this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
75  $this->UserView = get_package( 'user::user_view' , 'last' , __FILE__ );
76  }
77  catch( Exception $e )
78  {
79  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
80  }
81  }
82 //TODO: fix swotch user button
105  function compile_session_login( &$Settings )
106  {
107  try
108  {
109  if( $this->UserAlgorithms->logged_in() )
110  {
111  return( $this->UserAlgorithms->get_login() );
112  }
113 
114  return( 'public' );
115  }
116  catch( Exception $e )
117  {
118  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
119  }
120  }
121 
148  function compile_auth( &$Settings , $Data )
149  {
150  try
151  {
152  $RawSettings = $Settings->get_raw_settings();
153  $Flag = array_shift( array_keys( $RawSettings ) );
154 
155  $ShowData = ( $Flag == 'logged_in' && $this->UserAlgorithms->logged_in() === true ) ||
156  ( $Flag == 'guest' && $this->UserAlgorithms->logged_in() === false );
157 
158  if( $ShowData )
159  {
160  return( $Data );
161  }
162 
163  return( '' );
164  }
165  catch( Exception $e )
166  {
167  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
168  }
169  }
170 
193  function compile_user_id( &$Settings )
194  {
195  try
196  {
197  if( $this->UserAlgorithms->logged_in() )
198  {
199  return( $this->UserAlgorithms->get_id() );
200  }
201 
202  return( $this->UserAccess->GuestUserId );
203  }
204  catch( Exception $e )
205  {
206  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
207  }
208  }
209 
232  private function fetch_users( &$MacroSettings )
233  {
234  try
235  {
236  $PermitFilter = $MacroSettings->get_setting( 'permit_filter' , false );
237 
238  if( $PermitFilter !== false )
239  {
240  $Users = $this->PermitAlgorithms->get_users_for_permit( $PermitFilter );
241  }
242  else
243  {
244  /* all users */
245  $Users = $this->PermitAlgorithms->get_users_for_permit( 'registered' );
246  }
247 
248  return( $Users );
249  }
250  catch( Exception $e )
251  {
252  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
253  }
254  }
255 
278  function compile_user_list( &$Settings )
279  {
280  try
281  {
282  $Users = $this->fetch_users( $Settings );
283  $Name = $Settings->get_setting( 'name' );
284  $Field = $Settings->get_setting( 'field' , 'login' );
285 
286  $Code = '';
287  foreach( $Users as $i => $id )
288  {
289  $User = $this->UserAlgorithms->get_by_id( $id );
290  $Code .= "{checkbox:name=_$Name".get_field( $User , 'id' ).";current_value=on}".
291  get_field( $User , $Field ).
292  $this->CahcedMultyFS->get_template( __FILE__ , 'user_end_line.tpl' );
293  }
294 
295  return( $Code );
296  }
297  catch( Exception $e )
298  {
299  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
300  }
301  }
302 
325  function compile_months_on_site( &$Settings )
326  {
327  try
328  {
329  $User = $this->UserAlgorithms->get_by_id( $Settings->get_setting( 'user_id' ) );
330 
331  $Code = time() - strtotime( get_field( $User , 'registered' ) );
332  $Code = intval( $Code / ( 30 * 24 * 60 * 60 ) );
333 
334  return( $Code );
335  }
336  catch( Exception $e )
337  {
338  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
339  }
340  }
341 
364  function compile_user_login( &$Settings )
365  {
366  try
367  {
368  $User = $this->UserAlgorithms->get_by_id( $Settings->get_setting( 'user_id' ) );
369 
370  return( get_field( $User , 'login' ) );
371  }
372  catch( Exception $e )
373  {
374  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
375  }
376  }
377  }
378 ?>