public function regformAction()
 {
     // show reg form
     $view = Zend::registry("view");
     $view->title = "User Registration";
     print $view->render('user/regform.php');
 }
Exemple #2
0
 function __construct($config = array())
 {
     // set a Zend_Db_Adapter connection
     if (!empty($config['db'])) {
         // convenience variable
         $db = $config['db'];
         // use an object from the registry?
         if (is_string($db)) {
             $db = Zend::registry($db);
         }
         // make sure it's a Zend_Db_Adapter
         if (!$db instanceof Zend_Db_Adapter_Abstract) {
             throw new Varien_Db_Tree_Exception('db object does not implement Zend_Db_Adapter_Abstract');
         }
         // save the connection
         $this->_db = $db;
         $conn = $this->_db->getConnection();
         if ($conn instanceof PDO) {
             $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
         } elseif ($conn instanceof mysqli) {
             //TODO: ???
         }
     } else {
         throw new Varien_Db_Tree_Exception('db object is not set in config');
     }
     if (!empty($config['table'])) {
         $this->setTable($config['table']);
     }
     if (!empty($config['id'])) {
         $this->setIdField($config['id']);
     } else {
         $this->setIdField('id');
     }
     if (!empty($config['left'])) {
         $this->setLeftField($config['left']);
     } else {
         $this->setLeftField('left_key');
     }
     if (!empty($config['right'])) {
         $this->setRightField($config['right']);
     } else {
         $this->setRightField('right_key');
     }
     if (!empty($config['level'])) {
         $this->setLevelField($config['level']);
     } else {
         $this->setLevelField('level');
     }
     if (!empty($config['pid'])) {
         $this->setPidField($config['pid']);
     } else {
         $this->setPidField('parent_id');
     }
 }
Exemple #3
0
 public function routeShutdown($action)
 {
     $user = Zend::registry('user');
     if ($user->getPermission($action->getControllerName(), $action->getActionName())) {
         return $action;
     } else {
         $action->setControllerName('index');
         $action->setActionName('unauthorized');
         return $action;
     }
 }
Exemple #4
0
 /**
  * @param array $config
  * @throws LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function __construct($config = [])
 {
     // set a \Zend_Db_Adapter connection
     if (!empty($config['db'])) {
         // convenience variable
         $connection = $config['db'];
         // use an object from the registry?
         if (is_string($connection)) {
             $connection = \Zend::registry($connection);
         }
         // make sure it's a \Zend_Db_Adapter
         if (!$connection instanceof \Zend_Db_Adapter_Abstract) {
             throw new LocalizedException(new \Magento\Framework\Phrase('db object does not implement \\Zend_Db_Adapter_Abstract'));
         }
         // save the connection
         $this->_db = $connection;
         $conn = $this->_db->getConnection();
         if ($conn instanceof \PDO) {
             $conn->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
         }
     } else {
         throw new LocalizedException(new \Magento\Framework\Phrase('db object is not set in config'));
     }
     if (!empty($config['table'])) {
         $this->setTable($config['table']);
     }
     if (!empty($config['id'])) {
         $this->setIdField($config['id']);
     } else {
         $this->setIdField('id');
     }
     if (!empty($config['left'])) {
         $this->setLeftField($config['left']);
     } else {
         $this->setLeftField('left_key');
     }
     if (!empty($config['right'])) {
         $this->setRightField($config['right']);
     } else {
         $this->setRightField('right_key');
     }
     if (!empty($config['level'])) {
         $this->setLevelField($config['level']);
     } else {
         $this->setLevelField('level');
     }
     if (!empty($config['pid'])) {
         $this->setPidField($config['pid']);
     } else {
         $this->setPidField('parent_id');
     }
 }
 /**
  * Tworzy now� ankiet� i przekierowuje do akcji edytujAction
  */
 public function nowaAction()
 {
     $post = new Zend_Filter_Input($_POST);
     $user = Zend::registry('user');
     $poll = new Ankiety();
     $data = array('nazwa' => $post->getRaw('ankieta_nazwa'), 'opis' => $post->getRaw('ankieta_opis'), 'id_uzytkownik' => 1);
     try {
         $id = $poll->insert($data);
         $this->_forward('ankieter', 'edytuj', array('ankieta' => $id));
     } catch (Hamster_Validation_Exception $e) {
         $this->_forward('ankieter', 'index', array('validationError' => $e->getMessage()));
     }
 }
 /**
  * Constructor.
  *
  * @param array $config Array of user-specified config options.
  */
 public function __construct($config = null)
 {
     // set a custom Zend_Db_Adapter connection
     if (!empty($config['db'])) {
         // convenience variable
         $db = $config['db'];
         // use an object from the registry?
         if (is_string($db)) {
             $db = Zend::registry($db);
         }
         // make sure it's a Zend_Db_Adapter
         if (!$db instanceof Zend_Db_Adapter_Abstract) {
             throw new Zend_Db_Table_Exception('db object does not implement Zend_Db_Adapter_Abstract');
         }
         // save the connection
         $this->_db = $db;
     }
     // set the inflector
     self::$_inflector = new Zend_Db_Inflector();
     // continue with automated setup
     $this->_setup();
 }
 /**
  * Tests that:
  *   1. an object can be registered with register().
  *   2. attempting to register the same object throws an exception.
  *   3. the object is returned by registry('objectName').
  *   4. the object is listed in the array returned by registry().
  */
 public function testRegistry()
 {
     /**
      * Register an object
      */
     $obj = new stdClass();
     // throws exception on failure
     Zend::register('objectName', $obj);
     /**
      * Attempt to register the same object again
      */
     $e = null;
     try {
         Zend::register('another', $obj);
     } catch (Zend_Exception $e) {
         $this->assertRegExp('/duplicate(.*)objectName/i', $e->getMessage());
     }
     if ($e === null) {
         $this->fail('No exception thown during registration of duplicate object.');
     }
     /**
      * Attempt to retrieve the object with registry()
      */
     $this->assertSame(Zend::registry('objectName'), $obj);
     /**
      * Check registry listing
      */
     $this->assertEquals(Zend::registry(), array('objectName' => 'stdClass'));
 }
 public function logoutAction()
 {
     $user = Zend::registry('user');
     $user->logout();
     $this->_redirect('/index/index');
 }
Exemple #9
0
 public function __construct()
 {
     $this->db = Zend::registry('db');
 }
Exemple #10
0
<div id="bluebox">
	<div id="bluebox_body">
	
	<?php 
$user = Zend::registry('user');
if ($user->getUserId() == 0) {
    ?>
	<form action="/index/login" method="post">
	<label for="input_login">LOGIN</label>
	<div>
	<input type="text" class="input_classic" id="input_login" name="input_login">
	</div>
	<label for="input_haslo">HASŁO</label>
	<div>
	<input type="text" class="input_classic" id="input_haslo" name="input_haslo">
	</div>
	<input type="submit" value="zaloguj się" id="input_submit">
	</form>
	<?php 
} else {
    echo 'Zalogowany jako <b>' . $user->getLogin() . '</b> ';
    echo '<a href="/index/logout">wygoluj się</a>';
}
?>
	
	
	
	</div>
	<div id="bluebox_bottom"></div>
</div>
Exemple #11
0
 /**
  * Delete this record and delete its duration from the task
  * TODO: Remove once this is ported!
  */
 public function deleteRecord()
 {
     $user = za()->getUser();
     $db = Zend::registry('DbService');
     $taskId = $this->taskid;
     $select = $db->select();
     $select->from('task', '*')->where('id = ?', $taskId);
     $task = $db->getObject($select, 'task');
     if ($task == null) {
         throw new Exception("Task ID " . $taskId . " does not exist");
     }
     $toDelete = $this->endtime - $this->starttime;
     try {
         $db->delete($this, 'id=' . $this->id);
         // Get the total time for this task. $select = $db->select();
         $select = $db->select();
         $select->from('timesheetrecord', new Zend_Db_Expr('SUM(endtime - starttime) AS tasktime'))->where('taskid = ?', $taskId);
         $row = $db->fetchAll($select);
         $total = $row[0]['tasktime'];
         if ($total > 0) {
             // hours = timespent / 3600
             $task->timespent = $task->timespent - $toDelete;
             $task->save();
         }
     } catch (Exception $e) {
         $this->log->err($e->getTraceAsString());
         throw $e;
     }
 }
 /**
  * Tests that:
  *   1. an object can be registered with register().
  *   2. the object is returned by registry('objectName').
  *   3. the object is listed in the ArrayObject returned by registry().
  *   4. isRegistered() returns correct states.
  */
 public function testRegistry()
 {
     $registry = Zend::registry();
     $this->assertFalse($registry->offsetExists('objectName'));
     $subregistry = new Zend_Registry(array('option1' => 'setting1', 'option2' => 'setting2'));
     // throws exception on failure
     Zend::register('componentOptions', $subregistry);
     $this->assertTrue($registry->offsetExists('componentOptions'));
     // compare fetched value with the expected value
     $this->assertSame(Zend::registry('componentOptions'), $subregistry);
     $this->assertTrue($registry->offsetGet('componentOptions') == new Zend_Registry(array('option1' => 'setting1', 'option2' => 'setting2')));
     // Make sure a second object can be registered
     $object2 = new stdClass();
     $this->assertNotSame($subregistry, $object2);
     // throws exception on failure
     $registry->offsetSet('componentOptions', $object2);
     $this->assertTrue($registry->offsetExists('componentOptions'));
     $this->assertNotSame(Zend::registry('componentOptions'), $subregistry);
     $this->assertSame(Zend::registry('componentOptions'), $object2);
 }