Example #1
0
 /**
  * Install a theme
  *
  * @param   string	$theme_name Theme name
  * @return  void
  */
 public function install($theme_name)
 {
     $msg = null;
     // check permission
     $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], '_theme_install', 0, 4);
     if (is_null($msg)) {
         $qs = X4Route_core::get_query_string();
         // perform the install
         $theme = new Theme_model();
         $result = $theme->install($theme_name);
         // if result is an array an error occurred
         if (is_array($result)) {
             $this->notice(false, '_theme_not_installed');
             die;
         } else {
             // installed
             // set message
             $this->dict->get_words();
             $msg = AdmUtils_helper::set_msg(true);
             // add permission on new theme
             if ($result) {
                 $perm = new Permission_model();
                 $array[] = array('action' => 'insert', 'id_what' => $result, 'id_user' => $_SESSION['xuid'], 'level' => 4);
                 $result = $perm->pexec('themes', $array, 1);
                 // refactory permissions
                 $perm->refactory_table($_SESSION['xuid'], array(1), 'themes');
                 $perm->refactory_table($_SESSION['xuid'], array(1), 'templates');
                 $perm->refactory_table($_SESSION['xuid'], array(1), 'menus');
             }
             $msg->update[] = array('element' => 'tdown', 'url' => BASE_URL . 'themes', 'title' => null);
         }
     }
     $this->response($msg);
 }