Beispiel #1
0
 } else {
     add_error("The order is required. Please select the order which this descriptor should appear in.");
 }
 /**
  * Required field "reportable" / Include in Reports
  */
 if (isset($_POST["reportable"]) && ($reportable = clean_input($_POST["reportable"], array("trim", "int")))) {
     $PROCESSED["reportable"] = 1;
 } else {
     $PROCESSED["reportable"] = 0;
 }
 $PROCESSED["organisation_id"] = $ORGANISATION_ID;
 $PROCESSED["updated_date"] = time();
 $PROCESSED["updated_by"] = $ENTRADA_USER->getID();
 $PROCESSED["active"] = 1;
 $descriptor->fromArray($PROCESSED);
 if (!has_error()) {
     $existing_descriptors = Models_Evaluation_ResponseDescriptor::fetchAllByOrganisation($ORGANISATION_ID);
     foreach ($existing_descriptors as $existing_descriptor) {
         if ($existing_descriptor->getOrder() >= $PROCESSED["order"] && (!$descriptor->getOrder() || $existing_descriptor->getOrder() < $descriptor->getOrder())) {
             $descriptor_array = $existing_descriptor->toArray();
             $descriptor_array["order"]++;
             $existing_descriptor->fromArray($descriptor_array)->update();
         }
     }
     if (defined("ADD_DESCRIPTOR")) {
         if ($descriptor->insert()) {
             add_success("Successfully added the Evaluation Response Descriptor [<strong>" . $descriptor->getDescriptor() . "</strong>]. You will now be redirected to the Evaluation Response Descriptors index, please <a href=\"" . ENTRADA_URL . "/admin/settings/manage/descriptors?org=" . $ORGANISATION_ID . "\">click here</a> if you do not wish to wait.");
         } else {
             $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/admin/settings/manage/descriptors?org=" . $ORGANISATION_ID . "\\'', 5000)";
             add_error("An error occurred while attempting to add the Evaluation Response Descriptor [<strong>" . $descriptor->getDescriptor() . "</strong>]. A system administrator has been informed, please try again later.<br /><br />You will now be redirected to the Evaluation Response Descriptors index, please <a href=\"" . ENTRADA_URL . "/admin/settings/manage/descriptors?org=" . $ORGANISATION_ID . "\">click here</a> if you do not wish to wait.");