/** * Returns the output string for the form of selecting an existing address * @param type $default * @return type */ public static function existingAddressesOutput($default = "") { $values = EventDatabaseManager::getAllAddresses(); return View::outputOptions('addressID', $values, $default); }
/** * Returns TRUE, if the user is signed up for any event on the specified event's topic * * @param int $userID * @param int $eventID * @return boolean */ public static function isSignedForEventsTopic($userID, $eventID) { $event = EventDatabaseManager::getEvent($eventID); return EventDatabaseManager::isSignedInForTopic($userID, $event->getTopicID()); }
function isTopicActive($userID, $topicID, $repetitionFrequency) { $str = ""; $str = $userID . " " . $topicID . " " . $repetitionFrequency . " -> "; $courseID = EventDatabaseManager::getCourseByTopic($topicID); $certificate_date = EventDatabaseManager::getCertificateDate($userID, $courseID); $rep_date = strtotime($certificate_date . " +" . $repetitionFrequency . " days"); $rep_date = date("d.m.Y", time()); $str .= $rep_date . "<br>"; $str = ""; if ($certificate_date) { return 'done'; } else { if ($repetitionFrequency == 0) { // RepFreq = 0 -> keine Wiedervorlage $str .= " <span style=\"background: green; color: white;\">0:keine WV</span>"; } else { if (strtotime($certificate_date . " +" . $repetitionFrequency . " days") - strtotime('today') < 0) { // vergangen $str .= " <span style=\"background: red; color: white;\">V:zu bearb.</span>"; } if (strtotime($certificate_date . " +" . $repetitionFrequency . " days") - strtotime('today') >= 0) { // heute oder zukunft $str .= " <span style=\"background: green; color: white;\">Z:erledigt</span>"; } } } return $str; }
function show_courses_topic() { include_once '../wp-content/plugins/wp-courseware/lib/common.inc.php'; include_once '../wp-content/plugins/wp-courseware/lib/constants.inc.php'; include_once '../wp-content/plugins/wp-courseware/lib/email_defaults.inc.php'; include_once '../wp-content/plugins/wp-courseware/lib/class_user_progress.inc.php'; $was_saved = 0; if ($_POST["topic_for_course"]) { foreach ($_POST["topic_for_course"] as $tfc_id => $tfc_value) { $tfc_value = explode("-", $tfc_value); //echo $tfc_value[0]."---".$tfc_value[1]."<br>"; $set_topic = EventDatabaseManager::setTopicForCourse($tfc_value[0], $tfc_value[1]); $was_saved = 1; } } $output_str = ""; $output_str .= "<form name=\"form1\" method=\"post\" action=\"" . $_SERVER['REQUEST_URI'] . "\">"; $topic_per_course = EventDatabaseManager::getTopicPerCourse(); // $topic_per_course_test_cert_date = EventDatabaseManager::getTopicPerCourse_test_CertDate(); //echo "<pre>";var_dump($topic_per_course); echo "</pre><br><br>"; $output_str .= "<h2>" . HEADER_TOPICS_PER_COURSE . "</h2>"; if ($was_saved == 1) { $output_str .= "<p>Gespeichert!</p>"; } $output_str .= "<table>"; $output_str .= "<tr>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">Course-ID</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">Course-Title</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">Topic-Title</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">User</td>"; $output_str .= "</tr>"; $topics = EventDatabaseManager::getAllTopics(); $output_str .= "<tr>"; $output_str .= "<td colspan=4 style=\"padding: 1px 2px; border: 1px solid black;\">Variante 1: Datum ist Topic Expiry Date</td>"; $output_str .= "</tr>"; foreach ($topic_per_course as $tpc => $course_value) { $topic_select = "<select name=\"topic_for_course[" . $course_value['course_id'] . "]\">"; $topic_select .= "<option value=\"" . $course_value['course_id'] . "-0\">---</option>"; foreach ($topics as $topic_id => $topic_value) { $selected = ""; if ($topic_id == $course_value['topic_id']) { $selected = " selected "; } $topic_select .= "<option " . $selected . " value=\"" . $course_value['course_id'] . "-" . $topic_id . "\">" . $topic_value . " (" . $topic_id . ")</option>"; } $topic_select .= "</select>"; $user_string = ""; //echo "tpc2:<br><pre>";var_dump($course_value['users']); echo "</pre>"; foreach ($course_value['users'] as $users => $user) { $user_string .= $user['name'] . " ("; $user_string .= $user['id'] . "): "; // $user_string .= date("d.m.Y",strtotime($user['topic_expiry_date'])); // wird doch gar nicht benutzt!!! $bla = new UserProgress($course_value['course_id'], $user['id']); //echo "<pre>";var_dump($bla); echo "</pre><br><br>"; if ($bla->isCourseCompleted()) { $user_string .= " <span style=\"background: orange; color: white;\">[completed (certificate)]</span>"; } // Datum in Weiß auf Orange ist cert_generated $active = EventDatabaseManager::isTopicForUserActive($user['id'], $course_value['topic_id']); $user_string .= $active; // $user_string .= "+" . $user['repetition_frequency_days']."="; //$repetition_date = strtotime($user['topic_expiry_date']." +".$user['repetition_frequency_days']." days")."="; //$user_string .= date("d.m.Y",(int)$repetition_date); // wenn repetition_frequency_days == 0 -> keine Wiedervorlage // topic_expiry_date durch creation_date ersetzen // sonst: $user_string .= "<br>"; } $output_str .= "<tr>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">" . $course_value['course_id'] . "</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">" . $course_value['course_title'] . "</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">" . $topic_select . "</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">[" . count($course_value['users']) . "]<br>" . rtrim($user_string, ",") . "</td>"; $output_str .= "</tr>"; } $output_str .= "<tr><td colspan=\"4\">"; $output_str .= " <span style=\"background: orange; color: white;\"> Course Completed und Datum der Zertifkatsgenerierung </span>"; $output_str .= " <span style=\"background: red; color: white;\"> V = Rep.Date ist Vergangenheit </span>"; $output_str .= " <span style=\"background: green; color: white;\"> Z = Rep.Date ist Heute oder Zukunft </span>"; $output_str .= " <span style=\"background: red; color: white;\"> K = kein Zertifikat </span>"; $output_str .= " <span style=\"background: #FFCC00; color: black;\"> WV am </span>"; $output_str .= " <span style=\"background: green; color: white;\"> 0 = keine WV </span>"; $output_str .= "</td></tr>"; $output_str .= "<tr>"; $output_str .= "<td colspan=4 style=\"padding: 1px 2px; border: 1px solid black;\">Variante 2: Datum ist Certificate Creation Date -> weniger Treffer (wieder verworfen)</td>"; $output_str .= "</tr>"; $output_str .= "</table>"; $output_str .= " <br>"; $output_str .= " <input type=\"submit\" value=\"Speichern\" />"; $output_str .= " <input name=\"action\" value=\"insert\" type=\"hidden\" />"; $output_str .= " </form>"; echo $output_str; }
function save_new_fields($user_id) { if (!current_user_can('edit_user', $user_id)) { return false; } update_user_meta($user_id, 'datr_plugin_language', $_POST['datr_language']); if (!current_user_can('manage_options')) { return false; } $topics = EventDatabaseManager::getAllTopics(); foreach ($topics as $id => $title) { if (isset($_POST['user_has_topic_' . $id])) { $topicParams = array(); foreach (EventDatabaseManager::$userHasTopicsParams as $param) { $topicParams[$param] = $_POST[$param . '_' . $id]; } EventDatabaseManager::addOrUpdateAssignedTopic($user_id, $id, $topicParams); } else { EventDatabaseManager::deleteAssignedTopic($user_id, $id); } } $locations = EventDatabaseManager::getMandantLocations(get_user_meta($user_id, 'datr_mandantID', true)); foreach ($locations as $id => $locationName) { if (isset($_POST['location_' . $id])) { EventDatabaseManager::addLocationToUser($user_id, $id); } else { EventDatabaseManager::removeLocationFromUser($user_id, $id); } } update_user_meta($user_id, 'datr_gender', $_POST['datr_gender']); update_user_meta($user_id, 'datr_title', $_POST['datr_title']); update_user_meta($user_id, 'datr_mandantID', $_POST['datr_mandantID']); update_user_meta($user_id, 'datr_department', $_POST['datr_department']); }
/** * Outputs the form for editing existing topic */ function edit_topics() { View::loadScripts(); $topics = EventDatabaseManager::getAllTopics(true); View::outputAllTopics('edit_topics', $topics); View::linkToAddTopic(); if (isset($_GET['topicID']) && is_numeric($_GET['topicID'])) { $topic = EventDatabaseManager::getTopic($_GET['topicID']); View::topicFormOutput($topic); } }