Example #1
0
 public function execute($request, $response)
 {
     $myExtension = \Questionary::getInstance();
     $name = trim(isset($_POST["name"]) ? $_POST["name"] : "test");
     //current room steam object
     //if( (int) $object != 0 )
     //$current_room = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $object);
     //else
     $current_room = $GLOBALS["STEAM"]->get_current_steam_user()->get_workroom();
     $steamUser = $GLOBALS["STEAM"]->get_current_steam_user();
     //get write permission
     $access_write = $current_room->check_access_write($steamUser);
     $access_read = $current_room->check_access_read($steamUser);
     $access_insert = $current_room->check_access_insert($steamUser);
     $allowed = $access_write && $access_read && $access_insert ? true : false;
     if (!$allowed) {
         // ACCESS DENIED?
     }
     //create questionary if adviced too
     if (isset($_POST["mission"]) && $_POST["mission"] == "create" && $name != "" && $allowed) {
         //create new questionary
         $questionary = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), $name, $current_room);
         $questions_folder = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), 'questions', $questionary);
         $answers_folder = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), 'answers', $questionary);
         if (isset($_POST["description"])) {
             $description = $_POST["description"];
         } else {
             $description = "";
         }
         if ($questionary && $questions_folder && $answers_folder) {
             //set standard layout
             $layout = "template";
             //$templates[1];
             //define rights for the attributes
             $loginuser_id = $steamUser->get_id();
             $rootid = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), "root")->get_id();
             $author_rights[$loginuser_id] = $loginuser_id;
             $editor_rights[$loginuser_id] = $loginuser_id;
             $analyst_rights[$loginuser_id] = $loginuser_id;
             $author_rights[$rootid] = $rootid;
             $editor_rights[$rootid] = $rootid;
             $analyst_rights[$rootid] = $rootid;
             //define container as questionary and set all attributes
             $attributes = array("bid:doctype" => "questionary", "bid:questionary:fillout" => "1", "bid:questionary:editanswer" => "1", "bid:questionary:editownanswer" => "0", "bid:questionary:number" => "1", "bid:questionary:resultcreator" => "1", "bid:questionary:resultcreationtime" => "1", "bid:questionary:description" => $description, "bid:questionary:edittime" => array(0, 0, 0), "bid:questionary:enabled" => false, "bid:questionary:layout" => $layout, "bid:questionary:author_rights" => $author_rights, "bid:questionary:editor_rights" => $editor_rights, "bid:questionary:analyst_rights" => $analyst_rights);
             $result = $questionary->set_attributes($attributes);
             header("Location: " . PATH_URL . "questionary/editQuestionary/" . $questionary->get_id());
         }
     } else {
         $myExtension->addCSS();
         $content = $myExtension->loadTemplate("questionaryNewQuestionary.template.html");
         $content->setCurrentBlock('BLOCK_FORM_NEW_QUESTIONARY');
         $content->setVariable("QUESTIONARY_ID", "");
         $content->setVariable("BUTTON_MISSION", "create");
         $content->setVariable("OBJECT_ID", $current_room->get_id());
         $content->parse('BLOCK_FORM_NEW_QUESTIONARY');
         return $content->get();
     }
 }
Example #2
0
function steam_user_get_groups($username)
{
    $result = array();
    $steam_user = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $username);
    $groups = $steam_user->get_groups();
    $query = array("OBJ_NAME");
    $i = 0;
    foreach ($groups as $group) {
        $result[$i] = $group->get_attributes($query);
        $result[$i]["OBJ_ID"] = $group->get_id();
    }
    return $result;
}
Example #3
0
<?php

include_once "../etc/koala.conf.php";
include_once PATH_LIB . "url_handling.inc.php";
include_once PATH_LIB . "format_handling.inc.php";
$portal = lms_portal::get_instance();
$portal->initialize(GUEST_NOT_ALLOWED);
$login = $_GET["id"];
if (!($user = steam_factory::username_to_object($STEAM->get_id(), $login))) {
    include "bad_link.php";
    exit;
}
$backlink = PATH_URL . "user/" . $login . "/";
$path = url_parse_rewrite_path($_GET["path"]);
switch (TRUE) {
    case $path[0] == "contacts":
        if (YOUR_CONTACTS) {
            $backlink .= "contacts/";
            include "user_contacts.php";
        } else {
            include "bad_link.php";
        }
        exit;
        break;
    case $path[0] == "groups":
        if (YOUR_GROUPS) {
            $backlink .= "groups/";
            include "user_groups.php";
        } else {
            include "bad_link.php";
        }
Example #4
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //$portal = \lms_portal::get_instance();
     //$portal->initialize( GUEST_NOT_ALLOWED );
     //$portal->set_guest_allowed( GUEST_NOT_ALLOWED );
     $user = \lms_steam::get_current_user();
     //$portal_user = $portal->get_user();
     //$path = $request->getPath();
     $current_semester = $this->params[1];
     $group_course = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "Courses." . $this->params[0] . "." . $this->params[1]);
     $group = new \koala_group_course($group_course);
     //$html_handler_course = new \koala_html_course($course);
     if (!$group instanceof \koala_group) {
         throw new \Exception("Variable group not set.");
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (isset($_POST["remove"]) && is_array($_POST["remove"])) {
             $id = key($_POST["remove"]);
             $member_to_kick = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $id);
             $group->remove_member($member_to_kick);
             $frameResponseObject->setConfirmText(str_replace("%NAME", h($member_to_kick->get_attribute("USER_FIRSTNAME")) . " " . h($member_to_kick->get_attribute("USER_FULLNAME")), gettext("User %NAME successfully removed from group members.")));
             //$portal->set_confirmation( str_replace( "%NAME", h($member_to_kick->get_attribute( "USER_FIRSTNAME" ))." " . h($member_to_kick->get_attribute( "USER_FULLNAME" )), gettext( "User %NAME successfully removed from group members." ) ) );
             // clear caches:
             $cache = get_cache_function($member_to_kick->get_name());
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), TRUE);
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), FALSE);
             $cache->drop("lms_steam::user_get_profile", $member_to_kick->get_name());
             $cache->drop("lms_portal::get_menu_html", $member_to_kick->get_name(), TRUE);
             $cache = get_cache_function($group->get_id());
             $cache->drop("lms_steam::group_get_members", $group->get_id());
         } else {
             if (isset($_POST["hide"]) && is_array($_POST["hide"])) {
                 $hidden_members = $group->get_steam_group()->get_attribute("COURSE_HIDDEN_STAFF");
                 if (!is_array($hidden_members)) {
                     $hidden_members = array();
                 }
                 $users_to_hide = array_keys($_POST["hide"]);
                 $displayed_staff_members = array();
                 $displayed_staff_members = array_keys($_POST["displayed_staff_member"]);
                 $tmp1_users_to_hide = array_unique(array_merge($hidden_members, $users_to_hide));
                 $tmp2_users_to_hide = array_diff($tmp1_users_to_hide, $displayed_staff_members);
                 $final_users_to_hide = array_unique(array_merge($tmp2_users_to_hide, $users_to_hide));
                 $group->get_steam_group()->set_attribute("COURSE_HIDDEN_STAFF", $final_users_to_hide);
             } else {
                 $hidden_members = $group->get_steam_group()->get_attribute("COURSE_HIDDEN_STAFF");
                 if (!is_array($hidden_members)) {
                     $hidden_members = array();
                 }
                 $displayed_staff_members = array();
                 $displayed_staff_members = array_keys($_POST["displayed_staff_member"]);
                 $users_to_hide = array();
                 $users_to_hide = array_diff($hidden_members, $displayed_staff_members);
                 $group->get_steam_group()->set_attribute("COURSE_HIDDEN_STAFF", $users_to_hide);
             }
             $frameResponseObject->setConfirmText("Sucessfully updated the visibility of course staff");
             //$portal->set_confirmation( "Sucessfully updated the visibility of course staff" );
         }
     }
     $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
     switch (get_class($group)) {
         case "koala_group_course":
             $html_handler_group = new \koala_html_course($group);
             $html_handler_group->set_context("staff");
             //$members = $cache->call( "lms_steam::group_get_members", $group->steam_group_staff->get_id() );
             $members = \lms_steam::group_get_members($group->steam_group_staff->get_id());
             break;
         default:
             $html_handler_group = new \koala_html_group($group);
             $html_handler_group->set_context("staff");
             //$members = $cache->call( "lms_steam::group_get_members", $group->get_id() );
             $members = \lms_steam::group_get_members($group->get_id());
             break;
     }
     $is_admin = $group->is_admin($user);
     $content = \Course::getInstance()->loadTemplate("list_staff.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "list_staff.template.html" );
     $no_members = count($members);
     //DONE
     if ($no_members > 0) {
         $pageIterator = \lms_portal::get_paginator(10, $no_members, "(" . str_replace("%NAME", h($group->get_name()), gettext("%TOTAL members in %NAME")) . ")");
         $content->setVariable("PAGEITERATOR", $pageIterator["html"]);
         $start = $pageIterator["startIndex"];
         //$start = $portal->set_paginator( $content, 10, $no_members, "(" . str_replace( "%NAME", h($group->get_name()), gettext( "%TOTAL members in %NAME" ) ) . ")" );
         $end = $start + 10 > $no_members ? $no_members : $start + 10;
         $content->setVariable("LABEL_CONTACTS", gettext("staff member") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_members), gettext("%a-%z out of %s")) . ")");
         $content->setCurrentBlock("BLOCK_CONTACT_LIST");
         $content->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
         !COURSE_STAFF_FACULTY_AND_FOCUS or $content->setVariable("LABEL_SUBJECT_AREA", gettext("Origin/Focus"));
         $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
         if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
             !COURSE_STAFFLIST_MANAGE or $content->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
             !COURSE_STAFFLIST_HIDE or $content->setVariable("TH_STAFF_MEMBER_VISIBILITY", gettext("hidden"));
             !COURSE_STAFFLIST_HIDE or $content->setVariable("STAFF_MEMBER_VISIBILITY_TITLE", gettext("Selected staff members will not be visible on the course start page."));
         }
         !COURSE_STAFF_EXTENSIONS or $content->setVariable("TH_MANAGE_EXTENSIONS", "Status");
         $content->setVariable("BEGIN_HTML_FORM", "<form method=\"POST\" action=\"\">");
         $content->setVariable("END_HTML_FORM", "</form>");
         $hidden_members = $group->get_steam_group()->get_attribute("COURSE_HIDDEN_STAFF");
         if (!is_array($hidden_members)) {
             $hidden_members = array();
         }
         for ($i = $start; $i < $end; $i++) {
             $member = $members[$i];
             if ($member["USER_TRASHED"] === 1) {
                 continue;
             }
             $content->setCurrentBlock("BLOCK_CONTACT");
             $content->setVariable("CONTACT_LINK", PATH_URL . "user/" . h($member["OBJ_NAME"]) . "/");
             $icon_link = $member["OBJ_ICON"] == 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "download/image/" . h($member["OBJ_ICON"]) . "/26/35";
             $content->setVariable("CONTACT_IMAGE", $icon_link);
             $title = !empty($member["USER_ACADEMIC_TITLE"]) ? h($member["USER_ACADEMIC_TITLE"]) . " " : "";
             $content->setVariable("CONTACT_NAME", $title . h($member["USER_FIRSTNAME"]) . " " . h($member["USER_FULLNAME"]));
             if (!COURSE_SHOW_ONLY_EXTERN_MAIL || COURSE_SHOW_ONLY_EXTERN_MAIL && is_string(\steam_factory::get_user($GLOBALS['STEAM']->get_id(), $member["OBJ_NAME"])->get_attribute("USER_EMAIL")) && steam_factory::get_user($GLOBALS['STEAM']->get_id(), $member["OBJ_NAME"])->get_attribute("USER_EMAIL") != "" && steam_factory::get_user($GLOBALS['STEAM']->get_id(), $member["OBJ_NAME"])->get_attribute("USER_FORWARD_MSG") === 1) {
                 $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . h($member["OBJ_NAME"]));
                 $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                 $content->setVariable("LABEL_SEND", gettext("Send"));
             }
             !COURSE_STAFF_FACULTY_AND_FOCUS or $content->setVariable("FACULTY_AND_FOCUS", h($member["USER_PROFILE_FACULTY"]));
             if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
                 !COURSE_STAFFLIST_MANAGE or $content->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"remove[" . h($member["OBJ_NAME"]) . "]\" value=\"" . gettext("Remove") . "\"/></td>");
                 if (in_array($member["OBJ_ID"], $hidden_members)) {
                     !COURSE_STAFFLIST_HIDE or $content->setVariable("TD_STAFF_MEMBER_VISIBILITY", "<td align=\"center\"><input type=\"checkbox\" name=\"hide[" . $member["OBJ_ID"] . "]\" checked=\"checked\"/>" . "\n\t\t\t<input type=\"hidden\" name=\"displayed_staff_member[" . $member["OBJ_ID"] . "]\" />" . "</td>");
                 } else {
                     !COURSE_STAFFLIST_HIDE or $content->setVariable("TD_STAFF_MEMBER_VISIBILITY", "<td align=\"center\"><input type=\"checkbox\" name=\"hide[" . $member["OBJ_ID"] . "]\" />" . "\n\t\t\t<input type=\"hidden\" name=\"displayed_staff_member[" . $member["OBJ_ID"] . "]\" />" . "</td>");
                 }
             }
             $member_desc = empty($member["OBJ_DESC"]) ? "student" : $member["OBJ_DESC"];
             $status = secure_gettext($member_desc);
             $content->setVariable("OBJ_DESC", h($status));
             if (COURSE_STAFF_EXTENSIONS) {
                 $extensions = $group->get_extensions();
                 $result = "";
                 foreach ($extensions as $extension) {
                     $result .= $extension->get_member_info(\steam_factory::get_user($GLOBALS["STEAM"]->get_id(), $member["OBJ_NAME"]), $group);
                 }
                 $content->setVariable("EXTENSIONS_DATA", $result);
             }
             $content->parse("BLOCK_CONTACT");
         }
         if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
             !COURSE_STAFFLIST_HIDE or $content->setVariable("LABEL_SUBMIT_BUTTON", gettext("Save"));
         }
         $content->parse("BLOCK_CONTACT_LIST");
     } else {
         $content->setVariable("LABEL_NO_MEMBERS", gettext("No staff found."));
     }
     $html_handler_group->set_html_left($content->get());
     //$portal->set_page_main( $html_handler_group->get_headline(), $html_handler_group->get_html() , "" );
     $frameResponseObject->setHeadline($html_handler_group->get_headline());
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($html_handler_group->get_html());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Example #5
0
<?php

if (!$group instanceof koala_group) {
    throw new Exception("Variable group not set.");
}
if (COURSE_PARTICIPANTS_STAFF_ONLY && !$group->is_admin($user)) {
    header("location:../");
    exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (is_array($_POST["remove"])) {
        $id = key($_POST["remove"]);
        $member_to_kick = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $id);
        $group->remove_member($member_to_kick);
        $portal->set_confirmation(str_replace("%NAME", h($member_to_kick->get_attribute("USER_FIRSTNAME")) . " " . h($member_to_kick->get_attribute("USER_FULLNAME")), gettext("User %NAME successfully removed from group members.")));
        // clear caches:
        $cache = get_cache_function($member_to_kick->get_name());
        $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), TRUE);
        $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), FALSE);
        $cache->drop("lms_steam::user_get_profile", $member_to_kick->get_name());
        $cache->drop("lms_portal::get_menu_html", $member_to_kick->get_name(), TRUE);
        $cache = get_cache_function($group->get_id());
        $cache->drop("lms_steam::group_get_members", $group->get_id());
    }
}
$cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
switch (get_class($group)) {
    case "koala_group_course":
        $html_handler_group = new koala_html_course($group);
        $html_handler_group->set_context("members");
        $members = $cache->call("lms_steam::group_get_members", $group->steam_group_learners->get_id());
    paul_sync_log("PAUL_SYNC\tNew Bookings: " . $counter_new_bookings . " (scheduled:" . $info_sum_bookings . ")");
    paul_sync_log("PAUL_SYNC\tDeleted bookings: " . $counter_deleted_bookings . " (scheduled: " . $info_sum_part_todelete . ")");
    paul_sync_log("PAUL_SYNC\tSynchronized participants of " . $info_courses . " courses in: " . timelog("runtime_script"));
    paul_sync_log("PAUL_SYNC\tUsers never seen: " . $counter_never_seen_users);
    paul_sync_log("PAUL_SYNC\t=== END ===");
} catch (Exception $e) {
    paul_sync_log($e->getTraceAsString(), PAUL_SYNC_LOGLEVEL_ERROR);
    print "Cannot write Log-File! ";
    print "Please check if " . LOG_PAULSYNC . " is writable.";
}
if (defined("PAUL_SYNC_ADMIN_LOGIN")) {
    $logdata = "";
    if (file_exists(LOG_PAULSYNC_LAST)) {
        $fp = fopen(LOG_PAULSYNC_LAST, "r");
        $logdata = fread($fp, filesize(LOG_PAULSYNC_LAST));
        fclose($fp);
    }
    $admin = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), PAUL_SYNC_ADMIN_LOGIN);
    if (is_object($admin)) {
        $admin->mail("PAUL Sync summary for " . PATH_SERVER, $logdata != "" ? str_replace("\n", "<br />", $logdata) : "No log data");
    }
}
try {
    if (is_object($paulsync_folder)) {
        $paulsync_folder->set_attribute("PAUL_SYNC_ENDTIME", time());
        $paulsync_folder->set_attribute("PAUL_SYNC_RUNNING", "FALSE");
    }
    $GLOBALS["STEAM"]->disconnect();
} catch (Exception $e) {
    paul_sync_log("PAUL_SYNC\tWARNING\tError disconnecting from steam error=" . $e->getMessage(), PAUL_SYNC_LOGLEVEL_WARNING);
}
Example #7
0
 /**
  * function get-user:
  *
  * Returns a steam_user instance by its login-name
  *
  * @param steam_connector $pSteamConnector connection to sTeam-server
  * @param string $pUserName user's login name
  * @param Boolean $pBuffer Send now or buffer request?
  * @return steam_user the user object
  */
 public static function get_user($pSteamConnectorID, $pUserName, $pBuffer = 0)
 {
     if (!is_string($pSteamConnectorID)) {
         throw new ParameterException("pSteamConnectorID", "string");
     }
     return steam_factory::username_to_object($pSteamConnectorID, $pUserName, $pBuffer);
 }
Example #8
0
}
$backlink = $group->get_url();
if (!$group->is_admin($user)) {
    throw new Exception("No admin of " . $group->get_groupname() . ": " . $user->get_name());
}
if (!empty($_REQUEST["selected_user"])) {
    $selected_users = array_keys($_REQUEST["selected_user"]);
}
if (!empty($_REQUEST["add"]) && count($_REQUEST["add"]) > 0) {
    $selected_users = array(key($_REQUEST["add"]));
}
if (isset($selected_users) && count($selected_users) > 0) {
    $confirmations = array();
    $problems = array();
    foreach ($selected_users as $login) {
        $new_member = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $login);
        if ($group->add_member($new_member)) {
            $confirmations[] = h($new_member->get_full_name());
            // PROCEDURE FOR COURSE ADMINS
            if ($group->get_attribute("OBJ_TYPE") == "course_staff") {
                // TODO: fct to add an admin? set_sanction_all does not seem to work... :(
                $steam_group->set_sanction_all($new_member);
            }
            if ($group->get_attribute("OBJ_TYPE") == "course_tutorial" || $group->get_attribute("OBJ_TYPE") == "group_tutorial_koala") {
                $no_of_learners = (int) $group->get_attribute("GROUP_NO_MEMBERS");
                $group->set_attribute("GROUP_NO_MEMBERS", $no_of_learners + count($_REQUEST["add"]));
            }
            $group_name = koala_object::get_koala_object($group)->get_display_name();
            $message = str_replace("%NAME", $new_member->get_full_name(), gettext("Dear %NAME,")) . "\n\n";
            $message .= str_replace("%GROUP", $group_name, gettext("You were added to '%GROUP' as a new member.")) . "\n\n";
            $message .= gettext("This is an automatically generated message.") . " " . gettext("If you haven't been informed about this membership in advance, please contact the sender of this message.") . "\n\n" . str_replace("%GROUP", "<a href=\"" . $backlink . "\">" . $group_name . "</a>", gettext("See '%GROUP' for further information."));
Example #9
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     $group_id = $path[1];
     $content = \Semester::getInstance()->loadTemplate("search_persons.template.html");
     if (!($steam_group = \steam_factory::get_object($GLOBALS['STEAM']->get_id(), $group_id))) {
         throw new \Exception('Group not found: ' . $group_id);
     }
     if (!$steam_group instanceof \steam_group) {
         throw new \Exception('Is not a group: ' . $group_id);
     }
     // always try to use the correct specialized group:
     if (!isset($group)) {
         $group = \koala_object::get_koala_object($steam_group);
     } else {
         if ($group instanceof \koala_object) {
             $group = \koala_object::get_koala_object($group->get_steam_object());
         } else {
             throw new \Exception("No 'group' param provided");
         }
     }
     // TODO: Passt der Link?
     $backlink = $group->get_url();
     if (!$group->is_admin($user)) {
         throw new \Exception("No admin of " . $group->get_groupname() . ": " . $user->get_name());
     }
     if (!empty($_REQUEST["add"]) && count($_REQUEST["add"]) > 0) {
         $login = key($_REQUEST["add"]);
         $new_member = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $login);
         if ($group instanceof \koala_group_tutorial) {
             if ($group->get_course_group()->get_attribute("EXCLUSIVE_TUTORIAL_MEMBERSHIP") === "TRUE") {
                 $course_learners_group = $group->steam_group_course_learners;
                 $subgroups = $course_learners_group->get_subgroups();
                 foreach ($subgroups as $sg) {
                     if (($sg->get_attribute("OBJ_TYPE") === "course_tutorial" || $sg->get_attribute("OBJ_TYPE") === "group_tutorial_koala") && $sg->is_member($new_member) && $sg != $steam_group) {
                         $already_member_and_exclusive = true;
                         $in_group = $sg;
                     }
                 }
             }
         }
         if (isset($already_member_and_exclusive) && $already_member_and_exclusive) {
             if (!isset($_POST['confirmed']) || $_POST['confirmed'] != "true") {
                 $content->setVariable("WARNING_TEXT", "<p/>" . gettext("Attention! The user you want to add already became member in another tutorial in the meantime."));
             }
             if (isset($_POST['confirmed']) && $_POST['confirmed'] === "true") {
                 if ($group->add_member($new_member)) {
                     // PROCEDURE FOR COURSE ADMINS
                     if ($group->get_attribute("OBJ_TYPE") === "course_staff") {
                         // TODO: fct to add an admin? set_sanction_all does not seem to work... :(
                         $steam_group->set_sanction_all($new_member);
                     }
                     if ($group->get_attribute("OBJ_TYPE") == "course_tutorial" || $group->get_attribute("OBJ_TYPE") == "group_tutorial_koala") {
                         $no_of_learners = (int) $group->get_attribute("GROUP_NO_MEMBERS");
                         $group->set_attribute("GROUP_NO_MEMBERS", $no_of_learners + count($_REQUEST["add"]));
                     }
                     $group_name = \koala_object::get_koala_object($group)->get_display_name();
                     $message = str_replace("%NAME", $new_member->get_full_name(), gettext("Dear %NAME,")) . "\n\n";
                     $message .= str_replace("%GROUP", $group_name, gettext("You were added to '%GROUP' as a new member.")) . "\n\n";
                     $message .= gettext("This is an automatically generated message.") . " " . gettext("If you haven't been informed about this membership in advance, please contact the sender of this message.") . "\n\n" . str_replace("%GROUP", "<a href=\"" . $backlink . "\">" . $group_name . "</a>", gettext("See '%GROUP' for further information."));
                     \lms_steam::mail($new_member, $user, PLATFORM_NAME . ": " . str_replace("%GROUP", h($group_name), gettext("You were added to '%GROUP' as a new member")), $message);
                     $cache = get_cache_function($new_member->get_name());
                     $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), TRUE);
                     $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), FALSE);
                     $cache->drop("lms_steam::user_get_groups", $new_member->get_name());
                     $cache->drop("lms_steam::user_get_profile", $new_member->get_name());
                     $cache->drop("lms_portal::get_menu_html", $new_member->get_name(), TRUE);
                     $cache = get_cache_function($group->get_id());
                     $cache->drop("lms_steam::group_get_members", $group->get_id());
                     $portal->set_confirmation(str_replace("%NAME", $new_member->get_full_name(), gettext("%NAME successfully added to group.")));
                 }
             }
         } else {
             if ($group->add_member($new_member)) {
                 // PROCEDURE FOR COURSE ADMINS
                 if ($group->get_attribute("OBJ_TYPE") === "course_staff") {
                     // TODO: fct to add an admin? set_sanction_all does not seem to work... :(
                     $steam_group->set_sanction_all($new_member);
                 }
                 if ($group->get_attribute("OBJ_TYPE") == "course_tutorial" || $group->get_attribute("OBJ_TYPE") == "group_tutorial_koala") {
                     $no_of_learners = (int) $group->get_attribute("GROUP_NO_MEMBERS");
                     $group->set_attribute("GROUP_NO_MEMBERS", $no_of_learners + count($_REQUEST["add"]));
                 }
                 $group_name = \koala_object::get_koala_object($group)->get_display_name();
                 $message = str_replace("%NAME", $new_member->get_full_name(), gettext("Dear %NAME,")) . "\n\n";
                 $message .= str_replace("%GROUP", $group_name, gettext("You were added to '%GROUP' as a new member.")) . "\n\n";
                 $message .= gettext("This is an automatically generated message.") . " " . gettext("If you haven't been informed about this membership in advance, please contact the sender of this message.") . "\n\n" . str_replace("%GROUP", "<a href=\"" . $backlink . "\">" . $group_name . "</a>", gettext("See '%GROUP' for further information."));
                 \lms_steam::mail($new_member, $user, PLATFORM_NAME . ": " . str_replace("%GROUP", h($group_name), gettext("You were added to '%GROUP' as a new member")), $message);
                 $cache = get_cache_function($new_member->get_name());
                 $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), TRUE);
                 $cache->drop("lms_steam::user_get_groups", $new_member->get_name(), FALSE);
                 $cache->drop("lms_steam::user_get_groups", $new_member->get_name());
                 $cache->drop("lms_steam::user_get_profile", $new_member->get_name());
                 $cache->drop("lms_portal::get_menu_html", $new_member->get_name(), TRUE);
                 $cache = get_cache_function($group->get_id());
                 $cache->drop("lms_steam::group_get_members", $group->get_id());
                 $portal->set_confirmation(str_replace("%NAME", $new_member->get_full_name(), gettext("%NAME successfully added to group.")));
             }
         }
     }
     if ($group->get_maxsize() > 0 && $group->get_maxsize() <= $group->count_members()) {
         $html_content = "<div class=\"infoBar\">" . gettext("The group is full! You can not add any further members, because the maximum size of the group has been reached. Please increase this value to add more members.") . "</div>";
     } else {
         $content->setVariable("HEAD_SEARCH", gettext("Search"));
         $content->setVariable("INFO_TEXT", gettext("Here you can lookup some people.") . " " . str_replace("%GROUP", $group->get_display_name(), gettext("You can add a search result as member to '<b>%GROUP</b>'.")));
         if (!empty($_REQUEST["pattern"])) {
             $content->setVariable("VALUE_PATTERN", $_REQUEST["pattern"]);
         }
         $content->setVariable("LABEL_CHECK_NAME", gettext("Name"));
         $content->setVariable("LABEL_CHECK_LOGIN", gettext("Email address or login"));
         $content->setVariable("LABEL_SEARCH", gettext("Search"));
         $content->setVariable("GROUP_ID", $group->get_id());
         $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
         // SEARCH RESULTS
         if (!empty($_REQUEST["pattern"])) {
             $cache = get_cache_function($user->get_name(), 60);
             $result = $cache->call("lms_steam::search_user", $_REQUEST["pattern"], $_REQUEST["lookin"]);
             if ($_REQUEST["lookin"] == "name") {
                 $content->setVariable("CHECKED_NAME", 'checked="checked"');
             } else {
                 $content->setVariable("CHECKED_LOGIN", 'checked="checked"');
             }
             // PROCEED RESULT SET
             $html_people = \Semester::getInstance()->loadTemplate("list_users.template.html");
             $no_people = count($result);
             if ($no_people > 0) {
                 if (isset($_REQUEST["backlink"])) {
                     $tmp_backlink = $_REQUEST["backlink"];
                 } else {
                     if (isset($backlink)) {
                         $tmp_backlink = $backlink;
                     }
                 }
                 //$start = $portal->set_paginator( 10, $no_people, "(" . gettext( "%TOTAL people in result set" ) . ")", "?pattern=" . $_REQUEST[ "pattern" ] . "&lookin=" . $_REQUEST[ "lookin" ] . "&group=" . $_REQUEST["group"] . "&backlink=" . $tmp_backlink );
                 $paginator = \lms_portal::get_paginator(10, $no_people, "(" . gettext("%TOTAL people in result set") . ")", "?pattern=" . $_REQUEST["pattern"] . "&lookin=" . $_REQUEST["lookin"] . "&group=" . $_REQUEST["group"] . "&backlink=" . $tmp_backlink);
                 $start = $paginator["startIndex"];
                 $end = $start + 10 > $no_people ? $no_people : $start + 10;
                 $html_people->setVariable("PAGINATOR", $paginator["html"]);
                 $html_people->setVariable("LABEL_CONTACTS", gettext("Results") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_people), gettext("%a-%z out of %s")) . ")");
                 $html_people->setCurrentBlock("BLOCK_CONTACT_LIST");
                 $html_people->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
                 $html_people->setVariable("LABEL_SUBJECT_AREA", gettext("Subject area"));
                 $html_people->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
                 $html_people->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
                 for ($i = $start; $i < $end; $i++) {
                     $person = $result[$i];
                     $html_people->setCurrentBlock("BLOCK_CONTACT");
                     // TODO: Passt der Link?
                     $html_people->setVariable("CONTACT_LINK", PATH_URL . "user/" . $person["OBJ_NAME"] . "/");
                     // TODO: Passt der Link?
                     $icon_link = PATH_URL . "download/" . $person["OBJ_ICON"] . "/usericon/30/40";
                     $html_people->setVariable("CONTACT_IMAGE", $icon_link);
                     $html_people->setVariable("CONTACT_NAME", h($person["USER_FIRSTNAME"]) . " " . h($person["USER_FULLNAME"]));
                     $html_people->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . $person["OBJ_NAME"]);
                     $html_people->setVariable("LABEL_MESSAGE", gettext("Message"));
                     $html_people->setVariable("LABEL_SEND", gettext("Send"));
                     $html_people->setVariable("OBJ_DESC", h($person["OBJ_DESC"]));
                     $p = new \steam_object($GLOBALS["STEAM"]->get_id(), $person["OBJ_ID"]);
                     //if the group is a tutorial and the course has exclusive subgroups for tutorials set, we have to
                     //see if our person is already member in one of the other tutorials.
                     $already_member_and_exclusive = false;
                     if ($group instanceof \koala_group_tutorial) {
                         if ($group->get_course_group()->get_attribute("EXCLUSIVE_TUTORIAL_MEMBERSHIP") === "TRUE") {
                             $course_learners_group = $steam_group->get_parent_group();
                             $subgroups = $course_learners_group->get_subgroups();
                             foreach ($subgroups as $sg) {
                                 if (($sg->get_attribute("OBJ_TYPE") === "course_tutorial" || $sg->get_attribute("OBJ_TYPE") === "group_tutorial_koala") && $sg->is_member($p) && $sg != $steam_group) {
                                     $already_member_and_exclusive = true;
                                     $in_group = $sg;
                                 }
                             }
                         }
                     }
                     if (!$group->is_member($p)) {
                         if ($already_member_and_exclusive) {
                             $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><small><b>" . gettext("Attention: User already in tutorial") . " " . $in_group->get_name() . "<p /></b></small><input type=\"hidden\" name=\"confirmed\" value=\"true\"/><input type=\"submit\"  name=\"add[" . h($person["OBJ_NAME"]) . "]\" value=\"" . gettext("Add anyhow") . "\"/></td>");
                         } else {
                             $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"add[" . h($person["OBJ_NAME"]) . "]\" value=\"" . gettext("Add") . "\"/></td>");
                         }
                     } else {
                         $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\">" . gettext("Already a member.") . "</td>");
                     }
                     $html_people->parse("BLOCK_CONTACT");
                 }
                 $html_people->parse("BLOCK_CONTACT_LIST");
             } else {
                 $html_people->setVariable("LABEL_CONTACTS", gettext("No results."));
             }
             $content->setVariable("HTML_USER_LIST", $html_people->get());
         } else {
             $content->setVariable("CHECKED_NAME", 'checked="checked"');
         }
     }
     /*
     $portal->set_page_title( gettext( "Add member" ) );
     
     // give input focus to search field:
     $portal->add_javascript_onload("group_add_member", "document.getElementById('pattern').focus();");
     
     if(!isset($html_content))
     {
     	$portal->set_page_main(
     		array( $group->get_link(), array( "name" => gettext( "Add member" ) ) ),
     		$content->get(),
     		""
     		);
     } 
     else
     {
     	$portal->set_page_main(
     		array( $group->get_link(), array( "name" => gettext( "Add member" ) ) ),
     		$html_content,
     		""
     		);
     }
     $portal->show_html();
     */
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Example #10
0
 public function user_get_buddies($username, $confirmed = TRUE, $additional_attributes = array())
 {
     $result = array();
     $steam_user = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $username);
     if ($confirmed) {
         $confirmed_contacts = $steam_user->get_attribute("USER_CONTACTS_CONFIRMED");
         $buddies = array();
         if (!is_array($confirmed_contacts)) {
             $confirmed_contacts = array();
         }
         while (list($id, $confirmation) = each($confirmed_contacts)) {
             $buddy = new steam_user($GLOBALS["STEAM"]->get_id(), $id);
             // ignore invalid buddy entries:
             if (is_object($buddy)) {
                 $buddies[] = $buddy;
             }
         }
     } else {
         $buddies_tmp = $steam_user->get_attribute("USER_FAVOURITES");
         $buddies = array();
         // ignore invalid buddy entries:
         foreach ($buddies_tmp as $buddy) {
             if (is_object($buddy)) {
                 $buddies[] = $buddy;
             }
         }
     }
     $query = array("OBJ_NAME", "OBJ_DESC", "USER_FIRSTNAME", "USER_FULLNAME", "OBJ_ICON", "USER_PROFILE_FOCUS", "USER_PROFILE_FACULTY", "USER_ACADEMIC_TITLE");
     $query = array_merge($query, $additional_attributes);
     $no_buddies = count($buddies);
     $i = 0;
     steam_factory::load_attributes($GLOBALS["STEAM"]->get_id(), $buddies, $query);
     foreach ($buddies as $buddy) {
         if ($buddy instanceof steam_user) {
             $tmp = $buddy->get_attributes($query);
             if (!$confirmed) {
                 if ($steam_user->contact_is_confirmed($buddy)) {
                     $tmp["USER_CONFIRMED"] = 1;
                 } else {
                     $tmp["USER_CONFIRMED"] = 0;
                 }
             }
             $result[$i] = $tmp;
             if (is_object($result[$i]["OBJ_ICON"])) {
                 $result[$i]["OBJ_ICON"] = $result[$i]["OBJ_ICON"]->get_id();
             } else {
                 $result[$i]["OBJ_ICON"] = 0;
             }
             $result[$i]["OBJ_ID"] = $buddy->get_id();
             $i++;
         }
     }
     usort($result, "sort_buddies");
     return $result;
 }
Example #11
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     if (isset($path[0])) {
         if (\steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "courses." . $path[0]) instanceof \steam_group) {
             $current_semester = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "courses." . $path[0]);
         } else {
             header("Location: " . PATH_URL . "404/");
             die;
         }
     } else {
         $current_semester = \lms_steam::get_current_semester();
     }
     $current_semester_name = $current_semester->get_name();
     if (\lms_steam::is_steam_admin($user)) {
         if (!$portal->get_user()->is_logged_in()) {
             throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION);
         }
         $semester_admins = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $current_semester->get_groupname() . ".admins");
         $admin_group = new \koala_group_default($semester_admins);
         if ($_SERVER["REQUEST_METHOD"] == "POST") {
             $delete = $_POST["delete"];
             if (count($delete) == 1) {
                 $login = key($delete);
                 $admin = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $login);
                 $admin_group->remove_member($admin);
             }
         }
         $content = \Semester::getInstance()->loadTemplate("semester_admins.template.html");
         $content->setVariable("INFORMATION_ADMINS", str_replace("%SEMESTER", h($current_semester->get_attribute("OBJ_DESC")), gettext("These people are allowed to create courses for %SEMESTER.")) . " " . gettext("They can appoint other users as staff members/moderators for their own courses."));
         $content->setVariable("LINK_ADD_ADMIN", PATH_URL . "semester/addAdmin/" . $current_semester_name . "/" . $admin_group->get_id());
         $content->setVariable("LABEL_ADD_ADMIN", gettext("Add another admin"));
         //TODO: Messages extension schreiben
         // TODO: Passt der Link?
         $content->setVariable("LINK_MESSAGE", PATH_URL . "mail/write/" . $admin_group->get_id());
         $content->setVariable("LABEL_MESSAGE_ADMINS", gettext("Mail to admins"));
         $admins = $admin_group->get_members();
         $no_admins = count($admins);
         if ($no_admins > 0) {
             $content->setVariable("LABEL_ADMINS", gettext("Course admins"));
             $content->setCurrentBlock("BLOCK_CONTACT_LIST");
             $content->setVariable("LABEL_NAME_POSITION", gettext("Name") . "/" . gettext("Position"));
             $content->setVariable("LABEL_SUBJECT_AREA", gettext("Subject area"));
             $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
             $content->setVariable("LABEL_REMOVE_ADMIN", gettext("Action"));
             foreach ($admins as $admin) {
                 $adm_attributes = $admin->get_attributes(array("USER_FIRSTNAME", "USER_FULLNAME", "OBJ_DESC", "OBJ_ICON"));
                 $content->setCurrentBlock("BLOCK_CONTACT");
                 $content->setVariable("CONTACT_NAME", h($adm_attributes["USER_FIRSTNAME"]) . " " . h($adm_attributes["USER_FULLNAME"]));
                 // TODO: Profile Image einfügen
                 // TODO: Passt der Link?
                 $icon_link = \lms_user::get_user_image_url(30, 40);
                 $content->setVariable("CONTACT_IMAGE", $icon_link);
                 // TODO: Passt der Link?
                 $content->setVariable("CONTACT_LINK", PATH_URL . "user/" . $admin->get_name() . "/");
                 $content->setVariable("OBJ_DESC", h($adm_attributes["OBJ_DESC"]));
                 $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                 // TODO: Passt der Link?
                 $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "mail/write/" . $admin->get_name());
                 $content->setVariable("LABEL_SEND", gettext("Send"));
                 $content->setVariable("LABEL_REMOVE", gettext("Remove"));
                 $content->setVariable("CONTACT_ID", $admin->get_name());
                 $content->parse("BLOCK_CONTACT");
             }
             $content->parse("BLOCK_CONTACT_LIST");
         } else {
             $content->setVariable("LABEL_ADMINS", gettext("No admins found."));
         }
         /* TODO: Portal anpassen
         			$portal->set_page_title( h($current_semester->get_name()) . " Admins" );
         			$portal->set_page_main( 
         				array(
         					array( "link" => PATH_URL . SEMESTER_URL . "/" . h($current_semester->get_name()) . "/", "name" => h($current_semester->get_attribute( "OBJ_DESC" ))), array( "link" => "", "name" => gettext( "Admins" ) )
         				),
         				$content->get(),
         				""
         			);
         			$portal->show_html( );
         			*/
     } else {
         header("Location: " . PATH_URL . "404/");
         die;
     }
     $frameResponseObject->setTitle("Semester " . $current_semester_name);
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Example #12
0
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $content->setVariable("VALUE_SUBJECT", $subject);
        $content->setVariable("VALUE_BODY", $text);
    } else {
        $content->setVariable("VALUE_BODY", $signature . $new_body);
    }
}
// selection of the recievers
// if a buddy is given, there is no selection
// if a group is given, users can select the whole group or a set of members
// else users can select one or more of their buddies or groups
if (!empty($_GET["to"]) || isset($receiver) && $receiver instanceof steam_user) {
    // buddy given
    $content->setCurrentBlock("BLOCK_BUDDY_GIVEN");
    if (!isset($receiver)) {
        $receiver = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $_GET["to"]);
    }
    $content->setVariable("RECEIVER_NAME", $receiver->get_attribute("USER_FIRSTNAME") . " " . $receiver->get_attribute("USER_FULLNAME"));
    $icon_link = $receiver->get_attribute(OBJ_ICON) === 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "get_document.php?id=" . $receiver->get_attribute(OBJ_ICON)->get_id() . "&type=usericon&width=30&height=40";
    $content->setVariable("RECEIVER_IMAGE", $icon_link);
    $content->setVariable("RECEIVER_OBJ_ID", $receiver->get_id());
    $content->parse("BLOCK_BUDDY_GIVEN");
} elseif (!empty($_GET["group"]) || isset($receiver) && $receiver instanceof steam_group) {
    // group given
    $content->setCurrentBlock("BLOCK_GROUP_GIVEN");
    $content->setVariable("LABEL_SELECT_MEMBERS", gettext('Select members'));
    if (!isset($receiver) || !$receiver) {
        $receiver = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["group"]);
    }
    if (!$receiver instanceof steam_group) {
        throw new Exception("Group " . $_GET["group"] . " does not exist.");
Example #13
0
File: new.php Project: rolwi/koala
    $questionary = steam_factory::create_container($steam, $name, $current_room);
    $questions_folder = steam_factory::create_container($steam, 'questions', $questionary);
    $answers_folder = steam_factory::create_container($steam, 'answers', $questionary);
    if (isset($_POST["description"])) {
        $description = norm_post($_POST["description"]);
    } else {
        $description = "";
    }
    if ($questionary && $questions_folder && $answers_folder) {
        //set standard layout
        $layout = $templates[1];
        unset($layout["name_ge"]);
        unset($layout["name_en"]);
        //define rights for the attributes
        $loginuser_id = $steam->get_login_user()->get_id();
        $rootid = steam_factory::username_to_object($steam, "root")->get_id();
        $author_rights[$loginuser_id] = $loginuser_id;
        $editor_rights[$loginuser_id] = $loginuser_id;
        $analyst_rights[$loginuser_id] = $loginuser_id;
        $author_rights[$rootid] = $rootid;
        $editor_rights[$rootid] = $rootid;
        $analyst_rights[$rootid] = $rootid;
        //define container as questionary and set all attributes
        $attributes = array("bid:doctype" => "questionary", "bid:questionary:fillout" => "1", "bid:questionary:editanswer" => "1", "bid:questionary:editownanswer" => "0", "bid:questionary:number" => "1", "bid:questionary:resultcreator" => "1", "bid:questionary:resultcreationtime" => "1", "bid:questionary:description" => $description, "bid:questionary:edittime" => array(0, 0, 0), "bid:questionary:enabled" => false, "bid:questionary:layout" => $layout, "bid:questionary:author_rights" => $author_rights, "bid:questionary:editor_rights" => $editor_rights, "bid:questionary:analyst_rights" => $analyst_rights);
        $result = $questionary->set_attributes($attributes);
    }
}
//Disconnect
$steam->disconnect();
//on successfull creation do redirect
if (isset($result) && $result) {
Example #14
0
 public function search_user_posts($messageboard_id, $user_name)
 {
     if (defined("LOG_DEBUGLOG")) {
         $time1 = microtime(TRUE);
         logging::write_log(LOG_DEBUGLOG, "lms_forum::search_user_posts(" . $messageboard_id . ", " . $user_name . ") \t" . $GLOBALS["STEAM"]->get_login_user_name() . " \t" . $messageboard_id . " \t... ");
     }
     if (!($search_mod = $GLOBALS["STEAM"]->get_module("package:searchsupport"))) {
         throw new Exception("sTeam 'package:searchsupport' not installed.");
     }
     $messageboard = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $messageboard_id, CLASS_MESSAGEBOARD);
     $user = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $user_name);
     $search_results = $GLOBALS["STEAM"]->predefined_command($search_mod, "search_user_posts", array($messageboard, $user), 0);
     $result = lms_forum::get_discussions($messageboard->get_id(), $search_results);
     if (defined("LOG_DEBUGLOG")) {
         logging::append_log(LOG_DEBUGLOG, " \t" . round((microtime(TRUE) - $time1) * 1000) . " ms \t" . count($result));
     }
     return $result;
 }
Example #15
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $user = \lms_steam::get_current_user();
     $public = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_PUBLIC_GROUP, CLASS_GROUP);
     $id = $path[0];
     $portal = \lms_portal::get_instance();
     $portal_user = $portal->get_user();
     try {
         $steam_group = !empty($id) ? \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $id) : FALSE;
     } catch (\Exception $ex) {
         include "bad_link.php";
         exit;
     }
     $group_is_private = FALSE;
     if ($steam_group && is_object($steam_group)) {
         switch ((string) $steam_group->get_attribute("OBJ_TYPE")) {
             case "course":
                 $group = new \koala_group_course($steam_group);
                 // TODO: Passt der backlink?
                 $backlink = PATH_URL . SEMESTER_URL . "/" . $group->get_semester()->get_name() . "/" . h($group->get_name()) . "/";
                 break;
             default:
                 $group = new \koala_group_default($steam_group);
                 // TODO: Passt der backlink?
                 $backlink = PATH_URL . "groups/" . $group->get_id() . "/";
                 // Determine if group is public or private
                 $parent = $group->get_parent_group();
                 if ($parent->get_id() == STEAM_PRIVATE_GROUP) {
                     $group_is_private = TRUE;
                 }
                 break;
         }
     }
     if ($group_is_private) {
         if (!$steam_group->is_member($user) && !\lms_steam::is_koala_admin($user)) {
             throw new \Exception(gettext("You have no rights to access this group"), E_USER_RIGHTS);
         }
     }
     if (!$group instanceof \koala_group) {
         throw new \Exception("Variable group not set.");
     }
     if (COURSE_PARTICIPANTS_STAFF_ONLY && !$group->is_admin($user)) {
         header("location:../");
         exit;
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (is_array($_POST["remove"])) {
             $id = key($_POST["remove"]);
             $member_to_kick = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $id);
             $group->remove_member($member_to_kick);
             $portal->set_confirmation(str_replace("%NAME", h($member_to_kick->get_attribute("USER_FIRSTNAME")) . " " . h($member_to_kick->get_attribute("USER_FULLNAME")), gettext("User %NAME successfully removed from group members.")));
             // clear caches:
             $cache = get_cache_function($member_to_kick->get_name());
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), TRUE);
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), FALSE);
             $cache->drop("lms_steam::user_get_profile", $member_to_kick->get_name());
             $cache->drop("lms_portal::get_menu_html", $member_to_kick->get_name(), TRUE);
             $cache = get_cache_function($group->get_id());
             $cache->drop("lms_steam::group_get_members", $group->get_id());
         }
     }
     $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
     switch (get_class($group)) {
         case "koala_group_course":
             $html_handler_group = new \koala_html_course($group);
             $html_handler_group->set_context("members");
             $members = $cache->call("lms_steam::group_get_members", $group->steam_group_learners->get_id());
             break;
         default:
             $html_handler_group = new \koala_html_group($group);
             $html_handler_group->set_context("members");
             $members = $cache->call("lms_steam::group_get_members", $group->get_id());
             break;
     }
     $is_admin = $group->is_admin($user);
     $content = \Group::getInstance()->loadTemplate("list_users.template.html");
     $is_member = $group->is_member($user);
     //echo "is_member? " . $is_member;
     $privacy_deny_participants = $group->get_attribute("GROUP_PRIVACY");
     //echo "attribute: ''" . $privacy_deny_participants . "''";
     if ($privacy_deny_participants == PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS && !$is_member) {
         //echo "*** deny ***";
         //TODO
         $content->setVariable("LABEL_PRIVACY_DENY_PARTICIPANTS", gettext("Participants are hidden."));
     } else {
         //echo "*** permit ***";
         $no_members = count($members);
         if ($no_members > 0) {
             switch (get_class($group)) {
                 case "koala_group_course":
                     $groupname = $group->get_course_id();
                     break;
                 default:
                     $groupname = $group->get_name();
                     break;
             }
             if (!USER_LIST_NO_PAGEING) {
                 $paginator = \lms_portal::get_paginator(10, $no_members, "(" . str_replace("%NAME", h($groupname), gettext("%TOTAL members in %NAME")) . ")");
                 $start = $paginator["startIndex"];
                 $end = $start + 10 > $no_members ? $no_members : $start + 10;
                 $content->setVariable("PAGINATOR", $paginator["html"]);
                 $content->setVariable("LABEL_CONTACTS", gettext("Members") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_members), gettext("%a-%z out of %s")) . ")");
             } else {
                 //if (count($members) > 10) {
                 $content->setVariable("LABEL_CONTACTS", gettext("Members") . " (Anzahl " . count($members) . ")");
                 $content->setCurrentBlock("BLOCK_FILTER");
                 $content->setVariable("HELP_TEXT", "Benutzer lassen sich einfacher finden, indem Sie den Filter verwenden. Tippen Sie einfach einen Teil des Benutzernamen oder der Benutzerkennung in das Textfeld.");
                 $content->setVariable('LABEL_FILTER', "<b>" . gettext('Filter') . "</b>");
                 $start = 0;
                 $end = count($members);
                 if (COURSE_PARTICIPANTS_EXTENSIONS) {
                     $extensions = $group->get_extensions();
                     $html = "";
                     foreach ($extensions as $extension) {
                         $html .= $extension->get_filter_html($portal, "filter_user", "extension_data");
                     }
                     $content->setCurrentBlock("BLOCK_EXTENSION_FILTER");
                     $content->setVariable("EXTENSION_FILTER", $html);
                     $content->parse("BLOCK_EXTENSION_FILTER");
                 }
                 $content->parse("BLOCK_FILTER");
                 //}
             }
             $content->setCurrentBlock("BLOCK_CONTACT_LIST");
             $content->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
             !COURSE_PARTICIPANTS_FACULTY_AND_FOCUS or $content->setVariable("LABEL_SUBJECT_AREA", gettext("Origin/Focus"));
             !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
             if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
                 !COURSE_PARTICIPANTSLIST_MANAGE or $content->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
             }
             !COURSE_PARTICIPANTS_EXTENSIONS or $content->setVariable("TH_MANAGE_EXTENSIONS", "Status");
             $content->setVariable("BEGIN_HTML_FORM", "<form method=\"POST\" action=\"\">");
             $content->setVariable("END_HTML_FORM", "</form>");
             for ($i = $start; $i < $end; $i++) {
                 $member = $members[$i];
                 if ($member["USER_TRASHED"] === 1) {
                     continue;
                 }
                 $content->setCurrentBlock("BLOCK_CONTACT");
                 $content->setVariable("CONTACT_LINK", PATH_URL . "user/" . h($member["OBJ_NAME"]) . "/");
                 // TODO: Passt der link?
                 $icon_link = $member["OBJ_ICON"] == 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "cached/get_document.php?id=" . h($member["OBJ_ICON"]) . "&type=usericon&width=30&height=40";
                 $content->setVariable("CONTACT_IMAGE", $icon_link);
                 $title = !empty($member["USER_ACADEMIC_TITLE"]) ? h($member["USER_ACADEMIC_TITLE"]) . " " : "";
                 $content->setVariable("CONTACT_NAME", $title . h($member["USER_FIRSTNAME"]) . " " . h($member["USER_FULLNAME"]));
                 !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "messages_write.php?to=" . h($member["OBJ_NAME"]));
                 !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                 !COURSE_PARTICIPANTS_COMMUNICATION or $content->setVariable("LABEL_SEND", gettext("Send"));
                 !COURSE_PARTICIPANTS_FACULTY_AND_FOCUS or $content->setVariable("FACULTY_AND_FOCUS", h($member["USER_PROFILE_FACULTY"]));
                 if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
                     !COURSE_PARTICIPANTSLIST_MANAGE or $content->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"remove[" . h($member["OBJ_NAME"]) . "]\" value=\"" . gettext("Remove") . "\"/></td>");
                 }
                 if (COURSE_PARTICIPANTS_EXTENSIONS) {
                     $extensions = $group->get_extensions();
                     $result = "";
                     foreach ($extensions as $extension) {
                         $result .= $extension->get_member_info(\steam_factory::get_user($GLOBALS["STEAM"]->get_id(), $member["OBJ_NAME"]), $group);
                     }
                     $content->setVariable("EXTENSIONS_DATA", $result);
                 }
                 $member_desc = empty($member["OBJ_DESC"]) ? "student" : $member["OBJ_DESC"];
                 $status = secure_gettext($member_desc);
                 $content->setVariable("OBJ_DESC", h($status) . " " . ($i + 1));
                 $content->parse("BLOCK_CONTACT");
             }
             $content->parse("BLOCK_CONTACT_LIST");
         } else {
             $content->setVariable("LABEL_NO_MEMBERS", gettext("No members found."));
         }
     }
     $html_handler_group->set_html_left($content->get());
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($html_handler_group->get_html());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Example #16
0
 }
 $new_course = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $values["id"], $current_semester, FALSE, $values["name"]);
 $new_course->set_attributes(array("OBJ_TYPE" => "course", "COURSE_PARTICIPANT_MNGMNT" => $obj_type, "COURSE_SEMESTER" => $values["semester"], "COURSE_TUTORS" => $values["tutors"], "COURSE_SHORT_DSC" => $values["short_dsc"], "COURSE_LONG_DSC" => $values["long_dsc"], "COURSE_NAME_EN" => $values["name_en"], "COURSE_NUMBER" => $values["number"], "COURSE_PAUL_SEMESTER_ID" => $values["paul_semester_id"], "COURSE_PAUL_SEMESTER_NAME" => $values["paul_semester_name"], "COURSE_HOURS_IN_WEEK" => $values["hours_in_week"], "COURSE_FACULTY_ID" => $values["faculty_id"], "COURSE_FACULTY_NAME" => $values["faculty_name"], "COURSE_SMALL_GROUPS" => $values["small_groups"], "COURSE_EVENT_TYPE" => $values["event_type"], "COURSE_ASSOCIATED_SMALL_GROUPS" => $course_associated_small_groups));
 $learners = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "learners", $new_course, FALSE, "Participants of course '" . $values["name"] . "'");
 $learners->set_attribute("OBJ_TYPE", "course_learners");
 $staff = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "staff", $new_course, FALSE, "Tutors of course '" . $values["name"] . "'");
 $admins = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "admins", $new_course, FALSE, "Admins of course '" . $values["name"] . "'");
 $staff->set_attribute("OBJ_TYPE", "course_staff");
 $staff->set_attribute("OBJ_TYPE", "course_admins");
 $staff->add_member($user);
 $hide_user = true;
 //add the instructors/tutors
 if (strlen($values["tutors_obj_name"]) > 0) {
     $paul_tutors_obj_name = explode("+", $values["tutors_obj_name"]);
     foreach ($paul_tutors_obj_name as $paul_tutor_obj_name) {
         $paul_tutor = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $paul_tutor_obj_name);
         if ($paul_tutor->get_id() === $user->get_id()) {
             $hide_user = false;
         }
         $staff->add_member($paul_tutor);
         // Falls konfiguriert, automatische E-Mail-Benachrichtigung der Instructors
         if (defined("PAUL_INSTRUCTOR_NOTIFICATION") && PAUL_INSTRUCTOR_NOTIFICATION === TRUE) {
             $message = str_replace("%NAME", $paul_tutor->get_attribute("USER_FIRSTNAME") . " " . $paul_tutor->get_attribute("USER_FULLNAME"), gettext("Hallo %NAME,")) . "\n\n";
             $message .= str_replace("%GROUP", $course = $values["name"], gettext("You have been automatically added to the staff of course '%GROUP' because of your membership in that course in the PAUL system.")) . "\n\n";
             $message .= gettext("This is an automatically generated email.");
             lms_steam::mail($paul_tutor, lms_steam::get_current_user(), PLATFORM_NAME . ": " . str_replace("%GROUP", $course = $values["name"], gettext("You have been added to the staff of course '%GROUP'.")), $message);
         }
     }
 }
 if ($hide_user) {
     $new_course->set_attribute("COURSE_HIDDEN_STAFF", array($user->get_id()));