本文整理汇总了PHP中steam_factory::create_group方法的典型用法代码示例。如果您正苦于以下问题:PHP steam_factory::create_group方法的具体用法?PHP steam_factory::create_group怎么用?PHP steam_factory::create_group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类steam_factory
的用法示例。
在下文中一共展示了steam_factory::create_group方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_steam_group
function check_steam_group($group_name, $parent_group_name = NULL, $description = NULL, $fix = FALSE)
{
$parent_group = NULL;
if (is_string($parent_group_name)) {
$parent_group = steam_factory::get_group($GLOBALS["STEAM"]->get_id(), $parent_group_name);
if (!is_object($parent_group)) {
echo "Error: could not find parent group '" . $parent_group_name . "' for group '" . $group_name . "'.\n";
return FALSE;
}
}
$group_fullname = (is_string($parent_group_name) ? $parent_group_name . "." : "") . $group_name;
$group = steam_factory::get_group($GLOBALS["STEAM"]->get_id(), $group_fullname);
if (is_object($group)) {
return $group;
}
if (!$fix) {
echo "Error";
return FALSE;
}
$group = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $group_name, $parent_group, NULL, $description);
if (is_object($group)) {
echo "Created group '" . $group_fullname . "'.\n";
} else {
echo "Error: could not create group '" . $group_fullname . "'.\n";
}
return $group;
}
示例2: frameResponse
public function frameResponse(\FrameResponseObject $frameResponseObject)
{
$path = $this->params;
$portal = \lms_portal::get_instance();
$user = \lms_steam::get_current_user();
if (!\lms_steam::is_steam_admin($user)) {
//TODO: REDIRECT!!
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$values = $_POST["values"];
$start_date = iso_to_unix($values["start"]);
$end_date = iso_to_unix($values["end"]);
// TODO PROBLEM CHECKING MISSING
$courses = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_COURSES_GROUP, CLASS_GROUP);
$all_user = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_USER);
$new_semester = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $values["name"], $courses, FALSE, $values["desc"]);
$new_semester_admins = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "admins", $new_semester, FALSE, "admin group for " . $values["desc"]);
$new_semester_admins->set_attribute("OBJ_TYPE", "semester_admins");
$new_semester_admins->add_member($user);
$new_semester->set_insert_access($new_semester_admins, TRUE);
$new_semester->set_read_access($all_user, TRUE);
$new_semester->set_attributes(array("SEMESTER_START_DATE" => $start_date, "SEMESTER_END_DATE" => $end_date));
// CACHE ZURÜCKSETZEN
$cache = get_cache_function("ORGANIZATION");
$cache->drop("lms_steam::get_semesters");
header("Location: " . PATH_URL . "semester/index/" . $values["name"] . "/all");
}
$content = \Semester::getInstance()->loadTemplate("semester_create.template.html");
$content->setVariable("INFO_TEXT", gettext("So, you want to start a new semester?") . " " . gettext("Please fill out the requested values on the right.") . "<br/><br/>" . str_replace("%SEMESTER", STEAM_CURRENT_SEMESTER, gettext("And don't forget to reset the current semester in the etc/koala.def.php, which is <b>%SEMESTER</b> at the moment.")));
$content->setVariable("LABEL_NAME", gettext("Shortname"));
$content->setVariable("INFO_NAME", gettext("IMPORTANT: Don't use any slashes, commas or dots in this name. Keep it short, like 'WS0607' or 'SS06'."));
$content->setVariable("LABEL_DESC", gettext("Name"));
$content->setVariable("INFO_DESC", gettext("Examples: 'Wintersemester 06/07', or 'Sommersemester 2006'"));
$content->setVariable("LABEL_START_DATE", gettext("Starting date of semester"));
$content->setVariable("LABEL_END_DATE", gettext("Ending date of semester"));
$content->setVariable("INFO_DATE_FORMAT", gettext("Please type in the date in the following format: YYYY-MM-DD"));
$content->setVariable("LABEL_CREATE", gettext("Create Semester"));
/* TODO: Portal anpassen
$portal->set_page_main(
array(array("link" => PATH_URL.SEMESTER_URL."/", "name" => gettext("Semester")), array("link" => "", "name" => gettext("Create new"))),
$content->get(),
""
);
*/
$rawHtml = new \Widgets\RawHtml();
$rawHtml->setHtml($content->get());
$frameResponseObject->addWidget($rawHtml);
return $frameResponseObject;
}
示例3: execute
public function execute(\FrameResponseObject $frameResponseObject)
{
//echo SEMESTER_URL;die;
//$portal = \lms_portal::get_instance();
//$portal->initialize( GUEST_NOT_ALLOWED );
$user = \lms_steam::get_current_user();
$all_users = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_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_groupname() . "." . STEAM_CURRENT_SEMESTER);
if (!\lms_steam::is_steam_admin($user) && !lms_steam::is_semester_admin($current_semester, $user)) {
include "bad_link.php";
exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$values = $_POST["values"];
$problems = "";
$hints = "";
if (empty($values["semester"])) {
throw new Exception("Semester is not given.");
}
if (empty($values["id"])) {
$problems .= gettext("The course ID is missing.") . " ";
$hints .= gettext("The ID is necessary for unique identification, ordering and finding the course. Please fill this out.") . " ";
}
if (!empty($values["access"]) && $values["access"] == PERMISSION_COURSE_PASSWORD && empty($values["password"])) {
$problems .= gettext("The course password is missing.") . " ";
$hints .= gettext("You chose to password protect your course. Please provide a password.") . " ";
}
if (empty($problems) && !empty($values["get_lsf_infos"])) {
// INFOS UEBER LSF HOLEN
$lsf_client = new \hislsf_soap();
unset($_SESSION["LSF_COURSE_INFO"]);
// TODO: SEMESTER DYNAMISCH SETZEN
$result = $lsf_client->get_available_courses(SYNC_HISLSF_SEMESTER, $values["id"]);
if (isset($result->veranstaltung)) {
if (count($result->veranstaltung) == 1) {
header("Location: " . PATH_URL . "course/create" . "/" . $current_semester->get_name() . "/?lsf_course_id=" . $result->veranstaltung->Veranstaltungsschluessel);
exit;
} else {
header("Location: " . PATH_URL . "course" . "/" . $current_semester->get_name() . "/hislsf/" . $values["id"] . "/");
exit;
}
} else {
$problems = "Keine Veranstaltungen im LSF unter dieser Nummer gefunden.";
}
}
if (empty($problems)) {
if (empty($values["name"])) {
$problems .= gettext("The course name is missing.") . " ";
$hints .= gettext("A name is necessary for identification.") . " ";
}
if (strpos($values['id'], '.')) {
$problems .= gettext("Please don't use the \".\"-char in the course ID.") . ' ';
}
if (empty($values["tutors"])) {
$values["tutors"] = "NN";
}
if (empty($problems)) {
if (!isset($values["hislsf"]) || !$values["hislsf"]) {
$values["lsf_id"] = "";
}
$max_members = -1;
if ($values["lsf_id"] === "") {
if (!empty($values["maxsize"]) && trim($values["maxsize"]) != "" && preg_match('/[^-.0-9]/', trim($values["maxsize"]))) {
$problems .= gettext("Invalid max number of participants.") . " ";
$hints .= gettext("Please enter a valid number for the max number of participants.") . " " . gettext("Please note that the input of a '0' or to leave the field blank means no limitation.") . " ";
} else {
if (!empty($values["maxsize"]) && trim($values["maxsize"]) != "" && trim($values["maxsize"]) < 0) {
$problems .= gettext("Invalid max number of participants.") . " ";
$hints .= gettext("Please enter a number equal or greater than '0' for the max number of participants.") . " " . gettext("Please note that the input of a '0' or to leave the field blank means no limitation.") . " ";
} else {
if (isset($values["maxsize"])) {
if (trim($values["maxsize"]) === "") {
$max_members = 0;
} else {
$max_members = (int) trim($values["maxsize"]);
}
}
}
}
}
if (empty($problems)) {
try {
$new_course = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $values["id"], $current_semester, FALSE, $values["name"]);
} catch (Exception $e) {
$problems .= gettext("The course ID already exists.") . " ";
$hints .= gettext("The ID is necessary for unique identification, ordering and finding the course. This ID already exists.") . " ";
}
if (empty($problems)) {
$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_HISLSF_ID" => $values["lsf_id"]));
$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"] . "'");
$staff->set_attribute("OBJ_TYPE", "course_staff");
$staff->add_member($user);
$admins = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "admins", $new_course, FALSE, "Admins of course '" . $values["name"] . "'");
$admins->set_attribute("OBJ_TYPE", "course_admins");
// uncomment below if koala can handle admins vs tutors
//$admins->add_member( $user );
// RIGHTS MANAGEMENT =======================================
//.........这里部分代码省略.........
示例4: gettext
if (!$create_new && !$sizeproblems && isset($max_members) && $max_members > 0 && $max_members < $group->count_members()) {
$problems .= gettext("Cannot set max number of participants.") . " ";
$hints .= str_replace("%ACTUAL", $group->count_members(), str_replace("%CHOSEN", $max_members, gettext("You choosed to limit your group's max number of participants of %CHOSEN but your course already has %ACTUAL participants. If you want to set the max number of participants below %ACTUAL you have to remove some participants first."))) . " ";
}
if (!empty($values["access"]) && $values["access"] == PERMISSION_GROUP_PUBLIC_PASSWORD && empty($values["password"])) {
$problems .= gettext("The group password is missing.") . " ";
$hints .= gettext("You chose to password protect your group. Please provide a password.") . " ";
}
if (empty($problems)) {
$access = $values["access"];
$waspassword = 0;
if ($create_new) {
// CREATE
$akt_access = PERMISSION_GROUP_UNDEFINED;
$environment = !empty($values["category"]) ? steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $values["category"]) : FALSE;
$new_group = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $values["name"], $parentgroup, $environment, $values["short_dsc"]);
if (!is_object($new_group)) {
throw new Exception("Error creating group with name=" . $values["name"] . " in parent=" . $parentgroup->get_name(), E_PARAMETER);
exit;
}
$group = new koala_group_default($new_group);
$group->add_member(lms_steam::get_current_user());
} else {
// EDIT
$akt_access = $group->get_attribute(KOALA_GROUP_ACCESS);
}
if ($is_public) {
// PUBLIC
if ($akt_access == PERMISSION_GROUP_PUBLIC_PASSWORD) {
$waspassword = 1;
}
示例5: createCourse
public function createCourse($id, $courseID, $customerID)
{
$user = lms_steam::get_current_user();
$all_users = steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_USER);
$current_semester = steam_factory::get_group($GLOBALS["STEAM"]->get_id(), "Courses." . $this->getObjectName($customerID));
$elearning_course = elearning_mediathek::get_instance()->get_elearning_course_by_id($courseID);
$name = $elearning_course->get_name();
$new_course = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $id, $current_semester, FALSE, $name);
$icon_id = steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), "/packages/elearning_stahl_verkauf/icon_verkauf.jpg")->get_id();
$new_course->set_attributes(array("OBJ_TYPE" => "course", "COURSE_PARTICIPANT_MNGMNT" => 0, "COURSE_SEMESTER" => $this->getObjectName($customerID), "COURSE_TUTORS" => "", "COURSE_SHORT_DSC" => $elearning_course->get_description(), "COURSE_LONG_DSC" => "[img]" . PATH_SERVER . "/cached/get_document.php?id={$icon_id}&height=100[/img]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIn dieser Schulung möchten wir Ihnen die notwendigen Kenntnisse vermitteln, wie Sie ein Verkaufsgespräch gut führen – beginnend mit dem Blickkontakt, wenn eine Kundin oder ein Kunde Ihr Geschäft betritt, bis hin zur Verabschiedung, mit der Sie den Kunden hoffentlich mit dem Gefühl verabschieden, dass er bald wiederkommen wird.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOberhalb dieses Textes befindet sich eine Registerkarte »Lektionen«, über die Sie sich zunächst die Schulungsinhalte aneignen können. Auf diese Inhalte haben Sie jederzeit Zugriff; Sie können die Inhalte so oft durcharbeiten, wie Sie wünschen. Und Sie können dies von jedem an das Internet angeschlossenen Computer aus, also beispielsweise auch von zu Hause.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUm zu zeigen, dass Sie die Inhalte beherrschen, müssen Sie an einem Test teilnehmen. Dieser Test wird zu einem bestimmten Termin für Sie freigeschaltet. Sie erhalten dann zu gegebener Zeit eine Mitteilung, dass Sie zu dem Test zugelassen sind. Neben der Registerkarte, mit der Sie zu den Schulungsinhalten gelangen, finden Sie dann eine zusätzliche Registerkarte, mit der Sie den Test ablegen können.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSollten Sie auf Probleme stoßen – seien es technische, inhaltliche oder Fragen zur Benutzung dieses Systems – finden Sie Hilfe am oberen Rand dieser Seite. Außerdem können Sie jederzeit Kontakt zu Ihrem Ansprechpartner aufnehmen, der Ihnen gerne weiterhelfen wird.", "COURSE_HISLSF_ID" => "", "ACTIVATED_FOR_CUSTOMER" => $customerID));
$learners = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "learners", $new_course, FALSE, "Participants of course '" . $name . "'");
$learners->set_attribute("OBJ_TYPE", "course_learners");
$staff = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "staff", $new_course, FALSE, "Tutors of course '" . $name . "'");
$staff->set_attribute("OBJ_TYPE", "course_staff");
$admins = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "admins", $new_course, FALSE, "Admins of course '" . $name . "'");
$admins->set_attribute("OBJ_TYPE", "course_admins");
//$staff->add_member( $user );
// RIGHTS MANAGEMENT =======================================
$course_calendar = $new_course->get_calendar();
$learners_workroom = $learners->get_workroom();
$course_workroom = $new_course->get_workroom();
$staff->set_sanction_all($staff);
$staff->sanction_meta(SANCTION_ALL, $staff);
$learners->set_sanction_all($staff);
$learners->sanction_meta(SANCTION_ALL, $staff);
$new_course->set_sanction_all($staff);
$new_course->sanction_meta(SANCTION_ALL, $staff);
$admins->set_sanction_all($admins);
$admins->sanction_meta(SANCTION_ALL, $admins);
$staff->set_sanction_all($admins);
$staff->sanction_meta(SANCTION_ALL, $admins);
$learners->set_sanction_all($admins);
$learners->sanction_meta(SANCTION_ALL, $admins);
$new_course->set_sanction_all($admins);
$new_course->sanction_meta(SANCTION_ALL, $admins);
$course_calendar->set_acquire(FALSE);
$course_calendar->set_sanction_all($staff);
$course_calendar->sanction_meta(SANCTION_ALL, $staff);
$course_calendar->set_sanction_all($admins);
$course_calendar->sanction_meta(SANCTION_ALL, $admins);
$course_calendar->set_read_access($learners, TRUE);
$course_calendar->set_write_access($new_course, FALSE);
$course_calendar->set_insert_access($new_course, FALSE);
$course_calendar->set_insert_access($all_users, FALSE);
// Course workroom
$course_workroom->set_sanction($new_course, SANCTION_READ | SANCTION_EXECUTE | SANCTION_ANNOTATE);
$course_workroom->set_sanction_all($staff);
$course_workroom->set_sanction_all($admins);
$course_workroom->sanction_meta(SANCTION_ALL, $staff);
$course_workroom->sanction_meta(SANCTION_ALL, $admins);
// Learners workroom
$learners_workroom->set_read_access($all_users, TRUE);
$learners_workroom->set_sanction($learners, SANCTION_READ | SANCTION_EXECUTE | SANCTION_ANNOTATE);
$learners_workroom->set_sanction_all($staff);
$learners_workroom->set_sanction_all($admins);
$learners_workroom->sanction_meta(SANCTION_ALL, $staff);
$learners_workroom->sanction_meta(SANCTION_ALL, $admins);
$koala_course = new koala_group_course($new_course);
$koala_course->set_access(1, $learners, $staff, $admins, KOALA_GROUP_ACCESS);
$new_course->set_attributes(array("COURSE_UNITS_ENABLED" => "TRUE", "UNITS_DOCPOOL_ENABLED" => "TRUE", "UNITS_ELEARNING_ENABLED" => "TRUE", "UNITS_MEDIATHING_ENABLED" => "FALSE", "UNITS_ORGANIZATION_ENABLED" => "FALSE", "UNITS_VIDEOSTREAMING_ENABLED" => "FALSE"));
// create unit elearning
$env = $koala_course->get_workroom();
$new_unit_elearning_course = steam_factory::create_container($GLOBALS["STEAM"]->get_id(), $elearning_course->get_name(), $env, $elearning_course->get_description());
$new_unit_elearning_course->set_attributes(array("UNIT_TYPE" => "units_elearning", "OBJ_TYPE" => "elearning_unit_koala", "UNIT_DISPLAY_TYPE" => gettext("units_elearning"), "ELEARNING_UNIT_ID" => $courseID));
return true;
}
示例6: iso_to_unix
$portal = lms_portal::get_instance();
$portal->initialize(GUEST_NOT_ALLOWED);
$user = lms_steam::get_current_user();
if (!lms_steam::is_steam_admin($user)) {
include "bad_link.php";
exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$values = $_POST["values"];
$start_date = iso_to_unix($values["start"]);
$end_date = iso_to_unix($values["end"]);
// TODO PROBLEM CHECKING MISSING
$courses = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_COURSES_GROUP, CLASS_GROUP);
$all_user = steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_USER);
$new_semester = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $values["name"], $courses, FALSE, $values["desc"]);
$new_semester_admins = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "admins", $new_semester, FALSE, "admin group for " . $values["desc"]);
$new_semester_admins->set_attribute("OBJ_TYPE", "semester_admins");
$new_semester_admins->add_member($user);
$new_semester->set_insert_access($new_semester_admins, TRUE);
$new_semester->set_read_access($all_user, TRUE);
$new_semester->set_attributes(array("SEMESTER_START_DATE" => $start_date, "SEMESTER_END_DATE" => $end_date));
// CACHE ZUR�CKSETZEN
$cache = get_cache_function("ORGANIZATION");
$cache->drop("lms_steam::get_semesters");
header("Location: " . PATH_URL . SEMESTER_URL . "/" . $values["name"] . "/");
}
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "semester_create.template.html");
$content->setVariable("INFO_TEXT", gettext("So, you want to start a new semester?") . " " . gettext("Please fill out the requested values on the right.") . "<br/><br/>" . str_replace("%SEMESTER", STEAM_CURRENT_SEMESTER, gettext("And don't forget to reset the current semester in the etc/koala.def.php, which is <b>%SEMESTER</b> at the moment.")));
$content->setVariable("LABEL_NAME", gettext("Short name"));
$content->setVariable("INFO_NAME", gettext("IMPORTANT: Don't use any slashes, commas or dots in this name. Keep it short, like 'WS0607' or 'SS06'."));
示例7: catch
}
if (empty($problems)) {
try {
$new_course = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $values["id"], $current_semester, FALSE, $values["name"]);
} catch (Exception $e) {
$problems .= gettext("The course ID already exists.") . " ";
$hints .= gettext("The ID is necessary for unique identification, ordering and finding the course. This ID already exists.") . " ";
}
if (empty($problems)) {
$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_HISLSF_ID" => $values["lsf_id"]));
$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"] . "'");
$staff->set_attribute("OBJ_TYPE", "course_staff");
$staff->add_member($user);
$admins = steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "admins", $new_course, FALSE, "Admins of course '" . $values["name"] . "'");
$admins->set_attribute("OBJ_TYPE", "course_admins");
// uncomment below if koala can handle admins vs tutors
//$admins->add_member( $user );
// RIGHTS MANAGEMENT =======================================
$course_calendar = $new_course->get_calendar();
$learners_workroom = $learners->get_workroom();
$course_workroom = $new_course->get_workroom();
$staff->set_sanction_all($staff);
$staff->sanction_meta(SANCTION_ALL, $staff);
$learners->set_sanction_all($staff);
$learners->sanction_meta(SANCTION_ALL, $staff);
$new_course->set_sanction_all($staff);
$new_course->sanction_meta(SANCTION_ALL, $staff);
$admins->set_sanction_all($admins);
$admins->sanction_meta(SANCTION_ALL, $admins);
示例8: frameResponse
//.........这里部分代码省略.........
$problems .= gettext("Invalid max number of participants.") . " ";
$hints .= gettext("Please enter a valid number for the max number of participants.") . " " . gettext("Please note that the input of a '0' or to leave the field blank means no limitation.") . " ";
$sizeproblems = TRUE;
} else {
if (!empty($values["maxsize"]) && trim($values["maxsize"]) != "" && trim($values["maxsize"]) < 0) {
$problems .= gettext("Invalid max number of participants.") . " ";
$hints .= gettext("Please enter a number equal or greater than '0' for the max number of participants.") . " " . gettext("Please note that the input of a '0' or to leave the field blank means no limitation.") . " ";
$sizeproblems = TRUE;
} else {
if (isset($values["maxsize"])) {
if (trim($values["maxsize"]) === "") {
$max_members = 0;
} else {
$max_members = (int) trim($values["maxsize"]);
}
}
}
}
if (!$create_new && !$sizeproblems && isset($max_members) && $max_members > 0 && $max_members < $group->count_members()) {
$problems .= gettext("Cannot set max number of participants.") . " ";
$hints .= str_replace("%ACTUAL", $group->count_members(), str_replace("%CHOSEN", $max_members, gettext("You choosed to limit your group's max number of participants of %CHOSEN but your course already has %ACTUAL participants. If you want to set the max number of participants below %ACTUAL you have to remove some participants first."))) . " ";
}
if (!empty($values["access"]) && $values["access"] == PERMISSION_GROUP_PUBLIC_PASSWORD && empty($values["password"])) {
$problems .= gettext("The group password is missing.") . " ";
$hints .= gettext("You chose to password protect your group. Please provide a password.") . " ";
}
if (empty($problems)) {
$access = $values["access"];
$waspassword = 0;
if ($create_new) {
// CREATE
$akt_access = PERMISSION_GROUP_UNDEFINED;
$environment = !empty($values["category"]) ? \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $values["category"]) : FALSE;
$new_group = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $values["name"], $parentgroup, $environment, $values["short_dsc"]);
if (!is_object($new_group)) {
throw new \Exception("Error creating group with name=" . $values["name"] . " in parent=" . $parentgroup->get_name(), E_PARAMETER);
exit;
}
$group = new \koala_group_default($new_group);
$group->add_member(\lms_steam::get_current_user());
} else {
// EDIT
$akt_access = $group->get_attribute(KOALA_GROUP_ACCESS);
}
if ($is_public) {
// PUBLIC
if ($akt_access == PERMISSION_GROUP_PUBLIC_PASSWORD) {
$waspassword = 1;
}
if (!$accessmergel) {
$group->set_group_access($access);
}
if (isset($values) && $waspassword == 1 && isset($values["password"]) && $values["password"] == "******" && $values["access"] == PERMISSION_GROUP_PUBLIC_PASSWORD) {
// Do nothing in case of valid password dummy
} elseif ($values["access"] != PERMISSION_GROUP_PUBLIC_PASSWORD) {
$group->get_steam_group()->set_password("");
} else {
$group->get_steam_group()->set_password(isset($values["password"]) ? trim($values["password"]) : "");
}
if ($max_members > -1) {
$group->set_attribute(GROUP_MAXSIZE, $max_members);
}
} else {
// PRIVATE
// Set Group access only, if there is no problem with the access rights
// Set group access only for koala groups. Skip this for the steam only groups
示例9: ajaxResponse
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
{
$ajaxResponseObject->setStatus("ok");
if (!isset($this->params["group"])) {
$rawWidget = new \Widgets\RawHtml();
$rawWidget->setHtml("Error: Kurs oder Gruppe auswählen");
$ajaxResponseObject->addWidget($rawWidget);
return $ajaxResponseObject;
}
if ($this->params["group"] == 1) {
// course
if (!isset($this->params["course"])) {
$rawWidget = new \Widgets\RawHtml();
$rawWidget->setHtml("Error: Kurs oder Gruppe auswählen");
$ajaxResponseObject->addWidget($rawWidget);
return $ajaxResponseObject;
}
$course = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params["course"]);
$subgroups = $course->get_subgroups();
foreach ($subgroups as $subgroup) {
if ($subgroup->get_name() == "staff") {
$admingroup = $subgroup;
} else {
if ($subgroup->get_name() == "learners") {
$basegroup = $subgroup;
}
}
}
} else {
// group
if (!isset($this->params["basegroup"]) || !isset($this->params["admingroup"])) {
$rawWidget = new \Widgets\RawHtml();
$rawWidget->setHtml("Error: Kurs oder Gruppe auswählen");
$ajaxResponseObject->addWidget($rawWidget);
return $ajaxResponseObject;
}
$basegroup = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params["basegroup"]);
$admingroup = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params["admingroup"]);
}
$start = $this->params["startElements"];
$maxcol = intval(log($start, 2) + 1);
$pyramidRoom = \steam_factory::create_room($GLOBALS["STEAM"]->get_id(), $this->params["title"], $basegroup->get_workroom(), $this->params["title"]);
$pyramidRoom->set_sanction_all($admingroup);
$pyramidRoom->set_sanction_all($basegroup);
$pyramidRoom->set_attribute("OBJ_TYPE", "container_pyramiddiscussion");
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ACTCOL", 0);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ADMINGROUP", $admingroup);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_BASEGROUP", $basegroup);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_DEADLINES", array());
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_EDITOR", $this->params["editor"]);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_INITIALIZED", 1);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_MAX", $start);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_MAXCOL", $maxcol);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_OVERRIDE_DEADLINES", 0);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_USEDEADLINES", "no");
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_VERSION", "koala_3.0");
$participants = array();
$members = $basegroup->get_members();
$admins = $admingroup->get_members();
foreach ($admins as $admin) {
if (!$basegroup->is_member($admin) && $admin instanceof \steam_user) {
array_push($members, $admin);
}
}
foreach ($members as $member) {
if ($member instanceof \steam_user) {
$participants[$member->get_id()] = 0;
}
}
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_PARTICIPANT_MANAGEMENT", $participants);
$adminconfig = array();
foreach ($admins as $admin) {
if ($admin instanceof \steam_user) {
$options = array();
$options["show_adminoptions"] = "true";
$adminconfig[$admin->get_id()] = $options;
}
}
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ADMINCONFIG", $adminconfig);
$pyramidGroup = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "pyramid_" . $pyramidRoom->get_id(), $basegroup);
// create position documents and corresponding groups
$groups = array();
for ($count = 1; $count <= $maxcol; $count++) {
for ($count2 = 1; $count2 <= $start / pow(2, $count - 1); $count2++) {
$newGroup = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "group_" . $count . "_" . $count2, $pyramidGroup);
$newGroup->set_insert_access($basegroup);
$newGroup->set_insert_access($admingroup);
$groups[$count . $count2] = $newGroup;
$newPosition = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "Position_" . $count . "_" . $count2, "", $this->params["editor"], $pyramidRoom, "Position " . $count . "-" . $count2);
$newPosition->set_attribute("PYRAMIDDISCUSSION_COLUMN", $count);
$newPosition->set_attribute("PYRAMIDDISCUSSION_ROW", $count2);
$newPosition->set_attribute("PYRAMIDDISCUSSION_POS_READ_STATES", array());
$newPosition->set_attribute("PYRAMIDDISCUSSION_POS_TITLE", "");
$newPosition->set_attribute("PYRAMIDDISCUSSION_RELGROUP", $newGroup);
}
}
// generate group structure
for ($count = 2; $count <= $maxcol; $count++) {
for ($count2 = 1; $count2 <= $start / pow(2, $count - 1); $count2++) {
$groups[$count . $count2]->add_member($groups[$count - 1 . ($count2 * 2 - 1)]);
//.........这里部分代码省略.........
示例10: create_subgroup
/**
*function create_subgroup:
*
*@param $pName
*@param $pEnviroment
*@param $pDescription
*
*@return
*/
public function create_subgroup($pName, $pEnvironment = FALSE, $pDescription = "")
{
return steam_factory::create_group($this->steam_connectorID, $pName, $this, $pEnvironment, $pDescription);
}