本文整理匯總了PHP中session::haveRight方法的典型用法代碼示例。如果您正苦於以下問題:PHP session::haveRight方法的具體用法?PHP session::haveRight怎麽用?PHP session::haveRight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類session
的用法示例。
在下文中一共展示了session::haveRight方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getMessages
static function getMessages()
{
global $CFG_GLPI;
$pmMessage = new self();
// Display if shinken is in restart or if restarted less than 5 minutes
echo "<div id='shikenrestart'></div>";
echo "<script type=\"text/javascript\">\n (function worker() {\n \$.get('" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/updateshinkenrestartmessage.php" . "?glpiID=" . $_SESSION['glpiID'] . "', function(data) {\n \$('#shikenrestart').html(data);\n setTimeout(worker, 30000);\n });\n })();\n </script>";
$servicecatalog = '';
$confchanges = '';
if (session::haveRight("plugin_monitoring_servicescatalog", READ)) {
$servicecatalog = $pmMessage->servicescatalogMessage();
}
$confchanges = $pmMessage->configurationchangesMessage();
$runningshinken = $pmMessage->ShinkennotrunMessage();
$i = 0;
if ($servicecatalog != '' or $confchanges != '') {
echo "<div class='msgboxmonit msgboxmonit-orange'>";
if ($confchanges != '') {
echo $confchanges;
$i++;
}
if ($servicecatalog != '') {
if ($i > 0) {
echo "</div>";
echo "<div class='msgboxmonit msgboxmonit-orange'>";
}
echo $servicecatalog;
$i++;
}
if ($runningshinken != '') {
if ($i > 0) {
echo "</div>";
echo "<div class='msgboxmonit msgboxmonit-red'>";
}
echo $runningshinken . "!";
$i++;
}
echo "</div>";
}
}
示例2: getTabNameForItem
/**
* @see CommonGLPI::getTabNameForItem()
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
if (self::canView()) {
$nb = 0;
switch ($item->getType()) {
case 'RSSFeed':
$showtab = array(1 => __('Content'));
if (session::haveRight('rssfeed_public', UPDATE)) {
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = $item->countVisibilities();
}
$showtab[2] = self::createTabEntry(_n('Target', 'Targets', Session::getPluralNumber()), $nb);
}
return $showtab;
}
}
return '';
}
示例3: getMessages
static function getMessages() {
global $CFG_GLPI;
$pmMessage = new self();
$sess_id = session_id();
// PluginMonitoringSecurity::updateSession();
// Display if shinken is in restart or if restarted less than 5 minutes
echo "<div id='shikenrestart'></div>";
// echo "<script type=\"text/javascript\">
// var elshikenrestart = Ext.get(\"shikenrestart\");
// var mgrshikenrestart = elshikenrestart.getUpdateManager();
// mgrshikenrestart.loadScripts=true;
// mgrshikenrestart.showLoadIndicator=false;
// mgrshikenrestart.startAutoRefresh(30, \"".$CFG_GLPI["root_doc"].
// "/plugins/monitoring/ajax/updateshinkenrestartmessage.php\","
// . " \"sess_id=".$sess_id.
// "&glpiID=".$_SESSION['glpiID'].
// "&plugin_monitoring_securekey=".$_SESSION['plugin_monitoring_securekey'].
// "\", \"\", true);";
// echo "</script>";
echo "<script type=\"text/javascript\">
(function worker() {
$.get('".$CFG_GLPI["root_doc"]."/plugins/monitoring/ajax/updateshinkenrestartmessage.php"
."?sess_id=".$sess_id."&glpiID=".$_SESSION['glpiID']."', function(data) {
$('#shikenrestart').html(data);
setTimeout(worker, 30000);
});
})();
</script>";
$servicecatalog = '';
$confchanges = '';
if (session::haveRight("plugin_monitoring_servicescatalog", READ)) {
$servicecatalog = $pmMessage->servicescatalogMessage();
}
$confchanges = $pmMessage->configurationchangesMessage();
$runningshinken = $pmMessage->ShinkennotrunMessage();
$i = 0;
if ($servicecatalog != ''
OR $confchanges != '') {
echo "<div class='msgboxmonit msgboxmonit-orange'>";
if ($confchanges != '') {
echo $confchanges;
$i++;
}
if ($servicecatalog != '') {
if($i > 0) {
echo "</div>";
echo "<div class='msgboxmonit msgboxmonit-orange'>";
}
echo $servicecatalog;
$i++;
}
if ($runningshinken != '') {
if($i > 0) {
echo "</div>";
echo "<div class='msgboxmonit msgboxmonit-red'>";
}
echo $runningshinken."!";
$i++;
}
echo "</div>";
}
}
示例4: getUserName
/**
* Get name of the user with ID=$ID (optional with link to user.form.php)
*
*@param $ID integer ID of the user.
*@param $link integer 1 = Show link to user.form.php 2 = return array with comments and link
* (default =0)
*
*@return string : username string (realname if not empty and name if realname is empty).
**/
function getUserName($ID, $link = 0)
{
global $DB, $CFG_GLPI;
$user = "";
if ($link == 2) {
$user = array("name" => "", "link" => "", "comment" => "");
}
if ($ID) {
$query = "SELECT *\n FROM `glpi_users`\n WHERE `id` = '{$ID}'";
$result = $DB->query($query);
if ($link == 2) {
$user = array("name" => "", "comment" => "", "link" => "");
}
if ($DB->numrows($result) == 1) {
$data = $DB->fetch_assoc($result);
$username = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], $link);
if ($link == 2) {
$user["name"] = $username;
$user["link"] = $CFG_GLPI["root_doc"] . "/front/user.form.php?id=" . $ID;
$user['comment'] = '';
$comments = array();
$comments[] = array('name' => __('Name'), 'value' => $username);
// Ident only if you have right to read user
if (session::haveRight('user', READ)) {
$comments[] = array('name' => __('Login'), 'value' => $data["name"]);
}
$email = UserEmail::getDefaultForUser($ID);
if (!empty($email)) {
$comments[] = array('name' => __('Email'), 'value' => $email);
}
if (!empty($data["phone"])) {
$comments[] = array('name' => __('Phone'), 'value' => $data["phone"]);
}
if (!empty($data["mobile"])) {
$comments[] = array('name' => __('Mobile phone'), 'value' => $data["mobile"]);
}
if ($data["locations_id"] > 0) {
$comments[] = array('name' => __('Location'), 'value' => Dropdown::getDropdownName("glpi_locations", $data["locations_id"]));
}
if ($data["usertitles_id"] > 0) {
$comments[] = array('name' => _x('person', 'Title'), 'value' => Dropdown::getDropdownName("glpi_usertitles", $data["usertitles_id"]));
}
if ($data["usercategories_id"] > 0) {
$comments[] = array('name' => __('Category'), 'value' => Dropdown::getDropdownName("glpi_usercategories", $data["usercategories_id"]));
}
if (count($comments)) {
$user['comment'] = $user['comment'];
foreach ($comments as $datas) {
// Do not use SPAN here
$user['comment'] .= sprintf(__('%1$s: %2$s') . "<br>", "<strong>" . $datas['name'] . "</strong>", $datas['value']);
}
}
if (!empty($data['picture'])) {
$user['comment'] = "<div class='tooltip_picture_border'>" . "<img class='tooltip_picture' src='" . User::getThumbnailURLForPicture($data['picture']) . "' /></div>" . "<div class='tooltip_text'>" . $user['comment'] . "</div>";
}
} else {
$user = $username;
}
}
}
return $user;
}