/** * @param array $data * @param string $method * @return $this */ protected function loadIdentity(array $data, $method) { $this->identity = new Identity(); $link = $this->getUrl(); $credentials = $this->_clientId . ':' . $this->_clientSecret; $parameters = http_build_query($data); $options = [CURLOPT_FOLLOWLOCATION => true, CURLOPT_FORBID_REUSE => true, CURLOPT_HEADER => false, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_HTTPGET => false, CURLOPT_NETRC => false, CURLOPT_POST => false, CURLOPT_PUT => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 1, CURLOPT_TIMEOUT => 5, CURLOPT_URL => $link, CURLOPT_USERPWD => $credentials, CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded']]; switch ($method) { case 'post': $options[CURLOPT_POST] = true; $options[CURLOPT_POSTFIELDS] = $parameters; break; default: $options[CURLOPT_HTTPGET] = true; $options[CURLOPT_URL] = $link . '?' . $parameters; } curl_setopt_array($this->curl, $options); $source = curl_exec($this->curl); /* { "access_token": "22fe0c13e995da4a44a63a7ff549badb5d337a42bf80f17424482e35d4cca91a", "expires_at": 1382962374, "expires_in": 3600, "refresh_token": "8eb667707535655f2d9e14fc6491a59f6e06f2e73170761259907d8de186b6a1", "token_type": "bearer" } */ $identity = json_decode($source, true); $this->identity->setAccessToken($identity['access_token'])->setExpireAt($identity['expires_at'])->setExpireIn($identity['expires_in'])->setRefreshToken($identity['refresh_token'])->setTokenType($identity['token_type']); return $this; }
public function searchModal() { require_once 'models/studentContact.php'; $names = Identity::findByType(2); $types = StudentContact::getTypes(); include_once 'views/contact/modals/searchContacts.php'; }
public function getDelete($id) { $identity = Identity::find($id); $identity->delete(); Session::flash('message', 'The records are deleted successfully'); return Redirect::to('identity'); }
/** * Given a Member ID, return Member * * @param integer $member_id * @return Entry */ public function fetchMemberFromID($member_id) { if (!Identity::$driver instanceof Extension) { Identity::$driver = Symphony::ExtensionManager()->create('members'); } return Identity::$driver->getMemberDriver()->initialiseMemberObject($member_id); }
public static function findByType($type) { if (is_string($type)) { switch ($type) { case 'student': $type = 1; break; case 'contact': $type = 2; break; case 'teacher': $type = 3; break; default: return false; break; } } $db = DB::getInstance(); $request = $db->prepare('SELECT * FROM identity WHERE type = :type'); $request->bindParam(":type", $type, PDO::PARAM_INT); if (!$request->execute()) { return false; } $list = []; foreach ($request->fetchAll() as $i) { $item = new Identity($i['id'], $i['first_name'], $i['middle_name'], $i['last_name'], $i['gender'], $i['email'], $i['id_Image_uri'], $i['type']); $list[] = $item->getValues(); } return $list; }
/** * Resets user's password and send it to email * @param UserAccount $user */ public function resetPassword(UserAccount $user) { if ($user->status != UserAccount::STATUS_ACTIVE) { if (!$this->allowActivationOnPasswordReset) { throw new CException('Can\'t reset password for inactive users.'); } else { $identity = Identity::model()->findByAttributes(array('user_id' => $user->id, 'type' => Identity::TYPE_EMAIL, 'status' => Identity::STATUS_NEED_CONFIRMATION)); $identity->userIdentityConfirmation->confirm(); } } $emailAddr = $user->getActiveEmail(); $newPassword = $this->randomPassword(); $user->setPassword($newPassword); $user->save(false, array('password')); $email = new YiiMailer('resetPassword', $data = array('newPassword' => $newPassword, 'description' => $description = 'Password reset')); $email->setSubject($description); $email->setTo($emailAddr); $email->setFrom(Yii::app()->params['noreplyAddress'], Yii::app()->name, FALSE); Yii::log('Sendign reset password mail to ' . $emailAddr); if ($email->send()) { Yii::log('Ok'); } else { Yii::log('Failed'); throw new CException('Failed to send the email'); } }
public function __construct(&$parent) { parent::__construct($parent); $this->_required = true; $this->set('required', 'yes'); if (!self::$driver instanceof Extension) { self::$driver = Symphony::ExtensionManager()->create('members'); } }
/** * {@inheritDoc} */ public function remove($value) { $identityHash = Identity::hash($value); if (!isset($this->values[$identityHash]) && !array_key_exists($identityHash, $this->values)) { return false; } unset($this->values[$identityHash]); $this->length--; return true; }
public function testIdentityChained() { $result = Identity::unit(1)->bind(function ($value) { return 2 * $value; })->bind(function ($value) { return $value + 1; }); $this->assertEquals(3, $result->extract()); $this->assertEquals('Identity(3)', (string) $result); }
public function getEdit($id) { $data = guest::find($id); $regions = Regions::all(); $country = Countries::where('region_id', '=', $data->city->province->country->region->id)->get(); $province = Provinces::where('country_id', '=', $data->city->province->country->id)->get(); $city = Cities::where('province_id', '=', $data->city->province->id)->get(); $options = array('data' => $data, 'regions' => $regions, 'country' => $country, 'province' => $province, 'city' => $city, 'identity' => Identity::all(), 'job' => Jobs::all()); return View::make('home/dashboard', array())->nest('content', 'guest/edit', $options); }
public function action_view() { $uri = $this->request->detect_uri(); if ($uri == '') { $this->redirect(URL::to('page@view:home')); } $id = $this->request->param('id'); $query = $this->request->query(); $username = $this->request->post('username'); $password = $this->request->post('password'); $login = $this->request->post('login'); $identity = Identity::instance(); $info = ORM::factory('Page')->filter('alias', $id)->load(); if ($info->loaded()) { //downloads if ($id == 'download') { $downloads = true; } //contact if ($id == 'contact') { $form = Form::factory('Contact'); //$form = Form:: if ($form->valid()) { //var_dump($form->values()); $this->redirect(URL::to('page@view:contact') . '?form=sent'); } } else { $form = FALSE; } //login mechanism if (empty($username) && $login == 'Login') { $this->redirect(URL::current() . '?auth=nameError'); } elseif (empty($password) && $login == 'Login') { $this->redirect(URL::current() . '?auth=false'); } elseif (!empty($username) && !empty($password) && $login == 'Login') { $auth = $identity->authenticate($username, $password); if ($auth) { $this->redirect(URL::current()); } else { $this->redirect(URL::current() . '?auth=false'); } } //logout mechanism if ($login == 'Logout') { $identity->destroy(); $this->redirect(URL::current()); } $view = View::factory('page/item', array('item' => Viewer::factory($info), 'form' => $form, 'query' => $query, 'downloads' => isset($downloads) ? $downloads : null)); $this->response->body($view->render()); } else { throw HTTP_Exception::factory(404, 'Page not found'); } }
/** * Зарегистрировать */ public function executeCreate(sfWebRequest $request) { $this->executeSignup(); $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $user = $this->form->save(); $loginzaData = $this->getUser()->getAttribute('loginza.identity', false, 'loginza'); // связываем юзера с идентификатором $identity = new Identity(); $identity->setIdentity($loginzaData['identity']); $identity->setProvider($loginzaData['provider']); $identity->setUser($user); $identity->save(); $this->getUser()->setAttribute('identity.id', $identity->getId()); // авторизуем $this->getUser()->signin($user, true); } if (!$this->form->hasErrors()) { if ($request->isXmlHttpRequest()) { return $this->renderText("<script type='text/javascript'>window.location.href='/';</script>"); } else { return $this->redirect('homepage'); } } $this->setTemplate('signup'); }
public function commit() { if (!parent::commit()) { return false; } $id = $this->get('id'); if ($id === false) { return false; } fieldMemberEmail::createSettingsTable(); $fields = array('field_id' => $id); return FieldManager::saveSettings($id, $fields); }
public function run() { $transaction = Yii::app()->db->beginTransaction(); try { if ($this->data->validate()) { $user = new UserAccount(); $user->setPassword($this->data->password); $user->status = UserAccount::STATUS_NEED_ACTIVATION; if (!$user->save()) { throw new Exception("User registration failed. Cant save User row. Errors: " . var_export($user->getErrors(), true)); } $identity = new Identity(); $identity->user_id = $user->id; $identity->type = Identity::TYPE_EMAIL; $identity->status = Identity::STATUS_NEED_CONFIRMATION; $identity->identity = $this->data->email; if (!$identity->save()) { throw new Exception("User registration failed. Can't save Identity. Errors: " . var_export($identity->getErrors(), true)); } $profile = new Profile(); $attributeNames = $profile->attributeNames(); $attributes = $this->data->getAttributes($attributeNames); $profile->setAttributes($attributes, false); $profile->user_id = $user->id; if (!$profile->save()) { throw new Exception("User registration failed. Can't save Profile. Errors: " . var_export($profile->getErrors(), true)); } $this->afterRecordsCreated($user, $profile, $identity); } else { throw new Exception("Invalid registration data. Errors: " . var_export($this->data->getErrors(), true)); } } catch (Exception $exc) { $transaction->rollback(); throw $exc; } $transaction->commit(); return true; }
public function commit() { if (!parent::commit()) { return false; } $id = $this->get('id'); if ($id === false) { return false; } fieldMemberEmail::createSettingsTable(); $fields = array('field_id' => $id); Symphony::Database()->query("DELETE FROM `tbl_fields_" . $this->handle() . "` WHERE `field_id` = '{$id}' LIMIT 1"); return Symphony::Database()->insert($fields, 'tbl_fields_' . $this->handle()); }
/** * Provides ability to change password and email address. * If user want to change email it will be changed after confirmation of * new email address. * * @throws CException */ public function actionEdit() { $identity = Identity::model()->findByAttributes(array('user_id' => Yii::app()->user->id)); $newPassword = new ChangePasswordForm(); if ($this->request->isPostRequest) { if ($identity->identity !== $_POST['Identity']['identity']) { $newEmail = $_POST['Identity']['identity']; $storedIdentity = clone $identity; $identity->identity = $newEmail; } $newPassword->attributes = $_POST['ChangePasswordForm']; $isFormValid = $newPassword->validate(); if ($isFormValid && $newEmail) { $isFormValid = $identity->validate(); } if ($isFormValid && isset($newEmail)) { $identity->status = Identity::STATUS_NEED_CONFIRMATION; $identity->isNewRecord = true; $identity->id = null; $identity->save(); $confirmation = $identity->startConfirmation(IdentityConfirmation::TYPE_EMAIL_REPLACE_CONFIRMATION); $activationUrl = $this->createAbsoluteUrl($this->module->confirmationUrl, array('key' => $confirmation->key)); $email = new YiiMailer('changeEmail', $data = array('activationUrl' => $activationUrl, 'description' => $description = 'Email change confirmation')); $email->setSubject($description); $email->setTo($identity->identity); $email->setFrom(Yii::app()->params['noreplyAddress'], Yii::app()->name, FALSE); Yii::log('Sendign email change confirmation to ' . $identity->identity . ' with data: ' . var_export($data, true)); // @TODO: catch mailing exceptions here, to give user right messages if ($email->send()) { Yii::log('Ok'); } else { Yii::log('Failed'); throw new CException('Failed to send the email'); } Yii::app()->user->setFlash('info', 'Your new email will be applied after confirmation. Please, check this email address ' . $newEmail . '. You should get confirmation mail there.'); } if ($isFormValid) { $user = $identity->userAccount; if ($newPassword->password && !$user->passwordEquals($newPassword->password)) { $user->setPassword($newPassword->password); $user->save(); Yii::app()->user->setFlash('success', 'Password has been changed successfully'); } } if ($isFormValid) { $this->redirect(array($this->module->afterIdentityEditedUrl)); } } $this->render('edit', array('identity' => $identity, 'newPassword' => $newPassword)); }
public function actionRecovery() { $form = new RecoveryForm(); if ($this->request->isPostRequest) { $form->attributes = $_POST['RecoveryForm']; if ($form->validate()) { $user = Identity::model()->findByAttributes(array('identity' => $form->email, 'type' => Identity::TYPE_EMAIL))->userAccount; $this->module->resetPassword($user); Yii::app()->user->setFlash('success', 'New password had been sent to your email address.'); $this->redirect(array($this->module->loginUrl)); } } $this->render('recovery', array('model' => $form)); }
/** * @param SS_HTTPRequest $request */ public function run($request) { echo 'Syncing identities to sass file:'; $colors = Identity::get_colors(); $str = ''; echo '<ul>'; foreach ($colors as $name => $c) { $str .= '$identity-color-' . $name . ': ' . $c . ';' . "\n"; echo "<li><em>{$name}:</em> <strong>{$c}</strong></li>"; } echo '</ul>'; echo 'Sync done.'; $base = str_replace('/public', '', Director::baseFolder()); //TODO this one should be configurable $file = "{$base}/resources/sass/_identity_synced.scss"; file_put_contents($file, $str); }
/** * update */ public function action_update() { // get model $model = Identity::instance()->user; // create form $form = Form::factory($this->_settings->get('form')); // add request to form $form->request($this->request); // add model to form $form->model($model); // add text to form $form->text(Text::instance()); // add urls $form->urls(array('submit' => URL::to($this->request->controller() . '@update'), 'back' => URL::to($this->request->controller()))); $form->user($model); // do the action if ($this->update($model, $form)) { //redirect $this->redirect_done('updated'); } }
/** * init */ public function init() { // raise event Event::raise($this, Event::BEFORE_INIT); // get website and feed it the current uri so we can figure out the ->id() $website = Website::instance()->uri(Request::initial()->uri()); // set controller vars $this->_website = $website->id(); $this->_directory = Request::current()->directory(); $this->_controller = Request::current()->controller(); $this->_action = Request::current()->action(); $this->_language = isset(Identity::instance()->user) ? Identity::instance()->user->language : 'nl'; // manually set website in Website // this will be used by alias Website::instance()->id($this->_website); // set state session // get state instance for this website / controller State::session(Session::instance('database')); $this->_state = State::instance($this->_website . '.' . $this->_controller); // set route in URL helper URL::route('backend'); // Let Filereader cache results Reader::cache(Cache::instance('reader_backend'), 'backend'); // set default language Text::language($this->_language); // get that language's text instance and configure it Text::instance($this->_language)->load(array_keys(Settings::factory('modules')->as_array()))->group($this->_controller)->substitutes('module'); // set URL presets $base = URL::base(); URL::set('base', $base); URL::set('library', $base . 'library/'); URL::set('vendor', $base . 'vendor/'); URL::set('files', $base . 'files/'); // set website in view View::set_global('_website', $this->_website); // set language in view View::set_global('_language', $this->_language); }
public function authenticate() { $identityRow = Identity::model()->findByAttributes(array('identity' => $this->username, 'type' => Identity::TYPE_EMAIL, 'status' => Identity::STATUS_CONFIRMED)); if ($identityRow) { $user = $identityRow->userAccount; } if (!$identityRow || !$user) { $this->errorCode = self::ERROR_UNKNOWN_IDENTITY; } else { if (!$user->passwordEquals($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { if ($user->status != UserAccount::STATUS_ACTIVE) { $this->errorCode = self::ERROR_USER_NOT_ACTIVE; } else { $this->errorCode = self::ERROR_NONE; $this->setState('id', $user->id); $this->setState('username', $user->profile->username); } } } return !$this->errorCode; }
/** * @param $identity * @param string $type * @return Identity */ public function getIdentity($identity, $type = Identity::KLOUT_ID) { if (!$identity instanceof Identity) { if ($type) { $identity = Identity::getInstance(array($type => $identity)); } } if (!$identity->getId()) { if (Identity::TWITTER_SCREEN_NAME != $type) { $user = json_decode($this->client->call(sprintf('%s/v2/identity.json/%s/%s?key=%s', self::API_ENDPOINT, $type, $identity->getId($type), $this->key), 'get', array(), '')->getContent(), true); } else { $user = json_decode($this->client->call(sprintf('%s/v2/identity.json/%s?key=%s&screenName=%s', self::API_ENDPOINT, $type, $this->key, $identity->getId($type)), 'get', array(), '')->getContent(), true); } } else { $user = json_decode($this->client->call(sprintf('%s/v2/user.json/%s?key=%s', self::API_ENDPOINT, $identity->getId(), $this->key), 'get', array(), '')->getContent(), true); $user = array_merge($user, $identity->toArray()); $user['topics'] = json_decode($this->client->call(sprintf('%s/v2/user.json/%s/topics?key=%s', self::API_ENDPOINT, $identity->getId(), $this->key), 'get', array(), '')->getContent(), true); $influence = json_decode($this->client->call(sprintf('%s/v2/user.json/%s/influence?key=%s', self::API_ENDPOINT, $identity->getId(), $this->key), 'get', array(), '')->getContent(), true); if (is_array($influence)) { foreach ($influence as $key => $ins) { if (is_array($ins)) { foreach ($ins as $someone) { $user['influence'][$key][] = Identity::getInstance($someone['entity']['payload']); } } else { $user['influence'][$key] = $ins; } } } } if (is_array($user)) { return Identity::getInstance($user); } else { throw new \RuntimeException('User not found'); } }
/** * @returns string Active email */ public function getActiveEmail() { $identity = Identity::model()->findByAttributes(array('status' => Identity::STATUS_CONFIRMED, 'type' => Identity::TYPE_EMAIL, 'user_id' => $this->id)); return !$identity ? null : $identity->identity; }
/** * Constructor */ function __construct() { parent::__construct(); }
public function unlinkContactModal() { $info = StudentContact::findById($_GET['id'])->getValues(); $contact = Identity::findById($info['relationships']['identityId'])->getValues(); include_once 'views/contact/modals/deleteRelationship.php'; }
/** * copy * */ protected function copy($model) { // check rights if (!Acl::instance()->allowed($this->_controller, 'copy', $model->owner_id, $model->website_id)) { throw HTTP_Exception::factory(403, 'Copy not allowed on :controller :id', array(':controller' => $this->_controller, ':id' => $model->id)); } // create copied values $values = $model->as_array(); unset($values['id']); $values['title'] = 'Copy ' . $values['title']; $values['owner_id'] = Identity::instance()->id; $values['editor_id'] = Identity::instance()->id; // create copy $copy = ORM::factory($this->_settings->get('model')); $copy->values($values); // call hook Event::raise($this, Event::BEFORE_COPY, array('model' => $model, 'copy' => $copy)); // save copy $copy->save(); // call hook Event::raise($this, Event::AFTER_COPY, array('model' => $model, 'copy' => $copy)); // return copy return $copy; }
/** * @param Identity $identity * @return $this */ public function add(Identity $identity) { $this->identities[$identity->getUsername()] = $identity; return $this; }
* Copyright 2003-2004 Mike Cochrane <*****@*****.**> * * See the enclosed file COPYING for license information (LGPL). If you * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. */ @define('HORDE_BASE', dirname(__FILE__) . '/../..'); require_once HORDE_BASE . '/lib/base.php'; require_once HORDE_LIBS . 'Horde/Block.php'; require_once HORDE_LIBS . 'Horde/Identity.php'; require_once HORDE_LIBS . 'Horde/Menu.php'; require_once HORDE_LIBS . 'Horde/Help.php'; if (!Auth::isAuthenticated()) { Horde::authenticationFailureRedirect(); } // Get full name for title $identity =& Identity::singleton(); $fullname = $identity->getValue('fullname'); if (empty($fullname)) { $fullname = Auth::getAuth(); } // Get refresh interval. if ($prefs->getValue('summary_refresh_time')) { $refresh_time = $prefs->getValue('summary_refresh_time'); $refresh_url = Horde::applicationUrl('services/portal/'); } // Load layout from preferences. $layout_pref = @unserialize($prefs->getValue('portal_layout')); if (!is_array($layout_pref)) { $layout_pref = array(); } // Store the apps we need to load stylesheets for.
/** * Gradient overlay * Based on identity colors - you need to have set primary-gradient-start and primary-gradient-end in order to use this * @return string */ public function getBackgroundGradientCSS() { $colors = Identity::get_colors('rgb'); return "linear-gradient(" . $this->config()->gradient_direction . ',' . "rgba({$colors['primary-gradient-start']}, " . $this->config()->gradient_start_opacity . ")," . "rgba({$colors['primary-gradient-end']}, " . $this->config()->gradient_end_opacity . ")" . ")"; }
} ?> </ul> </li> <?php } ?> </ul> <ul class="nav navbar-nav navbar-right"> <!-- user options --> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <?php echo Identity::instance()->username; ?> <b class="caret"></b> </a> <ul class="dropdown-menu"> <li> <a href="<?php echo URL::to('Settings'); ?> "><?php echo text('section.settings'); ?> </a> </li> <li> <a href="<?php