예제 #1
0
 public function createUser(RegistrationForm $form, Profile $profile)
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $user = new User('registration');
         $data = $form->getAttributes();
         unset($data['cPassword'], $data['verifyCode']);
         $user->setAttributes($data);
         $user->hash = $this->hasher->hashPassword($form->password);
         $user->role = User::USER_ROLE;
         if ($user->save() && ($token = $this->tokenStorage->createAccountActivationToken($user)) !== false) {
             $profile->user_id = $user->id;
             if (!$profile->save()) {
                 throw new CException(Yii::t('UserModule.user', 'Error creating profile!'));
             }
             Yii::log(Yii::t('UserModule.user', 'Account {nick_name} was created', array('{nick_name}' => $user->email)), CLogger::LEVEL_INFO, UserModule::$logCategory);
             //@TODO
             Yii::app()->notify->send($user, Yii::t('UserModule.user', 'Registration on {site}', array('{site}' => Yii::app()->getModule('yupe')->siteName)), '//user/email/needAccountActivationEmail', array('token' => $token));
             Yii::app()->notify->sendAdmin('Новый пользователь на сайте ' . CHtml::encode(Yii::app()->getModule('yupe')->siteName), '//user/email/newUserEmail', array('user' => $user));
             $transaction->commit();
             return $user;
         }
         throw new CException(Yii::t('UserModule.user', 'Error creating account!'));
     } catch (Exception $e) {
         Yii::log(Yii::t('UserModule.user', 'Error {error} account creating!', array('{error}' => $e->__toString())), CLogger::LEVEL_INFO, UserModule::$logCategory);
         $transaction->rollback();
         return false;
     }
 }
예제 #2
0
 public function getIndex()
 {
     $campaign = new Campaign();
     $image = $campaign->getCampaignImage();
     $users = new Users();
     $member = $users->getRecentUsers();
     $this->layout->foot = View::make("landing.foot")->with(array('data' => $image, 'data2' => $member));
     $this->layout->title = "Welcome to Sagip.ph";
     if (Session::has('userid')) {
         $username = Session::get('username');
         $logstatus = true;
         $userid = Session::get('userid');
         $profile = new Profile();
         $pic = "#";
         $result = $profile->getProfile($userid);
         if ($result) {
             $pic = $result->profilepic;
         }
         $data = array('username' => $username, 'logstatus' => $logstatus, 'profilepic' => $pic);
         $campaign = new Campaign();
         $data2 = $campaign->getCampaignHome();
         $this->layout->head = View::make("landing.head")->with($data);
         $this->layout->body = View::make("landing.bodycontributordash")->with($data);
     } else {
         $logstatus = false;
         $data = array('logstatus' => $logstatus);
         $campaign = new Campaign();
         $data2 = $campaign->getCampaignHome();
         $this->layout->head = View::make("landing.head")->with($data);
         $this->layout->body = View::make("landing.bodycontributordash")->with($data);
     }
 }
예제 #3
0
 public function createUser(RegistrationForm $form)
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $user = new User('registration');
         $profile = new Profile('registration');
         $data = $form->getAttributes();
         // Устанавливаем атрибуты пользователя
         $user->setAttributes(array('email' => $data['email']));
         // Генерируем для пользователя новый пароль
         $password = $this->hasher->generateRandomPassword();
         $user->hash = $this->hasher->hashPassword($password);
         // Устанавливаем роль пользователя
         $user->role = User::USER_ROLE;
         $profile->setAttributes(array('name' => $data['name'], 'gender' => $data['gender'], 'birth_date' => $data['date'], 'birth_time' => $form->getTime(), 'city_id' => $data['city_id']));
         $profile->subscriber = Profile::SUBSCRIBER_YES;
         if ($user->save() && ($token = $this->tokenStorage->createAccountActivationToken($user)) !== false) {
             $profile->user_id = $user->id;
             if (!$profile->save()) {
                 throw new CException(Yii::t('UserModule.user', 'Error creating profile!'));
             }
             $event = new CEvent($this, array('user' => $user, 'password' => $password, 'token' => $token, 'programId' => $data['programId'], 'subscriptionType' => $data['subscriptionType']));
             $this->onSuccessRegistration($event);
             Yii::log(Yii::t('UserModule.user', 'Account {nick_name} was created', array('{nick_name}' => $user->email)), CLogger::LEVEL_INFO, UserModule::$logCategory);
             $transaction->commit();
             return $user;
         }
         throw new CException(Yii::t('UserModule.user', 'Error creating account!'));
     } catch (Exception $e) {
         Yii::log(Yii::t('UserModule.user', 'Error {error} account creating!', array('{error}' => $e->__toString())), CLogger::LEVEL_INFO, UserModule::$logCategory);
         $transaction->rollback();
         return false;
     }
 }
예제 #4
0
파일: hook.php 프로젝트: geldarr/hack-space
function plugin_pdf_MassiveActionsProcess($data)
{
    switch ($data["action"]) {
        case "plugin_pdf_DoIt":
            foreach ($data['item'] as $key => $val) {
                if ($val) {
                    $tab_id[] = $key;
                }
            }
            $_SESSION["plugin_pdf"]["type"] = $data["itemtype"];
            $_SESSION["plugin_pdf"]["tab_id"] = serialize($tab_id);
            echo "<script type='text/javascript'>\n               location.href='../plugins/pdf/front/export.massive.php'</script>";
            break;
        case "plugin_pdf_allow":
            $profglpi = new Profile();
            $prof = new PluginPdfProfile();
            foreach ($data['item'] as $key => $val) {
                if ($profglpi->getFromDB($key) && $profglpi->fields['interface'] != 'helpdesk') {
                    if ($prof->getFromDB($key)) {
                        $prof->update(array('id' => $key, 'use' => $data['use']));
                    } else {
                        if ($data['use']) {
                            $prof->add(array('id' => $key, 'use' => $data['use']));
                        }
                    }
                }
            }
            break;
    }
}
예제 #5
0
function updateUserUrls()
{
    printfnq("Updating user URLs...\n");
    // XXX: only update user URLs where out-of-date
    $qry = "SELECT * FROM profile order by id asc";
    $pflQry = new Profile();
    $pflQry->query($qry);
    $members = array();
    while ($pflQry->fetch()) {
        $members[] = clone $pflQry;
    }
    $pflQry->free();
    foreach ($members as $member) {
        $user = $member->getUser();
        printfv("Updating user {$user->nickname}...");
        try {
            $profile = $user->getProfile();
            updateProfileUrl($profile);
            updateAvatarUrls($profile);
            // Broadcast for remote users
            common_broadcast_profile($profile);
        } catch (Exception $e) {
            printv("Error updating URLs: " . $e->getMessage());
        }
        printfv("DONE.");
    }
}
예제 #6
0
 private function aProfile($pid)
 {
     $this->caller->requireAuthentication();
     require_once FRAMEWORK_PATH . 'models/profile.php';
     if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
         if ($pid == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
             $profile = new Profile($this->registry, $pid);
             if ($profile->isValid()) {
                 $data = $this->caller->getRequestData();
                 $profile->setName($this->registry->getObject('db')->sanitizeData($data['name']));
                 $profile->setDinoName($this->registry->getObject('db')->sanitizeData($data['dino_name']));
                 // etc, set all appropriate methods
                 $profile->save();
                 header('HTTP/1.0 204 No Content');
                 exit;
             } else {
                 header('HTTP/1.0 404 Not Found');
                 exit;
             }
         } else {
             header('HTTP/1.0 403 Forbidden');
             exit;
         }
     } else {
         $profile = new Profile($this->registry, $pid);
         if ($profile->isValid()) {
             header('HTTP/1.0 200 OK');
             echo json_encode($profile->toArray());
             exit;
         } else {
             header('HTTP/1.0 404 Not Found');
             exit;
         }
     }
 }
function update_profile($profile_id, $data)
{
    $yes_no = array('YES', 'NO');
    $urls = $_SESSION['OCS']['url_service'];
    $profiles = get_profiles();
    $profile = $profiles[$profile_id];
    $updatedProfile = new Profile($profile_id, $data['new_label'] ?: $profile->getLabel());
    foreach ($data['restrictions'] as $key => $val) {
        $updatedProfile->setRestriction($key, $val);
    }
    foreach ($data['config'] as $key => $val) {
        $updatedProfile->setConfig($key, $val);
    }
    foreach ($data['blacklist'] as $key => $val) {
        if ($val == 'YES') {
            $updatedProfile->addToBlacklist($key);
        }
    }
    foreach ($data['pages'] as $key => $val) {
        if ($urls->getUrl($key) and $val == 'on') {
            $updatedProfile->addPage($key);
        }
    }
    $serializer = new XMLProfileSerializer();
    $xml = $serializer->serialize($updatedProfile);
    if (file_put_contents(DOCUMENT_REAL_ROOT . '/config/profiles/' . $profile->getName() . '.xml', $xml)) {
        return $profile->getName();
    } else {
        return false;
    }
}
예제 #8
0
 public function postIndex()
 {
     $input = Input::only('first_name', 'last_name', 'email', 'username', 'password', 'domain_id');
     $domain_id = Cookie::get('domain_hash') ? Cookie::get('domain_hash') : 'NULL';
     $rules = array('first_name' => 'required|min:1', 'email' => 'required|email|unique:users,email,NULL,id,deleted_at,NULL,domain_id,' . $domain_id, 'username' => 'required|min:3|must_alpha_num|unique:users,username,NULL,id,deleted_at,NULL,domain_id,' . $domain_id, 'password' => 'required|min:6');
     $v = Validator::make($input, $rules);
     if ($v->fails()) {
         return Output::push(array('path' => 'register', 'errors' => $v, 'input' => TRUE));
     }
     $profile = new Profile(array('first_name' => $input['first_name'], 'last_name' => $input['last_name'], 'website' => ''));
     $profile->save();
     $user = new User(array('domain_id' => Cookie::get('domain_hash') ? Cookie::get('domain_hash') : NULL, 'email' => $input['email'], 'username' => $input['username'], 'password' => Hash::make($input['password']), 'status' => Cookie::get('domain_hash') ? 4 : 3));
     $user->profile()->associate($profile);
     $user->save();
     if ($user->id) {
         if ($user->status == 4) {
             $this->add_phone_number($user->id);
         }
         $cookie = Cookie::forget('rndext');
         $confirmation = App::make('email-confirmation');
         $confirmation->send($user);
         Mail::send('emails.register', array('new_user' => $input['username']), function ($message) {
             $message->from(Config::get('mail.from.address'), Config::get('mail.from.name'))->to(Input::get('email'))->subject(_('New user registration'));
         });
         Event::fire('logger', array(array('account_register', array('id' => $user->id, 'username' => $user->username), 2)));
         //			return Output::push(array(
         //				'path' => 'register',
         //				'messages' => array('success' => _('You have registered successfully')),
         //				));
         return Redirect::to('register')->with('success', _('You have registered successfully'))->withCookie($cookie);
     } else {
         return Output::push(array('path' => 'register', 'messages' => array('fail' => _('Fail to register')), 'input' => TRUE));
     }
 }
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     return;
     $profile = new Profile();
     $found_profiles = $profile->find("`interface` = 'central'");
     $tab_profile = new self();
     $found_tab_profiles = $tab_profile->find("`plugin_custom_tabs_id` = " . $item->getID());
     echo "<form method='POST' action='tabprofile.form.php' />";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __("Visibility") . "</th></tr>";
     $odd = 0;
     foreach ($found_profiles as $profiles_id => $profile_fields) {
         if ($odd % 2 === 0) {
             echo "<tr>";
         }
         echo "<td>" . $profile_fields['name'] . "</td>";
         echo "<td>";
         Dropdown::showYesNo("tab_profile[{$profiles_id}]", 0);
         echo "</td>";
         if ($odd % 2 === 1) {
             echo "</tr>";
         }
         $odd++;
     }
     if ($odd % 2 === 0) {
         echo "</tr>";
     }
     echo "<tr><td colspan='4'><div class='center'>";
     echo "<input type='submit' name='update' value=\"" . _sx('button', 'Post') . "\" class='submit'>";
     echo "</div></td></tr>";
     echo "</table>";
     Html::closeForm();
     return true;
 }
예제 #10
0
 static function getGraders($groupid)
 {
     $qry = 'SELECT profile.* ' . 'FROM profile JOIN grades_group ' . 'ON profile.id = grades_group.userid ' . 'WHERE grades_group.groupid = ' . $groupid;
     $graders = new Profile();
     $graders->query($qry);
     return $graders;
 }
예제 #11
0
 private function registerUser($username, $data = NULL)
 {
     try {
         $gingerKey = sfConfig::get('app_portail_ginger_key');
         if ($gingerKey != "abc") {
             $ginger = new \Ginger\Client\GingerClient(sfConfig::get('app_portail_ginger_key'));
             $cotisants = $ginger->getUser($username);
         } else {
             $cotisants = new stdClass();
             $cotisants->mail = $username . "@etu.utc.fr";
             $cotisants->prenom = "Le";
             $cotisants->nom = "Testeur";
             $cotisants->type = "etu";
         }
         if (!$data) {
             $data = new sfGuardUser();
         }
         $data->setUsername($username);
         $data->setEmailAddress($cotisants->mail);
         $data->setFirstName($cotisants->prenom);
         $data->setLastName($cotisants->nom);
         $data->setIsActive(true);
         $data->save();
         $profile = new Profile();
         $profile->setUser($data);
         $profile->setDomain($cotisants->type);
         $profile->save();
         return $data;
     } catch (\Ginger\Client\ApiException $ex) {
         $this->setFlash('error', "Il n'a pas été possible de vous identifier. Merci de contacter simde@assos.utc.fr en précisant votre login et le code d'erreur " . $ex->getCode() . ".");
     }
     return false;
 }
예제 #12
0
 /**
  * for person create user, assign Customer office role, send Inivation email
  * @param int $person_id
  * @return boolean
  */
 public function createUser($person_id)
 {
     $m = Person::model();
     $model = $m->findByPk($person_id);
     //person may be already registred as user
     if (!empty($model->user_id)) {
         return TRUE;
     }
     //create user
     $password = $this->randomPassword();
     $mUser = new User();
     $mUser->attributes = array('username' => $model->email, 'password' => UserModule::encrypting($password), 'email' => $model->email, 'superuser' => 0, 'status' => User::STATUS_ACTIVE);
     $mUser->activkey = UserModule::encrypting(microtime() . $password);
     if (!$mUser->save()) {
         return FALSE;
     }
     //attach user to person
     $model->user_id = $mUser->id;
     $model->save();
     //create user profile
     $profile = new Profile();
     $profile->user_id = $mUser->id;
     $profile->first_name = $model->first_name;
     $profile->last_name = $model->last_name;
     $profile->save();
     unset($profile);
     //add Customer office role
     Rights::assign(DbrUser::RoleCustomerOffice, $mUser->id);
     //send email
     Yii::import('vendor.dbrisinajumi.person.components.invitationEmail');
     $e = new invitationEmail();
     $name = $model->first_name . ' ' . $model->last_name;
     $e->sendInvitate($model->email, $password, $model->email, $name);
     return true;
 }
예제 #13
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $user = new User();
     $profile = new Profile();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation(array($user, $profile));
     if (isset($_POST['User'], $_POST['Profile'])) {
         // populate input into $model and $profile
         $user->attributes = $_POST['User'];
         $profile->attributes = $_POST['Profile'];
         // validate both $model and $profile
         $valid = $user->validate();
         $valid = $profile->validate() && $valid;
         if ($valid) {
             if ($user->save()) {
                 $profile->user_id = $user->id;
                 $profile->email = $user->username;
                 if ($profile->save()) {
                     $this->redirect(array('view', 'id' => $user->id));
                 }
             }
         }
     }
     $this->render('create', array('user' => $user, 'profile' => $profile));
 }
	/**
	 * Registration user
	 */
	public function actionRegistration() 
	{
        
        if(Y::module()->isRegistrationClose) $this->redirect('close');
		$model = new RegistrationForm;
        $profile=new Profile;
        $profile->regMode = true;
            
		// ajax validator
		if(isset($_POST['ajax']) && $_POST['ajax']==='registration-form')
			Y::end(UActiveForm::validate(array($model,$profile)));
		
		if (Y::userId()) {
			$this->redirect(Y::module()->cabinetUrl);
		} else {
			if(isset($_POST['RegistrationForm'])) {
				$model->attributes=$_POST['RegistrationForm'];
				$profile->attributes= isset($_POST['Profile'])?$_POST['Profile']:array();
				if($model->validate()&&$profile->validate())
				{
					$soucePassword = $model->password;
					$model->activkey=UserModule::encrypting(microtime().$soucePassword);
					$model->password=UserModule::encrypting($soucePassword);
					$model->verifyPassword=UserModule::encrypting($model->verifyPassword);
					$model->createtime=time();
					$model->lastvisit=((Y::module()->loginNotActiv||(Y::module()->activeAfterRegister&&Y::module()->sendActivationMail==false))&&Y::module()->autoLogin)?time():0;
					$model->superuser=0;
					$model->status=((Y::module()->activeAfterRegister)?User::STATUS_ACTIVE:User::STATUS_NOACTIVE);
						
					if ($model->save()) {
						$profile->user_id=$model->id;
						$profile->save();
						if (Y::module()->sendActivationMail) {
							$activation_url = $this->createAbsoluteUrl('/user/activation',array("activkey" => $model->activkey, "email" => $model->email));
							UserModule::sendMail($model->email,Users::t("You registered from {site_name}",array('{site_name}'=>Yii::app()->name)),Users::t("Please activate you account go to {activation_url}",array('{activation_url}'=>$activation_url)));
						}
							
						if ((Y::module()->loginNotActiv||(Y::module()->activeAfterRegister&&Y::module()->sendActivationMail==false))&&Y::module()->autoLogin) {
							$identity=new UserIdentity($model->username,$soucePassword);
								$identity->authenticate();
								Y::user()->login($identity,0);
								$this->redirect(Y::module()->returnUrl);
						} else {
							if (!Y::module()->activeAfterRegister&&!Y::module()->sendActivationMail) {
								Y::flash('/user/registration',Users::t("Thank you for your registration. Contact Admin to activate your account."));
							} elseif(Y::module()->activeAfterRegister&&Y::module()->sendActivationMail==false) {
								Y::flash('/user/registration',Users::t("Thank you for your registration. Please {{login}}.",array('{{login}}'=>CHtml::link(Users::t('Login'),Y::module()->loginUrl))));
							} elseif(Y::module()->loginNotActiv) {
								Y::flash('/user/registration',Users::t("Thank you for your registration. Please check your email or login."));
							} else {
								Y::flash('/user/registration',Users::t("Thank you for your registration. Please check your email."));
							}
							$this->refresh();
						}
					}
				} else $profile->validate();
			}
		    $this->render('/user/registration',array('model'=>$model,'profile'=>$profile,'lang'=>Yii::app()->language));
	    }
	}
예제 #15
0
 function profile()
 {
     // get the data to save. low on security because the user can only save to himself from here
     if ($this->input->post()) {
         $this->form_validation->set_rules('display_name', _('Display Name'), 'trim|max_length[30]|xss_clean');
         $this->form_validation->set_rules('twitter', _('Twitter username'), 'trim|max_length[20]|xss_clean');
         $this->form_validation->set_rules('bio', _('Bio'), 'trim|max_length[140]|xss_clean');
         if ($this->form_validation->run()) {
             $profile = new Profile($this->tank_auth->get_user_id());
             // use the from_array to be sure what's being inputted
             $profile->display_name = $this->form_validation->set_value('display_name');
             $profile->twitter = $this->form_validation->set_value('twitter');
             $profile->bio = $this->form_validation->set_value('bio');
             if ($profile->save()) {
                 $data["saved"] = TRUE;
             }
         }
     }
     $user = new User($this->tank_auth->get_user_id());
     $profile = new Profile($this->tank_auth->get_user_id());
     $data["user_id"] = $user->id;
     $data["user_name"] = $user->username;
     $data["user_email"] = $user->email;
     $data["user_display_name"] = $profile->display_name;
     $data["user_twitter"] = $profile->twitter;
     $data["user_bio"] = $profile->bio;
     $this->viewdata["function_title"] = _("Your profile");
     $this->viewdata["main_content_view"] = $this->load->view('account/profile/profile', $data, TRUE);
     $this->load->view("account/default.php", $this->viewdata);
 }
예제 #16
0
 /**
  * @see sfValidatorBase
  */
 protected function doClean($values)
 {
     // only validate if username and password are both present
     if (isset($values[$this->getOption('username_field')]) && isset($values[$this->getOption('password_field')])) {
         $username = $values[$this->getOption('username_field')];
         $password = $values[$this->getOption('password_field')];
         // user exists?
         if ($user = sfGuardUserPeer::retrieveByUsername($username)) {
             // password is ok?
             if ($user->getIsActive()) {
                 if (Configuration::get('ldap_enabled', false)) {
                     if (authLDAP::checkPassword($username, $password)) {
                         return array_merge($values, array('user' => $user));
                     }
                 } elseif ($user->checkPassword($password)) {
                     return array_merge($values, array('user' => $user));
                 }
             }
         } elseif (Configuration::get('ldap_enabled', false) && Configuration::get('ldap_create_user', false) && authLDAP::checkPassword($username, $password)) {
             $user = new sfGuardUser();
             $user->setUsername($username);
             $user->save();
             $profile = new Profile();
             $profile->setSfGuardUserId($user->getId());
             $profile->save();
             return array_merge($values, array('user' => $user));
         }
         if ($this->getOption('throw_global_error')) {
             throw new sfValidatorError($this, 'invalid');
         }
         throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
     }
     // assume a required error has already been thrown, skip validation
     return $values;
 }
예제 #17
0
 public function onEndUserRegister(Profile $profile)
 {
     $profile->sandbox();
     if ($this->debug) {
         common_log(LOG_WARNING, "AutoSandbox: sandboxed of {$profile->nickname}");
     }
 }
예제 #18
0
 function showResults($q, $page)
 {
     $profile = new Profile();
     $search_engine = $profile->getSearchEngine('profile');
     $search_engine->set_sort_mode('chron');
     // Ask for an extra to see if there's more.
     $search_engine->limit(($page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
     if (false === $search_engine->query($q)) {
         $cnt = 0;
     } else {
         $cnt = $profile->find();
     }
     if ($cnt > 0) {
         $terms = preg_split('/[\\s,]+/', $q);
         $results = new PeopleSearchResults($profile, $terms, $this);
         $results->show();
         $profile->free();
         $this->pagination($page > 1, $cnt > PROFILES_PER_PAGE, $page, 'peoplesearch', array('q' => $q));
     } else {
         // TRANS: Message on the "People search" page where a query has no results.
         $this->element('p', 'error', _('No results.'));
         $this->searchSuggestions($q);
         $profile->free();
     }
 }
예제 #19
0
 /**
  * Configuration form
  **/
 function showForm($id, $options = array())
 {
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $canedit = Session::haveRight("profile", "w");
     $prof = new Profile();
     if ($id) {
         $this->getFromDB($id);
         $prof->getFromDB($id);
     }
     echo "<form action='" . $target . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2' class='center b'>" . sprintf(_('%1$s %2$s'), 'gestion Vip :', Dropdown::getDropdownName("glpi_groups", $this->fields["id"]));
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>Groupe Vip</td><td>";
     Dropdown::showYesNo("isvip", $this->fields["isvip"]);
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' colspan='2'>";
         echo "<input type='hidden' name='id' value={$id}>";
         echo "<input type='submit' name='update_vip_group' value='Mettre à jour' class='submit'>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
 }
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     $rights = array(array('itemtype' => 'PluginAddressingAddressing', 'label' => __('Generate reports', 'addressing'), 'field' => 'plugin_addressing'));
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     echo "<table class='tab_cadre_fixehov'>";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_addressing_use_ping_in_equipment'));
     echo "<tr class='tab_bg_2'>";
     echo "<td width='20%'>" . __('Use ping on equipment form', 'addressing') . "</td>";
     echo "<td colspan='5'>";
     Html::showCheckbox(array('name' => '_plugin_addressing_use_ping_in_equipment[1_0]', 'checked' => $effective_rights['plugin_addressing_use_ping_in_equipment']));
     echo "</td></tr>\n";
     echo "</table>";
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
 public function editcoordonnateAction()
 {
     if (isset($_SESSION['connected']) && $_SESSION['connected'] == TRUE) {
         $tableau = array();
         $tableau[0] = 'none';
         $tableau[1] = 'none';
         $tableau[2] = 'none';
         $tableau[3] = 'none';
         $this->activeBar = $tableau;
         // On recupere le profile d'un utilisateur donne
         $myProfile = new Profile($_SESSION['idMember']);
         $this->profile = $myProfile;
         if (isset($_SESSION['editprofile']) && $_SESSION['editprofile'] == FALSE) {
             $_SESSION['editprofile'] = TRUE;
         } else {
             if (isset($_SESSION['editprofile']) && $_SESSION['editprofile'] == TRUE) {
                 // Si au moins une entree du formulaire est remplie on save
                 if (isset($_POST['ssnEdit']) && isset($_POST['phoneEdit']) && isset($_POST['emailEdit'])) {
                     $myProfile->getMember()->saveCoordonnate($_POST['ssnEdit'], $_POST['phoneEdit'], $_POST['emailEdit']);
                     unset($_POST);
                     $this->redirect('/profile/edit');
                 }
             }
         }
     } else {
         $this->redirect('/index/index');
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @return void
  */
 public function actionCreate()
 {
     $model = new User('create');
     $profile = new Profile();
     if (($data = Yii::app()->getRequest()->getPost('User')) !== null) {
         $model->setAttributes($data);
         $model->setAttributes(array('hash' => Yii::app()->userManager->hasher->hashPassword(Yii::app()->userManager->hasher->generateRandomPassword())));
         $profile->setAttributes(Yii::app()->getRequest()->getPost('Profile'));
         $profile->user_id = 0;
         if ($model->validate() && $profile->validate()) {
             $transaction = Yii::app()->db->beginTransaction();
             if ($model->save()) {
                 $profile->user_id = $model->id;
                 $profile->save();
                 $transaction->commit();
                 Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('UserModule.user', 'New user was created!'));
                 $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', array('create')));
             } else {
                 $transaction->rollback();
             }
             $this->redirect(array('view', 'id' => $model->id));
         } else {
             $profile->validate();
         }
     }
     $this->render('create', array('model' => $model, 'profile' => $profile));
 }
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     if ($profile->getField('interface') == 'central') {
         $rights = $this->getAllRights();
         $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Helpdesk') . "</th></tr>\n";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_racks_open_ticket'));
     echo "<tr class='tab_bg_2'>";
     echo "<td width='20%'>" . __('Associable items to a ticket') . "</td>";
     echo "<td colspan='5'>";
     Html::showCheckbox(array('name' => '_plugin_racks_open_ticket', 'checked' => $effective_rights['plugin_racks_open_ticket']));
     echo "</td></tr>\n";
     echo "</table>";
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
예제 #24
0
 function showForm($ID, $options = array())
 {
     global $LANG;
     if (!Profile::canView()) {
         return false;
     }
     $canedit = self::canUpdate();
     $profile = new Profile();
     if ($ID) {
         //$this->getFromDBByProfile($ID);
         $profile->getFromDB($ID);
     }
     if ($canedit) {
         echo "<form action='" . $profile->getFormURL() . "' method='post'>";
     }
     $rights = $this->getAllRights();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2'));
     if ($canedit) {
         echo "<div class='center'>";
         echo "<input type='hidden' name='id' value=" . $ID . ">";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</div>";
     }
     Html::closeForm();
     $this->showLegend();
 }
 public function actionRegister()
 {
     $user = new User('register');
     $profile = new Profile('register');
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'register') {
         $user->scenario = 'registerPlusComparePassword';
         echo CActiveForm::validate(array($user, $profile));
         Yii::app()->end();
     }
     if (isset($_POST['User'])) {
         $user->attributes = $_POST['User'];
         $user->password = md5($user->password);
         $user->password_repeat = md5($user->password_repeat);
         $user->user_type_id = 2;
         if ($user->save()) {
             if (isset($_POST['Profile'])) {
                 $profile->attributes = $_POST['Profile'];
                 $profile->birthday = $profile->b_year . "-" . $profile->b_month . "-" . $profile->b_day;
                 $profile->user_id = $user->id;
                 $profile->save();
                 $identity = new UserIdentity($user->login, $user->password);
                 $identity->authenticate();
                 Yii::app()->user->login($identity, 86400 * 7);
             }
             $this->redirect(array('index/index'));
         }
     }
     $this->render("registration", array('user' => $user, 'profile' => $profile));
 }
예제 #26
0
 function __construct($out, Profile $profile)
 {
     parent::__construct($out);
     $this->profile = $profile;
     $user = common_current_user();
     $this->lists = $profile->getLists($user);
 }
 public function run()
 {
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->password_confirmation = '@Password1';
     $user->confirmed = 1;
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->save();
     $profile = new Profile();
     $profile->user_id = $user->id;
     $profile->firstname = 'David';
     $profile->lastname = 'Hernandez';
     $profile->mobile = '(916)952-5736';
     $profile->dob = '09/24/1986';
     $profile->avatar = '/img/coach-avatar.jpg';
     $profile->save();
     if (!$user->id) {
         Log::info('Unable to create user ' . $user->username, (array) $user->errors());
     } else {
         Log::info('Created user "' . $user->username . '" <' . $user->email . '>');
     }
     $user1 = new User();
     $user1->username = '******';
     $user1->email = '*****@*****.**';
     $user1->password = '******';
     $user1->password_confirmation = '@Password1';
     $user1->confirmed = 1;
     $user1->confirmation_code = md5(uniqid(mt_rand(), true));
     $user1->save();
     $profile1 = new Profile();
     $profile1->user_id = $user1->id;
     $profile1->firstname = 'David';
     $profile1->lastname = 'Hernandez';
     $profile1->mobile = '(916)952-5736';
     $profile->dob = '09/24/1986';
     $profile1->avatar = '/img/coach-avatar.jpg';
     $profile1->save();
     if (!$user1->id) {
         Log::info('Unable to create user ' . $user1->username, (array) $user1->errors());
     } else {
         Log::info('Created user "' . $user1->username . '" <' . $user1->email . '>');
     }
     $admin = new Role();
     $admin->name = 'administrator';
     $admin->save();
     $club = new Role();
     $club->name = 'club owner';
     $club->save();
     $club2 = new Role();
     $club2->name = 'club administrator';
     $club2->save();
     $default = new Role();
     $default->name = 'default';
     $default->save();
     $user->attachRole($club);
     $user1->attachRole($default);
 }
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     //var_dump("test");exit;
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     //var_dump($model);exit;
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     //var_dump($_POST['ajax']);exit;
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             //var_dump($_POST['RegistrationForm']);exit;
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = AdminModule::encrypting(microtime() . $model->password);
                 $model->password = AdminModule::encrypting($model->password);
                 $model->verifyPassword = AdminModule::encrypting($model->verifyPassword);
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->save();
                     if (Yii::app()->controller->module->sendActivationMail) {
                         $activation_url = $this->createAbsoluteUrl('/admin/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                         AdminModule::sendMail($model->email, AdminModule::t("Anda registrasi dari {site_name}", array('{site_name}' => Yii::app()->name)), AdminModule::t("Silahkan Aktifkan akun anda melalui link {activation_url}", array('{activation_url}' => $activation_url)));
                     }
                     if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $this->redirect(Yii::app()->controller->module->returnUrl);
                     } else {
                         if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Hubungi Admin untuk mengaktifkan akun anda."));
                         } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Silahkan {{login}}.", array('{{login}}' => CHtml::link(AdminModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                         } elseif (Yii::app()->controller->module->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Silahkan cek email anda atau login."));
                         } else {
                             Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Silahkan cek email anda."));
                         }
                         $this->refresh();
                     }
                 }
             } else {
                 $profile->validate();
             }
         }
         $this->render('/user/registration', array('model' => $model, 'profile' => $profile));
     }
 }
 /**
  * Méthode permettant d'enregistrer un profil
  * @param $profile Le profil à enregistrer
  * @return void
  */
 public function save(Profile $profile)
 {
     if ($profile->isValid()) {
         $profile->isNew() ? $this->add($profile) : $this->modify($profile);
     } else {
         throw new RuntimeException('Le profil doit être valide pour être enregistré');
     }
 }
 public function saveSettings()
 {
     $data = Input::all();
     $profile = new Profile();
     $profile->deleteMyEmailNotifications(Auth::id());
     $profile->saveMyEmailNotifications(Auth::id(), $data);
     return Alert::flash(Lang::get('auth.settings-updated'), 'success');
 }