• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP formatUserName函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中formatUserName函数的典型用法代码示例。如果您正苦于以下问题:PHP formatUserName函数的具体用法?PHP formatUserName怎么用?PHP formatUserName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了formatUserName函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: logFailedMail

function logFailedMail($user, $correspondence)
{
    $message = "Correspondence email failed to be delivered - ";
    $message .= $correspondence;
    $message .= " - sent to ";
    $message .= formatUserName($user);
    logInfoEvent($message);
}
开发者ID:coyotetracks,项目名称:PiutePonds,代码行数:8,代码来源:correspondence_help.php


示例2: getUserName

 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);
                 $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)) {
                     foreach ($comments as $data) {
                         // Do not use SPAN here
                         $user['comment'] .= sprintf(__('%1$s: %2$s') . "<br>", "<strong>" . $data['name'] . "</strong>", $data['value']);
                     }
                 }
             } else {
                 $user = $username;
             }
         }
     }
     return $user;
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:55,代码来源:common.class.php


示例3: pdfForItem

 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $DB, $CFG_GLPI;
     $ID = $item->getField('id');
     $type = get_class($item);
     if (!Session::haveRight("reservation_central", "r")) {
         return;
     }
     $user = new User();
     $ri = new ReservationItem();
     $pdf->setColumnsSize(100);
     if ($ri->getFromDBbyItem($type, $ID)) {
         $now = $_SESSION["glpi_currenttime"];
         $query = "SELECT *\n                   FROM `glpi_reservationitems`\n                   INNER JOIN `glpi_reservations`\n                        ON (`glpi_reservations`.`reservationitems_id` = `glpi_reservationitems`.`id`)\n                   WHERE `end` > '" . $now . "'\n                         AND `glpi_reservationitems`.`items_id` = '{$ID}'\n                   ORDER BY `begin`";
         $result = $DB->query($query);
         $pdf->setColumnsSize(100);
         $pdf->displayTitle("<b>" . __('Current and future reservations') . "</b>");
         if (!$DB->numrows($result)) {
             $pdf->displayLine("<b>" . __('No reservation') . "</b>");
         } else {
             $pdf->setColumnsSize(14, 14, 26, 46);
             $pdf->displayTitle('<i>' . __('Start date'), __('End date'), __('By'), __('Comments') . '</i>');
             while ($data = $DB->fetch_assoc($result)) {
                 if ($user->getFromDB($data["users_id"])) {
                     $name = formatUserName($user->fields["id"], $user->fields["name"], $user->fields["realname"], $user->fields["firstname"]);
                 } else {
                     $name = "(" . $data["users_id"] . ")";
                 }
                 $pdf->displayLine(Html::convDateTime($data["begin"]), Html::convDateTime($data["end"]), $name, str_replace(array("\r", "\n"), " ", $data["comment"]));
             }
         }
         $query = "SELECT *\n                   FROM `glpi_reservationitems`\n                   INNER JOIN `glpi_reservations`\n                        ON (`glpi_reservations`.`reservationitems_id` = `glpi_reservationitems`.`id`)\n                   WHERE `end` <= '" . $now . "'\n                         AND `glpi_reservationitems`.`items_id` = '{$ID}'\n                   ORDER BY `begin`\n                   DESC";
         $result = $DB->query($query);
         $pdf->setColumnsSize(100);
         $pdf->displayTitle("<b>" . __('Past reservations') . "</b>");
         if (!$DB->numrows($result)) {
             $pdf->displayLine("<b>" . __('No reservation') . "</b>");
         } else {
             $pdf->setColumnsSize(14, 14, 26, 46);
             $pdf->displayTitle('<i>' . __('Start date'), __('End date'), __('By'), __('Comments') . '</i>');
             while ($data = $DB->fetch_assoc($result)) {
                 if ($user->getFromDB($data["users_id"])) {
                     $name = formatUserName($user->fields["id"], $user->fields["name"], $user->fields["realname"], $user->fields["firstname"]);
                 } else {
                     $name = "(" . $data["users_id"] . ")";
                 }
                 $pdf->displayLine(Html::convDateTime($data["begin"]), Html::convDateTime($data["end"]), $name, str_replace(array("\r", "\n"), " ", $data["comment"]));
             }
         }
     }
     $pdf->displaySpace();
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:52,代码来源:reservation.class.php


示例4: sendUpdateHuntNotification

function sendUpdateHuntNotification($hunt)
{
    $to = "[email protected],[email protected]";
    $from = "From: [email protected] \r\n";
    $user = getCurrentUser();
    $userName = formatUserName($user);
    $subject = "A hunt was updated";
    $mesg = "A hunt was updated by " . $userName . ".\r\n";
    if (mail($to, $subject, $mesg, $from)) {
        //echo "MAIL_SUCCESS";
    } else {
        //echo "MAIL_FAIL";
    }
}
开发者ID:coyotetracks,项目名称:PiutePonds,代码行数:14,代码来源:notification.php


示例5: helpHeader

/**
 * Print a nice HTML head for help page
 *
 * @param $title title of the page
 * @param $url not used anymore.
 **/
function helpHeader($title, $url = '')
{
    global $CFG_GLPI, $LANG, $HEADER_LOADED, $PLUGIN_HOOKS;
    // Print a nice HTML-head for help page
    if ($HEADER_LOADED) {
        return;
    }
    $HEADER_LOADED = true;
    includeCommonHtmlHeader($title);
    // Body
    echo "<body>";
    // Main Headline
    echo "<div id='header'>";
    echo "<div id='c_logo' >";
    echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' accesskey='0' title=\"" . $LANG['central'][5] . "\"><span class='invisible'>Logo</span></a></div>";
    // Les préférences + lien déconnexion
    echo "<div id='c_preference' >";
    echo "<ul><li id='deconnexion'><a href='" . $CFG_GLPI["root_doc"] . "/logout.php' title=\"" . $LANG['central'][6] . "\">" . $LANG['central'][6] . "</a>";
    // check user id : header used for display messages when session logout
    if (getLoginUserID()) {
        echo "&nbsp;(";
        echo formatUserName(0, $_SESSION["glpiname"], $_SESSION["glpirealname"], $_SESSION["glpifirstname"], 0, 20);
        echo ")";
    }
    echo "</li>\n";
    echo "<li><a href='" . (empty($CFG_GLPI["helpdesk_doc_url"]) ? "http://glpi-project.org/help-helpdesk" : $CFG_GLPI["helpdesk_doc_url"]) . "' target='_blank' title=\"" . $LANG['central'][7] . "\"> " . $LANG['central'][7] . "</a></li>";
    echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/preference.php' title=\"" . $LANG['Menu'][11] . "\">" . $LANG['Menu'][11] . "</a></li>\n";
    echo "</ul>";
    echo "<div class='sep'></div>";
    echo "</div>";
    //-- Le moteur de recherche --
    echo "<div id='c_recherche'>";
    echo "<div class='sep'></div>";
    echo "</div>";
    //-- Le menu principal --
    echo "<div id='c_menu'>";
    echo "<ul id='menu'>";
    // Build the navigation-elements
    // Home
    echo "<li id='menu1'>";
    echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' title=\"" . $LANG['job'][13] . "\" class='itemP'>" . $LANG['central'][5] . "</a>";
    echo "</li>";
    //  Create ticket
    if (haveRight("create_ticket", "1")) {
        echo "<li id='menu2'>";
        echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php?create_ticket=1' title=\"" . $LANG['profiles'][5] . "\" class='itemP'>" . $LANG['profiles'][5] . "</a>";
        echo "</li>";
    }
    //  Suivi ticket
    if (haveRight("observe_ticket", "1")) {
        echo "<li id='menu2'>";
        echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.php' title=\"" . $LANG['title'][10] . "\" class='itemP'>" . $LANG['title'][28] . "</a>";
        echo "</li>";
    }
    // Reservation
    if (haveRight("reservation_helpdesk", "1")) {
        echo "<li id='menu3'>";
        echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.php' title=\"" . $LANG['Menu'][17] . "\" class='itemP'>" . $LANG['Menu'][17] . "</a>";
        echo "</li>";
    }
    // FAQ
    if (haveRight("faq", "r")) {
        echo "<li id='menu4' >";
        echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.faq.php' title=\"" . $LANG['knowbase'][1] . "\" class='itemP'>" . $LANG['Menu'][20] . "</a>";
        echo "</li>";
    }
    // PLUGINS
    $plugins = array();
    if (isset($PLUGIN_HOOKS["helpdesk_menu_entry"]) && count($PLUGIN_HOOKS["helpdesk_menu_entry"])) {
        foreach ($PLUGIN_HOOKS["helpdesk_menu_entry"] as $plugin => $active) {
            if ($active) {
                $function = "plugin_version_{$plugin}";
                if (function_exists($function)) {
                    $plugins[$plugin] = $function();
                }
            }
        }
    }
    if (isset($plugins) && count($plugins) > 0) {
        $list = array();
        foreach ($plugins as $key => $val) {
            $list[$key] = $val["name"];
        }
        asort($list);
        echo "<li id='menu5' onmouseover=\"javascript:menuAff('menu5','menu');\">";
        echo "<a href='#' title=\"" . $LANG['common'][29] . "\" class='itemP'>" . $LANG['common'][29] . "</a>";
        // default none
        echo "<ul class='ssmenu'>";
        // list menu item
        foreach ($list as $key => $val) {
            $link = "";
            if (is_string($PLUGIN_HOOKS["helpdesk_menu_entry"][$key])) {
                $link = $PLUGIN_HOOKS["helpdesk_menu_entry"][$key];
            }
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:display.function.php


示例6: Copyright

 along with GLPI; along with Order. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 @package   order
 @author    the order plugin team
 @copyright Copyright (c) 2010-2015 Order plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/order
 @link      http://www.glpi-project.org/
 @since     2009
 ---------------------------------------------------------------------- */
if (strpos($_SERVER['PHP_SELF'], "dropdownSupplier.php")) {
    include "../../../inc/includes.php";
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
Session::checkCentralAccess();
// Make a select box
if (isset($_POST["suppliers_id"])) {
    // Make a select box
    $query = "SELECT c.`id`, c.`name`, c.`firstname`\n             FROM `glpi_contacts` c\n             LEFT JOIN `glpi_contacts_suppliers` s ON (s.`contacts_id` = c.`id`)\n             WHERE s.`suppliers_id` = '{$_POST['suppliers_id']}'\n             ORDER BY c.`name`";
    $result = $DB->query($query);
    $number = $DB->numrows($result);
    $values = array(0 => Dropdown::EMPTY_VALUE);
    if ($number) {
        while ($data = $DB->fetch_assoc($result)) {
            $values[$data['id']] = formatUserName('', '', $data['name'], $data['firstname']);
        }
    }
    Dropdown::showFromArray($_POST['fieldname'], $values);
}
开发者ID:equinoxefr,项目名称:order,代码行数:31,代码来源:dropdownSupplier.php


示例7: affiche_tableau

 /**
  * Fonction permettant de dessiner le tableau des informations générales.
  */
 function affiche_tableau($total, $items, $deviceType, $disposal = 0)
 {
     if ($total != 0) {
         /* en-tete */
         $this->CellLabel(false, $this->largeur_grande_cell, Toolbox::decodeFromUtf8($deviceType));
         $this->SetY($this->GetY() + $this->line_height);
         /* En tete tableau. */
         $this->CellEnTeteTableau(false, 45, Toolbox::decodeFromUtf8(__('Name')), 1, 'C', 1);
         $this->CellEnTeteTableau(false, 35, Toolbox::decodeFromUtf8(__('Inventory number')), 1, 'C', 1);
         $this->CellEnTeteTableau(false, 20, Toolbox::decodeFromUtf8(__('Date of purchase')), 1, 'C', 1);
         if ($disposal != 1) {
             $this->CellEnTeteTableau(false, 40, Toolbox::decodeFromUtf8(__('User / Group', 'financialreports')), 1, 'C', 1);
             $this->CellEnTeteTableau(false, 40, Toolbox::decodeFromUtf8(__('Location')), 1, 'C', 1);
         }
         $this->CellEnTeteTableau(false, 40, Toolbox::decodeFromUtf8(__('Model')), 1, 'C', 1);
         $this->CellEnTeteTableau(false, 40, Toolbox::decodeFromUtf8(__('Supplier')), 1, 'C', 1);
         if ($disposal == 1) {
             $this->CellEnTeteTableau(false, 20, Toolbox::decodeFromUtf8(__('HT', 'financialreports')), 1, 'C', 1);
             $this->CellEnTeteTableau(false, 25, Toolbox::decodeFromUtf8(__('Disposal date', 'financialreports')), 1, 'C', 1);
             $this->CellEnTeteTableau(false, 55, Toolbox::decodeFromUtf8(__('Comments')), 1, 'C', 1);
         } else {
             $this->CellEnTeteTableau(false, 20, Toolbox::decodeFromUtf8(__('HT', 'financialreports')), 1, 'C', 1);
         }
         $this->SetY($this->GetY() + $this->line_height);
         /* ligne. */
         $i = 1;
         foreach ($items as $data) {
             $i++;
             $this->SetFondBlanc();
             if ($i % 2) {
                 $this->SetFondTresClair();
             }
             $this->CellLigneTableau(false, 45, $data["ITEM_0"]);
             $this->CellLigneTableau(false, 35, $data["ITEM_2"]);
             $this->CellLigneTableau(false, 20, Html::convdate($data["ITEM_3"]), 1, 'C', 1);
             $this->SetTextBleu();
             $this->CellLigneTableau(false, 40, Toolbox::decodeFromUtf8(formatUserName($data["ITEM_4_3"], $data["ITEM_4"], $data["ITEM_4_2"], $data["ITEM_4_4"])));
             $this->SetTextNoir();
             if ($disposal != 1) {
                 $this->CellLigneTableau(false, 40, Toolbox::decodeFromUtf8($data["ITEM_9"]));
                 $this->CellLigneTableau(false, 40, Toolbox::decodeFromUtf8($data["ITEM_6"]));
             }
             $this->CellLigneTableau(false, 40, Toolbox::decodeFromUtf8($data["ITEM_7"]));
             if ($disposal == 1) {
                 $this->SetTextRouge();
                 $this->CellLigneTableau(false, 20, Html::clean(Html::formatNumber($data["ITEM_8"])), 1, 'R', 1);
                 $this->SetTextNoir();
                 $this->CellLigneTableau(false, 25, Html::convdate($data["ITEM_10"]), 1, 'C', 1);
                 $this->CellLigneTableau(false, 55, Toolbox::decodeFromUtf8($data["ITEM_9"]));
             } else {
                 $this->SetTextRouge();
                 $this->CellLigneTableau(false, 20, Html::clean(Html::formatNumber($data["ITEM_8"])), 1, 'R', 1);
                 $this->SetTextNoir();
             }
             $this->SetY($this->GetY() + $this->line_height);
         }
         /* pied */
         if ($total != -1) {
             $this->CellEnTeteTableau(true, $this->largeur_grande_cell - 20, Toolbox::decodeFromUtf8(__('Total')), 1, 'R', 1);
             $this->SetTextRouge();
             $this->CellEnTeteTableau(false, 20, Html::clean(Html::formatNumber($total)), 1, 'R', 1);
             $this->SetTextNoir();
             $this->SetY($this->GetY() + $this->line_height);
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:69,代码来源:pdf.class.php


示例8: showForTypology

 /**
  * Display all the linked computers of a defined typology
  *
  *@param $typoID = typo ID.
  *
  *@return Nothing (displays)
  **/
 public static function showForTypology(PluginTypologyTypology $typo)
 {
     global $DB, $CFG_GLPI;
     $typoID = $typo->fields['id'];
     if (!$typo->can($typoID, 'r')) {
         return false;
     }
     $canedit = $typo->can($typoID, 'w');
     $canview = $typo->can($typoID, 'r');
     $rand = mt_rand();
     $query = "SELECT DISTINCT `itemtype`\n                    FROM `glpi_plugin_typology_typologies_items`\n                    WHERE `plugin_typology_typologies_id` = '{$typoID}'\n                    ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (Session::isMultiEntitiesMode()) {
         $colsup = 1;
     } else {
         $colsup = 0;
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form method='post' name='typologies_form{$rand}' id='typologies_form{$rand}' action='" . $CFG_GLPI["root_doc"] . "/plugins/typology/front/typology.form.php'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         echo "<th colspan='7'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
         echo "<input type='hidden' name='plugin_typology_typologies_id' value='{$typoID}'>";
         Dropdown::showAllItems("items_id", 0, 0, $typo->fields['is_recursive'] ? -1 : $typo->fields['entities_id'], PluginTypologyTypology::getTypes());
         echo "</td>";
         echo "<td colspan='3' class='center' class='tab_bg_2'>";
         echo "<input type='submit' name='add_item' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array();
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='" . ($canedit ? 7 + $colsup : 6 + $colsup) . "'>";
     if ($DB->numrows($result) == 0) {
         _e('No linked element', 'typology');
     } else {
         _e('Linked elements', 'typology');
     }
     echo "</th></tr><tr>";
     if ($canedit && $number) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . __('Name') . "</th>";
     if (Session::isMultiEntitiesMode()) {
         echo "<th>" . __('Entity') . "</th>";
     }
     echo "<th>" . __('Serial number') . "</th>";
     echo "<th>" . __('Inventory number') . "</th>";
     echo "<th>" . __('Responding to typology\'s criteria', 'typology') . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         if ($canview) {
             $column = "name";
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `" . $itemtable . "`.*,\n                                `glpi_plugin_typology_typologies_items`.`id` AS IDP,\n                                `glpi_plugin_typology_typologies_items`.`is_validated`,\n                                `glpi_plugin_typology_typologies_items`.`error`,\n                                `glpi_entities`.`id` AS entity " . " FROM `glpi_plugin_typology_typologies_items`, `" . $itemtable . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $itemtable . "`.`entities_id`) " . " WHERE `" . $itemtable . "`.`id` = `glpi_plugin_typology_typologies_items`.`items_id`\n                              AND `glpi_plugin_typology_typologies_items`.`itemtype` = '{$itemtype}'\n                              AND `glpi_plugin_typology_typologies_items`.`plugin_typology_typologies_id` = '{$typoID}'";
             if ($itemtype != 'User') {
                 $query .= getEntitiesRestrictRequest(" AND ", $itemtable, '', '', $item->maybeRecursive());
             }
             if ($item->maybeTemplate()) {
                 $query .= " AND " . $itemtable . ".is_template='0'";
             }
             $query .= " ORDER BY `glpi_entities`.`completename`, `" . $itemtable . "`.`{$column}` ";
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     Session::initNavigateListItems($itemtype, PluginTypologyTypology::getTypeName(1) . " = " . $typo->fields['name']);
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         $ID = "";
                         $item->getFromDB($data["id"]);
                         Session::addToNavigateListItems($itemtype, $data["id"]);
                         if ($itemtype == 'User') {
                             $format = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], 1);
                         } else {
                             $format = $data["name"];
                         }
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $ID = " (" . $data["id"] . ")";
                         }
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:typology_item.class.php


示例9: giveItem

 /**
  * Generic Function to display Items
  *
  * @param $itemtype              item type
  * @param $ID                    ID of the SEARCH_OPTION item
  * @param $data            array containing data results
  * @param $num                   item num in the request
  * @param $meta                  is a meta item ? (default 0)
  * @param $addobjectparams array added parameters for union search
  *
  * @return string to print
  **/
 static function giveItem($itemtype, $ID, array $data, $num, $meta = 0, array $addobjectparams = array())
 {
     global $CFG_GLPI, $DB;
     $searchopt =& self::getOptions($itemtype);
     if (isset($CFG_GLPI["union_search_type"][$itemtype]) && $CFG_GLPI["union_search_type"][$itemtype] == $searchopt[$ID]["table"]) {
         if (isset($searchopt[$ID]['addobjectparams']) && $searchopt[$ID]['addobjectparams']) {
             return self::giveItem($data["TYPE"], $ID, $data, $num, $meta, $searchopt[$ID]['addobjectparams']);
         }
         return self::giveItem($data["TYPE"], $ID, $data, $num, $meta);
     }
     if (count($addobjectparams)) {
         $searchopt[$ID] = array_merge($searchopt[$ID], $addobjectparams);
     }
     // Plugin can override core definition for its type
     if ($plug = isPluginItemType($itemtype)) {
         $function = 'plugin_' . $plug['plugin'] . '_giveItem';
         if (function_exists($function)) {
             $out = $function($itemtype, $ID, $data, $num);
             if (!empty($out)) {
                 return $out;
             }
         }
     }
     $NAME = "ITEM_";
     //       if ($meta) {
     //          $NAME = "META_";
     //       }
     if (isset($searchopt[$ID]["table"])) {
         $table = $searchopt[$ID]["table"];
         $field = $searchopt[$ID]["field"];
         $linkfield = $searchopt[$ID]["linkfield"];
         /// TODO try to clean all specific cases using SpecificToDisplay
         switch ($table . '.' . $field) {
             case "glpi_users.name":
                 // USER search case
                 if ($itemtype != 'User' && isset($searchopt[$ID]["forcegroupby"]) && $searchopt[$ID]["forcegroupby"]) {
                     $out = "";
                     $count_display = 0;
                     $added = array();
                     $showuserlink = 0;
                     if (Session::haveRight('user', READ)) {
                         $showuserlink = 1;
                     }
                     for ($k = 0; $k < $data[$num]['count']; $k++) {
                         if (isset($data[$num][$k]['name']) && $data[$num][$k]['name'] > 0 || isset($data[$num][$k][2]) && $data[$num][$k][2] != '') {
                             if ($count_display) {
                                 $out .= self::LBBR;
                             }
                             if ($itemtype == 'Ticket') {
                                 if (isset($data[$num][$k]['name']) && $data[$num][$k]['name'] > 0) {
                                     $userdata = getUserName($data[$num][$k]['name'], 2);
                                     $tooltip = "";
                                     if (Session::haveRight('user', READ)) {
                                         $tooltip = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                                     }
                                     $out .= sprintf(__('%1$s %2$s'), $userdata['name'], $tooltip);
                                     $count_display++;
                                 }
                             } else {
                                 $out .= getUserName($data[$num][$k]['name'], $showuserlink);
                                 $count_display++;
                             }
                             // Manage alternative_email for tickets_users
                             if ($itemtype == 'Ticket' && isset($data[$num][$k][2])) {
                                 $split = explode(self::LONGSEP, $data[$num][$k][2]);
                                 for ($l = 0; $l < count($split); $l++) {
                                     $split2 = explode(" ", $split[$l]);
                                     if (count($split2) == 2 && $split2[0] == 0 && !empty($split2[1])) {
                                         if ($count_display) {
                                             $out .= self::LBBR;
                                         }
                                         $count_display++;
                                         $out .= "<a href='mailto:" . $split2[1] . "'>" . $split2[1] . "</a>";
                                     }
                                 }
                             }
                         }
                     }
                     return $out;
                 }
                 if ($itemtype != 'User') {
                     $toadd = '';
                     if ($itemtype == 'Ticket' && $data[$num][0]['id'] > 0) {
                         $userdata = getUserName($data[$num][0]['id'], 2);
                         $toadd = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                     }
                     $usernameformat = formatUserName($data[$num][0]['id'], $data[$num][0]['name'], $data[$num][0]['realname'], $data[$num][0]['firstname'], 1);
                     return sprintf(__('%1$s %2$s'), $usernameformat, $toadd);
//.........这里部分代码省略.........
开发者ID:jose-martins,项目名称:glpi,代码行数:101,代码来源:search.class.php


示例10: showForProfile

 /**
  * Show the User having a profile, in allowed Entity
  *
  * @param $prof Profile object
  **/
 static function showForProfile(Profile $prof)
 {
     global $DB, $CFG_GLPI;
     $ID = $prof->fields['id'];
     $canedit = Session::haveRightsOr("user", array(CREATE, UPDATE, DELETE, PURGE));
     $rand = mt_rand();
     if (!$prof->can($ID, READ)) {
         return false;
     }
     $query = "SELECT `glpi_users`.*,\n                       `glpi_profiles_users`.`entities_id` AS entity,\n                       `glpi_profiles_users`.`id` AS linkID,\n                       `glpi_profiles_users`.`is_dynamic`,\n                       `glpi_profiles_users`.`is_recursive`\n                FROM `glpi_profiles_users`\n                LEFT JOIN `glpi_entities`\n                     ON (`glpi_entities`.`id`=`glpi_profiles_users`.`entities_id`)\n                LEFT JOIN `glpi_users`\n                     ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                WHERE `glpi_profiles_users`.`profiles_id` = '{$ID}'\n                      AND `glpi_users`.`is_deleted` = '0' " . getEntitiesRestrictRequest("AND", "glpi_profiles_users", 'entities_id', $_SESSION['glpiactiveentities'], true) . "\n                ORDER BY `glpi_entities`.`completename`";
     $result = $DB->query($query);
     $nb = $DB->numrows($result);
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'><tr>";
     echo "<th>" . sprintf(__('%1$s: %2$s'), __('Profile'), $prof->fields["name"]) . "</th></tr>\n";
     echo "<tr><th colspan='2'>" . sprintf(__('%1$s (%2$s)'), _n('User', 'Users', Session::getPluralNumber()), __('D=Dynamic, R=Recursive')) . "</th></tr>";
     echo "</table>\n";
     echo "<table class='tab_cadre_fixe'>";
     $i = 0;
     $nb_per_line = 3;
     $rand = mt_rand();
     // Just to avoid IDE warning
     $canedit_entity = false;
     if ($nb) {
         $temp = -1;
         while ($data = $DB->fetch_assoc($result)) {
             if ($data["entity"] != $temp) {
                 while ($i % $nb_per_line != 0) {
                     if ($canedit_entity) {
                         echo "<td width='10'>&nbsp;</td>";
                     }
                     echo "<td class='tab_bg_1'>&nbsp;</td>\n";
                     $i++;
                 }
                 if ($i != 0) {
                     echo "</table>";
                     echo "</div>";
                     echo "</td></tr>\n";
                 }
                 // New entity
                 $i = 0;
                 $temp = $data["entity"];
                 $canedit_entity = $canedit && in_array($temp, $_SESSION['glpiactiveentities']);
                 $rand = mt_rand();
                 echo "<tr class='tab_bg_2'>";
                 echo "<td>";
                 echo "<a href=\"javascript:showHideDiv('entity{$temp}{$rand}','imgcat{$temp}', '" . $CFG_GLPI['root_doc'] . "/pics/folder.png','" . $CFG_GLPI['root_doc'] . "/pics/folder-open.png');\">";
                 echo "<img alt='' name='imgcat{$temp}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/folder.png\">&nbsp;";
                 echo "<span class='b'>" . Dropdown::getDropdownName('glpi_entities', $data["entity"]) . "</span>";
                 echo "</a>";
                 echo "</td></tr>\n";
                 echo "<tr class='tab_bg_2'><td>";
                 echo "<div class='center' id='entity{$temp}{$rand}' style='display:none;'>\n";
                 echo Html::checkAllAsCheckbox("entity{$temp}{$rand}") . __('All');
                 echo "<table class='tab_cadre_fixe'>\n";
             }
             if ($i % $nb_per_line == 0) {
                 if ($i != 0) {
                     echo "</tr>\n";
                 }
                 echo "<tr class='tab_bg_1'>\n";
                 $i = 0;
             }
             if ($canedit_entity) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
                 echo "</td>";
             }
             $username = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], 1);
             if ($data["is_dynamic"] || $data["is_recursive"]) {
                 $username = sprintf(__('%1$s %2$s'), $username, "<span class='b'>(");
                 if ($data["is_dynamic"]) {
                     $username = sprintf(__('%1$s%2$s'), $username, __('D'));
                 }
                 if ($data["is_dynamic"] && $data["is_recursive"]) {
                     $username = sprintf(__('%1$s%2$s'), $username, ", ");
                 }
                 if ($data["is_recursive"]) {
                     $username = sprintf(__('%1$s%2$s'), $username, __('R'));
                 }
                 $username = sprintf(__('%1$s%2$s'), $username, ")</span>");
             }
             echo "<td class='tab_bg_1'>" . $username . "</td>\n";
             $i++;
         }
         if ($i % $nb_per_line != 0) {
             while ($i % $nb_per_line != 0) {
                 if ($canedit_entity) {
                     echo "<td width='10'>&nbsp;</td>";
                 }
//.........这里部分代码省略.........
开发者ID:Ixertec,项目名称:glpi,代码行数:101,代码来源:profile_user.class.php


示例11: getSender

 function getSender($options = array())
 {
     $mails = new UserEmail();
     if (isset($_SESSION['glpiID']) && $_SESSION['glpiID'] > 0 && isset($_SESSION['glpilock_directunlock_notification']) && $_SESSION['glpilock_directunlock_notification'] > 0 && $mails->getFromDBByQuery(" WHERE users_id = " . $_SESSION['glpiID'] . "\n                                              AND is_default = 1 ")) {
         $ret = array('email' => $mails->fields['email'], 'name' => formatUserName(0, $_SESSION["glpiname"], $_SESSION["glpirealname"], $_SESSION["glpifirstname"]));
     } else {
         $ret = parent::getSender($options);
     }
     return $ret;
 }
开发者ID:btry,项目名称:glpi,代码行数:10,代码来源:notificationtargetobjectlock.class.php


示例12: showForResource

 /**
  * Show items links to a resource
  *
  * @since version 0.84
  *
  * @param $resource PluginResourcesResource object
  *
  * @return nothing (HTML display)
  **/
 public static function showForResource(PluginResourcesResource $resource, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $instID = $resource->fields['id'];
     if (!$resource->can($instID, 'r')) {
         return false;
     }
     $rand = mt_rand();
     $canedit = $resource->can($instID, 'w');
     if (empty($withtemplate)) {
         $withtemplate = 0;
     }
     $types = PluginResourcesResource::getTypes();
     $plugin = new Plugin();
     if ($plugin->isActivated("badges")) {
         $types[] = 'PluginBadgesBadge';
     }
     $query = "SELECT DISTINCT `itemtype` \n          FROM `glpi_plugin_resources_resources_items` \n          WHERE `plugin_resources_resources_id` = '{$instID}' \n          ORDER BY `itemtype` \n          LIMIT " . count($types);
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (Session::isMultiEntitiesMode()) {
         $colsup = 1;
     } else {
         $colsup = 0;
     }
     if ($canedit && $withtemplate < 2 && $number < 1) {
         echo "<div class='firstbloc'>";
         echo "<form method='post' name='resource_form{$rand}' id='resource_form{$rand}'\n         action='" . Toolbox::getItemTypeFormURL("PluginResourcesResource") . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='" . ($canedit ? 5 + $colsup : 4 + $colsup) . "'>" . __('Add a user') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td colspan='" . (3 + $colsup) . "' class='center'>";
         echo "<input type='hidden' name='plugin_resources_resources_id' value='{$instID}'>";
         echo "<input type='hidden' name='itemtype' value='User'>";
         //Dropdown::showAllItems("items_id",0,0,($resource->fields['is_recursive']?-1:$resource->fields['entities_id']),$types);
         User::dropdown(array('name' => 'items_id', 'entity' => $resource->fields["entities_id"], 'right' => 'all', 'ldap_import' => true));
         echo "</td>";
         echo "<td colspan='2' class='tab_bg_2'>";
         echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number && $withtemplate < 2) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array();
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $number && $withtemplate < 2) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . __('Name') . "</th>";
     if (Session::isMultiEntitiesMode()) {
         echo "<th>" . __('Entity') . "</th>";
     }
     echo "<th>" . __('Serial Number') . "</th>";
     echo "<th>" . __('Inventory number') . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $itemType = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemType))) {
             continue;
         }
         if ($item->canView()) {
             $column = "name";
             $itemTable = getTableForItemType($itemType);
             $query = "SELECT `" . $itemTable . "`.*,\n                             `glpi_plugin_resources_resources_items`.`id` AS items_id,\n                             `glpi_plugin_resources_resources_items`.`comment` AS comment,\n                             `glpi_entities`.`id` AS entity " . " FROM `glpi_plugin_resources_resources_items`, `" . $itemTable . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $itemTable . "`.`entities_id`) " . " WHERE `" . $itemTable . "`.`id` = `glpi_plugin_resources_resources_items`.`items_id`\n                AND `glpi_plugin_resources_resources_items`.`itemtype` = '{$itemType}'\n                AND `glpi_plugin_resources_resources_items`.`plugin_resources_resources_id` = '{$instID}' ";
             if ($itemType != 'User') {
                 $query .= getEntitiesRestrictRequest(" AND ", $itemTable, '', '', $item->maybeRecursive());
             }
             if ($item->maybeTemplate()) {
                 $query .= " AND `" . $itemTable . "`.`is_template` = '0'";
             }
             $query .= " ORDER BY `glpi_entities`.`completename`, `" . $itemTable . "`.`{$column}`";
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     Session::initNavigateListItems($itemType, PluginResourcesResource::getTypeName(2) . " = " . $resource->fields['name']);
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         $item->getFromDB($data["id"]);
                         Session::addToNavigateListItems($itemType, $data["id"]);
                         $ID = "";
                         if ($itemType == 'User') {
                             $format = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], 1);
                         } else {
                             $format = $data["name"];
                         }
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:resource_item.class.php


示例13: checkAvailability

 /**
  * Show the availability of a user
  *
  * @since version 0.83
  *
  * @param $params   array of params
  *    must contain :
  *          - begin: begin date to check (default '')
  *          - end: end date to check (default '')
  *          - itemtype : User or Object type (Ticket...)
  *          - foreign key field of the itemtype to define which item to used
  *    optional :
  *          - limitto : limit display to a specific user
  *
  * @return Nothing (display function)
  **/
 static function checkAvailability($params = array())
 {
     global $CFG_GLPI, $DB;
   

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP formatValue函数代码示例发布时间:2022-05-15
下一篇:
PHP formatUrl函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap