本文整理汇总了PHP中Contract_Item::can方法的典型用法代码示例。如果您正苦于以下问题:PHP Contract_Item::can方法的具体用法?PHP Contract_Item::can怎么用?PHP Contract_Item::can使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contract_Item
的用法示例。
在下文中一共展示了Contract_Item::can方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
if ($contract->update($_POST)) {
Event::log($_POST["id"], "contracts", 4, "financial", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["additem"])) {
$contractitem->check(-1, 'w', $_POST);
if ($contractitem->add($_POST)) {
Event::log($_POST["contracts_id"], "contracts", 4, "financial", $_SESSION["glpiname"] . " " . $LANG['log'][32]);
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["deleteitem"])) {
if (count($_POST["item"])) {
foreach ($_POST["item"] as $key => $val) {
if ($contractitem->can($key, 'w')) {
$contractitem->delete(array('id' => $key));
}
}
}
Event::log($_POST["contracts_id"], "contracts", 4, "financial", $_SESSION["glpiname"] . " " . $LANG['log'][33]);
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_GET["deleteitem"])) {
$contractitem->check($_GET["id"], 'w');
if ($contractitem->delete($_GET)) {
Event::log($_GET["contracts_id"], "contracts", 4, "financial", $_SESSION["glpiname"] . " " . $LANG['log'][33]);
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["addcontractsupplier"])) {
示例2: foreach
case "add_contact":
if ($_POST["itemtype"] == 'Supplier') {
$contactsupplier = new Contact_Supplier();
foreach ($_POST["item"] as $key => $val) {
$input = array('suppliers_id' => $key, 'contacts_id' => $_POST['conID']);
if ($contactsupplier->can(-1, 'w', $input)) {
$contactsupplier->add($input);
}
}
}
break;
case "add_contract":
$contractitem = new Contract_Item();
foreach ($_POST["item"] as $key => $val) {
$input = array('itemtype' => $_POST["itemtype"], 'items_id' => $key, 'contracts_id' => $_POST['contracts_id']);
if ($contractitem->can(-1, 'w', $input)) {
$contractitem->add($input);
}
}
break;
case "add_enterprise":
if ($_POST["itemtype"] == 'Contact') {
$contactsupplier = new Contact_Supplier();
foreach ($_POST["item"] as $key => $val) {
$input = array('suppliers_id' => $_POST['entID'], 'contacts_id' => $key);
if ($contactsupplier->can(-1, 'w', $input)) {
$contactsupplier->add($input);
}
}
}
break;
示例3: doMassiveActions
/**
* Do the standard massive actions
*
* @since version 0.84
*
* This must not be overloaded in Class
* @param $input array of input datas
*
* @return an array of results (ok, ko, noright counts, may include REDIRECT field to set REDIRECT page)
**/
function doMassiveActions($input = array())
{
global $CFG_GLPI;
if (!isset($input["item"]) || count($input["item"]) == 0) {
return false;
}
$res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
switch ($input['action']) {
case 'add_document':
case 'remove_document':
$doc = new Document();
return $doc->doSpecificMassiveActions($input);
case "add_transfer_list":
if (!isset($_SESSION['glpitransfer_list'])) {
$_SESSION['glpitransfer_list'] = array();
}
if (!isset($_SESSION['glpitransfer_list'][$input["itemtype"]])) {
$_SESSION['glpitransfer_list'][$input["itemtype"]] = array();
}
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
$_SESSION['glpitransfer_list'][$input["itemtype"]][$key] = $key;
$res['ok']++;
}
}
$res['REDIRECT'] = $CFG_GLPI['root_doc'] . '/front/transfer.action.php';
break;
case "delete":
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'd')) {
if ($this->delete(array("id" => $key))) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
break;
case "purge":
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'd')) {
$force = 1;
// Only mark deletion for
if ($this->maybeDeleted() && $this->useDeletedToLockIfDynamic() && $this->isDynamic()) {
$force = 0;
}
if ($this->delete(array("id" => $key), $force)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
break;
case "restore":
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'd')) {
if ($this->restore(array("id" => $key))) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
break;
case "update":
$searchopt = Search::getCleanedOptions($input["itemtype"], 'w');
if (isset($searchopt[$input["id_field"]])) {
/// Infocoms case
if (!isPluginItemType($input["itemtype"]) && Search::isInfocomOption($input["itemtype"], $input["id_field"])) {
$ic = new Infocom();
$link_entity_type = -1;
/// Specific entity item
if ($searchopt[$input["id_field"]]["table"] == "glpi_suppliers") {
$ent = new Supplier();
if ($ent->getFromDB($input[$input["field"]])) {
$link_entity_type = $ent->fields["entities_id"];
}
//.........这里部分代码省略.........