Пример #1
0
 /**
  * Moves all linked information from one person to another
  */
 public function merge()
 {
     try {
         $personA = new Person($_REQUEST['person_id_a']);
         $personB = new Person($_REQUEST['person_id_b']);
     } catch (\Exception $e) {
         $_SESSION['errorMessages'][] = $e;
         header('Location: ' . BASE_URL);
         exit;
     }
     // When the user chooses a target, merge the other ticket into the target
     if (isset($_POST['targetPerson'])) {
         try {
             if ($_POST['targetPerson'] == 'a') {
                 $personA->mergeFrom($personB);
                 $targetPerson = $personA;
             } else {
                 $personB->mergeFrom($personA);
                 $targetPerson = $personB;
             }
             header('Location: ' . $targetPerson->getURL());
             exit;
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
         }
     }
     $this->template->setFilename('merging');
     $this->template->blocks[] = new Block('people/mergeForm.inc', array('personA' => $personA, 'personB' => $personB));
     $this->template->blocks['left'][] = new Block('people/personInfo.inc', array('person' => $personA, 'disableButtons' => true));
     $lists = array('reportedBy' => 'Reported Cases', 'assigned' => 'Assigned Cases', 'referred' => 'Referred Cases', 'enteredBy' => 'Entered Cases');
     foreach ($lists as $listType => $title) {
         $this->addTicketList('left', $listType, $title, $personA, true, true);
     }
     $this->template->blocks['right'][] = new Block('people/personInfo.inc', array('person' => $personB, 'disableButtons' => true));
     $lists = array('reportedBy' => 'Reported Cases', 'assigned' => 'Assigned Cases', 'referred' => 'Referred Cases', 'enteredBy' => 'Entered Cases');
     foreach ($lists as $listType => $title) {
         $this->addTicketList('right', $listType, $title, $personB, true, true);
     }
 }