PHP User::deleteAll Examples

PHP User::deleteAll - 16 examples found. These are the top rated real world PHP examples of User::deleteAll extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 protected function tearDown()
 {
     Lesson::deleteAll();
     Unit::deleteAll();
     Course::deleteAll();
     User::deleteAll();
 }
Example #2
0
 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if (XUtils::method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif (XUtils::method() == 'POST') {
         $command = trim($_POST['command']);
         $ids = $_POST['id'];
         is_array($ids) && ($ids = implode(',', $ids));
     } else {
         XUtils::message('errorBack', '只支持POST,GET数据');
     }
     empty($ids) && XUtils::message('error', '未选择记录');
     switch ($command) {
         case 'delete':
             parent::_acl('user_delete');
             $cityModel = new User();
             $cityModel->deleteAll('id IN(' . $ids . ')');
             AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除会员,ID:' . $ids));
             parent::_delete(new User(), $ids, array('index'));
             break;
         default:
             throw new CHttpException(404, '错误的操作类型:' . $command);
             break;
     }
 }
 /**
  * Экшен создания учетной записи администратора:
  *
  * @return nothing
  **/
 public function actionCreateuser()
 {
     $model = new InstallForm('createUser');
     if (isset($this->session['InstallForm']['createUser'])) {
         $model->setAttributes($this->session['InstallForm']['createUser']);
         if ($model->validate() && $this->session['InstallForm']['createUserStep'] === true) {
             $this->session['InstallForm'] = array_merge($this->session['InstallForm'], ['createUser' => $model->attributes, 'createUserStep' => false]);
             $this->_markFinished('createuser');
             $this->_setSession();
             $this->redirect(['/install/default/sitesettings']);
         }
     }
     if (($data = Yii::app()->getRequest()->getPost('InstallForm')) !== null) {
         // Сбрасываем сессию текущего пользователя, может поменяться id
         Yii::app()->getUser()->clearStates();
         $model->setAttributes($data);
         if ($model->validate()) {
             $user = new User();
             $user->deleteAll();
             $user->setAttributes(['nick_name' => $model->userName, 'email' => $model->userEmail, 'gender' => User::GENDER_THING, 'access_level' => User::ACCESS_LEVEL_ADMIN, 'status' => User::STATUS_ACTIVE, 'email_confirm' => User::EMAIL_CONFIRM_YES, 'hash' => Yii::app()->userManager->hasher->hashPassword($model->userPassword), 'birth_date' => null]);
             if ($user->save()) {
                 //@TODO заменить на обработку через событие
                 if (Yii::app()->hasModule('rbac')) {
                     Yii::import('application.modules.rbac.models.*');
                     $assign = new AuthAssignment();
                     $assign->itemname = AuthItem::ROLE_ADMIN;
                     $assign->userid = $user->id;
                     $assign->save();
                 }
                 $login = new LoginForm();
                 $login->email = $model->userEmail;
                 $login->password = $model->userPassword;
                 Yii::app()->authenticationManager->login($login, Yii::app()->user, Yii::app()->request);
                 Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('InstallModule.install', 'The administrator has successfully created!'));
                 $this->session['InstallForm'] = array_merge($this->session['InstallForm'], ['createUser' => $model->attributes, 'createUserStep' => true]);
                 $this->_setSession();
                 $this->redirect(['/install/default/createuser']);
             } else {
                 $model->addErrors($user->getErrors());
             }
         }
     }
     $this->render('_view', ['data' => ['model' => $model]]);
 }
Example #4
0
 /**
  * Экшен создания учетной записи администратора:
  *
  * @return nothing
  **/
 public function actionCreateuser()
 {
     $model = new InstallForm('createUser');
     if (isset($this->session['InstallForm']['createUser'])) {
         $model->setAttributes($this->session['InstallForm']['createUser']);
         if ($model->validate() && $this->session['InstallForm']['createUserStep'] === true) {
             $this->session['InstallForm'] = array_merge($this->session['InstallForm'], array('createUser' => $model->attributes, 'createUserStep' => false));
             $this->_markFinished('createuser');
             $this->_setSession();
             $this->redirect(array('/install/default/sitesettings'));
         }
     }
     if (($data = Yii::app()->getRequest()->getPost('InstallForm')) !== null) {
         // Сбрасываем сессию текущего пользователя, может поменяться id
         Yii::app()->user->clearStates();
         $model->setAttributes($data);
         if ($model->validate()) {
             $user = new User();
             $user->deleteAll();
             $user->setAttributes(array('nick_name' => $model->userName, 'email' => $model->userEmail, 'gender' => 0, 'access_level' => User::ACCESS_LEVEL_ADMIN, 'status' => User::STATUS_ACTIVE, 'email_confirm' => User::EMAIL_CONFIRM_YES, 'hash' => Yii::app()->userManager->hasher->hashPassword($model->userPassword), 'birth_date' => null));
             if ($user->save()) {
                 $login = new LoginForm();
                 $login->email = $model->userEmail;
                 $login->password = $model->userPassword;
                 Yii::app()->authenticationManager->login($login, Yii::app()->user, Yii::app()->request);
                 Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('InstallModule.install', 'The administrator has successfully created!'));
                 $this->session['InstallForm'] = array_merge($this->session['InstallForm'], array('createUser' => $model->attributes, 'createUserStep' => true));
                 $this->_setSession();
                 $this->redirect(array('/install/default/createuser'));
             } else {
                 $model->addErrors($user->getErrors());
             }
         }
     }
     $this->render('_view', array('data' => array('model' => $model)));
 }
Example #5
0
 public function testAddRename()
 {
     User::deleteAll();
     $this->_conn->addColumn('users', 'girlfriend', 'string');
     User::create(array('girlfriend' => 'bobette'));
     $this->_conn->renameColumn('users', 'girlfriend', 'exgirlfriend');
     $bob = User::find('first');
     $this->assertEquals('bobette', $bob->exgirlfriend);
 }
Example #6
0
 function testDeleteAll()
 {
     //Arrange
     //We need some categories saved into the database so that we can make sure our deleteAll method removes them all.
     $user = "HIST100";
     $password = "Abeer";
     $id = null;
     $vegie = 0;
     $admin = 1;
     $test_User = new User($user, $password, $vegie, $admin, $id);
     $user2 = "HIST100";
     $password2 = "Abeer";
     $id2 = null;
     $vegie2 = 0;
     $admin2 = 1;
     $test_User2 = new User($user2, $password2, $vegie2, $admin2, $id2);
     $test_User2->save();
     //Act
     //Delete categories.
     User::deleteAll();
     //Assert
     //Now when we call getAll, we should get an empty array because we deleted all categories.
     $result = User::getAll();
     $this->assertEquals([], $result);
 }
 protected function tearDown()
 {
     User::deleteAll();
     Category::deleteAll();
 }
Example #8
0
 public function testShouldIncludeEmptyHasManyAsEmptyArray()
 {
     User::deleteAll();
     $xml = $this->companies('maintainable')->toXml(array('include' => 'Users', 'indent' => 2));
     $array = Mad_Support_ArrayObject::fromXml($xml);
     $this->assertEquals(array(), $array['company']['users']);
     $this->assertContains('<users type="array"></users>', $xml);
 }
Example #9
0
 protected function tearDown()
 {
     User::deleteAll();
     Course::deleteAll();
 }
Example #10
0
 /**
  * @covers EMongoDocument::deleteAll
  */
 function testDeleteAll()
 {
     $c = new User();
     $c->username = 'sammaye';
     $this->assertTrue($c->save());
     $c->deleteAll();
     $r = User::model()->findOne();
     $this->assertNull($r);
     for ($i = 0; $i < 9; $i++) {
         $c = new User();
         $c->username = 'ringwraith';
         $c->mainSkill = 'LoTR';
         $this->assertTrue($c->save());
     }
     $c = new User();
     $c->username = 'gandalf';
     $c->mainSkill = 'LoTR';
     $this->assertTrue($c->save());
     $r = User::model()->find(array('mainSkill' => 'LoTR'));
     $this->assertEquals(10, $r->count());
     $c->deleteAll(array('username' => 'ringwraith'));
     $r = User::model()->find(array('mainSkill' => 'LoTR'));
     $this->assertEquals(1, $r->count());
 }
Example #11
0
 public function testGetIssetBelongsToAssociationAttribute()
 {
     $this->fixtures('users', 'articles');
     $article = Article::find(1);
     $this->assertFalse(empty($article->user));
     // remove all associated objects & recheck
     User::deleteAll();
     $article = Article::find(1);
     $this->assertTrue(empty($article->user));
 }
Example #12
0
 protected function tearDown()
 {
     User::deleteAll();
     Place::deleteAll();
     Meetup::deleteAll();
 }
 function testDeleteAll()
 {
     $c = new User();
     $c->username = 'sammaye';
     $this->assertTrue($c->save());
     $c->deleteAll();
     $r = User::model()->findOne();
     $this->assertNull($r);
 }
Example #14
0
 protected function tearDown()
 {
     User::deleteAll();
     //Project::deleteAll();
 }
Example #15
0
 function testDeleteAll()
 {
     //Arrange
     $user_name = "Barack Obama";
     $preferred_style = "IPA";
     $region = "Northwest";
     $id = 1;
     $test_user = new User($user_name, $preferred_style, $region, $id);
     $test_user->save();
     $user_name2 = "Miley Cyrus";
     $preferred_style2 = "Stout";
     $region2 = "Southeast";
     $id2 = 2;
     $test_user2 = new User($user_name2, $preferred_style2, $region2, $id2);
     $test_user2->save();
     //Act
     User::deleteAll();
     $result = User::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
Example #16
0
 function testDeleteAll()
 {
     $user_name = "Wolf";
     $user_buy_quantity = 5;
     $user_phone = '1234567890';
     $user_email = "howl@yellowstone.com";
     $activity_id = 100;
     $id = 1;
     $test_user = new User($user_name, $user_buy_quantity, $user_phone, $user_email, $activity_id, $id);
     $test_user->save();
     $user_name2 = "WolfMan";
     $id2 = 2;
     $test_user2 = new User($user_name2, $user_buy_quantity, $user_phone, $user_email, $activity_id, $id2);
     $test_user2->save();
     User::deleteAll();
     $result = User::GetAll();
     $this->assertEquals([], $result);
 }