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


PHP NetworkPort::can方法代码示例

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


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

示例1: foreach

 if (isset($_POST["delete_several"])) {
     Session::checkRight("networking", UPDATE);
     if (isset($_POST["del_port"]) && count($_POST["del_port"])) {
         foreach ($_POST["del_port"] as $port_id => $val) {
             if ($np->can($port_id, PURGE)) {
                 $np->delete(array("id" => $port_id));
             }
         }
     }
     Event::log(0, "networkport", 5, "inventory", sprintf(__('%s deletes several network ports'), $_SESSION["glpiname"]));
     Html::back();
 } else {
     if (isset($_POST["update"])) {
         $np->check($_POST['id'], PURGE);
         $networkport = new NetworkPort();
         if ($networkport->can($_POST['id'], UPDATE)) {
             if ($networkport->switchInstantiationType($_POST['transform_to']) !== false) {
                 $instantiation = $networkport->getInstantiation();
                 $input = $np->fields;
                 $input['networkports_id'] = $input['id'];
                 unset($input['id']);
                 if ($instantiation->add($input)) {
                     $np->delete($_POST);
                 }
             } else {
                 Session::addMessageAfterRedirect(__('Cannot change a migration network port to an unknown one'));
             }
         } else {
             Session::addMessageAfterRedirect(__('Network port is not available...'));
             $np->delete($_POST);
         }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:networkportmigration.form.php

示例2: showForNetworkPort

 /**
  * @param $port   NetworkPort object
  **/
 static function showForNetworkPort(NetworkPort $port)
 {
     global $DB, $CFG_GLPI;
     $ID = $port->getID();
     if (!$port->can($ID, READ)) {
         return false;
     }
     $canedit = $port->canEdit($ID);
     $rand = mt_rand();
     $query = "SELECT `glpi_networkports_vlans`.id as assocID,\n                       `glpi_networkports_vlans`.tagged ,\n                       `glpi_vlans`.*\n                FROM `glpi_networkports_vlans`\n                LEFT JOIN `glpi_vlans`\n                        ON (`glpi_networkports_vlans`.`vlans_id` = `glpi_vlans`.`id`)\n                WHERE `networkports_id` = '{$ID}'";
     $result = $DB->query($query);
     $vlans = array();
     $used = array();
     if ($number = $DB->numrows($result)) {
         while ($line = $DB->fetch_assoc($result)) {
             $used[$line["id"]] = $line["id"];
             $vlans[$line["assocID"]] = $line;
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>\n";
         echo "<form method='post' action='" . static::getFormURL() . "'>\n";
         echo "<table class='tab_cadre_fixe'>\n";
         echo "<tr><th colspan='4'>" . __('Associate a VLAN') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='right'>";
         echo "<input type='hidden' name='networkports_id' value='{$ID}'>";
         Vlan::dropdown(array('used' => $used));
         echo "</td>";
         echo "<td class='right'>" . __('Tagged') . "</td>";
         echo "<td class='left'><input type='checkbox' name='tagged' value='1'></td>";
         echo "<td><input type='submit' name='add' value='" . _sx('button', 'Associate') . "' class='submit'>";
         echo "</td></tr>\n";
         echo "</table>\n";
         Html::closeForm();
         echo "</div>\n";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number, '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'>";
         $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
         $header_bottom .= "<th width='10'>";
         $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     $header_end .= "<th>" . __('Name') . "</th>";
     $header_end .= "<th>" . __('Entity') . "</th>";
     $header_end .= "<th>" . __('Tagged') . "</th>";
     $header_end .= "<th>" . __('ID TAG') . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     $used = array();
     foreach ($vlans as $data) {
         echo "<tr class='tab_bg_1'>";
         if ($canedit) {
             echo "<td>";
             Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
             echo "</td>";
         }
         $name = $data["name"];
         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
             $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
         }
         echo "<td class='center b'>\n               <a href='" . $CFG_GLPI["root_doc"] . "/front/vlan.form.php?id=" . $data["id"] . "'>" . $name . "</a>";
         echo "</td>";
         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]);
         echo "</td><td class='center'>" . Dropdown::getYesNo($data["tagged"]) . "</td>";
         echo "<td class='numeric'>" . $data["tag"] . "</td>";
         echo "</tr>";
     }
     if ($number) {
         echo $header_begin . $header_top . $header_end;
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
开发者ID:jose-martins,项目名称:glpi,代码行数:92,代码来源:networkport_vlan.class.php

示例3: unset

        Html::back();
    } else {
        Session::checkRight("networking", "w");
        $input = $_POST;
        unset($input['several']);
        unset($input['from_logical_number']);
        unset($input['to_logical_number']);
        for ($i = $_POST["from_logical_number"]; $i <= $_POST["to_logical_number"]; $i++) {
            $add = "";
            if ($i < 10) {
                $add = "0";
            }
            $input["logical_number"] = $i;
            $input["name"] = $_POST["name"] . $add . $i;
            unset($np->fields["id"]);
            if ($np->can(-1, 'w', $input)) {
                $np->splitInputForElements($input);
                $np->add($input);
                $np->updateDependencies(1);
            }
        }
        Event::log(0, "networkport", 5, "inventory", sprintf(__('%s adds several network ports'), $_SESSION["glpiname"]));
        Html::back();
    }
} else {
    if (isset($_POST["delete"])) {
        $np->check($_POST['id'], 'd');
        $np->delete($_POST);
        Event::log($_POST['id'], "networkport", 5, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
        if ($item = getItemForItemtype($np->fields['itemtype'])) {
            Html::redirect($item->getFormURL() . '?id=' . $np->fields['items_id']);
开发者ID:geldarr,项目名称:hack-space,代码行数:31,代码来源:networkport.form.php

示例4: showForNetworkPortForm

 static function showForNetworkPortForm($ID)
 {
     global $DB, $CFG_GLPI, $LANG;
     $port = new NetworkPort();
     if ($ID && $port->can($ID, 'w')) {
         echo "\n<div class='center'>";
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php'>";
         echo "<input type='hidden' name='networkports_id' value='{$ID}'>\n";
         echo "<table class='tab_cadre'>";
         echo "<tr><th>" . $LANG['setup'][90] . "</th></tr>\n";
         echo "<tr class='tab_bg_2'><td>";
         $used = self::showForNetworkPort($ID, true, 0);
         echo "</td></tr>\n";
         echo "<tr class='tab_bg_2'><td>";
         echo $LANG['networking'][55] . "&nbsp;:&nbsp;";
         Dropdown::show('Vlan', array('used' => $used));
         echo "&nbsp;<input type='submit' name='assign_vlan' value='" . $LANG['buttons'][3] . "' class='submit'>";
         echo "</td></tr>\n";
         echo "</table></form>";
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:21,代码来源:networkport_vlan.class.php

示例5: foreach

 if (isset($_POST["delete_several"])) {
     Session::checkRight("networking", "w");
     if (isset($_POST["del_port"]) && count($_POST["del_port"])) {
         foreach ($_POST["del_port"] as $port_id => $val) {
             if ($np->can($port_id, 'd')) {
                 $np->delete(array("id" => $port_id));
             }
         }
     }
     Event::log(0, "networkport", 5, "inventory", sprintf(__('%s deletes several network ports'), $_SESSION["glpiname"]));
     Html::back();
 } else {
     if (isset($_POST["update"])) {
         $np->check($_POST['id'], 'd');
         $networkport = new NetworkPort();
         if ($networkport->can($_POST['id'], 'w')) {
             if ($networkport->switchInstantiationType($_POST['transform_to']) !== false) {
                 $instantiation = $networkport->getInstantiation();
                 $input = $np->fields;
                 $input['networkports_id'] = $input['id'];
                 unset($input['id']);
                 if ($instantiation->add($input)) {
                     $np->delete($_POST);
                 }
             } else {
                 Session::addMessageAfterRedirect(__('Cannot change a migration network port to an unknown one'));
             }
         } else {
             Session::addMessageAfterRedirect(__('Network port is not available...'));
             $np->delete($_POST);
         }
开发者ID:gaforeror,项目名称:glpi,代码行数:31,代码来源:networkportmigration.form.php

示例6: unset

        Html::back();
    } else {
        Session::checkRight("networking", UPDATE);
        $input = $_POST;
        unset($input['several']);
        unset($input['from_logical_number']);
        unset($input['to_logical_number']);
        for ($i = $_POST["from_logical_number"]; $i <= $_POST["to_logical_number"]; $i++) {
            $add = "";
            if ($i < 10) {
                $add = "0";
            }
            $input["logical_number"] = $i;
            $input["name"] = $_POST["name"] . $add . $i;
            unset($np->fields["id"]);
            if ($np->can(-1, CREATE, $input)) {
                $np->splitInputForElements($input);
                $np->add($input);
                $np->updateDependencies(1);
            }
        }
        Event::log(0, "networkport", 5, "inventory", sprintf(__('%s adds several network ports'), $_SESSION["glpiname"]));
        Html::back();
    }
} else {
    if (isset($_POST["purge"])) {
        $np->check($_POST['id'], PURGE);
        $np->delete($_POST, 1);
        Event::log($_POST['id'], "networkport", 5, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
        if ($item = getItemForItemtype($np->fields['itemtype'])) {
            Html::redirect($item->getFormURL() . '?id=' . $np->fields['items_id']);
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:networkport.form.php

示例7: NetworkPort

--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file:
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
if (!isset($_POST['id'])) {
    exit;
}
if (!isset($_REQUEST['glpi_tab'])) {
    exit;
}
$port = new NetworkPort();
if ($_POST["id"] > 0 && $port->can($_POST["id"], 'r')) {
    switch ($_REQUEST['glpi_tab']) {
        case -1:
            // All
            NetworkPort_Vlan::showForNetworkPortForm($_POST["id"]);
            Plugin::displayAction($port, $_REQUEST['glpi_tab']);
            Log::showForItem($port);
            break;
        case 12:
            Log::showForItem($port);
            break;
        default:
            if (!Plugin::displayAction($port, $_REQUEST['glpi_tab'])) {
                NetworkPort_Vlan::showForNetworkPortForm($_POST["id"]);
            }
    }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:networkport.tabs.php

示例8: checkRight

        glpi_header($_SERVER['HTTP_REFERER']);
    } else {
        checkRight("networking", "w");
        $input = $_POST;
        unset($input['several']);
        unset($input['from_logical_number']);
        unset($input['to_logical_number']);
        for ($i = $_POST["from_logical_number"]; $i <= $_POST["to_logical_number"]; $i++) {
            $add = "";
            if ($i < 10) {
                $add = "0";
            }
            $input["logical_number"] = $i;
            $input["name"] = $_POST["name"] . $add . $i;
            unset($np->fields["id"]);
            if ($np->can(-1, 'w', $input)) {
                $np->add($input);
            }
        }
        Event::log(0, "networkport", 5, "inventory", $_SESSION["glpiname"] . "  " . ($_POST["to_logical_number"] - $_POST["from_logical_number"] + 1) . "  " . $LANG['log'][71]);
        glpi_header($_SERVER['HTTP_REFERER']);
    }
} else {
    if (isset($_POST["delete"])) {
        $np->check($_POST['id'], 'd');
        $np->delete($_POST);
        Event::log($_POST['id'], "networkport", 5, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][73]);
        if (class_exists($np->fields['itemtype'])) {
            $item = new $np->fields['itemtype']();
            glpi_header($item->getFormURL() . '?id=' . $np->fields['items_id']);
        }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:networkport.form.php

示例9: doSpecificMassiveActions

 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "transform_to":
             if (isset($input["transform_to"]) && !empty($input["transform_to"])) {
                 $networkport = new NetworkPort();
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($networkport->can($key, 'w') && $this->can($key, 'd')) {
                             // Don't try to migrate already affected ports
                             if (empty($networkport->fields['instantiation_type'])) {
                                 if ($networkport->switchInstantiationType($input['transform_to']) !== false) {
                                     $instantiation = $networkport->getInstantiation();
                                     $input2 = $this->fields;
                                     $input2['networkports_id'] = $input2['id'];
                                     unset($input2['id']);
                                     if ($instantiation->add($input2)) {
                                         $this->delete(array('id' => $key));
                                         $res['ok']++;
                                     } else {
                                         $res['ko']++;
                                     }
                                 } else {
                                     $res['ko']++;
                                 }
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             } else {
                 $res['ko']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:46,代码来源:networkportmigration.class.php


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