source: extensions/PWG_Stuffs/admin/functions.inc.php @ 9369

Last change on this file since 9369 was 9369, checked in by patdenice, 13 years ago

Plugins can add their own modules.

File size: 1.5 KB
RevLine 
[3609]1<?php
2
[9369]3function get_default_stuffs_modules($modules)
[3609]4{
[9369]5  $dir = opendir(STUFFS_PATH . 'modules/');
6  while ($file = readdir($dir))
7  {
8    if ($file != '.' and $file != '..' and $file != '.svn')
9    {
10      $path = STUFFS_PATH . 'modules/' . $file;
11      if (is_dir($path) and !is_link($path))
12      {
13        array_push($modules, array(
14          'path' => $path,
15          'name' => l10n('module_name_' . strtolower($file)),
16          'description' => l10n('module_desc_' . strtolower($file)),
17          )
18        );
19      }
[3609]20    }
[9369]21  }
22  closedir($dir);
23  return $modules;
[3609]24}
25
26function get_html_groups_selection(
27  $groups,
28  $fieldname,
29  $selecteds = array()
30  )
31{
32  global $conf;
33  if (count ($groups) == 0 )
34  {
35    return '';
36  }
37  $output = '<div id="'.$fieldname.'">';
38  $id = 1;
39  foreach ($groups as $group)
40  {
41    $output.=
42
43      '<input type="checkbox" name="'.$fieldname.'[]"'
44      .' id="group_'.$id++.'"'
45      .' value="'.$group['id'].'"'
46      ;
47
48    if (in_array($group['id'], $selecteds))
49    {
50      $output.= ' checked="checked"';
51    }
52
53    $output.=
54      '><label>'
55      .'&nbsp;'. $group['name']
56      .'</label>'
57      ."\n"
58      ;
59  }
60  $output.= '</div>';
61
62  return $output;
63}
64
65
66function get_all_groups()
67{
68$query = '
69SELECT id, name
70  FROM '.GROUPS_TABLE.'
71  ORDER BY name ASC
72;';
73$result = pwg_query($query);
74
75$groups = array();
76  while ($row = mysql_fetch_assoc($result))
77  {
78    array_push($groups, $row);
79  }
80
81  uasort($groups, 'name_compare');
82  return $groups;
83}
84
[3300]85?>
Note: See TracBrowser for help on using the repository browser.