To <strong>attach another quiz</strong> or <strong>close this window</strong> please use the buttons below.
												</div>
												<div id="footer">
													<button class="btn" id="close-button" onclick="closeWizard()">Close</button>
													<button class="btn btn-primary" onclick="restartWizard('<?php 
                                        echo ENTRADA_URL;
                                        ?>
/api/quiz-wizard.api.php?id=<?php 
                                        echo $RECORD_ID;
                                        ?>
&amp;action=add&amp;type=community_page')" style="float: right; margin: 4px 10px 4px 0px">Add Another</button>
												</div>
											</div>
										</div>
										<?php 
                                        history_log($RECORD_ID, "attached {$PROCESSED['quiz_title']} community quiz.");
                                    } else {
                                        $ERROR++;
                                        $ERRORSTR[] = "There was a problem attaching <strong>" . html_encode($PROCESSED["quiz_title"]) . "</strong> to this community page. The system administrator was informed of this error; please try again later.";
                                        application_log("error", "Unable to attach quiz [" . $PROCESSED["quiz_id"] . "] to community page [" . $RECORD_ID . "]. Database said: " . $db->ErrorMsg());
                                        ?>
										<div class="modal-dialog" id="quiz-wizard">
											<form id="wizard-form" target="upload-frame" action="<?php 
                                        echo ENTRADA_URL;
                                        ?>
/api/quiz-wizard.api.php?type=<?php 
                                        echo $QUIZ_TYPE;
                                        ?>
&amp;action=add&amp;id=<?php 
                                        echo $RECORD_ID;
                                        ?>
                 if ($result) {
                     $query = "DELETE FROM `attached_quizzes` WHERE `aquiz_id` = " . $db->qstr($aquiz_id) . " AND `content_type` = 'event' AND `content_id` = " . $db->qstr($EVENT_ID);
                     if ($db->Execute($query)) {
                         if ($db->Affected_Rows()) {
                             application_log("success", "Detached quiz [" . $result["quiz_id"] . "] from event [" . $EVENT_ID . "].");
                         } else {
                             application_log("error", "Failed to detach quiz [" . $result["quiz_id"] . "] from event [" . $EVENT_ID . "]. Database said: " . $db->ErrorMsg());
                         }
                     } else {
                         $ERROR++;
                         $ERRORSTR[] = "We are unable to detach <strong>" . html_encode($result["quiz_title"]) . "</strong> from this event. The system administrator has been informed of the error; please try again later.";
                         application_log("error", "Failed to detach quiz [" . $result["quiz_id"] . "] from event [" . $EVENT_ID . "]. Database said: " . $db->ErrorMsg());
                     }
                 }
             }
             history_log($EVENT_ID, "deleted " . count($QUIZ_IDS) . " quiz" . (count($QUIZ_IDS) > 1 ? "es" : ""), $PROXY_ID);
         }
     }
     break;
 case "lti":
     $LTI_IDS = array();
     if (!isset($_POST["delete"]) || !is_array($_POST["delete"]) || !@count($_POST["delete"])) {
         $ERROR++;
         $ERRORSTR[] = "You must select at least 1 LTI Provider to delete by checking the checkbox to the left the LTI Provider.";
         application_log("notice", "User pressed the Delete LTI Provider button without selecting any files to delete.");
     } else {
         foreach ($_POST["delete"] as $lti_id) {
             $lti_id = (int) trim($lti_id);
             if ($lti_id) {
                 $LTI_IDS[] = (int) trim($lti_id);
             }
                                    $clinical_presentations[$objective_id] = $clinical_presentations_list[$objective_id];
                                }
                            }
                        }
                    } else {
                        $clinical_presentations = array();
                    }
                    if ($clinical_presentations && count($clinical_presentations)) {
                        $query = "DELETE FROM `evaluation_form_question_objectives` WHERE `efquestion_id` = " . $db->qstr($EFQUESTION_ID);
                        $db->Execute($query);
                        foreach ($clinical_presentations as $clinical_presentation) {
                            $evaluation_form_question_objective = array("efquestion_id" => $EFQUESTION_ID, "objective_id" => $clinical_presentation["objective_id"], "updated_date" => time(), "updated_by" => $ENTRADA_USER->getID());
                            if (!$db->AutoExecute("evaluation_form_question_objectives", $evaluation_form_question_objective, "INSERT")) {
                                application_log("error", "Unable to insert a new evalution_form_question_objectives record while updating an evaluation form question's associated clinical presentations. Database said: " . $db->ErrorMsg());
                            } else {
                                history_log($EFQUESTION_ID, "Updated evaluation form question clinical presentations.");
                            }
                        }
                    }
                } else {
                    $query = "\tSELECT `objective_id`\n\t\t\t\t\t\t\t\tFROM `evaluation_form_question_objectives`\n\t\t\t\t\t\t\t\tWHERE `efquestion_id` = " . $db->qstr($EFQUESTION_ID);
                    $results = $db->GetAll($query);
                    if ($results) {
                        foreach ($results as $result) {
                            $clinical_presentations[$result["objective_id"]] = $clinical_presentations_list[$result["objective_id"]];
                        }
                    }
                }
                ?>
				<h2>Associated MCC Presentations</h2>
				<form method="POST" action="<?php 
 if (isset($event["parent_id"]) && in_array($event["parent_id"], $old_events[$event["parent_id"]])) {
     $event["parent_id"] = $old_events[$event["parent_id"]]["new_event_id"];
 }
 if ($db->AutoExecute("`events`", $event, 'INSERT')) {
     $event_id = $db->Insert_ID();
     if (!$recurring_id_updated && isset($event["recurring_id"]) && $event["recurring_id"] && !array_key_exists($event["recurring_id"], $recurring_event_id_map)) {
         $recurring_event_id_map[$event["recurring_id"]] = $event_id;
         $query = "UPDATE `events` SET `recurring_id` = " . $db->qstr($event_id) . " WHERE `event_id` = " . $db->qstr($event_id);
         if (!$db->Execute($query)) {
             application_log("error", "An error occurred when updating a draft event with a recurring event id. DB said: " . $db->ErrorMsg());
         }
     }
     $old_events[$old_event_id]["new_event_id"] = $event_id;
     application_log("success", "Successfully created event [" . $event_id . "]");
     //inserts creation log
     history_log($event_id, 'created this learning event.', $event["updated_by"]);
 } else {
     $error++;
     application_log("error", "Error inserting event [" . $event_id . "] on draft schedule import. DB said: " . $db->ErrorMsg());
 }
 $notification_events .= $event["event_title"] . " at " . date("Y-m-d H:i", $event["event_start"]) . "\n";
 /*
  *  add the eventtypes associated with the draft event
  */
 $query = "\tSELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM `draft_eventtypes`\n\t\t\t\t\t\t\t\t\t\t\tWHERE `devent_id` = " . $db->qstr($event["devent_id"]);
 if ($eventtypes = $db->GetAll($query)) {
     application_log("notice", "Found " . count($eventtypes) . " eventtypes for draft event [" . $event["devent_id"] . "].");
     foreach ($eventtypes as $eventtype) {
         $eventtype["event_id"] = $event_id;
         unset($eventtype["deventtype_id"]);
         unset($eventtype["eeventtype_id"]);
											To <strong>add another link</strong> or <strong>close this window</strong> please use the buttons below.
										</div>
										<div id="footer">
											<input type="button" class="btn" value="Close" onclick="closeWizard()" style="float: left; margin: 4px 0px 4px 10px" />
											<input type="button" class="btn btn-primary" value="Add Another Link" onclick="restartWizard('<?php 
                                echo ENTRADA_URL;
                                ?>
/api/link-wizard-event.api.php?id=<?php 
                                echo $EVENT_ID;
                                ?>
&amp;action=add')" style="float: right; margin: 4px 10px 4px 0px" />
										</div>
									</div>
								</div>
								<?php 
                                history_log($EVENT_ID, "added {$PROCESSED['link']} link.");
                                break;
                            case 1:
                            default:
                                $modal_onload[] = "initStep(" . $JS_INITSTEP . ")";
                                if (isset($_POST["timedrelease"]) && $_POST["timedrelease"] == "yes") {
                                    $modal_onload[] = "timedRelease('block')";
                                } else {
                                    $modal_onload[] = "timedRelease('none')";
                                }
                                ?>
								<div class="modal-dialog" id="link-add-wizard">
									<div id="wizard">
										<form id="wizard-form" target="upload-frame" action="<?php 
                                echo ENTRADA_URL;
                                ?>
             if (!$ERROR) {
                 $query = "\tSELECT b.*\n\t\t\t\t\t\t\t\t\t\t\t\tFROM `community_courses` AS a\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `community_pages` AS b\n\t\t\t\t\t\t\t\t\t\t\t\tON a.`community_id` = b.`community_id`\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `community_page_options` AS c\n\t\t\t\t\t\t\t\t\t\t\t\tON b.`community_id` = c.`community_id`\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE c.`option_title` = 'show_history'\n\t\t\t\t\t\t\t\t\t\t\t\tAND c.`option_value` = 1\n\t\t\t\t\t\t\t\t\t\t\t\tAND b.`page_url` = 'course_calendar'\n\t\t\t\t\t\t\t\t\t\t\t\tAND b.`page_active` = 1\n\t\t\t\t\t\t\t\t\t\t\t\tAND a.`course_id` = " . $db->qstr($PROCESSED["course_id"]);
                 $result = $db->GetRow($query);
                 if ($result) {
                     $COMMUNITY_ID = $result["community_id"];
                     $PAGE_ID = $result["cpage_id"];
                     communities_log_history($COMMUNITY_ID, $PAGE_ID, $EVENT_ID, "community_history_edit_learning_event", 1);
                 }
                 $SUCCESS++;
                 $SUCCESSSTR[] = "You have successfully edited <strong>" . html_encode($PROCESSED["event_title"]) . "</strong> in the system.<br /><br />" . $msg;
                 $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)";
                 application_log("success", "Event [" . $EVENT_ID . "] has been modified.");
             }
             if (!empty($stats)) {
                 $stats_string = implode(", ", $stats);
                 history_log($EVENT_ID, 'edited this learning event in sections: ' . $stats_string, $PROXY_ID);
             }
         } else {
             add_error("There was a problem updating this event in the system. The system administrator was informed of this error; please try again later." . $db->ErrorMsg());
             application_log("error", "There was an error updating event_id [" . $EVENT_ID . "]. Database said: " . $db->ErrorMsg());
         }
     }
     if ($ERROR) {
         $STEP = 1;
     }
     break;
 case 1:
 default:
     $PROCESSED = $event_info;
     /**
      * Add existing event type segments to the processed array.
											To <strong>add another file</strong> or <strong>close this window</strong> please use the buttons below.
										</div>
										<div id="footer">
											<input type="button" class="btn" value="Close" onclick="closeWizard()" style="float: left; margin: 4px 0px 4px 10px" />
											<input type="button" class="btn btn-primary" value="Add Another File" onclick="restartWizard('<?php 
                                echo ENTRADA_URL;
                                ?>
/api/file-wizard-event.api.php?id=<?php 
                                echo $EVENT_ID;
                                ?>
&amp;action=add')" style="float: right; margin: 4px 10px 4px 0px" />
										</div>
									</div>
								</div>
								<?php 
                                history_log($EVENT_ID, "added {$PROCESSED['file_title']} file.");
                                break;
                            case 1:
                            default:
                                $modal_onload[] = "initStep(" . $JS_INITSTEP . ")";
                                /*
                                
                                								if ($JS_INITSTEP == 3) {
                                									$modal_onload[] = "allowSubmit(0)";
                                								}
                                */
                                if (isset($_POST["timedrelease"]) && $_POST["timedrelease"] == "yes") {
                                    $modal_onload[] = "timedRelease('block')";
                                } else {
                                    $modal_onload[] = "timedRelease('none')";
                                }
                         $result["event_id"] = $EVENT_ID;
                         $result["valid_from"] = $result["valid_from"] ? $event_start - ($original_start - $result["valid_from"]) : 0;
                         $result["valid_until"] = $result["valid_until"] ? $event_start - ($original_start - $result["valid_until"]) : 0;
                         $result["updated_date"] = $updated_date;
                         $result["updated_by"] = $USER_ID;
                         array_shift($result);
                         if (!$db->AutoExecute("event_lti_consumers", $result, "INSERT")) {
                             $ERROR++;
                             $ERRORSTR[] = "There was an error while trying to save the selected <strong>LTI Event Consumer</strong> for this event {$EVENT_ID}.<br /><br />The system administrator was informed of this error; please try again later.";
                             application_log("error", "Unable to insert a new event_lti_consumer record while copying a new event {$EVENT_ID}. Database said: " . $db->ErrorMsg());
                             break 2;
                         }
                     }
                 }
                 $copied[$event_id]["event_title"] = $event_info["event_title"];
                 history_log($EVENT_ID, 'created this learning event.', $ENTRADA_USER->getID());
             } else {
                 $ERROR++;
                 $ERRORSTR[] = "There was a problem copying this event {$event_id} to {$EVENT_ID} into the system. The system administrator was informed of this error; please try again later.";
                 application_log("error", "There was an error inserting a event {$EVENT_ID}. Database said: " . $db->ErrorMsg());
                 break;
             }
         } else {
             add_error("Unable to located the requested event. Please ensure you select a valid event from the list on the Manage Events page and try again.");
         }
     }
 }
 $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/admin/events\\'', 5000)";
 if ($total_copied = @count($copied)) {
     $SUCCESS++;
     $SUCCESSSTR[$SUCCESS] = "You have successfully copied " . $total_copied . " event" . ($total_copied != 1 ? "s" : "") . " from the system:";