예제 #1
0
 public function createuserAction()
 {
     $t = Doctrine::getTable('User_Model_User');
     try {
         $c = $t->count();
         if ($c > 0) {
             $this->_helper->redirector->gotoSimple('success', 'install', 'install');
         } else {
             $this->view->form = new Install_Form_InstallUser();
             if ($this->request->isPost()) {
                 if ($this->view->form->isValid($_POST)) {
                     $values = $this->view->form->getValues();
                     $user = new User_Model_User();
                     $user->name = $values['username'];
                     $user->setPassword($values['password1']);
                     $user->email = $values['email'];
                     $user->save();
                     $ur = new User_Model_Role();
                     $ur->User_Model_User = $user;
                     $ur->role_name = 'admin_admin';
                     $ur->save();
                     $this->_helper->redirector->gotoSimple('success', 'install', 'install');
                 }
             }
         }
     } catch (Doctrine_Exception $e) {
         $this->_helper->redirector->gotoSimple('index', 'install', 'install');
     }
 }
예제 #2
0
 public function testDatabase()
 {
     // first migrate database if needed
     if (Install_Api_Migration::getInstance()->getCurrentVersion() < Install_Api_Migration::getInstance()->getLatestVersion()) {
         Install_Api_Migration::getInstance()->migrate();
     }
     $api = new Devtools_Api_DoctrineTool();
     // truncate all tables or import data if there is some
     $api->importFixtures(APPLICATION_PATH . '/resource/fixtures');
     // create an admin user for unit testing
     $user = new User_Model_User();
     $user->name = 'PHPUnit';
     $user->password = '******';
     $user->email = '*****@*****.**';
     $user->description = 'PHPUnit Testuser';
     $user->activated = 'yes';
     $user->active = 'no';
     $user->show_team = 'no';
     $user->save();
     $role = new User_Model_Role();
     $role->link('User_Model_User', array($user->id));
     $role->role_name = 'admin_admin';
     $role->save();
 }
예제 #3
0
파일: User.php 프로젝트: KasaiDot/FansubCMS
 public function updateProfile(array $values)
 {
     $this->name = $values['username'];
     if (!empty($values['password1'])) {
         $this->password = $values['password1'];
     }
     $this->description = $values['description'];
     $this->email = $values['email'];
     $this->active = $values['active'];
     $this->activated = $values['activated'];
     $this->show_team = $values['show_team'];
     # save
     $this->save();
     # add roles
     if (is_array($values['roles'])) {
         foreach ($this->User_Model_Role as $role) {
             $role->delete();
         }
         foreach ($values['roles'] as $role) {
             $r = new User_Model_Role();
             $r->user_id = $this->id;
             $r->role_name = $role;
             $r->save();
         }
     }
     if (is_array($values['tasks'])) {
         $unlink = array();
         foreach ($this->User_Model_UserTask as $task) {
             $task->delete();
         }
         foreach ($values['tasks'] as $task) {
             $ut = new User_Model_UserTask();
             $ut->task_id = $task;
             $ut->user_id = $this->id;
             $ut->save();
         }
     }
 }