/** * E-Mail Mailing Settings */ public function actionDesign() { $form = new \humhub\modules\admin\models\forms\DesignSettingsForm(); #$assetPrefix = Yii::$app->assetManager->publish(dirname(__FILE__) . '/../resources', true, 0, defined('YII_DEBUG')); #Yii::$app->clientScript->registerScriptFile($assetPrefix . '/uploadLogo.js'); if ($form->load(Yii::$app->request->post())) { $files = \yii\web\UploadedFile::getInstancesByName('logo'); if (count($files) != 0) { $file = $files[0]; $form->logo = $file; } if ($form->validate()) { Setting::Set('theme', $form->theme); Setting::Set('paginationSize', $form->paginationSize); Setting::Set('displayNameFormat', $form->displayName); Setting::Set('spaceOrder', $form->spaceOrder, 'space'); if ($form->logo) { $logoImage = new \humhub\libs\LogoImage(); $logoImage->setNew($form->logo); } // read and save colors from current theme \humhub\components\Theme::setColorVariables($form->theme); Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved')); Yii::$app->response->redirect(Url::toRoute('/admin/setting/design')); } } else { $form->theme = Setting::Get('theme'); $form->paginationSize = Setting::Get('paginationSize'); $form->displayName = Setting::Get('displayNameFormat'); $form->spaceOrder = Setting::Get('spaceOrder', 'space'); } $themes = \humhub\components\Theme::getThemes(); return $this->render('design', array('model' => $form, 'themes' => $themes, 'logo' => new \humhub\libs\LogoImage())); }
public function up() { \humhub\components\Theme::setColorVariables(Yii::$app->view->theme->name); }
/** * E-Mail Mailing Settings */ public function actionDesign() { $form = new \humhub\modules\admin\models\forms\DesignSettingsForm(); $form->theme = Setting::Get('theme'); $form->paginationSize = Setting::Get('paginationSize'); $form->displayName = Setting::Get('displayNameFormat'); $form->spaceOrder = Setting::Get('spaceOrder', 'space'); if ($form->load(Yii::$app->request->post())) { $files = \yii\web\UploadedFile::getInstancesByName('logo'); if (count($files) != 0) { $file = $files[0]; $form->logo = $file; } if ($form->validate()) { Setting::Set('theme', $form->theme); Setting::Set('paginationSize', $form->paginationSize); Setting::Set('displayNameFormat', $form->displayName); Setting::Set('spaceOrder', $form->spaceOrder, 'space'); if ($form->logo) { $logoImage = new \humhub\libs\LogoImage(); $logoImage->setNew($form->logo); } // read and save colors from current theme \humhub\components\Theme::setColorVariables($form->theme); DynamicConfig::rewrite(); Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved')); Yii::$app->response->redirect(Url::toRoute('/admin/setting/design')); } } $themes = []; foreach (\humhub\components\Theme::getThemes() as $theme) { $themes[$theme->name] = $theme->name; } return $this->render('design', array('model' => $form, 'themes' => $themes, 'logo' => new \humhub\libs\LogoImage())); }
public static function bootstrap() { // Seems database is already initialized if (Setting::Get('paginationSize') == 10) { return; } //Yii::$app->search->rebuild(); Setting::Set('baseUrl', \yii\helpers\BaseUrl::base(true)); Setting::Set('paginationSize', 10); Setting::Set('displayNameFormat', '{profile.firstname} {profile.lastname}'); // Authentication Setting::Set('authInternal', '1', 'authentication'); Setting::Set('authLdap', '0', 'authentication'); Setting::Set('refreshUsers', '1', 'authentication_ldap'); Setting::Set('needApproval', '0', 'authentication_internal'); Setting::Set('anonymousRegistration', '1', 'authentication_internal'); Setting::Set('internalUsersCanInvite', '1', 'authentication_internal'); // Mailing Setting::Set('transportType', 'php', 'mailing'); Setting::Set('systemEmailAddress', '*****@*****.**', 'mailing'); Setting::Set('systemEmailName', 'My Social Network', 'mailing'); Setting::Set('receive_email_activities', User::RECEIVE_EMAIL_DAILY_SUMMARY, 'mailing'); Setting::Set('receive_email_notifications', User::RECEIVE_EMAIL_WHEN_OFFLINE, 'mailing'); // File Setting::Set('maxFileSize', '1048576', 'file'); Setting::Set('maxPreviewImageWidth', '200', 'file'); Setting::Set('maxPreviewImageHeight', '200', 'file'); Setting::Set('hideImageFileInfo', '0', 'file'); // Caching Setting::Set('type', 'CFileCache', 'cache'); Setting::Set('expireTime', '3600', 'cache'); Setting::Set('installationId', md5(uniqid("", true)), 'admin'); // Design Setting::Set('theme', "HumHub"); Setting::Set('spaceOrder', 0, 'space'); // read and save colors from current theme \humhub\components\Theme::setColorVariables('HumHub'); // Basic Setting::Set('enable', 1, 'tour'); Setting::Set('defaultLanguage', Yii::$app->language); // Notification Setting::Set('enable_html5_desktop_notifications', 0, 'notification'); // Add Categories $cGeneral = new ProfileFieldCategory(); $cGeneral->title = "General"; $cGeneral->sort_order = 100; $cGeneral->visibility = 1; $cGeneral->is_system = 1; $cGeneral->description = ''; if (!$cGeneral->save()) { throw new Exception(print_r($cGeneral->getErrors(), true)); } $cCommunication = new ProfileFieldCategory(); $cCommunication->title = "Communication"; $cCommunication->sort_order = 200; $cCommunication->visibility = 1; $cCommunication->is_system = 1; $cCommunication->description = ''; $cCommunication->save(); $cSocial = new ProfileFieldCategory(); $cSocial->title = "Social bookmarks"; $cSocial->sort_order = 300; $cSocial->visibility = 1; $cSocial->is_system = 1; $cSocial->description = ''; $cSocial->save(); // Add Fields $field = new ProfileField(); $field->internal_name = "firstname"; $field->title = 'Firstname'; $field->sort_order = 100; $field->profile_field_category_id = $cGeneral->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->ldap_attribute = 'givenName'; $field->is_system = 1; $field->required = 1; $field->show_at_registration = 1; if ($field->save()) { $field->fieldType->maxLength = 20; $field->fieldType->save(); } else { throw new Exception(print_r($field->getErrors(), true)); } $field = new ProfileField(); $field->internal_name = "lastname"; $field->title = 'Lastname'; $field->sort_order = 200; $field->profile_field_category_id = $cGeneral->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->ldap_attribute = 'sn'; $field->show_at_registration = 1; $field->required = 1; $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 30; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "title"; $field->title = 'Title'; $field->sort_order = 300; $field->ldap_attribute = 'title'; $field->profile_field_category_id = $cGeneral->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 50; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "gender"; $field->title = 'Gender'; $field->sort_order = 300; $field->profile_field_category_id = $cGeneral->id; $field->field_type_class = 'ProfileFieldTypeSelect'; $field->is_system = 1; if ($field->save()) { $field->fieldType->options = "male=>Male\nfemale=>Female\ncustom=>Custom"; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "street"; $field->title = 'Street'; $field->sort_order = 400; $field->profile_field_category_id = $cGeneral->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 150; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "zip"; $field->title = 'Zip'; $field->sort_order = 500; $field->profile_field_category_id = $cGeneral->id; $field->is_system = 1; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); if ($field->save()) { $field->fieldType->maxLength = 10; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "city"; $field->title = 'City'; $field->sort_order = 600; $field->profile_field_category_id = $cGeneral->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 100; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "country"; $field->title = 'Country'; $field->sort_order = 700; $field->profile_field_category_id = $cGeneral->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 100; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "state"; $field->title = 'State'; $field->sort_order = 800; $field->profile_field_category_id = $cGeneral->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 100; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "birthday"; $field->title = 'Birthday'; $field->sort_order = 900; $field->profile_field_category_id = $cGeneral->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Birthday::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "about"; $field->title = 'About'; $field->sort_order = 900; $field->profile_field_category_id = $cGeneral->id; $field->field_type_class = 'ProfileFieldTypeTextArea'; $field->is_system = 1; if ($field->save()) { #$field->fieldType->maxLength = 100; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "phone_private"; $field->title = 'Phone Private'; $field->sort_order = 100; $field->profile_field_category_id = $cCommunication->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 100; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "phone_work"; $field->title = 'Phone Work'; $field->sort_order = 200; $field->profile_field_category_id = $cCommunication->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 100; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "mobile"; $field->title = 'Mobile'; $field->sort_order = 300; $field->profile_field_category_id = $cCommunication->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 100; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "fax"; $field->title = 'Fax'; $field->sort_order = 400; $field->profile_field_category_id = $cCommunication->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 100; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "im_skype"; $field->title = 'Skype Nickname'; $field->sort_order = 500; $field->profile_field_category_id = $cCommunication->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 100; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "im_msn"; $field->title = 'MSN'; $field->sort_order = 600; $field->profile_field_category_id = $cCommunication->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->maxLength = 100; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "im_icq"; $field->title = 'ICQ Number'; $field->sort_order = 700; $field->profile_field_category_id = $cCommunication->id; $field->field_type_class = 'ProfileFieldTypeNumber'; $field->is_system = 1; if ($field->save()) { $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "im_xmpp"; $field->title = 'XMPP Jabber Address'; $field->sort_order = 800; $field->profile_field_category_id = $cCommunication->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'email'; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "url"; $field->title = 'Url'; $field->sort_order = 100; $field->profile_field_category_id = $cSocial->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'url'; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "url_facebook"; $field->title = 'Facebook URL'; $field->sort_order = 200; $field->profile_field_category_id = $cSocial->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'url'; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "url_linkedin"; $field->title = 'LinkedIn URL'; $field->sort_order = 300; $field->profile_field_category_id = $cSocial->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'url'; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "url_xing"; $field->title = 'Xing URL'; $field->sort_order = 400; $field->profile_field_category_id = $cSocial->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'url'; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "url_youtube"; $field->title = 'Youtube URL'; $field->sort_order = 500; $field->profile_field_category_id = $cSocial->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'url'; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "url_vimeo"; $field->title = 'Vimeo URL'; $field->sort_order = 600; $field->profile_field_category_id = $cSocial->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'url'; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "url_flickr"; $field->title = 'Flickr URL'; $field->sort_order = 700; $field->profile_field_category_id = $cSocial->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'url'; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "url_myspace"; $field->title = 'MySpace URL'; $field->sort_order = 800; $field->profile_field_category_id = $cSocial->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'url'; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "url_googleplus"; $field->title = 'Google+ URL'; $field->sort_order = 900; $field->profile_field_category_id = $cSocial->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'url'; $field->fieldType->save(); } $field = new ProfileField(); $field->internal_name = "url_twitter"; $field->title = 'Twitter URL'; $field->sort_order = 1000; $field->profile_field_category_id = $cSocial->id; $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className(); $field->is_system = 1; if ($field->save()) { $field->fieldType->validator = 'url'; $field->fieldType->save(); } $group = new Group(); $group->name = "Users"; $group->description = "Example Group by Installer"; $group->save(); }
/** * Saves the form * * @return boolean */ public function save() { $settingsManager = Yii::$app->settings; $settingsManager->set('theme', $this->theme); \humhub\components\Theme::setColorVariables($this->theme); $settingsManager->set('paginationSize', $this->paginationSize); $settingsManager->set('displayNameFormat', $this->displayName); Yii::$app->getModule('space')->settings->set('spaceOrder', $this->spaceOrder); Yii::$app->getModule('admin')->settings->set('defaultDateInputFormat', $this->dateInputDisplayFormat); $settingsManager->set('horImageScrollOnMobile', $this->horImageScrollOnMobile); if ($this->logo) { $logoImage = new \humhub\libs\LogoImage(); $logoImage->setNew($this->logo); } \humhub\libs\DynamicConfig::rewrite(); return true; }