Esempio n. 1
0
 /**
  * Broadcast a message to all users
  */
 public function run()
 {
     //Send GCM notifications
     $model = new $this->modelClass();
     $records = $model->findBySql("SELECT * FROM gcm_relation")->all();
     $params = Yii::$app->getRequest()->getBodyParams();
     $data = array('message' => $params['message'], 'url' => $params['url']);
     $results = array();
     foreach ($records as $record) {
         if ($record->register_key) {
             //Enviar missatge
             $gcm = new GoogleCloudMessage();
             $gcm->apiKey = Setting::Get('gcmAPIKey', 'gcm');
             $gcm->url = Setting::Get('gcmURL', 'gcm');
             $result = $gcm->send($data, array($record->register_key));
             $results[$record->register_key] = $result;
         }
     }
     //Send mail notificacion
     $users = User::find()->distinct()->joinWith(['httpSessions', 'profile'])->where(['status' => User::STATUS_ENABLED]);
     Yii::setAlias('@gcmmodule', Yii::$app->getModule('gcm')->getBasePath());
     foreach ($users->each() as $user) {
         $mail = Yii::$app->mailer->compose(['html' => '@gcmmodule/views/emails/NewMessage'], ['message' => $params['message'], 'url' => $params['url']]);
         $mail->setFrom([Setting::Get('systemEmailAddress', 'mailing') => Setting::Get('systemEmailName', 'mailing')]);
         $mail->setTo($user->email);
         $mail->setSubject('Nova notícia al web: ' . $params['message']);
         $mail->send();
     }
     return true;
 }
 public function init()
 {
     $this->addItemGroup(array('id' => 'manage', 'label' => \Yii::t('AdminModule.widgets_AdminMenuWidget', '<strong>Administration</strong> menu'), 'sortOrder' => 100));
     $this->addItem(array('label' => \Yii::t('AdminModule.widgets_AdminMenuWidget', 'Users'), 'url' => Url::toRoute(['/admin/user']), 'icon' => '<i class="fa fa-user"></i>', 'group' => 'manage', 'sortOrder' => 200, 'isActive' => \Yii::$app->controller->module && \Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'user', 'isVisible' => \Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'User approval'), 'id' => 'approval', 'url' => Url::toRoute('/admin/approval'), 'icon' => '<i class="fa fa-check-circle"></i>', 'group' => 'manage', 'sortOrder' => 201, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'approval', 'isVisible' => Setting::Get('needApproval', 'authentication_internal') && Yii::$app->user->getIdentity()->canApproveUsers()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Groups'), 'id' => 'groups', 'url' => Url::toRoute('/admin/group'), 'icon' => '<i class="fa fa-group"></i>', 'group' => 'manage', 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'group', 'sortOrder' => 300, 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Spaces'), 'id' => 'spaces', 'url' => Url::toRoute('/admin/space'), 'icon' => '<i class="fa fa-inbox"></i>', 'group' => 'manage', 'sortOrder' => 400, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'space', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Modules'), 'id' => 'modules', 'url' => Url::toRoute('/admin/module'), 'icon' => '<i class="fa fa-rocket"></i>', 'sortOrder' => 500, 'group' => 'manage', 'newItemCount' => 0, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'module', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'About'), 'url' => Url::toRoute('/admin/about'), 'icon' => '<i class="fa fa-info-circle"></i>', 'sortOrder' => 10000, 'group' => 'manage', 'newItemCount' => 0, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'about', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItemGroup(array('id' => 'settings', 'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Settings'), 'sortOrder' => 200));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Basic'), 'url' => Url::toRoute('/admin/setting/index'), 'icon' => '<i class="fa fa-cogs"></i>', 'group' => 'settings', 'sortOrder' => 100, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'basic', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Design'), 'url' => Url::toRoute('/admin/setting/design'), 'icon' => '<i class="fa fa-magic"></i>', 'group' => 'settings', 'sortOrder' => 200, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'design', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Authentication'), 'url' => Url::toRoute('/admin/setting/authentication'), 'icon' => '<i class="fa fa-lock"></i>', 'group' => 'settings', 'sortOrder' => 500, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && (Yii::$app->controller->action->id == 'authentication' || Yii::$app->controller->action->id == 'authenticationLdap'), 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'User profiles'), 'url' => Url::toRoute('/admin/user-profile/index'), 'icon' => '<i class="fa fa-wrench"></i>', 'group' => 'settings', 'sortOrder' => 500, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'user-profile', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Mailing'), 'url' => Url::toRoute('/admin/setting/mailing'), 'icon' => '<i class="fa fa-envelope"></i>', 'group' => 'settings', 'sortOrder' => 600, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'mailing', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Caching'), 'url' => Url::toRoute(['/admin/setting/caching']), 'icon' => '<i class="fa fa-dashboard"></i>', 'group' => 'settings', 'sortOrder' => 800, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'caching', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Files'), 'url' => Url::toRoute('/admin/setting/file'), 'icon' => '<i class="fa fa-file"></i>', 'group' => 'settings', 'sortOrder' => 800, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'file', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Proxy'), 'url' => Url::toRoute('/admin/setting/proxy'), 'icon' => '<i class="fa fa-sitemap"></i>', 'group' => 'settings', 'sortOrder' => 800, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'proxy', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Statistics'), 'url' => Url::toRoute('/admin/setting/statistic'), 'icon' => '<i class="fa fa-bar-chart-o"></i>', 'group' => 'settings', 'sortOrder' => 900, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'statistic', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Cron jobs'), 'url' => Url::toRoute('/admin/setting/cronjob'), 'icon' => '<i class="fa fa-history"></i>', 'group' => 'settings', 'sortOrder' => 1000, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'cronjob', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Logging'), 'url' => Url::toRoute('/admin/logging'), 'icon' => '<i class="fa fa-keyboard-o"></i>', 'group' => 'settings', 'sortOrder' => 1100, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'logging', 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'OEmbed Provider'), 'url' => Url::toRoute('/admin/setting/oembed'), 'icon' => '<i class="fa fa-cloud"></i>', 'group' => 'settings', 'sortOrder' => 1200, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && (Yii::$app->controller->action->id == 'oembed' || Yii::$app->controller->action->id == 'oembedEdit'), 'isVisible' => Yii::$app->user->isAdmin()));
     $this->addItem(array('label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Self test & update'), 'url' => Url::toRoute('/admin/setting/self-test'), 'icon' => '<i class="fa fa-warning"></i>', 'group' => 'settings', 'sortOrder' => 1300, 'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'selftest', 'isVisible' => Yii::$app->user->isAdmin()));
     parent::init();
 }
Esempio n. 3
0
 public function actionAuto()
 {
     $this->stdout("Install:\n\n", Console::FG_YELLOW);
     \humhub\modules\installer\libs\InitialData::bootstrap();
     Setting::Set('name', "HumHub Test");
     Setting::Set('systemEmailName', "*****@*****.**", 'mailing');
     Setting::Set('systemEmailName', "*****@*****.**", 'mailing');
     Setting::Set('secret', \humhub\libs\UUID::v4());
     $user = new User();
     $user->group_id = 1;
     $user->username = "******";
     $user->auth_mode = 'local';
     $user->email = '*****@*****.**';
     $user->status = User::STATUS_ENABLED;
     $user->language = '';
     $user->last_activity_email = new \yii\db\Expression('NOW()');
     if (!$user->save()) {
         throw new \yii\base\Exception("Could not save user");
     }
     $user->profile->title = "System Administration";
     $user->profile->firstname = "John";
     $user->profile->lastname = "Doe";
     $user->profile->save();
     $password = new Password();
     $password->user_id = $user->id;
     $password->setPassword('test');
     $password->save();
     return self::EXIT_CODE_NORMAL;
 }
Esempio n. 4
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (Setting::Get('defaultDateInputFormat', 'admin') != '') {
         $this->dateInputFormat = Setting::Get('defaultDateInputFormat', 'admin');
     }
 }
 /**
  * Action to download a folder defined by request param "fid" as a zip file.
  *
  * @throws HttpException
  */
 public function actionDownloadZippedFolder()
 {
     // cleanup all old files
     $this->cleanup();
     // init output directory
     $outputPath = $this->getZipOutputPath();
     // check validity of currentFolder
     $currentFolder = $this->getCurrentFolder();
     if (empty($currentFolder)) {
         throw new HttpException(404, Yii::t('CfilesModule.base', 'The folder with the id %id% does not exist.', ['%id%' => (int) Yii::$app->request->get('fid')]));
     }
     // zip the current folder
     $zipTitle = $this->zipDir($currentFolder, $outputPath);
     $zipPath = $outputPath . DIRECTORY_SEPARATOR . $zipTitle;
     // check if the zip was created
     if (!file_exists($zipPath)) {
         throw new HttpException(404, Yii::t('CfilesModule.base', 'The archive could not be created.'));
     }
     // deliver the zip
     $options = ['inline' => false, 'mimeType' => FileHelper::getMimeTypeByExtension($zipPath)];
     if (!Setting::Get('useXSendfile', 'file')) {
         Yii::$app->response->sendFile($zipPath, $zipTitle, $options);
     } else {
         if (strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') === 0) {
             // set nginx specific X-Sendfile header name
             $options['xHeader'] = 'X-Accel-Redirect';
             // make path relative to docroot
             $docroot = rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR);
             if (substr($zipPath, 0, strlen($docroot)) == $docroot) {
                 $zipPath = substr($zipPath, strlen($docroot));
             }
         }
         Yii::$app->response->xSendFile($zipPath, null, $options);
     }
 }
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     $identity = Yii::$app->user->getIdentity();
     if ($identity != null && !$identity->isActive()) {
         Yii::$app->user->logout();
         Yii::$app->response->redirect(Yii::$app->urlManager->createUrl('user/auth/login'));
     }
     if (Yii::$app->user->isGuest) {
         if (!$this->loggedInOnly && !$this->adminOnly) {
             return true;
         }
         if (in_array($action->id, $this->guestAllowedActions) && Setting::Get('allowGuestAccess', 'authentication_internal') == 1) {
             return true;
         }
         Yii::$app->user->loginRequired();
         return false;
     }
     if ($this->adminOnly && !Yii::$app->user->isAdmin()) {
         $this->forbidden();
     }
     if ($this->loggedInOnly) {
         return true;
     }
     return false;
 }
Esempio n. 7
0
 public function getMailUpdate(User $user, $interval)
 {
     $output = "";
     foreach (Session::find()->where(['<', 'expire', time()])->all() as $session) {
         $session->delete();
     }
     $receive_email_notifications = $user->getSetting("receive_email_notifications", 'core', Setting::Get('receive_email_notifications', 'mailing'));
     // Never receive notifications
     if ($receive_email_notifications == User::RECEIVE_EMAIL_NEVER) {
         return "";
     }
     // We are in hourly mode and user wants daily
     if ($interval == CronController::EVENT_ON_HOURLY_RUN && $receive_email_notifications == User::RECEIVE_EMAIL_DAILY_SUMMARY) {
         return "";
     }
     // We are in daily mode and user dont wants daily reports
     if ($interval == CronController::EVENT_ON_DAILY_RUN && $receive_email_notifications != User::RECEIVE_EMAIL_DAILY_SUMMARY) {
         return "";
     }
     // User wants only when offline and is online
     if ($interval == CronController::EVENT_ON_HOURLY_RUN) {
         $isOnline = count($user->httpSessions) > 0;
         if ($receive_email_notifications == User::RECEIVE_EMAIL_WHEN_OFFLINE && $isOnline) {
             return "";
         }
     }
     $query = Notification::find()->where(['user_id' => $user->id])->andWhere(['!=', 'seen', 1])->andWhere(['!=', 'emailed', 1]);
     foreach ($query->all() as $notification) {
         $output .= $notification->getClass()->render(BaseNotification::OUTPUT_MAIL);
         $notification->emailed = 1;
         $notification->save();
     }
     return $output;
 }
 /**
  * Configuration Action for Super Admins.
  */
 public function actionIndex()
 {
     $post = $this->getPost(array('SmsProviderConfigureForm', 'AnySmsConfigureForm', 'ClickatellConfigureForm', 'SpryngConfigureForm'));
     if ($post != null) {
         $provider = $post['provider'];
         $form = $this->getSmsProviderForm($provider);
         // provider changed => just change the provider setting and reload the correct form
         if ($provider != Setting::Get('provider', 'sms')) {
             $form = new \humhub\modules\sms\forms\SmsProviderConfigureForm();
         } else {
             $form = $this->getSmsProviderForm($provider);
         }
         $form->setAttributes($post);
         if ($form->validate()) {
             foreach ($form->attributeNames() as $attributeName) {
                 Setting::Set($attributeName, $form->{$attributeName}, 'sms');
             }
             return $this->redirect(['/sms/config']);
         }
     } else {
         $provider = Setting::Get('provider', 'sms');
         $form = $this->getSmsProviderForm($provider);
         foreach ($form->attributeNames() as $attributeName) {
             $form->{$attributeName} = Setting::Get($attributeName, 'sms');
         }
     }
     return $this->render('index', array('model' => $form));
 }
Esempio n. 9
0
 /**
  * Checks if the application is already configured.
  */
 public function isConfigured()
 {
     if (\humhub\models\Setting::Get('secret') != "") {
         return true;
     }
     return false;
 }
Esempio n. 10
0
 public function actionIndex()
 {
     $keyword = Yii::$app->request->get('keyword', "");
     $scope = Yii::$app->request->get('scope', "");
     $page = (int) Yii::$app->request->get('page', 1);
     $limitSpaceGuids = Yii::$app->request->get('limitSpaceGuids', "");
     $limitSpaces = array();
     if ($limitSpaceGuids !== "") {
         foreach (explode(",", $limitSpaceGuids) as $guid) {
             $guid = trim($guid);
             if ($guid != "") {
                 $space = Space::findOne(['guid' => trim($guid)]);
                 if ($space !== null) {
                     $limitSpaces[] = $space;
                 }
             }
         }
     }
     $options = ['page' => $page, 'sort' => $keyword == '' ? 'title' : null, 'pageSize' => Setting::Get('paginationSize'), 'limitSpaces' => $limitSpaces];
     if ($scope == self::SCOPE_CONTENT) {
         $options['type'] = \humhub\modules\search\engine\Search::DOCUMENT_TYPE_CONTENT;
     } elseif ($scope == self::SCOPE_SPACE) {
         $options['model'] = Space::className();
     } elseif ($scope == self::SCOPE_USER) {
         $options['model'] = User::className();
     } else {
         $scope = self::SCOPE_ALL;
     }
     $searchResultSet = Yii::$app->search->find($keyword, $options);
     $pagination = new \yii\data\Pagination();
     $pagination->totalCount = $searchResultSet->total;
     $pagination->pageSize = $searchResultSet->pageSize;
     return $this->render('index', array('scope' => $scope, 'keyword' => $keyword, 'results' => $searchResultSet->getResultInstances(), 'pagination' => $pagination, 'totals' => $this->getTotals($keyword, $options), 'limitSpaceGuids' => $limitSpaceGuids));
 }
Esempio n. 11
0
 /**
  * Executes the widgets
  */
 public function run()
 {
     if (Yii::$app->user->isGuest) {
         return;
     }
     // Active tour flag not set
     if (!isset($_GET['tour'])) {
         return;
     }
     // Tour only possible when we are in a module
     if (Yii::$app->controller->module === null) {
         return;
     }
     // Check if tour is activated by admin and users
     if (Setting::Get('enable', 'tour') == 0 || Yii::$app->user->getIdentity()->getSetting("hideTourPanel", "tour") == 1) {
         return;
     }
     // save current module and controller id's
     $currentModuleId = Yii::$app->controller->module->id;
     $currentControllerId = Yii::$app->controller->id;
     if ($currentModuleId == "dashboard" && $currentControllerId == "dashboard") {
         return $this->render('guide_interface');
     } elseif ($currentModuleId == "space" && $currentControllerId == "space") {
         return $this->render('guide_spaces', array());
     } elseif ($currentModuleId == "user" && $currentControllerId == "profile") {
         return $this->render('guide_profile', array());
     } elseif ($currentModuleId == "admin" && $currentControllerId == "module") {
         return $this->render('guide_administration', array());
     }
 }
 public function actionIndex()
 {
     if (!Setting::Get('apiKey', 'dropbox')) {
         return $this->render('errorMissingKey', array());
     }
     $model = new CreateDropboxPostForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $dropboxPost = new DropboxPost();
         $dropboxPost->message = $model->message;
         $dropboxPost->content->container = $this->contentContainer;
         $dropboxPost->content->visibility = $this->contentContainer->visibility;
         $dropboxPost->save();
         $dropboxFileIds = explode(",", $model->dropboxFileId);
         foreach ($dropboxFileIds as $dropboxFileId) {
             if ($dropboxFileId != null) {
                 $dropboxFile = DropboxFile::findOne(['id' => $dropboxFileId]);
                 if ($dropboxFile->object_model != DropboxPost::className() || $dropboxFile->object_id != $dropboxPost->id) {
                     $dropboxFile->object_model = DropboxPost::className();
                     $dropboxFile->object_id = $dropboxPost->id;
                     $dropboxFile->save();
                 }
             }
         }
         return $this->htmlRedirect($this->contentContainer->createUrl());
     }
     return $this->render('index', array('model' => $model));
 }
 public function up()
 {
     if (\humhub\models\Setting::isInstalled()) {
         $this->alterColumn('profile', 'zip', 'VARCHAR(10) DEFAULT NULL');
         $this->update('profile_field', array('field_type_class' => 'ProfileFieldTypeText', 'field_type_config' => '{"minLength":null,"maxLength":10,"validator":null,"default":null,"regexp":null,"regexpErrorMessage":null}'), 'internal_name="zip"');
     }
 }
 /**
  * HumHub API
  * 
  * @param string $action
  * @param array $params
  * @return array
  */
 public static function request($action, $params = [])
 {
     if (!Yii::$app->params['humhub']['apiEnabled']) {
         return [];
     }
     $url = Yii::$app->params['humhub']['apiUrl'] . '/' . $action;
     $params['version'] = urlencode(Yii::$app->version);
     $params['installId'] = Setting::Get('installationId', 'admin');
     $url .= '?';
     foreach ($params as $name => $value) {
         $url .= urlencode($name) . '=' . urlencode($value) . "&";
     }
     try {
         $http = new \Zend\Http\Client($url, array('adapter' => '\\Zend\\Http\\Client\\Adapter\\Curl', 'curloptions' => CURLHelper::getOptions(), 'timeout' => 30));
         $response = $http->send();
         $json = $response->getBody();
     } catch (\Zend\Http\Client\Adapter\Exception\RuntimeException $ex) {
         Yii::error('Could not connect to HumHub API! ' . $ex->getMessage());
         return [];
     } catch (Exception $ex) {
         Yii::error('Could not get HumHub API response! ' . $ex->getMessage());
         return [];
     }
     try {
         return Json::decode($json);
     } catch (\yii\base\InvalidParamException $ex) {
         Yii::error('Could not parse HumHub API response! ' . $ex->getMessage());
         return [];
     }
 }
 public function up()
 {
     $this->dropTable(UserChatMessage::tableName());
     $this->createTable(UserChatMessage::tableName(), ['id' => $this->primaryKey(), 'message' => $this->text()->notNull(), 'created_at' => $this->dateTime()->notNull(), 'created_by' => $this->integer()->notNull()]);
     Setting::Set('theme', 'theme_bright.css', 'humhubchat');
     Setting::Set('timeout', '1', 'humhubchat');
 }
Esempio n. 16
0
 /**
  * Check if there is a new Humhub Version available and sends a notification
  * to super admins
  *
  * @param \yii\base\Event $event
  */
 public static function onCronDailyRun($event)
 {
     $controller = $event->sender;
     if (!Yii::$app->getModule('admin')->dailyCheckForNewVersion) {
         return;
     }
     if (!Yii::$app->params['humhub']['apiEnabled']) {
         return;
     }
     $controller->stdout("Checking for new HumHub version... ");
     $latestVersion = libs\HumHubAPI::getLatestHumHubVersion();
     if ($latestVersion != "") {
         $adminUserQuery = User::find()->where(['super_admin' => 1]);
         $latestNotifiedVersion = Setting::Get('lastVersionNotify', 'admin');
         $adminsNotified = !($latestNotifiedVersion == "" || version_compare($latestVersion, $latestNotifiedVersion, ">"));
         $newVersionAvailable = version_compare($latestVersion, Yii::$app->version, ">");
         $updateNotification = new notifications\NewVersionAvailable();
         // Cleanup existing notifications
         if (!$newVersionAvailable || $newVersionAvailable && !$adminsNotified) {
             foreach ($adminUserQuery->all() as $admin) {
                 $updateNotification->delete($admin);
             }
         }
         // Create new notification
         if ($newVersionAvailable && !$adminsNotified) {
             $updateNotification->sendBulk($adminUserQuery);
             Setting::Set('lastVersionNotify', $latestVersion, 'admin');
         }
     }
     $controller->stdout('done. ' . PHP_EOL, \yii\helpers\Console::FG_GREEN);
 }
Esempio n. 17
0
 function __construct()
 {
     $this->baseUrl = "http://api.clickatell.com/http/sendmsg";
     $this->api_id = Setting::Get('apiid_clickatell', 'sms');
     $this->user_id = Setting::Get('username_clickatell', 'sms');
     $this->pass = Setting::Get('password_clickatell', 'sms');
 }
 public function up()
 {
     if (Setting::isInstalled()) {
         $this->insert('setting', array('name' => 'enable_html5_desktop_notifications', 'value' => 0, 'module_id' => 'notification'));
     }
     $this->addColumn('notification', 'desktop_notified', 'tinyint(1) DEFAULT 0');
     $this->update('notification', array('desktop_notified' => 1));
 }
Esempio n. 19
0
 /**
  * Dashboard Index
  *
  * Show recent wall entries for this user
  */
 public function actionIndex()
 {
     if (Yii::$app->user->isGuest) {
         return $this->render('index_guest', array());
     } else {
         return $this->render('index', array('showProfilePostForm' => Setting::Get('showProfilePostForm', 'dashboard')));
     }
 }
 public function run()
 {
     $users = ActiveUser::find()->limit((int) Setting::Get('noUsers', 'mostactiveusers'))->all();
     if (count($users) == 0) {
         return;
     }
     return $this->render('sidebar', array('users' => $users));
 }
Esempio n. 21
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')));
     }
 }
Esempio n. 22
0
 public static function onSidebarInit($event)
 {
     if (Setting::Get('enable', 'share') == 1) {
         if (Yii::$app->user->isGuest || Yii::$app->user->getIdentity()->getSetting("hideSharePanel", "share") != 1) {
             $event->sender->addWidget(ShareWidget::className(), array(), array('sortOrder' => 150));
         }
     }
 }
Esempio n. 23
0
 function __construct()
 {
     $this->baseUrl = "https://www.any-sms.biz/gateway/send_sms.php";
     $this->id = Setting::Get('username_anysms', 'sms');
     $this->pass = Setting::Get('password_anysms', 'sms');
     $this->gateway = Setting::Get('gateway_anysms', 'sms');
     $this->test = Setting::Get('test_anysms', 'sms');
 }
Esempio n. 24
0
 public function send($email)
 {
     $mail = Yii::$app->mailer->compose(['html' => '@humhub/views/mail/TextOnly'], ['message' => $this->message]);
     $mail->setFrom([\humhub\models\Setting::Get('systemEmailAddress', 'mailing') => \humhub\models\Setting::Get('systemEmailName', 'mailing')]);
     $mail->setTo($email);
     $mail->setSubject($this->subject);
     $mail->send();
 }
Esempio n. 25
0
 /**
  * Executes daily cron tasks.
  */
 public function actionDaily()
 {
     $this->stdout("Executing daily tasks:\n\n", Console::FG_YELLOW);
     $this->trigger(self::EVENT_ON_DAILY_RUN);
     $this->stdout("\n\nAll cron tasks finished.\n\n", Console::FG_GREEN);
     Setting::Set('cronLastDailyRun', time());
     return self::EXIT_CODE_NORMAL;
 }
 /**
  * Enables this module
  */
 public function enable()
 {
     if (!Yii::$app->hasModule('mostactiveusers')) {
         // set default config values
         Setting::Set('noUsers', 5, 'mostactiveusers');
     }
     parent::enable();
 }
 /**
  * Configuration action for super admins.
  */
 public function actionIndex()
 {
     $form = new ConfigureForm();
     $form->disableZipSupport = Setting::Get('disableZipSupport', 'cfiles');
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         Setting::Set('disableZipSupport', $form->disableZipSupport, 'cfiles');
     }
     return $this->render('index', array('model' => $form));
 }
Esempio n. 28
0
 public static function onDashboardSidebarInit($event)
 {
     if (Yii::$app->user->isGuest) {
         return;
     }
     if (Setting::Get('enable', 'tour') == 1 && Yii::$app->user->getIdentity()->getSetting("hideTourPanel", "tour") != 1) {
         $event->sender->addWidget(Dashboard::className(), array(), array('sortOrder' => 100));
     }
 }
Esempio n. 29
0
 public function run()
 {
     $user = Yii::$app->user->getIdentity();
     $showUserApprovals = false;
     if (!Yii::$app->user->isGuest && Setting::Get('needApproval', 'authentication_internal') && $user->canApproveUsers()) {
         $showUserApprovals = true;
     }
     return $this->render('accountTopMenu', ['showUserApprovals' => $showUserApprovals, 'user' => $user]);
 }
Esempio n. 30
0
 public function init()
 {
     $theme = Setting::Get('theme', 'humhubchat');
     if ($theme) {
         $this->css = [$theme];
     }
     $this->sourcePath = dirname(__FILE__) . '/assets';
     parent::init();
 }