Example #1
0
 /**
  * Deletes a template
  * @return
  */
 function DeleteTemplate()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error('Token does not match', E_USER_ERROR);
     }
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $templateId = Kit::GetParam('templateid', _POST, _INT);
     if ($templateId == 0) {
         trigger_error(__('No template selected'), E_USER_ERROR);
     }
     // Is this user allowed to delete this template?
     $auth = $this->user->TemplateAuth($templateId, true);
     if (!$auth->del) {
         trigger_error(__('Access denied'), E_USER_ERROR);
     }
     // Use the data class
     Kit::ClassLoader('template');
     $template = new Template($db);
     // Delete the template
     if (!$template->Delete($templateId)) {
         trigger_error($template->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('The Template has been Deleted'));
     $response->Respond();
 }
Example #2
0
 /**
  * Delete Template
  * @return <XiboAPIResponse>
  */
 public function TemplateDelete()
 {
     if (!$this->user->PageAuth('template')) {
         return $this->Error(1, 'Access Denied');
     }
     Kit::ClassLoader('Template');
     $template = new Template($this->db);
     $templateId = $this->GetParam('templateId', _INT);
     if (!$this->user->TemplateAuth($templateId)) {
         return $this->Error(1, 'Access Denied');
     }
     if (!$template->Delete($templateId)) {
         return $this->Error($layout->GetErrorNumber(), $layout->GetErrorMessage());
     }
     return $this->Respond($this->ReturnId('success', true));
 }