Beispiel #1
0
 protected function display()
 {
     // Admins only
     if (Tools::isConnectedUser()) {
         $session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
         if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
             $this->smartyHelper->assign('defaultColor', Holidays::$defaultColor);
             if (isset($_POST['hol_color'])) {
                 $formatedDate = Tools::getSecurePOSTStringValue('date');
                 $timestamp = Tools::date2timestamp($formatedDate);
                 $hol_desc = Tools::getSecurePOSTStringValue('hol_desc');
                 $hol_color = Tools::getSecurePOSTStringValue('hol_color');
                 if (!Holidays::save($timestamp, $hol_desc, $hol_color)) {
                     $this->smartyHelper->assign('error', T_("Couldn't add the holiday"));
                 }
             } elseif (isset($_POST['hol_id'])) {
                 $hol_id = Tools::getSecurePOSTIntValue('hol_id');
                 if (!Holidays::delete($hol_id)) {
                     $this->smartyHelper->assign('error', T_("Couldn't remove the holiday"));
                 }
             }
             $this->smartyHelper->assign('holidays', Holidays::getHolidays());
         }
     }
 }