construct_custom_fields() now uses the new template system
[bugdar.git] / includes / functions.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright ©2002-2007 Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 // ###################################################################
23 /**
24 * Constructs HTML code <select>s from an array. You use they keys when
25 * you need to access a multi-dimensional array of data.
26 *
27 * @access public
28 *
29 * @param string HTML name of the select
30 * @param array Array of <option>s
31 * @param integer ID of the selected item, 0 for none
32 * @param string Name of the index where values are stored in the $array
33 * @param string Name of the iddex where the labels are stored in $array
34 * @param bool Value of the blank option, FALSE turns it off
35 * @param bool Construct a multiple-selection <select> menu and append "[]" to the end of the name
36 *
37 * @return string Constructed HTML output
38 */
39 function construct_option_select($name, $array, $selected = 0, $valuekey = '', $labelkey = '', $includenil = false, $multiple = false)
40 {
41 global $bugsys;
42
43 if ($multiple)
44 {
45 $selected = explode(',', $selected);
46 }
47
48 // if we're not working on a boolean false, we use it for the value (allows -1 and 0)
49 if ($includenil !== false)
50 {
51 $opts[] = '<option value="' . $includenil . '"' . ((!$selected OR (is_array($selected) AND in_array($includenil, $selected))) ? ' selected="selected"' : '') . '> ---------</option>';
52 }
53 foreach ($array AS $value => $label)
54 {
55 $newval = ($valuekey ? $label["$valuekey"] : $value);
56 $newlab = ($labelkey ? $label["$labelkey"] : $label);
57 $opts[] = '<option value="' . $newval . '"' . (($selected == $newval OR (is_array($selected) AND in_array($newval, $selected))) ? ' selected="selected"' : '') . '>' . $newlab . '</option>';
58 }
59 return '<select class="input" name="' . $name . ($multiple ? '[]' : '') . '"' . ($multiple ? ' multiple="multiple" size="' . (sizeof($array) < 8 ? sizeof($array) + 1 : 8) . '"' : '') . '>' . implode("\n\t", $opts) . "\r</select>";
60 }
61
62 // ################### Start construct_user_display ##################
63 // $userinfo needs userid, email, displayname, and showemail
64 function construct_user_display($userinfo, $html = true)
65 {
66 global $bugsys;
67
68 if (!$userinfo['userid'])
69 {
70 $userinfo['displayname'] = T('Guest');
71 $userinfo['showemail'] = false;
72 }
73
74 if ($html)
75 {
76 $tpl = new BSTemplate('username_display');
77 $tpl->vars = array('userinfo' => $userinfo);
78 $username = $tpl->evaluate()->getTemplate();
79 }
80 else
81 {
82 if ($userinfo['showemail'])
83 {
84 $username = sprintf(T('%1$s &lt;%2$s&gt;'), $userinfo['displayname'], $userinfo['email']);
85 }
86 else
87 {
88 $username = $userinfo['displayname'];
89 }
90 }
91
92 return $username;
93 }
94
95 // ######################## Start can_perform ########################
96 // short-hand for bitwise &
97 function can_perform($bitmask, $productid = 0, $userinfo = null)
98 {
99 global $bugsys;
100
101 // masks that aren't product-specific
102 static $inspecific = array(
103 'cansearch',
104 'canbeassignedto',
105 'canadminpanel',
106 'canadminbugs',
107 'canadminfields',
108 'canadminversions',
109 'canadminusers',
110 'canadmingroups',
111 'canadmintools'
112 );
113
114 if ($userinfo == null)
115 {
116 $userinfo =& bugdar::$userinfo;
117 }
118
119 $permissions =& bugdar::$datastore['permission'];
120
121 if (!isset($bugsys->permissions["$bitmask"]))
122 {
123 trigger_error('Invalid bitmask "' . $bitmask . '" specified for can_perform() [includes/functions.php]', E_USER_WARNING);
124 }
125
126 if (!$userinfo['permissions'])
127 {
128 $userinfo['permissions'] = FetchUserPermissions($userinfo);
129 }
130
131 if ($productid AND !in_array($bitmask, $inspecific))
132 {
133 $verdict = (isset($permissions["$userinfo[usergroupid]"]["$productid"]) ? ($permissions["$userinfo[usergroupid]"]["$productid"] & $bugsys->permissions["$bitmask"]) : ($userinfo['permissions'] & $bugsys->permissions["$bitmask"]));
134
135 foreach ($userinfo['groupids'] AS $group)
136 {
137 if (isset($permissions["$group"]["$productid"]))
138 {
139 $verdict |= ($permissions["$group"]["$productid"] & $bugsys->permissions["$bitmask"]);
140 }
141 }
142 BSApp::debug("verdict* on can_perform($bitmask, $productid, $userinfo[userid]) = $verdict");
143 return $verdict;
144 }
145
146 BSApp::debug("verdict on can_perform($bitmask, $productid, $userinfo[userid]) = " . ($userinfo['permissions'] & $bugsys->permissions["$bitmask"]));
147 return ($userinfo['permissions'] & $bugsys->permissions["$bitmask"]);
148 }
149
150 // ###################################################################
151 /**
152 * Runs through a given datastore item and creates a series of <select>
153 * options.
154 *
155 * @access public
156 *
157 * @param string Datastore name
158 * @param string Array index for the label
159 * @param string Array index for the value
160 * @param mixed The selected value(s)
161 * @param bool Include a blank option? TRUE will set a null value, FALSE turns it off, anything else is used as the value for the blank option
162 * @param bool Generate it using admin printers?
163 *
164 * @return string Unelss in admin mode, returns the constructed options
165 */
166 function construct_datastore_select($datastore, $labelname, $valuename, $selectedvalue = 0, $includeblank = false, $adminmode = false)
167 {
168 global $bugsys;
169
170 if ($adminmode)
171 {
172 global $admin;
173 }
174
175 $select = '';
176
177 if ($includeblank === true OR $includeblank !== false)
178 {
179 $newval = ($inclueblank === true ? '' : $includeblank);
180 if ($adminmode)
181 {
182 $admin->list_item('', '', ((!$selectedvalue OR (is_array($selectedvalue) AND in_array($newval, $selectedvalue))) ? true : false));
183 }
184 else
185 {
186 $label = '';
187 $value = $newval;
188 $selected = ((!$selectedvalue OR (is_array($selectedvalue) AND in_array($newval, $selectedvalue))) ? true : false);
189 eval('$select .= "' . $bugsys->template->fetch('selectoption') . '";');
190 }
191 }
192
193 foreach (bugdar::$datastore["$datastore"] AS $item)
194 {
195 $label = $item["$labelname"];
196 $value = $item["$valuename"];
197 $selected = (($value == $selectedvalue OR (is_array($selectedvalue) AND in_array($value, $selectedvalue))) ? true : false);
198
199 if ($adminmode)
200 {
201 $admin->list_item($label, $value, $selected);
202 }
203 else
204 {
205 eval('$select .= "' . $bugsys->template->fetch('selectoption') . '";');
206 }
207 }
208
209 if (!$adminmode)
210 {
211 return $select;
212 }
213 }
214
215 // ################## Start construct_custom_fields ##################
216 function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefault = false, $searchMode = false)
217 {
218 static $fields;
219
220 if (!is_array($fields))
221 {
222 $fields = array();
223 $fields_fetch = BSApp::$db->query("
224 SELECT bugfield.*, MAX(permission.mask) AS mask
225 FROM " . TABLE_PREFIX . "bugfield AS bugfield
226 LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
227 ON (bugfield.fieldid = permission.fieldid)
228 WHERE (permission.mask = 2 OR permission.mask = 1)
229 AND permission.usergroupid IN (" . bugdar::$userinfo['usergroupid'] . (sizeof(bugdar::$userinfo['groupids']) != 0 ? ',' . implode(',', bugdar::$userinfo['groupids']) : '') . ")
230 GROUP BY (bugfield.fieldid)
231 ");
232 foreach ($fields_fetch as $field)
233 {
234 $fields["$field[fieldid]"] = $field;
235 }
236 }
237
238 $fieldbits = array();
239
240 foreach ($fields AS $field)
241 {
242 if ($nodefault)
243 {
244 $field['defaultvalue'] = '';
245 }
246
247 if (!is_null($bug["custom$field[fieldid]"]))
248 {
249 BSApp::debug("not null: $field[fieldid]");
250 $value = $bug["custom$field[fieldid]"];
251 }
252 else
253 {
254 $value = $field['defaultvalue'];
255 }
256
257 if ($ignore21mask AND $field['mask'] != 0)
258 {
259 $field['mask'] = 2;
260 }
261
262 if ($field['mask'] == 2)
263 {
264 switch ($field['type'])
265 {
266 case 'input_text':
267 $tpl = new BSTemplate('bugfield_input_text');
268 $tpl->vars = array(
269 'field' => $field,
270 'value' => $value
271 );
272 $tempfield = $tpl->evaluate()->getTemplate();
273 break;
274
275 case 'input_checkbox':
276 $tpl = new BSTemplate('bugfield_input_checkbox');
277 $tpl->vars = array(
278 'field' => $field,
279 'searchMode' => $searchMode,
280 'selected' => ($value ? ' checked="checked"' : '')
281 );
282 $tempfield = $tpl->evaluate()->getTemplate();
283 break;
284
285 case 'select_single':
286 $selects = unserialize($field['selects']);
287 $value = trim($value);
288
289 $tpl = new BSTemplate('bugfield_select_single_option');
290 $tpl->vars = array(
291 'id' => -1,
292 'select' => '',
293 'selected' => ((!$field['usedefault'] && !trim($value)) ? ' selected="selected"' : '')
294 );
295 $options = $tpl->evaluate()->getTemplate();
296
297 foreach ($selects as $id => $select)
298 {
299 $tpl = new BSTemplate('bugfield_select_single_option');
300 $tpl->vars = array(
301 'id' => $id,
302 'select' => stripslashes(trim($select)),
303 'selected' => (($select == $value || ($field['usedefault'] && $id == 0)) ? ' selected="selected"' : '')
304 );
305 $options .= $tpl->evaluate()->getTemplate();
306 }
307
308 $tpl = new BSTemplate('bugfield_select_single');
309 $tpl->vars = array(
310 'field' => $field,
311 'options' => $options
312 );
313 $tempfield = $tpl->evaluate()->getTemplate();
314 break;
315 }
316 }
317 else
318 {
319 BSApp::debug('mask 1 processing');
320 if (is_null($bug["custom$field[fieldid]"]))
321 {
322 BSApp::debug("is null: $field[fieldid]");
323 if ($field['type'] == 'select_single')
324 {
325 if ($field['usedefault'])
326 {
327 $temp = unserialize($field['selects']);
328 $value = trim($temp[0]);
329 }
330 else
331 {
332 $value = $bug["custom$field[fieldid]"];
333 }
334 }
335 else
336 {
337 $value = $field['defaultvalue'];
338 }
339 }
340 else
341 {
342 $value = $bug["custom$field[fieldid]"];
343 }
344
345 if ($field['type'] == 'input_checkbox')
346 {
347 $value = ($value ? 'True' : 'False');
348 }
349 $field['value'] = $value;
350
351 $tpl = new BSTemplate('bugfield_static_text');
352 $tpl->vars = array('field' => $field);
353 $tempfield = $tpl->evaluate()->getTemplate();
354 }
355 $fieldbits[] = $tempfield;
356 }
357
358 return $fieldbits;
359 }
360
361 // ###################################################################
362 /**
363 * This takes the bug API object and input data and then sanitizes, verifies,
364 * and processes the data for custom fields. If there are any errors,
365 * they are passed to the message reporter.
366 *
367 * @param object A BugAPI object
368 * @param object MessageReporter object
369 * @param bool If there are errors, add them to an errorbox format? If not, then display-on-encounter
370 * @param bool Search mode: don't change certain fields when they're 0 or empty
371 *
372 * @return mixed NULL if an ID is passed, string if bugid is NULL
373 */
374 function process_custom_fields(&$bugapi, &$msg, $errorbox = false, $searchMode = false)
375 {
376 global $bugsys;
377
378 if (!$inputdata)
379 {
380 $inputdata =& $bugsys->in;
381 }
382
383 $fields = $bugsys->db->query("
384 SELECT bugfield.*, MAX(permission.mask) AS mask
385 FROM " . TABLE_PREFIX . "bugfield AS bugfield
386 LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
387 ON (bugfield.fieldid = permission.fieldid)
388 WHERE permission.mask = 2
389 AND permission.usergroupid IN (" . bugdar::$userinfo['usergroupid'] . (sizeof(bugdar::$userinfo['groupids']) != 0 ? ',' . implode(',', bugdar::$userinfo['groupids']) : '') . ")
390 GROUP BY (bugfield.fieldid)
391 ");
392 foreach ($fields as $field)
393 {
394 $fieldname = "custom$field[fieldid]";
395
396 if ($field['type'] == 'input_checkbox')
397 {
398 if ($searchMode AND intval($inputdata["$fieldname"]) == 0)
399 {
400 continue;
401 }
402 $bugapi->set($fieldname, intval($inputdata["$fieldname"]));
403 continue;
404 }
405 else if ($field['type'] == 'select_single')
406 {
407 $temp = unserialize($field['selects']);
408 $inputdata[$fieldname] = $temp[intval($inputdata["$fieldname"])] . ''; // make it a string so isset() doesn't catch
409 }
410
411 // field data wasn't passed, so skip it
412 if (!isset($inputdata["$fieldname"]))
413 {
414 continue;
415 }
416
417 if ($field['required'] AND empty($inputdata["$fieldname"]) AND !$searchMode)
418 {
419 $errorlist[] = sprintf(T('The field "%1$s" is a required.'), $field['name']);
420 continue;
421 }
422
423 if (!empty($field['regexmatch']))
424 {
425 if (!preg_match('#' . str_replace('#', '\#', $field['regexmatch']) . '#si', $inputdata["$fieldname"]))
426 {
427 $errorlist[] = sprintf(T('%1$s does not match the specified format'), $field['name']);
428 continue;
429 }
430 }
431
432 if (isset($inputdata["$fieldname"]))
433 {
434 if ($field['type'] == 'input_text')
435 {
436 if (empty($inputdata["$fieldname"]) AND $searchMode)
437 {
438 continue;
439 }
440 $bugapi->set($fieldname, $inputdata["$fieldname"]);
441 }
442 else
443 {
444 if (empty($inputdata["$fieldname"]))
445 {
446 if (!$searchMode)
447 {
448 $bugapi->set($fieldname, '');
449 }
450 continue;
451 }
452
453 $bugapi->set($fieldname, trim($inputdata["$fieldname"]));
454 }
455 }
456 }
457
458 if ($errorlist)
459 {
460 if ($errorbox)
461 {
462 foreach ($errorlist AS $err)
463 {
464 $msg->addError($err);
465 }
466 }
467 else
468 {
469 $msg->error($errorlist[0]);
470 }
471 }
472 }
473
474 // ####################### Start fetch_on_bits #######################
475 function fetch_on_bits($mask, $userinfo = null)
476 {
477 global $bugsys;
478
479 if ($userinfo == null)
480 {
481 $userinfo =& bugdar::$userinfo;
482 }
483
484 $onbits = array();
485
486 $usergroupid = $userinfo['usergroupid'];
487 FetchUserPermissions($userinfo); // get the groups
488 $groups = $userinfo['groupids'];
489 $groups[] = $usergroupid;
490
491 // product-inspecific work
492 if (is_array(bugdar::$datastore['product']))
493 {
494 foreach ($groups AS $groupid)
495 {
496 // we only need to do this so long as there's no onbits array because this isn't product specific
497 if (sizeof($onbits) == 0 AND bugdar::$datastore['usergroup']["$groupid"]['permissions'] & $bugsys->permissions["$mask"])
498 {
499 foreach (bugdar::$datastore['product'] AS $id => $product)
500 {
501 $onbits["$id"] = $id;
502 }
503 }
504 }
505 }
506
507 // bits set explicitly by products
508 $explicit = array();
509
510 // product specific work
511 foreach ($groups AS $groupid)
512 {
513 if (is_array(bugdar::$datastore['permission']["$groupid"]))
514 {
515 foreach (bugdar::$datastore['permission']["$groupid"] AS $productid => $bit)
516 {
517 if ($bit & $bugsys->permissions["$mask"])
518 {
519 $explicit["$productid"] = $productid;
520 $onbits["$productid"] = $productid;
521 }
522 else
523 {
524 // only unset if the bit was set in the first place by blanket and not product-specific permissions
525 // if it was set by product permissions then the highest level takes precedence
526 if ($onbits["$productid"] AND !isset($explicit["$productid"]))
527 {
528 unset($onbits["$productid"]);
529 }
530 }
531 }
532 }
533 }
534
535 // SQL queries would become very unhappy if we didn't do this
536 if (sizeof($onbits) < 1)
537 {
538 $onbits = array(0);
539 }
540
541 return implode(',', $onbits);
542 }
543
544 // #################### Start isso_pre_parse_hook ####################
545 // the pre-parse hook for ISSO's template engine
546 function isso_pre_parse_hook($template)
547 {
548 $template = preg_replace('#\$help\[(.*)\]#', '" . fetch_help_link("\1") . "', $template);
549 return $template;
550 }
551
552 // ###################### Start fetch_help_link ######################
553 // returns a prepared link to insert into templates that opens up a
554 // help popup in the user-end
555 function fetch_help_link($topic)
556 {
557 global $bugsys;
558
559 if (isset(bugdar::$datastore['help']["$topic"]))
560 {
561 eval('$temp = "' . $bugsys->template->fetch('help_link') . '";');
562 return $temp;
563 }
564 else
565 {
566 if (BSApp::debug)
567 {
568 return "[[INVALID TOPIC: $topic]]";
569 }
570 // do we want this?
571 else if (null == 1)
572 {
573 return eval('$temp = "' . $bugsys->template->fetch('help_link') . '";');
574 }
575 }
576 }
577
578 // ###################################################################
579 /**
580 * Returns a user array of information that is specific to all visiting
581 * users (guests). This can then be passed to any function that requires
582 * user information.
583 *
584 * @access public
585 *
586 * @return array User information array
587 */
588 function fetch_guest_user()
589 {
590 global $bugsys;
591
592 return array(
593 'usergroupid' => 1,
594 'groupids' => array(),
595 'userid' => 0,
596 'email' => '',
597 'displayname' => '',
598 'showcolors' => 1,
599 'permissions' => bugdar::$datastore['usergroup'][1]['permissions'],
600 'displaytitle' => bugdar::$datastore['usergroup'][1]['displaytitle'],
601 'timezone' => bugdar::$options['defaulttimezone']
602 );
603 }
604
605 // ###################################################################
606 /**
607 * Does an exhaustive permissions check on the bug. It checks for hidden
608 * bug status and ability to view hidden bugs. This normally was done
609 * at the top of each page, but it got so big, it was moved to a function.
610 *
611 * @access public
612 *
613 * @param array Bug array
614 * @param array Alternate user array
615 *
616 * @return bool Does the user have permission
617 */
618 function check_bug_permissions($bug, $userinfo = null)
619 {
620 global $bugsys;
621 if ($userinfo == null)
622 {
623 $userinfo = bugdar::$userinfo;
624 }
625
626 BSApp::debug("checking permissions for $userinfo[userid] on bug $bug[bugid]");
627
628 BSApp::debug('*** START VERBOSE CHECK ***');
629
630 BSApp::debug('* !can_perform(canviewbugs, $bug[product], $userinfo) = ' . (int)(!can_perform('canviewbugs', $bug['product'], $userinfo)));
631 BSApp::debug('* $bug[hidden] = ' . (int)$bug['hidden']);
632 BSApp::debug('* $userinfo[userid] (' . $userinfo['userid'] . ') == $bug[userid] (' . $bug['userid'] . ') = ' . (int)($userinfo['userid'] == $bug['userid']));
633 BSApp::debug('* can_perform(canviewownhidden, $bug[product], $userinfo) = ' . (int)(!!can_perform('canviewownhidden', $bug['product'], $userinfo)));
634 BSApp::debug('* can_perform(canviewhidden, $bug[product], $userinfo) = ' . (int)(!!can_perform('canviewhidden', $bug['product'], $userinfo)));
635 BSApp::debug('* !$bug[hidden] = ' . (int)(!$bug['hidden']));
636
637 BSApp::debug('*** END PERMISSIONS CHECK ***');
638
639 if
640 (
641 !can_perform('canviewbugs', $bug['product'], $userinfo)
642 OR
643 !(
644 (
645 $bug['hidden']
646 AND
647 (
648 ($userinfo['userid'] == $bug['userid'] AND can_perform('canviewownhidden', $bug['product'], $userinfo))
649 OR
650 can_perform('canviewhidden', $bug['product'], $userinfo)
651 )
652 )
653 OR
654 !$bug['hidden']
655 )
656 )
657 {
658 BSApp::debug('*** DONE WITH REAL CALLS ***');
659 return false;
660 }
661
662 BSApp::debug('*** DONE WITH REAL CALLS ***');
663
664 return true;
665 }
666
667 // ###################################################################
668 /**
669 * Takes an array of bug information and returns another array with
670 * information that is suitable for display as all the IDs have been
671 * replaced by their string equivalents
672 *
673 * @param array Unprocessed bug data
674 * @param string Color to display if the user has opted to not show status colours
675 *
676 * @param array Bug array with data fit for display
677 */
678 function ProcessBugDataForDisplay($bug, $color = '')
679 {
680 global $bugsys;
681
682 $bug['hiddendisplay'] = ($bug['hidden'] AND (can_perform('canviewhidden', $bug['product']) OR (can_perform('canviewownhidden') AND $bug['userid'] == bugdar::$userinfo['userid'])));
683
684 $bug['bgcolor'] = (bugdar::$userinfo['showcolors'] ? bugdar::$datastore['status']["$bug[status]"]['color'] : $color);
685 $bug['product'] = bugdar::$datastore['product']["$bug[product]"]['title'];
686 $bug['version'] = bugdar::$datastore['version']["$bug[version]"]['version'];
687 $bug['component'] = bugdar::$datastore['component']["$bug[component]"]['title'];
688 $bug['status'] = bugdar::$datastore['status']["$bug[status]"]['status'];
689 $bug['resolution'] = bugdar::$datastore['resolution']["$bug[resolution]"]['resolution'];
690 $bug['priority'] = bugdar::$datastore['priority']["$bug[priority]"]['priority'];
691 $bug['severity'] = bugdar::$datastore['severity']["$bug[severity]"]['severity'];
692 $bug['assignedto'] = ((empty($bug['assignedto']) OR !isset(bugdar::$datastore['assignto']["$bug[assignedto]"])) ? '' : construct_user_display(bugdar::$datastore['assignto']["$bug[assignedto]"]));
693
694 $bug['lastposttime'] = ($bug['hiddendisplay'] ? $bug['hiddenlastposttime'] : $bug['lastposttime']);
695 $bug['lastpost'] = ($bug['hiddendisplay'] ? $bug['hiddenlastpostbyname'] : $bug['lastpostbyname']);
696
697 $bug['lastposttime'] = BSApp::$date->format(bugdar::$options['dateformat'], $bug['lastposttime']);
698
699 return $bug;
700 }
701
702 // ###################################################################
703 /**
704 * Determines the correct permissions of the user. This is especially
705 * important for working with multiple-usergroup permission schemes.
706 * If a user is assigned to more than one usergroup, the highest level
707 * will always override (so a YES will always override a NO); this is
708 * because permissions are calculated with bitwise OR.
709 *
710 * @param array The user array with usergroups already exploded
711 *
712 * @return integer Permissions value
713 */
714 function FetchUserPermissions(&$user)
715 {
716 global $bugsys;
717
718 $perms = (int)bugdar::$datastore['usergroup']["$user[usergroupid]"]['permissions'];
719 if (!is_array($user['groupids']))
720 {
721 $user['groupids'] = explode(',', bugdar::$userinfo['groupids']);
722 }
723 $user['groupids'] = BSFunctions::array_strip_empty($user['groupids']);
724
725 foreach ($user['groupids'] AS $group)
726 {
727 $perms |= (int)bugdar::$datastore['usergroup']["$group"]['permissions'];
728 }
729
730 return $perms;
731 }
732
733 // ###################################################################
734 /**
735 * Fetches the path for an email template, given the name of the
736 * template and the locale to use
737 *
738 * @param string The template name
739 * @param string Language locale code
740 *
741 * @return string Template path
742 */
743 function FetchEmailPath($name, $locale)
744 {
745 return '../locale/' . $locale . '/emails/' . $name;
746 }
747
748 /*=====================================================================*\
749 || ###################################################################
750 || # $HeadURL$
751 || # $Id$
752 || ###################################################################
753 \*=====================================================================*/
754 ?>