本文整理汇总了PHP中CommonDBTM::getForeignKeyField方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::getForeignKeyField方法的具体用法?PHP CommonDBTM::getForeignKeyField怎么用?PHP CommonDBTM::getForeignKeyField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::getForeignKeyField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
$input = $ma->getInput();
switch ($ma->getAction()) {
case 'move_under':
if (isset($input['parent'])) {
$fk = $item->getForeignKeyField();
$parent = clone $item;
if (!$parent->getFromDB($input['parent'])) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
$ma->addMessage($parent->getErrorMessage(ERROR_NOT_FOUND));
return;
}
foreach ($ids as $id) {
if ($item->can($id, UPDATE)) {
// Check if parent is not a child of the original one
if (!in_array($parent->getID(), getSonsOf($item->getTable(), $item->getID()))) {
if ($item->update(array('id' => $id, $fk => $parent->getID()))) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
$ma->addMessage($parent->getErrorMessage(ERROR_COMPAT));
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例2: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
switch ($ma->getAction()) {
case 'add_actor':
$input = $ma->getInput();
foreach ($ids as $id) {
$input2 = array('id' => $id);
if (isset($input['_itil_requester'])) {
$input2['_itil_requester'] = $input['_itil_requester'];
}
if (isset($input['_itil_observer'])) {
$input2['_itil_observer'] = $input['_itil_observer'];
}
if (isset($input['_itil_assign'])) {
$input2['_itil_assign'] = $input['_itil_assign'];
}
if ($item->can($id, UPDATE)) {
if ($item->update($input2)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
return;
case 'update_notif':
$input = $ma->getInput();
foreach ($ids as $id) {
if ($item->can($id, UPDATE)) {
$linkclass = new $item->userlinkclass();
foreach ($linkclass->getActors($id) as $type => $users) {
foreach ($users as $data) {
$data['use_notification'] = $input['use_notification'];
$linkclass->update($data);
}
}
$linkclass = new $this->supplierlinkclass();
foreach ($linkclass->getActors($id) as $type => $users) {
foreach ($users as $data) {
$data['use_notification'] = $input['use_notification'];
$linkclass->update($data);
}
}
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
return;
case 'add_task':
if (!($task = getItemForItemtype($item->getType() . 'Task'))) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
break;
}
$field = $item->getForeignKeyField();
$input = $ma->getInput();
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
$input2 = array($field => $id, 'taskcategories_id' => $input['taskcategories_id'], 'content' => $input['content']);
if ($task->can(-1, CREATE, $input2)) {
if ($task->add($input2)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例3: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'merge':
$fk = $item->getForeignKeyField();
foreach ($ids as $key) {
if ($item->can($key, UPDATE)) {
if ($item->getEntityID() == $_SESSION['glpiactive_entity']) {
if ($item->update(array('id' => $key, 'is_recursive' => 1))) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$input2 = $item->fields;
// Remove keys (and name, tree dropdown will use completename)
if ($item instanceof CommonTreeDropdown) {
unset($input2['id'], $input2['name'], $input2[$fk]);
} else {
unset($input2['id']);
}
// Change entity
$input2['entities_id'] = $_SESSION['glpiactive_entity'];
$input2['is_recursive'] = 1;
$input2 = Toolbox::addslashes_deep($input2);
// Import new
if ($newid = $item->import($input2)) {
// Delete old
if ($newid > 0) {
// delete with purge for dropdown with dustbin (Budget)
$item->delete(array('id' => $key, '_replace_by' => $newid), 1);
}
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}