function check_permissions($user, $oid, $password) { $query = "select v from i_users where k='" . $user . "'"; $result = mysql_query($query); $row = mysql_fetch_row($result); $uid = $result[0]; // if we dont have uid we can get this from i_users $query = "select v from i_security_cache where k='" . $oid . ":" . $uid . "'"; $result = mysql_query($query); $row = mysql_fetch_row($result); $permissions = $row[0]; // read permission is bit "1" if (($permissions & 1) == 1) { return 1; } else { $permission_denied = $permissions >> 16; if (($permission_denied & 1) == 1) { return 0; } else { $STEAM = new steam_connector(STEAM_SERVER, STEAM_PORT, $user, $password); $document = steam_factory::get_object($STEAM->get_id(), (int) $oid, CLASS_OBJECT); if ($document->check_access_read($STEAM->get_current_steam_user()) === 1) { return 1; } } } return 0; }
public function add_contact($contact_id) { $admin_steam = new steam_connector(STEAM_SERVER, STEAM_PORT, STEAM_ROOT_LOGIN, STEAM_ROOT_PW); $contact = steam_factory::get_object($admin_steam->get_id(), $contact_id, CLASS_USER); //The user you are sending a request to is immediatly your contact $this->add_confirmed_contact($contact_id, $admin_steam); //This user have to be confirmed befor he is a also a conntact //of the target user $contact->add_unconfirmed_contact($this->get_id(), $admin_steam); $admin_steam->disconnect(); }
public function createEmployee($login, $password, $email, $firstname, $lastname, $branchID = "", $customerID = "") { $connector = new steam_connector(STEAM_SERVER, STEAM_PORT, STEAM_ROOT_LOGIN, STEAM_ROOT_PW); // Create user $activationCode = steam_factory::create_user($connector->get_id(), $login, $password, $email, $lastname, $firstname); // Get new user and activate $newUser = steam_factory::get_user($connector->get_id(), $login); $newUser->activate($activationCode); if ($branchID != "" && $branchID != "0") { // Add user to branch group $branch = new steam_group($connector->get_id(), $branchID); $branch->add_member($newUser); // Add user to customer group $customer = $branch->get_parent_group(); $customer->add_member($newUser); $newUser->set_attribute("BRANCH_ID", $branchID); } else { if ($customerID != "" && $customerID != "0") { $customer = new steam_group($connector->get_id(), $customerID); $customer->add_member($newUser); } } // Add user to base group $base = steam_factory::get_group($connector->get_id(), BASE_GROUP); $base->add_member($newUser); $newUser->set_attribute(GENERATED_PASSWORD, $password); $newUser->set_attribute("USER_LANGUAGE", "german"); $newUser->set_attribute("OBJ_DESC", "Teilnehmer"); //hack, adding user to course. remove this //steam_factory::get_group($GLOBALS["STEAM"]->get_id(), "Courses.Goertz.G-01.learners")->add_member($newUser); //$connector->disconnect(); return $activationCode; }
} if (!$is_buddy) { $buddies[] = $contact; $user->set_attribute("USER_FAVOURITES", $buddies); } // Clear buddies from cache $cache = get_cache_function($user->get_name(), 86400); $cache->drop("lms_steam::user_get_buddies", $user->get_name()); //$contact->contact_confirm(); // Is new contact in the list of contacts to confirm ? $toconfirm = $user->get_attribute("USER_CONTACTS_TOCONFIRM"); if (!is_array($toconfirm)) { $toconfirm = array(); } $admin_steam = new steam_connector(STEAM_SERVER, STEAM_PORT, STEAM_ROOT_LOGIN, STEAM_ROOT_PW); $acontact = steam_factory::get_object($admin_steam->get_id(), $contact->get_id(), CLASS_USER); // set confirmed contacts of contact $cc = $acontact->get_attribute("USER_CONTACTS_CONFIRMED"); if (!is_array($cc)) { $cc = array(); } $cc[$user->get_id()] = 1; $cc["_OBJECT_KEYS"] = "TRUE"; $acontact->set_attribute("USER_CONTACTS_CONFIRMED", $cc); // set contacts to confirm of contact $ctc = $acontact->get_attribute("USER_CONTACTS_TOCONFIRM"); if (!is_array($ctc)) { $ctc = array(); } $found = FALSE; foreach ($ctc as $tc) {
} include_once "../etc/koala.conf.php"; echo "<h1>Prüfe die Konfiguration</h1>"; echo "Gastanmeldung......"; $steam = new steam_connector(STEAM_SERVER, STEAM_PORT, STEAM_ROOT_LOGIN, STEAM_ROOT_PW); $GLOBALS["STEAM"] = $steam; $steam_user = $steam->get_current_steam_user(); echo $steam_user->get_name(); echo "<span style=\"color:green;font-size:small\">erfolgreich</span><br />"; if (!$steam || !$steam->get_login_status()) { print "No server connection!"; exit; } echo "connection data<br />"; echo "server: " . STEAM_SERVER . ":" . STEAM_PORT . "<br />"; echo "PublicGroups: " . steam_factory::groupname_to_object($steam->get_id(), "PublicGroups")->get_id() . "<br />"; echo "PrivGroups: " . steam_factory::groupname_to_object($steam->get_id(), "PrivGroups")->get_id() . "<br />"; echo "Faculties: " . steam_factory::groupname_to_object($steam->get_id(), "Faculties")->get_id() . "<br />"; echo "Courses: " . steam_factory::groupname_to_object($steam->get_id(), "Courses")->get_id() . "<br />"; echo "Prüfe STEAM_PUBLIC_GROUP......."; if (defined("STEAM_PUBLIC_GROUP") && STEAM_PUBLIC_GROUP != "") { check_steam_group(STEAM_PUBLIC_GROUP); // try { // $steam_public_group = steam_factory::get_object($steam->get_id(), STEAM_PUBLIC_GROUP); // } catch (Exception $e) { // echo "<span style=\"color:red;font-size:small\">STEAM_PUBLIC_GROUP falsch</span><br />"; // $steam_public_group = steam_factory::groupname_to_object( $steam->get_id(), "PublicGroups" ); // if ($steam_public_group != 0 && $steam_public_group instanceof steam_group) { // echo "STEAM_PUBLIC_GROUP should be: " . $steam_public_group->get_id(); // } else { // echo "create a public group e.g. PublicGroups and set id to STEAM_PUBLIC_GROUP in config file";
private function createUnitElearningPreferences() { //create steam container for unit elearning preferences if ($GLOBALS["STEAM"]->get_login_user_name() != "root") { // MUST BE DONE AS ROOT USER $root_steam = new steam_connector(STEAM_SERVER, STEAM_PORT, STEAM_ROOT_LOGIN, STEAM_ROOT_PW); $this->unit_elearning_preferences = steam_factory::create_container($root_steam->get_id(), $this->unit_elearning_preferences_name, $this->workroom); $koala_course = new koala_group_course($this->course_group); //$this->unit_elearning_preferences->set_sanction_all($this->steam_user); $this->unit_elearning_preferences->set_sanction_all($koala_course->get_group_staff()); //$this->unit_elearning_preferences->set_sanction_all($koala_course->get_group_admins()); $root_steam->buffer_flush(); $root_steam->disconnect(); } else { $this->unit_elearning_preferences = steam_factory::create_container($GLOBALS["STEAM"]->get_id(), $this->unit_elearning_preferences_name, $this->workroom); $koala_course = new koala_group_course($this->course_group); //$this->unit_elearning_preferences->set_sanction_all($this->steam_user); $this->unit_elearning_preferences->set_sanction_all($koala_course->get_group_staff()); //$this->unit_elearning_preferences->set_sanction_all($koala_course->get_group_admins()); $GLOBALS["STEAM"]->buffer_flush(); } // //create attributes.xml $this->unit_elearning_preferences = steam_factory::path_to_object($GLOBALS["STEAM"]->get_id(), $this->path_to_unit_elearning_preferences); if ($this->unit_elearning_preferences === 0) { $this->unit_elearning_preferences = steam_factory::path_to_object($GLOBALS["STEAM"]->get_id(), $this->path_to_unit_elearning_preferences); } if ($this->unit_elearning_preferences === 0) { throw new Exception("broke datastructure"); } $attributes_xml = new SimpleXMLElement("<attributes></attributes>"); $attributes_xml->addChild("OBJ_DESC", "storage for unit_elearning user data"); $attributes_xml->addChild("OBJ_HIDDEN", "TRUE"); $attributes_xml->addChild("OBJ_TYPE", "unit_elearning_data"); steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "attributes.xml", (string) $attributes_xml->asXML(), "text/xml", $this->unit_elearning_preferences); $GLOBALS["STEAM"]->buffer_flush(); }
<TITLE>PHP-Test</TITLE> <BODY> <center> <P> </P> <P> </P> <P> <b>koaLA Konvertierungsscript für die Kompatibilität der Erweiterungen</b> </P> <P> </P> <?php include "../../etc/koala.def.php"; include "../../classes/PHPsTeam/steam_connector.class.php"; $aktsem = isset($_GET["semester"]) ? $_GET["semester"] : STEAM_CURRENT_SEMESTER; $connector = new steam_connector(STEAM_SERVER, STEAM_PORT, STEAM_ROOT_LOGIN, STEAM_ROOT_PW); $GLOBALS["STEAM"] = $connector; $scg = steam_factory::get_object($connector->get_id(), STEAM_COURSES_GROUP, CLASS_GROUP); $scg = steam_factory::get_object($connector->get_id(), STEAM_COURSES_GROUP, CLASS_GROUP); $semname = $scg->get_groupname() . "." . $aktsem; $semester = steam_factory::groupname_to_object($connector->get_id(), $semname); if (!is_object($semester)) { die("Cannot find Group " . $scg->get_groupname() . "." . $aktsem . " for semester " . $aktsem); } $courses = $semester->get_subgroups(); steam_factory::load_attributes($connector->get_id(), $courses, array(OBJ_DESC, OBJ_NAME, "COURSE_UNITS_ENABLED")); echo "Listing all Courses for Semester " . $aktsem . " (" . $semname . ")"; echo "<table><tr><td>Kurs</td><td>COURSE_UNITS_ENABLED</td><td>UNITS_DOCPOOL_ENABLED</td><td>Konvertiert</td></tr><tr>"; foreach ($courses as $course) { if (is_object($course)) { echo "<tr><td>" . $course->get_name() . " (" . $course->get_attribute(OBJ_DESC) . ")</td><td>" . $course->get_attribute("COURSE_UNITS_ENABLED") . "</td><td>" . $course->get_attribute("UNITS_DOCPOOL_ENABLED") . "</td><td>"; if ($course->get_attribute("COURSE_UNITS_ENABLED") === "TRUE" && $course->get_attribute("UNITS_DOCPOOL_ENABLED") !== "TRUE") { if (isset($_GET["write"]) && $_GET["write"] == "true") {
function get_document_data($login, $password, $identifier, $identifier_type, $width = false, $height = false) { $STEAM = new steam_connector(STEAM_SERVER, STEAM_PORT, $login, $password); if ($identifier_type === "name") { $document = $STEAM->predefined_command($STEAM->get_module("icons"), "get_icon_by_name", array((string) $identifier), 0); } else { if ($identifier_type === "id") { $document = steam_factory::get_object($STEAM->get_id(), (int) $identifier); } } // If user is not logged in, open login dialog. If user is logged in // and not guest, then display "Access denied" message. if (!$document->check_access_read($STEAM->get_current_steam_user())) { if ($login == 'guest') { throw new Exception("Access denied. Please login.", E_USER_AUTHORIZATION); } else { throw new Exception("Access denied.", E_USER_RIGHTS); } } if (!is_object($document)) { return array("content" => array()); } // array is considered to be an error $document->get_attributes(array("OBJ_NAME", "DOC_MIME_TYPE", "DOC_LAST_MODIFIED"), TRUE); if (!$width && !$height) { //$tnr_content = $document->get_content(TRUE); // workaround: get data from sTeam webinterface $tnr_contentsize = $document->get_content_size(TRUE); } else { $tnr_imagecontent = $document->get_thumbnail_data($width, $height, 0, TRUE); } $result = $STEAM->buffer_flush(); if (isset($tnr_imagecontent)) { // handle thumbnail data $data["mimetype"] = $result[$tnr_imagecontent]["mimetype"]; $data["lastmodified"] = $result[$tnr_imagecontent]["timestamp"]; $data["name"] = $result[$tnr_imagecontent]["name"]; $data["content"] = $result[$tnr_imagecontent]["content"]; $data["contentsize"] = $result[$tnr_imagecontent]["contentsize"]; } else { if ($identifier_type === "id") { $data["mimetype"] = $document->get_attribute("DOC_MIME_TYPE"); $data["lastmodified"] = $document->get_attribute("DOC_LAST_MODIFIED"); $data["name"] = $document->get_name(); $data["contentsize"] = $result[$tnr_contentsize]; //$data["content"] = $result[$tnr_content]; // workaround: get data from sTeam webinterface // workaround: get content from sTeam webinterface, because //$data["content"] = $document->get_content(); // results in *huge* memory overheads (a 15 MB download fails with 60 MB scrip memory limit! if (defined("LOG_DEBUGLOG")) { $time1 = microtime(TRUE); logging::write_log(LOG_DEBUGLOG, "get_document::get_document_data(" . $login . ", *****" . ", " . $identifier . ", " . $identifier_type . ", false, false)\t " . $login . " \t" . $identifier . " \t" . $document->get_name() . " \t" . $data["contentsize"] . " Bytes \t... "); } $https_port = (int) $STEAM->get_config_value("https_port"); if ($https_port == 443 || $https_port == 0) { $https_port = ""; } else { $https_port = ":" . (string) $https_port; } $ch = curl_init("https://" . STEAM_SERVER . $https_port . "/scripts/get.pike?object=" . $identifier); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); curl_setopt($ch, CURLOPT_USERPWD, $login . ":" . $password); $data["content"] = curl_exec($ch); curl_close($ch); if (defined("LOG_DEBUGLOG")) { logging::append_log(LOG_DEBUGLOG, " \t" . round((microtime(TRUE) - $time1) * 1000) . " ms"); } } else { $data = array("content" => array()); // array is considered an error } } return $data; }
output("Wrote config to " . $config_path . "\n"); } } } catch (Exception $e) { output("Error while accessing the open-sTeam backend " . STEAM_SERVER . ":" . STEAM_PORT . " as '" . STEAM_ROOT_LOGIN . "'.\n"); output($e->getMessage() . "\n" . $e->getTraceAsString() . "\n"); exit(1); } // check koala_icons package on open-sTeam server: output("\nChecking koala_support package ...\n"); $koala_support = $STEAM->get_module("package:koala_support"); if (is_object($koala_support)) { $koala_support_installed_version = $STEAM->predefined_command($koala_support, "get_version", array(), 0); } $opensteam = new steam_connector("steam.uni-paderborn.de", 1900, "guest", "guest"); $koala_support_folder = steam_factory::get_object_by_name($opensteam->get_id(), "/home/web.steamware/Packages/koala_support/download"); $koala_support_server_version = "0_0"; foreach ($koala_support_folder->get_inventory() as $item) { $match = array(); if (preg_match("#koala_support-([0-9]+_[0-9]+)\\.spm#", $item->get_name(), $match) <= 0) { continue; } if (isset($match[1]) && is_string($match[1]) && !empty($match[1])) { $match[1] = str_replace("_", ".", $match[1]); if (strcmp($match[1], $koala_support_server_version)) { $koala_support_spm = $item; $koala_support_server_version = $match[1]; } } } if (!isset($koala_support_installed_version)) {