Exemplo n.º 1
0
 public function testTextSettings()
 {
     $longText = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
     Setting::SetText('longText', $longText);
     Setting::SetText('longText', $longText . "2", 'testModule');
     $this->assertEquals(Setting::GetText('longText'), $longText);
     $this->assertEquals(Setting::GetText('longText', 'testModule'), $longText . "2");
 }
Exemplo n.º 2
0
 /**
  * Executes the widget.
  */
 public function run()
 {
     $blacklisted_objects = explode(',', Setting::GetText('showFilesWidgetBlacklist', 'file'));
     if (!in_array(get_class($this->object), $blacklisted_objects)) {
         $files = \humhub\modules\file\models\File::getFilesOfObject($this->object);
         return $this->render('showFiles', array('files' => $files, 'maxPreviewImageWidth' => Setting::Get('maxPreviewImageWidth', 'file'), 'maxPreviewImageHeight' => Setting::Get('maxPreviewImageHeight', 'file'), 'hideImageFileInfo' => Setting::Get('hideImageFileInfo', 'file')));
     }
 }
 /**
  * Executes the widget.
  */
 public function run()
 {
     if ($this->object instanceof ContentActiveRecord) {
         $widget = $this->object->getWallEntryWidget();
         // File widget disabled in this wall entry
         if ($widget->showFiles === false) {
             return;
         }
     }
     $blacklisted_objects = explode(',', Setting::GetText('showFilesWidgetBlacklist', 'file'));
     if (!in_array(get_class($this->object), $blacklisted_objects)) {
         $files = \humhub\modules\file\models\File::getFilesOfObject($this->object);
         return $this->render('showFiles', array('files' => $files, 'maxPreviewImageWidth' => Setting::Get('maxPreviewImageWidth', 'file'), 'maxPreviewImageHeight' => Setting::Get('maxPreviewImageHeight', 'file'), 'hideImageFileInfo' => Setting::Get('hideImageFileInfo', 'file')));
     }
 }
 /**
  * Configuration Action for Super Admins
  */
 public function actionIndex()
 {
     $form = new AnonAccountsForm();
     if (isset($_POST['AnonAccountsForm'])) {
         $form->attributes = $_POST['AnonAccountsForm'];
         if ($form->validate()) {
             $form->anonAccountsFirstNameOptions = Setting::SetText('anonAccountsFirstNameOptions', $form->anonAccountsFirstNameOptions);
             $form->anonAccountsLastNameOptions = Setting::SetText('anonAccountsLastNameOptions', $form->anonAccountsLastNameOptions);
             // set flash message
             Yii::$app->getSession()->setFlash('data-saved', 'Saved');
             return $this->redirect(Url::toRoute('index'));
         }
     } else {
         $form->anonAccountsFirstNameOptions = Setting::GetText('anonAccountsFirstNameOptions');
         $form->anonAccountsLastNameOptions = Setting::GetText('anonAccountsLastNameOptions');
     }
     return $this->render('index', array('model' => $form));
 }
 /**
  * Configuration Action for Super Admins
  */
 public function actionIndex()
 {
     $form = new EditForm();
     $form->title = Setting::Get('title', 'breakingnews');
     $form->message = Setting::GetText('message', 'breakingnews');
     $form->active = Setting::Get('active', 'breakingnews');
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         Setting::Set('title', $form->title, 'breakingnews');
         Setting::SetText('message', $form->message, 'breakingnews');
         if ($form->active) {
             Setting::Set('active', true, 'breakingnews');
         } else {
             Setting::Set('active', false, 'breakingnews');
         }
         if ($form->reset) {
             foreach (\humhub\modules\user\models\Setting::findAll(array('name' => 'seen', 'module_id' => 'breakingnews')) as $userSetting) {
                 $userSetting->delete();
             }
         }
         return $this->redirect(Url::to(['/breakingnews/admin/index']));
     }
     return $this->render('index', ['model' => $form]);
 }
    ?>
        <?php 
} else {
    ?>
            <?php 
    echo $content;
    ?>
        <?php 
}
?>
        <!-- end: show content -->

        <script type="text/javascript">
            // Replace the standard checkbox and radio buttons
            $('body').find(':checkbox, :radio').flatelements();
        </script>

        <?php 
echo Setting::GetText('trackingHtmlCode');
?>
        <?php 
$this->endBody();
?>
        <div class="text text-center powered">
            Powered by <a href="http://www.humhub.org" target="_blank">HumHub</a>
        </div>
    </body>

</html>
<?php 
$this->endPage();
Exemplo n.º 7
0
 /**
  * File Settings
  */
 public function actionFile()
 {
     $form = new \humhub\modules\admin\models\forms\FileSettingsForm();
     $form->imageMagickPath = Setting::Get('imageMagickPath', 'file');
     $form->maxFileSize = Setting::Get('maxFileSize', 'file') / 1024 / 1024;
     $form->maxPreviewImageWidth = Setting::Get('maxPreviewImageWidth', 'file');
     $form->maxPreviewImageHeight = Setting::Get('maxPreviewImageHeight', 'file');
     $form->hideImageFileInfo = Setting::Get('hideImageFileInfo', 'file');
     $form->useXSendfile = Setting::Get('useXSendfile', 'file');
     $form->allowedExtensions = Setting::GetText('allowedExtensions', 'file');
     $form->showFilesWidgetBlacklist = Setting::GetText('showFilesWidgetBlacklist', 'file');
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         $new = $form->maxFileSize * 1024 * 1024;
         Setting::Set('imageMagickPath', $form->imageMagickPath, 'file');
         Setting::Set('maxFileSize', $new, 'file');
         Setting::Set('maxPreviewImageWidth', $form->maxPreviewImageWidth, 'file');
         Setting::Set('maxPreviewImageHeight', $form->maxPreviewImageHeight, 'file');
         Setting::Set('hideImageFileInfo', $form->hideImageFileInfo, 'file');
         Setting::Set('useXSendfile', $form->useXSendfile, 'file');
         Setting::SetText('allowedExtensions', strtolower($form->allowedExtensions), 'file');
         Setting::SetText('showFilesWidgetBlacklist', $form->showFilesWidgetBlacklist, 'file');
         // set flash message
         Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved'));
         return Yii::$app->response->redirect(Url::toRoute('/admin/setting/file'));
     }
     // Determine PHP Upload Max FileSize
     $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('upload_max_filesize'));
     if ($maxUploadSize > \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size'))) {
         $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size'));
     }
     $maxUploadSize = floor($maxUploadSize / 1024 / 1024);
     // Determine currently used ImageLibary
     $currentImageLibary = 'GD';
     if (Setting::Get('imageMagickPath', 'file')) {
         $currentImageLibary = 'ImageMagick';
     }
     return $this->render('file', array('model' => $form, 'maxUploadSize' => $maxUploadSize, 'currentImageLibary' => $currentImageLibary));
 }
Exemplo n.º 8
0
 /**
  * Returns all available OEmbed providers
  * 
  * @return array
  */
 public static function getProviders()
 {
     $providers = Setting::GetText('oembedProviders');
     if ($providers != "") {
         return \yii\helpers\Json::decode($providers);
     }
     return array();
 }
 public function validateExtension($attribute, $params)
 {
     $allowedExtensions = Setting::GetText('allowedExtensions', 'file');
     if ($allowedExtensions != "") {
         $extension = $this->getExtension();
         $extension = trim(strtolower($extension));
         $allowed = array_map('trim', explode(",", Setting::GetText('allowedExtensions', 'file')));
         if (!in_array($extension, $allowed)) {
             $this->addError($attribute, Yii::t('FileModule.models_File', 'This file type is not allowed!'));
         }
     }
 }
Exemplo n.º 10
0
    echo $content;
    ?>
    <?php 
}
?>
    <!-- end: show content -->

    <!-- start: Modal (every lightbox will/should use this construct to show content)-->
    <div class="modal" id="globalModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-body">
                    <?php 
echo \humhub\widgets\LoaderWidget::widget();
?>
                </div>
            </div>
        </div>
    </div>
    <!-- end: Modal -->

    <?php 
echo \humhub\models\Setting::GetText('trackingHtmlCode');
?>
    <?php 
$this->endBody();
?>
    </body>
    </html>
<?php 
$this->endPage();
 /**
  * Dashboard Welcome
  *
  * Show welcome spash screen to inform about new updates
  */
 public function actionIndex()
 {
     return $this->renderAjax('index', array('title' => Setting::Get('title', 'breakingnews'), 'message' => Setting::GetText('message', 'breakingnews')));
 }
 public function actionIndex()
 {
     $needApproval = Setting::Get('needApproval', 'authentication_internal');
     if (!Yii::$app->user->isGuest) {
         throw new HttpException(401, 'Your are already logged in! - Logout first!');
     }
     $userInvite = Invite::findOne(['token' => Yii::$app->request->get('token')]);
     if (!$userInvite) {
         throw new HttpException(404, 'Token not found!');
     }
     if ($userInvite->language) {
         Yii::$app->language = $userInvite->language;
     }
     $userModel = new User();
     $userModel->scenario = 'registration';
     $userModel->email = $userInvite->email;
     $userPasswordModel = new Password();
     $userPasswordModel->scenario = 'registration';
     $profileModel = $userModel->profile;
     $profileModel->scenario = 'registration';
     ///////////////////////////////////////////////////////
     // Generate a random first name
     $firstNameOptions = explode("\n", Setting::GetText('anonAccountsFirstNameOptions'));
     $randomFirstName = trim(ucfirst($firstNameOptions[array_rand($firstNameOptions)]));
     // Generate a random last name
     $lastNameOptions = explode("\n", Setting::GetText('anonAccountsLastNameOptions'));
     $randomLastName = trim(ucfirst($lastNameOptions[array_rand($lastNameOptions)]));
     // Pre-set the random first and last name
     $profileModel->lastname = $randomLastName;
     $profileModel->firstname = $randomFirstName;
     // Make the username from the first and lastnames (only first 25 chars)
     $userModel->username = substr(str_replace(" ", "_", strtolower($profileModel->firstname . "_" . $profileModel->lastname)), 0, 25);
     ///////////////////////////////////////////////////////
     // Build Form Definition
     $definition = array();
     $definition['elements'] = array();
     $groupModels = \humhub\modules\user\models\Group::find()->orderBy('name ASC')->all();
     $defaultUserGroup = \humhub\models\Setting::Get('defaultUserGroup', 'authentication_internal');
     $groupFieldType = "dropdownlist";
     if ($defaultUserGroup != "") {
         $groupFieldType = "hidden";
     } else {
         if (count($groupModels) == 1) {
             $groupFieldType = "hidden";
             $defaultUserGroup = $groupModels[0]->id;
         }
     }
     if ($groupFieldType == 'hidden') {
         $userModel->group_id = $defaultUserGroup;
     }
     // Add Identicon Form
     $identiconForm = new IdenticonForm();
     $definition['elements']['IdenticonForm'] = array('type' => 'form', 'elements' => array('image' => array('type' => 'hidden', 'class' => 'form-control', 'id' => 'image')));
     // Add Profile Form
     $definition['elements']['Profile'] = array_merge(array('type' => 'form'), $profileModel->getFormDefinition());
     // Add User Form
     $definition['elements']['User'] = array('type' => 'form', 'title' => Yii::t('UserModule.controllers_AuthController', 'Account'), 'elements' => array('username' => array('type' => 'hidden', 'class' => 'form-control', 'maxlength' => 25), 'group_id' => array('type' => $groupFieldType, 'class' => 'form-control', 'items' => \yii\helpers\ArrayHelper::map($groupModels, 'id', 'name'), 'value' => $defaultUserGroup)));
     // Add User Password Form
     $definition['elements']['UserPassword'] = array('type' => 'form', 'elements' => array('newPassword' => array('type' => 'password', 'class' => 'form-control', 'maxlength' => 255), 'newPasswordConfirm' => array('type' => 'password', 'class' => 'form-control', 'maxlength' => 255)));
     // Get Form Definition
     $definition['buttons'] = array('save' => array('type' => 'submit', 'class' => 'btn btn-primary', 'label' => Yii::t('UserModule.controllers_AuthController', 'Create account')));
     $form = new HForm($definition);
     $form->models['User'] = $userModel;
     $form->models['UserPassword'] = $userPasswordModel;
     $form->models['Profile'] = $profileModel;
     $form->models['IdenticonForm'] = $identiconForm;
     if ($form->submitted('save') && $form->validate() && $identiconForm->validate()) {
         $this->forcePostRequest();
         // Registe User
         $form->models['User']->email = $userInvite->email;
         $form->models['User']->language = Yii::$app->language;
         if ($form->models['User']->save()) {
             // Save User Profile
             $form->models['Profile']->user_id = $form->models['User']->id;
             $form->models['Profile']->save();
             // Save User Password
             $form->models['UserPassword']->user_id = $form->models['User']->id;
             $form->models['UserPassword']->setPassword($form->models['UserPassword']->newPassword);
             $form->models['UserPassword']->save();
             // Autologin user
             if (!$needApproval) {
                 $user = $form->models['User'];
                 Yii::$app->user->login($user);
                 // Prepend Data URI scheme (stripped out for safety)
                 $identiconForm->image = str_replace("[removed]", "data:image/png;base64,", $identiconForm->image);
                 // Upload new Profile Picture for user
                 $this->uploadProfilePicture(Yii::$app->user->guid, $identiconForm->image);
                 // Redirect to dashboard
                 return $this->redirect(Url::to(['/dashboard/dashboard']));
             }
             return $this->render('createAccount_success', array('form' => $form, 'needApproval' => $needApproval));
         }
     }
     return $this->render('createAccount', array('hForm' => $form, 'needAproval' => $needApproval));
 }