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


PHP Toolbox::is_a方法代码示例

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


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

示例1: canApplyOn

 /**
  * Check if given object can have InfoCom
  *
  * @since version 0.85
  *
  * @param $item  an object or a string
  *
  * @return true if $object is an object that can have InfoCom
  *
  **/
 static function canApplyOn($item)
 {
     global $CFG_GLPI;
     // All devices are subjects to infocom !
     if (Toolbox::is_a($item, 'Item_Devices')) {
         return true;
     }
     // We also allow direct items to check
     if ($item instanceof CommonGLPI) {
         $item = $item->getType();
     }
     if (in_array($item, $CFG_GLPI['infocom_types'])) {
         return true;
     }
     return false;
 }
开发者ID:GeorgeAlexandre,项目名称:glpi,代码行数:26,代码来源:infocom.class.php

示例2: getMetaReferenceItemtype

 /**
  * @since version 0.85
  *
  * @param $itemtype
  **/
 static function getMetaReferenceItemtype($itemtype)
 {
     $types = array('Computer', 'Problem', 'Ticket', 'Printer', 'Monitor', 'Peripheral', 'Software', 'Phone');
     foreach ($types as $type) {
         if (Toolbox::is_a($itemtype, $type)) {
             return $type;
         }
     }
     return false;
 }
开发者ID:jose-martins,项目名称:glpi,代码行数:15,代码来源:search.class.php

示例3: getMassiveActionsForItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::getMassiveActionsForItemtype()
  **/
 static function getMassiveActionsForItemtype(array &$actions, $itemtype, $is_deleted = 0, CommonDBTM $checkitem = NULL)
 {
     global $CFG_GLPI;
     $action_prefix = 'Document_Item' . MassiveAction::CLASS_ACTION_SEPARATOR;
     if (self::canApplyOn($itemtype)) {
         if (Document::canView()) {
             $actions[$action_prefix . 'add'] = _x('button', 'Add a document');
             $actions[$action_prefix . 'remove'] = _x('button', 'Remove a document');
         }
     }
     if (Toolbox::is_a($itemtype, __CLASS__) && static::canUpdate()) {
         $actions[$action_prefix . 'add_item'] = _x('button', 'Add an item');
         $actions[$action_prefix . 'remove_item'] = _x('button', 'Remove an item');
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:20,代码来源:document.class.php

示例4: 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;
     if (!isset($params['itemtype'])) {
         return false;
     }
     if (!($item = getItemForItemtype($params['itemtype']))) {
         return false;
     }
     if (!isset($params[$item->getForeignKeyField()]) || !$item->getFromDB($params[$item->getForeignKeyField()])) {
         return false;
     }
     // No limit by default
     if (!isset($params['limitto'])) {
         $params['limitto'] = 0;
     }
     if (isset($params['begin']) && !empty($params['begin'])) {
         $begin = $params['begin'];
     } else {
         $begin = date("Y-m-d");
     }
     if (isset($params['end']) && !empty($params['end'])) {
         $end = $params['end'];
     } else {
         $end = date("Y-m-d");
     }
     if ($end < $begin) {
         $end = $begin;
     }
     $realbegin = $begin . " " . $CFG_GLPI["planning_begin"];
     $realend = $end . " " . $CFG_GLPI["planning_end"];
     $users = array();
     switch ($item->getType()) {
         case 'User':
             $users[$item->getID()] = $item->getName();
             break;
         default:
             if (Toolbox::is_a($item, 'CommonITILObject')) {
                 foreach ($item->getUsers(CommonITILActor::ASSIGN) as $data) {
                     $users[$data['users_id']] = getUserName($data['users_id']);
                 }
                 foreach ($item->getGroups(CommonITILActor::ASSIGN) as $data) {
                     foreach (Group_User::getGroupUsers($data['groups_id']) as $data2) {
                         $users[$data2['id']] = formatUserName($data2["id"], $data2["name"], $data2["realname"], $data2["firstname"]);
                     }
                 }
             }
             break;
     }
     asort($users);
     // Use get method to check availability
     echo "<div class='center'><form method='GET' name='form' action='planning.php'>\n";
     echo "<table class='tab_cadre_fixe'>";
     $colspan = 5;
     if (count($users) > 1) {
         $colspan++;
     }
     echo "<tr class='tab_bg_1'><th colspan='{$colspan}'>" . __('Availability') . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Start') . "</td>\n";
     echo "<td>";
     Html::showDateField("begin", array('value' => $begin, 'maybeempty' => false));
     echo "</td>\n";
     echo "<td>" . __('End') . "</td>\n";
     echo "<td>";
     Html::showDateField("end", array('value' => $end, 'maybeempty' => false));
     echo "</td>\n";
     if (count($users) > 1) {
         echo "<td width='40%'>";
         $data = array(0 => __('All'));
         $data += $users;
         Dropdown::showFromArray('limitto', $data, array('width' => '100%', 'value' => $params['limitto']));
         echo "</td>";
     }
     echo "<td class='center'>";
     echo "<input type='hidden' name='" . $item->getForeignKeyField() . "' value=\"" . $item->getID() . "\">";
     echo "<input type='hidden' name='itemtype' value=\"" . $item->getType() . "\">";
     echo "<input type='submit' class='submit' name='checkavailability' value=\"" . _sx('button', 'Search') . "\">";
     echo "</td>\n";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>\n";
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:glpi,代码行数:101,代码来源:planning.class.php

示例5: showForObject

 /**
  * Print the item costs
  *
  * @param $item                  CommonITILObject object or Project
  * @param $withtemplate boolean  Template or basic item (default '')
  *
  * @return total cost
  **/
 static function showForObject($item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $forproject = false;
     if (Toolbox::is_a($item, 'Project')) {
         $forproject = true;
     }
     $ID = $item->fields['id'];
     if (!$item->getFromDB($ID) || !$item->canViewItem() || !static::canView()) {
         return false;
     }
     $canedit = false;
     if (!$forproject) {
         $canedit = $item->canUpdateItem();
     }
     echo "<div class='center'>";
     $condition = "= '{$ID}'";
     if ($forproject) {
         $condition = " IN ('" . implode("','", ProjectTask::getAllTicketsForProject($ID)) . "')";
     }
     $query = "SELECT *\n                FROM `" . static::getTable() . "`\n                WHERE `" . static::$items_id . "` {$condition}\n                ORDER BY `begin_date`";
     $rand = mt_rand();
     if ($canedit) {
         echo "<div id='viewcost" . $ID . "_{$rand}'></div>\n";
         echo "<script type='text/javascript' >\n";
         echo "function viewAddCost" . $ID . "_{$rand}() {\n";
         $params = array('type' => static::getType(), 'parenttype' => static::$itemtype, static::$items_id => $ID, 'id' => -1);
         Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo "};";
         echo "</script>\n";
         if (static::canCreate()) {
             echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddCost" . $ID . "_{$rand}();'>";
             echo __('Add a new cost') . "</a></div>\n";
         }
     }
     $total = 0;
     $total_time = 0;
     $total_costtime = 0;
     $total_fixed = 0;
     $total_material = 0;
     if ($result = $DB->query($query)) {
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr class='noHover'>";
         if ($forproject) {
             echo "<th colspan='10'>" . _n('Ticket cost', 'Ticket costs', $DB->numrows($result)) . "</th>";
         } else {
             echo "<th colspan='7'>" . self::getTypeName($DB->numrows($result)) . "</th>";
             echo "<th>" . __('Item duration') . "</th>";
             echo "<th>" . CommonITILObject::getActionTime($item->fields['actiontime']) . "</th>";
         }
         echo "</tr>";
         if ($DB->numrows($result)) {
             echo "<tr>";
             if ($forproject) {
                 echo "<th>" . __('Ticket') . "</th>";
                 $ticket = new Ticket();
             }
             echo "<th>" . __('Name') . "</th>";
             echo "<th>" . __('Begin date') . "</th>";
             echo "<th>" . __('End date') . "</th>";
             echo "<th>" . __('Budget') . "</th>";
             echo "<th>" . __('Duration') . "</th>";
             echo "<th>" . __('Time cost') . "</th>";
             echo "<th>" . __('Fixed cost') . "</th>";
             echo "<th>" . __('Material cost') . "</th>";
             echo "<th>" . __('Total cost') . "</th>";
             echo "</tr>";
             Session::initNavigateListItems(static::getType(), sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
             while ($data = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditCost" . $data[static::$items_id] . "_" . $data['id'] . "_{$rand}();\"" : '') . ">";
                 $name = empty($data['name']) ? sprintf(__('%1$s (%2$s)'), $data['name'], $data['id']) : $data['name'];
                 if ($forproject) {
                     $ticket->getFromDB($data['tickets_id']);
                     echo "<td>" . $ticket->getLink() . "</td>";
                 }
                 echo "<td>";
                 printf(__('%1$s %2$s'), $name, Html::showToolTip($data['comment'], array('display' => false)));
                 if ($canedit) {
                     echo "\n<script type='text/javascript' >\n";
                     echo "function viewEditCost" . $data[static::$items_id] . "_" . $data["id"] . "_{$rand}() {\n";
                     $params = array('type' => static::getType(), 'parenttype' => static::$itemtype, static::$items_id => $data[static::$items_id], 'id' => $data["id"]);
                     Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                     echo "};";
                     echo "</script>\n";
                 }
                 echo "</td>";
                 echo "<td>" . Html::convDate($data['begin_date']) . "</td>";
                 echo "<td>" . Html::convDate($data['end_date']) . "</td>";
                 echo "<td>" . Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']) . "</td>";
                 echo "<td>" . CommonITILObject::getActionTime($data['actiontime']) . "</td>";
                 $total_time += $data['actiontime'];
                 echo "<td class='numeric'>" . Html::formatNumber($data['cost_time']) . "</td>";
//.........这里部分代码省略.........
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:101,代码来源:commonitilcost.class.php

示例6: showMassiveActionsSubForm

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     $action = $ma->getAction();
     $items = $ma->getItems();
     $itemtypes_affect = array();
     $itemtypes_unaffect = array();
     foreach (array_keys($items) as $itemtype) {
         if (!Toolbox::is_a($itemtype, __CLASS__)) {
             continue;
         }
         $specificities = $itemtype::getConnexityMassiveActionsSpecificities();
         if (in_array($action, $specificities['normalized']['affect'])) {
             $itemtypes_affect[$itemtype] = $specificities;
             continue;
         }
         if (in_array($action, $specificities['normalized']['unaffect'])) {
             $itemtypes_unaffect[$itemtype] = $specificities;
             continue;
         }
     }
     if (count($itemtypes_affect) > count($itemtypes_unaffect)) {
         $normalized_action = 'affect';
         $itemtypes = $itemtypes_affect;
     } else {
         if (count($itemtypes_affect) < count($itemtypes_unaffect)) {
             $normalized_action = 'unaffect';
             $itemtypes = $itemtypes_unaffect;
         } else {
             return parent::showMassiveActionsSubForm($ma);
         }
     }
     switch ($normalized_action) {
         case 'unaffect':
             foreach ($itemtypes as $itemtype => $specificities) {
                 if (Toolbox::is_a($itemtype, 'CommonDBRelation')) {
                     $peer_field = "peer[{$itemtype}]";
                     if (!$itemtype::$mustBeAttached_1 && !$itemtype::$mustBeAttached_2) {
                         // Should never occur ... But we must care !
                         $values = array();
                         if (empty($itemtype::$itemtype_1) || preg_match('/^itemtype/', $itemtype::$itemtype_1)) {
                             $values[0] = __('First Item');
                         } else {
                             $itemtype_1 = $itemtype::$itemtype_1;
                             $values[0] = $itemtype_1::getTypeName(Session::getPluralNumber());
                         }
                         if (empty($itemtype::$itemtype_2) || preg_match('/^itemtype/', $itemtype::$itemtype_2)) {
                             $values[1] = __('Second Item');
                         } else {
                             $itemtype_2 = $itemtype::$itemtype_2;
                             $values[1] = $itemtype_2::getTypeName(Session::getPluralNumber());
                         }
                         echo sprintf(__('Select a peer for %s:'), $itemtype::getTypeName());
                         Dropdown::showFromArray($peer_field, $values);
                         echo "<br>\n";
                     } else {
                         if (!$itemtype::$mustBeAttached_1) {
                             echo "<input type='hidden' name='{$peer_field}' value='0'>";
                         } else {
                             if (!$itemtype::$mustBeAttached_2) {
                                 echo "<input type='hidden' name='{$peer_field}' value='1'>";
                             }
                         }
                     }
                 }
             }
             echo "<br><br>" . Html::submit(_x('button', 'Dissociate'), array('name' => 'massiveaction'));
             return true;
         case 'affect':
             $peertypes = array();
             foreach ($itemtypes as $itemtype => $specificities) {
                 if (!$specificities['reaffect']) {
                     continue;
                 }
                 if (Toolbox::is_a($itemtype, 'CommonDBRelation')) {
                     if ($specificities['reaffect'] == 1) {
                         $peertype = $itemtype::$itemtype_1;
                     } else {
                         $peertype = $itemtype::$itemtype_2;
                     }
                 } else {
                     $peertype = $itemtype::$itemtype;
                 }
                 if (preg_match('/^itemtype/', $peertype)) {
                     $peertypes = array_merge($peertypes, $specificities['itemtypes']);
                 } else {
                     $peertypes[] = $peertype;
                 }
             }
             $peertypes = array_unique($peertypes);
             if (count($peertypes) == 0) {
                 echo __('Unable to reaffect given elements !');
                 exit;
             }
             $options = array();
             if (count($peertypes) == 1) {
//.........这里部分代码省略.........
开发者ID:remicollet,项目名称:glpi,代码行数:101,代码来源:commondbconnexity.class.php


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