示例#1
0
 function startup()
 {
     parent::startup();
     $cache = NEnvironment::getCache();
     if (!isset($cache['acl'])) {
         $cache['acl'] = new Acl();
     }
     NEnvironment::getUser()->setAuthorizator($cache['acl']);
     $user = NEnvironment::getUser();
     $aclModel = new AclModel();
     // user authentication
     if (!$this->user->isLoggedIn()) {
         $backlink = $this->application->storeRequest();
         $this->redirect(':Admin:Login:default', array('backlink' => $backlink, 'lang' => $this->lang));
     }
     if (!$this->user->isAllowed('cms', 'edit')) {
         $this->flashMessage('Nemáte dostatočné prava.');
         $backlink = $this->application->storeRequest();
         $this->redirect(':Admin:Login:default', array('backlink' => $backlink, 'lang' => $this->lang));
     }
     //		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
     $this['header']['css']->addFile('../templates/admin/css/index.css');
     $this['header']['css']->addFile('ajax.css');
     $this['header']['css']->addFile('../jscripts/jquery/flick/jquery-ui-1.8.6.custom.css');
     $this['header']['css']->addFile('../jscripts/jquery/tags/jquery.tagsinput.css');
     $this['header']['js']->addFile('jquery/tags/jquery.tagsinput.js');
     //		$this['header']['js']->addFile('/jquery/jquery-1.4.2.js');
     $this['header']['js']->addFile('/jquery/jquery.nette.js');
     $this['header']['js']->addFile('/jquery/jquery.livequery.js');
     $this['header']['js']->addFile('jquery/jquery-ui-1.8.5.custom.min.js');
     $this['header']['js']->addFile('jquery/jquery.highlight.js');
     $this['header']['js']->addFile('jquery/jquery.easy-confirm-dialog.js');
     $this['header']['js']->addFile('confl.js');
     //		$this['header']->setHtmlTag( NHtml::el('script type="text/javacript"')->add( 'alert(1)' ) );
 }
示例#2
0
 function showUsers()
 {
     $user = NEnvironment::getUser();
     if (!$user->isAllowed('manage_user', 'edit')) {
         throw new LogicException('Nemáte dostatočné oprávnenie na túto sekciu');
     }
     try {
         //uprava uzivatela
         if (isset($_GET['id_auth_user']) and $_GET['id_auth_user'] != "") {
             $form = new NForm();
             $form->addText('name', 'Meno');
             $form->addText('surname', 'Priezvisko');
             $form->addText('email', 'Email');
             $form->addText('login', 'Login')->addRule(NFORM::FILLED, 'Login musí byť vyplnený');
             $form->addPassword('password', 'Heslo');
             $role = dibi::query('SELECT id_auth_role, key_name FROM auth_role ORDER BY key_name')->fetchPairs('id_auth_role', 'key_name');
             $form->addPassword('password2', 'Znova heslo')->addConditionOn($form['password'], NForm::FILLED)->addRule(NForm::FILLED, 'Zadejte heslo pro kontrolu')->addRule(NForm::EQUAL, 'Hesla se musi shodovat', $form['password']);
             $form->addSelect('id_auth_role', 'Uživateľská skupina:', $role);
             $form->addSubmit('addUser', 'Upravit');
             $form->onSubmit[] = array($this, 'changeUser');
             if (!$form->isSubmitted()) {
                 // 	první zobrazení, nastavíme výchozí hodnoty
                 $form->setDefaults(dibi::fetch("SELECT *, id_auth_role FROM auth_user LEFT JOIN [auth_user_role] USING(id_auth_user) WHERE auth_user.id_auth_user=%i", $_GET['id_auth_user']));
             }
             $form->fireEvents();
             MT::addTemplate(APP_DIR . '/require_modules/authentication/editUser.phtml', 'editUser');
             MT::addVar('editUser', 'form', (string) $form);
         }
     } catch (Exception $e) {
         ?>
   <div style="border:2px solid red;padding:5px;">
     <?php 
         echo $e->getMessage();
         ?>
   </div><?php 
     }
     if (!isset($_GET['id_auth_user'])) {
         if (isset($_GET['id_delete_user'])) {
             $this->deleteUser();
         }
         $form = new NForm();
         $form->getElementPrototype()->id = 'formAddUser';
         $form->addText('name', 'Meno');
         $form->addText('surname', 'Priezvisko');
         $form->addText('email', 'Email');
         $form->addText('login', 'Login')->addRule(NFORM::FILLED, 'Login musí byť vyplnený');
         $form->addPassword('password', 'Heslo')->addRule(NForm::FILLED, 'Zadejte heslo');
         $role = dibi::query('SELECT id_auth_role, key_name FROM [auth_role] ORDER BY key_name')->fetchPairs('id_auth_role', 'key_name');
         $form->addPassword('password2', 'Znova heslo')->addRule(NForm::FILLED, 'Zadejte heslo pro kontrolu')->addRule(NForm::EQUAL, 'Hesla se musi shodovat', $form['password']);
         $form->addSelect('id_auth_role', 'Uživateľská skupina:', $role);
         $form->addSubmit('addUser', 'Pridať použivateľa');
         $form->onSubmit[] = array($this, 'addUser');
         $form->fireEvents();
         MT::addTemplate(APP_DIR . '/require_modules/authentication/showUsers.phtml', 'showUsers');
         $list = dibi::fetchAll("\n      \tSELECT \n      \t\t*\n      \tFROM \n      \t\tauth_user\n      \tORDER BY login");
         MT::addVar('showUsers', 'list', $list);
         MT::addVar('showUsers', 'form', $form);
     }
 }
示例#3
0
 public function actionSummary()
 {
     if (!NEnvironment::getUser()->isLoggedIn()) {
         $this->redirect('Cart:default');
     }
     $session = NEnvironment::getSession('cart');
     if ($session->delivery_address == NULL) {
         $user = NEnvironment::getUser()->getIdentity()->data;
         $session->delivery_address = $user;
     }
     $this->template->s = $session;
 }
示例#4
0
 function onSubmitAuthenticate(NFORM $form)
 {
     $values = $form->getValues();
     $this->invalidateControl('login');
     $this->invalidateControl('minilogin');
     //		$this->invalidateControl('classs');
     $user = NEnvironment::getUser();
     try {
         $user->setExpiration('+ 2 days', FALSE);
         //			$user->setAuthenticationHandler ( new UserModel() );
         $user->login($values['login'], $values['password']);
         $form->setValues(array(), TRUE);
         if ($values['backlink'] != '') {
             $this->getPresenter()->redirectUrl($values['backlink']);
         } else {
             //$this->getPresenter()->redirect('this');
         }
     } catch (NAuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }
示例#5
0
 public function handleLogout()
 {
     NEnvironment::getUser()->logout();
     $this->flashMessage('Byl(a) jste úspěšně odhlášen(a).');
     $this->redirect('Default');
 }
示例#6
0
    function nodeAction()
    {
        $node = NodeModel::init();
        //-------------------------------//
        //--------AJAX REQUEST-----------//
        //------------------------------//
        if (@$_GET['ajax_change_modul_position']) {
            if (is_numeric(@$_GET['id_node_ajax']) and is_numeric($_GET['position'])) {
                dibi::query("UPDATE node SET position=%i", $_GET['position'], " WHERE id_node=%i", $_GET['id_node_ajax']);
                $node->invalidateCache();
            }
            exit;
        }
        if (@$_GET['ajax_change_modul_visible']) {
            if (is_numeric(@$_GET['id_node_ajax']) and is_numeric($_GET['modul_visible'])) {
                dibi::query("UPDATE node SET visible=%s", $_GET['modul_visible'], " WHERE id_node=%i", $_GET['id_node_ajax']);
            }
            $node->invalidateCache();
            //      	echo dibi::$sql;
            exit;
        }
        //------SITE MAP pre premiestnenie modulu
        if (isset($_GET['ajax_show_site_map_for_modul'])) {
            $m = new MenuItem();
            $m->doTreeSelectMoveModul(0, 0, $_GET['id_menu_item'], $_GET['id_type_modul']);
            echo '<form action="" method="post">
        		<select name="id_menu_item_for_change">';
            echo $m->doTreeSelectMoveModulText;
            echo '<input type="hidden" name="id_type_modul" value="' . htmlspecialchars($_GET['id_type_modul']) . '" />
		       <input type="hidden" name="id_node" value="' . htmlspecialchars($_GET['id_node']) . '" />
		       <input type="submit" name="changeModulParent" value="Ulož" /> 
      		</form>';
            exit;
        }
        if (isset($_POST['changeModulParent'])) {
            $this->changeModulParent();
            $node->invalidateCache();
            header("Location: ?id_menu_item=" . $_POST['id_menu_item_for_change'] . "&showModulsOnPage=1");
            exit;
        }
        if (isset($_GET['id_menu_item']) and isset($_GET['id_type_modul']) and isset($_GET['id_modul'])) {
            if (!dibi::fetchSingle("SELECT COUNT(*) FROM node WHERE id_menu_item=%i", $_GET['id_menu_item'], " AND id_type_modul=%i", $_GET['id_type_modul'], " AND id_node=%i", $_GET['id_modul'])) {
                header("Location:admin.php");
                exit;
            }
        }
        if (isset($_GET['addnode']) and isset($_GET['id_type_modul']) or isset($_POST['addModulToMenu'])) {
            if (isset($_POST['addModulToMenu'])) {
                $id_type_modul = $_POST['id_type_modul'];
            } else {
                $id_type_modul = $_GET['id_type_modul'];
            }
            $sequence = dibi::fetchSingle("SELECT MAX(sequence) FROM node WHERE id_menu_item=%i", $_GET['id_menu_item']) + 1;
            $session = NEnvironment::getSession('Authentication');
            $config = NEnvironment::getConfig();
            $arr = array('id_user' => NEnvironment::getUser()->getIdentity()->id, 'id_menu_item' => $_GET['id_menu_item'], 'sequence' => $sequence, 'id_type_modul' => $id_type_modul, 'visible' => $config['NODE_VISIBLE']);
            dibi::query("INSERT INTO node ", $arr);
            $this->addModul(dibi::insertId(), $id_type_modul);
            $node->invalidateCache();
        }
        //zmenenie poradia
        if (isset($_GET['modul_id_up']) or isset($_GET['modul_id_down'])) {
            $this->changeOrderNode();
            $node->invalidateCache();
            header("Location: admin.php?id_menu_item=" . $_GET['id_menu_item'] . "&showModulsOnPage=1");
            exit;
        }
        //ak je iba jeden modul, hned sa zobrazi ale iba ak nieje setnuta section a showModulsOnPage
        if (isset($_GET['id_menu_item']) and !isset($_GET['id_type_modul']) and !isset($_GET['section']) and !isset($_GET['showModulsOnPage']) and !isset($_GET['changeMenuItem'])) {
            $l = dibi::fetch("SELECT *, COUNT(*) as node_count FROM node WHERE id_menu_item=%i", $_GET['id_menu_item'], " ORDER BY sequence");
            if ($l['node_count'] == 1) {
                header("Location: admin.php?id_menu_item=" . $_GET['id_menu_item'] . "&id_type_modul=" . $l['id_type_modul'] . "&id_modul=" . $l['id_node']);
                exit;
            }
        }
        //pridanie do premenej activeModul instanciu objektu
        if (isset($_GET['id_type_modul']) and isset($_GET['id_modul'])) {
            $this->activeModul = $this->nodeFactory($_GET['id_type_modul']);
            $this->activeModul->action();
        }
        if (isset($_GET['id_modul_del']) and is_numeric($_GET['id_modul_del'])) {
            $this->deleteNode(NULL, $_GET['id_modul_del']);
            $node->invalidateCache();
            header("Location: admin.php?id_menu_item=" . $_GET['id_menu_item']);
            exit;
        }
    }
示例#7
0
 function getUser()
 {
     return NEnvironment::getUser();
 }
示例#8
0
$neon = new NConfigNeonAdapter();
$n = $neon->load(APP_NETTE_DIR . '/config/config.db.neon');
$database = $n['common']['parameters'];
foreach ($database as $k => $p) {
    NEnvironment::setVariable($k, $p);
}
//var_dump($d);exit;
//$config = NEnvironment::loadConfig(APP_NETTE_DIR.'/config/config.db.neon');
$session = NEnvironment::getSession();
//$session->setSavePath(APP_NETTE_DIR . '/sessions');
//$session->setExpiration("1 day");
$session->start();
try {
    dibi::connect(NEnvironment::getConfig()->database);
} catch (Exception $e) {
    // echo $e->getMessage();
    echo "Nepodarilo sa pripojit";
    exit;
}
$cache = NEnvironment::getCache();
if (!isset($cache['acl'])) {
    $cache['acl'] = new Acl();
}
//print_r($cache['acl']);
NEnvironment::getUser()->setAuthorizator($cache['acl']);
$user = NEnvironment::getUser();
$aclModel = new AclModel();
//NDebug::dump($aclModel->getRoles());
//NDebug::dump($aclModel->getResources());
//NDebug::fireLog($aclModel->getRules());
//Log::addGlobalLog();
示例#9
0
 function actionLogOut($backlink = 'Front_Homepage')
 {
     NEnvironment::getUser()->logout();
     $this->redirectUrl($backlink);
 }