Ejemplo n.º 1
0
 /**
  * function create_entry:
  *
  * @param $pEntryName
  * @param $pDescription
  *
  * @return
  */
 protected function create_entry($pEntryName, $pDescription)
 {
     $new_annotation = steam_factory::create_textdoc($this->steam_connectorID, $pEntryName, $pDescription);
     $this->add_annotation($new_annotation);
     // set acquiring
     $new_annotation->set_acquire($this);
     return $new_annotation;
 }
Ejemplo n.º 2
0
 public function processData(\IRequestObject $requestObject)
 {
     //TODO: NUR FILES GENERIEREN, WELCHE MAN AUCHS EHEN DARF
     $this->params = $requestObject->getParams();
     isset($this->params[0]) ? $this->id = $this->params[0] : "";
     $objId = $this->id;
     $steam = $GLOBALS["STEAM"];
     $steamId = $steam->get_id();
     if ($objId == "") {
         throw new \Exception("id not set");
     }
     $obj = \steam_factory::get_object($steamId, $objId);
     $icsFile = "BEGIN:VCALENDAR\n";
     $icsFile .= "VERSION:2.0\n";
     $icsFile .= "PRODID:koaLA 3.0 / " . $obj->get_name() . " \n";
     $icsFile .= "METHOD:PUBLISH\n";
     $objCalendar = $obj->get_attribute("USER_CALENDAR");
     $objCalendarSubscriptions = $obj->get_attribute("CALENDAR_SUBSCRIPTIONS");
     if ($objCalendar === 0 && $objCalendarSubscriptions === 0) {
         throw new \Exception("there is no calendar");
     }
     if ($objCalendar !== 0 && $objCalendar instanceof \steam_calendar) {
         $dates = $objCalendar->get_date_objects();
         foreach ($dates as $date) {
             if ($date instanceof \steam_date) {
                 $icsFile .= self::getEventData($date);
             }
         }
     }
     if ($objCalendarSubscriptions !== 0 && !empty($objCalendarSubscriptions)) {
         foreach ($objCalendarSubscriptions as $calendar) {
             if ($calendar instanceof \steam_calendar) {
                 $dates = $objCalendar->get_date_objects();
                 foreach ($dates as $date) {
                     if ($date instanceof \steam_date) {
                         $icsFile .= self::getEventData($date);
                     }
                 }
             }
         }
     }
     $icsFile .= "END:VCALENDAR";
     $existingIcsFile = $obj->get_attribute("CALENDAR_ICS_FILE_OUT");
     if ($existingIcsFile === 0) {
         $icsFileObj = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), $obj->get_name() . ".ics", $icsFile, $obj);
         $obj->set_attribute("CALENDAR_ICS_FILE_OUT", $icsFileObj);
     } else {
         $existingIcsFile->set_content($icsFile);
     }
     return $requestObject;
 }
Ejemplo n.º 3
0
 public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
 {
     $title = $this->params["title"];
     $content = $this->params["content"];
     $objectId = $this->id;
     $forumId = $this->params["forum"];
     $steam = $GLOBALS["STEAM"];
     $steamId = $steam->get_id();
     $object = \steam_factory::get_object($steamId, $objectId);
     $forum = \steam_factory::get_object($steamId, $forumId);
     if (trim($title) != "") {
         $new_annotation = \steam_factory::create_textdoc($steamId, rawurlencode($title), stripslashes($content));
         $new_annotation->set_attribute("OBJ_DESC", $title);
         $object->add_annotation($new_annotation);
         // set acquiring
         $new_annotation->set_acquire($object);
         $subscription = $forum->get_attribute("bid:forum_subscription");
         if ($subscription) {
             foreach ($subscription as $key => $user) {
                 $user->get_attributes(array("USER_EMAIL"), 1);
             }
             $result = $steam->buffer_flush();
             foreach ($subscription as $key => $user) {
                 $recipient = $user->get_attribute("USER_EMAIL");
                 $steam->send_mail_from($recipient, "New message in forum " . $forum->get_name . ", thread: " . $object->get_name(), "", "postmaster", 1, "text/plain");
             }
             $steam->buffer_flush();
         }
     } else {
         echo "Ihre Antwort hat keinen Inhalt!";
     }
     $ajaxResponseObject->setStatus("ok");
     $widget = new \Widgets\JSWrapper();
     $widget->setJs("location.reload();");
     $ajaxResponseObject->addWidget($widget);
     return $ajaxResponseObject;
 }
Ejemplo n.º 4
0
    public function frameResponse(\FrameResponseObject $frameResponseObject)
    {
        if (!empty($_FILES)) {
            $array = file($_FILES["uploadedfile"]["tmp_name"]);
            $string = "";
            foreach ($array as $row) {
                $string .= $row . " \n";
            }
            $obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
            $icsFile = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), "ics file " . $this->id, $string);
            $obj->set_attribute("CALENDAR_ICS_FILE_IN", $icsFile);
        } else {
            $rawHtml = new \Widgets\RawHtml();
            // HTML CODE FROM http://www.tizag.com/phpT/fileupload.php
            $rawHtml->setHtml('<form enctype="multipart/form-data" action="#" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
		');
            $frameResponseObject->addWidget($rawHtml);
        }
        return $frameResponseObject;
    }
Ejemplo n.º 5
0
function get_comment_html($document, $url)
{
    $cache = get_cache_function($document->get_id(), 600);
    $user = lms_steam::get_current_user();
    $write_access = $document->check_access(SANCTION_ANNOTATE, $user);
    $template = new HTML_TEMPLATE_IT();
    $template->loadTemplateFile(PATH_TEMPLATES . "comments.template.html");
    $headline = gettext("Add your comment");
    if ($_SERVER["REQUEST_METHOD"] == "POST" && $write_access) {
        $values = $_POST["values"];
        if (!empty($values["preview_comment"])) {
            $template->setCurrentBlock("BLOCK_PREVIEW_COMMENT");
            $template->setVariable("TEXT_COMMENT", $values["comment"]);
            $template->setVariable("PREVIEW", gettext("Preview"));
            $template->setVariable("POST_COMMENT", gettext("Post comment"));
            $template->setVariable("LABEL_PREVIEW_YOUR_COMMENT", gettext("Preview your comment"));
            $template->setVariable("VALUE_PREVIEW_COMMENT", get_formatted_output($values["comment"]));
            $template->parse("BLOCK_PREVIEW_COMMENT");
            $headline = gettext("Change it?");
        }
        if (!empty($values["submit_comment"]) && !empty($values["comment"])) {
            $new_comment = steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), $user->get_name() . "-" . time(), $values["comment"]);
            $all_user = steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_USER);
            $new_comment->set_acquire($document);
            $new_comment->set_read_access($all_user);
            $document->add_annotation($new_comment);
            $cache->drop("lms_steam::get_annotations", $document->get_id());
        }
    }
    $comments = $cache->call("lms_steam::get_annotations", $document->get_id());
    if (count($comments) > 0) {
        $template->setVariable("LABEL_COMMENTS", gettext("comments"));
    }
    $comments = array_reverse($comments);
    //reverse comment order (oldest first)
    foreach ($comments as $comment) {
        $obj_comment = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $comment["OBJ_ID"]);
        $template->setCurrentBlock("BLOCK_ANNOTATION");
        $template->setVariable("COMMENT_ID", $comment["OBJ_ID"]);
        $template->setVariable("AUTHOR_LINK", PATH_URL . "user/" . $comment["OBJ_CREATOR_LOGIN"] . "/");
        $template->setVariable("AUTHOR_NAME", $comment["OBJ_CREATOR"]);
        $template->setVariable("IMAGE_LINK", PATH_URL . "get_document.php?id=" . $comment["OBJ_ICON"]);
        $template->setVariable("LABEL_SAYS", gettext("says"));
        $template->setVariable("ANNOTATION_COMMENT", get_formatted_output($comment["CONTENT"], 80, "\n"));
        $template->setVariable("HOW_LONG_AGO", how_long_ago($comment["OBJ_CREATION_TIME"]));
        $template->setVariable('LINK_PERMALINK', $url . '/#comment' . $comment['OBJ_ID']);
        $template->setVariable("LABEL_PERMALINK", gettext("permalink"));
        if ($obj_comment->check_access_write($user)) {
            $template->setCurrentBlock("BLOCK_OWN_COMMENT");
            $template->setVariable("LINK_DELETE", $url . "/deletecomment" . $comment["OBJ_ID"] . "/");
            $template->setVariable("LABEL_DELETE", gettext("delete"));
            $template->setVariable("LINK_EDIT", $url . "/editcomment" . $comment["OBJ_ID"] . "/");
            $template->setVariable("LABEL_EDIT", gettext("edit"));
            $template->parse("BLOCK_OWN_COMMENT");
        }
        $template->parse("BLOCK_ANNOTATION");
    }
    if ($write_access) {
        $template->setCurrentBlock("BLOCK_ADD_COMMENT");
        $template->setVariable("LABEL_ADD_YOUR_COMMENT", $headline);
        $template->setVariable("LABEL_PREVIEW", gettext("Preview"));
        $template->setVariable("LABEL_OR", gettext("or"));
        $template->setVariable("LABEL_COMMENT", gettext("Add comment"));
        $template->setVariable("LABEL_BB_BOLD", gettext("B"));
        $template->setVariable("HINT_BB_BOLD", gettext("boldface"));
        $template->setVariable("LABEL_BB_ITALIC", gettext("I"));
        $template->setVariable("HINT_BB_ITALIC", gettext("italic"));
        $template->setVariable("LABEL_BB_UNDERLINE", gettext("U"));
        $template->setVariable("HINT_BB_UNDERLINE", gettext("underline"));
        $template->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S"));
        $template->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough"));
        $template->setVariable("LABEL_BB_IMAGE", gettext("IMG"));
        $template->setVariable("HINT_BB_IMAGE", gettext("image"));
        $template->setVariable("LABEL_BB_URL", gettext("URL"));
        $template->setVariable("HINT_BB_URL", gettext("web link"));
        $template->setVariable("LABEL_BB_MAIL", gettext("MAIL"));
        $template->setVariable("HINT_BB_MAIL", gettext("email link"));
        $template->parse("BLOCK_ADD_COMMENT");
    }
    return $template->get();
}
Ejemplo n.º 6
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $workplanExtension = \Workplan::getInstance();
     $workplanExtension->addJS();
     $workplanExtension->addJS($fileName = 'jsgantt.js');
     $workplanExtension->addCSS($fileName = 'jsgantt.css');
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $portal = \lms_portal::get_instance();
     $objectID = $this->params[0];
     $workplanContainer = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectID);
     if (is_object($workplanContainer) && $workplanContainer instanceof \steam_room) {
         $tabBar = new \Widgets\TabBar();
         $tabBar->setTabs(array(array("name" => "Überblick", "link" => $this->getExtension()->getExtensionUrl() . "overview/" . $objectID), array("name" => "Tabelle", "link" => $this->getExtension()->getExtensionUrl() . "listView/" . $objectID), array("name" => "Gantt-Diagramm", "link" => $this->getExtension()->getExtensionUrl() . "ganttView/" . $objectID), array("name" => "Mitarbeiter", "link" => $this->getExtension()->getExtensionUrl() . "users/" . $objectID), array("name" => "Snapshots", "link" => $this->getExtension()->getExtensionUrl() . "snapshots/" . $objectID)));
         $tabBar->setActiveTab(4);
         $frameResponseObject->addWidget($tabBar);
         $xmlfile = $workplanContainer->get_inventory_filtered(array(array("+", "class", CLASS_DOCUMENT)));
         // if user submitted new snapshot dialog add a now annotation/snapshot
         if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["new_snapshot"])) {
             $values = $_POST["values"];
             $newannotation = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), $values["snapshotname"], strval($xmlfile[0]->get_version()), $workplanContainer);
             $xmlfile[0]->add_annotation($newannotation);
             $portal->set_confirmation("Snapshot " . $values["snapshotname"] . " erfolgreich erstellt.");
         }
         // display snapshot list
         $content = $workplanExtension->loadTemplate("workplan_snapshots.template.html");
         $snapshots = $xmlfile[0]->get_annotations();
         $howmany = count($snapshots);
         if ($howmany > 0) {
             $content->setCurrentBlock("BLOCK_SNAPSHOTS_LIST");
             $content->setVariable("NAME_LABEL", "Name");
             $content->setVariable("DATE_LABEL", "Datum");
             $content->setVariable("VIEW_LABEL", "Ansicht");
             for ($count = count($snapshots) - 1; $count >= 0; $count--) {
                 $content->setCurrentBlock("BLOCK_SNAPSHOTS_LIST_ELEMENT");
                 $content->setVariable("ELEMENT_NAME", $snapshots[$count]->get_name());
                 $timestamp = $snapshots[$count]->get_attribute("OBJ_CREATION_TIME");
                 $content->setVariable("ELEMENT_DATE", strftime("%x %X", $timestamp));
                 $content->setVariable("ELEMENT_LIST", "Tabelle");
                 $content->setVariable("ELEMENT_GANTT", "Gantt-Diagramm");
                 $content->setVariable("WORKPLAN_VERSION", $snapshots[$count]->get_content());
                 $content->setVariable("WORKPLAN_ID", $objectID);
                 $content->setVariable("ANNOTATION_ID", $count);
                 $version = $snapshots[$count]->get_content();
                 if ($version == $xmlfile[0]->get_version()) {
                     $viewversion = $xmlfile[0];
                 } else {
                     $previousversions = $xmlfile[0]->get_previous_versions();
                     $viewversion = $previousversions[count($previousversions) - $version];
                 }
                 // change information of every snapshot to a form which is used to create the gantt view
                 $xml = simplexml_load_string($viewversion->get_content());
                 $helpToArray = $xml->children();
                 $list = array();
                 for ($counter = 0; $counter < count($helpToArray); $counter++) {
                     array_push($list, $helpToArray[$counter]);
                 }
                 usort($list, 'sort_xmllist');
                 $oids = "";
                 $names = "";
                 $start = "";
                 $end = "";
                 $depends = "";
                 $milestones = "";
                 for ($count2 = 0; $count2 < count($list); $count2++) {
                     $oids = $oids . $list[$count2]->oid . ",";
                     $names = $names . $list[$count2]->name . ",";
                     $start = $start . $list[$count2]->start . ",";
                     $end = $end . $list[$count2]->end . ",";
                     $depends = $depends . $list[$count2]->depends . ",";
                     if ($list[$count2]->getName() == 'milestone') {
                         $milestones = $milestones . "1,";
                     } else {
                         $milestones = $milestones . "0,";
                     }
                 }
                 $oids = "[" . substr($oids, 0, strlen($oids) - 1) . "]";
                 $names = "[" . substr($names, 0, strlen($names) - 1) . "]";
                 $start = "[" . substr($start, 0, strlen($start) - 1) . "]";
                 $end = "[" . substr($end, 0, strlen($end) - 1) . "]";
                 $depends = "[" . substr($depends, 0, strlen($depends) - 1) . "]";
                 $milestones = "[" . substr($milestones, 0, strlen($milestones) - 1) . "]";
                 $content->setVariable("WORKPLAN_OIDS", $oids);
                 $content->setVariable("WORKPLAN_NAMES", $names);
                 $content->setVariable("WORKPLAN_STARTS", $start);
                 $content->setVariable("WORKPLAN_ENDS", $end);
                 $content->setVariable("WORKPLAN_DEPENDS", $depends);
                 $content->setVariable("WORKPLAN_MILESTONES", $milestones);
                 $content->parse("BLOCK_SNAPSHOTS_LIST_ELEMENT");
             }
             $content->parse("BLOCK_SNAPSHOTS_LIST");
         } else {
             $content->setCurrentBlock("BLOCK_SNAPSHOTS_NO_LIST");
             $content->setVariable("NO_SNAPSHOTS", "Keine Snapshots zu diesem Projektplan vorhanden.");
             $content->parse("BLOCK_SNAPSHOTS_NO_LIST");
         }
         // if current user has the required rights display create snapshot dialog
         $content->setCurrentBlock("BLOCK_NEW_SNAPSHOT");
         $content->setVariable("WORKPLAN_ID", $objectID);
         $content->setVariable("LABEL_NEW_SNAPSHOT", "Neuen Snapshot erstellen");
         $content->setVariable("LABEL_NAME", "Name:*");
         $content->setVariable("LABEL_CREATE", "Abschicken");
         $content->setVariable("WORKPLAN_SHOW_CURRENTVERSION", "Aktuelle Version des Projektplans einblenden");
         $content->setVariable("WORKPLAN_HIDE_SNAPSHOT", "Snapshot ausblenden");
         $content->setVariable("WORKPLAN_HIDECURRENT_SNAPSHOT", "Aktuelle Version des Projektplans ausblenden");
         if ($user->get_id() == $workplanContainer->get_creator()->get_id() || in_array("WORKPLAN_" . $user->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) {
             $content->setVariable("SNAPSHOT_RIGHTS", "");
         } else {
             $content->setVariable("SNAPSHOT_RIGHTS", "none");
         }
         $content->parse("BLOCK_NEW_SNAPSHOT");
         $rawWidget = new \Widgets\RawHtml();
         $rawWidget->setHtml($content->get());
         $frameResponseObject->setTitle("Projektplan: " . $workplanContainer->get_name());
         $frameResponseObject->setHeadline(array(array("link" => $this->getExtension()->getExtensionUrl(), "name" => "Projektplanverwaltung"), array("", "name" => $workplanContainer->get_name())));
         $frameResponseObject->addWidget($rawWidget);
         return $frameResponseObject;
     }
 }
Ejemplo n.º 7
0
 if (!$allowed_annotate) {
     if ($steamUser->get_name() === "guest") {
         $do_login = True;
         $error[] = "error_not_logged_in";
     } else {
         $error[] = "no_access";
     }
 }
 if (trim($_POST["title"]) == "" || stripslashes($_POST["title"]) == "") {
     $error[] = "error_title";
 }
 if (isset($_POST['content']) && trim($_POST["content"]) == "") {
     $error[] = "error_content";
 }
 if (count($error) == 0) {
     $new_annotation = steam_factory::create_textdoc($steam, rawurlencode($_POST["title"]), stripslashes($_POST["content"]));
     $new_annotation->set_attributes(array(OBJ_DESC => norm_post($_POST["title"])));
     $object->add_annotation($new_annotation);
     // set acquiring
     $new_annotation->set_acquire($object);
     $subscription = $forum->get_attribute("bid:forum_subscription");
     if ($subscription) {
         foreach ($subscription as $key => $user) {
             $user->get_attributes(array("USER_EMAIL"), 1);
         }
         $result = $steam->buffer_flush();
         foreach ($subscription as $key => $user) {
             $recipient = $user->get_attribute("USER_EMAIL");
             $steam->send_mail_from($recipient, "New message in forum " . $forum->get_name . ", thread: " . $object->get_name(), "", "postmaster", 1, "text/plain");
         }
         $steam->buffer_flush();
Ejemplo n.º 8
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $forum_id = $this->params[0];
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     $rss_feeds = $user->get_attribute("USER_RSS_FEEDS");
     if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) {
         include "bad_link.php";
         exit;
     }
     if ($messageboard instanceof \steam_document) {
         $thread = $messageboard;
         $messageboard = $thread->get_annotating();
         define("OBJ_ID", $thread->get_id());
         if (!$thread->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     } else {
         define("OBJ_ID", $messageboard->get_id());
         if (!$messageboard->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     if (!$messageboard instanceof \steam_messageboard) {
         include "bad_link.php";
         exit;
     }
     $is_watching = FALSE;
     if (is_array($rss_feeds)) {
         foreach (array_keys($rss_feeds) as $item) {
             if ($item == $messageboard->get_id()) {
                 $is_watching = TRUE;
             }
         }
     }
     $content = \Messageboard::getInstance()->loadTemplate("forum_discussion.template.html");
     $content->setVariable("REPLY_LABEL", gettext("Reply to this topic?"));
     if ($_SERVER["REQUEST_METHOD"] == "POST" && $thread->check_access_annotate(\lms_steam::get_current_user())) {
         $values = $_POST["values"];
         if (empty($values["body"])) {
             $portal->set_problem_description(gettext("Please enter your message."));
         }
         if (!empty($values["save"]) && !empty($values["body"])) {
             $new_comment = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), "Re: " . $thread->get_name(), $values["body"]);
             //		$all_user = steam_factory::groupname_to_object( $GLOBALS[ "STEAM" ]->get_id(), STEAM_ALL_USER );
             //		$new_comment->set_acquire( FALSE );
             //		$new_comment->set_read_access( $all_user, TRUE );
             //		$new_comment->set_write_access( $all_user, FALSE );
             //		$new_comment->set_annotate_access( $all_user, TRUE );
             $thread->add_annotation($new_comment);
             $new_comment->set_acquire($thread);
             $mbid = $messageboard->get_id();
             // Handle Related Cache-Data
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache->clean($mbid);
             // clean forumcache
             $fcache = get_cache_function($forum_id, 600);
             $fcache->drop("lms_forum::get_discussions", $forum_id);
             // clean forumcache
             $fcache = get_cache_function($mbid, 600);
             $fcache->drop("lms_forum::get_discussions", $mbid);
             // clean rsscache of the forum
             // TODO: Passt der link?
             $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID;
             $rcache = get_cache_function("rss", 600);
             $rcache->drop("lms_rss::get_items", $feedlink);
         } else {
             if (empty($values["save"]) && !empty($values["body"])) {
                 // PREVIEW
                 $content->setCurrentBlock("BLOCK_PREVIEW_COMMENT");
                 $content->setVariable("LABEL_PREVIEW_COMMENT", gettext("Preview the edit"));
                 $content->setVariable("VALUE_PREVIEW_COMMENT", get_formatted_output($values["body"]));
                 $content->setVariable("TEXT_COMMENT", h($values["body"]));
                 $content->parse("BLOCK_PREVIEW_COMMENT");
                 $content->setVariable("REPLY_LABEL", gettext("Change it?"));
             }
         }
     }
     if (isset($_GET["action"]) && $_GET["action"] == "bookmark_rss") {
         \lms_steam::user_add_rssfeed($messageboard->get_id(), PATH_URL . "services/feeds/forum_public.php?id=" . $messageboard->get_id(), "discussion board", \lms_steam::get_link_to_root($messageboard));
         $_SESSION["confirmation"] = str_replace("%NAME", h($messageboard->get_name()), gettext("You are keeping an eye on '%NAME' from now on."));
         header("Location: " . PATH_URL . "forums/" . $thread->get_id() . "/");
         exit;
     }
     if (isset($_GET["action"]) && $_GET["action"] == "delete_bookmark") {
         $user = \lms_steam::get_current_user();
         $id = (int) $_GET["unsubscribe"];
         $feeds = $user->get_attribute("USER_RSS_FEEDS");
         if (!is_array($feeds)) {
             $feeds = array();
         }
         unset($feeds[$id]);
         $user->set_attribute("USER_RSS_FEEDS", $feeds);
         $_SESSION["confirmation"] = str_replace("%NAME", h($messageboard->get_name()), gettext("subscription of '%NAME' canceled."));
         header("Location: " . PATH_URL . "forums/" . $thread->get_id() . "/");
         exit;
     }
     $content->setVariable("CURRENT_DISCUSSIONS_LABEL", gettext("Current Thread"));
     $cache = get_cache_function($messageboard->get_id(), 600);
     $discussions = $cache->call("lms_forum::get_discussions", $messageboard->get_id());
     $max_discussions = 12;
     foreach ($discussions as $discussion) {
         $max_discussions--;
         if ($max_discussions == 0) {
             $content->setCurrentBlock("BLOCK_TOPIC_INFO");
             $content->setVariable("TOPIC_LINK", PATH_URL . "forums/" . $messageboard->get_id() . "/");
             $content->setVariable("TOPIC_TITLE", gettext("More..."));
             $content->parse("BLOCK_TOPIC_INFO");
             break;
         }
         $content->setCurrentBlock("BLOCK_TOPIC_INFO");
         if (time() - $discussion["LATEST_POST_TS"] > $_SESSION["last_login"]) {
             $content->setCurrentBlock("BLOCK_TOPIC_NEW");
             $content->setVariable("NEW_LABEL", gettext("New"));
             $content->parse("BLOCK_TOPIC_NEW");
         }
         $content->setVariable("TOPIC_LINK", PATH_URL . "messageboard/viewDiscussion/" . $discussion["OBJ_ID"] . "/");
         $content->setVariable("TOPIC_TITLE", h($discussion["OBJ_NAME"]));
         $content->setVariable("TOPIC_LAST_ENTRY", gettext("Latest:") . how_long_ago($discussion["LATEST_POST_TS"]));
         $content->parse("BLOCK_TOPIC_INFO");
     }
     $content->setVariable("LABEL_TOPICS_POSTED", gettext("Topics you've posted in"));
     $content->setVariable("LINK_AUTHOR", PATH_URL . "forums/" . $messageboard->get_id() . "/?author=" . \lms_steam::get_current_user()->get_name());
     $content->setVariable("LABEL_POST_NEW", gettext("Post a new topic"));
     $content->setVariable("LINK_POST_NEW", PATH_URL . "messageboard/newDiscussion/" . $messageboard->get_id());
     $content->setCurrentBlock("BLOCK_WATCH");
     if ($is_watching) {
         $content->setVariable("LABEL_BOOKMARK", gettext("End watching"));
         $content->setVariable("LINK_BOOKMARK", PATH_URL . "forums/" . $thread->get_id() . "/?action=delete_bookmark&unsubscribe=" . $messageboard->get_id());
     } else {
         $content->setVariable("LABEL_BOOKMARK", gettext("Watch this forum"));
         $content->setVariable("LINK_BOOKMARK", PATH_URL . "forums/" . $thread->get_id() . "/?action=bookmark_rss");
     }
     $content->parse("BLOCK_WATCH");
     $content->setVariable("DISCUSSION_SUBJECT", h($thread->get_name()));
     $author = $thread->get_creator();
     $author_data = $author->get_attributes(array("OBJ_NAME", "USER_FIRSTNAME", "USER_FULLNAME", "OBJ_ICON"));
     $content->setVariable("AUTHOR_LINK", PATH_URL . "user/" . $author_data["OBJ_NAME"] . "/");
     $icon = $author_data["OBJ_ICON"];
     if ($icon instanceof \steam_object) {
         $icon_id = $icon->get_id();
     } else {
         $icon_id = 0;
     }
     $content->setVariable("AUTHOR_IMAGE", PATH_URL . "cached/get_document.php?id=" . $icon_id . "&type=usericon&width=60&height=70");
     $content->setVariable("NAME_SAYS_LABEL", str_replace("%n", "<a href=\"" . PATH_URL . "user/" . $author_data["OBJ_NAME"] . "/\">" . h($author_data["USER_FIRSTNAME"]) . " " . h($author_data["USER_FULLNAME"]) . "</a>", gettext("%n says:")));
     $content->setVariable("DISCUSSION_TEXT", get_formatted_output($thread->get_content(), 65, "\n"));
     $ts = $thread->get_attribute("OBJ_CREATION_TIME");
     $content->setVariable("DISCUSSION_STARTED_TS", gettext("Posted at") . " " . strftime("%H:%M", $ts) . " | " . strftime("%d. %B %Y", $ts));
     $content->setVariable("DISCUSSION_PERMALINK", PATH_URL . 'forums/' . $discussion['OBJ_ID'] . '/');
     $content->setVariable("DISCUSSION_PERMALINK_TEXT", gettext("permalink"));
     $steam_user = \lms_steam::get_current_user();
     if ($thread->check_access_write($steam_user)) {
         $content->setCurrentBlock("BLOCK_OWN_DISCUSSION");
         $content->setVariable("DISCUSSION_LINK_DELETE", PATH_URL . "messageboard/deleteComment/" . $messageboard->get_id() . "/" . $thread->get_id());
         $content->setVariable("DISCUSSION_LABEL_DELETE", gettext("delete"));
         $content->setVariable("DISCUSSION_LINK_EDIT", PATH_URL . "messageboard/editComment/" . $thread->get_id() . "/" . $thread->get_id());
         $content->setVariable("DISCUSSION_LABEL_EDIT", gettext("edit"));
         $content->parse("BLOCK_OWN_DISCUSSION");
     }
     $annotations = \lms_steam::get_annotations($thread->get_id());
     $annotations = array_reverse($annotations);
     $access_tnr = array();
     foreach ($annotations as $annotation) {
         $steam_obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $annotation["OBJ_ID"], CLASS_OBJECT);
         $access_tnr[$steam_obj->get_id()] = $steam_obj->check_access_write($steam_user, TRUE);
     }
     $access_result = $GLOBALS["STEAM"]->buffer_flush();
     foreach ($annotations as $annotation) {
         $content->setCurrentBlock("REPLY");
         $content->setVariable('REPLY_ID', $annotation['OBJ_ID']);
         $content->setVariable("REPLYER_LINK", PATH_URL . "user/" . $annotation["OBJ_CREATOR_LOGIN"] . "/");
         $content->setVariable("REPLYER_IMAGE", PATH_URL . "cached/get_document.php?id=" . $annotation["OBJ_ICON"] . "&type=usericon&width=60&height=70");
         $content->setVariable("REPLYER_SAYS_LABEL", str_replace("%n", "<a href=\"" . PATH_URL . "user/" . $annotation["OBJ_CREATOR_LOGIN"] . "/\">" . h($annotation["OBJ_CREATOR"]) . "</a>", gettext("%n says:")));
         //$content->setVariable( "REPLYERS_SAYS_LABEL", str_replace );
         $content->setVariable("REPLY_CONTENT", get_formatted_output($annotation["CONTENT"], 60, "\n"));
         $content->setVariable("REPLY_TS", how_long_ago($annotation["OBJ_CREATION_TIME"]));
         $content->setVariable("REPLY_PERMALINK", PATH_URL . 'forums/' . $thread->get_id() . '/#comment' . $annotation['OBJ_ID']);
         $content->setVariable("REPLY_PERMALINK_TEXT", gettext("permalink"));
         $steam_obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $annotation["OBJ_ID"], CLASS_OBJECT);
         if ($access_result[$access_tnr[$steam_obj->get_id()]]) {
             $content->setCurrentBlock("BLOCK_OWN_REPLY");
             $content->setVariable("REPLY_LINK_DELETE", PATH_URL . "messageboard/deleteComment/" . $thread->get_id() . "/" . $annotation["OBJ_ID"] . "/");
             $content->setVariable("REPLY_LABEL_DELETE", gettext("delete"));
             $content->setVariable("REPLY_LABEL_EDIT", gettext("edit"));
             $content->setVariable("REPLY_LINK_EDIT", PATH_URL . "messageboard/editComment/" . $thread->get_id() . "/" . $annotation["OBJ_ID"] . "/");
             $content->parse("BLOCK_OWN_REPLY");
         }
         $content->parse("REPLY");
     }
     $content->setVariable("LABEL_BB_BOLD", gettext("B"));
     $content->setVariable("HINT_BB_BOLD", gettext("boldface"));
     $content->setVariable("LABEL_BB_ITALIC", gettext("I"));
     $content->setVariable("HINT_BB_ITALIC", gettext("italic"));
     $content->setVariable("LABEL_BB_UNDERLINE", gettext("U"));
     $content->setVariable("HINT_BB_UNDERLINE", gettext("underline"));
     $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S"));
     $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough"));
     $content->setVariable("LABEL_BB_IMAGE", gettext("IMG"));
     $content->setVariable("HINT_BB_IMAGE", gettext("image"));
     $content->setVariable("LABEL_BB_URL", gettext("URL"));
     $content->setVariable("HINT_BB_URL", gettext("web link"));
     $content->setVariable("LABEL_BB_MAIL", gettext("MAIL"));
     $content->setVariable("HINT_BB_MAIL", gettext("email link"));
     $content->setVariable("LABEL_PREVIEW", gettext("Preview"));
     $content->setVariable("LABEL_OR", gettext("or"));
     $content->setVariable("LABEL_POST_NOW", gettext("Post now"));
     $portal->set_rss_feed(PATH_URL . "services/feeds/discussion_public.php?id=" . OBJ_ID, gettext("Feed"), gettext("Subscribe to this forum's Newsfeed"));
     // TODO: Passt der link?
     $rootlink = \lms_steam::get_link_to_root($messageboard);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name()), array("link" => "", "name" => gettext("Discussion")));
     $frameResponseObject->setTitle("Messageboard");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Ejemplo n.º 9
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $path = $element->get_path();
     $path = substr($path, 0, strrpos($path, "/"));
     $type = substr($path, strrpos($path, "/") + 1, strlen($path));
     $TCR = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), substr($path, 0, strrpos($path, "/")));
     $TCRExtension = \TCR::getInstance();
     $TCRExtension->addCSS();
     $TCRExtension->addJS();
     $content = $TCRExtension->loadTemplate("tcr_release.template.html");
     $members = $TCR->get_attribute("TCR_USERS");
     sort($members);
     $critics = $element->get_attribute("TCR_REVIEWS");
     $group = $TCR->get_attribute("TCR_GROUP");
     $private = 1;
     // determine where the user is coming from
     $referer = getenv("HTTP_REFERER");
     if (strpos($referer, "Index") !== false) {
         $backurl = $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id();
         $referer = 1;
     } else {
         if (strpos($referer, "documents") !== false) {
             $backurl = $TCRExtension->getExtensionUrl() . "documents/" . $TCR->get_id();
             $referer = 2;
         } else {
             if (strpos($referer, "privateDocuments") !== false) {
                 $backurl = $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id();
                 $referer = 3;
             }
         }
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         // if a new comment was submitted
         if (isset($_POST["add_comment"])) {
             $new_comment = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), $_POST["title"], stripslashes($_POST["content"]));
             $new_comment->set_read_access($group);
             $new_comment->set_write_access($group);
             $element->add_annotation($new_comment);
         }
         // if a comment edit got submitted
         if (isset($_POST["edit_comment"])) {
             $comment = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["edit_id"]);
             $comment->set_content($_POST["content"]);
             $comment->set_name($_POST["title"]);
         }
         // determine where the user is coming from
         $referer = $_POST["referer"];
         if ($referer == 1) {
             $backurl = $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id();
         } else {
             if ($referer == 2) {
                 $backurl = $TCRExtension->getExtensionUrl() . "documents/" . $TCR->get_id();
             } else {
                 if ($referer == 3) {
                     $backurl = $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id();
                 }
             }
         }
     }
     // display dialog
     $content->setCurrentBlock("BLOCK_RELEASE_ELEMENT");
     if ($type == "theses") {
         if (is_array($critics) && count($critics) > 0) {
             // display already released thesis
             $release_label = "These anzeigen";
             $content->setVariable("SHOW_CRITICS", "none");
             $content->setVariable("SHOW_RELEASE", "none");
             $private = 0;
             $released = 1;
         } else {
             // release dialog
             $release_label = "These veröffentlichen";
             $released = 0;
         }
         $kind = 0;
         $kindWord = "These";
     } else {
         if ($type == "reviews") {
             $released = $element->get_attribute("TCR_RELEASED");
             if ($released != 0) {
                 // display already released review
                 $release_label = "Kritik anzeigen";
                 $content->setVariable("SHOW_RELEASE", "none");
                 $private = 0;
             } else {
                 // release dialog
                 $release_label = "Kritik veröffentlichen";
             }
             $content->setVariable("SHOW_CRITICS", "none");
             $kind = 1;
             $kindWord = "Kritik";
         } else {
             $released = $element->get_attribute("TCR_RELEASED");
             if ($released != 0) {
                 // display already released response
                 $release_label = "Replik anzeigen";
                 $content->setVariable("SHOW_RELEASE", "none");
                 $private = 0;
             } else {
                 // release dialog
                 $release_label = "Replik veröffentlichen";
             }
             $content->setVariable("SHOW_CRITICS", "none");
             $kind = 2;
             $kindWord = "Replik";
         }
     }
     if ($released == 0 && $referer == 3) {
         $backurl = $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id() . "/" . $kind;
     }
     $content->setVariable("SUBMIT_URL", $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id() . "/" . $kind);
     $content->setVariable("RELEASE_LABEL", $release_label);
     $content->setVariable("TITLE_LABEL", "Titel");
     $content->setVariable("TITLE_VALUE", $element->get_name());
     $content->setVariable("DESC_LABEL", "Untertitel / Beschreibung");
     $content->setVariable("DESC_VALUE", $element->get_attribute("OBJ_DESC"));
     $content->setVariable("AUTHOR_LABEL", "Autor");
     $author = $element->get_creator();
     $content->setVariable("AUTHOR_VALUE", $author->get_full_name() . " (" . $author->get_name() . ")");
     $content->setVariable("CONTENT_LABEL", "Inhalt");
     if ($element->get_attribute("DOC_MIME_TYPE") == "text/plain") {
         // if element is plain text display content directly
         $content->setVariable("DISPLAY_DOWNLOAD", "none");
         $content->setVariable("CONTENT_VALUE", nl2br($element->get_content()));
     } else {
         // if element is of another mime type display download dialog
         $content->setVariable("DISPLAY_TEXT", "none");
         $content->setVariable("ASSET_URL", $TCRExtension->getAssetUrl());
         $content->setVariable("DOWNLOAD_URL", PATH_URL . "download/Document/" . $this->id);
         $content->setVariable("DOWNLOAD_TITLE", "Datei herunterladen");
     }
     // display select critic dialog
     $content->setVariable("CRITICS_LABEL", "Kritiker(in)");
     $radioSelect = 0;
     foreach ($members as $memberID) {
         $member = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $memberID);
         $content->setCurrentBlock("BLOCK_CRITIC");
         $content->setVariable("CRITIC_ID", $member->get_id());
         $content->setVariable("CRITIC_NAME", $member->get_full_name());
         if ($radioSelect == 0) {
             $content->setVariable("CRITIC_CHECKED", "checked");
             $radioSelect++;
         }
         $content->parse("BLOCK_CRITIC");
     }
     $content->setVariable("RELEASE_WARNING", "Wenn Sie die " . $kindWord . " veröffentlichen, können Sie sie nicht mehr ändern oder löschen.");
     $content->setVariable("SUBMIT_RELEASE", "Veröffentlichen");
     $content->setVariable("BACK_LABEL", "Zurück");
     $content->setVariable("BACK_URL", $backurl);
     $content->setVariable("KIND_VALUE", $kind);
     $content->setVariable("ID_VALUE", $this->id);
     $content->parse("BLOCK_RELEASE_ELEMENT");
     // display comments
     if ($released != 0) {
         $comments = $element->get_annotations();
         usort($comments, "sortRepliesByDate");
         $content->setCurrentBlock("BLOCK_TCR_COMMENTS");
         $content->setVariable("COMMENTS_LABEL", "Kommentare");
         if (count($comments) == 0) {
             $content->setCurrentBlock("BLOCK_NO_COMMENTS");
             $content->setVariable("NO_COMMENTS", "Es sind noch keine Kommentare zu diesem Dokument vorhanden.");
             $content->parse("BLOCK_NO_COMMENTS");
         } else {
             for ($count = 0; $count < count($comments); $count++) {
                 $author = $comments[$count]->get_creator();
                 $content->setCurrentBlock("BLOCK_COMMENT");
                 $content->setVariable("COMMENT_CONTENT", nl2br($comments[$count]->get_content()));
                 $content->setVariable("COMMENT_CONTENT_NOBR", $comments[$count]->get_content());
                 $content->setVariable("COMMENT_TITLE", $comments[$count]->get_name());
                 $content->setVariable("COMMENT_ID", $comments[$count]->get_id());
                 $content->setVariable("ASSET", $TCRExtension->getAssetUrl());
                 $content->setVariable("EDIT_COMMENT", "Kommentar bearbeiten");
                 // if user is not the author and admin options are not shown dont display edit button
                 if ($author->get_id() != $user->get_id()) {
                     $content->setVariable("SHOW_COMMENT_EDIT", "none");
                 }
                 $content->setVariable("COMMENT_AUTHOR", "von " . $author->get_name() . " (" . $author->get_full_name() . ")");
                 $content->setVariable("COMMENT_DATE", "am " . date("d.m.Y H:i", (int) $comments[$count]->get_attribute("OBJ_CREATION_TIME")));
                 $content->parse("BLOCK_COMMENT");
             }
         }
         $content->parse("BLOCK_TCR_COMMENTS");
         $content->setCurrentBlock("BLOCK_CREATE_COMMENT");
         $content->setVariable("CREATE_COMMENT", "Kommentar hinzufügen");
         $content->setVariable("BACKURL_LABEL", "Zurück");
         $content->setVariable("BACKURL", $backurl);
         $content->setVariable("TITLE_LABEL_COMMENT", "Titel:");
         $content->setVariable("CONTENT_LABEL_COMMENT", "Kommentar:");
         $content->setVariable("BACK_LABEL_COMMENT", "Abbrechen");
         $content->setVariable("EDIT_COMMENT", "Kommentar bearbeiten");
         $content->setVariable("EDIT_COMMENT_SUBMIT", "Änderungen speichern");
         $content->setVariable("REFERER_VALUE", $referer);
         $content->parse("BLOCK_CREATE_COMMENT");
     } else {
         $content->setVariable("DISPLAY_COMMENTS", "none");
     }
     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);
     if ($private == 1) {
         $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id()), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id()), array("name" => $release_label)));
     } else {
         $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id()), array("name" => $release_label)));
     }
     return $frameResponseObject;
 }
Ejemplo n.º 10
0
<?php

require_once PATH_LIB . "format_handling.inc.php";
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "forum_discussion.template.html");
$content->setVariable("REPLY_LABEL", gettext("Reply to this topic?"));
if ($_SERVER["REQUEST_METHOD"] == "POST" && $thread->check_access_annotate(lms_steam::get_current_user())) {
    $values = $_POST["values"];
    if (empty($values["body"])) {
        $portal->set_problem_description(gettext("Please enter your message."));
    }
    if (!empty($values["save"]) && !empty($values["body"])) {
        $new_comment = steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), "Re: " . $thread->get_name(), $values["body"]);
        //		$all_user = steam_factory::groupname_to_object( $GLOBALS[ "STEAM" ]->get_id(), STEAM_ALL_USER );
        //		$new_comment->set_acquire( FALSE );
        //		$new_comment->set_read_access( $all_user, TRUE );
        //		$new_comment->set_write_access( $all_user, FALSE );
        //		$new_comment->set_annotate_access( $all_user, TRUE );
        $thread->add_annotation($new_comment);
        $new_comment->set_acquire($thread);
        $mbid = $messageboard->get_id();
        // Handle Related Cache-Data
        require_once "Cache/Lite.php";
        $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE));
        $cache->clean($mbid);
        // clean forumcache
        $fcache = get_cache_function($_GET["id"], 600);
        $fcache->drop("lms_forum::get_discussions", $_GET["id"]);
        // clean forumcache
        $fcache = get_cache_function($mbid, 600);
        $fcache->drop("lms_forum::get_discussions", $mbid);
Ejemplo n.º 11
0
 public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
 {
     $workplanExtension = \Workplan::getInstance();
     $objectID = $this->params["id"];
     $workplanContainer = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectID);
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $xmlfile = $workplanContainer->get_inventory_filtered(array(array("+", "class", CLASS_DOCUMENT)));
     $version = $this->params["version"];
     // if user submitted create snapshot dialog create the new annotation/snapshot
     $newsnapshot = 0;
     if (isset($this->params["newsnapshot"])) {
         $newsnapshot = $this->params["newsnapshot"];
     }
     if ($user->get_id() != $workplanContainer->get_creator()->get_id() && !in_array("WORKPLAN_" . $user->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) {
         $newsnapshot = 0;
     }
     if ($newsnapshot == 1) {
         $newannotation = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), $this->params["name"], strval($xmlfile[0]->get_version()), $workplanContainer);
         $xmlfile[0]->add_annotation($newannotation);
         $rawWidget = new \Widgets\RawHtml();
         $ajaxResponseObject->setStatus("ok");
         $ajaxResponseObject->addWidget($rawWidget);
         return $ajaxResponseObject;
     }
     // load the right version
     $previousversions = $xmlfile[0]->get_previous_versions();
     if ($version == 0 || $version == count($previousversions) + 1 || $version == 1) {
         $xml = simplexml_load_string($xmlfile[0]->get_content());
     } else {
         $thisversion = $previousversions[count($previousversions) - $version];
         $xml = simplexml_load_string($thisversion->get_content());
     }
     $annotations = $xmlfile[0]->get_annotations();
     // display general informations of a workplan (if version == 0 its the current one)
     $content = $workplanExtension->loadTemplate("workplan_snapshots.template.html");
     $content->setCurrentBlock("BEGIN BLOCK_SNAPSHOT_VIEW");
     if ($version != 0) {
         $annotation = $annotations[$this->params["annotationid"]];
         $timestamp = $annotation->get_attribute("OBJ_CREATION_TIME");
         $content->setVariable("SNAPSHOT_VERSION", "Snapshot " . $annotation->get_name() . " vom " . strftime("%x", (int) $timestamp));
     } else {
         $content->setVariable("SNAPSHOT_VERSION", "Aktueller Projektplan");
     }
     $content->setVariable("SNAPSHOT_VERSION_NAME", "Name");
     $content->setVariable("SNAPSHOT_VERSION_NAME_VALUE", $xml["name"]);
     $content->setVariable("SNAPSHOT_VERSION_START", "Beginn");
     $content->setVariable("SNAPSHOT_VERSION_START_VALUE", strftime("%x", (int) $xml["start"]));
     $content->setVariable("SNAPSHOT_VERSION_END", "Ende");
     if ($xml["end"] != -1) {
         $content->setVariable("SNAPSHOT_VERSION_END_VALUE", strftime("%x", (int) $xml["end"]));
     } else {
         $content->setVariable("SNAPSHOT_VERSION_END_VALUE", "-");
     }
     $content->setVariable("SNAPSHOT_VERSION_DESCRIPTION", "Beschreibung");
     if (strlen($xml["description"]) > 0) {
         $content->setVariable("SNAPSHOT_VERSION_DESCRIPTION_VALUE", nl2br($xml["description"]));
     } else {
         $content->setVariable("SNAPSHOT_VERSION_DESCRIPTION_VALUE", "-");
     }
     $content->parse("BEGIN BLOCK_SNAPSHOT_VIEW");
     $rawWidget = new \Widgets\RawHtml();
     $rawWidget->setHtml($content->get());
     $ajaxResponseObject->setStatus("ok");
     $ajaxResponseObject->addWidget($rawWidget);
     return $ajaxResponseObject;
 }
Ejemplo n.º 12
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $user = $GLOBALS["STEAM"]->get_current_steam_user();
     $pyramidPosition = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $positionGroup = $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_RELGROUP");
     $pyramidRoom = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->pyramiddiscussion);
     $phase = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_ACTCOL");
     $basegroup = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_BASEGROUP");
     $admingroup = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_ADMINGROUP");
     $adminconfig = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_ADMINCONFIG");
     $pyramiddiscussionExtension = \Pyramiddiscussion::getInstance();
     $pyramiddiscussionExtension->addCSS();
     $pyramiddiscussionExtension->addJS();
     $content = $pyramiddiscussionExtension->loadTemplate("pyramiddiscussion_viewposition.template.html");
     // if a new comment was submitted
     if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["add_comment"])) {
         $new_comment = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), $_POST["title"], stripslashes($_POST["content"]));
         $new_comment->set_read_access($basegroup);
         $new_comment->set_read_access($admingroup);
         $new_comment->set_write_access($basegroup);
         $new_comment->set_write_access($admingroup);
         $read_states = array();
         $read_states[$user->get_id()] = 1;
         $new_comment->set_attribute("PYRAMIDDISCUSSION_COMMENT_READ_STATES", $read_states);
         $pyramidPosition->add_annotation($new_comment);
     }
     // if a comment edit got submitted
     if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["edit_comment"])) {
         $comment = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["edit_id"]);
         $comment->set_content($_POST["content"]);
         $comment->set_name($_POST["title"]);
         $read_states = array();
         $read_states[$user->get_id()] = 1;
         $comment->set_attribute("PYRAMIDDISCUSSION_COMMENT_READ_STATES", $read_states);
     }
     // check if user is admin and if adminoptions are shown
     $showadmin = 1;
     if ($admingroup->is_member($user)) {
         if (array_key_exists($user->get_id(), $adminconfig)) {
             $options = $adminconfig[$user->get_id()];
             if (isset($options["show_adminoptions"]) && $options["show_adminoptions"] == "false") {
                 $showadmin = 0;
             }
         }
     } else {
         $showadmin = 0;
     }
     // get names of the users participating in this position
     $participants = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_PARTICIPANT_MANAGEMENT");
     $positionMembers = $positionGroup->get_members();
     $names = "";
     $users = array();
     while (count($positionMembers) > 0) {
         $currentMember = array_pop($positionMembers);
         if ($currentMember instanceof \steam_user) {
             if (!isset($participants[$currentMember->get_id()])) {
                 $participants[$currentMember->get_id()] = 0;
                 $pyramidRoom->set_attribute("PYRAMIDDISCUSSION_PARTICIPANT_MANAGEMENT", $participants);
             }
             if ($participants[$currentMember->get_id()] >= $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_COLUMN") || $participants[$currentMember->get_id()] == 0) {
                 array_push($users, $currentMember->get_id());
             }
         } else {
             $groupMembers = $currentMember->get_members();
             for ($count = 0; $count < count($groupMembers); $count++) {
                 array_push($positionMembers, $groupMembers[$count]);
             }
         }
     }
     // determine if current user already read this position
     $read_position = 0;
     $read_position_states = $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_POS_READ_STATES");
     if (is_array($read_position_states)) {
         if (array_key_exists($user->get_id(), $read_position_states)) {
             $read_position = $read_position_states[$user->get_id()];
         }
     }
     if ($pyramidPosition->get_content() == "0" || $pyramidPosition->get_content() == "") {
         $read_position = 1;
     }
     // display current position
     $content->setCurrentBlock("BLOCK_PYRAMID_POSITION");
     if ($pyramidPosition->get_attribute("PYRAMIDDISCUSSION_POS_TITLE") != "0" && $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_POS_TITLE") != "") {
         $content->setVariable("PYRAMID_POSITION", $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_POS_TITLE"));
     } else {
         $content->setVariable("PYRAMID_POSITION", "Position_" . $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_COLUMN") . "_" . $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_ROW"));
     }
     $positionPhase = $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_COLUMN");
     $positionRow = $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_ROW");
     if ($positionPhase != 1) {
         $previous1 = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $pyramidRoom->get_path() . "/Position_" . ($positionPhase - 1) . "_" . ($positionRow * 2 - 1));
         $previous2 = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $pyramidRoom->get_path() . "/Position_" . ($positionPhase - 1) . "_" . $positionRow * 2);
         $content->setVariable("PREVIOUS1_SHOW", "Position " . ($positionPhase - 1) . "-" . ($positionRow * 2 - 1) . " anzeigen");
         $content->setVariable("PREVIOUS2_SHOW", "Position " . ($positionPhase - 1) . "-" . $positionRow * 2 . " anzeigen");
         $content->setVariable("PREVIOUS1_HIDE", "Position " . ($positionPhase - 1) . "-" . ($positionRow * 2 - 1) . " ausblenden");
         $content->setVariable("PREVIOUS2_HIDE", "Position " . ($positionPhase - 1) . "-" . $positionRow * 2 . " ausblenden");
         $content->setVariable("PREVIOUS1_CONTENT", $previous1->get_content());
         $content->setVariable("PREVIOUS2_CONTENT", $previous2->get_content());
     } else {
         $content->setVariable("DISPLAY_PREVIOUS", "none");
     }
     if ($read_position == 0) {
         $content->setVariable("POSITION_NEW", "(neu)");
         // current user has now read this position
         if (is_array($read_position_states)) {
             $read_position_states[$user->get_id()] = 1;
         } else {
             $read_position_states = array();
             $read_position_states[$user->get_id()] = 1;
         }
         $pyramidPosition->set_attribute("PYRAMIDDISCUSSION_POS_READ_STATES", $read_position_states);
     }
     $content->setVariable("ASSETURL", $pyramiddiscussionExtension->getAssetUrl());
     $content->setVariable("EDIT_POSITION", "Position bearbeiten");
     $content->setVariable("PARAMS_AJAX", "{ id : " . $pyramidPosition->get_id() . ", action : 'edit' }");
     // do not display edit function if user is not member of this position and adminoptions are not shown
     if (!in_array($user->get_id(), $users) && $showadmin == 0) {
         $content->setVariable("DISPLAY_EDIT", "none");
     }
     // do not display edit function if position is from a former phase and adminoptions are not shown
     if ($phase > $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_COLUMN") && $showadmin == 0) {
         $content->setVariable("DISPLAY_EDIT", "none");
     }
     if ($phase == $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAXCOL") + 2) {
         $content->setVariable("DISPLAY_EDIT", "none");
     }
     $content->setVariable("POSITION_TITLE", $pyramidPosition->get_attribute("OBJ_DESC"));
     if ($pyramidPosition->get_content() != "0") {
         $content->setVariable("POSITION_CONTENT", nl2br($pyramidPosition->get_content()));
     }
     $content->setVariable("POSITION_AUTHORS", "Autoren:");
     foreach ($users as $currentAuthor) {
         $content->setCurrentBlock("BLOCK_POSITION_AUTHOR");
         $currentAuthor = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $currentAuthor);
         $pic_id = $currentAuthor->get_attribute("OBJ_ICON")->get_id();
         $pic_link = $pic_id == 0 ? PATH_URL . "styles/standard/images/anonymous.jpg" : PATH_URL . "download/image/" . $pic_id . "/42/56";
         $content->setVariable("AUTHOR_URL", PATH_URL . "user/index/" . $currentAuthor->get_name());
         $content->setVariable("AUTHOR_PIC", $pic_link);
         $content->setVariable("AUTHOR_NAME", $currentAuthor->get_full_name());
         $content->parse("BLOCK_POSITION_AUTHOR");
     }
     $content->setVariable("POSITION_LAST_CHANGED", "Zuletzt geändert:");
     if ($pyramidPosition->get_attribute("DOC_LAST_MODIFIED") != 0) {
         $content->setVariable("POSITION_LAST_CHANGED_DATE", "am " . date("d.m.Y H:i", (int) $pyramidPosition->get_attribute("DOC_LAST_MODIFIED")));
     }
     if (is_object($pyramidPosition->get_attribute("DOC_USER_MODIFIED"))) {
         $content->setVariable("POSITION_LAST_CHANGED_USER", "von " . $pyramidPosition->get_attribute("DOC_USER_MODIFIED")->get_full_name());
     }
     // display comments
     $content->setVariable("COMMENTS_LABEL", "Kommentare");
     $annotations = $pyramidPosition->get_annotations();
     usort($annotations, "sortRepliesByDate");
     if (count($annotations) == 0) {
         $content->setCurrentBlock("BLOCK_NO_COMMENTS");
         $content->setVariable("NO_COMMENTS", "Keine Kommentare zu dieser Position vorhanden.");
         $content->parse("BLOCK_NO_COMMENTS");
     } else {
         for ($count = 0; $count < count($annotations); $count++) {
             $author = $annotations[$count]->get_creator();
             // determine if current user has read this comment
             $read_comment = 0;
             $read_comment_states = $annotations[$count]->get_attribute("PYRAMIDDISCUSSION_COMMENT_READ_STATES");
             if (is_array($read_comment_states)) {
                 if (array_key_exists($user->get_id(), $read_comment_states)) {
                     $read_comment = $read_comment_states[$user->get_id()];
                 }
             }
             $content->setCurrentBlock("BLOCK_COMMENT");
             if ($read_comment == 0) {
                 $content->setVariable("COMMENT_NEW", "(neu)");
                 // current user has now read this comment
                 if (is_array($read_comment_states)) {
                     $read_comment_states[$user->get_id()] = 1;
                 } else {
                     $read_comment_states = array();
                     $read_comment_states[$user->get_id()] = 1;
                 }
                 $annotations[$count]->set_attribute("PYRAMIDDISCUSSION_COMMENT_READ_STATES", $read_comment_states);
             }
             $content->setVariable("COMMENT_CONTENT", nl2br($annotations[$count]->get_content()));
             $content->setVariable("COMMENT_CONTENT_NOBR", $annotations[$count]->get_content());
             $content->setVariable("COMMENT_TITLE", $annotations[$count]->get_name());
             $content->setVariable("COMMENT_ID", $annotations[$count]->get_id());
             $content->setVariable("ASSET", $pyramiddiscussionExtension->getAssetUrl());
             $content->setVariable("EDIT_COMMENT", "Kommentar bearbeiten");
             // if user is not the author and admin options are not shown dont display edit button
             if ($author->get_id() != $user->get_id() && $showadmin == 0) {
                 $content->setVariable("SHOW_COMMENT_EDIT", "none");
             }
             if ($phase == $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAXCOL") + 2) {
                 $content->setVariable("SHOW_COMMENT_EDIT", "none");
             }
             $pic_id = $author->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->setVariable("COMMENT_AUTHOR", "von <img style='vertical-align:middle;' src=" . $pic_link . ">&nbsp<a href=" . PATH_URL . "user/index/" . $author->get_name() . ">" . $author->get_full_name() . "</a>");
             $content->setVariable("COMMENT_DATE", "am " . date("d.m.Y H:i", (int) $annotations[$count]->get_attribute("OBJ_CREATION_TIME")));
             $content->parse("BLOCK_COMMENT");
         }
     }
     $content->setVariable("CREATE_COMMENT", "Kommentar hinzufügen");
     if ($phase == $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAXCOL") + 2) {
         $content->setVariable("DISPLAY_CREATE_COMMENT", "none");
     }
     $content->setVariable("TITLE_LABEL", "Titel:");
     $content->setVariable("NEW_TITLE", "Kommentar");
     $content->setVariable("CONTENT_LABEL", "Kommentar:");
     $content->setVariable("BACK_LABEL", "Abbrechen");
     $content->setVariable("EDIT_COMMENT", "Kommentar bearbeiten");
     $content->setVariable("EDIT_COMMENT_SUBMIT", "Änderungen speichern");
     $content->setVariable("PYRAMID_BACK", "Zurück zur Pyramide");
     $content->setVariable("PYRAMID_URL", $pyramiddiscussionExtension->getExtensionUrl() . "Index/" . $this->pyramiddiscussion);
     $content->parse("BLOCK_PYRAMID_POSITION");
     $rawWidget = new \Widgets\RawHtml();
     $rawWidget->setHtml($content->get());
     $frameResponseObject->addWidget($rawWidget);
     $frameResponseObject->setHeadline(array(array("name" => "Pyramidendiskussion", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "Index/" . $this->pyramiddiscussion), array("name" => "Diskussionsphase " . $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_COLUMN") . " Position " . $pyramidPosition->get_attribute("PYRAMIDDISCUSSION_ROW"))));
     return $frameResponseObject;
 }