本文整理汇总了PHP中Document_Item::can方法的典型用法代码示例。如果您正苦于以下问题:PHP Document_Item::can方法的具体用法?PHP Document_Item::can怎么用?PHP Document_Item::can使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document_Item
的用法示例。
在下文中一共展示了Document_Item::can方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSpecificMassiveActions
/**
* @see CommonDBTM::doSpecificMassiveActions()
**/
function doSpecificMassiveActions($input = array())
{
$res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
switch ($input['action']) {
case "add_document":
case "add_document_item":
$documentitem = new Document_Item();
foreach ($input["item"] as $key => $val) {
if (isset($input['items_id'])) {
// Add items to documents
$input2 = array('itemtype' => $input["item_itemtype"], 'items_id' => $input["items_id"], 'documents_id' => $key);
} else {
if (isset($input['documents_id'])) {
// Add document to item
$input2 = array('itemtype' => $input["itemtype"], 'items_id' => $key, 'documents_id' => $input['documents_id']);
} else {
return false;
}
}
if ($documentitem->can(-1, 'w', $input2)) {
if ($documentitem->add($input2)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
break;
case "remove_document":
case "remove_document_item":
foreach ($input["item"] as $key => $val) {
if (isset($input['items_id'])) {
// Remove item to documents
$input2 = array('itemtype' => $input["item_itemtype"], 'items_id' => $input["items_id"], 'documents_id' => $key);
} else {
if (isset($input['documents_id'])) {
// Remove contract to items
$input2 = array('itemtype' => $input["itemtype"], 'items_id' => $key, 'documents_id' => $input['documents_id']);
} else {
return false;
}
}
$docitem = new Document_Item();
if ($docitem->can(-1, 'w', $input2)) {
if ($item = getItemForItemtype($input2["itemtype"])) {
if ($item->getFromDB($input2['items_id'])) {
$doc = new self();
if ($doc->getFromDB($input2['documents_id'])) {
if ($docitem->getFromDBForItems($doc, $item)) {
if ($docitem->delete(array('id' => $docitem->getID()))) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['ko']++;
}
} else {
$res['ko']++;
}
} else {
$res['ko']++;
}
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
break;
default:
return parent::doSpecificMassiveActions($input);
}
return $res;
}
示例2: foreach
$input['entities_id'] = $_POST['entities_id'];
$input['profiles_id'] = $_POST['profiles_id'];
$input['is_recursive'] = $_POST['is_recursive'];
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
$input['users_id'] = $key;
$right->add($input);
}
}
}
break;
case "add_document":
$documentitem = new Document_Item();
foreach ($_POST["item"] as $key => $val) {
$input = array('itemtype' => $_POST["itemtype"], 'items_id' => $key, 'documents_id' => $_POST['docID']);
if ($documentitem->can(-1, 'w', $input)) {
$documentitem->add($input);
}
}
break;
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;
示例3: foreach
if ($doc->update($_POST)) {
Event::log($_POST["id"], "documents", 4, "document", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["adddocumentitem"])) {
$documentitem->check(-1, 'w', $_POST);
if ($documentitem->add($_POST)) {
Event::log($_POST["documents_id"], "documents", 4, "document", $_SESSION["glpiname"] . " " . $LANG['log'][32]);
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["deletedocumentitem"])) {
if (isset($_POST["item"]) && count($_POST["item"])) {
foreach ($_POST["item"] as $key => $val) {
if ($documentitem->can($key, 'w')) {
$documentitem->delete(array('id' => $key));
}
}
}
Event::log($_POST["documents_id"], "documents", 4, "document", $_SESSION["glpiname"] . " " . $LANG['log'][33]);
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_GET["deletedocumentitem"]) && isset($_GET["documents_id"]) && isset($_GET["id"])) {
$documentitem->check($_GET["id"], 'w');
if ($documentitem->delete(array('id' => $_GET["id"]))) {
Event::log($_GET["documents_id"], "documents", 4, "document", $_SESSION["glpiname"] . " " . $LANG['log'][33]);
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
commonHeader($LANG['Menu'][27], $_SERVER['PHP_SELF'], "financial", "document");