/** * Check whether or not currently logged in user * can download theme with the given name. * * @param string $name * @return boolean */ public function canDownloadTheme($name) { $theme = $this->theme->where('name', $name)->first(); if ($theme) { return $this->app['sentry']->getUser()->id == $theme->user_id || $theme->type == 'public'; } }
/** * Update already existing theme. * * @param ThemeModel $theme * @param array $data * * @return ThemeModel */ public function update(ThemeModel $theme, array $data) { if (!empty($data)) { $old = json_decode($theme->modified_vars, true); //merge newly changed vars and the ones saved in database $m = array_merge(is_array($old) ? $old : array(), $data['vars']); $css = $this->less->parse('bootstrap', $m, $data['custom']); if ($theme->name != $data['name']) { $this->fs->remove('themes/' . $theme->name); } $theme->modified_vars = json_encode($m); $theme->name = $data['name']; $theme->type = $data['type']; $theme->path = $this->saveStylesheet($theme->name, $css); $theme->custom_less = $data['custom']; $theme->save(); } return $theme; }