From: Nik Okuntseff Date: Wed, 27 Mar 2019 20:18:33 +0000 (+0000) Subject: Work in progress on project attachment list view. X-Git-Tag: timetracker_1.19-1~148 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=ebadc5e4019929d4e1686516160ee01a114d9b8a;p=timetracker.git Work in progress on project attachment list view. --- diff --git a/WEB-INF/lib/ttFileHelper.class.php b/WEB-INF/lib/ttFileHelper.class.php index 7c8324b6..f74e77a3 100644 --- a/WEB-INF/lib/ttFileHelper.class.php +++ b/WEB-INF/lib/ttFileHelper.class.php @@ -125,7 +125,7 @@ class ttFileHelper { $group_id = $user->getGroup(); $org_id = $user->org_id; - $fields = array('site_id' => urlencode($this->site_id), + $curl_fields = array('site_id' => urlencode($this->site_id), 'site_key' => urlencode($this->site_key), 'org_id' => urlencode($org_id), 'org_key' => urlencode($this->getOrgKey()), @@ -139,7 +139,7 @@ class ttFileHelper { ); // url-ify the data for the POST. - foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } + foreach($curl_fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } $fields_string = rtrim($fields_string, '&'); // Open connection. @@ -216,4 +216,25 @@ class ttFileHelper { $val = $res->fetchRow(); return $val['group_key']; } + + // getProjectFiles obtains a list of files for a project. + function getProjectFiles($project_id) { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $result = array(); + $sql = "select id, remote_id, file_name as name, description from tt_files". + " where entity_type = 'project' and entity_id = $project_id". + " and group_id = $group_id and org_id = $org_id and status = 1 order by id"; + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $result[] = $val; + } + } + return $result; + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index f73aa055..d5c62e90 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.61.4888 | Copyright © Anuko | +  Anuko Time Tracker 1.18.61.4889 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/project_files.tpl b/WEB-INF/templates/project_files.tpl index d092e3cb..a542c6bb 100644 --- a/WEB-INF/templates/project_files.tpl +++ b/WEB-INF/templates/project_files.tpl @@ -3,7 +3,7 @@ - + {if $can_manage} diff --git a/project_files.php b/project_files.php index cc917466..6abd0afa 100644 --- a/project_files.php +++ b/project_files.php @@ -52,8 +52,8 @@ if ($request->isPost()) { $cl_description = trim($request->getParameter('description')); } -$files = null; -// $files = ttAttachmentHelper::getProjectFiles(); +$fileHelper = new ttFileHelper($err); +$files = $fileHelper::getProjectFiles($cl_project_id); $form = new Form('fileUploadForm'); $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_project_id)); @@ -71,14 +71,15 @@ if ($request->isPost()) { // Finished validating user input. if ($err->no()) { - $fileHelper = new ttFileHelper($err); $fields = array('entity_type'=>'project', 'entity_id' => $cl_project_id, 'file_name' => $_FILES['newfile']['name'], 'description'=>$cl_description); - if (!$fileHelper->putFile($fields)) { + if ($fileHelper->putFile($fields)) { + header('Location: project_files.php?id='.$cl_project_id); + exit(); + } else $err->add($i18n->get('error.file_storage')); - } } } // isPost
{$i18n.label.image}{$i18n.label.thing_name} {$i18n.label.description}{$i18n.label.edit}