Ejemplo n.º 1
0
 /**
  * @since version 0.84
  *
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "delete_for_user":
             if (isset($input['users_id'])) {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         //Get software name and manufacturer
                         if ($input['users_id'] == Session::getLoginUserID()) {
                             //Process rules
                             if ($this->deleteByCriteria(array('users_id' => $input['users_id'], 'itemtype' => $key))) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             } else {
                 $res['ko']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 2
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case 'merge':
             $fk = $this->getForeignKeyField();
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'w')) {
                         if ($this->getEntityID() == $_SESSION['glpiactive_entity']) {
                             if ($this->update(array('id' => $key, 'is_recursive' => 1))) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $input2 = $this->fields;
                             // Remove keys (and name, tree dropdown will use completename)
                             if ($this 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 = $this->import($input2)) {
                                 // Delete old
                                 if ($newid > 0) {
                                     // delete with purge for dropdown with dustbin (Budget)
                                     $this->delete(array('id' => $key, '_replace_by' => $newid), 1);
                                 }
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 3
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "add_contact_supplier":
             $contactsupplier = new Contact_Supplier();
             return $contactsupplier->doSpecificMassiveActions($input);
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return false;
 }
Ejemplo n.º 4
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "mergesoftware":
             if (isset($input["id"]) && isset($input["item"]) && is_array($input["item"]) && count($input["item"])) {
                 if ($this->can($_POST["id"], 'w')) {
                     if ($this->merge($_POST["item"])) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 } else {
                     $res['noright']++;
                 }
             } else {
                 $res['ko']++;
             }
             break;
         case "compute_software_category":
             $softcatrule = new RuleSoftwareCategoryCollection();
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $params = array();
                     //Get software name and manufacturer
                     if ($this->can($key, 'w')) {
                         $params["name"] = $this->fields["name"];
                         $params["manufacturers_id"] = $this->fields["manufacturers_id"];
                         $params["comment"] = $this->fields["comment"];
                         $output = array();
                         $output = $softcatrule->processAllRules(null, $output, $params);
                         //Process rules
                         if (isset($output['softwarecategories_id']) && $this->update(array('id' => $key, 'softwarecategories_id' => $output['softwarecategories_id']))) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "replay_dictionnary":
             $softdictionnayrule = new RuleDictionnarySoftwareCollection();
             $ids = array();
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'w')) {
                         $ids[] = $key;
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             if ($softdictionnayrule->replayRulesOnExistingDB(0, 0, $ids) > 0) {
                 $res['ok'] += count($ids);
             } else {
                 $res['ko'] += count($ids);
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 5
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $projet_item = new PluginProjetProjet_Item();
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginProjetTask') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $this->getFromDB($key);
                         $tasktype = PluginProjetTaskType::transfer($this->fields["plugin_projet_tasktypes_id"], $input['entities_id']);
                         if ($tasktype > 0) {
                             $values["id"] = $key;
                             $values["plugin_projet_tasktypes_id"] = $tasktype;
                             $this->update($values);
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Duplicate":
             if ($input['itemtype'] == 'PluginProjetTask') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $this->getFromDB($key);
                         unset($this->fields["id"]);
                         $this->fields["name"] = addslashes($this->fields["name"]);
                         $this->fields["comment"] = addslashes($this->fields["comment"]);
                         $this->fields["sub"] = addslashes($this->fields["sub"]);
                         $this->fields["others"] = addslashes($this->fields["others"]);
                         $this->fields["affect"] = addslashes($this->fields["affect"]);
                         if ($this->add($this->fields)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Ejemplo n.º 6
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $resource_item = new PluginResourcesResource_Item();
     switch ($input['action']) {
         case "Send":
             if ($this->sendEmail($data)) {
                 $res['ok']++;
             } else {
                 $res['ko']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Ejemplo n.º 7
0
 /**
  * Do the specific massive actions
  *
  * @since version 0.84
  * 
  * @param $input array of input datas
  * 
  * @return an array of results (nbok, nbko, nbnoright counts)
  **/
 public function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $route_item = new PluginRoutetablesRoutetable_Item();
     switch ($input['action']) {
         case 'Duplicate':
             if ($input['itemtype'] == 'PluginRoutetablesRoutetable') {
                 foreach ($input['item'] as $key => $val) {
                     if ($val == 1) {
                         if ($this->getFromDB($key)) {
                             unset($this->fields["id"]);
                             $this->fields["entities_id"] = $input["entities_id"];
                             if ($newID = $this->add($this->fields)) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Install":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $values = array('plugin_routetables_routetables_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($route_item->can(-1, 'w', $input)) {
                         if ($route_item->add($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "Desinstall":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($route_item->deleteItemByRoutetablesAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         case "Transfert":
             if ($input['itemtype'] == 'PluginRoutetablesRoutetable') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Ejemplo n.º 8
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "add_actor":
             $item = new $input['itemtype']();
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $input2 = array('id' => $key);
                     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($key, 'w')) {
                         if ($item->update($input2)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "add_task":
             $taskitemtype = $_POST['itemtype'] . 'Task';
             if (!($task = getItemForItemtype($taskitemtype))) {
                 return false;
             }
             $field = $this->getForeignKeyField();
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $input2 = array($field => $key, 'taskcategories_id' => $input['taskcategories_id'], 'content' => $input['content']);
                     if ($task->can(-1, 'w', $input2)) {
                         if ($task->add($input2)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 9
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginBadgesBadge') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $badge = new PluginBadgesBadge();
                         $badge->getFromDB($key);
                         $type = PluginBadgesBadgeType::transfer($badge->fields["plugin_badges_badgetypes_id"], $input['entities_id']);
                         if ($type > 0) {
                             $values["id"] = $key;
                             $values["plugin_badges_badgetypes_id"] = $type;
                             if ($badge->update($values)) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($badge->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 10
0
 /**
  * @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;
 }
Ejemplo n.º 11
0
 /**
  * @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;
 }
Ejemplo n.º 12
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "connect":
             $ci = new Computer_Item();
             return $ci->doSpecificMassiveActions($input);
         case "install":
             if (isset($input['softwareversions_id']) && $input['softwareversions_id'] > 0) {
                 $inst = new Computer_SoftwareVersion();
                 foreach ($input['item'] as $key => $val) {
                     if ($val == 1) {
                         $input2 = array('computers_id' => $key, 'softwareversions_id' => $input['softwareversions_id']);
                         if ($inst->can(-1, 'w', $input2)) {
                             if ($inst->add($input2)) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             } else {
                 $res['ko']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 13
0
 /**
  * Do the specific massive actions
  *
  * @since version 0.84
  *
  * @param $input array of input datas
  *
  * @return an array of results (nbok, nbko, nbnoright counts)
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $criteria = new PluginTypologyTypologyCriteria();
     switch ($input['action']) {
         case "deleteAll":
             if ($input['itemtype'] == 'PluginTypologyTypologyCriteria') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($criteria->can($key, 'w')) {
                             if ($criteria->delete(array('id' => $key))) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         }
                     }
                 }
             }
             break;
         case "updateAll":
             if ($input['itemtype'] == 'PluginTypologyTypologyCriteria') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $values = array('id' => $key, 'is_active' => $input['is_active']);
                         if ($criteria->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 14
0
 /**
  * Do the specific massive actions
  *
  * @since version 0.84
  *
  * @param $input array of input datas
  *
  * @return an array of results (nbok, nbko, nbnoright counts)
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $criteria = new PluginTypologyTypologyCriteria();
     $definition = new PluginTypologyTypologyCriteriaDefinition();
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginTypologyTypology') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $this->getFromDB($key);
                         $restrict = "`plugin_typology_typologies_id` = '" . $key . "'";
                         $crits = getAllDatasFromTable("glpi_plugin_typology_typologycriterias", $restrict);
                         if (!empty($crits)) {
                             foreach ($crits as $crit) {
                                 $criteria->getFromDB($crit["id"]);
                                 $condition = "`plugin_typology_typologycriterias_id` = '" . $crit["id"] . "'";
                                 $defs = getAllDatasFromTable("glpi_plugin_typology_typologycriteriadefinitions", $condition);
                                 if (!empty($defs)) {
                                     foreach ($defs as $def) {
                                         $definition->getFromDB($def["id"]);
                                         unset($values);
                                         $values["id"] = $def["id"];
                                         $values["entities_id"] = $input['entities_id'];
                                         $definition->update($values);
                                     }
                                 }
                                 unset($values);
                                 $values["id"] = $crit["id"];
                                 $values["entities_id"] = $input['entities_id'];
                                 $criteria->update($values);
                             }
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Duplicate":
             if ($input['itemtype'] == 'PluginTypologyTypology') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $this->getFromDB($key);
                         $restrict = "`plugin_typology_typologies_id` = '" . $key . "'";
                         $crits = getAllDatasFromTable("glpi_plugin_typology_typologycriterias", $restrict);
                         unset($this->fields["id"]);
                         $this->fields["name"] = addslashes($this->fields["name"] . " Copy");
                         $this->fields["comment"] = addslashes($this->fields["comment"]);
                         $this->fields["notepad"] = addslashes($this->fields["notepad"]);
                         $newIDtypo = $this->add($this->fields);
                         if ($newIDtypo) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                         if (!empty($crits)) {
                             foreach ($crits as $crit) {
                                 $criteria->getFromDB($crit["id"]);
                                 $condition = "`plugin_typology_typologycriterias_id` = '" . $crit["id"] . "'";
                                 $defs = getAllDatasFromTable("glpi_plugin_typology_typologycriteriadefinitions", $condition);
                                 unset($criteria->fields["id"]);
                                 $criteria->fields["name"] = addslashes($criteria->fields["name"]);
                                 $criteria->fields["plugin_typology_typologies_id"] = $newIDtypo;
                                 $criteria->fields["itemtype"] = addslashes($criteria->fields["itemtype"]);
                                 $newIDcrit = $criteria->add($criteria->fields);
                                 if (!empty($defs)) {
                                     foreach ($defs as $def) {
                                         $definition->getFromDB($def["id"]);
                                         unset($definition->fields["id"]);
                                         $definition->fields["plugin_typology_typologycriterias_id"] = $newIDcrit;
                                         $definition->fields["field"] = addslashes($definition->fields["field"]);
                                         $definition->fields["action_type"] = addslashes($definition->fields["action_type"]);
                                         $definition->fields["value"] = addslashes($definition->fields["value"]);
                                         $definition->add($definition->fields);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 15
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $resource_item = new PluginResourcesResource_Item();
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginResourcesResource') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $this->getFromDB($key);
                         $contracttype = PluginResourcesContractType::transfer($PluginResourcesResource->fields["plugin_resources_contracttypes_id"], $input['entities_id']);
                         if ($contracttype > 0) {
                             $values["id"] = $key;
                             $values["plugin_resources_contracttypes_id"] = $contracttype;
                             $this->update($values);
                         }
                         unset($values);
                         $resourcestate = PluginResourcesResourceState::transfer($PluginResourcesResource->fields["plugin_resources_resourcestates_id"], $input['entities_id']);
                         if ($resourcestate > 0) {
                             $values["id"] = $key;
                             $values["plugin_resources_resourcestates_id"] = $resourcestate;
                             $this->update($values);
                         }
                         unset($values);
                         $department = PluginResourcesDepartment::transfer($PluginResourcesResource->fields["plugin_resources_departments_id"], $input['entities_id']);
                         if ($department > 0) {
                             $values["id"] = $key;
                             $values["plugin_resources_departments_id"] = $department;
                             $this->update($values);
                         }
                         unset($values);
                         $situation = PluginResourcesResourceSituation::transfer($PluginResourcesResource->fields["plugin_resources_resourcesituations_id"], $input['entities_id']);
                         if ($situation > 0) {
                             $values["id"] = $key;
                             $values["plugin_resources_resourcesituations_id"] = $situation;
                             $this->update($values);
                         }
                         unset($values);
                         $contractnature = PluginResourcesContractNature::transfer($PluginResourcesResource->fields["plugin_resources_contractnatures_id"], $input['entities_id']);
                         if ($contractnature > 0) {
                             $values["id"] = $key;
                             $values["plugin_resources_contractnatures_id"] = $contractnature;
                             $this->update($values);
                         }
                         unset($values);
                         $rank = PluginResourcesRank::transfer($PluginResourcesResource->fields["plugin_resources_ranks_id"], $input['entities_id']);
                         if ($rank > 0) {
                             $values["id"] = $key;
                             $values["plugin_resources_ranks_id"] = $rank;
                             $this->update($values);
                         }
                         unset($values);
                         $speciality = PluginResourcesResourceSpeciality::transfer($PluginResourcesResource->fields["plugin_resources_resourcespecialities_id"], $input['entities_id']);
                         if ($speciality > 0) {
                             $values["id"] = $key;
                             $values["plugin_resources_resourcespecialities_id"] = $speciality;
                             $this->update($values);
                         }
                         unset($values);
                         $PluginResourcesTask = new PluginResourcesTask();
                         $restrict = "`plugin_resources_resources_id` = '" . $key . "'";
                         $tasks = getAllDatasFromTable("glpi_plugin_resources_tasks", $restrict);
                         if (!empty($tasks)) {
                             foreach ($tasks as $task) {
                                 $PluginResourcesTask->getFromDB($task["id"]);
                                 $tasktype = PluginResourcesTaskType::transfer($PluginResourcesTask->fields["plugin_resources_tasktypes_id"], $input['entities_id']);
                                 if ($tasktype > 0) {
                                     $values["id"] = $task["id"];
                                     $values["plugin_resources_tasktypes_id"] = $tasktype;
                                     $PluginResourcesTask->update($values);
                                 }
                                 $values["id"] = $task["id"];
                                 $values["entities_id"] = $input['entities_id'];
                                 $PluginResourcesTask->update($values);
                             }
                         }
                         unset($values);
                         $PluginResourcesEmployment = new PluginResourcesEmployment();
                         $restrict = "`plugin_resources_resources_id` = '" . $key . "'";
                         $employments = getAllDatasFromTable("glpi_plugin_resources_employments", $restrict);
                         if (!empty($employments)) {
                             foreach ($employments as $employment) {
                                 $PluginResourcesEmployment->getFromDB($employment["id"]);
                                 $rank = PluginResourcesRank::transfer($PluginResourcesEmployment->fields["plugin_resources_ranks_id"], $input['entities_id']);
                                 if ($rank > 0) {
                                     $values["id"] = $employment["id"];
                                     $values["plugin_resources_ranks_id"] = $rank;
                                     $PluginResourcesEmployment->update($values);
                                 }
                                 $PluginResourcesEmployment->getFromDB($employment["id"]);
                                 $profession = PluginResourcesProfession::transfer($PluginResourcesEmployment->fields["plugin_resources_professions_id"], $input['entities_id']);
                                 if ($profession > 0) {
                                     $values["id"] = $employment["id"];
                                     $values["plugin_resources_professions_id"] = $profession;
                                     $PluginResourcesEmployment->update($values);
                                 }
                                 $values["id"] = $employment["id"];
                                 $values["entities_id"] = $input['entities_id'];
                                 $PluginResourcesEmployment->update($values);
                             }
                         }
                         unset($values);
                         $PluginResourcesEmployee = new PluginResourcesEmployee();
                         $restrict = "`plugin_resources_resources_id` = '" . $key . "'";
                         $employees = getAllDatasFromTable("glpi_plugin_resources_employees", $restrict);
                         if (!empty($employees)) {
                             foreach ($employees as $employee) {
                                 $employer = PluginResourcesEmployer::transfer($employee["plugin_resources_employers_id"], $input['entities_id']);
                                 if ($employer > 0) {
                                     $values["id"] = $employee["id"];
                                     $values["plugin_resources_employers_id"] = $employer;
                                     $PluginResourcesEmployee->update($values);
                                 }
                                 $client = PluginResourcesClient::transfer($employee["plugin_resources_clients_id"], $input['entities_id']);
                                 if ($client > 0) {
                                     $values["id"] = $employee["id"];
                                     $values["plugin_resources_clients_id"] = $client;
                                     $PluginResourcesEmployee->update($values);
                                 }
                             }
                         }
                         unset($values);
                         $query = "UPDATE `glpi_plugin_resources_checklists`\n                        SET `entities_id` = '" . $input['entities_id'] . "'\n                        WHERE `plugin_resources_resources_id` ='{$key}'";
                         $DB->query($query);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Install":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $values = array('plugin_resources_resources_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($resource_item->add($values)) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         case "Desinstall":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($resource_item->deleteItemByResourcesAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         case "Send":
             if ($this->sendEmail($input)) {
                 $res['ok']++;
             } else {
                 $res['ko']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Ejemplo n.º 16
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $projet_item = new PluginProjetProjet_Item();
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginProjetProjet') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $PluginProjetTask = new PluginProjetTask();
                         $restrict = "`plugin_projet_projets_id` = '" . $key . "'";
                         $tasks = getAllDatasFromTable("glpi_plugin_projet_tasks");
                         if (!empty($tasks)) {
                             foreach ($tasks as $task) {
                                 $PluginProjetTask->getFromDB($task["id"]);
                                 $tasktype = PluginProjetTaskType::transfer($PluginProjetTask->fields["plugin_projet_tasktypes_id"], $input['entities_id']);
                                 if ($tasktype > 0) {
                                     $values["id"] = $task["id"];
                                     $values["plugin_projet_tasktypes_id"] = $tasktype;
                                     $PluginProjetTask->update($values);
                                 }
                                 $values["id"] = $task["id"];
                                 $values["entities_id"] = $input['entities_id'];
                                 $PluginProjetTask->update($values);
                             }
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Install":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $values = array('plugin_projet_projets_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($projet_item->add($values)) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         case "Desinstall":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($projet_item->deleteItemByProjetAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Ejemplo n.º 17
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "move_rule":
             $collectionname = $input['itemtype'] . 'Collection';
             $rulecollection = new $collectionname();
             if ($rulecollection->canUpdate()) {
                 foreach ($input["item"] as $key => $val) {
                     if ($this->getFromDB($key)) {
                         if ($rulecollection->moveRule($key, $input['ranking'], $input['move_type'])) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['ko']++;
                     }
                 }
             } else {
                 $res['noright']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 18
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     $itemtype = $ma->getItemtype(false);
     $item = new PluginConsumablesRequest();
     $validation = new PluginConsumablesValidation();
     $consumable = new Consumable();
     $input = $ma->getInput();
     if (count($ids)) {
         switch ($ma->getAction()) {
             case "validate":
                 foreach ($ids as $key => $val) {
                     if ($item->can($key, UPDATE)) {
                         $item->getFromDB($key);
                         // Get available consumables
                         $outConsumable = array();
                         $availables = $consumable->find("`consumableitems_id` = '" . $item->fields['consumables_id'] . "' AND `items_id` = 0");
                         foreach ($availables as $available) {
                             $outConsumable[] = $available;
                         }
                         // Check if enough stock
                         if (!empty($outConsumable) && count($outConsumable) >= $item->fields['number']) {
                             // Give consumable
                             $result = array(1);
                             for ($i = 0; $i < $item->fields['number']; $i++) {
                                 if (isset($outConsumable[$i]) && $consumable->out($outConsumable[$i]['id'], $item->fields['give_itemtype'], $item->fields['give_items_id'])) {
                                     $result[] = 1;
                                 } else {
                                     $result[] = 0;
                                 }
                             }
                             if (!in_array(0, $result)) {
                                 // Validation status update
                                 $validation->validationConsumable($item->fields, CommonITILValidation::ACCEPTED);
                                 // Send notification
                                 NotificationEvent::raiseEvent(PluginConsumablesNotificationTargetRequest::CONSUMABLE_RESPONSE, $item, array('entities_id' => $_SESSION['glpiactive_entity'], 'consumablerequest' => $item->fields, 'comment' => $input['comment']));
                                 $ma->addMessage("<span style='color:green'>" . sprintf(__('Consumable %s validated', 'consumables'), Dropdown::getDropdownName("glpi_consumableitems", $item->fields['consumables_id'])) . "</span>");
                                 $ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_OK);
                             } else {
                                 $ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_KO);
                             }
                         } else {
                             $ma->addMessage(sprintf(__('Not enough stock for consumable %s', 'consumables'), Dropdown::getDropdownName("glpi_consumableitems", $item->fields['consumables_id'])));
                             $ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_KO);
                         }
                     } else {
                         $ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($validation->getErrorMessage(ERROR_RIGHT));
                     }
                 }
                 break;
             case "refuse":
                 foreach ($ids as $key => $val) {
                     if ($item->can($key, UPDATE)) {
                         // Validation status update
                         if ($validation->validationConsumable($item->fields, CommonITILValidation::REFUSED)) {
                             // Send notification
                             NotificationEvent::raiseEvent(PluginConsumablesNotificationTargetRequest::CONSUMABLE_RESPONSE, $item, array('entities_id' => $_SESSION['glpiactive_entity'], 'consumablerequest' => $item->fields, 'comment' => $input['comment']));
                             $ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_OK);
                             $ma->addMessage(__('Consumable refused', 'consumables'));
                         } else {
                             $ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_KO);
                         }
                     } else {
                         $ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($validation->getErrorMessage(ERROR_RIGHT));
                     }
                 }
                 break;
             default:
                 return parent::doSpecificMassiveActions($ma->POST);
         }
     }
 }
Ejemplo n.º 19
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $task_item = new PluginResourcesTask_Item();
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginResourcesEmployment') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Generate_Rule":
             if ($input['itemtype'] == 'PluginResourcesChecklistconfig') {
                 $this->addRulesFromChecklists($input);
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "deletevisibility":
             foreach ($input['item'] as $type => $items) {
                 if (in_array($type, array('PluginMonitoringDisplayview_Group', 'PluginMonitoringDisplayview_User'))) {
                     $item = new $type();
                     foreach ($items as $key => $val) {
                         if ($item->can($key, PURGE)) {
                             if ($item->delete(array('id' => $key))) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 21
0
 /**
  * @since version 0.84
  *
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     global $CFG_GLPI;
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "import":
         case "sync":
             if (!Session::haveRight("import_externalauth_users", 'w')) {
                 $res['nbnoright']++;
             } else {
                 if (isset($_GET['multiple_actions']) && isset($_SESSION["glpi_massiveaction"])) {
                     if ($count = count($input["item"])) {
                         $i = $input["ldap_process_count"] - $count + 1;
                         Html::createProgressBar();
                         Html::changeProgressBarPosition($i, $input["ldap_process_count"], sprintf(__('%1$s/%2$s'), $i, $input["ldap_process_count"]));
                         $key = key($input["item"]);
                         unset($input["item"][$key]);
                         if (AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $key), $input["mode"], $input["authldaps_id"], true)) {
                             $input['res']['ok']++;
                         } else {
                             $input['res']['ko']++;
                         }
                         if (count($input["item"])) {
                             // more to do -> redirect
                             $_SESSION['glpi_massiveaction']['POST'] = $input;
                             Html::redirect($CFG_GLPI['root_doc'] . '/front/massiveaction.php?multiple_actions=1');
                         } else {
                             // Nothing to do redirect
                             Html::changeProgressBarPosition(100, 100, __('Successful importation'));
                             $res = $input['res'];
                             $_SESSION['ldap_import']['action'] = 'show';
                         }
                     }
                 } else {
                     if (count($input['item']) > 0) {
                         $input["ldap_process_count"] = 0;
                         $input["authldaps_id"] = $_SESSION['ldap_import']['authldaps_id'];
                         $input["mode"] = $_SESSION['ldap_import']['mode'];
                         $input['res'] = array('ok' => 0, 'ko' => 0, 'noright' => 0);
                         foreach ($input['item'] as $key => $val) {
                             if ($val) {
                                 $input["ldap_process_count"]++;
                             }
                         }
                         $_SESSION['glpi_massiveaction']['POST'] = $input;
                         Html::redirect($CFG_GLPI['root_doc'] . '/front/massiveaction.php?multiple_actions=1');
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             $res['REDIRECT'] = $CFG_GLPI['root_doc'] . "/front/ldap.import.php";
             break;
         case "import_group":
             $group = new Group();
             if (!Session::haveRight("user_authtype", 'w') || !$group->canGlobal('w')) {
                 $res['nbnoright']++;
             } else {
                 if (isset($_GET['multiple_actions']) && isset($_SESSION["glpi_massiveaction"])) {
                     if ($count = count($input["item"])) {
                         $i = $input["ldap_process_count"] - $count + 1;
                         Html::createProgressBar();
                         Html::changeProgressBarPosition($i, $input["ldap_process_count"], sprintf(__('%1$s/%2$s'), $i, $input["ldap_process_count"]));
                         $key = key($input["item"]);
                         unset($input["item"][$key]);
                         if (isset($input["ldap_import_entities"][$key])) {
                             $entity = $input["ldap_import_entities"][$key];
                         } else {
                             $entity = $_SESSION["glpiactive_entity"];
                         }
                         if (AuthLdap::ldapImportGroup($key, array("authldaps_id" => $input["authldaps_id"], "entities_id" => $entity, "is_recursive" => $input["ldap_import_recursive"][$key], "type" => $input["ldap_import_type"][$key]))) {
                             $input['res']['ok']++;
                         } else {
                             $input['res']['ko']++;
                         }
                         if (count($input["item"])) {
                             // more to do -> redirect
                             $_SESSION['glpi_massiveaction']['POST'] = $input;
                             Html::redirect($CFG_GLPI['root_doc'] . '/front/massiveaction.php?multiple_actions=1');
                         } else {
                             // Nothing to do redirect
                             Html::changeProgressBarPosition(100, 100, __('Successful importation'));
                             $res = $input['res'];
                             $_SESSION['ldap_import']['action'] = 'show';
                         }
                     }
                 } else {
                     if (count($input['item']) > 0) {
                         $input["ldap_process_count"] = 0;
                         $input["authldaps_id"] = $_SESSION['ldap_server'];
                         $input['res'] = array('ok' => 0, 'ko' => 0, 'noright' => 0);
                         foreach ($input['item'] as $key => $val) {
                             if ($val) {
                                 $input["ldap_process_count"]++;
                                 $input["ldap_import_entities"][$key] = $input["ldap_import_entities"][$key];
                                 $input["ldap_import_type"][$key] = $input["ldap_import_type"][$key];
                                 $input["ldap_import_recursive"][$key] = $input["ldap_import_recursive"][$key];
                             }
                         }
                         $_SESSION['glpi_massiveaction']['POST'] = $input;
                         Html::redirect($CFG_GLPI['root_doc'] . '/front/massiveaction.php?multiple_actions=1');
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             $res['REDIRECT'] = $CFG_GLPI['root_doc'] . "/front/ldap.group.import.php";
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 22
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $database_item = new PluginDatabasesDatabase_Item();
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginDatabasesDatabase') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $this->getFromDB($key);
                         $type = PluginDatabasesDatabaseType::transfer($this->fields["plugin_databases_databasetypes_id"], $input['entities_id']);
                         if ($type > 0) {
                             $values["id"] = $key;
                             $values["plugin_databases_databasetypes_id"] = $type;
                             if ($this->update($values)) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Install":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $values = array('plugin_databases_databases_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($database_item->add($values)) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         case "Desinstall":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($database_item->deleteItemByDatabasesAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Ejemplo n.º 23
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "connect":
         case "disconnect":
             $ci = new Computer_Item();
             return $ci->doSpecificMassiveActions($input);
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 24
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case 'delete_email':
         case 'import_email':
             if (!static::canCreate()) {
                 $res['noright']++;
             } else {
                 $emails_ids = array();
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $emails_ids[$key] = $key;
                     }
                 }
                 if (count($emails_ids)) {
                     $mailcollector = new MailCollector();
                     if ($input["action"] == 'delete_email') {
                         $mailcollector->deleteOrImportSeveralEmails($emails_ids, 0);
                     } else {
                         $mailcollector->deleteOrImportSeveralEmails($emails_ids, 1, $input['entities_id']);
                     }
                 }
                 $res['ok']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 25
0
 /**
  * @since version 0.84
  *
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "deletevisibility":
             foreach ($input['item'] as $type => $items) {
                 if (in_array($type, array('Entity_Reminder', 'Group_Reminder', 'Profile_Reminder', 'Reminder_User'))) {
                     $item = new $type();
                     foreach ($items as $key => $val) {
                         if ($item->can($key, 'w')) {
                             if ($item->delete(array('id' => $key))) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 26
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case 'reset':
             if (Session::haveRight('config', 'w')) {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1 && $this->getFromDB($key)) {
                         if ($this->resetDate()) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['ko']++;
                     }
                 }
             } else {
                 $res['noright']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 27
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $task_item = new PluginResourcesTask_Item();
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginResourcesTask') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $this->getFromDB($key);
                         $tasktype = PluginResourcesTaskType::transfer($PluginResourcesTask->fields["plugin_resources_tasktypes_id"], $input['entities_id']);
                         if ($tasktype > 0) {
                             $values["id"] = $key;
                             $values["plugin_resources_tasktypes_id"] = $tasktype;
                             $PluginResourcesTask->update($values);
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Duplicate":
             if ($input['itemtype'] == 'PluginResourcesTask') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $this->getFromDB($key);
                         unset($this->fields["id"]);
                         $this->fields["name"] = addslashes($this->fields["name"]);
                         $this->fields["comment"] = addslashes($this->fields["comment"]);
                         if ($this->add($this->fields)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Install":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $values = array('plugin_resources_tasks_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($task_item->add($values)) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         case "Desinstall":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($task_item->deleteItemByTaskAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Ejemplo n.º 28
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "Transfert":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($this->update($values)) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Ejemplo n.º 29
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "add_user_group":
             $gu = new Group_User();
             return $gu->doSpecificMassiveActions($input);
         case "force_user_ldap_update":
             if (Session::haveRight("user", "w")) {
                 $ids = array();
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($this->getFromDB($key)) {
                             if ($this->fields["authtype"] == Auth::LDAP || $this->fields["authtype"] == Auth::EXTERNAL) {
                                 if (AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $this->fields["name"]), 1, $this->fields["auths_id"])) {
                                     $res['ok']++;
                                 } else {
                                     $res['ko']++;
                                 }
                             }
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             } else {
                 $res['noright']++;
             }
             break;
         case "change_authtype":
             if (!isset($input["authtype"]) || !isset($input["auths_id"])) {
                 return false;
             }
             if (Session::haveRight("user_authtype", "w")) {
                 $ids = array();
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $ids[] = $key;
                     }
                 }
                 if (User::changeAuthMethod($ids, $input["authtype"], $input["auths_id"])) {
                     $res['ok']++;
                 } else {
                     $res['ko']++;
                 }
             } else {
                 $res['noright']++;
             }
             break;
         case "add_userprofile":
             $right = new Profile_User();
             if (isset($input['profiles_id']) && $input['profiles_id'] > 0 && isset($input['entities_id']) && $input['entities_id'] >= 0) {
                 $input2 = array();
                 $input2['entities_id'] = $input['entities_id'];
                 $input2['profiles_id'] = $input['profiles_id'];
                 $input2['is_recursive'] = $input['is_recursive'];
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $input2['users_id'] = $key;
                         if ($right->can(-1, 'w', $input2)) {
                             if ($right->add($input2)) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Ejemplo n.º 30
0
 /**
  * Do the specific massive actions
  *
  * @since version 0.84
  * 
  * @param $input array of input datas
  * 
  * @return an array of results (nbok, nbko, nbnoright counts)
  **/
 public function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $command_item = new PluginShellcommandsShellcommand_Item();
     switch ($input['action']) {
         case "InstallTEST":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($command_item->addItem($key, $input['item_item'])) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         case "Desinstall":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($command_item->deleteItemByShellCommandsAndItem($key, $input['item_item'])) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }