예제 #1
0
 function do_savetransition()
 {
     $oForm = $this->form_edittransition($this->oTransition);
     $res = $oForm->validate();
     $data = $res['results'];
     $errors = $res['errors'];
     $extra_errors = array();
     // check if any *other* states have this name.
     if ($data['name'] == $this->oTransition->getName()) {
         $this->successRedirectTo('edittransition', _kt("No change in name."));
     }
     // otherwise we're looking for something different if there's a conflict.
     if (KTWorkflowTransition::nameExists($data['name'], $this->oWorkflow)) {
         $extra_errors['name'][] = _kt('There is already a transition with that name in this workflow.');
     }
     if (!empty($errors) || !empty($extra_errors)) {
         $oForm->handleError(null, $extra_errors);
     }
     $this->startTransaction();
     $this->oTransition->setName($data['name']);
     $this->oTransition->setHumanName($data['name']);
     $res = $this->oTransition->update();
     if (PEAR::isError($res)) {
         $oForm->handleError(sprintf(_kt("Unable to update transition: %s"), $res->getMessage()));
     }
     $this->successRedirectTo('basic', _kt("Transition updated."));
 }