Commit 51b425b8 authored by moyooo's avatar moyooo
Browse files

clean code / TODO

parent 23b6d60d
......@@ -38,8 +38,6 @@ include ('../inc/includes.php');
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
// TODO : check its validy regarding new MassiveAction system
if (isset($_POST["validatortype"])) {
switch ($_POST["validatortype"]){
case 'user' :
......
......@@ -678,9 +678,8 @@ class Bookmark extends CommonDBTM {
'height' => 200,
'specific_actions' => $maactions);
// TODO : is it normal that it is commented ?
// Html::showMassiveActions($massiveactionparams);
// No massive action on bottom
echo "<table class='tab_cadre_fixehov'>";
echo "<tr>";
echo "<th>".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand)."</th>";
......
......@@ -324,7 +324,6 @@ class Cartridge extends CommonDBChild {
static function getCount($tID, $alarm_threshold, $nohtml=0) {
global $DB;
/// TODO to be more useful permit to have several columns and display number in it
// Get total
$total = self::getTotalNumber($tID);
$out = "";
......@@ -380,7 +379,6 @@ class Cartridge extends CommonDBChild {
static function getCountForPrinter($pID, $nohtml=0) {
global $DB;
/// TODO to be more useful permit to have several columns and display number in it
// Get total
$total = self::getTotalNumberForPrinter($pID);
$out = "";
......
......@@ -46,45 +46,5 @@ class ChangeValidation extends CommonITILValidation {
static $rightname = 'changevalidation';
// static function alertValidation(Ticket $ticket, $type){
// global $CFG_GLPI;
//
// $status = Ticket::getClosedStatusArray();
// $closed = $status[0];
// $status = Ticket::getSolvedStatusArray();
// $solved = $status[0];
//
// $message = __("This ticket is waiting for approval, do you really want to resolve or close it?");
//
// switch($type){
// case 'ticket':
// Html::scriptStart();
// echo "$('[name=\"status\"]').change(function() {
// var status_ko = 0;
// var input_status = $(this).val();
// if(input_status != undefined){
// if ((input_status == ".$solved."
// || input_status == ".$closed.")
// && input_status != ".$ticket->fields['status']."){
// status_ko = 1;
// }
// }
// if (status_ko == 1 && '".$ticket->fields['global_validation']."' == 'waiting') {
// alert('".$message."');
// }
// });";
// echo Html::scriptEnd();
// break;
//
// case 'solution':
// if($ticket->fields['status'] != $solved
// && $ticket->fields['status'] != $closed
// && $ticket->fields['global_validation'] == 'waiting') {
// Html::displayTitle($CFG_GLPI['root_doc']."/pics/warning.png", $message, $message);
// }
// break;
// }
//
// }
}
?>
\ No newline at end of file
......@@ -605,30 +605,96 @@ abstract class CommonITILValidation extends CommonDBChild {
/**
* Form for Followup on Massive action
**/
// static function showFormMassiveAction() {
//
// global $CFG_GLPI;
//
// $types = array(0 => Dropdown::EMPTY_VALUE,
// 'user' => __('User'),
// 'group' => __('Group'));
//
// $rand = Dropdown::showFromArray("validatortype", $types);
//
// $paramsmassaction = array('validatortype' => '__VALUE__',
// 'entity' => $_SESSION['glpiactive_entity'],
// 'right' => array('validate_request', 'validate_incident'));
//
// Ajax::updateItemOnSelectEvent("dropdown_validatortype$rand", "show_massiveaction_field",
// $CFG_GLPI["root_doc"].
// "/ajax/dropdownMassiveActionAddValidator.php",
// $paramsmassaction);
//
// echo "<br><span id='show_massiveaction_field'>&nbsp;</span>\n";
//
// }
static function showFormMassiveAction() {
global $CFG_GLPI;
$types = array(0 => Dropdown::EMPTY_VALUE,
'user' => __('User'),
'group' => __('Group'));
$rand = Dropdown::showFromArray("validatortype", $types);
$paramsmassaction = array('validatortype' => '__VALUE__',
'entity' => $_SESSION['glpiactive_entity'],
'right' => array('validate_request', 'validate_incident'));
Ajax::updateItemOnSelectEvent("dropdown_validatortype$rand", "show_massiveaction_field",
$CFG_GLPI["root_doc"].
"/ajax/dropdownMassiveActionAddValidator.php",
$paramsmassaction);
echo "<br><span id='show_massiveaction_field'>&nbsp;</span>\n";
}
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma) {
switch ($ma->getAction()) {
case 'submit_validation' :
static::showFormMassiveAction();
return true;
}
return parent::showMassiveActionsSubForm($ma);
}
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item,
array $ids) {
switch ($ma->getAction()) {
case 'submit_validation' :
$input = $ma->getInput();
// print_r($input);exit();
$valid = new static();
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
$input2 = array(static::$items_id => $id,
'comment_submission' => $input['comment_submission']);
if ($valid->can(-1, CREATE, $input2)) {
$users = $input['users_id_validate'];
if (!is_array($users)) {
$users = array($users);
}
$ok = true;
foreach ($users as $user) {
$input2["users_id_validate"] = $user;
if (!$valid->add($input2)) {
$ok = false;
}
}
if ($ok) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
/**
* Print the validation list into item
*
......@@ -947,13 +1013,13 @@ abstract class CommonITILValidation extends CommonDBChild {
$tab[5]['field'] = 'validation_date';
$tab[5]['name'] = __('Approval date');
$tab[5]['datatype'] = 'datetime';
/*
$tab[6]['table'] = 'glpi_users';
$tab[6]['field'] = 'name';
$tab[6]['name'] = __('Approval requester');
$tab[6]['datatype'] = 'itemlink';
$tab[6]['right'] = array('create_incident_validation', 'create_request_validation');
*/
$tab[7]['table'] = 'glpi_users';
$tab[7]['field'] = 'name';
$tab[7]['linkfield'] = 'users_id_validate';
......
......@@ -81,67 +81,6 @@ class TicketValidation extends CommonITILValidation {
}
}
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma) {
switch ($ma->getAction()) {
case 'submit_validation' :
//TODO: this method has been updated by Moyo (r21827)
static::showFormMassiveAction();
return true;
}
return parent::showMassiveActionsSubForm($ma);
}
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item,
array $ids) {
switch ($ma->getAction()) {
case 'submit_validation' :
$input = $ma->getInput();
$valid = new self();
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
$input2 = array('tickets_id' => $id,
'comment_submission' => $input['comment_submission']);
if ($valid->can(-1, CREATE, $input2)) {
$users = $input['users_id_validate'];
foreach ($users as $user) {
$input2["users_id_validate"] = $user;
if ($valid->add($input2)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
/**
* @since version 0.85
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment