source: extensions/AdminTools/include/events.inc.php @ 25617

Last change on this file since 25617 was 25617, checked in by mistic100, 11 years ago

create plugin AdminTools

File size: 2.6 KB
Line 
1<?php
2defined('ADMINTOOLS_PATH') or die('Hacking attempt!');
3
4function admintools_add_public_controller()
5{
6  global $MultiView, $conf;
7
8  if (!$MultiView->is_admin())
9  {
10    return;
11  }
12
13  global $template, $page;
14
15  $url_root = get_root_url();
16
17  $tpl_vars = array(
18    'U_SITE_ADMIN' => $url_root . 'admin.php?page=',
19    'MULTIVIEW' => $MultiView->get_data(),
20    'U_SELF' => $MultiView->get_clean_url(true),
21    );
22
23  // TODO : param to allow owner modification
24  if (script_basename() == 'picture')
25  {
26    global $picture;
27
28    $url_self = duplicate_picture_url();
29
30    $tpl_vars['IS_PICTURE'] = true;
31
32    $template->clear_assign(array(
33      'U_SET_AS_REPRESENTATIVE',
34      'U_PHOTO_ADMIN',
35      'U_CADDIE',
36      ));
37
38    if (isset($page['category']))
39    {
40      $tpl_vars['U_SET_REPRESENTATIVE'] = add_url_params(
41        $url_self,
42        array('action'=>'set_as_representative')
43        );
44      $tpl_vars['CATEGORY_ID'] = $page['category']['id'];
45    }
46
47    $tpl_vars['U_EDIT'] = $url_root . 'admin.php?page=photo-' . $page['image_id']
48      .(isset($page['category']) ? '&amp;cat_id=' . $page['category']['id'] : '');
49
50    $tpl_vars['U_CADDIE'] = add_url_params(
51      $url_self,
52      array('action'=>'add_to_caddie')
53      );
54  }
55  else if (@$page['section'] = 'categories' and isset($page['category']))
56  {
57    $url_self = duplicate_index_url();
58
59    $tpl_vars['IS_CATEGORY'] = true;
60    $tpl_vars['CATEGORY_ID'] = $page['category']['id'];
61
62    $template->clear_assign(array(
63      'U_EDIT',
64      'U_CADDIE',
65      ));
66
67    $tpl_vars['U_EDIT'] = $url_root . 'admin.php?page=album-' . $page['category']['id'];
68
69    if (!empty($page['items']))
70    {
71      $tpl_vars['U_CADDIE'] = add_url_params(
72        $url_self,
73        array('caddie'=>1)
74        );
75    }
76  }
77
78
79  // get users
80  $query = '
81SELECT
82  '.$conf['user_fields']['id'].' AS id,
83  '.$conf['user_fields']['username'].' AS username
84FROM '.USERS_TABLE.'
85  ORDER BY CONVERT('.$conf['user_fields']['username'].', CHAR)
86;';
87  $tpl_vars['USERS'] = simple_hash_from_query($query, 'id', 'username');
88
89  // get themes
90  include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
91  $themes = new themes();
92  foreach (array_keys($themes->fs_themes) as $theme)
93  {
94    $tpl_vars['THEMES'][$theme] = $theme;
95  }
96
97  // get languages
98  foreach (get_languages() as $code => $name)
99  {
100    $tpl_vars['LANGS'][$code] = $name;
101  }
102
103
104  $template->assign(array(
105    'ADMINTOOLS_PATH' => ADMINTOOLS_PATH,
106    'ato' => $tpl_vars,
107  ));
108
109  $template->set_filename('ato', realpath(ADMINTOOLS_PATH . 'template/public_controller.tpl'));
110  $template->parse('ato');
111}
Note: See TracBrowser for help on using the repository browser.