From 3b3e56c2f4e2a9624f0e25b1d5b0892a421a00bd Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 8 Mar 2019 19:56:41 +0000 Subject: [PATCH] Template editor done. --- WEB-INF/lib/ttTemplateHelper.class.php | 2 +- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/template_delete.tpl | 18 +++++++ template_delete.php | 75 ++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 WEB-INF/templates/template_delete.tpl create mode 100644 template_delete.php diff --git a/WEB-INF/lib/ttTemplateHelper.class.php b/WEB-INF/lib/ttTemplateHelper.class.php index d6eefcde..cc1818d2 100644 --- a/WEB-INF/lib/ttTemplateHelper.class.php +++ b/WEB-INF/lib/ttTemplateHelper.class.php @@ -59,7 +59,7 @@ class ttTemplateHelper { $group_id = $user->getGroup(); $org_id = $user->org_id; - $sql = "update from tt_templates set status = null". + $sql = "update tt_templates set status = null". " where id = $id and group_id = $group_id and org_id = $org_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 6a9ecb56..8b3fb051 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.55.4845 | Copyright © Anuko | +  Anuko Time Tracker 1.18.55.4846 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/template_delete.tpl b/WEB-INF/templates/template_delete.tpl new file mode 100644 index 00000000..2dc4114a --- /dev/null +++ b/WEB-INF/templates/template_delete.tpl @@ -0,0 +1,18 @@ +{$forms.templateDeleteForm.open} + + + + +
+ + + + + + + + + +
{$template_to_delete|escape}
 
{$forms.templateDeleteForm.btn_delete.control}  {$forms.templateDeleteForm.btn_cancel.control}
+
+{$forms.templateDeleteForm.close} diff --git a/template_delete.php b/template_delete.php new file mode 100644 index 00000000..3eb34876 --- /dev/null +++ b/template_delete.php @@ -0,0 +1,75 @@ +isPluginEnabled('tp')) { + header('Location: feature_disabled.php'); + exit(); +} +$cl_template_id = (int) $request->getParameter('id'); +$template = ttTemplateHelper::get($cl_template_id); +if (!$template) { + header('Location: access_denied.php'); + exit(); +} +// End of access checks. + +$template_to_delete = $template['name']; + +$form = new Form('templateDeleteForm'); +$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_template_id)); +$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->get('label.delete'))); +$form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->get('button.cancel'))); + +if ($request->isPost()) { + if ($request->getParameter('btn_delete')) { + if (ttTemplateHelper::delete($cl_template_id)) { + header('Location: templates.php'); + exit(); + } else + $err->add($i18n->get('error.db')); + } elseif ($request->getParameter('btn_cancel')) { + header('Location: templates.php'); + exit(); + } +} // isPost + +$smarty->assign('template_to_delete', $template_to_delete); +$smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('onload', 'onLoad="document.templateDeleteForm.btn_cancel.focus()"'); +$smarty->assign('title', $i18n->get('title.delete_template')); +$smarty->assign('content_page_name', 'template_delete.tpl'); +$smarty->display('index.tpl'); -- 2.20.1