/** * Cleans up the session data to send along with an event * * @return array */ protected static function getCleanedSession() { if (Pii::guest()) { return false; } $session = Session::getSessionData(); if (isset($session, $session['allowed_apps'])) { $apps = []; /** @var App $app */ foreach ($session['allowed_apps'] as $app) { $apps[$app->name] = $app->getAttributes(); } $session['allowed_apps'] = $apps; } return $session; }
/** * Updates the user profile from a form */ public function actionProfile() { if (Pii::guest()) { $this->_redirectError('You must be logged in to change your profile.'); } $_model = new ProfileForm(); if (isset($_POST, $_POST['ProfileForm'])) { $_model->attributes = $_POST['ProfileForm']; if ($_model->validate()) { try { $_userId = Session::getCurrentUserId(); $_result = Profile::changeProfile($_userId, $_model->attributes); if (Option::getBool($_result, 'success')) { Yii::app()->user->setFlash('profile-form', 'Your profile has been successfully updated.'); } } catch (\Exception $_ex) { $_model->addError(null, $_ex->getMessage()); } } } else { $_userId = Session::getCurrentUserId(); $_model->attributes = Profile::getProfile($_userId); } $this->render('profile', array('model' => $_model, 'backUrl' => $this->_getRedirectUrl(), 'session' => Session::generateSessionDataFromUser(Session::getCurrentUserId()))); }
use Kisma\Core\Utility\Curl; use Kisma\Core\Utility\HtmlMarkup; use Kisma\Core\Utility\Inflector; //************************************************************************* // Constants //************************************************************************* /** * @type string */ const APPLICATION_NAME = 'portal-sandbox'; //******************************************************************************** //* Bootstrap and Debugging //******************************************************************************** require dirname(__DIR__) . '/autoload.php'; // Must be logged in... if (Pii::guest()) { header('Location: /web/login'); die; } //******************************************************************************** //* Load data for drop-downs... //******************************************************************************** $_apps = $_providers = null; $_providerCache = new \stdClass(); $_models = ResourceStore::model('app')->findAll(array('select' => 'id, api_name, name', 'order' => 'name')); if (!empty($_models)) { /** @var App[] $_models */ foreach ($_models as $_model) { $_attributes = array('value' => $_model->api_name, 'name' => $_model->api_name); if (APPLICATION_NAME == $_model->api_name) { $_attributes['selected'] = 'selected';