function get_context_menu($context, $params = array())
 {
     if (!isset($params["unit"])) {
         return array();
     }
     $unit = $params["unit"];
     if (!$unit instanceof koala_container_pyramiddiscussion) {
         return array();
     }
     if (!isset($params["owner"])) {
         throw new Exception("No 'owner' param provided.", E_PARAMETER);
     }
     $owner = $params["owner"];
     if (isset($params["container"])) {
         $container = koala_object::get_koala_object($params["container"]);
     } else {
         $container = $unit;
     }
     if (!$container instanceof koala_container_pyramiddiscussion) {
         return array();
     }
     $context_menu = array();
     $subcontext = $context;
     if (isset($params["subcontext"])) {
         $subcontext = $params["subcontext"];
     }
     switch ($subcontext) {
         case "unit":
             return $container->get_context_menu($context, $params);
             break;
     }
     return $context_menu;
 }
 protected function get_link_path_internal($top_object)
 {
     $koala_creator = koala_object::get_koala_object(lms_steam::get_root_creator($this->steam_object));
     $link_path = $koala_creator->get_link_path($top_object);
     $link_path[] = array("name" => $this->get_display_name(), "link" => $koala_creator->get_url() . "units/" . $this->get_id() . "/", "koala_obj" => $this, "obj" => $this->steam_object);
     return $link_path;
 }
示例#3
0
 /**
  * Set up a koala_user for a steam_user.
  *
  * @param Object $steam_user the steam_user that shall be
  *   represented by the koala_user
  */
 public function __construct($steam_user)
 {
     if (!is_object($steam_user) || !$steam_user instanceof steam_user) {
         throw new Exception("No valid steam_user provided", E_PARAMETER);
     }
     parent::__construct($steam_user);
 }
示例#4
0
 public function __construct($group)
 {
     if (!$group instanceof steam_group) {
         throw new Exception("Param is not a steam_group");
     }
     parent::__construct($group);
 }
 protected function get_link_path_internal($top_object)
 {
     $koala_creator = koala_object::get_koala_object($this->steam_object->get_creator());
     $link_path = $koala_creator->get_link_path($top_object);
     if (!$top_object instanceof koala_object) {
         $top_object = koala_object::get_koala_object($top_object);
     }
     // communication:
     if ($top_object instanceof lms_weblog || $top_object instanceof lms_wiki || $top_object instanceof lms_forum) {
         $link_path[] = array("name" => gettext("Communication"), "link" => $koala_creator->get_url() . "communication/", "koala_obj" => $this, "obj" => $this->steam_object);
     }
     $link_path[] = array("name" => $this->get_display_name(), "link" => $koala_creator->get_url() . "documents/", "koala_obj" => $this, "obj" => $this->steam_object);
     return $link_path;
 }
示例#6
0
 function __construct($description_file)
 {
     $em = extensionmanager::get_extensionmanager();
     $this->description_file = $description_file;
     $this->values = $this->parse_description_file($this->description_file);
     $this->name = $this->values['name'];
     $this->path = $this->values['path'];
     $this->description = $this->values['description'];
     $this->obj_type = $this->values['obj_type'];
     $this->classtype = $this->values['classtype'];
     $this->category = $this->values['category'];
     $this->enabled_default = $this->values['enabled_default'] === "TRUE" ? TRUE : FALSE;
     $this->requirements = $this->values['req_modules'];
     parent::__construct(steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), "/config/koala/extensions/" . $this->get_name()));
 }
示例#7
0
 protected function get_link_path_internal($top_object)
 {
     $parent = $this->steam_object->get_environment();
     if (!is_object($parent)) {
         $parent = $this->steam_object->get_creator();
         $koala_parent = koala_object::get_koala_object($parent);
         $link_path[-1] = $koala_parent->get_link_path($top_object);
         $link_path[] = array("name" => $this->get_display_name(), "koala_obj" => $this, "obj" => $this->steam_object);
         return $link_path;
     }
     if ($parent instanceof steam_user) {
         $koala_parent = new koala_container_clipboard($parent);
     } else {
         $koala_parent = koala_object::get_koala_object($parent);
     }
     $link_path = $koala_parent->get_link_path($top_object);
     $link = array("name" => $this->get_display_name(), "koala_obj" => $this, "obj" => $this->steam_object);
     if (isset($link_path[0]["link"])) {
         $link["link"] = $link_path[0]["link"] . $this->get_id() . "/";
     }
     $link_path[] = $link;
     return $link_path;
 }
示例#8
0
    }
}
$content = new HTML_TEMPLATE_IT(PATH_TEMPLATES);
$content->loadTemplateFile("document_edit.template.html");
$content->setVariable("LABEL_HERE_IT_IS", "");
$content->setVariable("LABEL_NAME", gettext("Name"));
$content->setVariable("LABEL_REPLACE", gettext("Replace with file"));
$content->setVariable("LABEL_DESC", gettext("Description"));
$content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes"));
$content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
$content->setVariable("BACK_LINK", $backlink);
if (empty($values)) {
    $content->setVariable("VALUE_NAME", h($document->get_name()));
    $content->setVariable("VALUE_DESC", h($document->get_attribute("OBJ_DESC")));
} else {
    $content->setVariable("VALUE_NAME", h($values["name"]));
    $content->setVariable("VALUE_DESC", h($values["desc"]));
}
if ($max_file_size > 0) {
    $content->setVariable("MAX_FILE_SIZE_INPUT", "<input type='hidden' name='MAX_FILE_SIZE' value='" . (string) $max_file_size . "'/>");
    $content->setVariable("MAX_FILE_SIZE_INFO", "<br />" . str_replace("%SIZE", readable_filesize($max_file_size), gettext("The maximum allowed file size is %SIZE.")));
}
$koala_doc = koala_object::get_koala_object($document);
$link_path = $koala_doc->get_link_path();
if (!is_array($link_path)) {
    $link_path = array();
}
$link_path[] = array("name" => gettext("Preferences"));
$portal->set_page_main($link_path, $content->get(), "");
$portal->set_page_title(gettext("Edit Document"));
$portal->show_html();
示例#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;
 }
示例#10
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $group_id = $this->params[0];
     $portal = \lms_portal::get_instance();
     $portal->initialize(GUEST_NOT_ALLOWED);
     $user = \lms_steam::get_current_user();
     //TODO: Was soll dieses $em hier??
     //$em = \lms_steam::get_extensionmanager();
     if (!($steam_group = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $group_id))) {
         include "bad_link.php";
         exit;
     }
     if (!$steam_group instanceof \steam_group) {
         throw new \Exception("Is not a group: " . $_GET["id"]);
     }
     $group = \koala_object::get_koala_object($steam_group);
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if ($group instanceof \koala_group_course && !($group->is_staff($user) || $group->is_learner($user))) {
             //throw new \Exception( $user->get_name() . " is not a member of " . $group->get_groupname() );
             header("Location: " . $values["return_to"]);
             exit;
         }
         if ($group instanceof \koala_group_default && !$group->is_member($user)) {
             //throw new \Exception( $user->get_name() . " is not a member of " . $group->get_groupname() );
             header("Location: " . $values["return_to"]);
             exit;
         }
         $values = $_POST["values"];
         if (defined("LOG_DEBUGLOG")) {
             \logging::write_log(LOG_DEBUGLOG, "group_cancel\t" . $user->get_name() . " leaves " . $steam_group->get_identifier());
         }
         \logging::start_timer("leave_group");
         if ($group->remove_member($user)) {
             $group_name = $group->get_display_name();
             $short_confirmation = str_replace("%GROUP", $group_name, gettext("Your membership in the group '%GROUP' has been terminated."));
             $confirmation = str_replace("%NAME", $user->get_full_name(), gettext("Dear %NAME,")) . "\n\n" . $short_confirmation . "\n\n" . gettext("Your koaLA Team");
             \lms_steam::mail($user, "\"" . PLATFORM_NAME . " System\"<no_reply@" . STEAM_SERVER . ">", PLATFORM_NAME . ": " . str_replace("%GROUP", $group_name, gettext("Your membership in the group '%GROUP' has been terminated")), $confirmation);
             $cache = get_cache_function($user->get_name());
             $cache->drop("lms_steam::user_get_groups", $user->get_name(), TRUE);
             $cache->drop("lms_steam::user_get_groups", $user->get_name(), FALSE);
             $cache->drop("lms_steam::user_get_profile", $user->get_name());
             $cache->drop("lms_portal::get_menu_html", $user->get_name(), TRUE);
             $cache = get_cache_function($group->get_id());
             $cache->drop("lms_steam::group_get_members", $group->get_id());
             $_SESSION["confirmation"] = $short_confirmation;
             if (defined("LOG_DEBUGLOG")) {
                 \logging::append_log(LOG_DEBUGLOG, " runtime=" . \logging::print_timer("leave_group"));
             }
             header("Location: " . $values["return_to"]);
             exit;
         } else {
             throw new \Exception("Cannot delete membership.");
         }
         if (defined("LOG_DEBUGLOG")) {
             \logging::append_log(LOG_DEBUGLOG, "failed. runtime=" . \logging::print_timer("leave_group"));
         }
     }
     $content = \Group::getInstance()->loadTemplate("groups_cancel_membership.template.html");
     $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
     $content->setVariable("LABEL_RETURN", gettext("back"));
     if ($group instanceof \koala_group_course && !($group->is_staff($user) || $group->is_learner($user))) {
         if (empty($_SESSION['confirmation'])) {
             // don't warn if we came here on successful membership cancel...
             if ($group instanceof \koala_group_course) {
                 $portal->set_problem_description(gettext("You are not member of this course."));
             } else {
                 $portal->set_problem_description(gettext("You are not member of this group."));
             }
         }
     } else {
         if ($group instanceof \koala_group_default && !$group->is_member($user)) {
             if (empty($_SESSION['confirmation'])) {
                 // don't warn if we came here on successful membership cancel...
                 if ($group instanceof \koala_group_course) {
                     $portal->set_problem_description(gettext("You are not member of this course."));
                 } else {
                     $portal->set_problem_description(gettext("You are not member of this group."));
                 }
             }
         } else {
             $redirect = $_SERVER["HTTP_REFERER"];
             if ($group instanceof \koala_group_default && !$group->is_public()) {
                 $redirect = PATH_URL . "user/" . \lms_steam::get_current_user()->get_name() . "/groups/";
             }
             $content->setVariable("DELETE_BACK_LINK", $redirect);
             $content->setVariable("FORM_ACTION", PATH_URL . "group/cancelGroup/\t" . $group_id);
             $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure?"));
             $content->setVariable("INFO_CANCEL_MEMBERSHIP", str_replace("%NAME", $group->get_display_name(), gettext("You are going to cancel your membership in <b>'%NAME'</b>.")));
             $content->setVariable("BUTTON_SUBMIT", "<input type=\"submit\" name=\"values[delete]\"  value=\"" . gettext("Yes, cancel my membership") . "\"/>");
         }
     }
     /*
     $portal->set_page_main(
     								"",
     								$content->get(),
     								""
     								);
     $portal->show_html();
     */
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
示例#11
0
文件: unit_new.php 项目: rolwi/koala
<?php

define("PATH_TEMPLATES_UNITS_BASE", PATH_EXTENSIONS . "units_base/templates/");
require_once "classes/unitmanager.class.php";
$portal = lms_portal::get_instance();
$portal->initialize(GUEST_NOT_ALLOWED);
$user = lms_steam::get_current_user();
if (!isset($owner) && isset($_POST["owner"])) {
    $steam_owner = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), (int) $_POST["owner"]);
    $owner = koala_object::get_koala_object($steam_owner);
}
if (!$owner->is_admin($user)) {
    throw new Exception("No group admin!", E_ACCESS);
}
$um = unitmanager::create_unitmanager($owner);
$content_ready = FALSE;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $problems = "";
    $hints = "";
    if (empty($problems)) {
        if (isset($_POST["unit_new"]) && is_array($_POST["unit_new"])) {
            $unitname = array_keys($_POST["unit_new"]);
            $unitname = $unitname[0];
            $akt_unit = $um->get_unittype($unitname);
            if ($akt_unit != FALSE) {
                $akt_unit->set_course($owner);
                if (isset($_POST["values"])) {
                    include $akt_unit->get_path() . "/modules/" . $akt_unit->get_name() . "_new.php";
                    $content_ready = TRUE;
                    $html_ready = $unit_new_html;
                } else {
示例#12
0
    $content->setVariable("VALUE_VIEWED", str_replace("%x", count($readers), gettext("%x times")));
    $content->setVariable("VALUE_SIZE", get_formatted_filesize($document->get_content_size()));
} else {
    if ($document instanceof steam_container) {
        // CONTAINER
        $content->setCurrentBlock("BLOCK_CONTAINER");
        $content->setVariable("LABEL_OBJECTCOUNT", gettext("Contents"));
        $content->setVariable("VALUE_OBJECTCOUNT", str_replace("%COUNT", $document->count_inventory(), gettext("%COUNT Objects")));
        $content->parse("BLOCK_CONTAINER");
    } else {
        // DOCEXTERN
        $content->setCurrentBlock("BLOCK_DOCEXTERN");
        $content->setVariable("LABEL_URL", gettext("URL"));
        $content->setVariable("VALUE_URL", $document->get_attribute(DOC_EXTERN_URL));
        $content->parse("BLOCK_DOCEXTERN");
    }
}
$portal->set_rss_feed(PATH_URL . "services/feeds/document_public.php?id=" . $document->get_id(), gettext("Feed"), gettext("Subscribe to this document's newsfeed"));
$parent = $document->get_environment();
$link_path = -1;
if (is_object($parent)) {
    $parent = koala_object::get_koala_object($parent);
    if (is_object($parent) && $parent instanceof lms_wiki) {
        $link_path = lms_steam::get_link_path($document);
    }
}
if ($link_path === -1) {
    $link_path = koala_object::get_koala_object($document)->get_link_path();
}
$portal->set_page_main($link_path, $content->get(), "");
$portal->show_html();
示例#13
0
文件: units.php 项目: rolwi/koala
$current_user = lms_steam::get_current_user();
$um = unitmanager::create_unitmanager($course);
$html_handler = new koala_html_course($course);
$html_handler->set_context("units");
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES_UNITS_BASE . "units.template.html");
$container = $course->get_workroom();
$koala_container = new koala_container_units($container, $course->get_url() . 'units/');
$koala_container->set_owner($course);
$is_admin = $course->is_admin($current_user);
$units = array();
$units_tmp = $koala_container->get_inventory();
// Pre-load Atributes for all units to optimize requests
steam_factory::load_attributes($GLOBALS["STEAM"]->get_id(), $units_tmp, array(OBJ_TYPE, OBJ_NAME, OBJ_ICON, OBJ_DESC, "UNIT_TYPE", "UNIT_DISPLAY_TYPE"));
foreach ($units_tmp as $unit) {
    $koala_unit = koala_object::get_koala_object($unit);
    if (is_object($koala_unit) && method_exists($koala_unit, 'get_unit')) {
        $unit_class = $koala_unit->get_unit();
        if (is_object($unit_class) && method_exists($unit_class, 'is_enabled_for') && !$unit_class->is_enabled_for($owner)) {
            continue;
        }
    }
    $units[] = $unit;
}
if ($is_admin) {
    //clipboard:
    $koala_user = new koala_html_user(new koala_user($current_user));
    $clipboard_menu = $koala_user->get_clipboard_menu($koala_container);
    $content->setCurrentBlock("BLOCK_CLIPBOARD");
    $content->setVariable("CLIPBOARD_HTML", $clipboard_menu->get_html());
    $content->parse("BLOCK_CLIPBOARD");
示例#14
0
 * * $documents_root : steam_container that is the root of the document path
 *     hierarchy, e.g. $user (for the clipboard)
 * * $portal : a valid lms_portal instance
 * 
 * The following variables *may* be set before including this file:
 * * $container_icons : if set to FALSE, then no icons will be displayed for
 *      the inventory objects, otherwise the icons from the open-sTeam backend
 *      will be displayed.
 */
$current_user = lms_steam::get_current_user();
$cache = get_cache_function($user->get_name(), 86400);
$action = "";
if (isset($documents_path[0]) && is_numeric($documents_path[0])) {
    $backlink .= $documents_path[0] . "/";
    $container = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), (int) $documents_path[0], CLASS_CONTAINER);
    $koala_container = koala_object::get_koala_object($container);
    if (isset($documents_path[1])) {
        $action = $documents_path[1];
    }
} else {
    $container = $documents_root;
    $koala_container = new koala_container_clipboard($user);
    if (isset($documents_path[0])) {
        $action = $documents_path[0];
    }
}
$html_handler = new koala_html_user($user);
$html_handler->set_context("clipboard", array("koala_container" => $koala_container));
//$link_path = $koala_container->get_link_path();
switch ($action) {
    case "new-folder":
示例#15
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."));
         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(), 60);
         $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());
     } else {
         $problems[] = h($new_member->get_full_name());
     }
 }
 $portal->set_confirmation(str_replace('%NAME', implode(', ', $confirmations), gettext('%NAME successfully added to group.')));
 if (count($problems) > 0) {
     $portal->set_problem_description('%NAME', implode(', ', $problems), gettext('%NAME could not be added to group.'));
 public function get_url()
 {
     return koala_object::get_koala_object(lms_steam::get_root_creator($this->steam_object))->get_url() . "units/" . $this->get_id() . "/";
 }
示例#17
0
 protected function get_link_path_internal($top_object)
 {
     $parent = $this->steam_object->get_environment();
     if (!is_object($parent)) {
         $parent = $this->steam_object->get_creator();
         $koala_parent = koala_object::get_koala_object($parent);
         $link_path = array();
         $link_path[-1] = $koala_parent->get_link_path($top_object);
     } else {
         if ($parent instanceof steam_user) {
             $koala_parent = new koala_container_clipboard($parent);
         } else {
             $koala_parent = koala_object::get_koala_object($parent);
         }
         $link_path = $koala_parent->get_link_path($top_object);
     }
     $link = $this->get_link();
     $link["koala_obj"] = $this;
     $link["obj"] = $this->steam_object;
     $link_path[] = $link;
     return $link_path;
 }
示例#18
0
 function handle_path($path, $owner = FALSE, $portal = FALSE)
 {
     if (is_string($path)) {
         $path = url_parse_rewrite_path($path);
     }
     if (!is_object($owner)) {
         throw new Exception("No owner provided.", E_PARAMETER);
     }
     if (!isset($portal) || !is_object($portal)) {
         $portal = lms_portal::get_instance();
         $portal->initialize(GUEST_NOT_ALLOWED);
     }
     $portal_user = $portal->get_user();
     $user = lms_steam::get_current_user();
     $scg = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_COURSES_GROUP, CLASS_GROUP);
     //$current_semester = steam_factory::groupname_to_object( $GLOBALS[ "STEAM" ]->get_id(), $scg->get_name() . "." . $path[0]);
     $current_semester = $owner->get_semester();
     $backlink = $owner->get_url() . $this->get_path_name() . "/";
     //$backlink = PATH_URL . "extensions/units/" . $path[0] ."/" . $path[1] . "/units/";
     switch (TRUE) {
         case isset($path[0]) && $path[0] == "new":
             if (!$portal_user->is_logged_in()) {
                 throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION);
             }
             $course = $owner;
             include self::$PATH . "unit_new.php";
             exit;
             break;
         case isset($path[0]) && is_numeric($path[0]) && isset($path[1]) && $path[1] == "edit":
             if (!$portal_user->is_logged_in()) {
                 throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION);
             }
             $course = $owner;
             $steam_unit = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), (int) $path[0]);
             if (!is_object($steam_unit)) {
                 include PATH_PUBLIC . "bad_link.php";
                 exit;
             }
             global $unit;
             $unit = koala_object::get_koala_object($steam_unit);
             if (!is_object($unit)) {
                 include PATH_PUBLIC . "bad_link.php";
                 exit;
             }
             if (!$steam_unit->check_access_write($user)) {
                 throw new Exception(gettext("You have no write access for this unit"), E_USER_RIGHTS);
             }
             $backlink = $backlink . $path[0] . "/";
             include self::$PATH . "unit_edit.php";
             exit;
             break;
         case isset($path[0]) && is_numeric($path[0]) && isset($path[1]) && $path[1] == "delete":
             if (!$portal_user->is_logged_in()) {
                 throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION);
             }
             $course = $owner;
             $steam_unit = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), (int) $path[0]);
             if (!is_object($steam_unit)) {
                 include PATH_PUBLIC . "bad_link.php";
                 exit;
             }
             global $unit;
             $unit = koala_object::get_koala_object($steam_unit);
             if (!is_object($unit)) {
                 include PATH_PUBLIC . "bad_link.php";
                 exit;
             }
             if (!$steam_unit->check_access_write($user)) {
                 throw new Exception(gettext("You have no write access for this unit"), E_USER_RIGHTS);
             }
             $backlink = $backlink . $path[0] . "/";
             include self::$PATH . "unit_delete.php";
             exit;
             break;
         case isset($path[0]) && !empty($path[0]):
             if (!$portal_user->is_logged_in()) {
                 throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION);
             }
             if (!is_numeric($path[0])) {
                 return FALSE;
             }
             // not a unit id
             $steam_unit = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), (int) $path[0]);
             if (!is_object($steam_unit)) {
                 return FALSE;
             }
             // not a unit
             $unit_type = $steam_unit->get_attribute('UNIT_TYPE');
             if (!is_string($unit_type) || empty($unit_type)) {
                 return FALSE;
             }
             // not a valid unit
             $unit_extension = unitmanager::create_unitmanager($owner)->get_unittype($unit_type);
             if (!is_object($unit_extension)) {
                 return FALSE;
             }
             // no matching unit extension
             if ($unit_extension->handle_path($path, $owner, $portal)) {
                 exit;
             } else {
                 return FALSE;
             }
             break;
         default:
             if (!$portal_user->is_logged_in()) {
                 throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION);
             }
             $course = $owner;
             include self::$PATH . "units.php";
             exit;
             break;
     }
     return FALSE;
 }
 protected function get_link_path_internal($top_object)
 {
     return koala_object::get_koala_object($this->steam_object->get_creator())->get_link_path();
 }
示例#20
0
<?php

require_once "../etc/koala.conf.php";
require_once PATH_LIB . "format_handling.inc.php";
$portal = lms_portal::get_instance();
$portal->initialize(GUEST_NOT_ALLOWED);
$user = lms_steam::get_current_user();
$em = lms_steam::get_extensionmanager();
if (!($steam_group = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["group"]))) {
    include "bad_link.php";
    exit;
}
if (!$steam_group instanceof steam_group) {
    throw new Exception("Is not a group: " . $_GET["id"]);
}
$group = koala_object::get_koala_object($steam_group);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($group instanceof koala_group_course && !($group->is_staff($user) || $group->is_learner($user))) {
        //throw new Exception( $user->get_name() . " is not a member of " . $group->get_groupname() );
        header("Location: " . $values["return_to"]);
        exit;
    }
    if ($group instanceof koala_group_default && !$group->is_member($user)) {
        //throw new Exception( $user->get_name() . " is not a member of " . $group->get_groupname() );
        header("Location: " . $values["return_to"]);
        exit;
    }
    $values = $_POST["values"];
    if (defined("LOG_DEBUGLOG")) {
        logging::write_log(LOG_DEBUGLOG, "group_cancel\t" . $user->get_name() . " leaves " . $steam_group->get_identifier());
    }
示例#21
0
<?php

//TODO: check for trashbin and then check for move permission on the container in which the document is
if (!$document->check_access_write($user)) {
    throw new Exception($user->get_login() . ": no right to delete " . $document->get_id(), E_USER_RIGHTS);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $values = $_POST["values"];
    $doc_name = $document->get_name();
    $env = $document->get_environment();
    if (is_object($env) && is_object($koala_container = koala_object::get_koala_object($env))) {
        $backlink = $koala_container->get_url();
    }
    if (!isset($backlink) || empty($backlink)) {
        $upper_link = lms_steam::get_link_to_root($document);
        $backlink = $upper_link["link"];
    }
    if (lms_steam::delete($document)) {
        $_SESSION["confirmation"] = str_replace("%DOC_NAME", $doc_name, gettext("%DOC_NAME successfully deleted."));
        // DASS DAS DOKUMENT IRGENDWO IM CACHE LIEGT, IST MIR ZZT NICHT BEKANNT.
        // FALLS CACHE-BEREINIGUNG NOTWENDIG IST, DANN HIER.
        header("Location: " . $backlink);
        exit;
    } else {
        throw new Exception("Cannot delete document");
    }
}
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "document_delete.template.html");
$content->setVariable("FORM_ACTION", "");
$content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure?"));
示例#22
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->initialize(GUEST_NOT_ALLOWED);
     $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);
         }
     }
     $content = \Group::getInstance()->loadTemplate("membership_requests.template.html");
     $content->setVariable("INFO_TEXT", gettext("The people listed are interested in becoming a member of your group.") . " " . gettext("Here, you can choose wether to affirm their membership or cancel the request.") . " " . gettext("In both cases, the user concerned will automatically get informed by mail about your decision."));
     // always try to use the correct specialized group:
     if ($group instanceof \koala_object) {
         $group = \koala_object::get_koala_object($group->get_steam_object());
     } else {
         if ($group instanceof \steam_object) {
             $group = \koala_object::get_koala_object($group);
         } else {
             throw new \Exception("No 'group' param provided");
         }
     }
     $type = $group->get_attribute("OBJ_TYPE");
     switch ($type) {
         case "group_tutorial_koala":
             // TODO: Passt der backlink?
             $backlink = $backlink . "tutorials/" . $group->get_id() . "/";
             break;
         case "course_tutorial":
             // TODO: Passt der backlink?
             $backlink = $backlink . "tutorials/" . $group->get_id() . "/";
             break;
         default:
             // TODO: Passt der backlink?
             $backlink = $backlink . "members/";
     }
     if (!$group->is_admin($user)) {
         //				throw new Exception( $user->get_name() . " is no admin of " . $group->get_name() );
         header("Location: " . PATH_URL . "error.php?error=" . E_USER_RIGHTS);
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (isset($_POST['affirm']) && is_array($_POST['affirm'])) {
             $candidate = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), key($_POST["affirm"]));
             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($candidate) && $sg != $steam_group) {
                             $already_member_and_exclusive = true;
                             $in_group = $sg;
                         }
                     }
                 }
             }
             if ($already_member_and_exclusive) {
                 if (!isset($_POST['confirmed']) || $_POST['confirmed'] != "true") {
                     $content->setCurrentBlock("BLOCK_WARNING");
                     $content->setVariable("WARNING_TEXT", gettext("Attention! The user whose membership you wish to affirm already became member in another tutorial in the meantime."));
                     $content->parse("BLOCK_WARNING");
                 }
                 if (isset($_POST['confirmed']) && $_POST['confirmed'] === "true") {
                     $group->add_member($candidate);
                     $group->remove_membership_request($candidate);
                     $subject = str_replace("%GROUP", $group->get_name(), gettext("Welcome to '%GROUP'"));
                     $message = gettext("Your membership was affirmed.");
                     $portal->set_confirmation(str_replace("%NAME", $candidate->get_attribute("USER_FIRSTNAME") . " " . $candidate->get_attribute("USER_FULLNAME"), gettext("Membership of %NAME affirmed.")));
                     // uncache group members page:
                     $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
                     $cache->drop("lms_steam::group_get_members", $group->get_id());
                     // uncache menu so that course/group appears:
                     $cache = get_cache_function($candidate->get_name());
                     $cache->drop("lms_steam::user_get_profile", $candidate->get_name());
                     $cache->drop("lms_portal::get_menu_html", $candidate->get_name(), TRUE);
                 }
             } else {
                 $group->add_member($candidate);
                 $group->remove_membership_request($candidate);
                 $subject = str_replace("%GROUP", $group->get_name(), gettext("Welcome to '%GROUP'"));
                 $message = gettext("Your membership was affirmed.");
                 $portal->set_confirmation(str_replace("%NAME", $candidate->get_attribute("USER_FIRSTNAME") . " " . $candidate->get_attribute("USER_FULLNAME"), gettext("Membership of %NAME affirmed.")));
                 // uncache group members page:
                 $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
                 $cache->drop("lms_steam::group_get_members", $group->get_id());
                 // uncache menu so that course/group appears:
                 $cache = get_cache_function($candidate->get_name());
                 $cache->drop("lms_steam::user_get_profile", $candidate->get_name());
                 $cache->drop("lms_portal::get_menu_html", $candidate->get_name(), TRUE);
             }
         } elseif (isset($_POST['cancel']) && is_array($_POST['cancel'])) {
             $candidate = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), key($_POST["cancel"]));
             $group->remove_membership_request($candidate);
             $subject = str_replace("%GROUP", $group->get_name(), gettext("Your membership for '%GROUP' was rejected"));
             $message = gettext("Your membership was rejected.");
             $portal->set_confirmation(str_replace("%NAME", $candidate->get_attribute("USER_FIRSTNAME") . " " . $candidate->get_attribute("USER_FULLNAME"), gettext("Membership of %NAME rejected.")));
         }
         //$candidate->mail( $subject, $message, $user->get_attribute( "USER_EMAIL" ));
         \lms_steam::mail($candidate, $user, $subject, $message);
     }
     $result = $group->get_membership_requests();
     $html_people = \Group::getInstance()->loadTemplate("list_users.template.html");
     $no_people = count($result);
     if ($no_people > 0) {
         $paginator = \lms_portal::get_paginator(10, $no_people, "(" . gettext("%TOTAL membership requests") . ")");
         $start = $paginator["startIndex"];
         //$start = $portal->set_paginator( 10, $no_people, "(" . gettext( "%TOTAL membership requests" ). ")" );
         $end = $start + 10 > $no_people ? $no_people : $start + 10;
         $content->setVariable("PAGINATOR", $paginator["html"]);
         $html_people->setVariable("LABEL_CONTACTS", gettext("Membership requests") . " (" . 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"));
         foreach ($result as $candidate) {
             $person = $candidate->get_attributes(array("USER_FIRSTNAME", "USER_FULLNAME", "OBJ_ICON", "OBJ_NAME", "OBJ_DESC"));
             $html_people->setCurrentBlock("BLOCK_CONTACT");
             $html_people->setVariable("CONTACT_LINK", PATH_URL . "user/" . h($person["OBJ_NAME"]) . "/");
             if (is_object($person["OBJ_ICON"])) {
                 // TODO: Passt der link?
                 $icon_link = PATH_URL . "cached/get_document.php?id=" . $person["OBJ_ICON"]->get_id() . "&type=usericon";
             } else {
                 // TODO: Passt der link?
                 $icon_link = PATH_STYLE . "images/anonymous.jpg";
             }
             $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=" . h($person["OBJ_NAME"]));
             $html_people->setVariable("LABEL_MESSAGE", gettext("Message"));
             $html_people->setVariable("LABEL_SEND", gettext("Send"));
             //if the group is a tutorial and the course has exclusive subgroups for tutorials set, we have to
             //see if our candidate 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 = $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($candidate) && $sg != $steam_group) {
                             $already_member_and_exclusive = true;
                             $in_group = $sg;
                         }
                     }
                 }
             }
             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=\"affirm[" . $candidate->get_id() . "]\" value=\"" . gettext("Affirm anyhow") . "\"> " . gettext("or") . " <input type=\"submit\"  name=\"cancel[" . $candidate->get_id() . "]\" value=\"" . gettext("Decline") . "\"/></td>");
             } else {
                 $html_people->setVariable("TD_MANAGE_CONTACT", "<td align=\"center\"><input type=\"submit\"  name=\"affirm[" . $candidate->get_id() . "]\" value=\"" . gettext("Affirm") . "\"> " . gettext("or") . " <input type=\"submit\"  name=\"cancel[" . $candidate->get_id() . "]\" value=\"" . gettext("Decline") . "\"/></td>");
             }
             $html_people->setVariable("OBJ_DESC", h($person["OBJ_DESC"]));
             $html_people->parse("BLOCK_CONTACT");
         }
         $html_people->parse("BLOCK_CONTACT_LIST");
         $content->setVariable("HTML_USER_LIST", $html_people->get());
     } else {
         $content->setVariable("LABEL_NO_REQUESTS", "<h3>" . gettext("No membership request found.") . "</h3>");
     }
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
 function get_headline($headline = array(), $context = "", $params = array())
 {
     if (!isset($params["unit"])) {
         return FALSE;
     }
     if (!($params["unit"]->get_attribute("OBJ_TYPE") === "docextern_unit_koala")) {
         return FALSE;
     }
     $unit = koala_object::get_koala_object($params["unit"]);
     $headline[] = array("name" => $unit->get_name());
     return $headline;
 }
示例#24
0
    if (!isset($koala_container) && isset($container) && $container instanceof steam_container) {
        $koala_container = koala_object::get_koala_object($container);
    }
}
if (!isset($koala_container) || !is_object($koala_container)) {
    if ((!isset($environment) || !is_object($environment)) && empty($_GET["env"])) {
        throw new Exception("Environment not set.");
    }
    if (!(isset($environment) || !is_object($environment)) && !is_object($environment = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["env"]))) {
        throw new Exception("Environment unknown.");
    }
    if ($environment instanceof steam_user) {
        $environment_koala_container = new koala_container_clipboard($environment);
        $group = $environment;
    } else {
        $environment_koala_container = koala_object::get_koala_object($environment);
        $group = $environment_koala_container->get_koala_owner();
    }
} else {
    $group = $koala_container->get_koala_owner();
}
$backlink = empty($_POST["values"]["backlink"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["backlink"];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $values = $_POST["values"];
    if (empty($values["name"])) {
        $problems = gettext("You didn't specify a name for the new folder.");
        $hints = gettext("Please type in a name.");
    }
    if (strpos($values["name"], "/")) {
        if (!isset($problems)) {
            $problems = "";
示例#25
0
}
if (!isset($portal)) {
    $portal = lms_portal::get_instance();
    $portal->initialize(GUEST_NOT_ALLOWED);
}
$user = lms_steam::get_current_user();
$unitname = $unit->get_display_name();
if (!lms_steam::is_steam_admin($user) && !lms_steam::is_semester_admin($current_semester, $user) && !$course->is_admin($user)) {
    include "bad_link.php";
    exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($_POST["id"] == $unit->get_id()) {
        try {
            $unit->delete();
            $owner = koala_object::get_koala_object(steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["owner"]));
            $backlink = $owner->get_url() . "units/";
        } catch (Exception $exception) {
            $problems = $exception->get_message();
        }
    }
    if (empty($problems)) {
        $_SESSION["confirmation"] = str_replace("%NAME", $unitname, gettext("The unit '%NAME' has been deleted."));
        header("Location: " . $backlink);
        exit;
    } else {
        $portal->set_problem_description($problems, $hints);
    }
}
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES_UNITS_VILM . "units_vilm_delete.template.html");
示例#26
0
 public function get_clipboard_menu($koala_container = FALSE)
 {
     // clipboard:
     $clipboard_menu = array();
     $koala_clipboard = new koala_container_clipboard($this->koala_user->get_steam_object());
     if (is_object($koala_container)) {
         $may_insert = $koala_container->get_steam_object()->check_access_insert($this->koala_user->get_steam_object());
     } else {
         $may_insert = FALSE;
     }
     foreach ($koala_clipboard->get_inventory() as $item) {
         $koala_item = koala_object::get_koala_object($item);
         $menu_item = array();
         if ($item instanceof steam_container) {
             $menu_item["link"] = PATH_URL . "desktop/clipboard/" . $item->get_id() . "/";
         } else {
             $menu_item["link"] = PATH_URL . "doc/" . $item->get_id() . "/";
         }
         $menu_item["name"] = $koala_item->get_display_name();
         if (is_object($icon = $item->get_attribute("OBJ_ICON"))) {
             $menu_item["icon"] = "<img src='" . PATH_URL . "cached/get_document.php?id=" . $icon->get_id() . "&type=objecticon&width=16&height=16' />";
         }
         if ($may_insert && $koala_container->accepts_object($koala_item)) {
             $menu_item["menu"] = array(array("name" => gettext("drop object"), "link" => PATH_URL . "clipboard/drop/" . $item->get_id() . "/into/" . $koala_container->get_id(), "icon" => "<img title='Einfügen' src='" . PATH_STYLE . "images/paste.png' />"));
         }
         $clipboard_menu[] = $menu_item;
     }
     return new koala_html_menu(array(array("name" => gettext("Clipboard") . " (" . sizeof($clipboard_menu) . ")", "link" => $koala_clipboard->get_url(), "menu" => $clipboard_menu)));
 }
示例#27
0
        $content->setVariable("VALUE_NAME", h($values["name"]));
    }
    if (!empty($values["dsc"])) {
        $content->setVariable("VALUE_DESC", h($values["dsc"]));
    }
    if (!empty($values["url"])) {
        $content->setVariable("VALUE_URL", h($values["url"]));
    } else {
        $content->setVariable("VALUE_URL", "http://");
    }
    if (!empty($values["return_to"])) {
        $backlink = $values["return_to"];
    } else {
        $backlink = $_SERVER["HTTP_REFERER"];
    }
} else {
    $content->setVariable("VALUE_URL", "http://");
    $backlink = $_SERVER["HTTP_REFERER"];
}
$content->setVariable("BACK_LINK", $backlink);
$content->setVariable("LABEL_RETURN", gettext("back"));
$koala_env = koala_object::get_koala_object($env);
if (is_object($env) && is_object($koala_env)) {
    $link_path = $koala_env->get_link_path();
}
if (!is_array($link_path)) {
    $link_path = array();
}
$link_path[] = array("name" => $pagetitle);
$portal->set_page_main($link_path, $content->get(), "");
$portal->show_html();
示例#28
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     if (!($env = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["env"]))) {
         throw new \Exception("Environment unknown.");
     }
     $koala_env = \koala_object::get_koala_object($env);
     if (isset($_SERVER["HTTP_REFERER"])) {
         $http_referer = $_SERVER["HTTP_REFERER"];
     } else {
         $http_referer = "";
     }
     $backlink = empty($_POST["values"]["backlink"]) ? $http_referer : $_POST["values"]["backlink"];
     $max_file_size = parse_filesize(ini_get('upload_max_filesize'));
     $max_post_size = parse_filesize(ini_get('post_max_size'));
     if ($max_post_size > 0 && $max_post_size < $max_file_size) {
         $max_file_size = $max_post_size;
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $values = isset($_POST["values"]) ? $_POST["values"] : array();
         $problems = "";
         $hints = "";
         if (empty($_FILES) || !empty($_FILES["material"]["error"]) && $_FILES["material"]["error"] > 0) {
             if (!empty($_FILES) && empty($_FILES["material"]["name"])) {
                 $problems = gettext("No file chosen.") . " ";
                 $hints = gettext("Please choose a local file to upload.") . " ";
             } else {
                 $problems = gettext("Could not upload document.") . " ";
                 $hints = str_replace(array("%SIZE", "%TIME"), array(readable_filesize($max_file_size), (string) ini_get('max_execution_time')), gettext("Maybe your document exceeded the allowed file size (max. %SIZE) or the upload might have taken too long (max. %TIME seconds).")) . " ";
             }
         }
         if (empty($problems)) {
             $content = file_get_contents($_FILES["material"]["tmp_name"]);
             /*
             ob_start();
             readfile( $_FILES["material"]["tmp_name"] );
             $content = ob_get_contents();
             ob_end_clean();
             */
             if (defined("LOG_DEBUGLOG")) {
                 $time1 = microtime(TRUE);
                 \logging::write_log(LOG_DEBUGLOG, "upload" . " \t" . $GLOBALS["STEAM"]->get_login_user_name() . " \t" . $_FILES["material"]["name"] . " \t" . filesize($_FILES["material"]["tmp_name"]) . " Bytes \t... ");
             }
             $filename = str_replace(array("\\", "'"), array("", ""), $_FILES["material"]["name"]);
             $new_material = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $filename, $content, $_FILES["material"]["type"], FALSE);
             if (defined("LOG_DEBUGLOG")) {
                 \logging::append_log(LOG_DEBUGLOG, " \t" . round((microtime(TRUE) - $time1) * 1000) . " ms");
             }
             //  Disabled for Testing issues
             // upload($new_material->get_content_id(), $content);
             if (isset($values["dsc"])) {
                 $new_material->set_attribute("OBJ_DESC", $values["dsc"]);
             }
             $new_material->move($env);
             $_SESSION["confirmation"] = str_replace("%DOCUMENT", h($filename), gettext("'%DOCUMENT' has been uploaded."));
             header("Location: " . $backlink);
             exit;
         } else {
             $frameResponseObject->setProblemDescription($problems);
             $frameResponseObject->setProblemSolution($hints);
             //$portal->set_problem_description( $problems, $hints );
         }
     }
     $content = \Wiki::getInstance()->loadTemplate("upload.template.html");
     //$content = new HTML_TEMPLATE_IT( PATH_TEMPLATES );
     //$content->loadTemplateFile( "upload.template.html" );
     $content->setVariable("LABEL_UPLOAD", gettext("Upload"));
     $content->setVariable("LABEL_FILE", gettext("Local file"));
     $content->setVariable("LABEL_DSC", gettext("Description"));
     $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
     $content->setVariable("BACK_LINK", $backlink);
     $content->setVariable("FORM_ACTION", PATH_URL . "wiki/upload/" . (isset($_GET["env"]) ? "?env=" . $_GET["env"] : ""));
     if ($max_file_size > 0) {
         $content->setVariable("MAX_FILE_SIZE_INPUT", "<input type='hidden' name='MAX_FILE_SIZE' value='" . (string) $max_file_size . "'/>");
         $content->setVariable("MAX_FILE_SIZE_INFO", "<br />" . str_replace("%SIZE", readable_filesize($max_file_size), gettext("The maximum allowed file size is %SIZE.")));
     }
     $link_path = $koala_env->get_link_path();
     if (!is_array($link_path)) {
         $link_path = array();
     }
     $link_path[] = array("name" => gettext("Upload document"));
     if (!WIKI_FULL_HEADLINE) {
         $tmp_array = array();
         $elem_last = array_pop($link_path);
         $elem_first = array_pop($link_path);
         $tmp_array[] = $elem_first;
         $tmp_array[] = $elem_last;
         $link_path = $tmp_array;
     }
     //$portal->set_page_main( $link_path, $content->get() );
     //$portal->set_page_main( str_replace( "%ENV", $env->get_name(), gettext( "New upload in '%ENV'" ) ), $content->get() );
     //$portal->set_page_title( gettext( "Upload document" ) );
     //$portal->show_html();
     $frameResponseObject->setHeadline($link_path);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
示例#29
0
                } elseif ($group instanceof koala_group_default && !$group instanceof koala_group_course && $access == PERMISSION_GROUP_PUBLIC_CONFIRMATION || ($group instanceof koala_group_course || $group instanceof koala_group_tutorial) && $access == PERMISSION_COURSE_CONFIRMATION) {
                    $content->setVariable("LABEL_KIND_OF_GROUP", gettext("Moderated group"));
                    $content->setVariable("INFO_KIND_OF_GROUP", gettext("To avoid unauthorized access, the moderators of this group have to approve your membership request first, before you can join the group.") . " " . gettext("Here, you can fill out a membership request and send it.") . " " . gettext("You will get automatically informed by mail if your request succeeds."));
                    $content->setCurrentBlock("BLOCK_GROUP_MODERATED");
                    $content->setVariable("LABEL_REASON_TO_JOIN", gettext("Please provide some information about the reason why you should join this group."));
                    $content->parse("BLOCK_GROUP_MODERATED");
                    $content->setVariable("LABEL_SUBMIT", gettext("Send membership request"));
                } elseif ($group instanceof koala_group_course && $access == PERMISSION_COURSE_PAUL_SYNC) {
                    $content->setVariable("LABEL_KIND_OF_GROUP", gettext("PAUL Import"));
                    $content->setVariable("INFO_KIND_OF_GROUP", gettext("The participants of this course are imported from the PAUL system. To join this course make sure to join the course in PAUL. After your Registration for this course in PAUL, the automatic synchronization will add you to this course in koaLA automatically.") . "<br />" . gettext("Please note that the synchronization may take up to one hour.") . "<br /><b>" . gettext("The Synchronisation will start if the registration period in PAUL ends at 30.04.2009.") . "</b>");
                    $content->setVariable("SUBMIT_EXTRA", "style='display: none;'");
                    $printor = FALSE;
                } else {
                    $content->setVariable("LABEL_KIND_OF_GROUP", gettext("Public group"));
                    $content->setVariable("INFO_KIND_OF_GROUP", gettext("This is a public group everyone can join.") . " " . gettext("Please confirm your intention."));
                    $content->setVariable("LABEL_SUBMIT", gettext("Join this group"));
                }
                $content->setVariable("BACKLINK_FORM", $backlink);
                if (!isset($printor) || $printor) {
                    $content->setVariable("LABEL_OR", gettext("Or,"));
                }
                $content->setVariable("LABEL_RETURN", gettext("Return to the group's page"));
                $content->setVariable("BACK_LINK", "javascript:history.back();");
                $content->parse("BLOCK_FORM");
            }
        }
    }
}
$koala_group = koala_object::get_koala_object($group);
$portal->set_page_main(array(array("link" => $backlink, "name" => $koala_group->get_display_name()), array("link" => "", "name" => gettext("Subscribe"))), $content->get());
$portal->show_html();
示例#30
0
     }
     if ($obj->move($user)) {
         $msg = gettext("'%OBJECT' has been picked up from '%CONTAINER' and placed into your clipboard.");
         $_SESSION["confirmation"] = str_replace(array("%OBJECT", "%CONTAINER"), array($koala_obj->get_display_name(), $koala_container->get_display_name()), $msg);
         header("Location: " . $_SERVER["HTTP_REFERER"]);
         exit;
     } else {
         $msg = gettext("Could not pick up '%OBJECT' from '%CONTAINER' and place it into your clipboard.");
         $_SESSION["problem"] = str_replace(array("%OBJECT", "%CONTAINER"), array($koala_obj->get_display_name(), $koala_container->get_display_name()), $msg);
         header("Location: " . $_SERVER["HTTP_REFERER"]);
         exit;
     }
     break;
 case 'take-copy':
     $obj = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["id"]);
     $koala_obj = koala_object::get_koala_object($obj);
     $container = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["where"], CLASS_CONTAINER);
     $koala_container = new koala_container($container);
     if ($_GET["modifier"] != "from" || !is_object($obj) || !is_object($container)) {
         break;
     }
     $copy = steam_factory::create_copy($GLOBALS["STEAM"]->get_id(), $obj);
     if (!is_object($copy)) {
         $msg = gettext("Could not obtain a copy of '%OBJECT'.");
         $_SESSION["confirmation"] = str_replace(array("%OBJECT", "%CONTAINER"), array($koala_obj->get_display_name(), $koala_container->get_display_name()), $msg);
         header("Location: " . $_SERVER["HTTP_REFERER"]);
         exit;
     }
     if ($copy->move($user)) {
         $msg = gettext("A copy of '%OBJECT' has been placed into your clipboard.");
         $_SESSION["confirmation"] = str_replace(array("%OBJECT", "%CONTAINER"), array($koala_obj->get_display_name(), $koala_container->get_display_name()), $msg);