Ejemplo n.º 1
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $TCR = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $TCRExtension = \TCR::getInstance();
     $TCRExtension->addCSS();
     $content = $TCRExtension->loadTemplate("tcr_configuration.template.html");
     $group = $TCR->get_attribute("TCR_GROUP");
     $members = $group->get_members();
     $admins = $TCR->get_attribute("TCR_ADMINS");
     $users = $TCR->get_attribute("TCR_USERS");
     if ($group->get_name() == "learners") {
         $parent = $group->get_parent_group();
         $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")";
         $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id();
     } else {
         $courseOrGroup = "Gruppe: " . $group->get_name();
         $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id();
     }
     if ($group->get_name() == "learners") {
         $parent = $group->get_parent_group();
         $groupname = $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")";
         $subgroups = $parent->get_subgroups();
         foreach ($subgroups as $subgroup) {
             if ($subgroup->get_name() == "staff") {
                 $staff = $subgroup->get_members();
                 foreach ($staff as $staffMember) {
                     if ($staffMember instanceof \steam_user) {
                         array_push($members, $staffMember);
                     }
                 }
                 break;
             }
         }
     } else {
         $groupname = $group->get_name();
     }
     // configuration form got submitted
     if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["change_configuration"])) {
         $TCR->set_attribute("OBJ_DESC", $_POST["title"]);
         if (intval($_POST["rounds"]) > 0) {
             $TCR->set_attribute("TCR_ROUNDS", $_POST["rounds"]);
         }
         if (isset($_POST["admin"])) {
             $admins_post = $_POST["admin"];
         } else {
             $admins_post = array();
         }
         if (isset($_POST["member"])) {
             $members_post = $_POST["member"];
         } else {
             $members_post = array();
         }
         foreach ($members as $member) {
             if ($member instanceof \steam_user) {
                 if (!array_key_exists($member->get_id(), $admins_post)) {
                     $admins_post[$member->get_id()] = "off";
                 }
                 if (!array_key_exists($member->get_id(), $members_post)) {
                     $members_post[$member->get_id()] = "off";
                 }
             }
         }
         $former_admins_post = $_POST["formeradmin"];
         $former_members_post = $_POST["formermember"];
         foreach ($members as $member) {
             if ($member instanceof \steam_user) {
                 // set new admin rights
                 if ($admins_post[$member->get_id()] != $former_admins_post[$member->get_id()] && $member->get_id() != $TCR->get_creator()->get_id()) {
                     if ($admins_post[$member->get_id()] == "off" && $former_admins_post[$member->get_id()] == "on") {
                         unset($admins[array_search($member->get_id(), $admins)]);
                         $admins = array_values($admins);
                     } else {
                         if ($admins_post[$member->get_id()] == "on" && $former_admins_post[$member->get_id()] == "off") {
                             array_push($admins, $member->get_id());
                         }
                     }
                 }
                 // set new members
                 if ($members_post[$member->get_id()] != $former_members_post[$member->get_id()]) {
                     if ($members_post[$member->get_id()] == "off" && $former_members_post[$member->get_id()] == "on") {
                         unset($users[array_search($member->get_id(), $users)]);
                         $users = array_values($users);
                     } else {
                         if ($members_post[$member->get_id()] == "on" && $former_members_post[$member->get_id()] == "off") {
                             array_push($users, $member->get_id());
                         }
                     }
                 }
             }
         }
         $TCR->set_attribute("TCR_ADMINS", $admins);
         $TCR->set_attribute("TCR_USERS", $users);
     }
     // display error message if current user is no admin
     if (!in_array($user->get_id(), $admins)) {
         $actionbar = new \Widgets\Actionbar();
         $actions = array(array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id));
         $actionbar->setActions($actions);
         $frameResponseObject->addWidget($actionbar);
         $rawWidget = new \Widgets\RawHtml();
         $rawWidget->setHtml("<center>Zugang verwehrt. Sie sind kein Administrator in diesem Thesen-Kritik-Replik-Verfahren</center>");
         $frameResponseObject->addWidget($rawWidget);
         $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Konfiguration")));
         return $frameResponseObject;
     }
     // display actionbar
     $actionbar = new \Widgets\Actionbar();
     $actions = array(array("name" => "Konfiguration", "link" => $TCRExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id));
     $actionbar->setActions($actions);
     $frameResponseObject->addWidget($actionbar);
     // display configuration table
     $content->setCurrentBlock("BLOCK_TCR_CONFIGURATION");
     $content->setVariable("TCR_OPTIONS", "Thesen-Kritik-Replik-Verfahren Konfiguration");
     $content->setVariable("TITLE_LABEL", "Titel");
     $content->setVariable("TITLE_VALUE", $TCR->get_attribute("OBJ_DESC"));
     $content->setVariable("ROUNDS_LABEL", "Runden");
     $content->setVariable("ROUNDS_VALUE", $TCR->get_attribute("TCR_ROUNDS"));
     $content->setVariable("GROUP_LABEL", "Arbeitsgruppe");
     $content->setVariable("GROUP_VALUE", $groupname);
     // user management
     $content->setVariable("USERS_LABEL", "Benutzerverwaltung");
     $content->setVariable("USER_LABEL", "Name");
     $content->setVariable("ADMIN_LABEL", "Administrator");
     $content->setVariable("MEMBER_LABEL", "Teilnehmer");
     usort($members, "sort_workplans");
     foreach ($members as $member) {
         if ($member instanceof \steam_user) {
             $content->setCurrentBlock("BLOCK_USER");
             $content->setVariable("USER_NAME", $member->get_full_name() . " (" . $member->get_name() . ")");
             $content->setVariable("USER_ID", $member->get_id());
             if (in_array($member->get_id(), $admins)) {
                 $content->setVariable("ADMIN_CHECKED", "checked");
                 if ($member->get_id() == $TCR->get_creator()->get_id()) {
                     $content->setVariable("ADMIN_DISABLED", "disabled");
                 }
                 $content->setVariable("FORMER_ADMIN", "on");
             } else {
                 $content->setVariable("FORMER_ADMIN", "off");
             }
             if (in_array($member->get_id(), $users)) {
                 $content->setVariable("MEMBER_CHECKED", "checked");
                 $content->setVariable("FORMER_MEMBER", "on");
             } else {
                 $content->setVariable("FORMER_MEMBER", "off");
             }
             $content->parse("BLOCK_USER");
         }
     }
     $content->setVariable("SAVE_CHANGES", "Änderungen speichern");
     $content->parse("BLOCK_TCR_CONFIGURATION");
     $rawWidget = new \Widgets\RawHtml();
     $rawWidget->setHtml($content->get());
     $frameResponseObject->addWidget($rawWidget);
     $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Konfiguration")));
     return $frameResponseObject;
 }
Ejemplo n.º 2
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $userID = $user->get_id();
     $pyramidRoom = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $pyramiddiscussionExtension = \Pyramiddiscussion::getInstance();
     $pyramiddiscussionExtension->addCSS();
     $pyramiddiscussionExtension->addJS();
     $content = $pyramiddiscussionExtension->loadTemplate("pyramiddiscussion_index.template.html");
     $admingroup = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_ADMINGROUP");
     $basegroup = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_BASEGROUP");
     $startElements = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAX");
     $maxcol = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAXCOL");
     $deadlines = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_DEADLINES");
     $user_management = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_PARTICIPANT_MANAGEMENT");
     $deadlines_used = false;
     $currentUserGroup = 0;
     $objtype = $pyramidRoom->get_attribute("OBJ_TYPE");
     if (!strStartsWith($objtype, "container_pyramiddiscussion")) {
         $rawWidget = new \Widgets\RawHtml();
         $rawWidget->setHtml("Objekt " . $this->id . " ist keine Pyramidendiskussion.");
         $frameResponseObject->addWidget($rawWidget);
         return $frameResponseObject;
     }
     // if one or more deadlines past by since the last visit on this page, change the phase
     $phase = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_ACTCOL");
     if ($phase != 0 && $phase <= $maxcol && $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_USEDEADLINES") == "yes" && $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_OVERRIDE_DEADLINES") == 0) {
         $currentDeadline = $deadlines[$phase];
         while (true) {
             if ($currentDeadline > time()) {
                 break;
             } else {
                 $phase++;
                 $pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ACTCOL", $phase);
                 if ($phase == $maxcol + 1) {
                     break;
                 }
                 $currentDeadline = $deadlines[$phase];
             }
         }
     }
     $adminoptions_change = -1;
     if (isset($this->params[1])) {
         $adminoptions_change = $this->params[1];
     }
     // if current user is admin display actionbar
     if ($admingroup->is_member($user)) {
         $adminconfig = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_ADMINCONFIG");
         if (array_key_exists($userID, $adminconfig)) {
             $options = $adminconfig[$userID];
             // change show/hide settings
             if ($adminoptions_change != -1) {
                 if ($adminoptions_change == 1) {
                     $options["show_adminoptions"] = "true";
                 } else {
                     $options["show_adminoptions"] = "false";
                 }
                 $adminconfig[$userID] = $options;
                 $pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ADMINCONFIG", $adminconfig);
             }
         } else {
             $adminconfig[$userID] = array();
             $options = $adminconfig[$userID];
             $options["show_adminoptions"] = "true";
             $adminconfig[$userID] = $options;
             $pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ADMINCONFIG", $adminconfig);
         }
         if ($options["show_adminoptions"] == "true") {
             $actionbar = new \Widgets\Actionbar();
             $actions = array(array("name" => "Konfiguration", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Teilnehmerverwaltung", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "users/" . $this->id), array("name" => "Rundmail erstellen", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "mail/" . $this->id), array("name" => "Adminmodus ausschalten", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "Index/" . $this->id . "/0"));
             $actionbar->setActions($actions);
             $frameResponseObject->addWidget($actionbar);
         } else {
             $actionbar = new \Widgets\Actionbar();
             $actions = array(array("name" => "Adminmodus einschalten", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "Index/" . $this->id . "/1"));
             $actionbar->setActions($actions);
             $frameResponseObject->addWidget($actionbar);
         }
     }
     // display the general information block
     $content->setCurrentBlock("BEGIN BLOCK_PYRAMID_INFORMATION");
     $content->setVariable("JS_URL", $pyramiddiscussionExtension->getAssetUrl());
     $content->setVariable("GENERAL_INFORMATION", "Allgemeine Informationen");
     $content->setVariable("PHASE_LABEL", "Aktueller Status:");
     // if user is an admin and adminoptions are shown, display a select box to change the current phase
     if (isset($options["show_adminoptions"]) && $options["show_adminoptions"] == "true") {
         for ($count = 0; $count <= $maxcol + 2; $count++) {
             $content->setCurrentBlock("BLOCK_PHASE_OPTION");
             $content->setVariable("PHASE_ID", $count);
             if ($count == 0) {
                 $content->setVariable("PHASE_VALUE", "Gruppeneinteilungsphase");
             } else {
                 if ($count <= $maxcol) {
                     $content->setVariable("PHASE_VALUE", $count . ". Diskussionsphase");
                 } else {
                     if ($count == $maxcol + 1) {
                         $content->setVariable("PHASE_VALUE", "Endphase");
                     } else {
                         $content->setVariable("PHASE_VALUE", "Pyramide einfrieren");
                     }
                 }
             }
             if ($count == $phase) {
                 $content->setVariable("PHASE_SELECTED", "selected");
             }
             $content->setVariable("CHANGE_PHASE", "Ändern");
             $params = "{ id : " . $pyramidRoom->get_id() . ", action : 'phase', newphase : document.getElementById('phase').value }";
             $content->setVariable("CHANGE_PHASE_ACTION", "sendRequest('Index', " . $params . ", '" . $pyramidRoom->get_id() . "', 'reload');");
             $content->parse("BLOCK_PHASE_OPTION");
         }
     } else {
         $content->setCurrentBlock("BLOCK_PYRAMID_PHASE_NOADMIN");
         if ($phase == 0) {
             $content->setVariable("PHASE_VALUE", "Gruppeneinteilungsphase");
         } else {
             if ($phase <= $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAXCOL")) {
                 $content->setVariable("PHASE_VALUE", $phase . ". Diskussionsphase");
             } else {
                 if ($phase == $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAXCOL") + 1) {
                     $content->setVariable("PHASE_VALUE", "Endphase");
                 } else {
                     $content->setVariable("PHASE_VALUE", "Pyramide eingefroren");
                 }
             }
         }
         $content->parse("BLOCK_PYRAMID_PHASE_NOADMIN");
     }
     $content->setVariable("DEADLINE_LABEL", "Deadline:");
     // display current deadline if deadlines are used and override is off
     if ($pyramidRoom->get_attribute("PYRAMIDDISCUSSION_USEDEADLINES") == "yes" && $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_OVERRIDE_DEADLINES") == 0 && $phase != 0 && $phase <= $maxcol) {
         $content->setVariable("DEADLINE_VALUE", date("d.m.Y H:i", (int) $deadlines[$phase]));
         $content->setVariable("DISPLAY_OVERRIDE", "none");
         $deadlines_used = true;
         // if user is admin, adminoptions are shown, deadlines are used but override is on, display a dialog to stop the override
     } else {
         if ($pyramidRoom->get_attribute("PYRAMIDDISCUSSION_USEDEADLINES") == "yes" && $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_OVERRIDE_DEADLINES") == 1 && isset($options["show_adminoptions"]) && $options["show_adminoptions"] == "true") {
             $content->setVariable("DEADLINE_VALUE", "Aktuelle Phase wurde trotz der Verwendung von Deadlines manuell gesetzt. Die Deadlines werden im Moment nicht berücksichtigt.");
             $content->setVariable("DEADLINE_OVERRIDE_LABEL", "Deadlines aktivieren");
             $params = "{ id : " . $pyramidRoom->get_id() . ", action : 'deadlines' }";
             $content->setVariable("DEADLINE_OVERRIDE_ACTION", "sendRequest('Index', " . $params . ", '" . $pyramidRoom->get_id() . "', 'reload');");
         } else {
             $content->setVariable("DEADLINE_VALUE", "keine");
             $content->setVariable("DISPLAY_OVERRIDE", "none");
         }
     }
     $content->setVariable("INFO_LABEL", "Infotext:");
     $content->setVariable("INFO_VALUE", nl2br($pyramidRoom->get_attribute("OBJ_DESC")));
     $content->parse("BEGIN BLOCK_PYRAMID_INFORMATION");
     // display pyramid
     $content->setCurrentBlock("BLOCK_PYRAMID");
     // create array to store the users for all positions
     $users = array();
     for ($count = 1; $count <= $maxcol; $count++) {
         for ($count2 = 1; $count2 <= $startElements / pow(2, $count - 1); $count2++) {
             $users[$count . $count2] = array();
         }
     }
     // for every phase
     $maxuser = 1;
     for ($count = 1; $count <= $maxcol; $count++) {
         // if deadlines are used, display deadline of every phase on the top of the phase
         if ($pyramidRoom->get_attribute("PYRAMIDDISCUSSION_USEDEADLINES") == "yes" && $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_OVERRIDE_DEADLINES") == 0 && $phase <= $maxcol) {
             $content->setCurrentBlock("BLOCK_PYRAMID_DEADLINE");
             $content->setVariable("DEADLINE_ID", "deadline" . $count);
             $content->setVariable("DEADLINE_DATE", date("d.m.Y H:i", (int) $deadlines[$count]));
             $content->parse("BLOCK_PYRAMID_DEADLINE");
         }
         // create user array
         for ($count2 = 1; $count2 <= $startElements / pow(2, $count - 1); $count2++) {
             $position = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $pyramidRoom->get_path() . "/Position_" . $count . "_" . $count2);
             $positionGroup = $position->get_attribute("PYRAMIDDISCUSSION_RELGROUP");
             $positionMembers = $positionGroup->get_members();
             // add the users from the positions in the first phase to their corresponding arrays
             if ($count == 1) {
                 if ($positionMembers instanceof \steam_user) {
                     $users[$count . $count2] = $positionMembers->get_id();
                     if ($positionMembers->get_id() == $userID) {
                         $currentUserGroup = $positionGroup->get_id();
                     }
                 } else {
                     foreach ($positionMembers as $positionMember) {
                         array_push($users[$count . $count2], $positionMember->get_id());
                         if ($positionMember->get_id() == $userID) {
                             $currentUserGroup = $positionGroup->get_id();
                         }
                     }
                 }
                 if (count($users[$count . $count2]) > $maxuser) {
                     $maxuser = count($users[$count . $count2]);
                 }
                 // add users to the arrays of the positions for all other phases
             } else {
                 $users[$count . $count2] = array_merge($users[$count - 1 . ($count2 * 2 - 1)], $users[$count - 1 . $count2 * 2]);
             }
         }
         // for every position in a phase
         for ($count2 = 1; $count2 <= $startElements / pow(2, $count - 1); $count2++) {
             $position = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $pyramidRoom->get_path() . "/Position_" . $count . "_" . $count2);
             $positionGroup = $position->get_attribute("PYRAMIDDISCUSSION_RELGROUP");
             $positionMembers = $positionGroup->get_members();
             // get the names from all users of the current position (that still take part in the discussion)
             $participants = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_PARTICIPANT_MANAGEMENT");
             foreach ($users[$count . $count2] as $currentUserID) {
                 if (!isset($participants[$currentUserID])) {
                     $participants[$currentUserID] = 0;
                     $pyramidRoom->set_attribute("PYRAMIDDISCUSSION_PARTICIPANT_MANAGEMENT", $participants);
                 }
                 if ($participants[$currentUserID] == 0 || $participants[$currentUserID] >= $count) {
                     $currentMember = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $currentUserID);
                 }
             }
             // get position read states
             $read_states = $position->get_attribute("PYRAMIDDISCUSSION_POS_READ_STATES");
             if (!is_array($read_states)) {
                 $read_states = array();
             }
             // determine if there are unread comments for the current position
             $comments_read = 1;
             $comments = $position->get_annotations();
             foreach ($comments as $comment) {
                 $comment_read_states = $comment->get_attribute("PYRAMIDDISCUSSION_COMMENT_READ_STATES");
                 if (!is_array($comment_read_states)) {
                     $comment_read_states = array();
                 }
                 if (!array_key_exists($userID, $comment_read_states) || $comment_read_states[$userID] != "1") {
                     $comments_read = 0;
                     break;
                 }
             }
             $read = false;
             $content->setCurrentBlock("BLOCK_PYRAMID_POSITION");
             $state = "phase" . $count . " ";
             if ($count <= $phase && count($users[$count . $count2]) > 0) {
                 $state = $state . "active ";
             } else {
                 if (!($phase == 0 && $count == 1) || $phase != 0 && count($users[$count . $count2]) == 0) {
                     $state = $state . "inactive ";
                     $content->setVariable("POSITION_ACTION_HIDDEN", "hidden");
                     $read = true;
                 } else {
                     $state = $state . "active ";
                 }
             }
             if (in_array($userID, $users[$count . $count2])) {
                 $state = $state . "my ";
                 if ($phase != 0) {
                     if ($phase == $count && (!isset($user_management[$currentUserID]) || $user_management[$currentUserID] == 0 || $user_management[$currentUserID] >= $count)) {
                         // current discussion phase
                         $content->setVariable("POSITION_ACTION_LABEL", "Position lesen<br>und bearbeiten");
                         $content->setVariable("COMMENTS_URL", 'href="' . $pyramiddiscussionExtension->getExtensionUrl() . 'ViewPosition/' . $pyramidRoom->get_id() . '/' . $position->get_id() . '#comments"');
                     } else {
                         if ($count < $phase) {
                             // previous discussion phase
                             $content->setVariable("POSITION_ACTION_LABEL", "Position lesen");
                             $content->setVariable("COMMENTS_URL", 'href="' . $pyramiddiscussionExtension->getExtensionUrl() . 'ViewPosition/' . $pyramidRoom->get_id() . '/' . $position->get_id() . '#comments"');
                         }
                     }
                     $content->setVariable("POSITION_ACTION_URL", $pyramiddiscussionExtension->getExtensionUrl() . "ViewPosition/" . $pyramidRoom->get_id() . "/" . $position->get_id());
                     if (array_key_exists($userID, $read_states) && $read_states[$userID] == "1" || $position->get_content() == "0" || $position->get_content() == "") {
                         $read = true;
                     }
                 } else {
                     // group choosing phase, my position
                     $content->setVariable("POSITION_ACTION_LABEL", "Position<br>verlassen");
                     $params = "{ id : " . $position->get_id() . ", pyramid : " . $pyramidRoom->get_id() . ", action : 'join', formergroup : " . $currentUserGroup . ", newgroup : " . $positionGroup->get_id() . " }";
                     $content->setVariable("POSITION_ACTION_URL", "javascript:sendRequest('EditPosition', " . $params . ", '" . $position->get_id() . "', 'reload');");
                     $read = true;
                 }
             } else {
                 if ($phase != 0) {
                     if ($count < $phase) {
                         // previous discussion phase, other positions (reading allowed)
                         $content->setVariable("POSITION_ACTION_LABEL", "Position lesen");
                         $content->setVariable("POSITION_ACTION_URL", $pyramiddiscussionExtension->getExtensionUrl() . "ViewPosition/" . $pyramidRoom->get_id() . "/" . $position->get_id());
                         if (array_key_exists($userID, $read_states) && $read_states[$userID] == "1" || $position->get_content() == "0" || $position->get_content() == "") {
                             $read = true;
                         }
                         $content->setVariable("COMMENTS_URL", 'href="' . $pyramiddiscussionExtension->getExtensionUrl() . 'ViewPosition/' . $pyramidRoom->get_id() . '/' . $position->get_id() . '#comments"');
                     } else {
                         if ($phase == $count) {
                             // current discussion phase, other positions (reading not allowed)
                             $content->setVariable("POSITION_ACTION_HIDDEN", "hidden");
                             $read = true;
                         }
                     }
                 } else {
                     // group choosing phase, other positions
                     $content->setVariable("POSITION_ACTION_LABEL", "Position<br>beitreten");
                     $params = "{ id : " . $position->get_id() . ", pyramid : " . $pyramidRoom->get_id() . ", action : 'join', formergroup : " . $currentUserGroup . ", newgroup : " . $positionGroup->get_id() . " }";
                     $content->setVariable("POSITION_ACTION_URL", "javascript:sendRequest('EditPosition', " . $params . ", '" . $position->get_id() . "', 'reload');");
                     $read = true;
                 }
             }
             if ($read) {
                 $state = $state . "read";
                 $content->setVariable("READSTATUS_ICON", "read_position");
                 $content->setVariable("READSTATUS_TITLE", "Position gelesen");
             } else {
                 $state = $state . "unread";
                 $content->setVariable("READSTATUS_ICON", "not_read_position");
                 $content->setVariable("READSTATUS_TITLE", "Position ungelesen");
             }
             if ($phase > 0 && $phase != $maxcol + 2 && (isset($options["show_adminoptions"]) && $options["show_adminoptions"] == "true")) {
                 $content->setVariable("POSITION_ACTION_URL", $pyramiddiscussionExtension->getExtensionUrl() . "ViewPosition/" . $pyramidRoom->get_id() . "/" . $position->get_id());
                 $content->setVariable("POSITION_ACTION_HIDDEN", "");
                 $content->setVariable("POSITION_ACTION_LABEL", "Position lesen<br>und bearbeiten");
                 $content->setVariable("COMMENTS_URL", 'href="' . $pyramiddiscussionExtension->getExtensionUrl() . 'ViewPosition/' . $pyramidRoom->get_id() . '/' . $position->get_id() . '#comments"');
             }
             $content->setVariable("POSITION_ID", "position" . $count . $count2);
             $content->setVariable("POSITION_STATE", $state);
             $content->setVariable("POSITION_LABEL", "Position " . $count . "-" . $count2);
             $content->setVariable("ASSETURL", $pyramiddiscussionExtension->getAssetUrl());
             if ($comments_read == 1) {
                 $content->setVariable("ANNOTATION_COUNT", count($comments));
                 $content->setVariable("ANNOTATION_TITLE", "Keine ungelesenen Kommentare vorhanden");
                 $content->setVariable("COMMENTSTATUS_ICON", "no_comments");
             } else {
                 $content->setVariable("ANNOTATION_COUNT", "<b>" . count($comments) . "</b>");
                 $content->setVariable("ANNOTATION_TITLE", "Ungelesene Kommentare vorhanden");
                 $content->setVariable("COMMENTSTATUS_ICON", "comments");
             }
             foreach ($users[$count . $count2] as $currentUserID) {
                 if (!isset($user_management[$currentUserID]) || $user_management[$currentUserID] == 0 || $user_management[$currentUserID] >= $count) {
                     $currentUser = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $currentUserID);
                     $pic_id = $currentUser->get_attribute("OBJ_ICON")->get_id();
                     $pic_link = $pic_id == 0 ? PATH_URL . "styles/standard/images/anonymous.jpg" : PATH_URL . "download/image/" . $pic_id . "/15/20";
                     $content->setCurrentBlock("BLOCK_PYRAMID_POSITION_USER");
                     $content->setVariable("USER_URL", PATH_URL . "user/index/" . $currentUser->get_name());
                     $content->setVariable("PIC_URL", $pic_link);
                     $content->setVariable("USER_NAME", $currentUser->get_full_name());
                     $content->parse("BLOCK_PYRAMID_POSITION_USER");
                 }
             }
             $content->parse("BLOCK_PYRAMID_POSITION");
         }
     }
     $heights = array();
     $heights[0] = 5;
     // gap
     switch ($maxuser) {
         case 1:
             $heights[1] = 106;
             break;
         case 2:
             $heights[1] = 126;
             break;
         case 3:
             $heights[1] = 146;
             break;
         case 4:
             $heights[1] = 166;
             break;
         default:
             $heights[1] = 176;
             break;
     }
     $heights[2] = 2 * $heights[1] - 0.5 * $heights[1] + 1 * $heights[0];
     $heights[3] = 3 * $heights[1] + 2 * $heights[0];
     $heights[4] = 4 * $heights[1] + 3 * $heights[0];
     $heights[5] = 8 * $heights[1] + 7 * $heights[0];
     $heights[6] = 16 * $heights[1] + 15 * $heights[0];
     $heights[7] = 32 * $heights[1] + 31 * $heights[0];
     // special case
     if ($maxcol == 3) {
         $heights[3] = 2 * $heights[1] + 1 * $heights[0];
     }
     $css = "";
     for ($count = 1; $count <= $maxcol; $count++) {
         $css = $css . ".phase" . $count . " { width: 120px; height: " . $heights[$count] . "px; } \n";
     }
     // background triangle
     $triangle = $startElements * ($heights[0] + $heights[1]) * 0.5 + 16;
     $triangle_end = array(0, 300, 450, 600, 720);
     if ($startElements <= 16) {
         $css = $css . "\n\t\t\t.pyramid_triangle {\n\t  \t\t\tborder-color: transparent transparent transparent #FDF1A7;\n\t  \t\t\tborder-style: solid;\n\t  \t\t\tborder-width: " . $triangle . "px 0px " . $triangle . "px " . $triangle_end[$maxcol - 1] . "px;\n\t  \t\t\twidth:0px;\n\t  \t\t\theight:0px;\n\t\t\t}";
     }
     $content->setVariable("CSS_HEIGHTS", $css);
     $content->setVariable("JS_STARTPOSITIONS", $startElements);
     $content->setVariable("JS_GAP", $heights[0]);
     $content->setVariable("JS_HEIGHT", $heights[1]);
     $content->setVariable("JS_DEADLINES", $deadlines_used);
     $content->setVariable("EMPTY_DIV_HEIGHT", $startElements * ($heights[0] + $heights[1]) + 16 . "px");
     $content->parse("BLOCK_PYRAMID");
     $rawWidget = new \Widgets\RawHtml();
     $rawWidget->setHtml($content->get());
     $frameResponseObject->addWidget($rawWidget);
     $frameResponseObject->setHeadline("Pyramidendiskussion: " . $pyramidRoom->get_name());
     return $frameResponseObject;
 }
Ejemplo n.º 3
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $rapidfeedback = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $RapidfeedbackExtension = \Rapidfeedback::getInstance();
     $RapidfeedbackExtension->addJS();
     // admin action (start, stop, copy, delete) got submitted
     if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["admin_action"])) {
         $element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["element_id"]);
         if ($element instanceof \steam_object) {
             switch ($_POST["admin_action"]) {
                 case 1:
                     $element->set_attribute("RAPIDFEEDBACK_STATE", 1);
                     break;
                 case 2:
                     $element->set_attribute("RAPIDFEEDBACK_STATE", 2);
                     break;
                 case 3:
                     $copy = \steam_factory::create_copy($GLOBALS["STEAM"]->get_id(), $element);
                     $copy->move($rapidfeedback);
                     $copy->set_attribute("RAPIDFEEDBACK_PARTICIPANTS", array());
                     $copy->set_attribute("RAPIDFEEDBACK_STATE", 0);
                     $copy->set_attribute("RAPIDFEEDBACK_RESULTS", 0);
                     $copy->set_attribute("RAPIDFEEDBACK_STARTTYPE", 0);
                     $resultContainer = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $copy->get_path() . "/results");
                     $results = $resultContainer->get_inventory();
                     foreach ($results as $result) {
                         $result->delete();
                     }
                     break;
                 case 4:
                     $element->delete();
                     break;
             }
         }
     }
     // edit configuration got submitted
     if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["edit_rapidfeedback"])) {
         $rapidfeedback->set_name($_POST["title"]);
         $rapidfeedback->set_attribute("OBJ_DESC", $_POST["desc"]);
         if (isset($_POST["adminsurvey"]) && $_POST["adminsurvey"] == "on") {
             $rapidfeedback->set_attribute("RAPIDFEEDBACK_ADMIN_SURVEY", 1);
         } else {
             $rapidfeedback->set_attribute("RAPIDFEEDBACK_ADMIN_SURVEY", 0);
         }
     }
     // create/edit survey got submitted
     if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["create_survey"])) {
         $survey_object = new \Rapidfeedback\Model\Survey($rapidfeedback);
         $survey_object->setName($_POST["title"]);
         $survey_object->setBeginText($_POST["begintext"]);
         $survey_object->setEndText($_POST["endtext"]);
         $questioncounter = 0;
         $sortedQuestions = $_POST["sortable_array"];
         $sortedQuestions != '' ? $sortedQuestions = explode(',', $sortedQuestions) : '';
         foreach ($sortedQuestions as $question) {
             if ($question != "newquestion" && $question != "newlayout" && $question != "") {
                 $questionValues = $_POST[$question];
                 $questionValues != '' ? $questionValues = explode(',', $questionValues) : '';
                 switch ($questionValues[0]) {
                     case 0:
                         $newquestion = new \Rapidfeedback\Model\TextQuestion();
                         break;
                     case 1:
                         $newquestion = new \Rapidfeedback\Model\TextareaQuestion();
                         break;
                     case 2:
                         $newquestion = new \Rapidfeedback\Model\SingleChoiceQuestion();
                         $options = $_POST[$question . "_options"];
                         $options != '' ? $options = explode(',', $options) : '';
                         foreach ($options as $option) {
                             $newquestion->addOption(rawurldecode($option));
                         }
                         $newquestion->setArrangement($questionValues[4]);
                         break;
                     case 3:
                         $newquestion = new \Rapidfeedback\Model\MultipleChoiceQuestion();
                         $options = $_POST[$question . "_options"];
                         $options != '' ? $options = explode(',', $options) : '';
                         foreach ($options as $option) {
                             $newquestion->addOption(rawurldecode($option));
                         }
                         $newquestion->setArrangement($questionValues[4]);
                         break;
                     case 4:
                         $newquestion = new \Rapidfeedback\Model\MatrixQuestion();
                         $columns = $_POST[$question . "_columns"];
                         $columns != '' ? $columns = explode(',', $columns) : '';
                         foreach ($columns as $column) {
                             $newquestion->addcolumn(rawurldecode($column));
                         }
                         $rows = $_POST[$question . "_rows"];
                         $rows != '' ? $rows = explode(',', $rows) : '';
                         foreach ($rows as $row) {
                             $newquestion->addRow(rawurldecode($row));
                         }
                         break;
                     case 5:
                         $newquestion = new \Rapidfeedback\Model\GradingQuestion();
                         $options = $_POST[$question . "_rows"];
                         $options != '' ? $options = explode(',', $options) : '';
                         foreach ($options as $option) {
                             $newquestion->addRow(rawurldecode($option));
                         }
                         break;
                     case 6:
                         $newquestion = new \Rapidfeedback\Model\TendencyQuestion();
                         $options = $_POST[$question . "_options"];
                         $options != '' ? $options = explode(',', $options) : '';
                         $newquestion->setSteps($questionValues[4]);
                         for ($count = 0; $count < count($options); $count = $count + 2) {
                             $newquestion->addOption(array($options[$count], $options[$count + 1]));
                         }
                         break;
                 }
                 $newquestion->setQuestionText(rawurldecode($questionValues[1]));
                 $newquestion->setHelpText(rawurldecode($questionValues[2]));
                 $newquestion->setRequired($questionValues[3]);
                 $survey_object->addQuestion($newquestion);
             }
         }
         if ($_POST["starttype"] == 1) {
             $survey_object->setStartType(1, $_POST["begin"], $_POST["end"]);
         } else {
             $survey_object->setStartType(0);
         }
         if (isset($this->params[1])) {
             $survey_object->createSurvey($this->params[1]);
         } else {
             $survey_object->createSurvey();
         }
     }
     // display actionbar if current user is admin
     $staff = $rapidfeedback->get_attribute("RAPIDFEEDBACK_STAFF");
     $admin = 0;
     if ($staff instanceof \steam_group && $staff->is_member($user) || $staff instanceof \steam_user && $staff->get_id() == $user->get_id()) {
         $admin = 1;
         $actionbar = new \Widgets\Actionbar();
         $actions = array(array("name" => "Konfiguration", "link" => $RapidfeedbackExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Import", "link" => $RapidfeedbackExtension->getExtensionUrl() . "import/" . $this->id), array("name" => "Umfrage erstellen", "link" => $RapidfeedbackExtension->getExtensionUrl() . "edit/" . $this->id));
         $actionbar->setActions($actions);
         $frameResponseObject->addWidget($actionbar);
     }
     // get the surveys that are to be shown and sort them
     $surveys = $rapidfeedback->get_inventory();
     $surveys_inactive = array();
     $surveys_running = array();
     $surveys_ended = array();
     foreach ($surveys as $survey) {
         if ($survey instanceof \steam_container && !$survey instanceof \steam_user) {
             $starttype = $survey->get_attribute("RAPIDFEEDBACK_STARTTYPE");
             $state = $survey->get_attribute("RAPIDFEEDBACK_STATE");
             // if survey is started/ended automatically check the times
             if (is_array($starttype)) {
                 if (time() > $starttype[1] && $state == 0) {
                     $survey->set_attribute("RAPIDFEEDBACK_STATE", 1);
                 }
                 if (time() > $starttype[0] && $state == 1) {
                     $survey->set_attribute("RAPIDFEEDBACK_STATE", 2);
                 }
             }
             $state = $survey->get_attribute("RAPIDFEEDBACK_STATE");
             if ($state == 0) {
                 array_push($surveys_inactive, $survey);
             } else {
                 if ($state == 1) {
                     $participants = $survey->get_attribute("RAPIDFEEDBACK_PARTICIPANTS");
                     if ($admin == 1 || !in_array($user->get_id(), $participants)) {
                         array_push($surveys_running, $survey);
                     }
                 } else {
                     array_push($surveys_ended, $survey);
                 }
             }
         }
     }
     usort($surveys_inactive, "sort_workplans");
     usort($surveys_running, "sort_workplans");
     usort($surveys_ended, "sort_workplans");
     if ($admin == 1) {
         $surveys = array_merge($surveys_inactive, $surveys_running, $surveys_ended);
     } else {
         $surveys = $surveys_running;
     }
     // display surveys
     $content = $RapidfeedbackExtension->loadTemplate("rapidfeedback_index.template.html");
     if (count($surveys) == 0) {
         $content->setCurrentBlock("BLOCK_NO_SURVEYS");
         $content->setVariable("NO_SURVEYS", "Keine Umfragen vorhanden.");
         $content->setVariable("RAPIDFEEDBACK_NAME", $rapidfeedback->get_name());
         if ($rapidfeedback->get_attribute("OBJ_DESC") != "0") {
             $content->setVariable("RAPIDFEEDBACK_DESC", $rapidfeedback->get_attribute("OBJ_DESC"));
         }
         $content->parse("BLOCK_NO_SURVEYS");
     } else {
         $content->setCurrentBlock("BLOCK_SURVEY_TABLE");
         $content->setVariable("RAPIDFEEDBACK_NAME", $rapidfeedback->get_name());
         if ($rapidfeedback->get_attribute("OBJ_DESC") != "0") {
             $content->setVariable("RAPIDFEEDBACK_DESC", $rapidfeedback->get_attribute("OBJ_DESC"));
         }
         $content->setVariable("NAME_LABEL", "Name der Umfrage");
         $content->setVariable("STATUS_LABEL", "Status");
         $content->setVariable("QUESTIONS_LABEL", "Anzahl der Fragen");
         $content->setVariable("RESULTS_LABEL", "Anzahl der Abgaben");
         $content->setVariable("ACTIONS_LABEL", "Aktionen");
         foreach ($surveys as $survey) {
             $content->setCurrentBlock("BLOCK_SURVEY_ELEMENT");
             $content->setVariable("NAME_VALUE", $survey->get_name());
             $participants = $survey->get_attribute("RAPIDFEEDBACK_PARTICIPANTS");
             $state = $survey->get_attribute("RAPIDFEEDBACK_STATE");
             $adminsAllowed = $rapidfeedback->get_attribute("RAPIDFEEDBACK_ADMIN_SURVEY");
             if ($admin == 1 && in_array($user->get_id(), $participants) | $state != 1 | $adminsAllowed == 0) {
                 $content->setVariable("DISPLAY_LINK", "none");
                 $content->setVariable("NAME_DONE", $survey->get_name());
             }
             $starttype = $survey->get_attribute("RAPIDFEEDBACK_STARTTYPE");
             if ($state == 0) {
                 if (is_array($starttype)) {
                     $content->setVariable("STATE_VALUE", "Inaktiv (Start: " . date('d.m.Y', $starttype[1]) . ")");
                     $content->setVariable("DISPLAY_START", "none");
                 } else {
                     $content->setVariable("STATE_VALUE", "Inaktiv");
                 }
                 $content->setVariable("DISPLAY_RESULTS", "none");
                 $content->setVariable("DISPLAY_STOP", "none");
                 $content->setVariable("DISPLAY_REPEAT", "none");
             } else {
                 if ($state == 1) {
                     if (is_array($starttype)) {
                         $content->setVariable("STATE_VALUE", "Aktiv (Ende: " . date('d.m.Y', $starttype[0]) . ")");
                         $content->setVariable("DISPLAY_STOP", "none");
                     } else {
                         $content->setVariable("STATE_VALUE", "Aktiv");
                     }
                     $content->setVariable("DISPLAY_EDIT", "none");
                     $content->setVariable("DISPLAY_START", "none");
                     $content->setVariable("DISPLAY_REPEAT", "none");
                     if ($survey->get_attribute("RAPIDFEEDBACK_RESULTS") == 0) {
                         $content->setVariable("DISPLAY_RESULTS", "none");
                     }
                 } else {
                     $content->setVariable("STATE_VALUE", "Beendet");
                     $content->setVariable("DISPLAY_EDIT", "none");
                     $content->setVariable("DISPLAY_START", "none");
                     $content->setVariable("DISPLAY_STOP", "none");
                     if ($survey->get_attribute("RAPIDFEEDBACK_RESULTS") == 0) {
                         $content->setVariable("DISPLAY_RESULTS", "none");
                     }
                 }
             }
             $content->setVariable("QUESTIONS_VALUE", $survey->get_attribute("RAPIDFEEDBACK_QUESTIONS"));
             $content->setVariable("RESULTS_VALUE", $survey->get_attribute("RAPIDFEEDBACK_RESULTS"));
             $content->setVariable("ASSET_URL", $RapidfeedbackExtension->getAssetUrl() . "icons");
             $content->setVariable("PREVIEW_TITLE", "Vorschau");
             $content->setVariable("VIEW_URL", $RapidfeedbackExtension->getExtensionUrl() . "view/" . $this->id . "/" . $survey->get_id());
             $content->setVariable("PREVIEW_URL", $RapidfeedbackExtension->getExtensionUrl() . "view/" . $this->id . "/" . $survey->get_id() . "/1");
             $content->setVariable("EDIT_TITLE", "Umfrage bearbeiten");
             $content->setVariable("EDIT_URL", $RapidfeedbackExtension->getExtensionUrl() . "edit/" . $this->id . "/" . $survey->get_id());
             $content->setVariable("RESULTS_TITLE", "Auswertung");
             $content->setVariable("RESULTS_URL", $RapidfeedbackExtension->getExtensionUrl() . "results/" . $this->id . "/" . $survey->get_id());
             $content->setVariable("DELETE_TITLE", "Umfrage löschen");
             $content->setVariable("START_TITLE", "Umfrage starten");
             $content->setVariable("STOP_TITLE", "Umfrage beenden");
             $content->setVariable("REPEAT_TITLE", "Umfrage wiederholen");
             $content->setVariable("ELEMENT_ID", $survey->get_id());
             if ($admin == 0) {
                 $content->setVariable("DISPLAY_ADMIN_ELEMENT", "none");
             }
             $content->parse("BLOCK_SURVEY_ELEMENT");
         }
         if ($admin == 0) {
             $content->setVariable("DISPLAY_ADMIN", "none");
         }
         $content->parse("BLOCK_SURVEY_TABLE");
     }
     $group = $rapidfeedback->get_attribute("RAPIDFEEDBACK_GROUP");
     if ($group->get_name() == "learners") {
         $parent = $group->get_parent_group();
         $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")";
         $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id();
     } else {
         $courseOrGroup = "Gruppe: " . $group->get_name();
         $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id();
     }
     $rawWidget = new \Widgets\RawHtml();
     $rawWidget->setHtml($content->get());
     $frameResponseObject->addWidget($rawWidget);
     $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Rapid Feedback")));
     return $frameResponseObject;
 }
Ejemplo n.º 4
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $TCR = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $TCRExtension = \TCR::getInstance();
     $TCRExtension->addCSS();
     // determine kind of documents of the current user to display (0 = theses, 1 = reviews, 2 = responses)
     $kindOfDocument = 0;
     if (isset($this->params[1])) {
         $kindOfDocument = $this->params[1];
     }
     // release document dialog was submitted
     if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["release_element"])) {
         $element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["element_id"]);
         if ($_POST["kind"] == 0) {
             $critics = array();
             $critics[$_POST["critic"]] = 0;
             $element->set_attribute("TCR_REVIEWS", $critics);
             $element->set_attribute("TCR_RELEASED", time());
         } else {
             $element->set_attribute("TCR_RELEASED", time());
         }
     }
     // edit document dialog was submitted
     if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["edit_element"])) {
         $old_element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["old_id"]);
         // old element was plain text
         if ($old_element->get_attribute("DOC_MIME_TYPE") == "text/plain") {
             // new element is plain text
             if ($_POST["new_upload_text"] == 0) {
                 $old_element->set_name($_POST["title"]);
                 $old_element->set_attribute("OBJ_DESC", $_POST["desc"]);
                 $old_element->set_content($_POST["content"]);
                 // new element is an upload
             } else {
                 $old_element->delete();
                 $radio = 1;
             }
             // old element was an upload
         } else {
             // new element is the same
             if ($_POST["new_upload"] == 0) {
                 $old_element->set_name($_POST["title"]);
                 $old_element->set_attribute("OBJ_DESC", $_POST["desc"]);
                 // new element is a new upload
             } else {
                 if ($_POST["new_upload"] == 1) {
                     $old_element->delete();
                     $radio = 1;
                     // new element is plain text
                 } else {
                     $old_element->set_attribute("DOC_MIME_TYPE", "text/plain");
                     $old_element->set_name($_POST["title"]);
                     $old_element->set_attribute("OBJ_DESC", $_POST["desc"]);
                     $old_element->set_content($_POST["new_content"]);
                 }
             }
         }
     }
     // if a new element got created or already existing element gets a new upload
     if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["create_element"]) || isset($radio)) {
         $problems = "";
         $hints = "";
         if (!isset($radio)) {
             $radio = $_POST["radio"];
         }
         if ($radio == 1) {
             // handle upload
             require_once PATH_LIB . "format_handling.inc.php";
             $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 (empty($_FILES) || !empty($_FILES["file"]["error"]) && $_FILES["file"]["error"] > 0) {
                 if (!empty($_FILES) && empty($_FILES["file"]["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["file"]["tmp_name"]);
                 $type = $_FILES["file"]["type"];
             }
         } else {
             $content = $_POST["content"];
             $type = "text/plain";
         }
         if ($_POST["kind"] == 0) {
             $container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/theses");
         } else {
             if ($_POST["kind"] == 1) {
                 $container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/reviews");
             } else {
                 $container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/responses");
             }
         }
         $title = $_POST["title"];
         $desc = $_POST["desc"];
         if (empty($problems)) {
             $new_element = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $title, $content, $type, $container, $desc);
             if ($_POST["kind"] == 0) {
                 $new_element->set_attribute("TCR_ROUND", $_POST["round"]);
                 $new_element->set_attribute("TCR_REVIEWS", array());
                 $new_element->set_attribute("TCR_RELEASED", 0);
             } else {
                 if ($_POST["kind"] == 1) {
                     $new_element->set_attribute("TCR_RELEASED", 0);
                     $correspondingThesis = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["elementID"]);
                     $critics_thesis = $correspondingThesis->get_attribute("TCR_REVIEWS");
                     $critics_thesis[$user->get_id()] = $new_element->get_id();
                     $correspondingThesis->set_attribute("TCR_REVIEWS", $critics_thesis);
                 } else {
                     $new_element->set_attribute("TCR_RELEASED", 0);
                     $correspondingReview = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["elementID"]);
                     $correspondingReview->set_attribute("TCR_RESPONSE", $new_element->get_id());
                 }
             }
         } else {
             $frameResponseObject->setProblemDescription($problems);
             $frameResponseObject->setProblemSolution($hints);
         }
     }
     // display actionbar
     $actionbar = new \Widgets\Actionbar();
     $admins = $TCR->get_attribute("TCR_ADMINS");
     if (in_array($user->get_id(), $admins)) {
         $actions = array(array("name" => "Konfiguration", "link" => $TCRExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id));
     } else {
         $actions = array(array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id));
     }
     $actionbar->setActions($actions);
     $frameResponseObject->addWidget($actionbar);
     $group = $TCR->get_attribute("TCR_GROUP");
     if ($group->get_name() == "learners") {
         $parent = $group->get_parent_group();
         $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")";
         $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id();
     } else {
         $courseOrGroup = "Gruppe: " . $group->get_name();
         $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id();
     }
     $content = $TCRExtension->loadTemplate("tcr_privatedocuments.template.html");
     // display a message if current user is not a user of this tcr
     $members = $TCR->get_attribute("TCR_USERS");
     if (!in_array($user->get_id(), $members)) {
         $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE");
         $content->setVariable("DISPLAY_TABLE", "none");
         $content->setVariable("NOT_USER", "Sie sind nicht als Teilnehmer dieses Thesen-Kritik-Replik-Verfahrens eingetragen. Wenden Sie sich an einen Administrator.");
         $content->parse("BLOCK_DOCUMENTS_TABLE");
         $rawWidget = new \Widgets\RawHtml();
         $rawWidget->setHtml($content->get());
         $frameResponseObject->addWidget($rawWidget);
         $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Private Dokumente")));
         return $frameResponseObject;
     }
     // display tabbar
     $tabBar = new \Widgets\TabBar();
     $tabBar->setTabs(array(array("name" => "Thesen", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Kritiken", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id . "/1"), array("name" => "Repliken", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id . "/2")));
     $tabBar->setActiveTab($kindOfDocument);
     $frameResponseObject->addWidget($tabBar);
     // create array structure and add theses for their round
     $rounds = $TCR->get_attribute("TCR_ROUNDS");
     $theses_container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/theses");
     $theses_inventory = $theses_container->get_inventory();
     $theses = array();
     $theses_response = array();
     foreach ($theses_inventory as $thesis) {
         $current_round = $thesis->get_attribute("TCR_ROUND");
         if ($thesis->get_creator()->get_id() == $user->get_id()) {
             $theses[$current_round] = $thesis;
         }
         $critics = $thesis->get_attribute("TCR_REVIEWS");
         if (is_array($critics)) {
             if (array_key_exists($user->get_id(), $critics)) {
                 $theses_response[$current_round] = $thesis;
             }
         }
     }
     // display private documents table
     $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE");
     if ($kindOfDocument == 0 || $kindOfDocument == 2) {
         $content->setVariable("THESES_LABEL", "Erstellte Thesen");
         $content->setVariable("REVIEWS_LABEL", "Erhaltene Kritiken");
         $content->setVariable("RESPONSES_LABEL", "Erstellte Repliken");
         if ($kindOfDocument == 0) {
             // thesis view
             for ($count = 1; $count <= $rounds; $count++) {
                 $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE_ELEMENT");
                 $content->setVariable("ROUND_VALUE", "Runde " . $count);
                 if (!array_key_exists($count, $theses)) {
                     $content->setVariable("CREATE_THESIS", "These erstellen");
                     $content->setVariable("THESIS_ICON", "create_32");
                     $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "create/" . $this->id . "/" . $count . "/" . $kindOfDocument);
                     $content->setVariable("DISPLAY_THESIS_SECOND", "none");
                     $content->setVariable("DISPLAY_REVIEW", "none");
                     $content->setVariable("DISPLAY_RESPONSE", "none");
                 } else {
                     $current_critics = $theses[$count]->get_attribute("TCR_REVIEWS");
                     if (count($current_critics) > 0) {
                         $content->setVariable("CREATE_THESIS", "Anzeigen");
                         $content->setVariable("THESIS_ICON", "view_32");
                         $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "release/" . $theses[$count]->get_id());
                         $content->setVariable("DISPLAY_THESIS_SECOND", "none");
                         foreach ($current_critics as $critic => $review) {
                             if ($review == 0) {
                                 $content->setVariable("DISPLAY_REVIEW", "none");
                                 $content->setVariable("DISPLAY_RESPONSE", "none");
                                 $review_released = 0;
                             } else {
                                 $current_review = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $review);
                                 $review_released = $current_review->get_attribute("TCR_RELEASED");
                             }
                             if ($review_released != 0) {
                                 $content->setVariable("CREATE_REVIEW", "Anzeigen");
                                 $content->setVariable("REVIEW_ICON", "view_32");
                                 $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_review->get_id());
                                 $content->setVariable("DISPLAY_REVIEW_SECOND", "none");
                                 $responseID = $current_review->get_attribute("TCR_RESPONSE");
                                 if ($responseID == 0) {
                                     $response_released = 0;
                                 } else {
                                     $response_element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $responseID);
                                     $response_released = $response_element->get_attribute("TCR_RELEASED");
                                 }
                                 if ($response_released == 0) {
                                     $content->setVariable("DISPLAY_RESPONSE", "none");
                                 } else {
                                     $content->setVariable("CREATE_RESPONSE", "Anzeigen");
                                     $content->setVariable("RESPONSE_ICON", "view_32");
                                     $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "release/" . $response_element->get_id());
                                     $content->setVariable("DISPLAY_RESPONSE_SECOND", "none");
                                 }
                             } else {
                                 $content->setVariable("DISPLAY_REVIEW", "none");
                                 $content->setVariable("DISPLAY_RESPONSE", "none");
                             }
                         }
                     } else {
                         $content->setVariable("CREATE_THESIS", "Anzeigen / Bearbeiten");
                         $content->setVariable("THESIS_ICON", "view_32");
                         $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "edit/" . $theses[$count]->get_id());
                         $content->setVariable("THESIS_ICON2", "release_32");
                         $content->setVariable("THESIS_URL2", $TCRExtension->getExtensionUrl() . "release/" . $theses[$count]->get_id());
                         $content->setVariable("RELEASE_THESIS", "Veröffentlichen");
                         $content->setVariable("DISPLAY_REVIEW", "none");
                         $content->setVariable("DISPLAY_RESPONSE", "none");
                     }
                 }
                 $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl());
                 $content->parse("BLOCK_DOCUMENTS_TABLE_ELEMENT");
             }
             // response view
         } else {
             for ($count = 1; $count <= $rounds; $count++) {
                 $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE_ELEMENT");
                 $content->setVariable("ROUND_VALUE", "Runde " . $count);
                 if (!array_key_exists($count, $theses)) {
                     $content->setVariable("DISPLAY_THESIS", "none");
                     $content->setVariable("DISPLAY_REVIEW", "none");
                     $content->setVariable("DISPLAY_RESPONSE", "none");
                 } else {
                     $current_critics = $theses[$count]->get_attribute("TCR_REVIEWS");
                     if (count($current_critics) > 0) {
                         $content->setVariable("CREATE_THESIS", "Anzeigen");
                         $content->setVariable("THESIS_ICON", "view_32");
                         $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "release/" . $theses[$count]->get_id());
                         $content->setVariable("DISPLAY_THESIS_SECOND", "none");
                         foreach ($current_critics as $critic => $review) {
                             if ($review == 0) {
                                 $review_released = 0;
                             } else {
                                 $current_review = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $review);
                                 $review_released = $current_review->get_attribute("TCR_RELEASED");
                             }
                             if ($review_released != 0) {
                                 $content->setVariable("CREATE_REVIEW", "Anzeigen");
                                 $content->setVariable("REVIEW_ICON", "view_32");
                                 $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_review->get_id());
                                 $content->setVariable("DISPLAY_REVIEW_SECOND", "none");
                                 $responseID = $current_review->get_attribute("TCR_RESPONSE");
                                 if ($responseID == 0) {
                                     $content->setVariable("CREATE_RESPONSE", "Replik erstellen");
                                     $content->setVariable("RESPONSE_ICON", "create_32");
                                     $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "create/" . $this->id . "/" . $count . "/" . $kindOfDocument . "/" . $current_review->get_id());
                                     $content->setVariable("DISPLAY_RESPONSE_SECOND", "none");
                                 } else {
                                     $response_element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $responseID);
                                     $response_released = $response_element->get_attribute("TCR_RELEASED");
                                     if ($response_released == 0) {
                                         $content->setVariable("CREATE_RESPONSE", "Anzeigen / Bearbeiten");
                                         $content->setVariable("RESPONSE_ICON", "view_32");
                                         $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "edit/" . $response_element->get_id());
                                         $content->setVariable("RESPONSE_ICON2", "release_32");
                                         $content->setVariable("RESPONSE_URL2", $TCRExtension->getExtensionUrl() . "release/" . $response_element->get_id());
                                         $content->setVariable("RELEASE_RESPONSE", "Veröffentlichen");
                                     } else {
                                         $content->setVariable("CREATE_RESPONSE", "Anzeigen");
                                         $content->setVariable("RESPONSE_ICON", "view_32");
                                         $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "release/" . $response_element->get_id());
                                         $content->setVariable("DISPLAY_RESPONSE_SECOND", "none");
                                     }
                                 }
                             } else {
                                 $content->setVariable("DISPLAY_REVIEW", "none");
                                 $content->setVariable("DISPLAY_RESPONSE", "none");
                             }
                         }
                     } else {
                         $content->setVariable("DISPLAY_THESIS", "none");
                         $content->setVariable("DISPLAY_REVIEW", "none");
                         $content->setVariable("DISPLAY_RESPONSE", "none");
                     }
                 }
                 $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl());
                 $content->parse("BLOCK_DOCUMENTS_TABLE_ELEMENT");
             }
         }
         // review view
     } else {
         $content->setVariable("THESES_LABEL", "Erhaltene Thesen");
         $content->setVariable("REVIEWS_LABEL", "Erstellte Kritiken");
         $content->setVariable("RESPONSES_LABEL", "Erhaltene Repliken");
         for ($count = 1; $count <= $rounds; $count++) {
             $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE_ELEMENT");
             $content->setVariable("ROUND_VALUE", "Runde " . $count);
             if (!array_key_exists($count, $theses_response)) {
                 $content->setVariable("DISPLAY_THESIS", "none");
                 $content->setVariable("DISPLAY_REVIEW", "none");
                 $content->setVariable("DISPLAY_RESPONSE", "none");
             } else {
                 $content->setVariable("CREATE_THESIS", "Anzeigen");
                 $content->setVariable("THESIS_ICON", "view_32");
                 $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "release/" . $theses_response[$count]->get_id());
                 $content->setVariable("DISPLAY_THESIS_SECOND", "none");
                 $critics_array = $theses_response[$count]->get_attribute("TCR_REVIEWS");
                 if ($critics_array[$user->get_id()] == 0) {
                     $content->setVariable("CREATE_REVIEW", "Kritik erstellen");
                     $content->setVariable("REVIEW_ICON", "create_32");
                     $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "create/" . $this->id . "/" . $count . "/" . $kindOfDocument . "/" . $theses_response[$count]->get_id());
                     $content->setVariable("DISPLAY_REVIEW_SECOND", "none");
                     $content->setVariable("DISPLAY_RESPONSE", "none");
                     $content->setVariable("DISPLAY_RESPONSE_SECOND", "none");
                 } else {
                     $review = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $critics_array[$user->get_id()]);
                     $released = $review->get_attribute("TCR_RELEASED");
                     if ($released == 0) {
                         $content->setVariable("CREATE_REVIEW", "Anzeigen / Bearbeiten");
                         $content->setVariable("REVIEW_ICON", "view_32");
                         $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "edit/" . $review->get_id());
                         $content->setVariable("REVIEW_ICON2", "release_32");
                         $content->setVariable("REVIEW_URL2", $TCRExtension->getExtensionUrl() . "release/" . $review->get_id());
                         $content->setVariable("RELEASE_REVIEW", "Veröffentlichen");
                         $content->setVariable("DISPLAY_RESPONSE", "none");
                     } else {
                         $content->setVariable("CREATE_REVIEW", "Anzeigen");
                         $content->setVariable("REVIEW_ICON", "view_32");
                         $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "release/" . $review->get_id());
                         $content->setVariable("DISPLAY_REVIEW_SECOND", "none");
                         $responseID = $review->get_attribute("TCR_RESPONSE");
                         if ($responseID == 0) {
                             $response_released = 0;
                         } else {
                             $response_element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $responseID);
                             $response_released = $response_element->get_attribute("TCR_RELEASED");
                         }
                         if ($response_released == 0) {
                             $content->setVariable("DISPLAY_RESPONSE", "none");
                         } else {
                             $content->setVariable("CREATE_RESPONSE", "Anzeigen");
                             $content->setVariable("RESPONSE_ICON", "view_32");
                             $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "release/" . $response_element->get_id());
                             $content->setVariable("DISPLAY_RESPONSE_SECOND", "none");
                         }
                     }
                 }
             }
             $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl());
             $content->parse("BLOCK_DOCUMENTS_TABLE_ELEMENT");
         }
     }
     $content->parse("BLOCK_DOCUMENTS_TABLE");
     $rawWidget = new \Widgets\RawHtml();
     $rawWidget->setHtml($content->get());
     $frameResponseObject->addWidget($rawWidget);
     $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Private Dokumente")));
     return $frameResponseObject;
 }
Ejemplo n.º 5
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $TCR = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $TCRExtension = \TCR::getInstance();
     $TCRExtension->addCSS();
     $TCRExtension->addJS();
     $content = $TCRExtension->loadTemplate("tcr_index.template.html");
     $members = $TCR->get_attribute("TCR_USERS");
     // determine which kind of elements is displayed (0 = theses, 1 = reviews, 2 = responses, 3 = all)
     if (isset($this->params[1])) {
         $kind = $this->params[1];
     } else {
         $kind = 3;
     }
     // display actionbar
     $actionbar = new \Widgets\Actionbar();
     $admins = $TCR->get_attribute("TCR_ADMINS");
     if (in_array($user->get_id(), $admins)) {
         $actions = array(array("name" => "Konfiguration", "link" => $TCRExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id));
     } else {
         $actions = array(array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id));
     }
     $actionbar->setActions($actions);
     $frameResponseObject->addWidget($actionbar);
     // display tabbar
     $tabBar = new \Widgets\TabBar();
     $tabBar->setTabs(array(array("name" => "Alle", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id), array("name" => "Thesen", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id . "/0"), array("name" => "Kritiken", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id . "/1"), array("name" => "Repliken", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id . "/2")));
     if ($kind == 3) {
         $tabBar->setActiveTab(0);
     } else {
         $tabBar->setActiveTab($kind + 1);
     }
     $frameResponseObject->addWidget($tabBar);
     // create arrays for every round and add the theses to these arrays
     $rounds = $TCR->get_attribute("TCR_ROUNDS");
     $theses_container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/theses");
     $theses_inventory = $theses_container->get_inventory();
     $theses = array();
     for ($count = 1; $count <= $rounds; $count++) {
         $theses[$count] = array();
     }
     foreach ($theses_inventory as $thesis) {
         $critics = $thesis->get_attribute("TCR_REVIEWS");
         if (count($critics) > 0 && in_array($thesis->get_creator()->get_id(), $members)) {
             $current_round = $thesis->get_attribute("TCR_ROUND");
             array_push($theses[$current_round], $thesis);
         }
     }
     // display documents table
     $content = $TCRExtension->loadTemplate("tcr_documents.template.html");
     $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE");
     $content->setVariable("ROUND_LABEL", "Runde");
     $content->setVariable("DOCUMENT_KIND_LABEL", "Art");
     $content->setVariable("CONTENT_LABEL", "Inhalt");
     $content->setVariable("AUTHOR_LABEL", "Autor(in)");
     $content->setVariable("DATE_LABEL", "Veröffentlicht am");
     $content->setVariable("COMMENTS_LABEL", "Kommentare");
     for ($count = 1; $count <= $rounds; $count++) {
         $content->setCurrentBlock("BLOCK_DOCUMENTS_ROUND");
         $content->setVariable("CURRENT_ROUND", $count . ". Runde");
         $content->setVariable("CURRENT_ROUND_VALUE", $count);
         // display every thesis in the corresponding round
         foreach ($theses[$count] as $current_thesis) {
             if ($kind == 3 || $kind == 0) {
                 $creator = $current_thesis->get_creator();
                 $date = $current_thesis->get_attribute("TCR_RELEASED");
                 $content->setCurrentBlock("BLOCK_DOCUMENTS_ELEMENT");
                 $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl());
                 $content->setVariable("DOCUMENT_KIND", "These");
                 $content->setVariable("ELEMENT_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_thesis->get_id());
                 $content->setVariable("VIEW_ELEMENT", "Inhalt anzeigen");
                 $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl());
                 $content->setVariable("AUTHOR_VALUE", $creator->get_full_name() . " (" . $creator->get_name() . ")");
                 $content->setVariable("DATE_VALUE", date("d.m.Y H:i:s", $date));
                 if (count($current_thesis->get_annotations()) == 1) {
                     $content->setVariable("COMMENTS_VALUE", "(1 Kommentar)");
                 } else {
                     $content->setVariable("COMMENTS_VALUE", "(" . count($current_thesis->get_annotations()) . " Kommentare)");
                 }
                 $content->setVariable("COMMENTS_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_thesis->get_id());
                 $content->parse("BLOCK_DOCUMENTS_ELEMENT");
             }
             $critics = $current_thesis->get_attribute("TCR_REVIEWS");
             // display reviews to the thesis if there are any released ones
             foreach ($critics as $critic => $review) {
                 if ($review != 0) {
                     $review_object = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $review);
                     $review_released = $review_object->get_attribute("TCR_RELEASED");
                     if ($review_released != 0 && in_array($critic, $members)) {
                         if ($kind == 3 || $kind == 1) {
                             $creator = $review_object->get_creator();
                             $date = $review_object->get_attribute("TCR_RELEASED");
                             $content->setCurrentBlock("BLOCK_DOCUMENTS_ELEMENT");
                             $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl());
                             $content->setVariable("DOCUMENT_KIND", "Kritik");
                             $content->setVariable("ELEMENT_URL", $TCRExtension->getExtensionUrl() . "release/" . $review_object->get_id());
                             $content->setVariable("VIEW_ELEMENT", "Inhalt anzeigen");
                             $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl());
                             $content->setVariable("AUTHOR_VALUE", $creator->get_full_name() . " (" . $creator->get_name() . ")");
                             $content->setVariable("DATE_VALUE", date("d.m.Y H:i:s", $date));
                             if (count($review_object->get_annotations()) == 1) {
                                 $content->setVariable("COMMENTS_VALUE", "(1 Kommentar)");
                             } else {
                                 $content->setVariable("COMMENTS_VALUE", "(" . count($review_object->get_annotations()) . " Kommentare)");
                             }
                             $content->setVariable("COMMENTS_URL", $TCRExtension->getExtensionUrl() . "release/" . $review_object->get_id());
                             $content->parse("BLOCK_DOCUMENTS_ELEMENT");
                         }
                         // display response if it exists and is released
                         $response = $review_object->get_attribute("TCR_RESPONSE");
                         if ($response != 0) {
                             $response_object = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $response);
                             $response_released = $response_object->get_attribute("TCR_RELEASED");
                             if ($response_released != 0) {
                                 if ($kind == 3 || $kind == 2) {
                                     $creator = $response_object->get_creator();
                                     $date = $response_object->get_attribute("TCR_RELEASED");
                                     $content->setCurrentBlock("BLOCK_DOCUMENTS_ELEMENT");
                                     $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl());
                                     $content->setVariable("DOCUMENT_KIND", "Replik");
                                     $content->setVariable("ELEMENT_URL", $TCRExtension->getExtensionUrl() . "release/" . $response_object->get_id());
                                     $content->setVariable("VIEW_ELEMENT", "Inhalt anzeigen");
                                     $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl());
                                     $content->setVariable("AUTHOR_VALUE", $creator->get_full_name() . " (" . $creator->get_name() . ")");
                                     $content->setVariable("DATE_VALUE", date("d.m.Y H:i:s", $date));
                                     if (count($response_object->get_annotations()) == 1) {
                                         $content->setVariable("COMMENTS_VALUE", "(1 Kommentar)");
                                     } else {
                                         $content->setVariable("COMMENTS_VALUE", "(" . count($response_object->get_annotations()) . " Kommentare)");
                                     }
                                     $content->setVariable("COMMENTS_URL", $TCRExtension->getExtensionUrl() . "release/" . $response_object->get_id());
                                     $content->parse("BLOCK_DOCUMENTS_ELEMENT");
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $content->parse("BLOCK_DOCUMENTS_ROUND");
     }
     // display filter
     $content->setVariable("FILTER_LABEL", "Filter:");
     $content->setCurrentBlock("BLOCK_DOCUMENTS_DROPDOWN");
     $content->setVariable("OPTION_VALUE", 0);
     $content->setVariable("OPTION_NAME", "Alle Runden");
     $content->setVariable("ROUNDS_VALUE", $rounds);
     $content->parse("BLOCK_DOCUMENTS_DROPDOWN");
     for ($count = 1; $count <= $rounds; $count++) {
         $content->setCurrentBlock("BLOCK_DOCUMENTS_DROPDOWN");
         $content->setVariable("OPTION_VALUE", $count);
         $content->setVariable("OPTION_NAME", $count . ". Runde");
         $content->setVariable("ROUNDS_VALUE", $rounds);
         $content->parse("BLOCK_DOCUMENTS_DROPDOWN");
     }
     $content->parse("BLOCK_DOCUMENTS_TABLE");
     $group = $TCR->get_attribute("TCR_GROUP");
     if ($group->get_name() == "learners") {
         $parent = $group->get_parent_group();
         $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")";
         $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id();
     } else {
         $courseOrGroup = "Gruppe: " . $group->get_name();
         $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id();
     }
     $rawWidget = new \Widgets\RawHtml();
     $rawWidget->setHtml($content->get());
     $frameResponseObject->addWidget($rawWidget);
     $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id()), array("name" => "Alle Dokumente")));
     return $frameResponseObject;
 }
Ejemplo n.º 6
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $TCR = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $TCRExtension = \TCR::getInstance();
     $TCRExtension->addCSS();
     $content = $TCRExtension->loadTemplate("tcr_index.template.html");
     // display actionbar
     $actionbar = new \Widgets\Actionbar();
     $admins = $TCR->get_attribute("TCR_ADMINS");
     if (in_array($user->get_id(), $admins)) {
         $actions = array(array("name" => "Konfiguration", "link" => $TCRExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id));
     } else {
         $actions = array(array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id));
     }
     $actionbar->setActions($actions);
     $frameResponseObject->addWidget($actionbar);
     // create array data structure of the theses (identified by writer of the thesis and writer of the review)
     $theses_container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/theses");
     $theses_inventory = $theses_container->get_inventory();
     $theses = array();
     $rounds = $TCR->get_attribute("TCR_ROUNDS");
     $members = $TCR->get_attribute("TCR_USERS");
     sort($members);
     foreach ($members as $member) {
         $theses[$member] = array();
         foreach ($members as $member2) {
             $theses[$member][$member2] = array();
         }
     }
     $group = $TCR->get_attribute("TCR_GROUP");
     if ($group->get_name() == "learners") {
         $parent = $group->get_parent_group();
         $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")";
         $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id();
     } else {
         $courseOrGroup = "Gruppe: " . $group->get_name();
         $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id();
     }
     // display message if there are no members specified
     if (count($members) == 0) {
         $content->setCurrentBlock("BLOCK_OVERVIEW_TABLE");
         $content->setVariable("TCR_TITLE", $TCR->get_attribute("OBJ_DESC"));
         $content->setVariable("TCR_NO_USERS", "Keine Teilnehmer festgelegt. Bitte in der Konfiguration die teilnehmenden Personen auswählen.");
         $content->setVariable("DISPLAY_MANY", "none");
         $content->setVariable("DISPLAY_TABLE", "none");
         $content->parse("BLOCK_OVERVIEW_TABLE");
         $rawWidget = new \Widgets\RawHtml();
         $rawWidget->setHtml($content->get());
         $frameResponseObject->addWidget($rawWidget);
         $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren")));
         return $frameResponseObject;
     }
     // shortform of the table is displayed if amount of members is > 4
     $shortform = 0;
     if (count($members) > 4 && count($members) < 9) {
         $shortform = 1;
     } else {
         if (count($members) >= 9) {
             $help = round(count($members) / 8);
             if (count($members) / 8 > $help) {
                 $shortform = $help + 1;
             } else {
                 $shortform = $help;
             }
         }
     }
     if ($shortform > 1) {
         $divide = $shortform;
     } else {
         $divide = 1;
     }
     $area = 0;
     if (isset($this->params[1])) {
         $area = $this->params[1];
     }
     // fill array data structure
     foreach ($theses_inventory as $thesis) {
         $creator = $thesis->get_creator();
         $released = $thesis->get_attribute("TCR_RELEASED");
         $round = $thesis->get_attribute("TCR_ROUND");
         if ($released != 0) {
             $critic_array = $thesis->get_attribute("TCR_REVIEWS");
             foreach ($critic_array as $critic => $review) {
                 $theses[$creator->get_id()][$critic][$round] = $thesis->get_id();
             }
         }
     }
     // display document table
     $content->setCurrentBlock("BLOCK_OVERVIEW_TABLE");
     $content->setVariable("TCR_TITLE", $TCR->get_attribute("OBJ_DESC"));
     if ($divide == 1) {
         $content->setVariable("DISPLAY_MANY", "none");
     } else {
         // if there are > 8 members only display 8 on a page and create navigation for the rest
         if ($area != 0) {
             $content->setVariable("PREVIOUS_CRITICS", "Zeige " . (($area - 1) * 8 + 1) . " bis " . (($area - 1) * 8 + 8));
             $content->setVariable("PREVIOUS_URL", $TCRExtension->getExtensionUrl() . "Index/" . $this->id . "/" . ($area - 1));
         }
         if (count($members) <= $area * 8 + 8) {
             $content->setVariable("CURRENT_CRITICS", "Aktuell angezeigt: Kritiker " . ($area * 8 + 1) . " bis " . count($members) . " (von " . count($members) . ")");
         } else {
             $content->setVariable("CURRENT_CRITICS", "Aktuell angezeigt: Kritiker " . ($area * 8 + 1) . " bis " . ($area * 8 + 8) . " (von " . count($members) . ")");
         }
         if (count($members) > $area * 8 + 8) {
             if (count($members) >= ($area + 1) * 8 + 8) {
                 $content->setVariable("NEXT_CRITICS", "Zeige " . (($area + 1) * 8 + 1) . " bis " . (($area + 1) * 8 + 8));
             } else {
                 $content->setVariable("NEXT_CRITICS", "Zeige " . (($area + 1) * 8 + 1) . " bis " . count($members));
             }
             $content->setVariable("NEXT_URL", $TCRExtension->getExtensionUrl() . "Index/" . $this->id . "/" . ($area + 1));
         }
     }
     $content->setVariable("TABLE_LABEL", "Autoren \\ Kritiker");
     $countmembers = 0;
     // create user columns
     for ($count = $area * 8; $count < min(count($members), ($area + 1) * 8); $count++) {
         $content->setCurrentBlock("BLOCK_USER_TH");
         $member_object = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $members[$count]);
         $content->setVariable("USER_NAME", $member_object->get_name());
         if (count($members) < 8) {
             $content->setVariable("USER_WIDTH", 80 / count($members));
         } else {
             $content->setVariable("USER_WIDTH", 10);
         }
         $content->parse("BLOCK_USER_TH");
     }
     if (count($members) > 8) {
         $tablewidth = 20 + (min(count($members), ($area + 1) * 8) - $area * 8) * 10;
     } else {
         $tablewidth = 100;
     }
     $content->setVariable("TABLE_WIDTH", $tablewidth . "%");
     // create content of the table
     for ($count = 0; $count < count($members); $count++) {
         $content->setCurrentBlock("BLOCK_TABLE_ROW");
         $creator = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $members[$count]);
         $content->setVariable("USER_NAME2", $creator->get_full_name() . " (" . $creator->get_name() . ")");
         for ($count2 = $area * 8; $count2 < min(count($members), ($area + 1) * 8); $count2++) {
             $content->setCurrentBlock("BLOCK_TABLE_COLUMN");
             $current_critic = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $members[$count2]);
             $content->setVariable("COLUMN_TITLE", "Autor: " . $creator->get_name() . " Kritiker: " . $current_critic->get_name());
             for ($count3 = 1; $count3 <= $rounds; $count3++) {
                 if (isset($theses[$members[$count]][$members[$count2]][$count3])) {
                     $current_thesis = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $theses[$members[$count]][$members[$count2]][$count3]);
                     $current_critics = $current_thesis->get_attribute("TCR_REVIEWS");
                     $content->setCurrentBlock("BLOCK_TABLE_ELEMENT");
                     if ($shortform == 0) {
                         $content->setVariable("ROUND_ROW", "<td width='25%'>R" . $count3 . ":</td>");
                         $content->setVariable("OTHER_WIDTH", "25");
                         $content->setVariable("THESIS_LABEL", "These");
                     } else {
                         $content->setVariable("THESIS_LABEL", "T" . $count3);
                         $content->setVariable("OTHER_WIDTH", "33");
                     }
                     $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "release/" . $theses[$members[$count]][$members[$count2]][$count3]);
                     $current_review = $current_critics[$members[$count2]];
                     if ($current_review != 0) {
                         $review = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $current_review);
                         $released = $review->get_attribute("TCR_RELEASED");
                         if ($released != 0) {
                             if ($shortform == 0) {
                                 $content->setVariable("REVIEW_LABEL", "Kritik");
                             } else {
                                 $content->setVariable("REVIEW_LABEL", "K" . $count3);
                             }
                             $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_review);
                         }
                         $current_response = $review->get_attribute("TCR_RESPONSE");
                         if ($current_response != 0) {
                             $response = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $current_response);
                             $released = $response->get_attribute("TCR_RELEASED");
                             if ($released != 0) {
                                 if ($shortform == 0) {
                                     $content->setVariable("RESPONSE_LABEL", "Replik");
                                 } else {
                                     $content->setVariable("RESPONSE_LABEL", "R" . $count3);
                                 }
                                 $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_response);
                             }
                         }
                     }
                     $content->parse("BLOCK_TABLE_ELEMENT");
                 } else {
                     $content->setCurrentBlock("BLOCK_TABLE_ELEMENT");
                     $content->setVariable("ROUND_ROW", "");
                     $content->parse("BLOCK_TABLE_ELEMENT");
                 }
             }
             $content->parse("BLOCK_TABLE_COLUMN");
         }
         $content->parse("BLOCK_TABLE_ROW");
     }
     $content->parse("BLOCK_OVERVIEW_TABLE");
     $rawWidget = new \Widgets\RawHtml();
     $rawWidget->setHtml($content->get());
     $frameResponseObject->addWidget($rawWidget);
     $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren")));
     return $frameResponseObject;
 }