public function execute($request)
 {
     $this->form = new sfForm();
     $this->form->setValidator('confirmPassword', new sfValidatorString(array('required' => true)));
     $this->form->setWidget('confirmPassword', new sfWidgetFormInputPassword());
     $this->form->setValidator('email', new sfValidatorEmail(array('required' => true)));
     $this->form->setWidget('email', new sfWidgetFormInput());
     $this->form->setValidator('password', new sfValidatorString(array('required' => true)));
     $this->form->setWidget('password', new sfWidgetFormInputPassword());
     $this->form->setValidator('siteDescription', new sfValidatorString());
     $this->form->setWidget('siteDescription', new sfWidgetFormInput());
     $this->form->setValidator('siteTitle', new sfValidatorString(array('required' => true)));
     $this->form->setWidget('siteTitle', new sfWidgetFormInput());
     $this->form->setValidator('username', new sfValidatorString(array('required' => true)));
     $this->form->setWidget('username', new sfWidgetFormInput());
     $this->form->getValidatorSchema()->setPostValidator(new sfValidatorSchemaCompare('password', '==', 'confirmPassword'));
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $setting = new QubitSetting();
             $setting->name = 'siteTitle';
             $setting->value = $this->form->getValue('siteTitle');
             $setting->save();
             $setting = new QubitSetting();
             $setting->name = 'siteDescription';
             $setting->value = $this->form->getValue('siteDescription');
             $setting->save();
             $user = new QubitUser();
             $user->username = $this->form->getValue('username');
             $user->email = $this->form->getValue('email');
             $user->setPassword($this->form->getValue('password'));
             $user->save();
             $aclUserGroup = new QubitAclUserGroup();
             $aclUserGroup->userId = $user->id;
             $aclUserGroup->groupId = QubitAclGroup::ADMINISTRATOR_ID;
             $aclUserGroup->save();
             $this->redirect(array('module' => 'sfInstallPlugin', 'action' => 'clearCache'));
         }
     }
 }
 /**
  * Updates user's access privileges from Shibboleth data
  *
  * @param QubitUser $user the current user
  * @param sfWebRequest $request the current web request
  *
  */
 protected function updateUserFromShibInfo($request, $user)
 {
     $params = $request->getPathInfoArray();
     $isMemberOf = explode(";", $params['isMemberOf']);
     // read group mapping from config file
     $mapings = array('ADMINISTRATOR_ID' => explode(';', sfConfig::get('app_shibboleth_administrator_groups')), 'EDITOR_ID' => explode(';', sfConfig::get('app_shibboleth_editor_groups')), 'CONTRIBUTOR_ID' => explode(';', sfConfig::get('app_shibboleth_contributor_groups')), 'TRANSLATOR_ID' => explode(';', sfConfig::get('app_shibboleth_translator_groups')));
     // for each privilege class, check whether the current user should have it and assign it if not yet assigned
     foreach ($mapings as $key => $array) {
         if (0 < count(array_intersect($array, $isMemberOf))) {
             if (!$user->hasGroup(constant("QubitAclGroup::{$key}"))) {
                 $aclUserGroup = new QubitAclUserGroup();
                 $aclUserGroup->userId = $user->id;
                 $aclUserGroup->groupId = constant("QubitAclGroup::{$key}");
                 $aclUserGroup->save();
             }
         } else {
             // remove the user from groups he should not be in
             if ($user->hasGroup(constant("QubitAclGroup::{$key}"))) {
                 foreach ($user->aclUserGroups as $membership) {
                     if ($membership->groupId == constant("QubitAclGroup::{$key}")) {
                         $membership->delete();
                     }
                 }
             }
         }
     }
     return true;
 }