/** * This method is automatically called by sh_template when the admin/master * changes the template he is using.<br /> * It does everything that has to be done in this class when it occurs. * @param str $template The name of the template that will now be used. */ public function template_change($template) { // We remove the generated images from the disk $this->reset(); $this->uid = substr(md5(microtime()), 0, 6); $this->setParam('uid', $this->uid); $this->writeParams(); //Removes the cache sh_cache::removeCache(); // We check if we can rebuild the menus $menus = array_keys($this->linker->template->get('menuButtons')); foreach ($menus as $menu) { $activated = $this->getParamForMenu($menu, 'activated', true); if ($activated) { // checking if the menu may be rebuilt // We should get the texts from the database and the datas from the params file $textHeight = $this->getParamForMenu($menu, 'textHeight', 16); $font = $this->getParamForMenu($menu, 'font'); $entries = $this->getParamForMenu($menu, 'entries'); foreach ($entries as $entryId => $entry) { $categories[$entryId]['name'] = $this->getI18n($entry['title'], '*'); $categories[$entryId]['link'] = $entry['link']; } $_POST = array('real' => true, 'id' => $menu, 'font' => $font, 'textHeight' => $textHeight, 'sectionsCount' => count($entries), 'categories' => $categories, 'menuState' => true); if (!$this->verifyLength(true, $menu)) { if (is_int($menu)) { $this->setParamForMenu($menu, 'activated', false); $this->writeParamsForMenu($menu); $_SESSION[__CLASS__]['template_change_deactivated_menu'] = true; } } else { $this->updateDB($menu); } } } return true; }
public function connect($as = self::CONNECT_AS_USER) { sh_cache::removeCache(); if ($as == self::CONNECT_AS_MASTER) { $_SESSION[__CLASS__]['admin'] = true; $_SESSION[__CLASS__]['master'] = true; $_SESSION[__CLASS__]['user'] = true; $_SESSION[__CLASS__]['newConnexion'] = true; $this->admin = true; $this->master = true; $this->linker->events->onMasterConnection(); return true; } if ($as == self::CONNECT_AS_ADMIN) { $_SESSION[__CLASS__]['master'] = false; $_SESSION[__CLASS__]['admin'] = true; $_SESSION[__CLASS__]['user'] = true; $_SESSION[__CLASS__]['newConnexion'] = true; $this->master = false; $this->admin = true; $this->linker->events->onAdminConnection(); return true; } $_SESSION[__CLASS__]['admin'] = false; $_SESSION[__CLASS__]['master'] = false; $_SESSION[__CLASS__]['user'] = true; $_SESSION[__CLASS__]['newConnexion'] = true; $this->master = false; $this->admin = false; $this->linker->events->onUserConnection(); return true; }