function can_moderate_calendar($calendarid = 0, $do = '', $userid = -1) { global $vbulletin, $cmodcache; if ($userid == -1) { $userid = $vbulletin->userinfo['userid']; } if ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator']) { DEVDEBUG(' USER IS A SUPER MODERATOR'); return true; } cache_calendar_moderators(); if ($calendarid == 0) { // just check to see if the user is a moderator of any calendar DEVDEBUG('looping through cmodcache to find userid $userid'); $ismod = 0; foreach ($cmodcache as $calendarmods) { if (!empty($calendarmods["{$userid}"])) { $ismod = 1; break; } } return $ismod; } else { // check to see if user is a moderator of specific calendar $getmodperms = intval($cmodcache["{$calendarid}"]["{$userid}"]['permissions']); if (empty($do) and $getmodperms) { return true; } else { // check if user is a mod and has permissions to '$do' if ($getmodperms & $vbulletin->bf_misc_calmoderatorpermissions["{$do}"]) { return true; } else { return false; } // if has perms for this action } // if is mod for calendar and no action set } // if calendarid=0 }
?> &do=addmod&c=" + calendarinfo; break; case '': return false; break; default: window.location = "admincalendar.php?s=<?php echo $vbulletin->session->vars['sessionhash']; ?> &do=editmod&moderatorid=" + modinfo; } } </script> <?php cache_calendar_moderators(); $calendaroptions = array('edit' => $vbphrase['edit'], 'view' => $vbphrase['view'], 'remove' => $vbphrase['delete'], 'perms' => $vbphrase['permissions']); print_form_header('admincalendar', 'doorder'); print_table_header($vbphrase['calendar_manager'], 4); print_description_row($vbphrase['if_you_change_display_order'], 0, 4); print_cells_row(array(' ' . $vbphrase['title'], $vbphrase['controls'], $vbphrase['order_by'], $vbphrase['moderators']), 1, 'tcat'); $calendars = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "calendar ORDER BY displayorder"); while ($calendar = $db->fetch_array($calendars)) { $cell = array(); $cell[] = " <b><a href=\"admincalendar.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&c={$calendar['calendarid']}\">{$calendar['title']}</a></b>"; $cell[] = "\n\t<select name=\"c{$calendar['calendarid']}\" onchange=\"js_calendar_jump({$calendar['calendarid']});\" class=\"bginput\">\n" . construct_select_options($calendaroptions) . "\t</select>\n\t<input type=\"button\" class=\"button\" value=\"" . $vbphrase['go'] . "\" onclick=\"js_calendar_jump({$calendar['calendarid']});\" />\n\t"; $cell[] = "<input type=\"text\" class=\"bginput\" name=\"order[{$calendar['calendarid']}]\" value=\"{$calendar['displayorder']}\" tabindex=\"1\" size=\"3\" title=\"" . $vbphrase['order_by'] . 'ssss' . "\" />"; $mods = array('no_value' => $vbphrase['moderators'] . ' (' . sizeof($cmodcache["{$calendar['calendarid']}"]) . ')'); if (is_array($cmodcache["{$calendar['calendarid']}"])) { foreach ($cmodcache["{$calendar['calendarid']}"] as $moderator) { $mods["{$moderator['calendarmoderatorid']}"] = " {$moderator['username']}";