当前位置: 首页>>代码示例>>PHP>>正文


PHP sfGuardUser::addGroupByName方法代码示例

本文整理汇总了PHP中sfGuardUser::addGroupByName方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::addGroupByName方法的具体用法?PHP sfGuardUser::addGroupByName怎么用?PHP sfGuardUser::addGroupByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfGuardUser的用法示例。


在下文中一共展示了sfGuardUser::addGroupByName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doSave

 public function doSave($con = null)
 {
     if ($this->isNew) {
         $user = new sfGuardUser();
         $user->setUsername($this->getValue('username'));
         $user->setPassword($this->getValue('password'));
         $user->setEmailAddress($this->getValue('email'));
         $user->addGroupByName(sfConfig::get('app_user_default_group'));
         // They must confirm their account first
         $user->setIsActive(false);
         $user->save();
         $this->getObject()->setUserId($user->getId());
     }
     return parent::doSave($con);
 }
开发者ID:hielh,项目名称:abjihproject,代码行数:15,代码来源:sfGuardUserProfileForm.class.php

示例2: executeIdentification

 public function executeIdentification(sfWebRequest $request)
 {
     if (!$this->getUser()->isAuthenticated()) {
         $this->formInscription = new InscriptionForm();
         $class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin');
         $this->form = new $class();
         if ($request->ismethod('post')) {
             if ($request->getParameter('send') == "signin") {
                 $this->form->bind($request->getParameter('signin'));
                 if ($this->form->isValid()) {
                     $values = $this->form->getValues();
                     $this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false);
                     if ($this->getUser()->getAttribute('montantLocation')) {
                         $paypal = new PayPal();
                         $ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture');
                         print_r($ret);
                     } else {
                         $this->redirect('espace_membre_profil');
                     }
                 }
             } else {
                 if ($request->getParameter('send') == "signup") {
                     $this->formInscription->bind($request->getParameter('signup'));
                     if ($this->formInscription->isValid()) {
                         $values = $this->formInscription->getValues();
                         //print_r($values);
                         //exit;
                         $user = new sfGuardUser();
                         $user->setEmailAddress($values['email_address']);
                         $user->setUsername($values['email_address']);
                         $user->setLastName($values['nom']);
                         $user->setFirstName($values['prenom']);
                         $user->setPassword($values['password1']);
                         $user->setIsActive(1);
                         $user->getProfile()->setAdresse($values['adresse']);
                         $user->getProfile()->setCodepostal($values['codepostal']);
                         $user->getProfile()->setVille($values['ville']);
                         $user->getProfile()->setFixe($values['fixe']);
                         $user->getProfile()->setMobile($values['mobile']);
                         $user->getProfile()->setDateNaissance($values['date_naissance']);
                         $user->getProfile()->setNumeroPermis($values['numero_permis']);
                         $user->getProfile()->setVilleDelivrance($values['ville_permis']);
                         $user->getProfile()->setPaysDelivrance($values['pays_permis']);
                         $user->getProfile()->setDateDelivrance($values['date_delivrance_permis']);
                         $user->getProfile()->setIsActivated(1);
                         $user->addGroupByName("client");
                         $user->save();
                         $this->getUser()->setAttribute('email_address', $values['email_address']);
                         $message = $this->getMailer()->compose(sfConfig::get('app_mail_saidi'), $values['email_address'], '[Mobilyrent] - Inscription Mobilyrent location de voiture', '[Mobilyrent] - Inscription Mobilyrent location de voiture');
                         $this->getMailer()->send($message);
                         //echo $this->getUser()->getAttribute('montantLocation');exit;
                         if ($this->getUser()->getAttribute('montantLocation')) {
                             $paypal = new PayPal();
                             $ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture');
                             print_r($ret);
                         }
                         //$this->getUser()->setFlash('notice', sprintf('Inscription terminée.<br/>Un email vous a été envoyé. Connectez vous et continuer votre reservation.'));
                     }
                 }
             }
         }
     } else {
         $paypal = new PayPal();
         $ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture');
         print_r($ret);
     }
 }
开发者ID:sfinx13,项目名称:appsmartproject,代码行数:67,代码来源:_actions.class.php

示例3: executeInvite

 public function executeInvite($request)
 {
     $this->user_invite_form = new UserInviteForm();
     if ($request->isMethod('post')) {
         $userParams = $request->getParameter('user');
         $this->user_invite_form->bind($userParams);
         if ($this->user_invite_form->isValid()) {
             $db = Doctrine_Manager::connection();
             try {
                 $db->beginTransaction();
                 //create user
                 $user = new sfGuardUser();
                 $user->username = $userParams['email'];
                 $user->algorithm = 'sha1';
                 $user->setPassword('pending');
                 $user->is_active = false;
                 $user->addGroupByName($userParams['group']);
                 $user->save();
                 //create user profile
                 $profile = new sfGuardUserProfile();
                 $profile->user_id = $user->id;
                 $profile->name_first = $userParams['name_first'];
                 $profile->name_last = $userParams['name_last'];
                 $profile->email = $userParams['email'];
                 $profile->is_visible = false;
                 $profile->invitation_code = substr(sha1($profile->getEmail() . time()), 0, 10);
                 $profile->save();
                 //send welcome email
                 $mailBody = $this->getPartial($userParams['template'], array('profile' => $profile));
                 $mailer = new Swift(new Swift_Connection_NativeMail());
                 $message = new Swift_Message("You're invited to become a LittleSis analyst!", $mailBody, 'text/plain');
                 $address = new Swift_Address(sfConfig::get('app_mail_invite_sender_address'), sfConfig::get('app_mail_invite_sender_name'));
                 $mailer->send($message, $profile->email, $address);
                 $mailer->disconnect();
                 //all's well, commit transaction
                 $db->commit();
             } catch (Exception $e) {
                 $db->rollback();
                 throw $e;
             }
             $this->redirect('user/list');
         }
         //gather errors
         $this->errors = $this->user_invite_form->getErrorSchema()->getErrors();
     }
 }
开发者ID:silky,项目名称:littlesis,代码行数:46,代码来源:actions.class.php

示例4: executeUpdate


//.........这里部分代码省略.........
             $c->add(pmProjectsPeer::CLIENT_ID, $client_user_id);
             $c->addDescendingOrderByColumn(pmProjectsPeer::CREATED_AT);
             $this->project = pmProjectsPeer::doSelectOne($c);
         }
         $this->form->bind($form_data);
         if ($this->form->isValid()) {
             $status = sfConfig::get('mod_client_opportunity_accountstatus');
             $form_data['account_status'] = accountStatusPeer::getStatusId($status[$client_rank]) + 1;
             if ($this->form->isNew()) {
                 $form_data['created_by_id'] = $sf_user_id;
                 $form_data['created_at'] = date('Y-m-d H:i:s');
                 $form_data['updated_at'] = date('Y-m-d H:i:s');
                 $form_data['updated_by_id'] = $sf_user_id;
                 /*
                  *  save client instance into sfguard
                  */
                 $sf_object = new sfGuardUser();
                 $tools_obj = new myTools();
                 /*
                  * login infomation
                  */
                 if (!array_key_exists('username', $login_details) || !$login_details['username']) {
                     $client_username = $tools_obj->RandomUsernameGenerator();
                     $sf_object->setUsername($client_username);
                 } else {
                     $sf_object->setUsername($login_details['username']);
                 }
                 if (!array_key_exists('password', $login_details) || !$login_details['password']) {
                     $sf_object->setPassword($tools_obj->randomPasswordGenerator());
                 } else {
                     $sf_object->setPassword($login_details['username']);
                 }
                 $sf_object->save();
                 $sf_object->addGroupByName('client');
                 $new_user_id = $sf_object->getId();
                 $form_data['user_id'] = $new_user_id;
                 $enquiry_details = new Inquiry();
                 $enquiry_details->setUserId($new_user_id);
                 if ($login_details['budget'] != '') {
                     $enquiry_details->setBudget($login_details['budget']);
                 }
                 if ($login_details['expected_close_date'] != '') {
                     $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime($login_details['expected_close_date'])));
                 } elseif ($login_details['expected_close_date'] == '') {
                     $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime(date('Y-m-01') . ' +6 month')));
                 }
                 $enquiry_details->save();
                 /*
                  *  save instance into branch users
                  */
                 $branch_object = new BranchUsers();
                 $branch_object->addBranchUser($new_user_id, $branch_id);
                 // set intance into company users
                 $company_object = new CompanyUsers();
                 $company_object->addCompanyUser($new_user_id, $company_id);
             } else {
                 $enquiry_id = InquiryPeer::getEnquiryId($client_user_id);
                 $enquiry_details = InquiryPeer::retrieveByPK($enquiry_id);
                 if ($enquiry_details) {
                     $enquiry_details->setBudget($login_details['budget']);
                     $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime($login_details['expected_close_date'])));
                     $enquiry_details->save();
                 } else {
                     $enquiry_details = new Inquiry();
                     $enquiry_details->setUserId($client_login->getId());
                     if ($login_details['budget'] != '') {
开发者ID:uniraymond,项目名称:ravebuild_symfony,代码行数:67,代码来源:actions.class.php

示例5: Doe

$activeUser->first_name = 'John';
$activeUser->last_name = 'Doe';
$activeUser->email_address = 'email2@test.com';
$activeUser->username = 'active_user';
$activeUser->password = 'password';
$activeUser->is_active = true;
$activeUser->save();
// ->__toString()
$t->diag('output functions');
$t->is((string) $activeUser, 'John Doe (active_user)', '->__toString() returns the full name and the username');
$t->is($activeUser->getName(), 'John Doe', '->getName() returns the full name of the user');
// group managment
$t->diag('group managment');
$t->is($activeUser->getGroupNames(), array(), '->getGroupNames() return empty array if no group is set');
try {
    $activeUser->addGroupByName('test-group');
    $t->fail('->addGroupByName() does throw an exception if group not exist');
} catch (Exception $e) {
    $t->pass('->addGroupByName() does throw an exception if group not exist');
}
$group = new sfGuardGroup();
$group->name = 'test-group';
$group->save();
$t->is($activeUser->hasGroup('test-group'), false, '->hasGroup() return false if user hasn\'t this group');
try {
    $activeUser->addGroupByName('test-group');
    $t->pass('->addGroupByName() does not throw an exception if group exist');
} catch (Exception $e) {
    $t->diag($e->getMessage());
    $t->fail('->addGroupByName() does not throw an exception if group exist');
}
开发者ID:limitium,项目名称:uberlov,代码行数:31,代码来源:PluginsfGuardUserTest.php

示例6: ajouterUtilisateur

 public function ajouterUtilisateur($values)
 {
     $user = new sfGuardUser();
     $user->setEmailAddress($values['email_address']);
     $user->setUsername($values['email_address']);
     $user->setLastName($values['nom']);
     $user->setFirstName($values['prenom']);
     $user->setPassword($values['password1']);
     $user->setIsActive(1);
     $user->getProfile()->setAdresse($values['adresse']);
     $user->getProfile()->setCodepostal($values['codepostal']);
     $user->getProfile()->setVille($values['ville']);
     $user->getProfile()->setFixe($values['fixe']);
     $user->getProfile()->setMobile($values['mobile']);
     $user->getProfile()->setDateNaissance($values['date_naissance']);
     $user->getProfile()->setNumeroPermis($values['numero_permis']);
     $user->getProfile()->setVilleDelivrance($values['ville_permis']);
     $user->getProfile()->setPaysDelivrance($values['pays_permis']);
     $user->getProfile()->setDateDelivrance($values['date_delivrance_permis']);
     $user->getProfile()->setIsActivated(1);
     $user->addGroupByName("client");
     $user->save();
     $this->getUser()->setAttribute('email_address', $values['email_address']);
     return $user;
 }
开发者ID:sfinx13,项目名称:appsmartproject,代码行数:25,代码来源:actions.class.php


注:本文中的sfGuardUser::addGroupByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。