當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Infocom::getMassiveActionsForItemtype方法代碼示例

本文整理匯總了PHP中Infocom::getMassiveActionsForItemtype方法的典型用法代碼示例。如果您正苦於以下問題:PHP Infocom::getMassiveActionsForItemtype方法的具體用法?PHP Infocom::getMassiveActionsForItemtype怎麽用?PHP Infocom::getMassiveActionsForItemtype使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Infocom的用法示例。


在下文中一共展示了Infocom::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


注:本文中的Infocom::getMassiveActionsForItemtype方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。