Beispiel #1
0
 /**
  * @since version 0.90
  *
  * @param $rand
  **/
 function showTimelineForm($rand)
 {
     global $CFG_GLPI;
     //check global rights
     if (!Session::haveRight("ticket", Ticket::READMY) && !Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE))) {
         return false;
     }
     // javascript function for add and edit items
     echo "<script type='text/javascript' >\n";
     echo "function viewAddSubitem" . $this->fields['id'] . "{$rand}(itemtype) {\n";
     $params = array('action' => 'viewsubitem', 'type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $this->fields['id'], 'id' => -1);
     if (isset($_GET['load_kb_sol'])) {
         $params['load_kb_sol'] = $_GET['load_kb_sol'];
     }
     $out = Ajax::updateItemJsCode("viewitem" . $this->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/timeline.php", $params, "", false);
     echo str_replace("\"itemtype\"", "itemtype", $out);
     echo "\$('#approbation_form{$rand}').remove()";
     echo "};";
     echo "\n\n      function change_task_state(tasks_id, target) {\n         \$.post('" . $CFG_GLPI["root_doc"] . "/ajax/timeline.php',\n                {'action':     'change_task_state',\n                  'tasks_id':   tasks_id,\n                  'tickets_id': " . $this->fields['id'] . "\n                })\n                .done(function(new_state) {\n                  \$(target).removeClass('state_1 state_2')\n                           .addClass('state_'+new_state);\n                });\n      }\n\n      function viewEditSubitem" . $this->fields['id'] . "{$rand}(e, itemtype, items_id, o, domid) {\n               domid = (typeof domid === 'undefined')\n                         ? 'viewitem" . $this->fields['id'] . $rand . "'\n                         : domid;\n               var target = e.target || window.event.srcElement;\n               if (target.nodeName == 'a') return;\n               if (target.className == 'read_more_button') return;\n               \$('#'+domid).addClass('edited');\n               \$('#'+domid+' .displayed_content').hide();\n               \$('#'+domid+' .cancel_edit_item_content').show()\n                                                        .click(function() {\n                                                            \$(this).hide();\n                                                            \$('#'+domid).removeClass('edited');\n                                                            \$('#'+domid+' .edit_item_content').empty().hide();\n                                                            \$('#'+domid+' .displayed_content').show();\n                                                        });\n               \$('#'+domid+' .edit_item_content').show()\n                                                 .load('" . $CFG_GLPI["root_doc"] . "/ajax/timeline.php',\n                                                       {'action'    : 'viewsubitem',\n                                                        'type'      : itemtype,\n                                                        'parenttype': 'Ticket',\n                                                        'tickets_id': " . $this->fields['id'] . ",\n                                                        'id'        : items_id\n                                                       });\n\n\n      };";
     if (isset($_GET['load_kb_sol'])) {
         echo "viewAddSubitem" . $this->fields['id'] . "{$rand}('Solution');";
     }
     echo "</script>\n";
     //check sub-items rights
     $tmp = array('tickets_id' => $this->getID());
     $fup = new TicketFollowup();
     $ttask = new TicketTask();
     $doc = new Document();
     $canadd_fup = $fup->can(-1, CREATE, $tmp);
     $canadd_task = $ttask->can(-1, CREATE, $tmp);
     $canadd_document = $doc->can(-1, CREATE, $tmp) && $this->canAddItem('Document');
     $canadd_solution = Ticket::canUpdate() && $this->canSolve();
     if (!$canadd_fup && !$canadd_task && !$canadd_document && !$canadd_solution) {
         return false;
     }
     //show choices
     echo "<h2>" . _sx('button', 'Add') . " : </h2>";
     echo "<div class='timeline_form'>";
     echo "<ul class='timeline_choices'>";
     if ($canadd_fup) {
         echo "<li class='followup' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketFollowup\");'>" . __("Followup") . "</li>";
     }
     if ($canadd_task) {
         echo "<li class='task' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketTask\");'>" . __("Task") . "</li>";
     }
     if ($canadd_document) {
         echo "<li class='document' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Document_Item\");'>" . __("Document") . "</li>";
     }
     if ($canadd_solution) {
         echo "<li class='solution' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Solution\");'>" . __("Solution") . "</li>";
     }
     echo "</ul>";
     // timeline_choices
     echo "<div class='clear'>&nbsp;</div>";
     echo "</div>";
     //end timeline_form
     echo "<div class='ajax_box' id='viewitem" . $this->fields['id'] . "{$rand}'></div>\n";
 }
     $valid = new TicketValidation();
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $input = array('tickets_id' => $key, 'users_id_validate' => $_POST['users_id_validate'], 'comment_submission' => $_POST['comment_submission']);
             if ($valid->can(-1, 'w', $input)) {
                 $valid->add($input);
             }
         }
     }
     break;
 case "add_task":
     $task = new TicketTask();
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $input = array('tickets_id' => $key, 'taskcategories_id' => $_POST['taskcategories_id'], 'content' => $_POST['content']);
             if ($task->can(-1, 'w', $input)) {
                 $task->add($input);
             }
         }
     }
     break;
 case "add_actor":
     $ticket = new Ticket();
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $input = array('id' => $key);
             if (isset($_POST['_ticket_requester'])) {
                 $input['_ticket_requester'] = $_POST['_ticket_requester'];
             }
             if (isset($_POST['_ticket_observer'])) {
                 $input['_ticket_observer'] = $_POST['_ticket_observer'];
Beispiel #3
0
 /**
  * @since version 0.90
  *
  * @param $rand
  **/
 function showTimelineForm($rand)
 {
     global $CFG_GLPI;
     //check global rights
     if (!Session::haveRight("ticket", Ticket::READMY) && !Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE))) {
         return false;
     }
     // javascript function for add and edit items
     echo "<script type='text/javascript' >\n";
     echo "function viewAddSubitem" . $this->fields['id'] . "{$rand}(itemtype) {\n";
     $params = array('type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $this->fields['id'], 'id' => -1);
     if (isset($_GET['load_kb_sol'])) {
         $params['load_kb_sol'] = $_GET['load_kb_sol'];
     }
     $out = Ajax::updateItemJsCode("viewitem" . $this->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/timeline_viewsubitem.php", $params, "", false);
     echo str_replace("\"itemtype\"", "itemtype", $out);
     echo "\$('#approbation_form{$rand}').remove()";
     echo "};";
     $out = "function viewEditSubitem" . $this->fields['id'] . "{$rand}(e, itemtype, items_id, o) {\n\n               var target = e.target || window.event.srcElement;\n               if (target.nodeName == 'a') return;\n               if (target.className == 'read_more_button') return;";
     $params = array('type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $this->fields['id'], 'id' => 'items_id');
     $out .= Ajax::updateItemJsCode("viewitem" . $this->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/timeline_viewsubitem.php", $params, "", false);
     $out = str_replace("\"itemtype\"", "itemtype", $out);
     $out = str_replace("\"items_id\"", "items_id", $out);
     echo $out;
     //scroll to edit form
     echo "\$('body').scrollTop(0);";
     echo "\$('.ui-tabs-panel').scrollTop(0);";
     // add a mark to currently edited element
     echo "var found_active = \$('.talk_active');\n            i = found_active.length;\n            while(i--) {\n               var classes = found_active[i].className.replace( /(?:^|\\s)talk_active(?!\\S)/ , '' );\n               found_active[i].className = classes;\n            }\n            o.className = o.className + ' talk_active';\n\n            \$('#approbation_form{$rand}').remove();\n      };";
     if (isset($_GET['load_kb_sol'])) {
         echo "viewAddSubitem" . $this->fields['id'] . "{$rand}('Solution');";
     }
     echo "</script>\n";
     //check sub-items rights
     $tmp = array('tickets_id' => $this->getID());
     $fup = new TicketFollowup();
     $ttask = new TicketTask();
     $doc = new Document();
     $canadd_fup = $fup->can(-1, CREATE, $tmp);
     $canadd_task = $ttask->can(-1, CREATE, $tmp);
     $canadd_document = $doc->can(-1, CREATE, $tmp) && $this->canAddItem('Document');
     $canadd_solution = Ticket::canUpdate() && $this->canSolve();
     if (!$canadd_fup && !$canadd_task && !$canadd_document && !$canadd_solution) {
         return false;
     }
     //show choices
     echo "<h2>" . _sx('button', 'Add') . " : </h2>";
     echo "<div class='timeline_form'>";
     echo "<ul class='timeline_choices'>";
     if ($canadd_fup) {
         echo "<li class='followup' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketFollowup\");'>" . __("Followup") . "</li>";
     }
     if ($canadd_task) {
         echo "<li class='task' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketTask\");'>" . __("Task") . "</li>";
     }
     if ($canadd_document) {
         echo "<li class='document' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Document_Item\");'>" . __("Document") . "</li>";
     }
     if ($canadd_solution) {
         echo "<li class='solution' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Solution\");'>" . __("Solution") . "</li>";
     }
     echo "</ul>";
     // timeline_choices
     echo "<div class='clear'>&nbsp;</div>";
     echo "</div>";
     //end timeline_form
     echo "<div class='ajax_box' id='viewitem" . $this->fields['id'] . "{$rand}'></div>\n";
 }
 static function showForm(Ticket $ticket, $rand)
 {
     global $CFG_GLPI;
     //check global rights
     if (!Session::haveRight("ticket", Ticket::READMY) && !Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE))) {
         return false;
     }
     // javascript function for add and edit items
     echo "<script type='text/javascript' >\n";
     ?>
   function getUrlVar(key) {
      var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
      return result && unescape(result[1]) || "";
   }
   <?php 
     echo "function viewAddSubitem" . $ticket->fields['id'] . "{$rand}(itemtype) {\n";
     $params = array('type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $ticket->fields['id'], 'load_kb_sol' => "load_kb_sol_value", 'id' => -1);
     $out = Ajax::updateItemJsCode("viewitem" . $ticket->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/plugins/talk/ajax/viewsubitem.php", $params, "", false);
     $out = str_replace("\"load_kb_sol_value\"", "getUrlVar('load_kb_sol')", $out);
     echo str_replace("\"itemtype\"", "itemtype", $out);
     echo "};";
     $out = "function viewEditSubitem" . $ticket->fields['id'] . "{$rand}(e, itemtype, items_id, o) {\n\n               var target = e.target || window.event.srcElement;\n               if (target.nodeName == 'a') return;\n               if (target.className == 'read_more_button') return;";
     $params = array('type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $ticket->fields['id'], 'id' => 'items_id');
     $out .= Ajax::updateItemJsCode("viewitem" . $ticket->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/plugins/talk/ajax/viewsubitem.php", $params, "", false);
     $out = str_replace("\"itemtype\"", "itemtype", $out);
     $out = str_replace("\"items_id\"", "items_id", $out);
     echo $out;
     //scroll to edit form
     echo "window.scrollTo(0,110);";
     // add a mark to currently edited element
     echo "var found_active = \$('.talk_active');\n            i = found_active.length;\n            while(i--) {\n               var classes = found_active[i].className.replace( /(?:^|\\s)talk_active(?!\\S)/ , '' );\n               found_active[i].className = classes;\n            }\n            o.className = o.className + ' talk_active';\n      };";
     echo "</script>\n";
     //check sub-items rights
     $tmp = array('tickets_id' => $ticket->getID());
     $fup = new TicketFollowup();
     $ttask = new TicketTask();
     $canadd_fup = TicketFollowup::canCreate() && $fup->can(-1, UPDATE, $tmp);
     $canadd_task = TicketTask::canCreate() && $ttask->can(-1, UPDATE, $tmp);
     $canadd_document = Document::canCreate();
     $canadd_solution = Ticket::canUpdate() && $ticket->canSolve();
     if (!$canadd_fup && !$canadd_task && !$canadd_document && !$canadd_solution) {
         return false;
     }
     //show choices
     if ($ticket->fields["status"] != CommonITILObject::SOLVED && $ticket->fields["status"] != CommonITILObject::CLOSED) {
         echo "<h2>" . _sx('button', 'Add') . " : </h2>";
         echo "<div class='talk_form'>";
         echo "<ul class='talk_choices'>";
         if ($canadd_fup) {
             echo "<li class='followup' onclick='" . "javascript:viewAddSubitem" . $ticket->fields['id'] . "{$rand}(\"TicketFollowup\");'>" . __("Followup") . "</li>";
         }
         if ($canadd_task) {
             echo "<li class='task' onclick='" . "javascript:viewAddSubitem" . $ticket->fields['id'] . "{$rand}(\"TicketTask\");'>" . __("Task") . "</li>";
         }
         if ($canadd_document) {
             echo "<li class='document' onclick='" . "javascript:viewAddSubitem" . $ticket->fields['id'] . "{$rand}(\"Document_Item\");'>" . __("Document") . "</li>";
         }
         if ($canadd_solution) {
             echo "<li class='solution' onclick='" . "javascript:viewAddSubitem" . $ticket->fields['id'] . "{$rand}(\"Solution\");'>" . __("Solution") . "</li>";
             self::addJavascriptForViewAddSubitem($ticket, $rand);
         }
         echo "</ul>";
         // talk_choices
         echo "<div class='clear'>&nbsp;</div>";
         echo "</div>";
         //end talk_form
     }
     echo "<div class='ajax_box' id='viewitem" . $ticket->fields['id'] . "{$rand}'></div>\n";
 }