/**
  * Attaches files by url which found in content text.
  * This is experimental and only supports image files at the moment.
  *
  * @param HActiveRecord $record to bind files to
  * @param String $text to parse for links 
  */
 public static function attachFiles($record, $text)
 {
     if (!$record instanceof HActiveRecord) {
         throw new CException("Invalid content object given!");
     }
     $max = 5;
     $count = 1;
     $text = preg_replace_callback('/http(.*?)(\\s|$)/i', function ($match) use(&$count, &$max, &$record) {
         if ($max > $count) {
             $url = $match[0];
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
             curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
             curl_setopt($ch, CURLOPT_HEADER, true);
             curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
             curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
             if (HSetting::Get('enabled', 'proxy')) {
                 curl_setopt($ch, CURLOPT_PROXY, HSetting::Get('server', 'proxy'));
                 curl_setopt($ch, CURLOPT_PROXYPORT, HSetting::Get('port', 'proxy'));
                 if (defined('CURLOPT_PROXYUSERNAME')) {
                     curl_setopt($ch, CURLOPT_PROXYUSERNAME, HSetting::Get('user', 'proxy'));
                 }
                 if (defined('CURLOPT_PROXYPASSWORD')) {
                     curl_setopt($ch, CURLOPT_PROXYPASSWORD, HSetting::Get('pass', 'proxy'));
                 }
                 if (defined('CURLOPT_NOPROXY')) {
                     curl_setopt($ch, CURLOPT_NOPROXY, HSetting::Get('noproxy', 'proxy'));
                 }
             }
             $ret = curl_exec($ch);
             $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
             $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
             list($headers, $outputContent) = explode("\r\n\r\n", $ret, 2);
             curl_close($ch);
             if ($httpCode == 200 && substr($contentType, 0, 6) == 'image/') {
                 $extension = 'img';
                 if ($contentType == 'image/jpeg' || $contentType == 'image/jpg') {
                     $extension = 'jpg';
                 } elseif ($contentType == 'image/gif') {
                     $extension = 'gif';
                 } elseif ($contentType == 'image/png') {
                     $extension = 'png';
                 }
                 $file = new File();
                 $file->object_model = get_class($record);
                 $file->object_id = $record->getPrimaryKey();
                 $file->mime_type = $contentType;
                 $file->title = "Link Image";
                 $file->file_name = "LinkImage." . $extension;
                 $file->newFileContent = $outputContent;
                 $file->validate();
                 $file->save();
             }
         }
         $count++;
     }, $text);
 }
Example #2
0
 public function testFixedSettings()
 {
     Yii::app()->params['HSettingFixed'] = array('test' => 'abc');
     $this->assertEquals(HSetting::Get('test'), 'abc');
     HSetting::Set('test', 'bcd');
     $this->assertEquals(HSetting::Get('test'), 'abc');
 }
Example #3
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 (HSetting::Get('enable', 'tour') == 0 || Yii::app()->user->getModel()->getSetting("hideTourPanel", "tour") == 1) {
         return;
     }
     $this->loadResources();
     // save current module and controller id's
     $currentModuleId = Yii::app()->controller->module->id;
     $currentControllerId = Yii::app()->controller->id;
     if ($currentModuleId == "dashboard" && $currentControllerId == "dashboard") {
         $this->render('guide_interface');
     } elseif ($currentModuleId == "space" && $currentControllerId == "space") {
         $this->render('guide_spaces', array());
     } elseif ($currentModuleId == "user" && $currentControllerId == "profile") {
         $this->render('guide_profile', array());
     } elseif ($currentModuleId == "admin" && $currentControllerId == "module") {
         $this->render('guide_administration', array());
     }
 }
Example #4
0
 /**
  * This is the action to handle external exceptions.
  */
 public function actionIndex()
 {
     if ($error = Yii::app()->errorHandler->error) {
         if (Yii::app()->request->isAjaxRequest) {
             echo CHtml::encode($error['message']);
             return;
         }
         /**
          * Switch to plain base layout, in case the user is not logged in
          * and public access is disabled.
          */
         if (Yii::app()->user->isGuest && !HSetting::Get('allowGuestAccess', 'authentication_internal')) {
             $this->layout = "application.views.error._layout";
         }
         if ($error['type'] == 'CHttpException') {
             switch ($error['code']) {
                 case 401:
                     Yii::app()->user->returnUrl = Yii::app()->request->requestUri;
                     return $this->render('401', $error);
                     break;
             }
         }
         $this->render('index', $error);
     }
 }
 /**
  * Configuration Action for Super Admins
  */
 public function actionIndex()
 {
     Yii::import('library.forms.*');
     $form = new LibraryAdminForm();
     // uncomment the following code to enable ajax-based validation
     //if (isset($_POST['ajax']) && $_POST['ajax'] === 'LibraryAdminForm') {
     //    echo CActiveForm::validate($form);
     //    Yii::app()->end();
     //}
     if (isset($_POST['LibraryAdminForm'])) {
         $_POST['LibraryAdminForm'] = Yii::app()->input->stripClean($_POST['LibraryAdminForm']);
         $form->attributes = $_POST['LibraryAdminForm'];
         if ($form->validate()) {
             $form->globalPublicLibrary = HSetting::Set('globalPublicLibrary', $form->globalPublicLibrary, 'library');
             $form->disclaimerWidget = HSetting::Set('disclaimerWidget', $form->disclaimerWidget, 'library');
             $form->disclaimerTitle = HSetting::Set('disclaimerTitle', $form->disclaimerTitle, 'library');
             $form->disclaimerContent = HSetting::Set('disclaimerContent', $form->disclaimerContent, 'library');
             $this->redirect(Yii::app()->createUrl('library/admin/index'));
         }
     } else {
         $form->globalPublicLibrary = HSetting::Get('globalPublicLibrary', 'library');
         $form->disclaimerWidget = HSetting::Get('disclaimerWidget', 'library');
         $form->disclaimerTitle = HSetting::Get('disclaimerTitle', 'library');
         $form->disclaimerContent = HSetting::Get('disclaimerContent', 'library');
     }
     $this->render('index', array('model' => $form));
 }
Example #6
0
 /**
  * Checks if the application is already configured.
  */
 public function isConfigured()
 {
     if (HSetting::Get('secret') != "") {
         return true;
     }
     return false;
 }
Example #7
0
 /**
  * Dashboard Index
  *
  * Show recent wall entries for this user
  */
 public function actionIndex()
 {
     if (Yii::app()->user->isGuest) {
         $this->render('index_guest', array());
     } else {
         $this->render('index', array('showProfilePostForm' => HSetting::Get('showProfilePostForm', 'dashboard')));
     }
 }
Example #8
0
 /**
  * Do general tasks used application whide
  */
 protected function doBaseTasks()
 {
     $this->showTestHeadline("Checking application base structure");
     if (HSetting::Get('secret') == "" || HSetting::Get('secret') == null) {
         HSetting::Set('secret', UUID::v4());
         $this->showFix('Setting missing application secret!');
     }
 }
Example #9
0
 /**
  * Executes the widget.
  */
 public function run()
 {
     $blacklisted_objects = explode(',', HSetting::GetText('showFilesWidgetBlacklist', 'file'));
     if (!in_array(get_class($this->object), $blacklisted_objects)) {
         $files = File::getFilesOfObject($this->object);
         $this->render('showFiles', array('files' => $files, 'maxPreviewImageWidth' => HSetting::Get('maxPreviewImageWidth', 'file'), 'maxPreviewImageHeight' => HSetting::Get('maxPreviewImageHeight', 'file'), 'hideImageFileInfo' => HSetting::Get('hideImageFileInfo', 'file')));
     }
 }
 public function run()
 {
     $disclaimerWidget = HSetting::Get('disclaimerWidget', 'library');
     $disclaimerTitle = HSetting::Get('disclaimerTitle', 'library');
     $disclaimerContent = HSetting::Get('disclaimerContent', 'library');
     if ($disclaimerWidget) {
         $this->render('disclaimerPanel', array('disclaimerTitle' => $disclaimerTitle, 'disclaimerContent' => $disclaimerContent));
     }
 }
Example #11
0
 public static function onDashboardSidebarInit($event)
 {
     if (Yii::app()->user->isGuest) {
         return;
     }
     if (HSetting::Get('enable', 'tour') == 1 && Yii::app()->user->getModel()->getSetting("hideTourPanel", "tour") != 1) {
         $event->sender->addWidget('application.modules_core.tour.widgets.TourDashboardWidget', array(), array('sortOrder' => 0));
     }
 }
 /**
  * Sets some mandatory request infos to ensure absolute url creation.
  * These values are extracted from baseUrl which is stored as HSetting.
  */
 private function setupRequestInfo()
 {
     $parsedUrl = parse_url(HSetting::Get('baseUrl'));
     $path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '';
     $port = isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : '';
     Yii::app()->request->setHostInfo($parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port);
     Yii::app()->request->setBaseUrl(HSetting::Get('baseUrl'));
     Yii::app()->request->setScriptUrl($path . '/index.php');
 }
Example #13
0
 public function send($email)
 {
     $message = new HMailMessage();
     $message->addFrom(HSetting::Get('systemEmailAddress', 'mailing'), HSetting::Get('systemEmailName', 'mailing'));
     $message->addTo($email);
     $message->view = "application.views.mail.TextOnly";
     $message->subject = $this->subject;
     $message->setBody(array('message' => $this->message), 'text/html');
     Yii::app()->mail->send($message);
 }
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     if (HSetting::Get('roomOrder', 'room') == 0) {
         $criteria->order = 'name ASC';
     } else {
         $criteria->order = 'last_visit DESC';
     }
     $memberships = RoomMembership::model()->with('room')->findAllByAttributes(array('user_id' => Yii::app()->user->id, 'status' => RoomMembership::STATUS_MEMBER), $criteria);
     $this->renderPartial('index', array('memberships' => $memberships), false, true);
 }
Example #15
0
 /**
  * Like Count for specifc model
  */
 public static function GetLikes($objectModel, $objectId)
 {
     $cacheId = "likes_" . $objectModel . "_" . $objectId;
     $cacheValue = Yii::app()->cache->get($cacheId);
     if ($cacheValue === false) {
         $newCacheValue = Like::model()->findAllByAttributes(array('object_model' => $objectModel, 'object_id' => $objectId));
         Yii::app()->cache->set($cacheId, $newCacheValue, HSetting::Get('expireTime', 'cache'));
         return $newCacheValue;
     } else {
         return $cacheValue;
     }
 }
Example #16
0
 /**
  * Returns a workspace list by json
  *
  * It can be filtered by by keyword.
  */
 public function actionSearchJson()
 {
     $keyword = Yii::app()->request->getParam('keyword', "");
     // guid of user/workspace
     $page = (int) Yii::app()->request->getParam('page', 1);
     // current page (pagination)
     $limit = (int) Yii::app()->request->getParam('limit', HSetting::Get('paginationSize'));
     // current page (pagination)
     $keyword = Yii::app()->input->stripClean($keyword);
     $hitCount = 0;
     $query = "model:Space ";
     if (strlen($keyword) > 2) {
         // Include Keyword
         if (strpos($keyword, "@") === false) {
             $keyword = str_replace(".", "", $keyword);
             $query .= "AND (title:" . $keyword . "* OR tags:" . $keyword . "*)";
         }
     }
     //, $limit, $page
     $hits = new ArrayObject(HSearch::getInstance()->Find($query));
     $hitCount = count($hits);
     // Limit Hits
     $hits = new LimitIterator($hits->getIterator(), ($page - 1) * $limit, $limit);
     $json = array();
     #$json['totalHits'] = $hitCount;
     #$json['limit'] = $limit;
     #$results = array();
     foreach ($hits as $hit) {
         $doc = $hit->getDocument();
         $model = $doc->getField("model")->value;
         if ($model == "Space") {
             $workspaceId = $doc->getField('pk')->value;
             $workspace = Space::model()->findByPk($workspaceId);
             if ($workspace != null) {
                 $wsInfo = array();
                 $wsInfo['guid'] = $workspace->guid;
                 $wsInfo['title'] = CHtml::encode($workspace->name);
                 $wsInfo['tags'] = CHtml::encode($workspace->tags);
                 $wsInfo['image'] = $workspace->getProfileImage()->getUrl();
                 $wsInfo['link'] = $workspace->getUrl();
                 #$results[] = $wsInfo;
                 $json[] = $wsInfo;
             } else {
                 Yii::log("Could not load workspace with id " . $userId . " from search index!", CLogger::LEVEL_ERROR);
             }
         } else {
             Yii::log("Got no workspace hit from search index!", CLogger::LEVEL_ERROR);
         }
     }
     #$json['results'] = $results;
     print CJSON::encode($json);
     Yii::app()->end();
 }
 public function up()
 {
     $allowedExtensions = HSetting::Get('allowedExtensions', 'file');
     if ($allowedExtensions != "") {
         HSetting::Set('allowedExtensions', '', 'file');
         HSetting::SetText('allowedExtensions', $allowedExtensions, 'file');
     }
     $showFilesWidgetBlacklist = HSetting::Get('showFilesWidgetBlacklist', 'file');
     if ($showFilesWidgetBlacklist != "") {
         HSetting::Set('showFilesWidgetBlacklist', '', 'file');
         HSetting::SetText('showFilesWidgetBlacklist', $showFilesWidgetBlacklist, 'file');
     }
 }
 /**
  * Sends Change E-Mail E-Mail
  *
  */
 public function sendChangeEmail()
 {
     if ($this->validate()) {
         $user = User::model()->findByPk(Yii::app()->user->id);
         $token = md5(HSetting::Get('secret') . $user->guid . $this->newEmail);
         $message = new HMailMessage();
         $message->view = "application.modules_core.user.views.mails.ChangeEmail";
         $message->addFrom(HSetting::Get('systemEmailAddress', 'mailing'), HSetting::Get('systemEmailName', 'mailing'));
         $message->addTo($this->newEmail);
         $message->subject = Yii::t('UserModule.forms_AccountChangeEmailForm', 'E-Mail change');
         $message->setBody(array('user' => $user, 'newEmail' => $this->newEmail, 'token' => $token), 'text/html');
         Yii::app()->mail->send($message);
     }
 }
Example #19
0
 /**
  * Run method for CronRunner
  *
  * @param type $args
  */
 public function run($args)
 {
     $this->printHeader('Cron Interface');
     if (!isset($args[0]) || $args[0] != "daily" && $args[0] != 'hourly') {
         print "\n Run with parameter:\n" . "\t daily - for Daily Interval\n" . "\t hourly - for Hourly Interval \n";
         print "\n\n";
         exit;
     }
     // Set current interval to attribute
     if ($args[0] == 'daily') {
         $this->interval = self::INTERVAL_DAILY;
     } elseif ($args[0] == 'hourly') {
         $this->interval = self::INTERVAL_HOURLY;
     } else {
         throw new CException(500, 'Invalid cron interval!');
     }
     // Do some base tasks, handle by event in future
     if ($this->interval == self::INTERVAL_HOURLY) {
         // Raise Event for Module specific tasks
         if ($this->hasEventHandler('onHourlyRun')) {
             $this->onHourlyRun(new CEvent($this));
         }
         print "- Optimizing Search Index\n";
         // Optimize Search Index
         HSearch::getInstance()->Optimize();
         if (HSetting::Get('enabled', 'authentication_ldap') && HSetting::Get('refreshUsers', 'authentication_ldap')) {
             print "- Updating LDAP Users\n";
             HLdap::getInstance()->refreshUsers();
         }
         print "- Invoking EMailing hourly\n\n";
         // Execute Hourly Mailing Runner
         Yii::import('application.commands.shell.EMailing.*');
         $command = new EMailing('test', 'test');
         $command->run(array('hourly'));
         HSetting::Set('cronLastHourlyRun', time());
     } elseif ($this->interval == self::INTERVAL_DAILY) {
         // Raise Event for Module specific tasks
         if ($this->hasEventHandler('onDailyRun')) {
             $this->onDailyRun(new CEvent($this));
         }
         // Execute Daily Mailing Runner
         print "- Invoking EMailing daily\n\n";
         Yii::import('application.commands.shell.EMailing.*');
         $command = new EMailing('test', 'test');
         $command->run(array('daily'));
         HSetting::Set('cronLastDailyRun', time());
     }
 }
 /**
  * Delete All Albums and settings.
  */
 public function disable()
 {
     if (parent::disable()) {
         foreach (Album::model()->findAll() as $album) {
             $album->delete();
         }
         $blacklisted_objects = explode(',', HSetting::Get('showFilesWidgetBlacklist', 'file'));
         if (false !== ($key = array_search('Album', $blacklisted_objects))) {
             unset($blacklisted_objects[$key]);
             HSetting::Set('showFilesWidgetBlacklist', implode(',', $blacklisted_objects));
         }
         HSetting::set('allowedExtensions', '', 'album');
         return true;
     }
     return false;
 }
 /**
  * Sends this user a new password by E-Mail
  *
  */
 public function recoverPassword()
 {
     $user = User::model()->findByAttributes(array('email' => $this->email));
     // Switch to users language - if specified
     if ($user->language !== "") {
         Yii::app()->language = $user->language;
     }
     $token = UUID::v4();
     $user->setSetting('passwordRecoveryToken', $token . '.' . time(), 'user');
     $message = new HMailMessage();
     $message->view = "application.modules_core.user.views.mails.RecoverPassword";
     $message->addFrom(HSetting::Get('systemEmailAddress', 'mailing'), HSetting::Get('systemEmailName', 'mailing'));
     $message->addTo($this->email);
     $message->subject = Yii::t('UserModule.forms_AccountRecoverPasswordForm', 'Password Recovery');
     $message->setBody(array('user' => $user, 'linkPasswordReset' => Yii::app()->createAbsoluteUrl("//user/auth/resetPassword", array('token' => $token, 'guid' => $user->guid))), 'text/html');
     Yii::app()->mail->send($message);
 }
Example #22
0
 /**
  * Returns user records
  *
  * @return User
  */
 private function getUser()
 {
     // Find User
     $criteria = new CDbCriteria();
     $criteria->condition = 'username=:userName OR email=:email';
     $criteria->params = array(':userName' => $this->username, ':email' => $this->username);
     $user = User::model()->resetScope()->find($criteria);
     // If user not found in db and ldap is enabled, do ldap lookup and create it when found
     if ($user === null && HSetting::Get('enabled', 'authentication_ldap')) {
         try {
             $usernameDn = HLdap::getInstance()->ldap->getCanonicalAccountName($this->username, Zend_Ldap::ACCTNAME_FORM_DN);
             HLdap::getInstance()->handleLdapUser(HLdap::getInstance()->ldap->getNode($usernameDn));
             $user = User::model()->findByAttributes(array('username' => $this->username));
         } catch (Exception $ex) {
         }
     }
     return $user;
 }
 /**
  * Sends this user a new password by E-Mail
  *
  */
 public function recoverPassword()
 {
     $user = User::model()->findByAttributes(array('email' => $this->email));
     // Switch to users language
     Yii::app()->language = Yii::app()->user->language;
     // Set New Password
     $userPassword = new UserPassword();
     $userPassword->user_id = $user->id;
     $newPassword = $userPassword->setRandomPassword();
     $userPassword->save();
     $message = new HMailMessage();
     $message->view = "application.modules_core.user.views.mails.RecoverPassword";
     $message->addFrom(HSetting::Get('systemEmailAddress', 'mailing'), HSetting::Get('systemEmailName', 'mailing'));
     $message->addTo($this->email);
     $message->subject = Yii::t('UserModule.forms_AccountRecoverPasswordForm', 'Password Recovery');
     $message->setBody(array('user' => $user, 'newPassword' => $newPassword), 'text/html');
     Yii::app()->mail->send($message);
 }
Example #24
0
 /**
  * Initializes the module manager
  */
 public function init()
 {
     parent::init();
     if (Yii::app()->params['installed']) {
         // Load all enabled modules
         $cacheId = "enabledModules";
         $cacheValue = Yii::app()->cache->get($cacheId);
         if ($cacheValue === false || !is_array($cacheValue)) {
             foreach (ModuleEnabled::model()->findAll() as $em) {
                 $this->enabledModules[] = $em->module_id;
             }
             Yii::app()->cache->set($cacheId, $this->enabledModules, HSetting::Get('expireTime', 'cache'));
         } else {
             $this->enabledModules = $cacheValue;
         }
     }
     // Intercept this controller
     Yii::app()->interceptor->intercept($this);
 }
 /**
  * Returns a room list by json
  *
  * It can be filtered by by keyword.
  */
 public function actionSearchJson()
 {
     $keyword = Yii::app()->request->getParam('keyword', "");
     $page = (int) Yii::app()->request->getParam('page', 1);
     $limit = (int) Yii::app()->request->getParam('limit', HSetting::Get('paginationSize'));
     $searchResultSet = Yii::app()->search->find($keyword, ['model' => 'Room', 'page' => $page, 'pageSize' => $limit]);
     $json = array();
     foreach ($searchResultSet->getResultInstances() as $room) {
         $roomInfo = array();
         $roomInfo['guid'] = $room->guid;
         $roomInfo['title'] = CHtml::encode($room->name);
         $roomInfo['tags'] = CHtml::encode($room->tags);
         $roomInfo['image'] = $room->getProfileImage()->getUrl();
         $roomInfo['link'] = $room->getUrl();
         $json[] = $roomInfo;
     }
     print CJSON::encode($json);
     Yii::app()->end();
 }
 public function up()
 {
     $connection = $this->getDbConnection();
     // Create New User Password Table
     $this->createTable('user_password', array('id' => 'pk', 'user_id' => 'int(10) DEFAULT NULL', 'algorithm' => 'varchar(20) DEFAULT NULL', 'password' => 'text DEFAULT NULL', 'salt' => 'text DEFAULT NULL', 'created_at' => 'datetime DEFAULT NULL'), '');
     $this->createIndex('idx_user_id', 'user_password', 'user_id', false);
     // Migrate Passwords from User Table to UserPasswords
     $command = $connection->commandBuilder->createFindCommand('user', new CDbCriteria());
     $reader = $command->query();
     $algorithm = 'sha1md5';
     foreach ($reader as $row) {
         $userId = $row['id'];
         $password = $row['password'];
         $password = str_replace('___enc___', '', $password);
         $insertCommand = $connection->commandBuilder->createInsertCommand('user_password', array('user_id' => $userId, 'password' => $password, 'algorithm' => $algorithm, 'salt' => HSetting::Get('secret'), 'created_at' => new CDbExpression("NOW()")));
         $insertCommand->execute();
     }
     $this->dropColumn('user', 'password');
 }
Example #27
0
 public function run($args)
 {
     print " E-Mail - Test Interface\n";
     print "-------------------------------------------------------------------------\n\n";
     if (!isset($args[0]) || $args[0] == "") {
         print "\n Run with parameter [email]!\n" . (print "\n\n");
         exit;
     }
     $email = $args[0];
     $user = User::model()->findByPk(1);
     $message = new HMailMessage();
     $message->view = 'application.views.mail.EMailing';
     $message->addFrom(HSetting::Get('systemEmailAddress', 'mailing'), HSetting::Get('systemEmailName', 'mailing'));
     $message->addTo($email);
     $message->subject = "Test Mail";
     $message->setBody(array('user' => $user), 'text/html');
     Yii::app()->mail->send($message);
     print "Sent! \n";
     print "\nEMailing completed.\n";
 }
 /**
  * Invite New Members to this workspace
  */
 public function actionInvite()
 {
     $room = $this->getRoom();
     // Check Permissions to Invite
     if (!$room->canInvite()) {
         throw new CHttpException(403, 'Access denied - You cannot invite members!');
     }
     $model = new RoomInviteForm();
     $model->room = $room;
     if (isset($_POST['RoomInviteForm'])) {
         $_POST['RoomInviteForm'] = Yii::app()->input->stripClean($_POST['RoomInviteForm']);
         $model->attributes = $_POST['RoomInviteForm'];
         if ($model->validate()) {
             // check if both invite inputs are empty
             if ($model->invite == "" && $model->inviteExternal == "") {
             } else {
                 // Invite existing members
                 foreach ($model->getInvites() as $user) {
                     $room->inviteMember($user->id, Yii::app()->user->id);
                     $statusInvite = $room->getMembership($user->id)->status;
                 }
                 if (HSetting::Get('internalUsersCanInvite', 'authentication_internal')) {
                     // Invite non existing members
                     foreach ($model->getInvitesExternal() as $email) {
                         $statusInvite = $room->inviteMemberByEMail($email, Yii::app()->user->id) ? RoomMembership::STATUS_INVITED : false;
                     }
                 }
                 // close modal
                 //$this->renderModalClose();
                 $output = $this->renderPartial('statusInvite', array('status' => $statusInvite));
                 Yii::app()->clientScript->render($output);
                 echo $output;
                 Yii::app()->end();
             }
         }
     }
     $output = $this->renderPartial('invite', array('model' => $model, 'room' => $room));
     Yii::app()->clientScript->render($output);
     echo $output;
     Yii::app()->end();
 }
 public function getCurlOptions()
 {
     $useSsl = false;
     if (isset(Yii::app()->getModule('admin')->marketplaceApiValidateSsl)) {
         $useSsl = Yii::app()->getModule('admin')->marketplaceApiValidateSsl;
     }
     $options = array(CURLOPT_SSL_VERIFYPEER => $useSsl ? true : false, CURLOPT_SSL_VERIFYHOST => $useSsl ? 2 : 0, CURLOPT_REDIR_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS, CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS);
     if (HSetting::Get('enabled', 'proxy')) {
         $options[CURLOPT_PROXY] = HSetting::Get('server', 'proxy');
         $options[CURLOPT_PROXYPORT] = HSetting::Get('port', 'proxy');
         if (defined('CURLOPT_PROXYUSERNAME')) {
             $options[CURLOPT_PROXYUSERNAME] = HSetting::Get('user', 'proxy');
         }
         if (defined('CURLOPT_PROXYPASSWORD')) {
             $options[CURLOPT_PROXYPASSWORD] = HSetting::Get('pass', 'proxy');
         }
         if (defined('CURLOPT_NOPROXY')) {
             $options[CURLOPT_NOPROXY] = HSetting::Get('noproxy', 'proxy');
         }
     }
     return $options;
 }
 public function actionSettings()
 {
     $form = new RoomsSettingsForm();
     $form->defaultJoinPolicy = HSetting::Get('defaultJoinPolicy', 'room');
     $form->defaultVisibility = HSetting::Get('defaultVisibility', 'room');
     // uncomment the following code to enable ajax-based validation
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'rooms-settings-form') {
         echo CActiveForm::validate($form);
         Yii::app()->end();
     }
     if (isset($_POST['RoomsSettingsForm'])) {
         $_POST['RoomsSettingsForm'] = Yii::app()->input->stripClean($_POST['RoomsSettingsForm']);
         $form->attributes = $_POST['RoomsSettingsForm'];
         if ($form->validate()) {
             HSetting::Set('defaultJoinPolicy', $form->defaultJoinPolicy, 'room');
             HSetting::Set('defaultVisibility', $form->defaultVisibility, 'room');
             // set flash message
             Yii::app()->user->setFlash('data-saved', Yii::t('RoomsModule.controllers_SpaceController', 'Saved'));
             $this->redirect($this->createUrl('settings'));
         }
     }
     $this->render('settings', array('model' => $form));
 }