Esempio n. 1
0
 /**
  * Create a new theme.
  * 
  * @param  array $data 
  * 
  * @return ThemeModel
  */
 public function create(array $data)
 {
     $css = $this->less->parse('bootstrap', $data['vars'], $data['custom']);
     $path = $this->saveStylesheet($data['name'], $css);
     //save theme to database
     $this->model->path = $path;
     $this->model->name = $data['name'];
     $this->model->type = $data['type'];
     $this->model->custom_less = $data['custom'];
     $this->model->user_id = Sentry::getUser()->id;
     if (!empty($vars)) {
         $this->model->modified_vars = json_encode($vars);
     }
     $this->model->save();
     return $this->model;
 }
Esempio n. 2
0
 public function delete($id)
 {
     if (!$this->app['sentry']->getUser()->hasAccess('themes.delete')) {
         return new Response($this->app['translator']->trans('noPermThemeDelete'), 403);
     }
     return new Response($this->model->destroy($id), 204);
 }
Esempio n. 3
0
 /**
  * Delete template with given id from database.
  * 
  * @param  string/int $id
  * @return Response
  */
 public function delete($id)
 {
     if (!$this->app['sentry']->getUser()->hasAccess('templates.delete')) {
         return new Response($this->app['translator']->trans('noPermTemplateDelete'), 403);
     }
     $template = $this->model->where('id', $id)->first();
     if (!$template) {
         return new Response($this->app['translator']->trans('noTemplateWithId'), 400);
     }
     if ($template->type == 'base' || $template->user_id != Sentry::getUser()->id) {
         return new Response($this->app['translator']->trans('noPermissionsToDeleteTemplate'), 403);
     }
     $template->pages()->delete();
     $template->destroy($id);
     return new Response($this->app['translator']->trans('templateDeleteSuccess'), 204);
 }