本文整理汇总了PHP中CommonDBTM::processMassiveActionsForOneItemtype方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::processMassiveActionsForOneItemtype方法的具体用法?PHP CommonDBTM::processMassiveActionsForOneItemtype怎么用?PHP CommonDBTM::processMassiveActionsForOneItemtype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::processMassiveActionsForOneItemtype方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
switch ($ma->getAction()) {
case 'duplicate':
$rulecollection = new RuleCollection();
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
if ($rulecollection->duplicateRule($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_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
break;
case 'export':
if (count($ids)) {
$_SESSION['exportitems'] = $ids;
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_OK);
$ma->setRedirect('rule.backup.php?action=download&itemtype=' . $item->getType());
}
break;
case 'move_rule':
$input = $ma->getInput();
$collectionname = $input['rule_class_name'] . 'Collection';
$rulecollection = new $collectionname();
if ($rulecollection->canUpdate()) {
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
if ($rulecollection->moveRule($id, $input['ranking'], $input['move_type'])) {
$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_NOT_FOUND));
}
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
break;
}
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 'force_user_ldap_update':
foreach ($ids as $id) {
if ($item->can($id, UPDATE)) {
if ($item->fields["authtype"] == Auth::LDAP || $item->fields["authtype"] == Auth::EXTERNAL) {
if (AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $item->fields["name"]), 1, $item->fields["auths_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_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 'change_authtype':
$input = $ma->getInput();
if (!isset($input["authtype"]) || !isset($input["auths_id"])) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
return;
}
if (Session::haveRight(self::$rightname, self::UPDATEAUTHENT)) {
if (User::changeAuthMethod($ids, $input["authtype"], $input["auths_id"])) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例3: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
$certif_item = new PluginCertificatesCertificate_Item();
switch ($ma->getAction()) {
case "plugin_certificates_add_item":
$input = $ma->getInput();
foreach ($ids as $id) {
$input = array('plugin_certificates_certificates_id' => $input['plugin_certificates_certificates_id'], 'items_id' => $id, 'itemtype' => $item->getType());
if ($certif_item->can(-1, UPDATE, $input)) {
if ($certif_item->add($input)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
}
return;
case "transfer":
$input = $ma->getInput();
if ($item->getType() == 'PluginCertificatesCertificate') {
foreach ($ids as $key) {
$item->getFromDB($key);
$type = PluginCertificatesCertificateType::transfer($item->fields["plugin_certificates_certificatetypes_id"], $input['entities_id']);
if ($type > 0) {
$values["id"] = $key;
$values["plugin_certificates_certificatetypes_id"] = $type;
$item->update($values);
}
$state = PluginCertificatesCertificateState::transfer($this->fields["plugin_certificates_certificatestates_id"], $input['entities_id']);
if ($state > 0) {
$values["id"] = $key;
$values["plugin_certificates_certificatestates_id"] = $state;
$item->update($values);
}
unset($values);
$values["id"] = $key;
$values["entities_id"] = $input['entities_id'];
if ($item->update($values)) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
}
}
}
return;
case 'install':
$input = $ma->getInput();
foreach ($ids as $key) {
if ($item->can($key, UPDATE)) {
$values = array('plugin_certificates_certificates_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
if ($certif_item->add($values)) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
return;
case 'uninstall':
$input = $ma->getInput();
foreach ($ids as $key) {
if ($val == 1) {
if ($certif_item->deleteItemByCertificatesAndItem($key, $input['item_item'], $input['typeitem'])) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
}
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例4: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
switch ($ma->getAction()) {
case 'move_bookmark':
$input = $ma->getInput();
if ($item->moveBookmark($ids, $input['bookmarks_id_ref'], $input['move_type'])) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例5: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'add_followup':
$input = $ma->getInput();
$fup = new self();
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
$input2 = array('tickets_id' => $id, 'is_private' => $input['is_private'], 'requesttypes_id' => $input['requesttypes_id'], 'content' => $input['content']);
if ($fup->can(-1, CREATE, $input2)) {
if ($fup->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));
}
}
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例6: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
switch ($ma->getAction()) {
case 'add_to_static_group':
if ($item->getType() == 'Computer') {
$group_item = new PluginFusioninventoryDeployGroup_Staticdata();
foreach ($ids as $id) {
//if ($group_item->can($id, UPDATE)) {
if (!countElementsInTable($group_item->getTable(), "`plugin_fusioninventory_deploygroups_id`='" . $_POST['plugin_fusioninventory_deploygroups_id'] . "'\n AND `itemtype`='Computer'\n AND `items_id`='{$id}'")) {
$values = array('plugin_fusioninventory_deploygroups_id' => $_POST['plugin_fusioninventory_deploygroups_id'], 'itemtype' => 'Computer', 'items_id' => $id);
$group_item->add($values);
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
}
//} else {
// $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
// $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
//}
}
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
}
示例7: 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);
}
示例8: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
* */
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
switch ($ma->getAction()) {
case "transfer":
$input = $ma->getInput();
if ($item->getType() == 'PluginTasklistsTask') {
foreach ($ids as $key) {
$item->getFromDB($key);
$type = PluginTasklistsTaskType::transfer($item->fields["plugin_tasklists_tasktypes_id"], $input['entities_id']);
if ($type > 0) {
$values["id"] = $key;
$values["plugin_tasklists_tasktypes_id"] = $type;
$item->update($values);
}
unset($values);
$values["id"] = $key;
$values["entities_id"] = $input['entities_id'];
if ($item->update($values)) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
}
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例9: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
$disposal = new PluginFinancialreportsDisposalItem();
switch ($ma->getAction()) {
case "plugin_financialreports_add_date_disposal":
$input = $ma->getInput();
foreach ($ids as $id) {
if ($disposal->addDateDisposal($id, $item->getType(), $input['date_disposal'])) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} 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)
{
if (!is_a($item, __CLASS__)) {
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
return;
}
$itemtype = $item->getType();
$specificities = $itemtype::getConnexityMassiveActionsSpecificities();
$action = $ma->getAction();
$input = $ma->getInput();
// First, get normalized action : affect or unaffect
if (in_array($action, $specificities['normalized']['affect'])) {
$normalized_action = 'affect';
} else {
if (in_array($action, $specificities['normalized']['unaffect'])) {
$normalized_action = 'unaffect';
} else {
// If we cannot get normalized action, then, its not for this method !
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
return;
}
}
switch ($normalized_action) {
case 'unaffect':
foreach ($ids as $key) {
if ($item->can($key, UPDATE)) {
if ($item instanceof CommonDBRelation) {
if (isset($input['peer'][$item->getType()])) {
if ($item->affectRelation($key, $input['peer'][$item->getType()])) {
$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_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
if ($item instanceof CommonDBChild) {
if ($item->affectChild($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 'affect':
if (!$specificities['reaffect']) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
return;
}
if (is_a($item, 'CommonDBRelation')) {
if ($specificities['reaffect'] == 1) {
$peertype = $itemtype::$itemtype_1;
$peers_id = $itemtype::$items_id_1;
} else {
$peertype = $itemtype::$itemtype_2;
$peers_id = $itemtype::$items_id_2;
}
} else {
$peertype = $itemtype::$itemtype;
$peers_id = $itemtype::$items_id;
}
$input2 = $itemtype::getConnexityInputForProcessingOfMassiveActions($action, $item, $ids, $input);
$input2[$peers_id] = $input['peers_id'];
if (preg_match('/^itemtype/', $peertype)) {
if (!in_array($input['peertype'], $specificities['itemtypes'])) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
return;
}
$input2[$peertype] = $input['peertype'];
} else {
if ($peertype != $input['peertype']) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
return;
}
}
foreach ($ids as $key) {
if (!$item->getFromDB($key)) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
continue;
}
if (preg_match('/^itemtype/', $peertype)) {
//.........这里部分代码省略.........
示例11: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
switch ($ma->getAction()) {
case 'DoIt':
if ($item->getType() == 'Computer') {
Session::addMessageAfterRedirect(__("Right it is the type I want...", 'example'));
Session::addMessageAfterRedirect(__('Write in item history', 'example'));
$changes = array(0, 'old value', 'new value');
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
Session::addMessageAfterRedirect("- " . $item->getField("name"));
Log::history($id, 'Computer', $changes, 'PluginExampleExample', Log::HISTORY_PLUGIN);
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
// Example of ko count
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
}
}
} else {
// When nothing is possible ...
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
return;
case 'do_nothing':
if ($item->getType() == 'PluginExampleExample') {
Session::addMessageAfterRedirect(__("Right it is the type I want...", 'example'));
Session::addMessageAfterRedirect(__("But... I say I will do nothing for:", 'example'));
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
Session::addMessageAfterRedirect("- " . $item->getField("name"));
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
// Example for noright / Maybe do it with can function is better
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
}
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例12: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
* */
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
switch ($ma->getAction()) {
case "transfer":
$input = $ma->getInput();
if ($item->getType() == 'PluginSimcardSimcard') {
foreach ($ids as $key) {
// Types
$item->getFromDB($key);
$type = PluginSimcardSimcardType::transfer($item->fields["plugin_simcard_simcardtypes_id"], $input['entities_id']);
if ($type > 0) {
$values["id"] = $key;
$values["plugin_simcard_simcardtypes_id"] = $type;
$item->update($values);
}
// Size
$size = PluginSimcardSimcardSize::transfer($item->fields["plugin_simcard_simcardsizes_id"], $input['entities_id']);
if ($size > 0) {
$values["id"] = $key;
$values["plugin_simcard_simcardsizes_id"] = $size;
$item->update($values);
}
// Voltage
$voltage = PluginSimcardSimcardVoltage::transfer($item->fields["plugin_simcard_simcardvoltages_id"], $input['entities_id']);
if ($voltage > 0) {
$values["id"] = $key;
$values["plugin_simcard_simcardvoltages_id"] = $voltage;
$item->update($values);
}
// Phoneoperator
$phoneoperator = PluginSimcardPhoneOperator::transfer($item->fields["plugin_simcard_phoneoperators_id"], $input['entities_id']);
if ($phoneoperator > 0) {
$values["id"] = $key;
$values["plugin_simcard_phoneoperators_id"] = $phoneoperator;
$item->update($values);
}
unset($values);
$values["id"] = $key;
$values["entities_id"] = $input['entities_id'];
if ($item->update($values)) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
}
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例13: processMassiveActionsForOneItemtype
/**
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'sendmail':
foreach ($ids as $id) {
if ($item->canEdit($id)) {
if ($item->sendMailById($id)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例14: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $CFG_GLPI;
$input = $ma->getInput();
switch ($ma->getAction()) {
case 'import_group':
$group = new Group();
if (!Session::haveRight("user", User::UPDATEAUTHENT) || !$group->canGlobal(UPDATE)) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
return;
}
foreach ($ids as $id) {
if (isset($input["dn"][$id])) {
$group_dn = $input["dn"][$id];
if (isset($input["ldap_import_entities"][$id])) {
$entity = $input["ldap_import_entities"][$id];
} else {
$entity = $_SESSION["glpiactive_entity"];
}
// Is recursive is in the main form and thus, don't pass through
// zero_on_empty mechanism inside massive action form ...
$is_recursive = empty($input['ldap_import_recursive'][$id]) ? 0 : 1;
$options = array('authldaps_id' => $_SESSION['ldap_server'], 'entities_id' => $entity, 'is_recursive' => $is_recursive, 'type' => $input['ldap_import_type'][$id]);
if (AuthLdap::ldapImportGroup($group_dn, $options)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION, $group_dn));
}
}
// Clean history as id does not correspond to group
$_SESSION['glpimassiveactionselected'] = array();
}
return;
case 'import':
case 'sync':
if (!Session::haveRight("user", User::IMPORTEXTAUTHUSERS)) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
return;
}
foreach ($ids as $id) {
if (AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $id), $_SESSION['ldap_import']['mode'], $_SESSION['ldap_import']['authldaps_id'], true)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION, $id));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例15: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'delete_email':
case 'import_email':
if (!$item->canUpdate()) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT);
} else {
$input = $ma->getInput();
if (count($ids)) {
$mailcollector = new MailCollector();
if ($ma->getAction() == 'delete_email') {
$mailcollector->deleteOrImportSeveralEmails($ids, 0);
} else {
$mailcollector->deleteOrImportSeveralEmails($ids, 1, $input['entities_id']);
}
}
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_OK);
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}