/** * Display/set user profile settings. */ public function actionSettings() { $model = $this->loadModel(Yii::app()->user->getId()); if (isset($_POST['Profile']) || isset($_POST['preferences'])) { if (isset($_POST['Profile'])) { $model->attributes = $_POST['Profile']; if (isset($_POST['preferences']['loginSound'])) { $pieces = explode(',', $_POST['preferences']['loginSound']); $model->loginSound = $pieces[0]; unset($_POST['preferences']['loginSound']); } if (isset($_POST['preferences']['notificationSound'])) { $pieces = explode(',', $_POST['preferences']['notificationSound']); $model->notificationSound = $pieces[0]; unset($_POST['preferences']['notificationSound']); } $model->save(); } if (isset($_POST['preferences']['themeName'])) { ThemeGenerator::clearCache(); Yii::import('application.components.ThemeGenerator.LoginThemeHelper'); LoginThemeHelper::saveProfileTheme($_POST['preferences']['themeName']); $model->theme = array_merge(array_diff_key($model->theme, array_flip(ThemeGenerator::getProfileKeys())), ThemeGenerator::loadDefault($_POST['preferences']['themeName'], false), array_diff_key($_POST['preferences'], array_flip(ThemeGenerator::getProfileKeys()))); $model->save(); } $this->refresh(); } $modules = Modules::model()->findAllByAttributes(array('visible' => 1)); $menuItems = array(); foreach ($modules as $module) { if ($module->name == 'document') { $menuItems[$module->title] = $module->title; } else { $menuItems[$module->name] = Yii::t('app', $module->title); } } $menuItems = array('' => Yii::t('app', 'Activity Feed')) + $menuItems; $languages = $model->getLanguageOptions(); $times = $this->getTimeZones(); $myThemeProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "((private = 1 AND uploadedBy = '" . Yii::app()->user->name . "') OR private = 0) AND associationType = 'theme'", 'order' => 'createDate DESC'), 'pagination' => false)); $myBackgroundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType = 'bg-private' AND associationId = '" . Yii::app()->user->getId() . "') OR associationType = 'bg'", 'order' => 'createDate DESC'), 'pagination' => false)); $myLoginSoundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType='loginSound' AND (private=0 OR private IS NULL OR uploadedBy='" . Yii::app()->user->getName() . "'))", 'order' => 'createDate DESC'), 'pagination' => false)); $myNotificationSoundProvider = new CActiveDataProvider('Media', array('criteria' => array('condition' => "(associationType='notificationSound' AND (private=0 OR private IS NULL OR uploadedBy='" . Yii::app()->user->getName() . "'))", 'order' => 'createDate DESC'), 'pagination' => false)); $hiddenTags = json_decode(Yii::app()->params->profile->hiddenTags, true); if (empty($hiddenTags)) { $hiddenTags = array(); } if (sizeof($hiddenTags)) { $tagParams = AuxLib::bindArray($hiddenTags); $allTags = Yii::app()->db->createCommand()->select('COUNT(*) AS count, tag')->from('x2_tags')->group('tag')->where('tag IS NOT NULL AND tag IN (' . implode(',', array_keys($tagParams)) . ')', $tagParams)->order('tag ASC')->limit(20)->queryAll(); } else { $allTags = array(); } $admin = Yii::app()->settings; $this->render('settings', array('model' => $model, 'languages' => $languages, 'times' => $times, 'myThemes' => $myThemeProvider, 'myBackgrounds' => $myBackgroundProvider, 'myLoginSounds' => $myLoginSoundProvider, 'myNotificationSounds' => $myNotificationSoundProvider, 'menuItems' => $menuItems, 'allTags' => $allTags)); }