本文整理汇总了PHP中CommonDBChild类的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBChild类的具体用法?PHP CommonDBChild怎么用?PHP CommonDBChild使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommonDBChild类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareInputForUpdate
/**
* @see CommonDBChild::prepareInputForUpdate()
**/
function prepareInputForUpdate($input)
{
// TODO: Check because I replaced creation of a cloned infocom by $this
if (isset($input['warranty_duration'])) {
$input['_warranty_duration'] = $this->fields['warranty_duration'];
}
//Check if one or more dates needs to be updated
foreach (self::getAutoManagemendDatesFields() as $key => $field) {
$result = Entity::getUsedConfig($key, $this->fields['entities_id']);
//Only update date if it's empty in DB. Otherwise do nothing
if ($result > 0 && !isset($this->fields[$field])) {
self::autofillDates($input, $field, $result);
}
}
return parent::prepareInputForUpdate($input);
}
示例2: prepareInputForUpdate
/**
* @see CommonDBTM::prepareInputForUpdate()
**/
function prepareInputForUpdate($input)
{
if (empty($input['end_date']) || $input['end_date'] == 'NULL' || $input['end_date'] < $input['begin_date']) {
$input['end_date'] = $input['begin_date'];
}
return parent::prepareInputForUpdate($input);
}
示例3: getConnexityMassiveActionsSpecificities
/**
* @since version 0.85
*
* @see CommonDBConnexity::getConnexityMassiveActionsSpecificities()
**/
static function getConnexityMassiveActionsSpecificities()
{
$specificities = parent::getConnexityMassiveActionsSpecificities();
$specificities['reaffect'] = true;
$specificities['itemtypes'] = array('Computer', 'NetworkEquipment');
$specificities['normalized']['unaffect'] = array();
$specificities['action_name']['affect'] = _x('button', 'Move');
return $specificities;
}
示例4: doSpecificMassiveActions
/**
* @since version 0.84
*
* @see CommonDBTM::doSpecificMassiveActions()
**/
function doSpecificMassiveActions($input = array())
{
$res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
// print_r($input);exit();
switch ($input['action']) {
case "give":
if ($input["give_items_id"] > 0 && !empty($input['give_itemtype'])) {
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'w')) {
if ($this->out($key, $input['give_itemtype'], $input["give_items_id"])) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
if ($item = getItemForItemtype($input['give_itemtype'])) {
Event::log($input["consumableitems_id"], "consumables", 5, "inventory", sprintf(__('%s gives a consumable'), $_SESSION["glpiname"]));
}
} else {
$res['ko']++;
}
break;
default:
return parent::doSpecificMassiveActions($input);
}
return $res;
}
示例5: doSpecificMassiveActions
/**
* @see CommonDBTM::doSpecificMassiveActions()
**/
function doSpecificMassiveActions($input = array())
{
$res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
switch ($input['action']) {
case "assign_vlan":
if (!empty($input["vlans_id"])) {
$networkportvlan = new NetworkPort_Vlan();
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'w')) {
if ($networkportvlan->assignVlan($key, $input["vlans_id"], isset($input['tagged']) ? '1' : '0')) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
} else {
$res['ko']++;
}
break;
case "unassign_vlan":
if (!empty($input["vlans_id"])) {
$networkportvlan = new NetworkPort_Vlan();
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'w')) {
if ($networkportvlan->unassignVlan($key, $input["vlans_id"])) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
} else {
$nbko++;
}
break;
// Interest of this massive action ? Replace switch by another : don't re-create manually all ports
// Interest of this massive action ? Replace switch by another : don't re-create manually all ports
case "move_port":
if (isset($input["items_id"]) && !empty($input["items_id"])) {
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->getFromDB($key)) {
$input2 = array();
$input2['id'] = $key;
$input2['items_id'] = $input["items_id"];
$input2['itemtype'] = 'NetworkEquipment';
if ($this->can($input2['id'], 'w')) {
if ($this->update($input2)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
} else {
$res['ko']++;
}
}
}
} else {
$res['ko']++;
}
break;
default:
return parent::doSpecificMassiveActions($input);
}
return $res;
}
示例6: Calendar
function post_deleteFromDB()
{
// Update calendar cache
$cal = new Calendar();
$cal->updateDurationCache($this->fields['calendars_id']);
parent::post_deleteFromDB();
}
示例7: getSearchOptions
function getSearchOptions()
{
global $CFG_GLPI;
$tab = parent::getSearchOptions();
$optionIndex = 10;
// From 10 to 14
foreach (self::getMotives() as $motive => $name) {
$tab[$optionIndex]['table'] = $this->getTable();
$tab[$optionIndex]['field'] = $motive;
$tab[$optionIndex]['name'] = $name;
$tab[$optionIndex]['datatype'] = 'bool';
$optionIndex++;
}
$tab[20]['table'] = $this->getTable();
$tab[20]['field'] = 'ip';
$tab[20]['datatype'] = 'ip';
$tab[20]['name'] = IPAddress::getTypeName(1);
$tab[21]['table'] = $this->getTable();
$tab[21]['field'] = 'netmask';
$tab[21]['datatype'] = 'string';
$tab[21]['name'] = IPNetmask::getTypeName(1);
$tab[22]['table'] = $this->getTable();
$tab[22]['field'] = 'subnet';
$tab[22]['datatype'] = 'string';
$tab[22]['name'] = __('Network address');
$tab[23]['table'] = $this->getTable();
$tab[23]['field'] = 'gateway';
$tab[23]['datatype'] = 'string';
$tab[23]['name'] = IPAddress::getTypeName(1);
if (TableExists('glpi_networkinterfaces')) {
$tab[24]['table'] = 'glpi_networkinterfaces';
$tab[24]['field'] = 'name';
$tab[24]['datatype'] = 'dropdown';
$tab[24]['name'] = __('Network interface');
}
return $tab;
}
示例8: getForbiddenStandardMassiveAction
/**
* @since version 0.84
**/
function getForbiddenStandardMassiveAction()
{
$forbidden = parent::getForbiddenStandardMassiveAction();
$forbidden[] = 'update';
return $forbidden;
}
示例9: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'uninstall':
foreach ($ids as $key) {
if ($item->can($key, UPDATE)) {
if ($item->uninstall($key)) {
$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;
case 'backtostock':
foreach ($ids as $id) {
if ($item->can($id, UPDATE)) {
if ($item->backToStock(array("id" => $id))) {
$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 'updatepages':
$input = $ma->getInput();
if (isset($input['pages'])) {
foreach ($ids as $key) {
if ($item->can($key, UPDATE)) {
if ($item->update(array('id' => $key, 'pages' => $input['pages']))) {
$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));
}
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例10: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'activate':
$ic = new self();
if ($ic->canCreate()) {
$itemtype = $item->getType();
foreach ($ids as $key) {
if (!$ic->getFromDBforDevice($itemtype, $key)) {
$input = array('itemtype' => $itemtype, 'items_id' => $key);
if ($ic->can(-1, CREATE, $input)) {
if ($ic->add($input)) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($ic->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ic->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($ic->getErrorMessage(ERROR_NOT_FOUND));
}
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例11:
function post_deleteFromDB()
{
global $DB;
// if default is set : set default to another one
if ($this->fields["is_default"] == 1) {
$query = "UPDATE `" . $this->getTable() . "`\n SET `is_default` = '1'\n WHERE `id` <> '" . $this->fields['id'] . "'\n AND `users_id` = '" . $this->fields['users_id'] . "'\n LIMIT 1";
$DB->query($query);
}
parent::post_deleteFromDB();
}
示例12: prepareInputForAdd
function prepareInputForAdd($input)
{
// My preparation on $input
return parent::prepareInputForAdd($input);
}
示例13: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'backtostock':
foreach ($ids as $id) {
if ($item->can($id, UPDATE)) {
if ($item->backToStock(array("id" => $id))) {
$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 'give':
$input = $ma->getInput();
if ($input["give_items_id"] > 0 && !empty($input['give_itemtype'])) {
foreach ($ids as $key) {
if ($item->can($key, UPDATE)) {
if ($item->out($key, $input['give_itemtype'], $input["give_items_id"])) {
$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));
}
}
Event::log($item->fields['consumableitems_id'], "consumables", 5, "inventory", sprintf(__('%s gives a consumable'), $_SESSION["glpiname"]));
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例14: getRights
/**
* @see commonDBTM::getRights()
**/
function getRights($interface = 'central')
{
$values = parent::getRights();
unset($values[UPDATE], $values[READ]);
$values[self::VALIDATE] = __('Validate');
return $values;
}
示例15: doSpecificMassiveActions
/**
* @since version 0.84
*
* @see CommonDBTM::doSpecificMassiveActions()
**/
function doSpecificMassiveActions($input = array())
{
$res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
switch ($input['action']) {
case "uninstall":
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'w')) {
if ($this->uninstall($key)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
break;
case "updatepages":
if (isset($input['pages'])) {
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'w')) {
if ($this->update(array('id' => $key, 'pages' => $input['pages']))) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
} else {
$res['ko']++;
}
break;
default:
return parent::doSpecificMassiveActions($input);
}
return $res;
}