public function frameResponse(\FrameResponseObject $frameResponseObject) { $user = $GLOBALS["STEAM"]->get_current_steam_user(); $testObject = \steam_factory::create_room($GLOBALS["STEAM"]->get_id(), "Test Workflow2", $user->get_workroom()); $testObject->set_attribute("OBJ_TYPE", "WORKPLAN_CONTAINER"); $workplanExtension = \Workplan::getInstance(); $workplanExtension->addJS(); $content = $workplanExtension->loadTemplate("workplan_create.template.html"); $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml("Test container wurde erstellt!"); $frameResponseObject->setTitle("Projektplan erstellen"); $frameResponseObject->addWidget($rawWidget); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $workplanExtension = \Workplan::getInstance(); $workplanExtension->addJS(); $content = $workplanExtension->loadTemplate("workplan_create.template.html"); $content->setCurrentBlock("BLOCK_INFO"); $content->setVariable("INFO_TEXT", "Sie sind dabei einen neuen Projektplan zu erstellen."); $content->parse("BLOCK_INFO"); $content->setCurrentBlock("BLOCK_CREATE_FORMULAR"); $content->setVariable("NAME_LABEL", "Projektname:*"); $content->setVariable("START_DATE_LABEL", "Beginn:*"); $content->setVariable("END_DATE_LABEL", "Ende:"); $content->setVariable("DESCRIPTION_LABEL", "Beschreibung:"); $content->setVariable("CREATE_WORKPLAN_LABEL", "Projektplan erstellen"); $content->setVariable("LABEL_BACK", "Zurück"); $content->setVariable("WORKPLAN_LINK_BACK", $this->getExtension()->getExtensionUrl()); $content->parse("BLOCK_CREATE_FORMULAR"); $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->setTitle("Projektplan erstellen"); $frameResponseObject->setHeadline(array(array("link" => $this->getExtension()->getExtensionUrl(), "name" => "Projektplanverwaltung"), array("", "name" => "Neuer Projektplan"))); $frameResponseObject->addWidget($rawWidget); return $frameResponseObject; }
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); $xmlfile = $workplanContainer->get_inventory_filtered(array(array("+", "class", CLASS_DOCUMENT))); $createContainer = 0; // check if user submitted create milestone or create task form if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST["new_milestone"])) { $createContainer = 1; } else { if (isset($_POST["new_task"])) { $createContainer = 2; } } } // create new milestone or task if ($createContainer != 0) { $xmltree = new \SimpleXMLElement($xmlfile[0]->get_content()); if ($createContainer == 1) { $xml = $xmltree->addChild("milestone"); $newName = $_POST["milestonename"]; $newStart = $_POST["milestonedate"]; $newStart = mktime(0, 0, 0, substr($newStart, 3, 2), substr($newStart, 0, 2), substr($newStart, 6, 4)); $newEnd = $_POST["milestonedate"]; $newEnd = mktime(0, 0, 0, substr($newEnd, 3, 2), substr($newEnd, 0, 2), substr($newEnd, 6, 4)); if (strlen($_POST["milestoneduration"]) > 0) { $newDuration = $_POST["milestoneduration"]; } else { $newDuration = -1; } if (strlen($_POST["milestonedepends"]) > 0) { $newDepends = $_POST["milestonedepends"]; } else { $newDepends = -1; } $newUsers = ""; if (isset($_POST["milestoneusers"])) { for ($count = 0; $count < count($_POST["milestoneusers"]); $count++) { $newUsers = $newUsers . $_POST["milestoneusers"][$count] . ","; } $newUsers = substr($newUsers, 0, strlen($newUsers) - 1); } $portal->set_confirmation("Meilenstein " . $newName . " wurde erfolgreich erstellt."); } else { $xml = $xmltree->addChild("task"); $newName = $_POST["taskname"]; $newStart = $_POST["taskstart"]; $newStart = mktime(0, 0, 0, substr($newStart, 3, 2), substr($newStart, 0, 2), substr($newStart, 6, 4)); $newEnd = $_POST["taskend"]; $newEnd = mktime(0, 0, 0, substr($newEnd, 3, 2), substr($newEnd, 0, 2), substr($newEnd, 6, 4)); if (strlen($_POST["taskduration"]) > 0) { $newDuration = $_POST["taskduration"]; } else { $newDuration = -1; } if (strlen($_POST["taskdepends"]) > 0) { $newDepends = $_POST["taskdepends"]; } else { $newDepends = -1; } $newUsers = ""; if (isset($_POST["taskusers"])) { for ($count = 0; $count < count($_POST["taskusers"]); $count++) { $newUsers = $newUsers . $_POST["taskusers"][$count] . ","; } $newUsers = substr($newUsers, 0, strlen($newUsers) - 1); } $portal->set_confirmation("Vorgang " . $newName . " wurde erfolgreich erstellt."); } $newContainer = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), $newName, $workplanContainer); $xml->addChild("name", $newName); $xml->addChild("oid", $newContainer->get_id()); $newContainer->set_attribute("WORKPLAN_START", $newStart); $xml->addChild("start", $newStart); $newContainer->set_attribute("WORKPLAN_END", $newEnd); $xml->addChild("end", $newEnd); $xml->addChild("duration", $newDuration); $newContainer->set_attribute("WORKPLAN_DURATION", $newDuration); $xml->addChild("depends", $newDepends); $newContainer->set_attribute("WORKPLAN_DEPENDS", $newDepends); $newContainer->set_attribute("WORKPLAN_USERS", $newUsers); $xml->addChild("users", $newUsers); $xmlfile[0]->set_content($xmltree->saveXML()); } if (is_object($workplanContainer) && $workplanContainer instanceof \steam_room) { // if user has the required rights display actionbar if ($user->get_id() == $workplanContainer->get_creator()->get_id() || in_array("WORKPLAN_" . $user->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { $content = $workplanExtension->loadTemplate("workplan_ganttview.template.html"); $content->setCurrentBlock("BLOCK_CONFIRMATION"); $content->setVariable("CONFIRMATION_TEXT", "NONE"); $content->parse("BLOCK_CONFIRMATION"); $content->setCurrentBlock("BLOCK_WORKPLAN_GANTT_ACTIONBAR"); $content->setVariable("LABEL_NEW_SNAPSHOT", "Snapshot erstellen"); $content->setVariable("WORKPLAN_ID", $objectID); $content->setVariable("LABEL_NEW_MILESTONE", "Neuer Meilenstein"); $content->setVariable("LABEL_NEW_TASK", "Neuer Vorgang"); $content->parse("BLOCK_WORKPLAN_GANTT_ACTIONBAR"); $actionBar = new \Widgets\RawHtml(); $actionBar->setHtml($content->get()); $frameResponseObject->addWidget($actionBar); } $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(2); $frameResponseObject->addWidget($tabBar); $xml = simplexml_load_string($xmlfile[0]->get_content()); $helpToArray = $xml->children(); $list = array(); for ($counter = 0; $counter < count($helpToArray); $counter++) { array_push($list, $helpToArray[$counter]); } usort($list, 'sort_xmllist'); $content = $workplanExtension->loadTemplate("workplan_ganttview.template.html"); if (count($list) == 0) { $content->setCurrentBlock("BLOCK_WORKPLAN_GANTT_EMPTY"); $content->setVariable("WORKPLAN_GANTT_EMPTY", "Keine Meilensteine oder Vorgänge zu diesem Projektplan vorhanden."); $content->parse("BLOCK_WORKPLAN_GANTT_EMPTY"); } // change the format of the information so it can be displayed via javascript/jsgantt $oids = "["; $tasks = "["; $starts = "["; $ends = "["; $dependslist = "["; $milestones = "["; for ($counter = 0; $counter < count($list); $counter++) { $name = $list[$counter]->name; $tasks = $tasks . $name . ","; $starts = $starts . (int) $list[$counter]->start . ","; $ends = $ends . (int) $list[$counter]->end . ","; $oids = $oids . $list[$counter]->oid . ","; $depends = $list[$counter]->depends; if ($depends == -1) { $dependslist = $dependslist . "-1,"; } else { $dependslist = $dependslist . $depends . ","; } if ($list[$counter]->getName() == "milestone") { $milestones = $milestones . "1,"; } else { $milestones = $milestones . "0,"; } } if (count($list) > 0) { $oids = substr($oids, 0, strlen($oids) - 1) . "]"; $tasks = substr($tasks, 0, strlen($tasks) - 1) . "]"; $starts = substr($starts, 0, strlen($starts) - 1) . "]"; $ends = substr($ends, 0, strlen($ends) - 1) . "]"; $dependslist = substr($dependslist, 0, strlen($dependslist) - 1) . "]"; $milestones = substr($milestones, 0, strlen($milestones) - 1) . "]"; } else { $oids = $oids . "]"; $tasks = $tasks . "]"; $starts = $starts . "]"; $ends = $ends . "]"; $dependslist = $dependslist . "]"; $milestones = $milestones . "]"; } $content->setCurrentBlock("BLOCK_GANTT_CHART"); $content->setVariable("GANTT_DIV", "ganttchartdiv"); $content->setVariable("WORKPLAN_GANTT_TASKS", $tasks); $content->setVariable("WORKPLAN_GANTT_OID", $oids); $content->setVariable("WORKPLAN_GANTT_MILESTONE", $milestones); $content->setVariable("WORKPLAN_GANTT_DEPENDS", $dependslist); $content->setVariable("WORKPLAN_GANTT_START", $starts); $content->setVariable("WORKPLAN_GANTT_END", $ends); $content->parse("BLOCK_GANTT_CHART"); $content->setCurrentBlock("BLOCK_WORKPLAN_LIST_FORMULAR"); $content->setVariable("LABEL_NEW_MILESTONE", "Meilenstein hinzufügen"); $content->setVariable("LABEL_NEW_TASK", "Vorgang hinzufügen"); $content->setVariable("NAME_LABEL", "Name:*"); $content->setVariable("START_LABEL", "Beginn:*"); $content->setVariable("END_LABEL", "Ende:*"); $content->setVariable("DATE_LABEL", "Datum:*"); $content->setVariable("DURATION_LABEL", "Dauer:"); $content->setVariable("DEPENDS_LABEL", "Abhängigkeit:"); $content->setVariable("USERS_LABEL", "Mitarbeiter:"); $groupID = 0; if (in_array("WORKPLAN_GROUP", $workplanContainer->get_attribute_names())) { $groupID = $workplanContainer->get_attribute("WORKPLAN_GROUP"); } if ($groupID == 0) { $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_MILESTONE"); $content->setVariable("USER_ID", $user->get_id()); $content->setVariable("USER_NAME", $user->get_full_name()); $content->parse("BLOCK_USER_OPTION_MILESTONE"); $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_TASK"); $content->setVariable("USER_ID", $user->get_id()); $content->setVariable("USER_NAME", $user->get_full_name()); if (in_array("WORKPLAN_" . $user->get_id() . "_RESSOURCE", $workplanContainer->get_attribute_names())) { $content->setVariable("USER_RESSOURCE", $workplanContainer->get_attribute("WORKPLAN_" . $user->get_id() . "_RESSOURCE")); } else { $content->setVariable("USER_RESSOURCE", 0); } $content->parse("BLOCK_USER_OPTION_TASK"); } else { $groupObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $groupID); $members = $groupObject->get_members(); for ($count = 0; $count < count($members); $count++) { $currentMember = $members[$count]; $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_MILESTONE"); $content->setVariable("USER_ID", $currentMember->get_id()); $content->setVariable("USER_NAME", $currentMember->get_full_name()); $content->parse("BLOCK_USER_OPTION_MILESTONE"); $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_TASK"); $content->setVariable("USER_ID", $currentMember->get_id()); $content->setVariable("USER_NAME", $currentMember->get_full_name()); if (in_array("WORKPLAN_" . $currentMember->get_id() . "_RESSOURCE", $workplanContainer->get_attribute_names())) { $content->setVariable("USER_RESSOURCE", $workplanContainer->get_attribute("WORKPLAN_" . $currentMember->get_id() . "_RESSOURCE")); } else { $content->setVariable("USER_RESSOURCE", 0); } $content->parse("BLOCK_USER_OPTION_TASK"); } } $content->setCurrentBlock("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setVariable("DEPENDS_OID", "-1"); $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit"); $content->parse("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setCurrentBlock("BLOCK_LIST_TASK_DEPENDS"); $content->setVariable("DEPENDS_OID", "-1"); $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit"); $content->parse("BLOCK_LIST_TASK_DEPENDS"); for ($count = 0; $count < count($list); $count++) { if ($list[$count]->getName() == 'task') { $content->setCurrentBlock("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setVariable("DEPENDS_OID", $list[$count]->oid); $content->setVariable("DEPENDS_NAME", $list[$count]->name); $content->parse("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setCurrentBlock("BLOCK_LIST_TASK_DEPENDS"); $content->setVariable("DEPENDS_OID", $list[$count]->oid); $content->setVariable("DEPENDS_NAME", $list[$count]->name); $content->parse("BLOCK_LIST_TASK_DEPENDS"); } } $content->setVariable("LABEL_BACK", "Ausblenden"); $content->setVariable("LABEL_ADD", "Hinzufügen"); $content->setVariable("WORKPLAN_ID", $this->params[0]); $content->parse("BLOCK_WORKPLAN_LIST_FORMULAR"); $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; } }
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject) { $workplanExtension = \Workplan::getInstance(); $content = $workplanExtension->loadTemplate("workplan_listview.template.html"); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $objectID = $this->params["id"]; $workplanContainer = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectID); $xmlfile = $workplanContainer->get_inventory_filtered(array(array("+", "class", CLASS_DOCUMENT))); $snapshot = $this->params["snapshot"]; $update = $this->params["update"]; if ($user->get_id() != $workplanContainer->get_creator()->get_id() && !in_array("WORKPLAN_" . $user->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { $update = -1; } // load old version if snapshot is requested if ($snapshot != 0) { if ($snapshot == $xmlfile[0]->get_version() || $snapshot == -1) { $snapshot = -1; } else { $previousversions = $xmlfile[0]->get_previous_versions(); $xmlfile[0] = $previousversions[count($previousversions) - $snapshot]; $snapshot = -1; } // if user submitted the update dialog } else { if ($update == 1) { $xmltree = new \SimpleXMLElement($xmlfile[0]->get_content()); $children = $xmltree->children(); $changeID = $this->params["changeID"]; $changeObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $changeID); // search for changeObject in xml tree for ($count = 0; $count < count($children); $count++) { $currentElementID = $children[$count]->oid; if ((int) $currentElementID == (int) $changeID) { $changeElement = $children[$count]; break; } } // save changes in xml file and attributes of the container $changeElement->name = $this->params["name"]; $changeObject->set_name($this->params["name"]); $start = $this->params["start"]; $start = mktime(0, 0, 0, substr($start, 3, 2), substr($start, 0, 2), substr($start, 6, 4)); $changeElement->start = $start; $changeObject->set_attribute("WORKPLAN_START", $start); $end = $this->params["end"]; $end = mktime(0, 0, 0, substr($end, 3, 2), substr($end, 0, 2), substr($end, 6, 4)); $changeElement->end = $end; $changeObject->set_attribute("WORKPLAN_END", $end); if (strlen($this->params["duration"]) > 0) { $changeElement->duration = $this->params["duration"]; $changeObject->set_attribute("WORKPLAN_DURATION", $this->params["duration"]); } else { $changeElement->duration = -1; $changeObject->set_attribute("WORKPLAN_DURATION", -1); } if (strlen($this->params["depends"]) > 0) { $changeElement->depends = $this->params["depends"]; $changeObject->set_attribute("WORKPLAN_DEPENDS", $this->params["depends"]); } else { $changeElement->depends = -1; $changeObject->set_attribute("WORKPLAN_DEPENDS", -1); } $changeElement->users = $this->params["users"]; $changeObject->set_attribute("WORKPLAN_USERS", $this->params["users"]); $xmlfile[0]->set_content($xmltree->saveXML()); // if user deleted something delete it in xml file and on the steam server } else { if ($update == 2) { $mot = $this->params["mot"]; $deleteID = $this->params["elementid"]; $xmltree = new \SimpleXMLElement($xmlfile[0]->get_content()); $children = $xmltree->children(); $tasks = 0; $milestones = 0; for ($count = 0; $count < count($children); $count++) { $currentElementID = $children[$count]->oid; if ((int) $currentElementID == (int) $deleteID) { break; } if ($children[$count]->getName() == 'task') { $tasks++; } else { $milestones++; } } if ($mot == 1) { unset($xmltree->milestone[$milestones]); } else { unset($xmltree->task[$tasks]); } for ($count = 0; $count < count($children); $count++) { if ($children[$count]->depends == (int) $deleteID) { $children[$count]->depends = -1; $dependelement = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $children[$count]->oid); $dependelement->set_attribute("WORKPLAN_DEPENDS", -1); } } $xmlfile[0]->set_content($xmltree->saveXML()); $deleteElement = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $deleteID); $deleteElement->delete(); // if user created a new milestone or task } else { if ($update == 0) { $xmltree = new \SimpleXMLElement($xmlfile[0]->get_content()); if ($this->params["mot"] == 0) { $xml = $xmltree->addChild("milestone"); } else { $xml = $xmltree->addChild("task"); } $newContainer = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), $this->params["name"], $workplanContainer); $xml->addChild("name", $this->params["name"]); $xml->addChild("oid", $newContainer->get_id()); $start = $this->params["start"]; $start = mktime(0, 0, 0, substr($start, 3, 2), substr($start, 0, 2), substr($start, 6, 4)); $newContainer->set_attribute("WORKPLAN_START", $start); $xml->addChild("start", $start); $end = $this->params["end"]; $end = mktime(0, 0, 0, substr($end, 3, 2), substr($end, 0, 2), substr($end, 6, 4)); $newContainer->set_attribute("WORKPLAN_END", $end); $xml->addChild("end", $end); if (strlen($this->params["duration"]) > 0) { $xml->addChild("duration", $this->params["duration"]); $newContainer->set_attribute("WORKPLAN_DURATION", $this->params["duration"]); } else { $xml->addChild("duration", -1); $newContainer->set_attribute("WORKPLAN_DURATION", -1); } if (strlen($this->params["depends"]) > 0) { $xml->addChild("depends", $this->params["depends"]); $newContainer->set_attribute("WORKPLAN_DEPENDS", $this->params["depends"]); } else { $xml->addChild("depends", -1); $newContainer->set_attribute("WORKPLAN_DEPENDS", -1); } $newContainer->set_attribute("WORKPLAN_USERS", $this->params["users"]); $xml->addChild("users", $this->params["users"]); $xmlfile[0]->set_content($xmltree->saveXML()); } } } } // display updated list view of current workplan $xml = simplexml_load_string($xmlfile[0]->get_content()); $helpToArray = $xml->children(); $list = array(); for ($counter = 0; $counter < count($helpToArray); $counter++) { array_push($list, $helpToArray[$counter]); } usort($list, 'sort_xmllist'); if (count($list) == 0) { $content->setCurrentBlock("BLOCK_WORKPLAN_LIST_EMPTY"); $content->setVariable("WORKPLAN_LIST_EMPTY", "Keine Meilensteine oder Vorgänge zu diesem Projektplan vorhanden."); $content->parse("BLOCK_WORKPLAN_LIST_EMPTY"); } else { $content->setCurrentBlock("BLOCK_WORKPLAN_LIST"); $content->setVariable("WORKPLAN_LIST_ELEMENT_NAME", "Name"); $content->setVariable("WORKPLAN_LIST_ELEMENT_START", "Beginn"); $content->setVariable("WORKPLAN_LIST_ELEMENT_END", "Ende"); $content->setVariable("WORKPLAN_LIST_ELEMENT_DURATION", "Arbeitsstunden"); $content->setVariable("WORKPLAN_LIST_ELEMENT_DEPENDS", "Abhängigkeit"); $content->setVariable("WORKPLAN_LIST_ELEMENT_USERS", "Mitarbeiter"); // create and fill array for displaying dependencies $dependencies = array(); for ($counter = 0; $counter < count($list); $counter++) { $dependencies[strval($list[$counter]->oid)] = $counter + 1; } // create list view of current elements for ($counter = 0; $counter < count($list); $counter++) { $content->setCurrentBlock("BLOCK_WORKPLAN_LIST_ELEMENT"); $content->setVariable("WORKPLAN_LIST_ELEMENT_NUMBER", $counter + 1); if ($snapshot == -1) { $content->setVariable("WORKPLAN_LIST_ELEMENT_NAME_VALUE", $list[$counter]->name); } else { $element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $list[$counter]->oid); $elinventory = $element->get_inventory(); $content->setVariable("WORKPLAN_LIST_ELEMENT_NAME_VALUE", $list[$counter]->name . " (" . count($elinventory) . ")"); } $content->setVariable("WORKPLAN_LIST_ELEMENT_START_VALUE", date("d.m.Y", (int) $list[$counter]->start)); $content->setVariable("WORKPLAN_LIST_ELEMENT_END_VALUE", date("d.m.Y", (int) $list[$counter]->end)); if ($list[$counter]->duration == -1) { $content->setVariable("WORKPLAN_LIST_ELEMENT_DURATION_VALUE", "-"); } else { $content->setVariable("WORKPLAN_LIST_ELEMENT_DURATION_VALUE", $list[$counter]->duration); } $content->setVariable("WORKPLAN_LIST_ELEMENT_DURATION_UPDATE", $list[$counter]->duration); if ($list[$counter]->depends == -1) { $content->setVariable("WORKPLAN_LIST_ELEMENT_DEPENDS_VALUE", "-"); } else { if (array_key_exists(strval($list[$counter]->depends), $dependencies)) { $content->setVariable("WORKPLAN_LIST_ELEMENT_DEPENDS_VALUE", $dependencies[strval($list[$counter]->depends)]); } } $content->setVariable("WORKPLAN_LIST_ELEMENT_DEPENDS_UPDATE", $list[$counter]->depends); if ($list[$counter]->getName() == 'task') { $content->setVariable("WORKPLAN_LIST_ELEMENT_MOT", "0"); } else { $content->setVariable("WORKPLAN_LIST_ELEMENT_MOT", "1"); } $content->setVariable("WORKPLAN_LIST_ELEMENT_OID", $list[$counter]->oid); $content->setVariable("WORKPLAN_LIST_ELEMENT_NAME_DEL", $list[$counter]->name); $content->setVariable("WORKPLAN_ID", $objectID); // convert saved users to output format $userList = $list[$counter]->users; $userList = "[" . str_replace(";", ",", $userList) . "]"; $content->setVariable("WORKPLAN_LIST_ELEMENT_USERS_JSON", $userList); $userList = json_decode($userList); $outputUsers = ""; for ($count = 0; $count < count($userList); $count++) { $currentUser = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $userList[$count]); $outputUsers = $outputUsers . $currentUser->get_full_name() . "<br>"; } if (count($userList) == 0) { $outputUsers = "-"; } $content->setVariable("WORKPLAN_LIST_ELEMENT_USERS_VALUE", $outputUsers); $content->setVariable("WORKPLAN_LIST_ELEMENT_CHANGE_VALUE", "Bearbeiten"); $content->setVariable("WORKPLAN_LIST_ELEMENT_DELETE_VALUE", "Löschen"); if ($snapshot != -1 && ($user->get_id() == $workplanContainer->get_creator()->get_id() || in_array("WORKPLAN_" . $user->get_id() . "_LEADER", $workplanContainer->get_attribute_names()))) { $content->setVariable("WORKPLAN_RIGHTS", ""); } else { $content->setVariable("WORKPLAN_RIGHTS", "none"); } $content->parse("BLOCK_WORKPLAN_LIST_ELEMENT"); } $content->parse("BLOCK_WORKPLAN_LIST"); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $ajaxResponseObject->setStatus("ok"); $ajaxResponseObject->addWidget($rawWidget); return $ajaxResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $workplanExtension = \Workplan::getInstance(); $workplanExtension->addJS(); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $portal = \lms_portal::get_instance(); $newWorkplan = FALSE; if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["new_workplan"])) { $newWorkplan = TRUE; $values = $_POST["values"]; $workplanContainer = \steam_factory::create_room($GLOBALS["STEAM"]->get_id(), $values["name"], $user->get_workroom()); $workplanContainer->set_attribute("OBJ_TYPE", "WORKPLAN_CONTAINER"); $xml = new \SimpleXMLElement("<workplan></workplan>"); $xml->addAttribute("name", $values["name"]); $start = $values["start"]; $start = mktime(0, 0, 0, substr($start, 3, 2), substr($start, 0, 2), substr($start, 6, 4)); $workplanContainer->set_attribute("WORKPLAN_START", $start); $xml->addAttribute("start", $start); if (!empty($values["end"])) { $end = $values["end"]; $end = mktime(0, 0, 0, substr($end, 3, 2), substr($end, 0, 2), substr($end, 6, 4)); $workplanContainer->set_attribute("WORKPLAN_END", $end); $xml->addAttribute("end", $end); } else { $workplanContainer->set_attribute("WORKPLAN_END", -1); $xml->addAttribute("end", -1); } if (!empty($values["description"])) { $workplanContainer->set_attribute("WORKPLAN_DESCRIPTION", $values["description"]); $xml->addAttribute("description", $values["description"]); } else { $workplanContainer->set_attribute("WORKPLAN_DESCRIPTION", ""); $xml->addAttribute("description", ""); } \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "version.xml", $xml->saveXML(), "text/xml", $workplanContainer); $portal->set_confirmation("Projektplan " . $values["name"] . " erfolgreich erstellt."); } if (!$newWorkplan) { $workplanContainer = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[0]); } if (is_object($workplanContainer) && $workplanContainer instanceof \steam_room) { $content = $workplanExtension->loadTemplate("workplan_overview.template.html"); if (!$newWorkplan) { $content->setCurrentBlock("BLOCK_CONFIRMATION"); $content->setVariable("CONFIRMATION_TEXT", "NONE"); $content->parse("BLOCK_CONFIRMATION"); } // if current user has required rights display actionbar if ($workplanContainer->get_creator()->get_id() == $user->get_id() || in_array("WORKPLAN_" . $user->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { $content->setCurrentBlock("BLOCK_WORKPLAN_OVERVIEW_ACTIONBAR"); $content->setVariable("LABEL_CHANGE", "Eigenschaften bearbeiten"); $content->setVariable("LABEL_SNAPSHOT", "Snapshot erstellen"); $content->setVariable("WORKPLAN_ID", $workplanContainer->get_id()); if ($workplanContainer->get_creator()->get_id() == $user->get_id()) { $content->setVariable("WORKPLAN_RIGHTS_CHANGE", ""); } else { $content->setVariable("WORKPLAN_RIGHTS_CHANGE", "none"); } $content->parse("BLOCK_WORKPLAN_OVERVIEW_ACTIONBAR"); } $actionBar = new \Widgets\RawHtml(); $actionBar->setHtml($content->get()); $frameResponseObject->addWidget($actionBar); $tabBar = new \Widgets\TabBar(); $tabBar->setTabs(array(array("name" => "Überblick", "link" => $this->getExtension()->getExtensionUrl() . "overview/" . $workplanContainer->get_id()), array("name" => "Tabelle", "link" => $this->getExtension()->getExtensionUrl() . "listView/" . $workplanContainer->get_id()), array("name" => "Gantt-Diagramm", "link" => $this->getExtension()->getExtensionUrl() . "ganttView/" . $workplanContainer->get_id()), array("name" => "Mitarbeiter", "link" => $this->getExtension()->getExtensionUrl() . "users/" . $workplanContainer->get_id()), array("name" => "Snapshots", "link" => $this->getExtension()->getExtensionUrl() . "snapshots/" . $workplanContainer->get_id()))); $tabBar->setActiveTab(0); $frameResponseObject->addWidget($tabBar); $content = $workplanExtension->loadTemplate("workplan_overview.template.html"); if (isset($_POST["edit"])) { $edit = $_POST["edit"]; } else { $edit = 0; } // if the user clicked on the edit symbol in Index-Command-View display edit view if ($edit == 1) { $content->setCurrentBlock("BLOCK_WORKPLAN_OVERVIEW_TABLE_EDIT"); $content->setVariable("WORKPLAN_OVERVIEW_EDIT", "Eigenschaften bearbeiten"); $content->setVariable("NAME_LABEL", "Projektname:*"); $content->setVariable("START_LABEL", "Beginn:*"); $content->setVariable("END_LABEL", "Ende:"); $content->setVariable("CREATOR_LABEL", "Projektersteller:"); $content->setVariable("DESCRIPTION_LABEL", "Beschreibung:"); $content->setVariable("NAME_VALUE", $workplanContainer->get_name()); $content->setVariable("START_VALUE", date("d.m.Y", (int) $workplanContainer->get_attribute("WORKPLAN_START"))); $content->setVariable("CREATOR_VALUE", $workplanContainer->get_creator()->get_full_name()); if ($workplanContainer->get_attribute("WORKPLAN_END") != -1) { $content->setVariable("END_VALUE", date("d.m.Y", (int) $workplanContainer->get_attribute("WORKPLAN_END"))); } if (in_array("WORKPLAN_DESCRIPTION", $workplanContainer->get_attribute_names())) { $content->setVariable("DESCRIPTION_VALUE", $workplanContainer->get_attribute("WORKPLAN_DESCRIPTION")); } $content->setVariable("LABEL_SAVE", "Speichern"); $content->setVariable("LABEL_BACK", "Abbrechen"); $content->setVariable("WORKPLAN_ID", $workplanContainer->get_id()); $content->parse("BLOCK_WORKPLAN_OVERVIEW_TABLE_EDIT"); // else display normal view } else { $content->setCurrentBlock("BLOCK_WORKPLAN_OVERVIEW_TABLE"); $content->setVariable("WORKPLAN_OVERVIEW_ATTRIBUTE", "Eigenschaft"); $content->setVariable("WORKPLAN_OVERVIEW_VALUE", "Wert"); $content->setVariable("NAME_LABEL", "Projektname"); $content->setVariable("START_LABEL", "Beginn"); $content->setVariable("END_LABEL", "Ende"); $content->setVariable("CREATOR_LABEL", "Projektersteller"); $content->setVariable("DESCRIPTION_LABEL", "Beschreibung"); $content->setVariable("NAME_VALUE", $workplanContainer->get_name()); $content->setVariable("START_VALUE", date("d.m.Y", (int) $workplanContainer->get_attribute("WORKPLAN_START"))); $content->setVariable("CREATOR_VALUE", $workplanContainer->get_creator()->get_full_name()); if ($workplanContainer->get_attribute("WORKPLAN_END") != -1) { $content->setVariable("END_VALUE", date("d.m.Y", (int) $workplanContainer->get_attribute("WORKPLAN_END"))); } else { $content->setVariable("END_VALUE", "-"); } if (in_array("WORKPLAN_DESCRIPTION", $workplanContainer->get_attribute_names())) { if (strlen(trim($workplanContainer->get_attribute("WORKPLAN_DESCRIPTION"))) > 0) { $content->setVariable("DESCRIPTION_VALUE", nl2br($workplanContainer->get_attribute("WORKPLAN_DESCRIPTION"))); } else { $content->setVariable("DESCRIPTION_VALUE", "-"); } } else { $content->setVariable("DESCRIPTION_VALUE", "-"); } $content->parse("BLOCK_WORKPLAN_OVERVIEW_TABLE"); } $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; } }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $workplanExtension = \Workplan::getInstance(); $workplanExtension->addJS(); $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); // move workplan to group workroom if form was submitted if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["move"])) { $values = $_POST["values"]; $groupID = $values["groupid"]; $newgroup = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $groupID); $newroom = $newgroup->get_workroom(); $workplanContainer->set_attribute("WORKPLAN_GROUP", $groupID); $workplanContainer->move($newroom); $portal->set_confirmation("Projektplan " . $workplanContainer->get_name() . " erfolgreich in Gruppe " . $newgroup->get_name() . " verschoben."); } if (is_object($workplanContainer) && $workplanContainer instanceof \steam_room) { $content = $workplanExtension->loadTemplate("workplan_users.template.html"); $content->setCurrentBlock("BLOCK_CONFIRMATION"); $content->setVariable("CONFIRMATION_TEXT", "NONE"); $content->parse("BLOCK_CONFIRMATION"); $confirmationBar = new \Widgets\RawHtml(); $confirmationBar->setHtml($content->get()); $frameResponseObject->addWidget($confirmationBar); // if current user has required rights display actionbar if ($workplanContainer->get_creator()->get_id() == $user->get_id()) { $actionBar = new \Widgets\ActionBar(); $actionBar->setActions(array(array("name" => "Mitarbeiter bearbeiten", "link" => "javascript:changeUsers(" . $objectID . ")"))); $frameResponseObject->addWidget($actionBar); } $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(3); $frameResponseObject->addWidget($tabBar); $content = $workplanExtension->loadTemplate("workplan_users.template.html"); $content->setCurrentBlock("BLOCK_USERS_LIST"); $content->setVariable("WORKPLAN_USERS_ELEMENT_NAME", "Name"); $content->setVariable("WORKPLAN_USERS_ELEMENT_ROLE", "Rolle"); $content->setVariable("WORKPLAN_USERS_ELEMENT_RESSOURCE", "Ressourcenwert"); // check if workplan is in group and save the right users in array (sorted according to their role) $group = 0; if (in_array("WORKPLAN_GROUP", $workplanContainer->get_attribute_names())) { $group = $workplanContainer->get_attribute("WORKPLAN_GROUP"); } if ($group == 0) { $users = array(); array_push($users, $workplanContainer->get_creator()); } else { $groupObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $group); $users = array(); $normalusers = array(); $groupusers = $groupObject->get_members(); array_push($users, $workplanContainer->get_creator()); for ($count = 0; $count < count($groupusers); $count++) { if ($groupusers[$count]->get_id() != $workplanContainer->get_creator()->get_id()) { if (in_array("WORKPLAN_" . $groupusers[$count]->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { array_push($users, $groupusers[$count]); } else { array_push($normalusers, $groupusers[$count]); } } } $users = array_merge($users, $normalusers); } // display found users sorted according to their role for ($count = 0; $count < count($users); $count++) { $content->setCurrentBlock("BLOCK_USERS_ELEMENT"); $content->setVariable("WORKPLAN_USERS_ELEMENT_NAME_VALUE", $users[$count]->get_full_name()); $content->setVariable("WORKPLAN_USERS_ELEMENT_RESSOURCE_VALUE", $workplanContainer->get_attribute("WORKPLAN_" . $users[$count]->get_id() . "_RESSOURCE")); if ($workplanContainer->get_creator()->get_id() == $users[$count]->get_id()) { $content->setVariable("WORKPLAN_USERS_ELEMENT_ROLE_VALUE", "Projektersteller"); } else { if (in_array("WORKPLAN_" . $users[$count]->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { $content->setVariable("WORKPLAN_USERS_ELEMENT_ROLE_VALUE", "Projektleiter"); } else { $content->setVariable("WORKPLAN_USERS_ELEMENT_ROLE_VALUE", "Mitarbeiter"); } } $content->parse("BLOCK_USERS_ELEMENT"); } $content->parse("BLOCK_USERS_LIST"); // if workplan is private display dialog to move it to a group the current user is member in if ($group == 0) { $groups = $user->get_groups(); $koalagroups = array(); for ($count = 0; $count < count($groups); $count++) { $currentGroup = $groups[$count]; if (substr($currentGroup->get_groupname(), 0, 10) == 'PrivGroups' | substr($currentGroup->get_groupname(), 0, 12) == 'PublicGroups') { array_push($koalagroups, $currentGroup); } } if (count($koalagroups) > 0) { $content->setCurrentBlock("BLOCK_USERS_TOGROUP"); $content->setVariable("WORKPLAN_TOGROUP", "Verschieben in Gruppe: "); $content->setVariable("GROUPCOUNT", count($koalagroups)); $content->setVariable("LABEL_MOVE", "Verschieben"); for ($count = 0; $count < count($koalagroups); $count++) { $currentGroup = $koalagroups[$count]; $content->setCurrentBlock("BLOCK_USERS_TOGROUP_ELEMENT"); $content->setVariable("GROUPID", $currentGroup->get_id()); $content->setVariable("GROUPNAME", $currentGroup->get_name()); $content->parse("BLOCK_USERS_TOGROUP_ELEMENT"); } $content->parse("BLOCK_USERS_TOGROUP"); } } $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; } }
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; } }
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject) { $workplanExtension = \Workplan::getInstance(); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $content = $workplanExtension->loadTemplate("workplan_users.template.html"); $portal = \lms_portal::get_instance(); $objectID = $this->params["id"]; $workplanContainer = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectID); if ($user->get_id() != $workplanContainer->get_creator()->get_id()) { $this->params["newChanges"] = 0; $this->params["change"] = 0; } // if user submitted new changes save them if ($this->params["newChanges"] == 1) { $oids = json_decode($this->params["oids"]); $ressources = json_decode($this->params["ressources"]); $roles = json_decode($this->params["roles"]); $workplanContainer->set_attribute("WORKPLAN_" . $workplanContainer->get_creator()->get_id() . "_RESSOURCE", $this->params["leaderRes"]); for ($count = 0; $count < count($oids); $count++) { $workplanContainer->set_attribute("WORKPLAN_" . $oids[$count] . "_RESSOURCE", $ressources[$count]); if ($roles[$count] == 1) { $workplanContainer->set_attribute("WORKPLAN_" . $oids[$count] . "_LEADER", "LEADER"); } else { $workplanContainer->delete_attribute("WORKPLAN_" . $oids[$count] . "_LEADER"); } } } // check if workplan is in group and save the group members in array (sorted according to their role) $group = 0; if (in_array("WORKPLAN_GROUP", $workplanContainer->get_attribute_names())) { $group = $workplanContainer->get_attribute("WORKPLAN_GROUP"); } $users = array(); array_push($users, $workplanContainer->get_creator()); if ($group != 0) { $groupObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $group); $normalusers = array(); $groupusers = $groupObject->get_members(); for ($count = 0; $count < count($groupusers); $count++) { if ($groupusers[$count]->get_id() != $workplanContainer->get_creator()->get_id()) { if (in_array("WORKPLAN_" . $groupusers[$count]->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { array_push($users, $groupusers[$count]); } else { array_push($normalusers, $groupusers[$count]); } } } $users = array_merge($users, $normalusers); } // display edit view if ($this->params["change"] == 1) { $content->setCurrentBlock("BLOCK_USERS_CHANGE_LIST"); $content->setVariable("WORKPLAN_USERS_ELEMENT_NAME", "Name"); $content->setVariable("WORKPLAN_USERS_ELEMENT_ROLE", "Rolle"); $content->setVariable("WORKPLAN_USERS_ELEMENT_RESSOURCE", "Ressourcenwert"); $content->setCurrentBlock("BLOCK_USERS_CREATOR"); $content->setVariable("WORKPLAN_USERS_ELEMENT_ROLE_VALUE", "Projektersteller"); $content->setVariable("WORKPLAN_USERS_ELEMENT_NAME_VALUE", $workplanContainer->get_creator()->get_full_name()); $content->setVariable("WORKPLAN_USERS_ELEMENT_RESSOURCE_VALUE", $workplanContainer->get_attribute("WORKPLAN_" . $workplanContainer->get_creator()->get_id() . "_RESSOURCE")); $content->parse("BLOCK_USERS_CREATOR"); for ($count = 0; $count < count($users); $count++) { if ($users[$count]->get_id() != $workplanContainer->get_creator()->get_id()) { if (in_array("WORKPLAN_" . $users[$count]->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { $content->setCurrentBlock("BLOCK_USERS_CHANGE_ELEMENT_LEADER"); $content->setVariable("WORKPLAN_USERS_ELEMENT_NAME_VALUE", $users[$count]->get_full_name()); $content->setVariable("WORKPLAN_USERS_ELEMENT_RESSOURCE_VALUE", $workplanContainer->get_attribute("WORKPLAN_" . $users[$count]->get_id() . "_RESSOURCE")); $content->setVariable("WORKPLAN_USERS_ELEMENT_OID", $users[$count]->get_id()); $content->setVariable("WORKPLAN_WORKER", "Mitarbeiter"); $content->setVariable("WORKPLAN_LEADER", "Projektleiter"); $content->parse("BLOCK_USERS_CHANGE_ELEMENT_LEADER"); } else { $content->setCurrentBlock("BLOCK_USERS_CHANGE_ELEMENT_WORKER"); $content->setVariable("WORKPLAN_USERS_ELEMENT_NAME_VALUE", $users[$count]->get_full_name()); $content->setVariable("WORKPLAN_USERS_ELEMENT_RESSOURCE_VALUE", $workplanContainer->get_attribute("WORKPLAN_" . $users[$count]->get_id() . "_RESSOURCE")); $content->setVariable("WORKPLAN_USERS_ELEMENT_OID", $users[$count]->get_id()); $content->setVariable("WORKPLAN_WORKER", "Mitarbeiter"); $content->setVariable("WORKPLAN_LEADER", "Projektleiter"); $content->parse("BLOCK_USERS_CHANGE_ELEMENT_WORKER"); } } } $content->setVariable("LABEL_SAVE", "Änderungen speichern"); $content->setVariable("LABEL_BACK", "Abbrechen"); $content->setVariable("WORKPLAN_ID", $objectID); $content->parse("BLOCK_USERS_CHANGE_LIST"); // display normal view } else { if ($this->params["change"] == 0) { $content->setCurrentBlock("BLOCK_USERS_LIST"); $content->setVariable("WORKPLAN_USERS_ELEMENT_NAME", "Name"); $content->setVariable("WORKPLAN_USERS_ELEMENT_ROLE", "Rolle"); $content->setVariable("WORKPLAN_USERS_ELEMENT_RESSOURCE", "Ressourcenwert"); for ($count = 0; $count < count($users); $count++) { $content->setCurrentBlock("BLOCK_USERS_ELEMENT"); $content->setVariable("WORKPLAN_USERS_ELEMENT_NAME_VALUE", $users[$count]->get_full_name()); $content->setVariable("WORKPLAN_USERS_ELEMENT_RESSOURCE_VALUE", $workplanContainer->get_attribute("WORKPLAN_" . $users[$count]->get_id() . "_RESSOURCE")); if ($workplanContainer->get_creator()->get_id() == $users[$count]->get_id()) { $content->setVariable("WORKPLAN_USERS_ELEMENT_ROLE_VALUE", "Projektersteller"); } else { if (in_array("WORKPLAN_" . $users[$count]->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { $content->setVariable("WORKPLAN_USERS_ELEMENT_ROLE_VALUE", "Projektleiter"); } else { $content->setVariable("WORKPLAN_USERS_ELEMENT_ROLE_VALUE", "Mitarbeiter"); } } $content->parse("BLOCK_USERS_ELEMENT"); } $content->parse("BLOCK_USERS_LIST"); } } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $ajaxResponseObject->setStatus("ok"); $ajaxResponseObject->addWidget($rawWidget); return $ajaxResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $workplanExtension = \Workplan::getInstance(); $workplanExtension->addJS(); $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_container) { // if current user has required rights display actionbar if ($user->get_id() == $workplanContainer->get_creator()->get_id() || in_array("WORKPLAN_" . $user->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { $content = $workplanExtension->loadTemplate("workplan_listview.template.html"); $content->setCurrentBlock("BLOCK_CONFIRMATION"); $content->setVariable("CONFIRMATION_TEXT", "NONE"); $content->parse("BLOCK_CONFIRMATION"); $content->setCurrentBlock("BLOCK_WORKPLAN_LIST_ACTIONBAR"); $content->setVariable("WORKPLAN_ID", $objectID); $content->setVariable("LABEL_NEW_SNAPSHOT", "Snapshot erstellen"); $content->setVariable("LABEL_NEW_MILESTONE", "Neuer Meilenstein"); $content->setVariable("LABEL_NEW_TASK", "Neuer Vorgang"); $content->parse("BLOCK_WORKPLAN_LIST_ACTIONBAR"); $actionBar = new \Widgets\RawHtml(); $actionBar->setHtml($content->get()); $frameResponseObject->addWidget($actionBar); } $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(1); $frameResponseObject->addWidget($tabBar); // load workplan from xml file in workplan room and sort elements $xmlfile = $workplanContainer->get_inventory_filtered(array(array("+", "class", CLASS_DOCUMENT))); $xml = simplexml_load_string($xmlfile[0]->get_content()); $helpToArray = $xml->children(); $list = array(); for ($counter = 0; $counter < count($helpToArray); $counter++) { array_push($list, $helpToArray[$counter]); } usort($list, 'sort_xmllist'); $content = $workplanExtension->loadTemplate("workplan_listview.template.html"); if (count($list) == 0) { $content->setCurrentBlock("BLOCK_WORKPLAN_LIST_EMPTY"); $content->setVariable("WORKPLAN_LIST_EMPTY", "Keine Meilensteine oder Vorgänge zu diesem Projektplan vorhanden."); $content->parse("BLOCK_WORKPLAN_LIST_EMPTY"); } else { $content->setCurrentBlock("BLOCK_WORKPLAN_LIST"); $content->setVariable("WORKPLAN_LIST_ELEMENT_NAME", "Name"); $content->setVariable("WORKPLAN_LIST_ELEMENT_START", "Beginn"); $content->setVariable("WORKPLAN_LIST_ELEMENT_END", "Ende"); $content->setVariable("WORKPLAN_LIST_ELEMENT_DURATION", "Arbeitsstunden"); $content->setVariable("WORKPLAN_LIST_ELEMENT_DEPENDS", "Abhängigkeit"); $content->setVariable("WORKPLAN_LIST_ELEMENT_USERS", "Mitarbeiter"); // create and fill array for displaying dependencies $dependencies = array(); for ($counter = 0; $counter < count($list); $counter++) { $dependencies[strval($list[$counter]->oid)] = $counter + 1; } // create list view of current elements for ($counter = 0; $counter < count($list); $counter++) { $element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $list[$counter]->oid); $elinventory = $element->get_inventory(); $content->setCurrentBlock("BLOCK_WORKPLAN_LIST_ELEMENT"); $content->setVariable("WORKPLAN_LIST_ELEMENT_NUMBER", $counter + 1); $content->setVariable("WORKPLAN_LIST_ELEMENT_NAME_VALUE", $list[$counter]->name . " (" . count($elinventory) . ")"); $content->setVariable("WORKPLAN_LIST_ELEMENT_START_VALUE", date("d.m.Y", (int) $list[$counter]->start)); $content->setVariable("WORKPLAN_LIST_ELEMENT_END_VALUE", date("d.m.Y", (int) $list[$counter]->end)); if ($list[$counter]->duration == -1) { $content->setVariable("WORKPLAN_LIST_ELEMENT_DURATION_VALUE", "-"); } else { $content->setVariable("WORKPLAN_LIST_ELEMENT_DURATION_VALUE", $list[$counter]->duration); } $content->setVariable("WORKPLAN_LIST_ELEMENT_DURATION_UPDATE", $list[$counter]->duration); if ($list[$counter]->depends == -1) { $content->setVariable("WORKPLAN_LIST_ELEMENT_DEPENDS_VALUE", "-"); } else { if (array_key_exists(strval($list[$counter]->depends), $dependencies)) { $content->setVariable("WORKPLAN_LIST_ELEMENT_DEPENDS_VALUE", $dependencies[strval($list[$counter]->depends)]); } } $content->setVariable("WORKPLAN_LIST_ELEMENT_DEPENDS_UPDATE", $list[$counter]->depends); if ($list[$counter]->getName() == 'task') { $content->setVariable("WORKPLAN_LIST_ELEMENT_MOT", "0"); } else { $content->setVariable("WORKPLAN_LIST_ELEMENT_MOT", "1"); } $content->setVariable("WORKPLAN_LIST_ELEMENT_OID", $list[$counter]->oid); $content->setVariable("WORKPLAN_LIST_ELEMENT_NAME_DEL", $list[$counter]->name); $content->setVariable("WORKPLAN_ID", $objectID); // convert saved users to output format $userList = $list[$counter]->users; $userList = "[" . str_replace(";", ",", $userList) . "]"; $content->setVariable("WORKPLAN_LIST_ELEMENT_USERS_JSON", $userList); $userList = json_decode($userList); $outputUsers = ""; for ($count = 0; $count < count($userList); $count++) { $currentUser = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $userList[$count]); $outputUsers = $outputUsers . $currentUser->get_full_name() . "<br>"; } if (count($userList) == 0) { $outputUsers = "-"; } $content->setVariable("WORKPLAN_LIST_ELEMENT_USERS_VALUE", $outputUsers); $content->setVariable("WORKPLAN_LIST_UPDATE_OID", $list[$counter]->oid); $content->setVariable("WORKPLAN_LIST_ELEMENT_CHANGE_VALUE", "Bearbeiten"); $content->setVariable("WORKPLAN_LIST_ELEMENT_DELETE_VALUE", "Löschen"); if ($user->get_id() == $workplanContainer->get_creator()->get_id() || in_array("WORKPLAN_" . $user->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { $content->setVariable("WORKPLAN_RIGHTS", ""); } else { $content->setVariable("WORKPLAN_RIGHTS", "none"); } $content->parse("BLOCK_WORKPLAN_LIST_ELEMENT"); } $content->parse("BLOCK_WORKPLAN_LIST"); } // create update dialogs $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_DIALOG"); $content->setVariable("WORKPLAN_UPDATE_ID", $objectID); $content->setVariable("UPDATE_LABEL", "Meilenstein bearbeiten"); $content->setVariable("UPDATE_TASK_LABEL", "Vorgang bearbeiten"); $content->setVariable("UPDATE_NAME_LABEL", "Name:*"); $content->setVariable("UPDATE_DATE_LABEL", "Datum:*"); $content->setVariable("UPDATE_START_LABEL", "Beginn:*"); $content->setVariable("UPDATE_END_LABEL", "Ende:*"); $content->setVariable("UPDATE_DURATION_LABEL", "Dauer:"); $content->setVariable("UPDATE_DEPENDS_LABEL", "Abhängigkeit:"); // create all dependency options in update dialogs $content->setCurrentBlock("UPDATE_BLOCK_WORKPLAN_UPDATE_DEPENDS"); $content->setVariable("DEPENDS_OID", "-1"); $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit"); $content->parse("BLOCK_WORKPLAN_UPDATE_DEPENDS"); $content->setCurrentBlock("UPDATE_BLOCK_WORKPLAN_UPDATE_TASK_DEPENDS"); $content->setVariable("DEPENDS_OID", "-1"); $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit"); $content->parse("BLOCK_WORKPLAN_UPDATE_TASK_DEPENDS"); for ($count = 0; $count < count($list); $count++) { if ($list[$count]->getName() == 'task') { $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_DEPENDS"); $content->setVariable("DEPENDS_OID", $list[$count]->oid); $content->setVariable("DEPENDS_NAME", $list[$count]->name); $content->parse("BLOCK_WORKPLAN_UPDATE_DEPENDS"); $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_TASK_DEPENDS"); $content->setVariable("DEPENDS_OID", $list[$count]->oid); $content->setVariable("DEPENDS_NAME", $list[$count]->name); $content->parse("BLOCK_WORKPLAN_UPDATE_TASK_DEPENDS"); } } // create user options in update dialogs $content->setVariable("UPDATE_USERS_LABEL", "Mitarbeiter:"); $groupID = 0; if (in_array("WORKPLAN_GROUP", $workplanContainer->get_attribute_names())) { $groupID = $workplanContainer->get_attribute("WORKPLAN_GROUP"); } if ($groupID == 0) { $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_USER"); $content->setVariable("USER_ID", $user->get_id()); $content->setVariable("USER_NAME", $user->get_full_name()); $content->parse("BLOCK_WORKPLAN_UPDATE_USER"); $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_TASK_USER"); $content->setVariable("USER_ID", $user->get_id()); $content->setVariable("USER_NAME", $user->get_full_name()); $content->parse("BLOCK_WORKPLAN_UPDATE_TASK_USER"); } else { $groupObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $groupID); $members = $groupObject->get_members(); for ($count = 0; $count < count($members); $count++) { $currentMember = $members[$count]; $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_USER"); $content->setVariable("USER_ID", $currentMember->get_id()); $content->setVariable("USER_NAME", $currentMember->get_full_name()); $content->parse("BLOCK_WORKPLAN_UPDATE_USER"); $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_TASK_USER"); $content->setVariable("USER_ID", $currentMember->get_id()); $content->setVariable("USER_NAME", $currentMember->get_full_name()); $content->parse("BLOCK_WORKPLAN_UPDATE_TASK_USER"); } } $content->setVariable("UPDATE_SUBMIT_LABEL", "Abschicken"); $content->setVariable("UPDATE_LABEL_BACK", "Abbrechen"); $content->parse("BLOCK_WORKPLAN_UPDATE_DIALOG"); // create task and milestone create forms $content->setCurrentBlock("BLOCK_WORKPLAN_LIST_FORMULAR"); $content->setVariable("LABEL_NEW_MILESTONE", "Meilenstein hinzufügen"); $content->setVariable("LABEL_NEW_TASK", "Vorgang hinzufügen"); $content->setVariable("NAME_LABEL", "Name:*"); $content->setVariable("START_LABEL", "Beginn:*"); $content->setVariable("END_LABEL", "Ende:*"); $content->setVariable("DATE_LABEL", "Datum:*"); $content->setVariable("DURATION_LABEL", "Dauer:"); $content->setVariable("DEPENDS_LABEL", "Abhängigkeit:"); $content->setVariable("USERS_LABEL", "Mitarbeiter:"); // create all dependency options in create forms $content->setCurrentBlock("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setVariable("DEPENDS_OID", "-1"); $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit"); $content->parse("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setCurrentBlock("BLOCK_LIST_TASK_DEPENDS"); $content->setVariable("DEPENDS_OID", "-1"); $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit"); $content->parse("BLOCK_LIST_TASK_DEPENDS"); for ($count = 0; $count < count($list); $count++) { if ($list[$count]->getName() == 'task') { $content->setCurrentBlock("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setVariable("DEPENDS_OID", $list[$count]->oid); $content->setVariable("DEPENDS_NAME", $list[$count]->name); $content->parse("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setCurrentBlock("BLOCK_LIST_TASK_DEPENDS"); $content->setVariable("DEPENDS_OID", $list[$count]->oid); $content->setVariable("DEPENDS_NAME", $list[$count]->name); $content->parse("BLOCK_LIST_TASK_DEPENDS"); } } // create user options in create forms if ($groupID == 0) { $content->setCurrentBlock("BLOCK_USER_OPTION_MILESTONE"); $content->setVariable("USER_ID", $user->get_id()); $content->setVariable("USER_NAME", $user->get_full_name()); $content->parse("BLOCK_USER_OPTION_MILESTONE"); $content->setCurrentBlock("BLOCK_USER_OPTION_TASK"); $content->setVariable("USER_ID", $user->get_id()); $content->setVariable("USER_NAME", $user->get_full_name()); if (in_array("WORKPLAN_" . $user->get_id() . "_RESSOURCE", $workplanContainer->get_attribute_names())) { $content->setVariable("USER_RESSOURCE", $workplanContainer->get_attribute("WORKPLAN_" . $user->get_id() . "_RESSOURCE")); } else { $content->setVariable("USER_RESSOURCE", 0); } $content->parse("BLOCK_USER_OPTION_TASK"); } else { $groupObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $groupID); $members = $groupObject->get_members(); for ($count = 0; $count < count($members); $count++) { $currentMember = $members[$count]; $content->setCurrentBlock("BLOCK_USER_OPTION_MILESTONE"); $content->setVariable("USER_ID", $currentMember->get_id()); $content->setVariable("USER_NAME", $currentMember->get_full_name()); $content->parse("BLOCK_USER_OPTION_MILESTONE"); $content->setCurrentBlock("BLOCK_USER_OPTION_TASK"); $content->setVariable("USER_ID", $currentMember->get_id()); $content->setVariable("USER_NAME", $currentMember->get_full_name()); if (in_array("WORKPLAN_" . $currentMember->get_id() . "_RESSOURCE", $workplanContainer->get_attribute_names())) { $content->setVariable("USER_RESSOURCE", $workplanContainer->get_attribute("WORKPLAN_" . $currentMember->get_id() . "_RESSOURCE")); } else { $content->setVariable("USER_RESSOURCE", 0); } $content->parse("BLOCK_USER_OPTION_TASK"); } } $content->setVariable("LABEL_BACK", "Ausblenden"); $content->setVariable("LABEL_ADD", "Hinzufügen"); $content->setVariable("WORKPLAN_ID", $objectID); $content->parse("BLOCK_WORKPLAN_LIST_FORMULAR"); $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; } }
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject) { $workplanExtension = \Workplan::getInstance(); $content = $workplanExtension->loadTemplate("workplan_listview.template.html"); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $objectID = $this->params["id"]; $workplanContainer = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectID); $xmlfile = $workplanContainer->get_inventory_filtered(array(array("+", "class", CLASS_DOCUMENT))); // load elements of the workplan for displaying options in update and create dialogs $xml = simplexml_load_string($xmlfile[0]->get_content()); $helpToArray = $xml->children(); $list = array(); for ($counter = 0; $counter < count($helpToArray); $counter++) { array_push($list, $helpToArray[$counter]); } usort($list, 'sort_xmllist'); // create update dialogs $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_DIALOG"); $content->setVariable("WORKPLAN_LIST_UPDATE_OID", $objectID); $content->setVariable("UPDATE_LABEL", "Meilenstein bearbeiten"); $content->setVariable("UPDATE_TASK_LABEL", "Vorgang bearbeiten"); $content->setVariable("UPDATE_NAME_LABEL", "Name:*"); $content->setVariable("UPDATE_DATE_LABEL", "Datum:*"); $content->setVariable("UPDATE_START_LABEL", "Beginn:*"); $content->setVariable("UPDATE_END_LABEL", "Ende:*"); $content->setVariable("UPDATE_DURATION_LABEL", "Dauer:"); $content->setVariable("UPDATE_DEPENDS_LABEL", "Abhängigkeit:"); // create all dependency options in update dialogs $content->setCurrentBlock("UPDATE_BLOCK_WORKPLAN_UPDATE_DEPENDS"); $content->setVariable("DEPENDS_OID", "-1"); $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit"); $content->parse("BLOCK_WORKPLAN_UPDATE_DEPENDS"); $content->setCurrentBlock("UPDATE_BLOCK_WORKPLAN_UPDATE_TASK_DEPENDS"); $content->setVariable("DEPENDS_OID", "-1"); $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit"); $content->parse("BLOCK_WORKPLAN_UPDATE_TASK_DEPENDS"); for ($count = 0; $count < count($list); $count++) { if ($list[$count]->getName() == 'task') { $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_DEPENDS"); $content->setVariable("DEPENDS_OID", $list[$count]->oid); $content->setVariable("DEPENDS_NAME", $list[$count]->name); $content->parse("BLOCK_WORKPLAN_UPDATE_DEPENDS"); $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_TASK_DEPENDS"); $content->setVariable("DEPENDS_OID", $list[$count]->oid); $content->setVariable("DEPENDS_NAME", $list[$count]->name); $content->parse("BLOCK_WORKPLAN_UPDATE_TASK_DEPENDS"); } } $content->setVariable("UPDATE_USERS_LABEL", "Mitarbeiter:"); $groupID = 0; if (in_array("WORKPLAN_GROUP", $workplanContainer->get_attribute_names())) { $groupID = $workplanContainer->get_attribute("WORKPLAN_GROUP"); } // create user options in update dialogs if ($groupID == 0) { $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_USER"); $content->setVariable("USER_ID", $user->get_id()); $content->setVariable("USER_NAME", $user->get_full_name()); $content->parse("BLOCK_WORKPLAN_UPDATE_USER"); $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_TASK_USER"); $content->setVariable("USER_ID", $user->get_id()); $content->setVariable("USER_NAME", $user->get_full_name()); $content->parse("BLOCK_WORKPLAN_UPDATE_TASK_USER"); } else { $groupObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $groupID); $members = $groupObject->get_members(); for ($count = 0; $count < count($members); $count++) { $currentMember = $members[$count]; $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_USER"); $content->setVariable("USER_ID", $currentMember->get_id()); $content->setVariable("USER_NAME", $currentMember->get_full_name()); $content->parse("BLOCK_WORKPLAN_UPDATE_USER"); $content->setCurrentBlock("BLOCK_WORKPLAN_UPDATE_TASK_USER"); $content->setVariable("USER_ID", $currentMember->get_id()); $content->setVariable("USER_NAME", $currentMember->get_full_name()); $content->parse("BLOCK_WORKPLAN_UPDATE_TASK_USER"); } } $content->setVariable("UPDATE_SUBMIT_LABEL", "Abschicken"); $content->setVariable("UPDATE_LABEL_BACK", "Abbrechen"); $content->setVariable("WORKPLAN_UPDATE_ID", $objectID); $content->parse("BLOCK_WORKPLAN_UPDATE_DIALOG"); // create task and milestone create forms $content->setCurrentBlock("BLOCK_WORKPLAN_LIST_FORMULAR"); $content->setVariable("LABEL_NEW_MILESTONE", "Meilenstein hinzufügen"); $content->setVariable("LABEL_NEW_TASK", "Vorgang hinzufügen"); $content->setVariable("NAME_LABEL", "Name:*"); $content->setVariable("START_LABEL", "Beginn:*"); $content->setVariable("END_LABEL", "Ende:*"); $content->setVariable("DATE_LABEL", "Datum:*"); $content->setVariable("DURATION_LABEL", "Dauer:"); $content->setVariable("DEPENDS_LABEL", "Abhängigkeit:"); $content->setVariable("USERS_LABEL", "Mitarbeiter:"); // create all dependency options in create forms $content->setCurrentBlock("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setVariable("DEPENDS_OID", "-1"); $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit"); $content->parse("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setCurrentBlock("BLOCK_LIST_TASK_DEPENDS"); $content->setVariable("DEPENDS_OID", "-1"); $content->setVariable("DEPENDS_NAME", "Keine Abhängigkeit"); $content->parse("BLOCK_LIST_TASK_DEPENDS"); for ($count = 0; $count < count($list); $count++) { if ($list[$count]->getName() == 'task') { $content->setCurrentBlock("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setVariable("DEPENDS_OID", $list[$count]->oid); $content->setVariable("DEPENDS_NAME", $list[$count]->name); $content->parse("BLOCK_LIST_MILESTONE_DEPENDS"); $content->setCurrentBlock("BLOCK_LIST_TASK_DEPENDS"); $content->setVariable("DEPENDS_OID", $list[$count]->oid); $content->setVariable("DEPENDS_NAME", $list[$count]->name); $content->parse("BLOCK_LIST_TASK_DEPENDS"); } } // create user options in create forms if ($groupID == 0) { $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_MILESTONE"); $content->setVariable("USER_ID", $user->get_id()); $content->setVariable("USER_NAME", $user->get_full_name()); $content->parse("BLOCK_USER_OPTION_MILESTONE"); $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_TASK"); if (in_array("WORKPLAN_" . $user->get_id() . "_RESSOURCE", $workplanContainer->get_attribute_names())) { $content->setVariable("USER_RESSOURCE", $workplanContainer->get_attribute("WORKPLAN_" . $user->get_id() . "_RESSOURCE")); } else { $content->setVariable("USER_RESSOURCE", 0); } $content->setVariable("USER_ID", $user->get_id()); $content->setVariable("USER_NAME", $user->get_full_name()); $content->parse("BLOCK_USER_OPTION_TASK"); } else { $groupObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $groupID); $members = $groupObject->get_members(); for ($count = 0; $count < count($members); $count++) { $currentMember = $members[$count]; $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_MILESTONE"); $content->setVariable("USER_ID", $currentMember->get_id()); $content->setVariable("USER_NAME", $currentMember->get_full_name()); $content->parse("BLOCK_USER_OPTION_MILESTONE"); $content->setCurrentBlock("BEGIN BLOCK_USER_OPTION_TASK"); if (in_array("WORKPLAN_" . $currentMember->get_id() . "_RESSOURCE", $workplanContainer->get_attribute_names())) { $content->setVariable("USER_RESSOURCE", $currentMember->get_attribute("WORKPLAN_" . $objectID . "_RESSOURCE")); } else { $content->setVariable("USER_RESSOURCE", 0); } $content->setVariable("USER_ID", $currentMember->get_id()); $content->setVariable("USER_NAME", $currentMember->get_full_name()); $content->parse("BLOCK_USER_OPTION_TASK"); } } $content->setVariable("LABEL_BACK", "Ausblenden"); $content->setVariable("LABEL_ADD", "Hinzufügen"); $content->setVariable("WORKPLAN_ID", $objectID); $content->parse("BLOCK_WORKPLAN_LIST_FORMULAR"); $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $ajaxResponseObject->setStatus("ok"); $ajaxResponseObject->addWidget($rawWidget); return $ajaxResponseObject; }
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; }
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject) { $workplanExtension = \Workplan::getInstance(); $content = $workplanExtension->loadTemplate("workplan_overview.template.html"); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $objectID = $this->params["id"]; $workplanContainer = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectID); $change = $this->params["change"]; if ($user->get_id() != $workplanContainer->get_creator()->get_id() && !in_array("WORKPLAN_" . $user->get_id() . "_LEADER", $workplanContainer->get_attribute_names())) { $change = 0; } // if edit form got submitted save new data if ($change == 2) { $workplanContainer->set_name($this->params["name"]); $start = $this->params["start"]; $start = mktime(0, 0, 0, substr($start, 3, 2), substr($start, 0, 2), substr($start, 6, 4)); $workplanContainer->set_attribute("WORKPLAN_START", $start); $end = $this->params["end"]; if (strlen($end) > 0) { $end = mktime(0, 0, 0, substr($end, 3, 2), substr($end, 0, 2), substr($end, 6, 4)); } else { $end = -1; } $workplanContainer->set_attribute("WORKPLAN_END", $end); $workplanContainer->set_attribute("WORKPLAN_DESCRIPTION", $this->params["description"]); $xmlfile = $workplanContainer->get_inventory_filtered(array(array("+", "class", CLASS_DOCUMENT))); $xmltree = new \SimpleXMLElement($xmlfile[0]->get_content()); $xmltree["name"] = $this->params["name"]; $xmltree["start"] = $start; $xmltree["end"] = $end; $xmltree["description"] = $this->params["description"]; $xmlfile[0]->set_content($xmltree->saveXML()); // if edit button was clicked display edit view } else { if ($change == 1) { $content->setCurrentBlock("BLOCK_WORKPLAN_OVERVIEW_TABLE_EDIT"); $content->setVariable("WORKPLAN_OVERVIEW_EDIT", "Eigenschaften bearbeiten"); $content->setVariable("NAME_LABEL", "Projektname:*"); $content->setVariable("START_LABEL", "Beginn:*"); $content->setVariable("END_LABEL", "Ende:"); $content->setVariable("CREATOR_LABEL", "Projektersteller:"); $content->setVariable("DESCRIPTION_LABEL", "Beschreibung:"); $content->setVariable("NAME_VALUE", $workplanContainer->get_name()); $content->setVariable("START_VALUE", date("d.m.Y", (int) $workplanContainer->get_attribute("WORKPLAN_START"))); $content->setVariable("CREATOR_VALUE", $workplanContainer->get_creator()->get_full_name()); if ($workplanContainer->get_attribute("WORKPLAN_END") != -1) { $content->setVariable("END_VALUE", date("d.m.Y", (int) $workplanContainer->get_attribute("WORKPLAN_END"))); } if (in_array("WORKPLAN_DESCRIPTION", $workplanContainer->get_attribute_names())) { $content->setVariable("DESCRIPTION_VALUE", $workplanContainer->get_attribute("WORKPLAN_DESCRIPTION")); } $content->setVariable("LABEL_SAVE", "Speichern"); $content->setVariable("LABEL_BACK", "Abbrechen"); $content->setVariable("WORKPLAN_ID", $objectID); $content->parse("BLOCK_WORKPLAN_OVERVIEW_TABLE_EDIT"); } } // if edit got cancelled or changes were saved display normal view if ($change != 1) { $content->setCurrentBlock("BLOCK_WORKPLAN_OVERVIEW_TABLE"); $content->setVariable("WORKPLAN_OVERVIEW_ATTRIBUTE", "Eigenschaft"); $content->setVariable("WORKPLAN_OVERVIEW_VALUE", "Wert"); $content->setVariable("NAME_LABEL", "Projektname"); $content->setVariable("START_LABEL", "Beginn"); $content->setVariable("END_LABEL", "Ende"); $content->setVariable("CREATOR_LABEL", "Projektersteller"); $content->setVariable("DESCRIPTION_LABEL", "Beschreibung"); $content->setVariable("NAME_VALUE", $workplanContainer->get_name()); $content->setVariable("START_VALUE", date("d.m.Y", (int) $workplanContainer->get_attribute("WORKPLAN_START"))); $content->setVariable("CREATOR_VALUE", $workplanContainer->get_creator()->get_full_name()); if ($workplanContainer->get_attribute("WORKPLAN_END") != -1) { $content->setVariable("END_VALUE", date("d.m.Y", (int) $workplanContainer->get_attribute("WORKPLAN_END"))); } else { $content->setVariable("END_VALUE", "-"); } if (in_array("WORKPLAN_DESCRIPTION", $workplanContainer->get_attribute_names())) { if (strlen(trim($workplanContainer->get_attribute("WORKPLAN_DESCRIPTION"))) > 0) { $content->setVariable("DESCRIPTION_VALUE", nl2br($workplanContainer->get_attribute("WORKPLAN_DESCRIPTION"))); } else { $content->setVariable("DESCRIPTION_VALUE", "-"); } } else { $content->setVariable("DESCRIPTION_VALUE", "-"); } $content->parse("BLOCK_WORKPLAN_OVERVIEW_TABLE"); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $ajaxResponseObject->setStatus("ok"); $ajaxResponseObject->addWidget($rawWidget); return $ajaxResponseObject; }
private function displayWorkplans() { $workplanExtension = \Workplan::getInstance(); $workplanExtension->addJS(); $content = $workplanExtension->loadTemplate("workplan_index.template.html"); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $workplans_private = array(); $workplans_group = array(); // get all workplans from the private workroom of the current user $inventory = $user->get_workroom()->get_inventory(); for ($count = 0; $count < count($inventory); $count++) { $object = $inventory[$count]; if (in_array("OBJ_TYPE", $object->get_attribute_names()) && $object->get_attribute("OBJ_TYPE") == "WORKPLAN_CONTAINER") { array_push($workplans_private, $object); } } usort($workplans_private, 'sort_workplans'); // search for workplans in workrooms of all groups the current user is member in $groups = $user->get_groups(); for ($count = 0; $count < count($groups); $count++) { $groupWorkroom = $groups[$count]->get_workroom(); $inventory = $groupWorkroom->get_inventory(); for ($count2 = 0; $count2 < count($inventory); $count2++) { $object = $inventory[$count2]; if (in_array("OBJ_TYPE", $object->get_attribute_names()) && $object->get_attribute("OBJ_TYPE") == "WORKPLAN_CONTAINER") { array_push($workplans_group, $object); } } } usort($workplans_group, 'sort_workplans'); $content->setCurrentBlock("BLOCK_CONFIRMATION"); $content->setVariable("CONFIRMATION_TEXT", "NONE"); $content->parse("BLOCK_CONFIRMATION"); $content->setCurrentBlock("BLOCK_WORKPLAN_ADMINISTRATION_ACTIONBAR"); $content->setVariable("WORKPLAN_PATH_URL", $this->getExtension()->getExtensionUrl()); $content->setVariable("LABEL_CREATE_PROJECT", "Neuer Projektplan"); $content->parse("BLOCK_WORKPLAN_ADMINISTRATION_ACTIONBAR"); // display private workplan table if (count($workplans_private) != 0) { $content->setCurrentBlock("BLOCK_WORKPLAN_ADMINISTRATION"); $content->setVariable("WORKPLAN_ADMINISTRATION_ID", "Nummer"); $content->setVariable("WORKPLAN_ADMINISTRATION_NAME", "Name"); $content->setVariable("WORKPLAN_PROJECTS_KIND", "Private Projektpläne"); for ($count = 0; $count < count($workplans_private); $count++) { $content->setCurrentBlock("BLOCK_WORKPLAN_ADMINISTRATION_ELEMENT"); $content->setVariable("WORKPLAN_PATH_URL", $this->getExtension()->getExtensionUrl()); $content->setVariable("WORKPLAN_ADMINISTRATION_ELEMENT_ID", $workplans_private[$count]->get_id()); $content->setVariable("WORKPLAN_ADMINISTRATION_ELEMENT_NAME", $workplans_private[$count]->get_name()); $content->setVariable("WORKPLAN_ADMINISTRATION_CHANGE_VALUE", "Bearbeiten"); $content->setVariable("WORKPLAN_ADMINISTRATION_DELETE_VALUE", "Löschen"); $content->parse("BLOCK_WORKPLAN_ADMINISTRATION_ELEMENT"); } $content->parse("BLOCK_WORKPLAN_ADMINISTRATION"); } else { $content->setCurrentBlock("BLOCK_WORKPLAN_ADMINISTRATION_NO_PROJECTS_PRIVATE"); $content->setVariable("WORKPLAN_PROJECTS_KIND", "Private Projektpläne"); $content->setVariable("WORKPLAN_ADMINISTRATION_NO_PROJECT", "Keine privaten Projektpläne vorhanden."); $content->parse("BLOCK_WORKPLAN_ADMINISTRATION_NO_PROJECTS_PRIVATE"); } // display group workplan table if (count($workplans_group) != 0) { $content->setCurrentBlock("BLOCK_WORKPLAN_ADMINISTRATION"); $content->setVariable("WORKPLAN_PATH_URL", $this->getExtension()->getExtensionUrl()); $content->setVariable("WORKPLAN_ADMINISTRATION_ID", "Nummer"); $content->setVariable("WORKPLAN_ADMINISTRATION_NAME", "Name"); $content->setVariable("WORKPLAN_PROJECTS_KIND", "Gruppen Projektpläne"); for ($count = 0; $count < count($workplans_group); $count++) { $content->setCurrentBlock("BLOCK_WORKPLAN_ADMINISTRATION_ELEMENT"); $content->setVariable("WORKPLAN_PATH_URL", $this->getExtension()->getExtensionUrl()); $content->setVariable("WORKPLAN_ADMINISTRATION_ELEMENT_ID", $workplans_group[$count]->get_id()); $content->setVariable("WORKPLAN_ADMINISTRATION_ELEMENT_NAME", $workplans_group[$count]->get_name()); $content->setVariable("WORKPLAN_ADMINISTRATION_CHANGE_VALUE", "Bearbeiten"); $content->setVariable("WORKPLAN_ADMINISTRATION_DELETE_VALUE", "Löschen"); if ($workplans_group[$count]->get_creator()->get_id() == $user->get_id()) { $content->setVariable("WORKPLAN_ADMINISTRATION_ELEMENT_RIGHTS", ""); } else { $content->setVariable("WORKPLAN_ADMINISTRATION_ELEMENT_RIGHTS", "none"); } $content->parse("BLOCK_WORKPLAN_ADMINISTRATION_ELEMENT"); } $content->parse("BLOCK_WORKPLAN_ADMINISTRATION"); } else { $content->setCurrentBlock("BLOCK_WORKPLAN_ADMINISTRATION_NO_PROJECTS_GROUP"); $content->setVariable("WORKPLAN_PROJECTS_KIND", "Gruppen Projektpläne"); $content->setVariable("WORKPLAN_ADMINISTRATION_NO_PROJECT", "Keine Gruppen Projektpläne vorhanden."); $content->parse("BLOCK_WORKPLAN_ADMINISTRATION_NO_PROJECTS_GROUP"); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); return $rawWidget; }