/**
  * Handle Request
  * @return 
  */
 public function handleRequest()
 {
     $this->initIlias();
     $this->initTokenHandler();
     if ($this->getTokenHandler()->getIcal() and !$this->getTokenHandler()->isIcalExpired()) {
         ilUtil::deliverData($this->getTokenHandler(), 'calendar.ics', 'text/calendar', 'utf-8');
     }
     include_once './Services/Calendar/classes/Export/class.ilCalendarExport.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
     if ($this->getTokenHandler()->getSelectionType() == ilCalendarAuthenticationToken::SELECTION_CALENDAR) {
         $export = new ilCalendarExport(array($this->getTokenHandler()->getCalendar()));
     } else {
         $cats = ilCalendarCategories::_getInstance();
         $cats->initialize(ilCalendarCategories::MODE_REMOTE_ACCESS);
         $export = new ilCalendarExport($cats->getCategories(true));
     }
     $export->export();
     $this->getTokenHandler()->setIcal($export->getExportString());
     $this->getTokenHandler()->storeIcal();
     ilUtil::deliverData($export->getExportString(), 'calendar.ics', 'text/calendar', 'utf-8');
     #echo $export->getExportString();
     #echo nl2br($export->getExportString());
     #$fp = fopen('ilias.ics', 'w');
     #fwrite($fp,$export->getExportString());
     $GLOBALS['ilAuth']->logout();
     exit;
 }
 /**
  * Called when the a log should be exported
  */
 public function exportLogObject()
 {
     $from = mktime($_POST['log_from']['time']['h'], $_POST['log_from']['time']['m'], 0, $_POST['log_from']['date']['m'], $_POST['log_from']['date']['d'], $_POST['log_from']['date']['y']);
     $until = mktime($_POST['log_until']['time']['h'], $_POST['log_until']['time']['m'], 0, $_POST['log_until']['date']['m'], $_POST['log_until']['date']['d'], $_POST['log_until']['date']['y']);
     $test = $_POST['sel_test'];
     $csv = array();
     $separator = ";";
     $row = array($this->lng->txt("assessment_log_datetime"), $this->lng->txt("user"), $this->lng->txt("assessment_log_text"), $this->lng->txt("question"));
     include_once "./Modules/Test/classes/class.ilObjTest.php";
     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
     $available_tests =& ilObjTest::_getAvailableTests(1);
     array_push($csv, ilUtil::processCSVRow($row, TRUE, $separator));
     $log_output =& $this->object->getLog($from, $until, $test);
     $users = array();
     foreach ($log_output as $key => $log) {
         if (!array_key_exists($log["user_fi"], $users)) {
             $users[$log["user_fi"]] = ilObjUser::_lookupName($log["user_fi"]);
         }
         $title = "";
         if ($log["question_fi"] || $log["original_fi"]) {
             $title = assQuestion::_getQuestionTitle($log["question_fi"]);
             if (strlen($title) == 0) {
                 $title = assQuestion::_getQuestionTitle($log["original_fi"]);
             }
             $title = $this->lng->txt("assessment_log_question") . ": " . $title;
         }
         $csvrow = array();
         $date = new ilDateTime($log['tstamp'], IL_CAL_UNIX);
         array_push($csvrow, $date->get(IL_CAL_FKT_DATE, 'Y-m-d H:i'));
         array_push($csvrow, trim($users[$log["user_fi"]]["title"] . " " . $users[$log["user_fi"]]["firstname"] . " " . $users[$log["user_fi"]]["lastname"]));
         array_push($csvrow, trim($log["logtext"]));
         array_push($csvrow, $title);
         array_push($csv, ilUtil::processCSVRow($csvrow, TRUE, $separator));
     }
     $csvoutput = "";
     foreach ($csv as $row) {
         $csvoutput .= join($row, $separator) . "\n";
     }
     ilUtil::deliverData($csvoutput, str_replace(" ", "_", "log_" . $from . "_" . $until . "_" . $available_tests[$test]) . ".csv");
 }
 /**
  * Events List CSV Export
  *
  * @access public
  * @param
  * 
  */
 public function exportCSV()
 {
     global $tree, $ilAccess;
     include_once 'Services/Utilities/classes/class.ilCSVWriter.php';
     include_once 'Modules/Session/classes/class.ilEventParticipants.php';
     $members = $this->members_obj->getParticipants();
     $members = ilUtil::_sortIds($members, 'usr_data', 'lastname', 'usr_id');
     $events = array();
     foreach ($tree->getSubtree($tree->getNodeData($this->course_ref_id), false, 'sess') as $event_id) {
         $tmp_event = ilObjectFactory::getInstanceByRefId($event_id, false);
         if (!is_object($tmp_event) or !$ilAccess->checkAccess('write', '', $event_id)) {
             continue;
         }
         $events[] = $tmp_event;
     }
     $this->csv = new ilCSVWriter();
     $this->csv->addColumn($this->lng->txt("lastname"));
     $this->csv->addColumn($this->lng->txt("firstname"));
     $this->csv->addColumn($this->lng->txt("login"));
     foreach ($events as $event_obj) {
         // TODO: do not export relative dates
         $this->csv->addColumn($event_obj->getTitle() . ' (' . $event_obj->getFirstAppointment()->appointmentToString() . ')');
     }
     $this->csv->addRow();
     foreach ($members as $user_id) {
         $name = ilObjUser::_lookupName($user_id);
         $this->csv->addColumn($name['lastname']);
         $this->csv->addColumn($name['firstname']);
         $this->csv->addColumn(ilObjUser::_lookupLogin($user_id));
         foreach ($events as $event_obj) {
             $event_part = new ilEventParticipants((int) $event_obj->getId());
             $this->csv->addColumn($event_part->hasParticipated($user_id) ? $this->lng->txt('event_participated') : $this->lng->txt('event_not_participated'));
         }
         $this->csv->addRow();
     }
     $date = new ilDate(time(), IL_CAL_UNIX);
     ilUtil::deliverData($this->csv->getCSVString(), $date->get(IL_CAL_FKT_DATE, 'Y-m-d') . "_course_events.csv", "text/csv");
 }
 /**
  * 
  */
 public function exportHTML()
 {
     /**
      * @var $tpl      ilTemplate
      * @var $lng      ilLanguage
      * @var $ilAccess ilAccessHandler
      * @var $ilias    ILIAS
      */
     global $lng, $tpl, $ilAccess, $ilias;
     if (!$ilAccess->checkAccess('read,visible', '', $_GET['ref_id'])) {
         $ilias->raiseError($lng->txt('permission_denied'), $ilias->error_obj->MESSAGE);
     }
     ilDatePresentation::setUseRelativeDates(false);
     $tpl = new ilTemplate('tpl.forums_export_html.html', true, true, 'Modules/Forum');
     $location_stylesheet = ilUtil::getStyleSheetLocation();
     $tpl->setVariable('LOCATION_STYLESHEET', $location_stylesheet);
     $tpl->setVariable('BASE', substr(ILIAS_HTTP_PATH, -1) == '/' ? ILIAS_HTTP_PATH : ILIAS_HTTP_PATH . '/');
     $num_threads = count((array) $_POST['thread_ids']);
     for ($j = 0; $j < $num_threads; $j++) {
         $topic = new ilForumTopic((int) $_POST['thread_ids'][$j], $this->is_moderator);
         $this->frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topic->getForumId()));
         if (is_array($thread_data = $this->frm->getOneTopic())) {
             if (0 == $j) {
                 $tpl->setVariable('TITLE', $thread_data['top_name']);
             }
             $first_post = $topic->getFirstPostNode();
             $topic->setOrderField('frm_posts_tree.rgt');
             $post_collection = $topic->getPostTree($first_post);
             $z = 0;
             foreach ($post_collection as $post) {
                 $this->renderPostHtml($tpl, $post, $z++, self::MODE_EXPORT_CLIENT);
             }
             $tpl->setCurrentBlock('thread_headline');
             $tpl->setVariable('T_TITLE', $topic->getSubject());
             if ($this->is_moderator) {
                 $tpl->setVariable('T_NUM_POSTS', $topic->countPosts());
             } else {
                 $tpl->setVariable('T_NUM_POSTS', $topic->countActivePosts());
             }
             $tpl->setVariable('T_NUM_VISITS', $topic->getVisits());
             $tpl->setVariable('T_FORUM', $thread_data['top_name']);
             $authorinfo = new ilForumAuthorInformation($topic->getThrAuthorId(), $topic->getDisplayUserId(), $topic->getUserAlias(), $topic->getImportName());
             $tpl->setVariable('T_AUTHOR', $authorinfo->getAuthorName());
             $tpl->setVariable('T_TXT_FORUM', $lng->txt('forum') . ': ');
             $tpl->setVariable('T_TXT_TOPIC', $lng->txt('forums_thread') . ': ');
             $tpl->setVariable('T_TXT_AUTHOR', $lng->txt('forums_thread_create_from') . ': ');
             $tpl->setVariable('T_TXT_NUM_POSTS', $lng->txt('forums_articles') . ': ');
             $tpl->setVariable('T_TXT_NUM_VISITS', $lng->txt('visits') . ': ');
             $tpl->parseCurrentBlock();
         }
         $tpl->setCurrentBlock('thread_block');
         $tpl->parseCurrentBlock();
     }
     ilUtil::deliverData($tpl->get('DEFAULT', false, false, false, true, false, false), 'forum_html_export_' . $_GET['ref_id'] . '.html');
 }
Example #5
0
 function send_paragraph($par_id, $filename)
 {
     $this->builddom();
     $mydom = $this->dom;
     $xpc = xpath_new_context($mydom);
     //$path = "//PageContent[position () = $par_id]/Paragraph";
     //$path = "//Paragraph[$par_id]";
     $path = "/descendant::Paragraph[position() = {$par_id}]";
     $res =& xpath_eval($xpc, $path);
     if (count($res->nodeset) != 1) {
         die("Should not happen");
     }
     $context_node = $res->nodeset[0];
     // get plain text
     $childs = $context_node->child_nodes();
     for ($j = 0; $j < count($childs); $j++) {
         $content .= $mydom->dump_node($childs[$j]);
     }
     $content = str_replace("<br />", "\n", $content);
     $content = str_replace("<br/>", "\n", $content);
     $plain_content = html_entity_decode($content);
     ilUtil::deliverData($plain_content, $filename);
     /*
     		$file_type = "application/octet-stream";
     		header("Content-type: ".$file_type);
     		header("Content-disposition: attachment; filename=\"$filename\"");
     		echo $plain_content;*/
     exit;
 }
Example #6
0
 /**
  * Delivers a PDF file from a XSL-FO string
  *
  * @param string $fo The XSL-FO string
  * @access public
  */
 public function deliverPDFfromFO($fo, $title = null)
 {
     global $ilLog;
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     $fo_file = ilUtil::ilTempnam() . ".fo";
     $fp = fopen($fo_file, "w");
     fwrite($fp, $fo);
     fclose($fp);
     include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
     try {
         $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($fo);
         $filename = strlen($title) ? $title : $this->getTitle();
         ilUtil::deliverData($pdf_base64->scalar, ilUtil::getASCIIFilename($filename) . ".pdf", "application/pdf", false, true);
         return true;
     } catch (XML_RPC2_FaultException $e) {
         $ilLog->write(__METHOD__ . ': ' . $e->getMessage());
         return false;
     } catch (Exception $e) {
         $ilLog->write(__METHOD__ . ': ' . $e->getMessage());
         return false;
     }
     /*
     include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
     $fo2pdf = new ilFO2PDF();
     $fo2pdf->setFOString($fo);
     $result = $fo2pdf->send();
     $filename = (strlen($title)) ? $title : $this->getTitle();
     ilUtil::deliverData($result, ilUtil::getASCIIFilename($filename) . ".pdf", "application/pdf", false, true);
     */
 }
 /**
  * export released
  *
  * @access protected
  * @return
  */
 protected function exportReleased()
 {
     global $ilObjDataCache;
     include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
     $exported = ilECSExport::getExportedIds();
     $ilObjDataCache->preloadObjectCache($exported);
     include_once 'Services/Utilities/classes/class.ilCSVWriter.php';
     $writer = new ilCSVWriter();
     $writer->addColumn($this->lng->txt('title'));
     $writer->addColumn($this->lng->txt('description'));
     $writer->addColumn($this->lng->txt('ecs_field_courseID'));
     $writer->addColumn($this->lng->txt('ecs_field_term'));
     $writer->addColumn($this->lng->txt('ecs_field_lecturer'));
     $writer->addColumn($this->lng->txt('ecs_field_courseType'));
     $writer->addColumn($this->lng->txt('ecs_field_semester_hours'));
     $writer->addColumn($this->lng->txt('ecs_field_credits'));
     $writer->addColumn($this->lng->txt('ecs_field_room'));
     $writer->addColumn($this->lng->txt('ecs_field_cycle'));
     $writer->addColumn($this->lng->txt('ecs_field_begin'));
     $writer->addColumn($this->lng->txt('ecs_field_end'));
     $writer->addColumn($this->lng->txt('last_update'));
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     $settings = ilECSDataMappingSettings::_getInstance();
     foreach ($exported as $obj_id) {
         include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
         $values = ilAdvancedMDValues::_getValuesByObjId($obj_id);
         $writer->addRow();
         $writer->addColumn(ilObject::_lookupTitle($obj_id));
         $writer->addColumn(ilObject::_lookupDescription($obj_id));
         $field = $settings->getMappingByECSName('courseID');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('term');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('lecturer');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('courseType');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('semester_hours');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('credits');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('room');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('cycle');
         $writer->addColumn(isset($values[$field]) ? $values[$field] : '');
         $field = $settings->getMappingByECSName('begin');
         $writer->addColumn(isset($values[$field]) ? ilFormat::formatUnixTime($values[$field], true) : '');
         $field = $settings->getMappingByECSName('end');
         $writer->addColumn(isset($values[$field]) ? ilFormat::formatUnixTime($values[$field], true) : '');
         $writer->addColumn($ilObjDataCache->lookupLastUpdate($obj_id));
     }
     ilUtil::deliverData($writer->getCSVString(), date("Y_m_d") . "_ecs_export.csv", "text/csv");
 }
 /**
  * Create and offer server ini file for download
  * @return 
  */
 protected function downloadJavaServerIniObject()
 {
     $this->initJavaServerIniForm();
     if ($this->form->checkInput()) {
         include_once './Services/WebServices/RPC/classes/class.ilRpcIniFileWriter.php';
         $ini = new ilRpcIniFileWriter();
         $ini->setHost($this->form->getInput('ho'));
         $ini->setPort($this->form->getInput('po'));
         $ini->setIndexPath($this->form->getInput('in'));
         $ini->setLogPath($this->form->getInput('lo'));
         $ini->setLogLevel($this->form->getInput('le'));
         $ini->setNumThreads($this->form->getInput('cp'));
         $ini->setMaxFileSize($this->form->getInput('fs'));
         $ini->write();
         ilUtil::deliverData($ini->getIniString(), 'ilServer.ini', 'text/plain', 'utf-8');
         return true;
     }
     $this->form->setValuesByPost();
     ilUtil::sendFailure($this->lng->txt('err_check_input'));
     $this->setGeneralSettingsSubTabs('java_server');
     $this->tpl->setContent($this->form->getHTML());
     return true;
 }
 /**
  * Creates a PDF preview of the XSL-FO certificate
  */
 public function createPreview()
 {
     global $ilLog;
     ilDatePresentation::setUseRelativeDates(false);
     $xslfo = file_get_contents($this->getXSLPath());
     include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
     try {
         $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($this->exchangeCertificateVariables($xslfo));
         ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(), "application/pdf");
     } catch (XML_RPC2_FaultException $e) {
         $ilLog->write(__METHOD__ . ': ' . $e->getMessage());
         return false;
     } catch (Exception $e) {
         $ilLog->write(__METHOD__ . ': ' . $e->getMessage());
         return false;
     }
     ilDatePresentation::setUseRelativeDates(true);
     /*
     include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
     $fo2pdf = new ilFO2PDF();
     $fo2pdf->setFOString($this->exchangeCertificateVariables($xslfo));
     $result = $fo2pdf->send();
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     ilUtil::deliverData($result, $this->getAdapter()->getCertificateFilename(), "application/pdf");
     */
 }
Example #10
0
 /**
  * export selected notes to html
  */
 function exportNotesHTML()
 {
     $tpl = new ilTemplate("tpl.main.html", true, true);
     $this->export_html = true;
     $this->multi_selection = false;
     $tpl->setVariable("CONTENT", $this->getNotesHTML());
     ilUtil::deliverData($tpl->get(), "notes.html");
 }
 function exportCodes()
 {
     global $ilAccess, $ilErr, $lng;
     if (!$ilAccess->checkAccess('read', '', $this->ref_id)) {
         $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
     }
     include_once "./Services/User/classes/class.ilAccountCodesTableGUI.php";
     $utab = new ilAccountCodesTableGUI($this, "listCodes");
     include_once './Services/User/classes/class.ilAccountCode.php';
     $codes = ilAccountCode::getCodesForExport($utab->filter["code"], $utab->filter["valid_until"], $utab->filter["generated"]);
     if (sizeof($codes)) {
         // #13497
         ilUtil::deliverData(implode("\r\n", $codes), "ilias_account_codes_" . date("d-m-Y") . ".txt", "text/plain");
     } else {
         ilUtil::sendFailure($lng->txt("account_export_codes_no_data"));
         $this->listCodes();
     }
 }
 /**
  * export bookmarks
  */
 function export($deliver = true)
 {
     $bm_ids = $_GET['bm_id'] ? array($_GET['bm_id']) : $_POST['bm_id'];
     if (!$bm_ids) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     $export_ids = array();
     foreach ($bm_ids as $id) {
         if ($this->tree->isInTree($id)) {
             //list($type, $obj_id) = explode(":", $id);
             //$export_ids[]=$obj_id;
             $export_ids[] = $id;
         }
     }
     require_once "./Services/Bookmarks/classes/class.ilBookmarkImportExport.php";
     $html_content = ilBookmarkImportExport::_exportBookmark($export_ids, true, $this->lng->txt("bookmarks_of") . " " . $this->ilias->account->getFullname());
     if ($deliver) {
         ilUtil::deliverData($html_content, 'bookmarks.html', "application/save", $charset = "");
     } else {
         return $html_content;
     }
 }
 public function exportCodes()
 {
     $codes = $this->coupon_obj->getCodesByCouponId($_GET["coupon_id"]);
     if (is_array($codes)) {
         include_once './Services/Utilities/classes/class.ilCSVWriter.php';
         $csv = new ilCSVWriter();
         $csv->setDelimiter("");
         foreach ($codes as $data) {
             if ($data["pcc_code"]) {
                 $csv->addColumn($data["pcc_code"]);
                 $csv->addRow();
             }
         }
         ilUtil::deliverData($csv->getCSVString(), "code_export_" . date("Ymdhis") . ".csv");
     }
     $this->showCodes();
     return true;
 }
 /**
  * Export to HTML.
  *
  */
 function exportHTML()
 {
     global $lng, $tpl, $ilUser, $ilAccess, $ilias;
     if (!$ilAccess->checkAccess('read,visible', '', $_GET['ref_id'])) {
         $ilias->raiseError($lng->txt('permission_denied'), $ilias->error_obj->MESSAGE);
     }
     $tplEx = new ilTemplate('tpl.forums_export_html.html', true, true, 'Modules/Forum');
     // threads
     //for ($j = 0; $j < count($_POST['forum_id']); $j++)
     for ($j = 0; $j < count($_POST['thread_ids']); $j++) {
         //$objCurrentTopic = new ilForumTopic(addslashes($_POST['forum_id'][$j]), $ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id']));
         $objCurrentTopic = new ilForumTopic(addslashes($_POST['thread_ids'][$j]), $ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id']));
         // get forum- and thread-data
         $this->frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($objCurrentTopic->getForumId()));
         if (is_array($frmData = $this->frm->getOneTopic())) {
             $objFirstPostNode = $objCurrentTopic->getFirstPostNode();
             $objCurrentTopic->setOrderField('frm_posts_tree.rgt');
             $postTree = $objCurrentTopic->getPostTree($objFirstPostNode);
             $posNum = count($postTree);
             $z = 0;
             foreach ($postTree as $post) {
                 $tplEx->setCurrentBlock('posts_row');
                 $rowCol = ilUtil::switchColor($z++, 'tblrow2', 'tblrow1');
                 $tplEx->setVariable('ROWCOL', $rowCol);
                 $authorinfo = new ilForumAuthorInformation($post->getUserId(), $post->getUserAlias(), $post->getImportName());
                 $tplEx->setVariable('AUTHOR', $authorinfo->getAuthorName());
                 if ($post->getUserId()) {
                     // get create- and update-dates
                     if ($post->getUpdateUserId()) {
                         $authorinfo = new ilForumAuthorInformation($post->getUpdateUserId(), '', '');
                         $tplEx->setVariable('POST_UPDATE', "<br />[" . $lng->txt('edited_on') . ": " . $this->frm->convertDate($post->getChangeDate()) . " - " . strtolower($lng->txt('from')) . " " . $authorinfo->getAuthorName() . "]");
                     }
                     if ($authorinfo->getAuthor()->getPref('public_profile') != 'n') {
                         $tplEx->setVariable('TXT_REGISTERED', $lng->txt('registered_since'));
                         $tplEx->setVariable('REGISTERED_SINCE', $this->frm->convertDate($authorinfo->getAuthor()->getCreateDate()));
                     }
                     if ($ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id'])) {
                         $numPosts = $this->frm->countUserArticles($post->getUserId());
                     } else {
                         $numPosts = $this->frm->countActiveUserArticles($post->getUserId());
                     }
                     $tplEx->setVariable('TXT_NUM_POSTS', $lng->txt('forums_posts'));
                     $tplEx->setVariable('NUM_POSTS', $numPosts);
                 }
                 $tplEx->setVariable('SUBJECT', $post->getSubject());
                 $tplEx->setVariable('TXT_CREATE_DATE', $lng->txt('forums_thread_create_date'));
                 $tplEx->setVariable('POST_DATE', $this->frm->convertDate($post->getCreateDate()));
                 $tplEx->setVariable('SPACER', "<hr noshade width=\"100%\" size=\"1\" align=\"center\" />");
                 if ($post->isCensored()) {
                     $tplEx->setVariable('POST', nl2br(stripslashes($post->getCensorshipComment())));
                 } else {
                     /** @todo mjansen: possible bugfix for mantis #8223 */
                     if ($post->getMessage() == strip_tags($post->getMessage())) {
                         // We can be sure, that there are not html tags
                         $post->setMessage(nl2br($post->getMessage()));
                     }
                     $tplEx->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($this->frm->prepareText($post->getMessage(), 0, '', 'export'), 1));
                 }
                 $tplEx->parseCurrentBlock('posts_row');
                 unset($author);
             }
             // foreach ($postTree as $post)
             $tplEx->setCurrentBlock('posttable');
             $tplEx->setVariable('TXT_AUTHOR', $lng->txt('author'));
             $tplEx->setVariable('TXT_POST', $lng->txt('forums_thread') . ': ' . $objCurrentTopic->getSubject());
             $tplEx->parseCurrentBlock('posttable');
             // Thread Headline
             $tplEx->setCurrentBlock('thread_headline');
             $tplEx->setVariable('T_TITLE', $objCurrentTopic->getSubject());
             if ($ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id'])) {
                 $tplEx->setVariable('T_NUM_POSTS', $objCurrentTopic->countPosts());
             } else {
                 $tplEx->setVariable('T_NUM_POSTS', $objCurrentTopic->countActivePosts());
             }
             $tplEx->setVariable('T_NUM_VISITS', $objCurrentTopic->getVisits());
             $tplEx->setVariable('T_FORUM', $frmData['top_name']);
             $authorinfo = new ilForumAuthorInformation($objCurrentTopic->getUserId(), $objCurrentTopic->getUserAlias(), $objCurrentTopic->getImportName());
             $tplEx->setVariable('T_AUTHOR', $authorinfo->getAuthorName());
             $tplEx->setVariable('T_TXT_FORUM', $lng->txt('forum') . ': ');
             $tplEx->setVariable('T_TXT_TOPIC', $lng->txt('forums_thread') . ': ');
             $tplEx->setVariable('T_TXT_AUTHOR', $lng->txt('forums_thread_create_from') . ': ');
             $tplEx->setVariable('T_TXT_NUM_POSTS', $lng->txt('forums_articles') . ': ');
             $tplEx->setVariable('T_TXT_NUM_VISITS', $lng->txt('visits') . ': ');
             $tplEx->parseCurrentBlock('thread_headline');
             $tplEx->setCurrentBlock('thread_block');
             $tplEx->parseCurrentBlock('thread_block');
             $tplEx->setCurrentBlock('forum_block');
             $tplEx->parseCurrentBlock('forum_block');
         }
         // if (is_array($frmData = $this->frm->getOneTopic()))
     }
     // for ($j = 0; $j < count($_POST["forum_id"]); $j++)
     ilUtil::deliverData($tplEx->get(), 'forum_html_export_' . $_GET['ref_id'] . '.html');
     exit;
 }
 /**
  * Command: Download an xml file (accounts or booking)
  *
  * The file type is given in $_GET['xmltype']
  * The part ID is given in    $_GET['part_id']
  */
 protected function downloadXml()
 {
     switch ($_GET['xmltype']) {
         case 'accounts':
             $file = $this->object->getAccountsXML();
             $filename = 'accounts' . $this->object->getId() . '.xml';
             break;
         case 'booking':
             $part_obj = $this->object->getPart($_GET['part_id']);
             $file = $part_obj->getBookingXML();
             $filename = 'booking' . $part_obj->getPartId() . '.xml';
             break;
         default:
             $this->editQuestion();
             return;
     }
     ilUtil::deliverData($file, $filename, 'text/xml', false);
 }
 /**
  * Deliver vcard information.
  */
 function deliverVCard()
 {
     // get user object
     if (!ilObject::_exists($this->getUserId())) {
         return "";
     }
     $user = new ilObjUser($this->getUserId());
     require_once "./Services/User/classes/class.ilvCard.php";
     $vcard = new ilvCard();
     // ilsharedresourceGUI: embedded in shared portfolio
     if ($user->getPref("public_profile") != "y" && $user->getPref("public_profile") != "g" && $_GET["baseClass"] != "ilsharedresourceGUI") {
         return;
     }
     $vcard->setName($user->getLastName(), $user->getFirstName(), "", $user->getUTitle());
     $vcard->setNickname($user->getLogin());
     $webspace_dir = ilUtil::getWebspaceDir("output");
     $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image");
     if ($user->getPref("public_upload") == "y" && @is_file($imagefile)) {
         $fh = fopen($imagefile, "r");
         if ($fh) {
             $image = fread($fh, filesize($imagefile));
             fclose($fh);
             require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
             $mimetype = ilObjMediaObject::getMimeType($imagefile);
             if (preg_match("/^image/", $mimetype)) {
                 $type = $mimetype;
             }
             $vcard->setPhoto($image, $type);
         }
     }
     $val_arr = array("getInstitution" => "institution", "getDepartment" => "department", "getStreet" => "street", "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country", "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home", "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email", "getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip");
     $org = array();
     $adr = array();
     foreach ($val_arr as $key => $value) {
         // if value "y" show information
         if ($user->getPref("public_" . $value) == "y") {
             switch ($value) {
                 case "institution":
                     $org[0] = $user->{$key}();
                     break;
                 case "department":
                     $org[1] = $user->{$key}();
                     break;
                 case "street":
                     $adr[2] = $user->{$key}();
                     break;
                 case "zipcode":
                     $adr[5] = $user->{$key}();
                     break;
                 case "city":
                     $adr[3] = $user->{$key}();
                     break;
                 case "country":
                     $adr[6] = $user->{$key}();
                     break;
                 case "phone_office":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_WORK);
                     break;
                 case "phone_home":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_HOME);
                     break;
                 case "phone_mobile":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_CELL);
                     break;
                 case "fax":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_FAX);
                     break;
                 case "email":
                     $vcard->setEmail($user->{$key}());
                     break;
                 case "hobby":
                     $vcard->setNote($user->{$key}());
                     break;
             }
         }
     }
     if (count($org)) {
         $vcard->setOrganization(join(";", $org));
     }
     if (count($adr)) {
         $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
     }
     ilUtil::deliverData(utf8_decode($vcard->buildVCard()), $vcard->getFilename(), $vcard->getMimetype());
 }
Example #17
0
 public function outCertificateWithGivenContentAndVariables($content, $insert_tags)
 {
     global $ilLog;
     ilDatePresentation::setUseRelativeDates(false);
     $form_fields = $this->getFormFieldsFromFO();
     $form_fields['certificate_text'] = $content;
     $xslfo = $this->processXHTML2FO($form_fields);
     $content = $this->exchangeCertificateVariables($xslfo, $insert_tags);
     $content = str_replace('[BR]', "<fo:block/>", $content);
     include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
     try {
         $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($content);
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(array()), "application/pdf");
     } catch (XML_RPC2_FaultException $e) {
         $ilLog->write(__METHOD__ . ': ' . $e->getMessage());
         return false;
     } catch (Exception $e) {
         $ilLog->write(__METHOD__ . ': ' . $e->getMessage());
         return false;
     }
     ilDatePresentation::setUseRelativeDates(true);
 }
 /**
  * Export selected user tracking data
  * @global ilDB $ilDB
  * @global ilObjUser $ilUser
  * @param bool $a_all
  * @param array $a_users
  */
 public function exportSelected($a_all, $a_users = array())
 {
     global $ilDB, $ilUser, $ilSetting;
     $inst_id = $ilSetting->get('inst_id', 0);
     // Get all scos
     $scos = array();
     //get all SCO's of this object
     $query = 'SELECT scorm_object.obj_id, scorm_object.title, ' . 'scorm_object.c_type, scorm_object.slm_id, scorm_object.obj_id scoid  ' . 'FROM scorm_object, sc_item, sc_resource ' . 'WHERE (scorm_object.slm_id = %s ' . 'AND scorm_object.obj_id = sc_item.obj_id ' . 'AND sc_item.identifierref = sc_resource.import_id ' . 'AND sc_resource.scormtype = %s) ' . 'GROUP BY scorm_object.obj_id, scorm_object.title, scorm_object.c_type,  ' . 'scorm_object.slm_id, scorm_object.obj_id ';
     $res = $ilDB->queryF($query, array('integer', 'text'), array($this->getId(), 'sco'));
     while ($row = $ilDB->fetchAssoc($res)) {
         $scos[] = $row['scoid'];
     }
     $users = array();
     if ($a_all) {
         $query = 'SELECT user_id FROM scorm_tracking ' . 'WHERE obj_id = ' . $ilDB->quote($this->getId(), 'integer') . ' ' . 'GROUP BY user_id';
         $res = $ilDB->query($query);
         while ($row = $ilDB->fetchAssoc($res)) {
             $users[] = $row['user_id'];
         }
     } else {
         $users = $a_users;
     }
     // get all completed
     include_once './Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php';
     $completed = ilObjSCORMTracking::_getCompleted($scos, $this->getId());
     $last = ilObjSCORMTracking::lookupLastAccessTimes($this->getId());
     include_once './Services/Utilities/classes/class.ilCSVWriter.php';
     $csv = new ilCSVWriter();
     $csv->setSeparator(';');
     foreach (array('Department', 'Login', 'Lastname', 'Firstname', 'Email', 'Date', 'Status') as $col) {
         $csv->addColumn($col);
     }
     // Read user data
     $query = 'SELECT usr_id,login,firstname,lastname,department,email ' . 'FROM usr_data ' . 'WHERE ' . $ilDB->in('usr_id', $users, false, 'integer');
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $csv->addRow();
         $csv->addColumn((string) $row->department);
         $csv->addColumn((string) $row->login);
         $csv->addColumn((string) $row->lastname);
         $csv->addColumn((string) $row->firstname);
         $csv->addColumn((string) $row->email);
         if (isset($last[$row->usr_id])) {
             $dt = new ilDateTime($last[$row->usr_id], IL_CAL_DATETIME);
             $csv->addColumn((string) $dt->get(IL_CAL_FKT_DATE, 'd.m.Y'));
         } else {
             $csv->addColumn('');
         }
         $csv->addColumn(in_array($row->usr_id, $completed) ? 1 : 0);
     }
     ilUtil::deliverData($csv->getCSVString(), 'scorm_tracking_' . $this->getRefId() . '_' . time() . '.csv');
 }
 /**
  *   export bibinfo for download or copy/paste
  *
  *   @param
  *   @access public
  *   @return
  */
 function exportbibinfo()
 {
     global $ilDB;
     $objRow["obj_id"] = ilObject::_lookupObjId($_GET["ref_id"]);
     $objRow["title"] = ilObject::_lookupTitle($objRow["obj_id"]);
     $filename = preg_replace('/[^a-z0-9_]/i', '_', $objRow["title"]);
     $C = $this->lm_gui->showAbstract(array(1));
     if ($_GET["print"] == 1) {
         $printTpl = new ilTemplate("tpl.print.html", true, true, "Modules/LearningModule");
         $printTpl->touchBlock("printreq");
         $css1 = ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId());
         $css2 = ilUtil::getStyleSheetLocation();
         $printTpl->setVariable("LOCATION_CONTENT_STYLESHEET", $css1);
         $printTpl->setVariable("LOCATION_STYLESHEET", $css2);
         // syntax style
         $printTpl->setCurrentBlock("SyntaxStyle");
         $printTpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
         $printTpl->parseCurrentBlock();
         $printTpl->setVariable("CONTENT", $C);
         echo $printTpl->get();
         exit;
     } else {
         ilUtil::deliverData($C, $filename . ".html");
         exit;
     }
 }
 /**
  * Export the user specific results for the survey
  *
  * Export the user specific results for the survey
  *
  * @access private
  */
 function exportUserSpecificResults($export_format, $export_label, $finished_ids)
 {
     global $ilLog;
     // #13620
     ilDatePresentation::setUseRelativeDates(false);
     $csvfile = array();
     $csvrow = array();
     $csvrow2 = array();
     $questions = array();
     $questions =& $this->object->getSurveyQuestions(true);
     array_push($csvrow, $this->lng->txt("lastname"));
     // #12756
     array_push($csvrow, $this->lng->txt("firstname"));
     array_push($csvrow, $this->lng->txt("login"));
     array_push($csvrow, $this->lng->txt('workingtime'));
     // #13622
     array_push($csvrow, $this->lng->txt('survey_results_finished'));
     array_push($csvrow2, "");
     array_push($csvrow2, "");
     array_push($csvrow2, "");
     array_push($csvrow2, "");
     array_push($csvrow2, "");
     if ($this->object->canExportSurveyCode()) {
         array_push($csvrow, $this->lng->txt("codes"));
         array_push($csvrow2, "");
     }
     /* #8211
     		if ($this->object->getAnonymize() == ilObjSurvey::ANONYMIZE_OFF)
     		{
     			array_push($csvrow, $this->lng->txt("gender"));
     		}		 
     	    */
     $cellcounter = 1;
     foreach ($questions as $question_id => $question_data) {
         include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
         $question = SurveyQuestion::_instanciateQuestion($question_data["question_id"]);
         switch ($export_label) {
             case "label_only":
                 $question->addUserSpecificResultsExportTitles($csvrow, true);
                 break;
             case "title_only":
                 $question->addUserSpecificResultsExportTitles($csvrow, false);
                 break;
             default:
                 $question->addUserSpecificResultsExportTitles($csvrow, false);
                 $question->addUserSpecificResultsExportTitles($csvrow2, true, false);
                 break;
         }
         $questions[$question_data["question_id"]] = $question;
     }
     array_push($csvfile, $csvrow);
     if (sizeof($csvrow2) && implode("", $csvrow2)) {
         array_push($csvfile, $csvrow2);
     }
     if (!$finished_ids) {
         $participants =& $this->object->getSurveyFinishedIds();
     } else {
         $participants = $finished_ids;
     }
     $finished_data = array();
     foreach ($this->object->getSurveyParticipants($participants) as $item) {
         $finished_data[$item["active_id"]] = $item;
     }
     foreach ($participants as $user_id) {
         if ($user_id < 1) {
             continue;
         }
         $resultset =& $this->object->getEvaluationByUser($questions, $user_id);
         $csvrow = array();
         // #12756
         array_push($csvrow, trim($resultset["lastname"]) ? $resultset["lastname"] : $resultset["name"]);
         // anonymous
         array_push($csvrow, $resultset["firstname"]);
         array_push($csvrow, $resultset["login"]);
         // #10579
         if ($this->object->canExportSurveyCode()) {
             array_push($csvrow, $user_id);
         }
         /* #8211
         			if ($this->object->getAnonymize() == ilObjSurvey::ANONYMIZE_OFF)
         			{
         				array_push($csvrow, $resultset["gender"]);
         			}			
         		    */
         $wt = $this->object->getWorkingtimeForParticipant($user_id);
         array_push($csvrow, $wt);
         $finished = $finished_data[$user_id];
         if ((bool) $finished["finished"]) {
             array_push($csvrow, ilDatePresentation::formatDate(new ilDateTime($finished["finished_tstamp"], IL_CAL_UNIX)));
         } else {
             array_push($csvrow, "-");
         }
         foreach ($questions as $question_id => $question) {
             $question->addUserSpecificResultsData($csvrow, $resultset);
         }
         array_push($csvfile, $csvrow);
     }
     // #11179
     $surveyname = $this->object->getTitle() . " " . $this->lng->txt("svy_eval_user") . " " . date("Y-m-d");
     $surveyname = preg_replace("/\\s/", "_", trim($surveyname));
     $surveyname = ilUtil::getASCIIFilename($surveyname);
     switch ($export_format) {
         case self::TYPE_XLS:
             include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
             $excelfile = ilUtil::ilTempnam();
             $adapter = new ilExcelWriterAdapter($excelfile, FALSE);
             $workbook = $adapter->getWorkbook();
             $workbook->setVersion(8);
             // Use Excel97/2000 Format
             // Creating a worksheet
             $format_bold =& $workbook->addFormat();
             $format_bold->setBold();
             $format_percent =& $workbook->addFormat();
             $format_percent->setNumFormat("0.00%");
             $format_datetime =& $workbook->addFormat();
             $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
             $format_title =& $workbook->addFormat();
             $format_title->setBold();
             $format_title->setColor('black');
             $format_title->setPattern(1);
             $format_title->setFgColor('silver');
             $format_title_plain =& $workbook->addFormat();
             $format_title_plain->setColor('black');
             $format_title_plain->setPattern(1);
             $format_title_plain->setFgColor('silver');
             // Creating a worksheet
             $pages = floor(count($csvfile[0]) / 250) + 1;
             $worksheets = array();
             for ($i = 0; $i < $pages; $i++) {
                 $worksheets[$i] =& $workbook->addWorksheet();
             }
             $row = 0;
             include_once "./Services/Excel/classes/class.ilExcelUtils.php";
             $contentstartrow = 0;
             foreach ($csvfile as $csvrow) {
                 $col = 0;
                 if ($row == 0) {
                     $worksheet = 0;
                     $mainworksheet =& $worksheets[$worksheet];
                     foreach ($csvrow as $text) {
                         if (is_array($text)) {
                             $textcount = 0;
                             foreach ($text as $string) {
                                 $mainworksheet->writeString($row + $textcount, $col, ilExcelUtils::_convert_text($string, $_POST["export_format"]), $format_title);
                                 $textcount++;
                                 $contentstartrow = max($contentstartrow, $textcount);
                             }
                             $col++;
                         } else {
                             $mainworksheet->writeString($row, $col++, ilExcelUtils::_convert_text($text, $_POST["export_format"]), $format_title);
                         }
                         if ($col % 251 == 0) {
                             $worksheet++;
                             $col = 1;
                             $mainworksheet =& $worksheets[$worksheet];
                             $mainworksheet->writeString($row, 0, ilExcelUtils::_convert_text($csvrow[0], $_POST["export_format"]), $format_title);
                         }
                     }
                     $row = $contentstartrow;
                 } else {
                     $worksheet = 0;
                     $mainworksheet =& $worksheets[$worksheet];
                     foreach ($csvrow as $text) {
                         if (is_numeric($text)) {
                             $mainworksheet->writeNumber($row, $col++, $text);
                         } else {
                             $mainworksheet->writeString($row, $col++, ilExcelUtils::_convert_text($text, $_POST["export_format"]));
                         }
                         if ($col % 251 == 0) {
                             $worksheet++;
                             $col = 1;
                             $mainworksheet =& $worksheets[$worksheet];
                             $mainworksheet->writeString($row, 0, ilExcelUtils::_convert_text($csvrow[0], $_POST["export_format"]));
                         }
                     }
                 }
                 $row++;
             }
             $workbook->close();
             ilUtil::deliverFile($excelfile, "{$surveyname}.xls", "application/vnd.ms-excel");
             exit;
             break;
         case self::TYPE_SPSS:
             $csv = "";
             $separator = ";";
             foreach ($csvfile as $idx => $csvrow) {
                 $csvrow =& str_replace("\n", " ", $this->object->processCSVRow($csvrow, TRUE, $separator));
                 $csv .= join($csvrow, $separator) . "\n";
             }
             include_once "./Services/Utilities/classes/class.ilUtil.php";
             ilUtil::deliverData($csv, "{$surveyname}.csv");
             exit;
             break;
     }
 }
 /**
  * Exports all survey codes
  */
 public function exportAllCodesObject()
 {
     $export = $this->object->getSurveyCodesForExport();
     ilUtil::deliverData($export, ilUtil::getASCIIFilename($this->object->getTitle() . ".csv"));
 }
 /**
  * Download a language file
  */
 function downloadObject()
 {
     // save the selected scope
     $this->session["export"]["scope"] = ilUtil::stripSlashes($_POST["scope"]);
     $filename = 'ilias_' . $this->object->key . '_' . str_replace(".", "_", substr(ILIAS_VERSION, 0, strpos(ILIAS_VERSION, " "))) . "-" . date('Y-m-d') . ".lang." . $this->session["export"]["scope"];
     $global_file_obj = $this->object->getGlobalLanguageFile();
     $local_file_obj = new ilLanguageFile($filename, $this->object->key, $_POST["scope"]);
     if ($_POST["scope"] == 'global') {
         $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
         $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
         $local_file_obj->setAllValues($this->object->getAllValues());
         if ($this->langmode) {
             $local_file_obj->setAllComments($this->object->getAllRemarks());
         }
     } elseif ($_POST["scope"] == 'local') {
         $local_file_obj->setParam("based_on", $global_file_obj->getParam('version'));
         $local_file_obj->setAllValues($this->object->getChangedValues());
         if ($this->langmode) {
             $local_file_obj->setAllComments($this->object->getAllRemarks());
         }
     } elseif ($_POST["scope"] == 'added') {
         $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
         $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
         $local_file_obj->setAllValues($this->object->getAddedValues());
         $local_file_obj->setAllComments($this->object->getAllRemarks());
     } elseif ($_POST["scope"] == 'unchanged') {
         $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
         $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
         $local_file_obj->setAllValues($this->object->getUnchangedValues());
         if ($this->langmode) {
             $local_file_obj->setAllComments($this->object->getAllRemarks());
         }
     } elseif ($_POST["scope"] == 'merged') {
         $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
         $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
         $local_file_obj->setAllValues($this->object->getMergedValues());
         $local_file_obj->setAllComments($this->object->getMergedRemarks());
     }
     ilUtil::deliverData($local_file_obj->build(), $filename);
 }
 /**
  * Download export file
  *
  * @access public
  * @param
  * 
  */
 public function downloadExportFile()
 {
     if (count($_POST['files']) != 1) {
         ilUtil::sendFailure($this->lng->txt('ps_select_one'));
         $this->show();
         return true;
     }
     foreach ($this->fss_export->getMemberExportFiles() as $file) {
         if (!in_array($file['timest'], $_POST['files'])) {
             continue;
         }
         $contents = $this->fss_export->getMemberExportFile($file['timest'] . '_participant_export_' . $file['type'] . '_' . $this->obj_id . '.' . $file['type']);
         switch ($file['type']) {
             case 'xls':
                 ilUtil::deliverData($contents, date('Y_m_d_H-i' . $file['timest']) . '_member_export_' . $this->obj_id . '.xls', 'application/vnd.ms-excel');
             default:
             case 'csv':
                 ilUtil::deliverData($contents, date('Y_m_d_H-i' . $file['timest']) . '_member_export_' . $this->obj_id . '.csv', 'text/csv');
                 break;
         }
         return true;
     }
 }
Example #24
0
 /**
  * Exports the evaluation data to the CSV file format
  *
  * Exports the evaluation data to the CSV file format
  *
  * @param string $filtertext Filter text for the user data
  * @param boolean $passedonly TRUE if only passed user datasets should be exported, FALSE otherwise
  * @access public
  */
 function exportToCSV($deliver = TRUE, $filterby = "", $filtertext = "", $passedonly = FALSE)
 {
     global $ilLog;
     if (strcmp($this->mode, "aggregated") == 0) {
         return $this->aggregatedResultsToCSV($deliver);
     }
     $rows = array();
     $datarow = array();
     $col = 1;
     if ($this->test_obj->getAnonymity()) {
         array_push($datarow, $this->lng->txt("counter"));
         $col++;
     } else {
         array_push($datarow, $this->lng->txt("name"));
         $col++;
         array_push($datarow, $this->lng->txt("login"));
         $col++;
     }
     $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
     if (count($additionalFields)) {
         foreach ($additionalFields as $fieldname) {
             array_push($datarow, $this->lng->txt($fieldname));
             $col++;
         }
     }
     array_push($datarow, $this->lng->txt("tst_stat_result_resultspoints"));
     $col++;
     array_push($datarow, $this->lng->txt("maximum_points"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_resultsmarks"));
     $col++;
     if ($this->test_obj->getECTSOutput()) {
         array_push($datarow, $this->lng->txt("ects_grade"));
         $col++;
     }
     array_push($datarow, $this->lng->txt("tst_stat_result_qworkedthrough"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_qmax"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_pworkedthrough"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_timeofwork"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_atimeofwork"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_firstvisit"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_lastvisit"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_mark_median"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_rank_participant"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_rank_median"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_total_participants"));
     $col++;
     array_push($datarow, $this->lng->txt("tst_stat_result_median"));
     $col++;
     array_push($datarow, $this->lng->txt("scored_pass"));
     $col++;
     array_push($datarow, $this->lng->txt("pass"));
     $col++;
     $data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext);
     $headerrow = $datarow;
     $counter = 1;
     foreach ($data->getParticipants() as $active_id => $userdata) {
         $datarow = $headerrow;
         $remove = FALSE;
         if ($passedonly) {
             if ($data->getParticipant($active_id)->getPassed() == FALSE) {
                 $remove = TRUE;
             }
         }
         if (!$remove) {
             $datarow2 = array();
             if ($this->test_obj->getAnonymity()) {
                 array_push($datarow2, $counter);
             } else {
                 array_push($datarow2, $data->getParticipant($active_id)->getName());
                 array_push($datarow2, $data->getParticipant($active_id)->getLogin());
             }
             if (count($additionalFields)) {
                 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
                 foreach ($additionalFields as $fieldname) {
                     if (strcmp($fieldname, "gender") == 0) {
                         array_push($datarow2, $this->lng->txt("gender_" . $userfields[$fieldname]));
                     } else {
                         array_push($datarow2, $userfields[$fieldname]);
                     }
                 }
             }
             array_push($datarow2, $data->getParticipant($active_id)->getReached());
             array_push($datarow2, $data->getParticipant($active_id)->getMaxpoints());
             array_push($datarow2, $data->getParticipant($active_id)->getMark());
             if ($this->test_obj->getECTSOutput()) {
                 array_push($datarow2, $data->getParticipant($active_id)->getECTSMark());
             }
             array_push($datarow2, $data->getParticipant($active_id)->getQuestionsWorkedThrough());
             array_push($datarow2, $data->getParticipant($active_id)->getNumberOfQuestions());
             array_push($datarow2, $data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0);
             $time = $data->getParticipant($active_id)->getTimeOfWork();
             $time_seconds = $time;
             $time_hours = floor($time_seconds / 3600);
             $time_seconds -= $time_hours * 3600;
             $time_minutes = floor($time_seconds / 60);
             $time_seconds -= $time_minutes * 60;
             array_push($datarow2, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
             $time = $data->getParticipant($active_id)->getQuestionsWorkedThrough() ? $data->getParticipant($active_id)->getTimeOfWork() / $data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
             $time_seconds = $time;
             $time_hours = floor($time_seconds / 3600);
             $time_seconds -= $time_hours * 3600;
             $time_minutes = floor($time_seconds / 60);
             $time_seconds -= $time_minutes * 60;
             array_push($datarow2, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
             $fv = $data->getParticipant($active_id)->getFirstVisit();
             $lv = $data->getParticipant($active_id)->getLastVisit();
             foreach (array($fv, $lv) as $ts) {
                 if ($ts) {
                     $visit = ilFormat::formatDate(date('Y-m-d H:i:s', $ts), "datetime", false, false);
                     array_push($datarow2, $visit);
                 } else {
                     array_push($datarow2, "");
                 }
             }
             $median = $data->getStatistics()->getStatistics()->median();
             $pct = $data->getParticipant($active_id)->getMaxpoints() ? $median / $data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
             $mark = $this->test_obj->mark_schema->getMatchingMark($pct);
             $mark_short_name = "";
             if (is_object($mark)) {
                 $mark_short_name = $mark->getShortName();
             }
             array_push($datarow2, $mark_short_name);
             array_push($datarow2, $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
             array_push($datarow2, $data->getStatistics()->getStatistics()->rank_median());
             array_push($datarow2, $data->getStatistics()->getStatistics()->count());
             array_push($datarow2, $median);
             if ($this->test_obj->getPassScoring() == SCORE_BEST_PASS) {
                 array_push($datarow2, $data->getParticipant($active_id)->getBestPass() + 1);
             } else {
                 array_push($datarow2, $data->getParticipant($active_id)->getLastPass() + 1);
             }
             for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++) {
                 $finishdate = $this->test_obj->getPassFinishDate($active_id, $pass);
                 if ($finishdate > 0) {
                     if ($pass > 0) {
                         for ($i = 1; $i < $col - 1; $i++) {
                             array_push($datarow2, "");
                             array_push($datarow, "");
                         }
                         array_push($datarow, "");
                     }
                     array_push($datarow2, $pass + 1);
                     if (is_object($data->getParticipant($active_id)) && is_array($data->getParticipant($active_id)->getQuestions($pass))) {
                         foreach ($data->getParticipant($active_id)->getQuestions($pass) as $question) {
                             $question_data = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
                             array_push($datarow2, $question_data["reached"]);
                             array_push($datarow, preg_replace("/<.*?>/", "", $data->getQuestionTitle($question["id"])));
                         }
                     }
                     if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions() || $counter == 1 && $pass == 0) {
                         array_push($rows, $datarow);
                     }
                     $datarow = array();
                     array_push($rows, $datarow2);
                     $datarow2 = array();
                 }
             }
             $counter++;
         }
     }
     $csv = "";
     $separator = ";";
     foreach ($rows as $evalrow) {
         $csvrow =& $this->test_obj->processCSVRow($evalrow, TRUE, $separator);
         $csv .= join($csvrow, $separator) . "\n";
     }
     if ($deliver) {
         ilUtil::deliverData($csv, ilUtil::getASCIIFilename($this->test_obj->getTitle() . "_results.csv"));
         exit;
     } else {
         return $csv;
     }
 }
 /**
  * Export one template
  */
 protected function exportTemplate()
 {
     global $ilErr, $ilCtrl;
     if (!$_REQUEST['tplid']) {
         ilUtil::sendFailure($this->lng->txt('select_one'));
         return $ilCtrl->redirect($this, 'overview');
     }
     include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateXmlWriter.php';
     $writer = new ilDidacticTemplateXmlWriter((int) $_REQUEST['tplid']);
     $writer->write();
     ilUtil::deliverData($writer->xmlDumpMem(TRUE), $writer->getSetting()->getTitle() . '.xml', 'application/xml');
 }