当前位置: 首页>>代码示例>>PHP>>正文


PHP steam_factory::username_to_object方法代码示例

本文整理汇总了PHP中steam_factory::username_to_object方法的典型用法代码示例。如果您正苦于以下问题:PHP steam_factory::username_to_object方法的具体用法?PHP steam_factory::username_to_object怎么用?PHP steam_factory::username_to_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在steam_factory的用法示例。


在下文中一共展示了steam_factory::username_to_object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute($request, $response)
 {
     $myExtension = \Questionary::getInstance();
     $name = trim(isset($_POST["name"]) ? $_POST["name"] : "test");
     //current room steam object
     //if( (int) $object != 0 )
     //$current_room = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $object);
     //else
     $current_room = $GLOBALS["STEAM"]->get_current_steam_user()->get_workroom();
     $steamUser = $GLOBALS["STEAM"]->get_current_steam_user();
     //get write permission
     $access_write = $current_room->check_access_write($steamUser);
     $access_read = $current_room->check_access_read($steamUser);
     $access_insert = $current_room->check_access_insert($steamUser);
     $allowed = $access_write && $access_read && $access_insert ? true : false;
     if (!$allowed) {
         // ACCESS DENIED?
     }
     //create questionary if adviced too
     if (isset($_POST["mission"]) && $_POST["mission"] == "create" && $name != "" && $allowed) {
         //create new questionary
         $questionary = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), $name, $current_room);
         $questions_folder = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), 'questions', $questionary);
         $answers_folder = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), 'answers', $questionary);
         if (isset($_POST["description"])) {
             $description = $_POST["description"];
         } else {
             $description = "";
         }
         if ($questionary && $questions_folder && $answers_folder) {
             //set standard layout
             $layout = "template";
             //$templates[1];
             //define rights for the attributes
             $loginuser_id = $steamUser->get_id();
             $rootid = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), "root")->get_id();
             $author_rights[$loginuser_id] = $loginuser_id;
             $editor_rights[$loginuser_id] = $loginuser_id;
             $analyst_rights[$loginuser_id] = $loginuser_id;
             $author_rights[$rootid] = $rootid;
             $editor_rights[$rootid] = $rootid;
             $analyst_rights[$rootid] = $rootid;
             //define container as questionary and set all attributes
             $attributes = array("bid:doctype" => "questionary", "bid:questionary:fillout" => "1", "bid:questionary:editanswer" => "1", "bid:questionary:editownanswer" => "0", "bid:questionary:number" => "1", "bid:questionary:resultcreator" => "1", "bid:questionary:resultcreationtime" => "1", "bid:questionary:description" => $description, "bid:questionary:edittime" => array(0, 0, 0), "bid:questionary:enabled" => false, "bid:questionary:layout" => $layout, "bid:questionary:author_rights" => $author_rights, "bid:questionary:editor_rights" => $editor_rights, "bid:questionary:analyst_rights" => $analyst_rights);
             $result = $questionary->set_attributes($attributes);
             header("Location: " . PATH_URL . "questionary/editQuestionary/" . $questionary->get_id());
         }
     } else {
         $myExtension->addCSS();
         $content = $myExtension->loadTemplate("questionaryNewQuestionary.template.html");
         $content->setCurrentBlock('BLOCK_FORM_NEW_QUESTIONARY');
         $content->setVariable("QUESTIONARY_ID", "");
         $content->setVariable("BUTTON_MISSION", "create");
         $content->setVariable("OBJECT_ID", $current_room->get_id());
         $content->parse('BLOCK_FORM_NEW_QUESTIONARY');
         return $content->get();
     }
 }
开发者ID:rolwi,项目名称:koala,代码行数:58,代码来源:NewQuestionary.class.php

示例2: steam_user_get_groups

function steam_user_get_groups($username)
{
    $result = array();
    $steam_user = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $username);
    $groups = $steam_user->get_groups();
    $query = array("OBJ_NAME");
    $i = 0;
    foreach ($groups as $group) {
        $result[$i] = $group->get_attributes($query);
        $result[$i]["OBJ_ID"] = $group->get_id();
    }
    return $result;
}
开发者ID:rolwi,项目名称:koala,代码行数:13,代码来源:steam_handling.inc.php

示例3:

<?php

include_once "../etc/koala.conf.php";
include_once PATH_LIB . "url_handling.inc.php";
include_once PATH_LIB . "format_handling.inc.php";
$portal = lms_portal::get_instance();
$portal->initialize(GUEST_NOT_ALLOWED);
$login = $_GET["id"];
if (!($user = steam_factory::username_to_object($STEAM->get_id(), $login))) {
    include "bad_link.php";
    exit;
}
$backlink = PATH_URL . "user/" . $login . "/";
$path = url_parse_rewrite_path($_GET["path"]);
switch (TRUE) {
    case $path[0] == "contacts":
        if (YOUR_CONTACTS) {
            $backlink .= "contacts/";
            include "user_contacts.php";
        } else {
            include "bad_link.php";
        }
        exit;
        break;
    case $path[0] == "groups":
        if (YOUR_GROUPS) {
            $backlink .= "groups/";
            include "user_groups.php";
        } else {
            include "bad_link.php";
        }
开发者ID:rolwi,项目名称:koala,代码行数:31,代码来源:user_index.php

示例4: execute

 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //$portal = \lms_portal::get_instance();
     //$portal->initialize( GUEST_NOT_ALLOWED );
     //$portal->set_guest_allowed( GUEST_NOT_ALLOWED );
     $user = \lms_steam::get_current_user();
     //$portal_user = $portal->get_user();
     //$path = $request->getPath();
     $current_semester = $this->params[1];
     $group_course = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "Courses." . $this->params[0] . "." . $this->params[1]);
     $group = new \koala_group_course($group_course);
     //$html_handler_course = new \koala_html_course($course);
     if (!$group instanceof \koala_group) {
         throw new \Exception("Variable group not set.");
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (isset($_POST["remove"]) && is_array($_POST["remove"])) {
             $id = key($_POST["remove"]);
             $member_to_kick = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $id);
             $group->remove_member($member_to_kick);
             $frameResponseObject->setConfirmText(str_replace("%NAME", h($member_to_kick->get_attribute("USER_FIRSTNAME")) . " " . h($member_to_kick->get_attribute("USER_FULLNAME")), gettext("User %NAME successfully removed from group members.")));
             //$portal->set_confirmation( str_replace( "%NAME", h($member_to_kick->get_attribute( "USER_FIRSTNAME" ))." " . h($member_to_kick->get_attribute( "USER_FULLNAME" )), gettext( "User %NAME successfully removed from group members." ) ) );
             // clear caches:
             $cache = get_cache_function($member_to_kick->get_name());
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), TRUE);
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), FALSE);
             $cache->drop("lms_steam::user_get_profile", $member_to_kick->get_name());
             $cache->drop("lms_portal::get_menu_html", $member_to_kick->get_name(), TRUE);
             $cache = get_cache_function($group->get_id());
             $cache->drop("lms_steam::group_get_members", $group->get_id());
         } else {
             if (isset($_POST["hide"]) && is_array($_POST["hide"])) {
                 $hidden_members = $group->get_steam_group()->get_attribute("COURSE_HIDDEN_STAFF");
                 if (!is_array($hidden_members)) {
                     $hidden_members = array();
                 }
                 $users_to_hide = array_keys($_POST["hide"]);
                 $displayed_staff_members = array();
                 $displayed_staff_members = array_keys($_POST["displayed_staff_member"]);
                 $tmp1_users_to_hide = array_unique(array_merge($hidden_members, $users_to_hide));
                 $tmp2_users_to_hide = array_diff($tmp1_users_to_hide, $displayed_staff_members);
                 $final_users_to_hide = array_unique(array_merge($tmp2_users_to_hide, $users_to_hide));
                 $group->get_steam_group()->set_attribute("COURSE_HIDDEN_STAFF", $final_users_to_hide);
             } else {
                 $hidden_members = $group->get_steam_group()->get_attribute("COURSE_HIDDEN_STAFF");
                 if (!is_array($hidden_members)) {
                     $hidden_members = array();
                 }
                 $displayed_staff_members = array();
                 $displayed_staff_members = array_keys($_POST["displayed_staff_member"]);
                 $users_to_hide = array();
                 $users_to_hide = array_diff($hidden_members, $displayed_staff_members);
                 $group->get_steam_group()->set_attribute("COURSE_HIDDEN_STAFF", $users_to_hide);
             }
             $frameResponseObject->setConfirmText("Sucessfully updated the visibility of course staff");
             //$portal->set_confirmation( "Sucessfully updated the visibility of course staff" );
         }
     }
     $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
     switch (get_class($group)) {
         case "koala_group_course":
             $html_handler_group = new \koala_html_course($group);
             $html_handler_group->set_context("staff");
             //$members = $cache->call( "lms_steam::group_get_members", $group->steam_group_staff->get_id() );
             $members = \lms_steam::group_get_members($group->steam_group_staff->get_id());
             break;
         default:
             $html_handler_group = new \koala_html_group($group);
             $html_handler_group->set_context("staff");
             //$members = $cache->call( "lms_steam::group_get_members", $group->get_id() );
             $members = \lms_steam::group_get_members($group->get_id());
             break;
     }
     $is_admin = $group->is_admin($user);
     $content = \Course::getInstance()->loadTemplate("list_staff.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "list_staff.template.html" );
     $no_members = count($members);
     //DONE
     if ($no_members > 0) {
         $pageIterator = \lms_portal::get_paginator(10, $no_members, "(" . str_replace("%NAME", h($group->get_name()), gettext("%TOTAL members in %NAME")) . ")");
         $content->setVariable("PAGEITERATOR", $pageIterator["html"]);
         $start = $pageIterator["startIndex"];
         //$start = $portal->set_paginator( $content, 10, $no_members, "(" . str_replace( "%NAME", h($group->get_name()), gettext( "%TOTAL members in %NAME" ) ) . ")" );
         $end = $start + 10 > $no_members ? $no_members : $start + 10;
         $content->setVariable("LABEL_CONTACTS", gettext("staff member") . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_members), gettext("%a-%z out of %s")) . ")");
         $content->setCurrentBlock("BLOCK_CONTACT_LIST");
         $content->setVariable("LABEL_NAME_POSITION", gettext("Name, position"));
         !COURSE_STAFF_FACULTY_AND_FOCUS or $content->setVariable("LABEL_SUBJECT_AREA", gettext("Origin/Focus"));
         $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
         if (\lms_steam::is_koala_admin($user) || !COURSE_KOALAADMIN_ONLY && $is_admin) {
             !COURSE_STAFFLIST_MANAGE or $content->setVariable("TH_MANAGE_CONTACT", gettext("Action"));
             !COURSE_STAFFLIST_HIDE or $content->setVariable("TH_STAFF_MEMBER_VISIBILITY", gettext("hidden"));
             !COURSE_STAFFLIST_HIDE or $content->setVariable("STAFF_MEMBER_VISIBILITY_TITLE", gettext("Selected staff members will not be visible on the course start page."));
         }
         !COURSE_STAFF_EXTENSIONS or $content->setVariable("TH_MANAGE_EXTENSIONS", "Status");
         $content->setVariable("BEGIN_HTML_FORM", "<form method=\"POST\" action=\"\">");
         $content->setVariable("END_HTML_FORM", "</form>");
         $hidden_members = $group->get_steam_group()->get_attribute("COURSE_HIDDEN_STAFF");
         if (!is_array($hidden_members)) {
//.........这里部分代码省略.........
开发者ID:rolwi,项目名称:koala,代码行数:101,代码来源:Staff.class.php

示例5: Exception

<?php

if (!$group instanceof koala_group) {
    throw new Exception("Variable group not set.");
}
if (COURSE_PARTICIPANTS_STAFF_ONLY && !$group->is_admin($user)) {
    header("location:../");
    exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (is_array($_POST["remove"])) {
        $id = key($_POST["remove"]);
        $member_to_kick = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $id);
        $group->remove_member($member_to_kick);
        $portal->set_confirmation(str_replace("%NAME", h($member_to_kick->get_attribute("USER_FIRSTNAME")) . " " . h($member_to_kick->get_attribute("USER_FULLNAME")), gettext("User %NAME successfully removed from group members.")));
        // clear caches:
        $cache = get_cache_function($member_to_kick->get_name());
        $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), TRUE);
        $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), FALSE);
        $cache->drop("lms_steam::user_get_profile", $member_to_kick->get_name());
        $cache->drop("lms_portal::get_menu_html", $member_to_kick->get_name(), TRUE);
        $cache = get_cache_function($group->get_id());
        $cache->drop("lms_steam::group_get_members", $group->get_id());
    }
}
$cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
switch (get_class($group)) {
    case "koala_group_course":
        $html_handler_group = new koala_html_course($group);
        $html_handler_group->set_context("members");
        $members = $cache->call("lms_steam::group_get_members", $group->steam_group_learners->get_id());
开发者ID:rolwi,项目名称:koala,代码行数:31,代码来源:groups_members.php

示例6: paul_sync_log

    paul_sync_log("PAUL_SYNC\tNew Bookings: " . $counter_new_bookings . " (scheduled:" . $info_sum_bookings . ")");
    paul_sync_log("PAUL_SYNC\tDeleted bookings: " . $counter_deleted_bookings . " (scheduled: " . $info_sum_part_todelete . ")");
    paul_sync_log("PAUL_SYNC\tSynchronized participants of " . $info_courses . " courses in: " . timelog("runtime_script"));
    paul_sync_log("PAUL_SYNC\tUsers never seen: " . $counter_never_seen_users);
    paul_sync_log("PAUL_SYNC\t=== END ===");
} catch (Exception $e) {
    paul_sync_log($e->getTraceAsString(), PAUL_SYNC_LOGLEVEL_ERROR);
    print "Cannot write Log-File! ";
    print "Please check if " . LOG_PAULSYNC . " is writable.";
}
if (defined("PAUL_SYNC_ADMIN_LOGIN")) {
    $logdata = "";
    if (file_exists(LOG_PAULSYNC_LAST)) {
        $fp = fopen(LOG_PAULSYNC_LAST, "r");
        $logdata = fread($fp, filesize(LOG_PAULSYNC_LAST));
        fclose($fp);
    }
    $admin = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), PAUL_SYNC_ADMIN_LOGIN);
    if (is_object($admin)) {
        $admin->mail("PAUL Sync summary for " . PATH_SERVER, $logdata != "" ? str_replace("\n", "<br />", $logdata) : "No log data");
    }
}
try {
    if (is_object($paulsync_folder)) {
        $paulsync_folder->set_attribute("PAUL_SYNC_ENDTIME", time());
        $paulsync_folder->set_attribute("PAUL_SYNC_RUNNING", "FALSE");
    }
    $GLOBALS["STEAM"]->disconnect();
} catch (Exception $e) {
    paul_sync_log("PAUL_SYNC\tWARNING\tError disconnecting from steam error=" . $e->getMessage(), PAUL_SYNC_LOGLEVEL_WARNING);
}
开发者ID:rolwi,项目名称:koala,代码行数:31,代码来源:synchronize_participants_paul_backport.php

示例7: get_user

 /**
  * function get-user:
  *
  * Returns a steam_user instance by its login-name
  *
  * @param steam_connector $pSteamConnector connection to sTeam-server
  * @param string $pUserName user's login name
  * @param Boolean $pBuffer Send now or buffer request?
  * @return steam_user the user object
  */
 public static function get_user($pSteamConnectorID, $pUserName, $pBuffer = 0)
 {
     if (!is_string($pSteamConnectorID)) {
         throw new ParameterException("pSteamConnectorID", "string");
     }
     return steam_factory::username_to_object($pSteamConnectorID, $pUserName, $pBuffer);
 }
开发者ID:rolwi,项目名称:koala,代码行数:17,代码来源:steam_factory.class.php

示例8: Exception

}
$backlink = $group->get_url();
if (!$group->is_admin($user)) {
    throw new Exception("No admin of " . $group->get_groupname() . ": " . $user->get_name());
}
if (!empty($_REQUEST["selected_user"])) {
    $selected_users = array_keys($_REQUEST["selected_user"]);
}
if (!empty($_REQUEST["add"]) && count($_REQUEST["add"]) > 0) {
    $selected_users = array(key($_REQUEST["add"]));
}
if (isset($selected_users) && count($selected_users) > 0) {
    $confirmations = array();
    $problems = array();
    foreach ($selected_users as $login) {
        $new_member = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $login);
        if ($group->add_member($new_member)) {
            $confirmations[] = h($new_member->get_full_name());
            // PROCEDURE FOR COURSE ADMINS
            if ($group->get_attribute("OBJ_TYPE") == "course_staff") {
                // TODO: fct to add an admin? set_sanction_all does not seem to work... :(
                $steam_group->set_sanction_all($new_member);
            }
            if ($group->get_attribute("OBJ_TYPE") == "course_tutorial" || $group->get_attribute("OBJ_TYPE") == "group_tutorial_koala") {
                $no_of_learners = (int) $group->get_attribute("GROUP_NO_MEMBERS");
                $group->set_attribute("GROUP_NO_MEMBERS", $no_of_learners + count($_REQUEST["add"]));
            }
            $group_name = koala_object::get_koala_object($group)->get_display_name();
            $message = str_replace("%NAME", $new_member->get_full_name(), gettext("Dear %NAME,")) . "\n\n";
            $message .= str_replace("%GROUP", $group_name, gettext("You were added to '%GROUP' as a new member.")) . "\n\n";
            $message .= gettext("This is an automatically generated message.") . " " . gettext("If you haven't been informed about this membership in advance, please contact the sender of this message.") . "\n\n" . str_replace("%GROUP", "<a href=\"" . $backlink . "\">" . $group_name . "</a>", gettext("See '%GROUP' for further information."));
开发者ID:rolwi,项目名称:koala,代码行数:31,代码来源:group_add_members.php

示例9: frameResponse

 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.")));
             }
//.........这里部分代码省略.........
开发者ID:rolwi,项目名称:koala,代码行数:101,代码来源:AddAdmin.class.php

示例10: user_get_buddies

 public function user_get_buddies($username, $confirmed = TRUE, $additional_attributes = array())
 {
     $result = array();
     $steam_user = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $username);
     if ($confirmed) {
         $confirmed_contacts = $steam_user->get_attribute("USER_CONTACTS_CONFIRMED");
         $buddies = array();
         if (!is_array($confirmed_contacts)) {
             $confirmed_contacts = array();
         }
         while (list($id, $confirmation) = each($confirmed_contacts)) {
             $buddy = new steam_user($GLOBALS["STEAM"]->get_id(), $id);
             // ignore invalid buddy entries:
             if (is_object($buddy)) {
                 $buddies[] = $buddy;
             }
         }
     } else {
         $buddies_tmp = $steam_user->get_attribute("USER_FAVOURITES");
         $buddies = array();
         // ignore invalid buddy entries:
         foreach ($buddies_tmp as $buddy) {
             if (is_object($buddy)) {
                 $buddies[] = $buddy;
             }
         }
     }
     $query = array("OBJ_NAME", "OBJ_DESC", "USER_FIRSTNAME", "USER_FULLNAME", "OBJ_ICON", "USER_PROFILE_FOCUS", "USER_PROFILE_FACULTY", "USER_ACADEMIC_TITLE");
     $query = array_merge($query, $additional_attributes);
     $no_buddies = count($buddies);
     $i = 0;
     steam_factory::load_attributes($GLOBALS["STEAM"]->get_id(), $buddies, $query);
     foreach ($buddies as $buddy) {
         if ($buddy instanceof steam_user) {
             $tmp = $buddy->get_attributes($query);
             if (!$confirmed) {
                 if ($steam_user->contact_is_confirmed($buddy)) {
                     $tmp["USER_CONFIRMED"] = 1;
                 } else {
                     $tmp["USER_CONFIRMED"] = 0;
                 }
             }
             $result[$i] = $tmp;
             if (is_object($result[$i]["OBJ_ICON"])) {
                 $result[$i]["OBJ_ICON"] = $result[$i]["OBJ_ICON"]->get_id();
             } else {
                 $result[$i]["OBJ_ICON"] = 0;
             }
             $result[$i]["OBJ_ID"] = $buddy->get_id();
             $i++;
         }
     }
     usort($result, "sort_buddies");
     return $result;
 }
开发者ID:rolwi,项目名称:koala,代码行数:55,代码来源:lms_steam.class.php

示例11: frameResponse

 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     if (isset($path[0])) {
         if (\steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "courses." . $path[0]) instanceof \steam_group) {
             $current_semester = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "courses." . $path[0]);
         } else {
             header("Location: " . PATH_URL . "404/");
             die;
         }
     } else {
         $current_semester = \lms_steam::get_current_semester();
     }
     $current_semester_name = $current_semester->get_name();
     if (\lms_steam::is_steam_admin($user)) {
         if (!$portal->get_user()->is_logged_in()) {
             throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION);
         }
         $semester_admins = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $current_semester->get_groupname() . ".admins");
         $admin_group = new \koala_group_default($semester_admins);
         if ($_SERVER["REQUEST_METHOD"] == "POST") {
             $delete = $_POST["delete"];
             if (count($delete) == 1) {
                 $login = key($delete);
                 $admin = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $login);
                 $admin_group->remove_member($admin);
             }
         }
         $content = \Semester::getInstance()->loadTemplate("semester_admins.template.html");
         $content->setVariable("INFORMATION_ADMINS", str_replace("%SEMESTER", h($current_semester->get_attribute("OBJ_DESC")), gettext("These people are allowed to create courses for %SEMESTER.")) . " " . gettext("They can appoint other users as staff members/moderators for their own courses."));
         $content->setVariable("LINK_ADD_ADMIN", PATH_URL . "semester/addAdmin/" . $current_semester_name . "/" . $admin_group->get_id());
         $content->setVariable("LABEL_ADD_ADMIN", gettext("Add another admin"));
         //TODO: Messages extension schreiben
         // TODO: Passt der Link?
         $content->setVariable("LINK_MESSAGE", PATH_URL . "mail/write/" . $admin_group->get_id());
         $content->setVariable("LABEL_MESSAGE_ADMINS", gettext("Mail to admins"));
         $admins = $admin_group->get_members();
         $no_admins = count($admins);
         if ($no_admins > 0) {
             $content->setVariable("LABEL_ADMINS", gettext("Course admins"));
             $content->setCurrentBlock("BLOCK_CONTACT_LIST");
             $content->setVariable("LABEL_NAME_POSITION", gettext("Name") . "/" . gettext("Position"));
             $content->setVariable("LABEL_SUBJECT_AREA", gettext("Subject area"));
             $content->setVariable("LABEL_COMMUNICATION", gettext("Communication"));
             $content->setVariable("LABEL_REMOVE_ADMIN", gettext("Action"));
             foreach ($admins as $admin) {
                 $adm_attributes = $admin->get_attributes(array("USER_FIRSTNAME", "USER_FULLNAME", "OBJ_DESC", "OBJ_ICON"));
                 $content->setCurrentBlock("BLOCK_CONTACT");
                 $content->setVariable("CONTACT_NAME", h($adm_attributes["USER_FIRSTNAME"]) . " " . h($adm_attributes["USER_FULLNAME"]));
                 // TODO: Profile Image einfügen
                 // TODO: Passt der Link?
                 $icon_link = \lms_user::get_user_image_url(30, 40);
                 $content->setVariable("CONTACT_IMAGE", $icon_link);
                 // TODO: Passt der Link?
                 $content->setVariable("CONTACT_LINK", PATH_URL . "user/" . $admin->get_name() . "/");
                 $content->setVariable("OBJ_DESC", h($adm_attributes["OBJ_DESC"]));
                 $content->setVariable("LABEL_MESSAGE", gettext("Message"));
                 // TODO: Passt der Link?
                 $content->setVariable("LINK_SEND_MESSAGE", PATH_URL . "mail/write/" . $admin->get_name());
                 $content->setVariable("LABEL_SEND", gettext("Send"));
                 $content->setVariable("LABEL_REMOVE", gettext("Remove"));
                 $content->setVariable("CONTACT_ID", $admin->get_name());
                 $content->parse("BLOCK_CONTACT");
             }
             $content->parse("BLOCK_CONTACT_LIST");
         } else {
             $content->setVariable("LABEL_ADMINS", gettext("No admins found."));
         }
         /* TODO: Portal anpassen
         			$portal->set_page_title( h($current_semester->get_name()) . " Admins" );
         			$portal->set_page_main( 
         				array(
         					array( "link" => PATH_URL . SEMESTER_URL . "/" . h($current_semester->get_name()) . "/", "name" => h($current_semester->get_attribute( "OBJ_DESC" ))), array( "link" => "", "name" => gettext( "Admins" ) )
         				),
         				$content->get(),
         				""
         			);
         			$portal->show_html( );
         			*/
     } else {
         header("Location: " . PATH_URL . "404/");
         die;
     }
     $frameResponseObject->setTitle("Semester " . $current_semester_name);
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
开发者ID:rolwi,项目名称:koala,代码行数:91,代码来源:ManageSemester.class.php

示例12: elseif

    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $content->setVariable("VALUE_SUBJECT", $subject);
        $content->setVariable("VALUE_BODY", $text);
    } else {
        $content->setVariable("VALUE_BODY", $signature . $new_body);
    }
}
// selection of the recievers
// if a buddy is given, there is no selection
// if a group is given, users can select the whole group or a set of members
// else users can select one or more of their buddies or groups
if (!empty($_GET["to"]) || isset($receiver) && $receiver instanceof steam_user) {
    // buddy given
    $content->setCurrentBlock("BLOCK_BUDDY_GIVEN");
    if (!isset($receiver)) {
        $receiver = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $_GET["to"]);
    }
    $content->setVariable("RECEIVER_NAME", $receiver->get_attribute("USER_FIRSTNAME") . " " . $receiver->get_attribute("USER_FULLNAME"));
    $icon_link = $receiver->get_attribute(OBJ_ICON) === 0 ? PATH_STYLE . "images/anonymous.jpg" : PATH_URL . "get_document.php?id=" . $receiver->get_attribute(OBJ_ICON)->get_id() . "&type=usericon&width=30&height=40";
    $content->setVariable("RECEIVER_IMAGE", $icon_link);
    $content->setVariable("RECEIVER_OBJ_ID", $receiver->get_id());
    $content->parse("BLOCK_BUDDY_GIVEN");
} elseif (!empty($_GET["group"]) || isset($receiver) && $receiver instanceof steam_group) {
    // group given
    $content->setCurrentBlock("BLOCK_GROUP_GIVEN");
    $content->setVariable("LABEL_SELECT_MEMBERS", gettext('Select members'));
    if (!isset($receiver) || !$receiver) {
        $receiver = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["group"]);
    }
    if (!$receiver instanceof steam_group) {
        throw new Exception("Group " . $_GET["group"] . " does not exist.");
开发者ID:rolwi,项目名称:koala,代码行数:31,代码来源:messages_write.php

示例13: norm_post

    $questionary = steam_factory::create_container($steam, $name, $current_room);
    $questions_folder = steam_factory::create_container($steam, 'questions', $questionary);
    $answers_folder = steam_factory::create_container($steam, 'answers', $questionary);
    if (isset($_POST["description"])) {
        $description = norm_post($_POST["description"]);
    } else {
        $description = "";
    }
    if ($questionary && $questions_folder && $answers_folder) {
        //set standard layout
        $layout = $templates[1];
        unset($layout["name_ge"]);
        unset($layout["name_en"]);
        //define rights for the attributes
        $loginuser_id = $steam->get_login_user()->get_id();
        $rootid = steam_factory::username_to_object($steam, "root")->get_id();
        $author_rights[$loginuser_id] = $loginuser_id;
        $editor_rights[$loginuser_id] = $loginuser_id;
        $analyst_rights[$loginuser_id] = $loginuser_id;
        $author_rights[$rootid] = $rootid;
        $editor_rights[$rootid] = $rootid;
        $analyst_rights[$rootid] = $rootid;
        //define container as questionary and set all attributes
        $attributes = array("bid:doctype" => "questionary", "bid:questionary:fillout" => "1", "bid:questionary:editanswer" => "1", "bid:questionary:editownanswer" => "0", "bid:questionary:number" => "1", "bid:questionary:resultcreator" => "1", "bid:questionary:resultcreationtime" => "1", "bid:questionary:description" => $description, "bid:questionary:edittime" => array(0, 0, 0), "bid:questionary:enabled" => false, "bid:questionary:layout" => $layout, "bid:questionary:author_rights" => $author_rights, "bid:questionary:editor_rights" => $editor_rights, "bid:questionary:analyst_rights" => $analyst_rights);
        $result = $questionary->set_attributes($attributes);
    }
}
//Disconnect
$steam->disconnect();
//on successfull creation do redirect
if (isset($result) && $result) {
开发者ID:rolwi,项目名称:koala,代码行数:31,代码来源:new.php

示例14: search_user_posts

 public function search_user_posts($messageboard_id, $user_name)
 {
     if (defined("LOG_DEBUGLOG")) {
         $time1 = microtime(TRUE);
         logging::write_log(LOG_DEBUGLOG, "lms_forum::search_user_posts(" . $messageboard_id . ", " . $user_name . ") \t" . $GLOBALS["STEAM"]->get_login_user_name() . " \t" . $messageboard_id . " \t... ");
     }
     if (!($search_mod = $GLOBALS["STEAM"]->get_module("package:searchsupport"))) {
         throw new Exception("sTeam 'package:searchsupport' not installed.");
     }
     $messageboard = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $messageboard_id, CLASS_MESSAGEBOARD);
     $user = steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $user_name);
     $search_results = $GLOBALS["STEAM"]->predefined_command($search_mod, "search_user_posts", array($messageboard, $user), 0);
     $result = lms_forum::get_discussions($messageboard->get_id(), $search_results);
     if (defined("LOG_DEBUGLOG")) {
         logging::append_log(LOG_DEBUGLOG, " \t" . round((microtime(TRUE) - $time1) * 1000) . " ms \t" . count($result));
     }
     return $result;
 }
开发者ID:rolwi,项目名称:koala,代码行数:18,代码来源:lms_forum.class.php

示例15: frameResponse

 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $user = \lms_steam::get_current_user();
     $public = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_PUBLIC_GROUP, CLASS_GROUP);
     $id = $path[0];
     $portal = \lms_portal::get_instance();
     $portal_user = $portal->get_user();
     try {
         $steam_group = !empty($id) ? \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $id) : FALSE;
     } catch (\Exception $ex) {
         include "bad_link.php";
         exit;
     }
     $group_is_private = FALSE;
     if ($steam_group && is_object($steam_group)) {
         switch ((string) $steam_group->get_attribute("OBJ_TYPE")) {
             case "course":
                 $group = new \koala_group_course($steam_group);
                 // TODO: Passt der backlink?
                 $backlink = PATH_URL . SEMESTER_URL . "/" . $group->get_semester()->get_name() . "/" . h($group->get_name()) . "/";
                 break;
             default:
                 $group = new \koala_group_default($steam_group);
                 // TODO: Passt der backlink?
                 $backlink = PATH_URL . "groups/" . $group->get_id() . "/";
                 // Determine if group is public or private
                 $parent = $group->get_parent_group();
                 if ($parent->get_id() == STEAM_PRIVATE_GROUP) {
                     $group_is_private = TRUE;
                 }
                 break;
         }
     }
     if ($group_is_private) {
         if (!$steam_group->is_member($user) && !\lms_steam::is_koala_admin($user)) {
             throw new \Exception(gettext("You have no rights to access this group"), E_USER_RIGHTS);
         }
     }
     if (!$group instanceof \koala_group) {
         throw new \Exception("Variable group not set.");
     }
     if (COURSE_PARTICIPANTS_STAFF_ONLY && !$group->is_admin($user)) {
         header("location:../");
         exit;
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (is_array($_POST["remove"])) {
             $id = key($_POST["remove"]);
             $member_to_kick = \steam_factory::username_to_object($GLOBALS["STEAM"]->get_id(), $id);
             $group->remove_member($member_to_kick);
             $portal->set_confirmation(str_replace("%NAME", h($member_to_kick->get_attribute("USER_FIRSTNAME")) . " " . h($member_to_kick->get_attribute("USER_FULLNAME")), gettext("User %NAME successfully removed from group members.")));
             // clear caches:
             $cache = get_cache_function($member_to_kick->get_name());
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), TRUE);
             $cache->drop("lms_steam::user_get_groups", $member_to_kick->get_name(), FALSE);
             $cache->drop("lms_steam::user_get_profile", $member_to_kick->get_name());
             $cache->drop("lms_portal::get_menu_html", $member_to_kick->get_name(), TRUE);
             $cache = get_cache_function($group->get_id());
             $cache->drop("lms_steam::group_get_members", $group->get_id());
         }
     }
     $cache = get_cache_function($group->get_id(), CACHE_LIFETIME_STATIC);
     switch (get_class($group)) {
         case "koala_group_course":
             $html_handler_group = new \koala_html_course($group);
             $html_handler_group->set_context("members");
             $members = $cache->call("lms_steam::group_get_members", $group->steam_group_learners->get_id());
             break;
         default:
             $html_handler_group = new \koala_html_group($group);
             $html_handler_group->set_context("members");
             $members = $cache->call("lms_steam::group_get_members", $group->get_id());
             break;
     }
     $is_admin = $group->is_admin($user);
     $content = \Group::getInstance()->loadTemplate("list_users.template.html");
     $is_member = $group->is_member($user);
     //echo "is_member? " . $is_member;
     $privacy_deny_participants = $group->get_attribute("GROUP_PRIVACY");
     //echo "attribute: ''" . $privacy_deny_participants . "''";
     if ($privacy_deny_participants == PERMISSION_GROUP_PRIVACY_DENY_PARTICIPANTS && !$is_member) {
         //echo "*** deny ***";
         //TODO
         $content->setVariable("LABEL_PRIVACY_DENY_PARTICIPANTS", gettext("Participants are hidden."));
     } else {
         //echo "*** permit ***";
         $no_members = count($members);
         if ($no_members > 0) {
             switch (get_class($group)) {
                 case "koala_group_course":
                     $groupname = $group->get_course_id();
                     break;
                 default:
                     $groupname = $group->get_name();
                     break;
             }
             if (!USER_LIST_NO_PAGEING) {
                 $paginator = \lms_portal::get_paginator(10, $no_members, "(" . str_replace("%NAME", h($groupname), gettext("%TOTAL members in %NAME")) . ")");
                 $start = $paginator["startIndex"];
//.........这里部分代码省略.........
开发者ID:rolwi,项目名称:koala,代码行数:101,代码来源:Members.class.php


注:本文中的steam_factory::username_to_object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。