public function up() { $this->createTable('db_user', array('primary' => 'dbUserID'), array(array('dbUserID', 'integer'), array('dbUserName', 'string', array('limit' => 20)), array('dbUserPW', 'string', array('limit' => 50)), array('dbUserFullName', 'string', array('limit' => 50, 'null' => true)), array('dbUserActive', 'string', array('limit' => 1, 'default' => 'Y')), array('ACLstring', 'text', array('null' => true, 'limit' => '1M')))); $this->createIndex('db_user', array('dbUserName')); // reset db metadata cache QFrame_Db_Table::scanDb(); // create some default data $admin = new DbUserModel(array('dbUserName' => 'admin', 'dbUserPW' => 'admin', 'dbUserFullName' => 'Administrator')); $admin->save(); $user = new DbUserModel(array('dbUserName' => 'user', 'dbUserPW' => 'user', 'dbUserFullName' => 'User')); $user->save(); }
/** * Edit action. Sets a user up to be modified or, when posted to, edits a user * and redirects to the index page. */ public function editAction() { $user = new DbUserModel(array('dbUserID' => $this->_getParam('id'))); if ($this->getRequest()->isPost()) { foreach ($this->_getParam('user') as $field => $value) { $user->{$field} = $value; } $pw = $this->_getParam('dbUserPW'); $pwConf = $this->_getParam('dbUserPWConf'); if ($pw !== '' && $pw === $pwConf) { $user->dbUserPW = $pw; } if ($pw !== $pwConf) { $this->flashNow('error', 'Passwords do not match'); $this->view->user = $user; } else { $user->save(); $this->flash('notice', 'User updated successfully'); $this->_redirector->gotoRoute(array('action' => 'index', 'id' => null)); } } else { $this->view->user = $user; } }