示例#1
0
/**
 * 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);
    }
}
示例#2
0
 /**
  * Returns the output string for event form field
  * 
  * @param String $param
  * @param String $defaultValue
  * @return String
  */
 public static function eventFormFieldsOutput($param, $defaultValue = "")
 {
     if ($param == 'topicID') {
         $topicsValues = EventDatabaseManager::getAllTopics();
         return View::outputOptions('topicID', $topicsValues, $defaultValue, true, 'validate');
     } else {
         if ($param == 'mandantID') {
             $mandants = EventDatabaseManager::getAllMandants();
             return View::outputOptions('mandantID', $mandants, $defaultValue, true, 'validate');
         } else {
             if ($param == 'addressID') {
                 return "<b>" . CHOOSE_EXISTING_ADDRESS . ": </b>" . View::existingAddressesOutput($defaultValue, true) . "</br> <b>" . ENTER_NEW_ADDRESS . ": </b>" . View::newAddressFormOutput();
             } else {
                 if ($param == 'date_time') {
                     if ($defaultValue != "") {
                         $date = date_parse($defaultValue);
                         return View::timeFormOutput("", $date['year'], $date['month'], $date['day'], $date['hour'], $date['minute']);
                     } else {
                         return View::timeFormOutput("");
                     }
                 } else {
                     if ($param == 'event_visible') {
                         if ($defaultValue != '1' && $defaultValue != 1) {
                             $defaultValue = "";
                         }
                         return View::checkboxFormOutput('event_visible', '1', $defaultValue);
                     } else {
                         if ($param == 'eventType') {
                             if ($defaultValue == '') {
                                 $defaultValue = 'offline';
                             }
                             return View::outputOptions('eventType', Event::$eventTypes, $defaultValue, true, 'validate');
                         } else {
                             if ($param == 'invitation_text') {
                                 return View::textAreaFormOutput($param, $defaultValue, 'validate');
                             } else {
                                 return View::textFormOutput($param, $defaultValue, 'validate');
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#3
0
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'] . "&nbsp;(";
            $user_string .= $user['id'] . "):&nbsp;";
            // $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;
}
示例#4
0
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']);
}