/** * Download task list as attachment * * @access public * @param void * @return null */ function download_list() { $task_list = ProjectTaskLists::findById(get_id()); if (!$task_list instanceof ProjectTaskList) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if $this->canGoOn(); if (!$task_list->canView(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('task')); } // if $output = array_var($_GET, 'output', 'csv'); $project_name = active_project()->getName(); $task_list_name = $task_list->getName(); $task_count = 0; if ($output == 'pdf') { Env::useLibrary('fpdf'); $download_name = "{$project_name}-{$task_list_name}-tasks.pdf"; $download_type = 'application/pdf'; $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetTitle($task_list_name); $pdf->SetCompression(true); $pdf->SetCreator('ProjectPier'); $pdf->SetDisplayMode(fullpage, single); $pdf->SetSubject(active_project()->getObjectName()); $pdf->SetFont('Arial', 'B', 16); $task_lists = active_project()->getOpenTaskLists(); $pdf->Cell(0, 10, lang('project') . ': ' . active_project()->getObjectName(), 'C'); $pdf->Ln(); foreach ($task_lists as $task_list) { $pdf->SetFont('Arial', 'B', 14); $pdf->Write(10, lang('task list') . ': ' . $task_list->getObjectName()); $pdf->Ln(); $tasks = $task_list->getTasks(); $line = 0; // Column widths $w = array(10, 0, 0); // Header //for($i=0;$i<count($header);$i++) // $this->Cell($w[$i],7,$header[$i],1,0,'C'); //$this->Ln(); $pdf->SetFont('Arial', 'I', 14); foreach ($tasks as $task) { $line++; if ($task->isCompleted()) { $task_status = lang('completed'); $pdf->SetTextColor(100, 200, 100); $task_completion_info = lang('completed task') . ' : ' . format_date($task->getCompletedOn()); } else { $task_status = lang('open'); $pdf->SetTextColor(255, 0, 0); $task_completion_info = lang('due date') . ' : ' . lang('not assigned'); if ($task->getDueDate()) { $task_completion_info = lang('due date') . ' : ' . format_date($task->getDueDate()); } } if ($task->getAssignedTo()) { $task_assignee = $task->getAssignedTo()->getObjectName(); } else { $task_assignee = lang('not assigned'); } $pdf->Cell($w[0], 6, $line); $pdf->Cell($w[2], 6, $task_status, "TLRB"); $pdf->Ln(); $pdf->Cell($w[0], 6, ''); $pdf->SetTextColor(0, 0, 0); $pdf->Cell($w[2], 6, $task_completion_info, "TLRB"); $pdf->Ln(); $pdf->Cell($w[0], 6, ''); $pdf->SetTextColor(0, 0, 0); $pdf->Cell($w[2], 6, $task_assignee, "TLRB"); $pdf->Ln(); $pdf->Cell($w[0], 6, ''); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell($w[2], 6, $task->getText(), "TLRB"); $pdf->Ln(); } } $pdf->Output($download_name, 'D'); } else { $download_name = "{$project_name}-{$task_list_name}-tasks.txt"; $download_type = 'text/csv'; $download_contents = $task_list->getDownloadText($task_count, "\t", true); download_contents($download_contents, $download_type, $download_name, strlen($download_contents)); } die; }
/** * Download task list as attachment * * @access public * @param void * @return null */ function download_list() { $task_list = ProjectTaskLists::findById(get_id()); if (!$task_list instanceof ProjectTaskList) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if $this->canGoOn(); if (!$task_list->canView(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('task')); } // if $project_name = active_project()->getName(); $task_list_name = $task_list->getName(); $task_count = 0; $download_name = "{$project_name}-{$task_list_name}-tasks.txt"; $download_type = 'text/csv'; $download_contents = $task_list->getDownloadText($task_count, "\t", true); download_contents($download_contents, $download_type, $download_name, strlen($download_contents)); }
function export_to_vcard_all() { $contacts_all = Contacts::instance()->getAllowedContacts(); $user = logged_user(); if (count($contacts_all) == 0) { flash_error(lang("you must select the contacts from the grid")); ajx_current("empty"); return; } $data = self::build_vcard($contacts_all); $name = "contacts_all_".$user->getUsername().".vcf"; download_contents($data, 'text/x-vcard', $name, strlen($data), true); die(); }
/** * Download specific revision * * @param string $revision_id * @return null */ private function _download_revision($revision = null, $inline) { trace(__FILE__, "_download_revision(...):"); if (!$revision instanceof ProjectFileRevision) { flash_error(lang('file revision dnx')); $this->redirectToReferer(get_url('files')); } // if $repository_id = $revision->getRepositoryId(); if ('fs' == config_option('file_storage_adapter', 'fs')) { trace(__FILE__, "_download_revision(...):from fs"); $is_fs = true; $contents = FileRepository::getFilePath($repository_id); } else { trace(__FILE__, "_download_revision(...):from db"); $is_fs = false; $contents =& $revision->getFileContent(); } trace(__FILE__, "_download_revision(...):{$repository_id}"); download_contents($contents, $revision->getTypeString(), $revision->getFileName(), $revision->getFileSize(), $inline, $is_fs); }
/** * Forward specific file to the browser. Download can be forced (disposition: attachment) or passed as inline file * * @access public * @param string $path File path * @param string $type Serve file as this type * @param string $name If set use this name, else use filename (basename($path)) * @param boolean $force_download Force download (add Disposition => attachement) * @return boolean */ function download_file($path, $type = 'application/octet-stream', $name = '', $force_download = false) { if (!is_readable($path)) { return false; } // if $filename = trim($name) == '' ? basename($path) : trim($name); return download_contents(file_get_contents($path), $type, $filename, filesize($path), $force_download); }
function download() { $this->setTemplate(get_template_path('back')); $id = array_var($_GET, 'id'); $email = MailContents::findById($id); if (!$email instanceof MailContent) { flash_error(lang('email dnx')); return; } if (!$email->canView(logged_user())) { flash_error(lang('no access permissions')); return; } if ($email->getContent()) { download_contents($email->getContent(), 'message/rfc822', $email->getSubject() . ".eml", strlen($email->getContent()), true); die; } else { download_from_repository($email->getContentFileId(), 'message/rfc822', $email->getSubject() . ".eml", true); die; } }
/** * Download file * * @param null * @return void */ function file_download() { if (!$this->active_file) { $this->httpError(HTTP_BAD_REQUEST); } // if if (!$this->active_repository->canView($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $file_source = implode("\n", $this->repository_engine->cat($this->active_revision, $this->active_file, $this->request->get('peg'))); download_contents($file_source, 'application/octet-stream', $this->active_file_basename, true); }
/** * Download a file from the file repository. * * @param string $id * @param string $type * @param string $name * @param boolean $force_download * @return boolean */ function download_from_repository($id, $type, $name, $force_download = false) { if (FileRepository::getBackend() instanceof FileRepository_Backend_FileSystem) { $path = FileRepository::getBackend()->getFilePath($id); if (is_file($path)) { // this method allows downloading big files without exhausting php's memory return download_file($path, $type, $name, $force_download); } } $content = FileRepository::getBackend()->getFileContent($id); return download_contents($content, $type, $name, strlen($content), $force_download); }
/** * Download specific revision * * @param void * @return null */ function download_revision() { $revision = ProjectFileRevisions::findById(get_id()); if (!$revision instanceof ProjectFileRevision) { flash_error(lang('file revision dnx')); $this->redirectToReferer(get_url('files')); } // if $file = $revision->getFile(); if (!$file instanceof ProjectFile) { flash_error(lang('file dnx')); $this->redirectToReferer(get_url('files')); } // if if (!$revision->canDownload(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('files')); } // if $this->canGoOn(); download_contents($revision->getFileContent(), $revision->getTypeString(), $file->getFilename(), $file->getFileSize()); die; }
/** * Exports language in XML form * * @param void * @return null */ function export() { $this->wireframe->print_button = false; $this->skip_layout = true; if ($this->active_language->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $translation_files = $this->active_language->getTranslationFiles(); if (is_foreachable($translation_files)) { $translations_path = $this->active_language->getLocalizationPath(); foreach ($translation_files as $translation_file) { $translation_filename = $translations_path . '/module.' . $translation_file . '.php'; if (is_file($translation_filename)) { $translation_content = (require $translation_filename); if (is_foreachable($translation_content)) { foreach ($translation_content as $phrase => $translation) { if ($translation) { $translations[$translation_file][$phrase] = $translation; } // if } // forach } // if } // if } // foreach } // if $this->smarty->assign(array('ac_version' => $this->application->version ? $this->application->version : '1.0', 'translations' => $translations)); $xml = $this->smarty->fetch($this->getTemplatePath()); header('Content-Type: application/xml; charset=utf-8'); download_contents($xml, 'application/xml', clean($this->active_language->getName()) . ' (' . $this->active_language->getLocale() . ').xml', true, true); }
function export_to_vcard() { $ids = array_var($_GET, 'ids'); if (trim($ids) == "") { $ids = "0"; } $contacts = Contacts::instance()->getAllowedContacts(" id IN (" . $ids . ")"); if (count($contacts) == 0) { flash_error(lang("you must select the contacts from the grid")); ajx_current("empty"); return; } $data = self::build_vcard($contacts); $name = (count($contacts) == 1 ? $contacts[0]->getObjectName() : "contacts") . ".vcf"; download_contents($data, 'text/x-vcard', $name, strlen($data), true); die; }
/** * Export report as CSV * * @param void * @return null */ function report_export() { if ($this->active_report->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_report->canView($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if download_contents(array_to_csv(TimeReports::executeReportForExport($this->logged_user, $this->active_report)), 'text/csv', "time-report.csv", true); }
/** * Download tickets as attachment * * @access public * @param void * @return null */ function download() { $this->canGoOn(); $download_type = isset($_REQUEST['content_type']) ? $_REQUEST['content_type'] : 'text/csv'; $download = ProjectTickets::getDownload(active_project(), $download_type); download_contents($download['content'], $download['type'], $download['name'], strlen($download['content'])); die; }
/** * Download project task lists * * @param void * @return null */ function download_task_lists() { if (!logged_user()->isProjectUser(active_project())) { flash_error(lang('no access permissions')); $this->redirectTo('dashboard', 'index'); } // if $project = active_project(); $task_lists = $project->getTaskLists(); $project_name = $project->getName(); if (is_array($task_lists)) { $name = $project_name . '_tasks.txt'; $content = ''; $header = true; $count = 0; foreach ($task_lists as $task_list) { $content .= $task_list->getDownloadText($count, "\t", $header); $header = false; } flash_success(lang('%s items downloaded', $count)); download_contents($content, 'text/csv', $name, strlen($content)); } else { flash_error(lang('nothing to download', $project_name)); } $this->redirectTo('project', 'index'); }
/** * Download task list as attachment * * @access public * @param void * @return null */ function download_list() { $task_list = ProjectTaskLists::findById(get_id()); if (!$task_list instanceof ProjectTaskList) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if $this->canGoOn(); if (!$task_list->canView(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('task')); } // if $output = array_var($_GET, 'output', 'csv'); $project_name = active_project()->getName(); $task_list_name = $task_list->getName(); $task_count = 0; if ($output == 'pdf') { Env::useLibrary('fpdf'); $download_name = "{$project_name}-tasks.pdf"; $download_type = 'application/pdf'; $pdf = new FPDF("P", "mm"); $pdf->AddPage(); $pdf->SetTitle($project_name); $pdf->SetCompression(true); $pdf->SetCreator('ProjectPier'); $pdf->SetDisplayMode('fullpage', 'single'); $pdf->SetSubject(active_project()->getObjectName()); $pdf->SetFont('Arial', 'B', 16); $task_lists = active_project()->getOpenTaskLists(); $pdf->Cell(0, 10, lang('project') . ': ' . active_project()->getObjectName(), 'B', 0, 'C'); $pdf->Ln(14); $w = array(0 => 12, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140); foreach ($task_lists as $task_list) { $pdf->SetFont('Arial', 'B', 14); $pdf->Write(10, lang('task list') . ': ' . $task_list->getObjectName()); $pdf->Ln(14); $tasks = $task_list->getTasks(); $pdf->SetFont('Arial', 'I', 14); $pdf->SetFillColor(230, 230, 230); $pdf->Cell($w[1], 6, '#', 1, 0, 'C', true); $pdf->Cell($w[3], 6, lang('status'), 1, 0, 'C', true); $pdf->Cell($w[10], 6, lang('info'), 1, 0, 'C', true); $pdf->Cell(0, 6, lang(user), 1, 0, 'C', true); $pdf->Ln(); foreach ($tasks as $task) { $line++; if ($task->isCompleted()) { $task_status = lang('completed'); $task_status_color_R = 0; $task_status_color_G = 150; $task_status_color_B = 0; $task_completion_info = lang('completed task') . ' : ' . format_date($task->getCompletedOn()) . ' @ ' . format_time($task->getCompletedOn()); } else { $task_status = lang('open'); $task_status_color_R = 200; $task_status_color_G = 0; $task_status_color_B = 0; $task_completion_info = lang('due date') . ' : ' . lang('not assigned'); $task_completion_info_color_R = 200; $task_completion_info_color_G = 0; $task_completion_info_color_B = 0; if ($task->getDueDate()) { $task_completion_info = lang('due date') . ' : ' . format_date($task->getDueDate()) . ' @ ' . format_time($task->getDueDate()); $task_completion_info_color_R = 0; $task_completion_info_color_G = 0; $task_completion_info_color_B = 0; } } if ($task->getAssignedTo()) { $task_assignee = $task->getAssignedTo()->getObjectName(); $task_assignee_color_R = 0; $task_assignee_color_G = 0; $task_assignee_color_B = 0; } else { $task_assignee = lang('not assigned'); $task_assignee_color_R = 200; $task_assignee_color_G = 0; $task_assignee_color_B = 0; } $pdf->SetFillColor(245, 245, 245); $pdf->Cell($w[1], 6, $line, 1, 0, 'C', true); $pdf->SetTextColor($task_status_color_R, $task_status_color_G, $task_status_color_B); $pdf->Cell($w[3], 6, $task_status, 1, 0, 'C', true); $pdf->SetTextColor($task_completion_info_color_R, $task_completion_info_color_G, $task_completion_info_color_B); $pdf->Cell($w[10], 6, $task_completion_info, 1, 0, 'C', true); $pdf->SetTextColor($task_assignee_color_R, $task_assignee_color_G, $task_assignee_color_B); $pdf->Cell(0, 6, $task_assignee, 1, 0, 'C', true); $pdf->SetTextColor(0, 0, 0); $pdf->Ln(); $pdf->MultiCell(0, 6, $task->getText(), 1); //$pdf->Ln(); } } $pdf->Output($download_name, 'I'); } if ($output == 'txt') { $download_name = "{$project_name}-tasks.txt"; $download_type = 'text/csv'; $txt_lang_1 = lang('project'); $txt_lang_2 = lang('milestone'); $txt_lang_3 = lang('task list'); $txt_lang_4 = lang('status'); $txt_lang_5 = lang('description'); $txt_lang_6 = lang('id'); $txt_lang_7 = lang('status'); $txt_lang_8 = lang('completion info'); $txt_lang_9 = lang('assigned to'); $s .= "{$txt_lang_1}\t{$txt_lang_2}\t{$txt_lang_3}\t{$txt_lang_4}\t{$txt_lang_5}\t{$txt_lang_6}\t{$txt_lang_7}\t{$txt_lang_8}\t{$txt_lang_9}"; $s .= "\n"; $task_lists = active_project()->getOpenTaskLists(); foreach ($task_lists as $task_list) { /*$s .= $task_list->getObjectName(); $s .= "\n"; $task_list_desc = $task_list->getDescription(); $task_list_desc = strtr($task_list_desc,"\r\n\t"," "); $task_list_desc_100 = substr($task_list_desc,0,100); $s .= $task_list_desc_100; $s .= "\n";*/ $milestone = $task_list->getMilestone(); $tasks = $task_list->getTasks(); foreach ($tasks as $task) { $s .= $project_name; $s .= "\t"; $milestone_name = lang(none); if ($milestone instanceof ProjectMilestone) { $milestone_name = $milestone->getName(); } $s .= $milestone_name; $s .= "\t"; $s .= $task_list->getObjectName(); $s .= "\t"; $task_list_name = $task_list->getName(); if ($task_list->isCompleted()) { $task_list_status = lang('completed'); } else { $task_list_status = lang('open'); } $s .= $task_list_status; $s .= "\t"; $task_list_desc2 = $task_list->getDescription(); $task_list_desc2 = strtr($task_list_desc2, "\r\n\t", " "); $task_list_desc2_100 = substr($task_list_desc2, 0, 50); $s .= $task_list_desc2_100; $s .= "\t"; $s .= $task->getId(); $s .= "\t"; if ($task->isCompleted()) { $task_status = lang('completed'); $task_completion_info = format_date($task->getCompletedOn()) . " @ " . format_time($task->getCompletedOn()); } else { $task_status = lang('open'); $task_completion_info = format_date($task->getDueDate()) . " @ " . format_time($task->getDueDate()); } $s .= $task_status; $s .= "\t"; $s .= $task_completion_info; $s .= "\t"; if ($task->getAssignedTo()) { $task_assignee = $task->getAssignedTo()->getObjectName(); } else { $task_assignee = lang('not assigned'); } $s .= $task_assignee; $s .= "\n"; } } $download_contents = $s; download_headers($download_name, $download_type, strlen($download_contents), true); echo $download_contents; } else { $download_name = "{$project_name}-{$task_list_name}-tasks.csv"; $download_type = 'text/csv'; $download_contents = $task_list->getDownloadText($task_count, "\t", true); download_contents($download_contents, $download_type, $download_name, strlen($download_contents)); } die; }