Added user config params to import.
[timetracker.git] / cf_custom_field_delete.php
index 139253d..86c10b1 100644 (file)
@@ -30,17 +30,21 @@ require_once('initialize.php');
 require_once('plugins/CustomFields.class.php');
 import('form.Form');
 
-// Access check.
-if (!ttAccessCheck(right_manage_team)) {
+// Access checks.
+if (!ttAccessAllowed('manage_custom_fields')) {
   header('Location: access_denied.php');
   exit();
 }
+if (!$user->isPluginEnabled('cf')) {
+  header('Location: feature_disabled.php');
+  exit();
+}
 
 $id = $request->getParameter('id');
 
 $form = new Form('fieldDeleteForm');
 
-if ($request->getMethod() == 'POST') {
+if ($request->isPost()) {
   if ($request->getParameter('btn_delete')) {
     // Delete button pressed.
     $res = CustomFields::deleteField($id);
@@ -48,7 +52,7 @@ if ($request->getMethod() == 'POST') {
       header('Location: cf_custom_fields.php');
       exit();
     } else
-      $errors->add($i18n->getKey('error.db'));
+      $err->add($i18n->get('error.db'));
   }
   if ($request->getParameter('btn_cancel')) {
     // Cancel button pressed.
@@ -58,18 +62,18 @@ if ($request->getMethod() == 'POST') {
 } else {
   $field = CustomFields::getField($id);        
   if (false === $field)
-    $errors->add($i18n->getKey('error.db'));
+    $err->add($i18n->get('error.db'));
 
-  if ($errors->no()) {
+  if ($err->no()) {
     $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$id));
-    $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
-    $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel')));
+    $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')));
   }
 }
 
 $smarty->assign('field', $field['label']);
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
 $smarty->assign('onload', 'onLoad="document.fieldDeleteForm.btn_cancel.focus()"');
-$smarty->assign('title', $i18n->getKey('title.cf_delete_custom_field'));
+$smarty->assign('title', $i18n->get('title.cf_delete_custom_field'));
 $smarty->assign('content_page_name', 'cf_custom_field_delete.tpl');
 $smarty->display('index.tpl');