aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/admin_advices/main.inc.php
blob: a17f5a65821dc01a6f99710d8bfc833f34c966c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php /*
Plugin Name: Admin Advices !
Version: 1.0.0
Author: PhpWebGallery team
Description: Give you an advice on the administration page.
*/

add_event_handler('loc_begin_page_tail', 'set_admin_advice' );


function set_admin_advice()
{
  global $page, $user, $template, $conf;  

  // This Plugin works only on the Admin page
  if ( isset($page['body_id']) and $page['body_id']=='theAdminPage'
    and isset($page['page']['name']) and $page['page']['name'] == 'intro' 
    and isset($page['page']['type']) and $page['page']['type'] == 'standard'
    )
  {
  // Setup Advice Language (Maybe there is already a variable)  
    $advlang = ( isset($user['language']) ) ? 
      $user['language'] : $conf['default_language']; // en_UK.iso-8859-1

    $adv = array();

//  Include language advices
    include_once( PHPWG_ROOT_PATH
      . "plugins/admin_advices/$advlang/lang.adv.php" );

//  If there is an advice
    if ( $cond )
    {  
//  $template->set_filenames( array( 'advice' => 'admin_advices.tpl' ));    
      $template->set_filenames(array(
        'admin_advice' => 
          PHPWG_ROOT_PATH.'/plugins/admin_advices/admin_advices.tpl')
        );
        
// Random Thumbnail
      $query = '
SELECT *
  FROM '.IMAGES_TABLE.'
  ORDER BY RAND(NOW())
  LIMIT 0, 1
;'; 
      $result = pwg_query($query);  
      $row = mysql_fetch_assoc($result); 
      if ( is_array($row) )
      {
        $template->assign_block_vars(
          'thumbnail',
           array(
             'IMAGE'              => get_thumbnail_url($row),
             'IMAGE_ALT'          => $row['file'],
             'IMAGE_TITLE'        => $row['name'],
           )
         );
      }      
      $advice_text = array_shift($adv);
      $template->assign_vars(
        array(
          'ADVICE_ABOUT' => '$conf[' . "'$confk'] ", 
          'ADVICE_TEXT'  => $advice_text,    
           )
        );
      foreach ($adv as $advice)
      {
          $template->assign_block_vars(
            'More',
            array(
              'ADVICE' => $advice
              )
            );    
      } 
    $template->parse('admin_advice');
    }
  }
}
?>