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


PHP Lock::getMassiveActionsForItemtype方法代码示例

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


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

示例1: getAllMassiveActions

 /**
  * Get the standard massive actions
  *
  * @param $item                   the item for which we want the massive actions
  * @param $is_deleted             massive action for deleted items ?   (default 0)
  * @param $checkitem              link item to check right              (default NULL)
  *
  * @return an array of massive actions or false if $item is not valid
  **/
 static function getAllMassiveActions($item, $is_deleted = 0, CommonDBTM $checkitem = NULL)
 {
     global $CFG_GLPI, $PLUGIN_HOOKS;
     // TODO: when maybe* will be static, when can completely switch to $itemtype !
     if (is_string($item)) {
         $itemtype = $item;
         if (!($item = getItemForItemtype($itemtype))) {
             return false;
         }
     } else {
         if ($item instanceof CommonDBTM) {
             $itemtype = $item->getType();
         } else {
             return false;
         }
     }
     if (!is_null($checkitem)) {
         $canupdate = $checkitem->canUpdate();
         $candelete = $checkitem->canDelete();
         $canpurge = $checkitem->canPurge();
     } else {
         $canupdate = $itemtype::canUpdate();
         $candelete = $itemtype::canDelete();
         $canpurge = $itemtype::canPurge();
     }
     $actions = array();
     $self_pref = __CLASS__ . self::CLASS_ACTION_SEPARATOR;
     if ($is_deleted) {
         if ($canpurge) {
             if (in_array($itemtype, Item_Devices::getConcernedItems())) {
                 $actions[$self_pref . 'purge_item_but_devices'] = _x('button', 'Delete permanently but keep devices');
                 $actions[$self_pref . 'purge'] = _x('button', 'Delete permanently and remove devices');
             } else {
                 $actions[$self_pref . 'purge'] = _x('button', 'Delete permanently');
             }
             $actions[$self_pref . 'restore'] = _x('button', 'Restore');
         }
     } else {
         if ($_SESSION['glpiactiveprofile']['interface'] == 'central' && ($canupdate || InfoCom::canApplyOn($itemtype) && Infocom::canUpdate())) {
             //TRANS: select action 'update' (before doing it)
             $actions[$self_pref . 'update'] = _x('button', 'Update');
         }
         Infocom::getMassiveActionsForItemtype($actions, $itemtype, $is_deleted, $checkitem);
         CommonDBConnexity::getMassiveActionsForItemtype($actions, $itemtype, $is_deleted, $checkitem);
         // do not take into account is_deleted if items may be dynamic
         if ($item->maybeDeleted() && !$item->useDeletedToLockIfDynamic()) {
             if ($candelete) {
                 $actions[$self_pref . 'delete'] = _x('button', 'Put in dustbin');
             }
         } else {
             if ($canpurge) {
                 $actions[$self_pref . 'purge'] = _x('button', 'Delete permanently');
                 if ($item instanceof CommonDropdown) {
                     $actions[$self_pref . 'purge_but_item_linked'] = _x('button', 'Delete permanently even if linked items');
                 }
             }
         }
         Document::getMassiveActionsForItemtype($actions, $itemtype, $is_deleted, $checkitem);
         Contract::getMassiveActionsForItemtype($actions, $itemtype, $is_deleted, $checkitem);
         // Specific actions
         $actions += $item->getSpecificMassiveActions($checkitem);
         // Plugin Specific actions
         if (isset($PLUGIN_HOOKS['use_massive_action'])) {
             foreach ($PLUGIN_HOOKS['use_massive_action'] as $plugin => $val) {
                 $plug_actions = Plugin::doOneHook($plugin, 'MassiveActions', $itemtype);
                 if (count($plug_actions)) {
                     $actions += $plug_actions;
                 }
             }
         }
     }
     Lock::getMassiveActionsForItemtype($actions, $itemtype, $is_deleted, $checkitem);
     // Manage forbidden actions : try complete action name or MassiveAction:action_name
     $forbidden_actions = $item->getForbiddenStandardMassiveAction();
     if (is_array($forbidden_actions) && count($forbidden_actions)) {
         foreach ($forbidden_actions as $actiontodel) {
             if (isset($actions[$actiontodel])) {
                 unset($actions[$actiontodel]);
             } else {
                 // Not found search adding MassiveAction prefix
                 $actiontodel = $self_pref . $actiontodel;
                 if (isset($actions[$actiontodel])) {
                     unset($actions[$actiontodel]);
                 }
             }
         }
     }
     return $actions;
 }
开发者ID:kipman,项目名称:glpi,代码行数:98,代码来源:massiveaction.class.php


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