当前位置: 首页>>代码示例>>PHP>>正文


PHP Problem::can方法代码示例

本文整理汇总了PHP中Problem::can方法的典型用法代码示例。如果您正苦于以下问题:PHP Problem::can方法的具体用法?PHP Problem::can怎么用?PHP Problem::can使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Problem的用法示例。


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

示例1: showForProblem

 /**
  * Print the HTML array for Items linked to a problem
  *
  * @param $problem Problem object
  *
  * @return Nothing (display)
  **/
 static function showForProblem(Problem $problem)
 {
     global $DB, $CFG_GLPI;
     $instID = $problem->fields['id'];
     if (!$problem->can($instID, READ)) {
         return false;
     }
     $canedit = $problem->canEdit($instID);
     $rand = mt_rand();
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_items_problems`\n                WHERE `glpi_items_problems`.`problems_id` = '{$instID}'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='problemitem_form{$rand}' id='problemitem_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>";
         $types = array();
         foreach ($problem->getAllTypesForHelpdesk() as $key => $val) {
             $types[] = $key;
         }
         Dropdown::showSelectItemFromItemtypes(array('itemtypes' => $types, 'entity_restrict' => $problem->fields['is_recursive'] ? getSonsOf('glpi_entities', $problem->fields['entities_id']) : $problem->fields['entities_id']));
         echo "</td><td class='center' width='30%'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "<input type='hidden' name='problems_id' value='{$instID}'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $number) {
         $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_top .= "</th>";
         $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= "</th>";
     }
     $header_end .= "<th>" . __('Type') . "</th>";
     $header_end .= "<th>" . __('Entity') . "</th>";
     $header_end .= "<th>" . __('Name') . "</th>";
     $header_end .= "<th>" . __('Serial number') . "</th>";
     $header_end .= "<th>" . __('Inventory number') . "</th></tr>";
     echo $header_begin . $header_top . $header_end;
     $totalnb = 0;
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         if ($item->canView()) {
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                             `glpi_items_problems`.`id` AS IDD,\n                             `glpi_entities`.`id` AS entity\n                      FROM `glpi_items_problems`,\n                           `{$itemtable}`";
             if ($itemtype != 'Entity') {
                 $query .= " LEFT JOIN `glpi_entities`\n                                 ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) ";
             }
             $query .= " WHERE `{$itemtable}`.`id` = `glpi_items_problems`.`items_id`\n                              AND `glpi_items_problems`.`itemtype` = '{$itemtype}'\n                              AND `glpi_items_problems`.`problems_id` = '{$instID}'";
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             $query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n                      ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`";
             $result_linked = $DB->query($query);
             $nb = $DB->numrows($result_linked);
             for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) {
                 $name = $data["name"];
                 if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                     $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
                 }
                 $link = $itemtype::getFormURLWithID($data['id']);
                 $namelink = "<a href=\"" . $link . "\">" . $name . "</a>";
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td width='10'>";
                     Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]);
                     echo "</td>";
                 }
                 if ($prem) {
                     $typename = $item->getTypeName($nb);
                     echo "<td class='center top' rowspan='{$nb}'>" . ($nb > 1 ? sprintf(__('%1$s: %2$s'), $typename, $nb) : $typename) . "</td>";
                 }
                 echo "<td class='center'>";
                 echo Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>";
                 echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'");
//.........这里部分代码省略.........
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:101,代码来源:item_problem.class.php

示例2: Problem

* @since version 0.83
*/
if (!defined('GLPI_ROOT')) {
    include '../inc/includes.php';
}
$link = new Problem_User();
$item = new Problem();
Session::checkLoginUser();
Html::popHeader(__('Email followup'), $_SERVER['PHP_SELF']);
if (isset($_POST["update"])) {
    $link->check($_POST["id"], UPDATE);
    $link->update($_POST);
} else {
    if (isset($_POST['delete'])) {
        $link->check($_POST['id'], DELETE);
        $link->delete($_POST);
        Event::log($link->fields['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"]));
        if ($item->can($link->fields["problems_id"], READ)) {
            Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $link->fields['problems_id']);
        }
        Session::addMessageAfterRedirect(__('You have been redirected because you no longer have access to this item'), true, ERROR);
        Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.php");
    } else {
        if (isset($_GET["id"])) {
            $link->showUserNotificationForm($_GET["id"]);
        } else {
            Html::displayErrorAndDie('Lost');
        }
    }
}
Html::popFooter();
开发者ID:glpi-project,项目名称:glpi,代码行数:31,代码来源:problem_user.form.php

示例3: showForProblem

 /**
  * Show tickets for a problem
  *
  * @param $problem Problem object
  **/
 static function showForProblem(Problem $problem)
 {
     global $DB, $CFG_GLPI;
     $ID = $problem->getField('id');
     if (!$problem->can($ID, READ)) {
         return false;
     }
     $canedit = $problem->canEdit($ID);
     $rand = mt_rand();
     $query = "SELECT DISTINCT `glpi_problems_tickets`.`id` AS linkID,\n                                `glpi_tickets`.*\n                FROM `glpi_problems_tickets`\n                LEFT JOIN `glpi_tickets`\n                     ON (`glpi_problems_tickets`.`tickets_id` = `glpi_tickets`.`id`)\n                WHERE `glpi_problems_tickets`.`problems_id` = '{$ID}'\n                ORDER BY `glpi_tickets`.`name`";
     $result = $DB->query($query);
     $tickets = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $tickets[$data['id']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='changeticket_form{$rand}' id='changeticket_form{$rand}' method='post'\n               action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a ticket') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td class='right'>";
         echo "<input type='hidden' name='problems_id' value='{$ID}'>";
         $condition = "`glpi_tickets`.`status`\n                        NOT IN ('" . implode("', '", array_merge(Ticket::getSolvedStatusArray(), Ticket::getClosedStatusArray())) . "')";
         Ticket::dropdown(array('used' => $used, 'entity' => $problem->getEntityID(), 'entity_sons' => $problem->isRecursive(), 'condition' => $condition, 'displaywith' => array('id')));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently'), __CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'solveticket' => __('Solve tickets')), 'extraparams' => array('problems_id' => $problem->getID()), 'width' => 1000, 'height' => 500);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='noHover'><th colspan='12'>" . Ticket::getTypeName($numrows) . "</th>";
     echo "</tr>";
     if ($numrows) {
         Ticket::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
         Session::initNavigateListItems('Ticket', sprintf(__('%1$s = %2$s'), Problem::getTypeName(1), $problem->fields["name"]));
         $i = 0;
         foreach ($tickets as $data) {
             Session::addToNavigateListItems('Ticket', $data["id"]);
             Ticket::showShort($data['id'], array('followups' => false, 'row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID']));
             $i++;
         }
         Ticket::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
开发者ID:jose-martins,项目名称:glpi,代码行数:68,代码来源:problem_ticket.class.php

示例4: showForProblem

 /**
  * Show tickets for a problem
  *
  * @param $problem Problem object
  **/
 static function showForProblem(Problem $problem)
 {
     global $DB, $CFG_GLPI;
     $ID = $problem->getField('id');
     if (!$problem->can($ID, 'r')) {
         return false;
     }
     $canedit = $problem->can($ID, 'w');
     $rand = mt_rand();
     $showentities = Session::isMultiEntitiesMode();
     $query = "SELECT DISTINCT `glpi_changes_problems`.`id` AS linkID,\n                                `glpi_changes`.*\n                FROM `glpi_changes_problems`\n                LEFT JOIN `glpi_changes`\n                     ON (`glpi_changes_problems`.`changes_id` = `glpi_changes`.`id`)\n                WHERE `glpi_changes_problems`.`problems_id` = '{$ID}'\n                ORDER BY `glpi_changes`.`name`";
     $result = $DB->query($query);
     $changes = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $changes[$data['id']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a change') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td>";
         echo "<input type='hidden' name='problems_id' value='{$ID}'>";
         Change::dropdown(array('used' => $used, 'entity' => $problem->getEntityID(), 'entity_sons' => $problem->isRecursive()));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td><td>";
         echo "<a href='" . Toolbox::getItemTypeFormURL('Change') . "?problems_id={$ID}'>";
         _e('Create a change from this problem');
         echo "</a>";
         echo "</td></tr></table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows);
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     if ($canedit && $numrows) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . _n('Change', 'Changes', 2);
     echo "</th>";
     if ($showentities) {
         echo "<th>" . __('Entity') . "</th>";
     }
     echo "</tr>";
     $used = array();
     if ($numrows) {
         Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), Problem::getTypeName(1), $problem->fields["name"]));
         foreach ($changes as $data) {
             Session::addToNavigateListItems('Change', $data["id"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
                 echo "</td>";
             }
             echo "<td><a href='" . Toolbox::getItemTypeFormURL('Change') . "?id=" . $data['id'] . "'>" . $data["name"] . "</a></td>";
             if ($showentities) {
                 echo "<td>" . Dropdown::getDropdownName('glpi_entities', $data["entities_id"]) . "</td>";
             }
             echo "</tr>";
         }
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:86,代码来源:change_problem.class.php

示例5: showForProblem

 /**
  * Show tickets for a problem
  *
  * @param $problem Problem object
  **/
 static function showForProblem(Problem $problem)
 {
     global $DB, $CFG_GLPI;
     $ID = $problem->getField('id');
     if (!$problem->can($ID, READ)) {
         return false;
     }
     $canedit = $problem->canEdit($ID);
     $rand = mt_rand();
     $showentities = Session::isMultiEntitiesMode();
     $query = "SELECT DISTINCT `glpi_changes_problems`.`id` AS linkID,\n                                `glpi_changes`.*\n                FROM `glpi_changes_problems`\n                LEFT JOIN `glpi_changes`\n                     ON (`glpi_changes_problems`.`changes_id` = `glpi_changes`.`id`)\n                WHERE `glpi_changes_problems`.`problems_id` = '{$ID}'\n                ORDER BY `glpi_changes`.`name`";
     $result = $DB->query($query);
     $changes = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $changes[$data['id']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a change') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td>";
         echo "<input type='hidden' name='problems_id' value='{$ID}'>";
         Change::dropdown(array('used' => $used, 'entity' => $problem->getEntityID(), 'entity_sons' => $problem->isRecursive()));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td><td>";
         if (Session::haveRight('change', CREATE)) {
             echo "<a href='" . Toolbox::getItemTypeFormURL('Change') . "?problems_id={$ID}'>";
             _e('Create a change from this problem');
             echo "</a>";
         }
         echo "</td></tr></table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='noHover'><th colspan='12'>" . Change::getTypeName($numrows) . "</th>";
     echo "</tr>";
     if ($numrows) {
         Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
         Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), Problem::getTypeName(1), $problem->fields["name"]));
         $i = 0;
         foreach ($changes as $data) {
             Session::addToNavigateListItems('Change', $data["id"]);
             Change::showShort($data['id'], array('row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID']));
             $i++;
         }
         Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:73,代码来源:change_problem.class.php

示例6: sprintf

     $problem->check($_POST["id"], 'w');
     $problem->update($_POST);
     Event::log($_POST["id"], "problem", 4, "maintain", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
     // Copy solution to KB redirect to KB
     if (isset($_POST['_sol_to_kb']) && $_POST['_sol_to_kb']) {
         Html::redirect($CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?id=new&item_itemtype=Problem&item_items_id=" . $_POST["id"]);
     } else {
         Html::back();
     }
 } else {
     if (isset($_POST['delete_user'])) {
         $problem_user = new Problem_User();
         $problem_user->check($_POST['id'], 'd');
         $problem_user->delete($_POST);
         Event::log($_POST['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"]));
         if ($problem->can($_POST["problems_id"], 'r')) {
             Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $_POST["problems_id"]);
         }
         Session::addMessageAfterRedirect(__('You have been redirected because you no longer have access to this item'), true, ERROR);
         Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.php");
     } else {
         if (isset($_POST['delete_group'])) {
             $group_problem = new Group_Problem();
             $group_problem->check($_POST['id'], 'd');
             $group_problem->delete($_POST);
             Event::log($_POST['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"]));
             if ($problem->can($_POST["problems_id"], 'r')) {
                 Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $_POST["problems_id"]);
             }
             Session::addMessageAfterRedirect(__('You have been redirected because you no longer have access to this item'), true, ERROR);
             Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.php");
开发者ID:geldarr,项目名称:hack-space,代码行数:31,代码来源:problem.form.php


注:本文中的Problem::can方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。