Ejemplo n.º 1
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());
     }
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }
 public function up()
 {
     if (HSetting::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"');
     }
 }
 /**
  * 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));
 }
Ejemplo n.º 5
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);
     }
 }
 public function up()
 {
     $connection = $this->getDbConnection();
     $command = $connection->commandBuilder->createFindCommand('user', new CDbCriteria());
     $reader = $command->query();
     foreach ($reader as $row) {
         // Ignore deleted users
         if ($row['status'] == 3) {
             continue;
         }
         $userId = $row['id'];
         $receive_email_notifications = $row['receive_email_notifications'];
         $receive_email_messaging = $row['receive_email_messaging'];
         $receive_email_activities = $row['receive_email_activities'];
         $insertCommand = $connection->commandBuilder->createInsertCommand('user_setting', array('user_id' => $userId, 'module_id' => 'core', 'name' => 'receive_email_notifications', 'value' => $receive_email_notifications));
         $insertCommand->execute();
         $insertCommand = $connection->commandBuilder->createInsertCommand('user_setting', array('user_id' => $userId, 'module_id' => 'core', 'name' => 'receive_email_messaging', 'value' => $receive_email_messaging));
         $insertCommand->execute();
         $insertCommand = $connection->commandBuilder->createInsertCommand('user_setting', array('user_id' => $userId, 'module_id' => 'core', 'name' => 'receive_email_activities', 'value' => $receive_email_activities));
         $insertCommand->execute();
     }
     $this->dropColumn('user', 'receive_email_notifications');
     $this->dropColumn('user', 'receive_email_messaging');
     $this->dropColumn('user', 'receive_email_activities');
     if (HSetting::isInstalled()) {
         $this->insert('setting', array('name' => 'receive_email_activities', 'value' => '1', 'name' => 'mailing'));
         $this->insert('setting', array('name' => 'receive_email_notifications', 'value' => '2', 'name' => 'mailing'));
     }
 }
Ejemplo n.º 7
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')));
     }
 }
Ejemplo n.º 8
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')));
     }
 }
Ejemplo n.º 9
0
 public function up()
 {
     if (HSetting::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));
 }
Ejemplo n.º 10
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!');
     }
 }
Ejemplo n.º 11
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');
 }
Ejemplo n.º 12
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));
     }
 }
 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));
     }
 }
Ejemplo n.º 14
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);
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 17
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;
     }
 }
Ejemplo n.º 18
0
 /**
  * Validate the file extensions.
  */
 public function validateExtension($attribute, $params)
 {
     $allowedExtensions = HSetting::get('allowedExtensions', 'album');
     if ($allowedExtensions != "") {
         $extension = $this->getExtension();
         $extension = trim(strtolower($extension));
         $allowed = array_map('trim', explode(",", $allowedExtensions));
         if (!in_array($extension, $allowed)) {
             $this->addError($attribute, 'This file type is not allowed!');
         }
     }
 }
Ejemplo n.º 19
0
 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');
     }
 }
Ejemplo n.º 20
0
 /**
  * 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);
     }
 }
 public function actionIndex()
 {
     $model = new AlbumSettings();
     $model->allowedExtensions = HSetting::get('allowedExtensions', 'album');
     if (isset($_POST['AlbumSettings'])) {
         $model->attributes = $_POST['AlbumSettings'];
         if ($model->validate()) {
             HSetting::set('allowedExtensions', $model->allowedExtensions, 'album');
             // set flash message
             Yii::app()->user->setFlash('data-saved', 'Saved');
             $this->redirect(Yii::app()->createUrl('//album/setting'));
         }
     }
     $this->render('index', compact('model'));
 }
Ejemplo n.º 22
0
 /**
  * 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;
 }
 /** 
  * Prototyping the random name generator
  */
 public function actionRand()
 {
     $assetPrefix = Yii::app()->assetManager->publish(dirname(__FILE__) . '/../resources', true, 0, defined('YII_DEBUG'));
     Yii::app()->clientScript->registerScriptFile($assetPrefix . '/md5.min.js');
     Yii::app()->clientScript->registerScriptFile($assetPrefix . '/jdenticon-1.3.0.min.js');
     $firstNameOptions = explode("\n", HSetting::GetText('anonAccountsFirstNameOptions'));
     $randomFirstName = ucfirst($firstNameOptions[array_rand($firstNameOptions)]);
     $lastNameOptions = explode("\n", HSetting::GetText('anonAccountsLastNameOptions'));
     $randomLastName = ucfirst($lastNameOptions[array_rand($lastNameOptions)]);
     ////// Save DataURL as Image ///////
     // @TODO: Pull this from $_POST
     // $data = "data:image/png;base64,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";
     // $filePath = dirname(__FILE__) . '/../resources/test.png';
     // $fp = fopen($filePath,"w");
     // fwrite($fp, file_get_contents($data));
     // fclose($fp);
     ////////////////////////////////////
     $model = new AnonAccountRegisterForm();
     if (isset($_POST['AnonAccountRegisterForm'])) {
         // Pre-set the random first and last name
         $model->firstName = trim($randomFirstName);
         $model->lastName = trim($randomLastName);
         // Load attributes into the model
         $model->attributes = $_POST['AnonAccountRegisterForm'];
         // Make the username from the first and lastnames
         $model->username = strtolower($model->firstName . "_" . $model->lastName);
         // Validate
         if ($model->validate()) {
             // Create temporary file
             $temp_file_name = tempnam(sys_get_temp_dir(), 'img') . '.png';
             $fp = fopen($temp_file_name, "w");
             fwrite($fp, file_get_contents($model->image));
             fclose($fp);
             // Store profile image for user
             $profileImage = new ProfileImage($model->guid);
             $profileImage->setNew($temp_file_name);
             // Remove temporary file
             unlink($temp_file_name);
             // Finished. Redirect away!
             $this->redirect($this->createUrl('//anon_accounts/admin/rand', array()));
         } else {
             echo "Error processing account register form";
         }
     }
     $this->render('test', array('firstName' => $randomFirstName, 'lastName' => $randomLastName, 'model' => $model));
 }
 /**
  * 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);
 }
Ejemplo n.º 25
0
 /**
  * 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);
 }
Ejemplo n.º 26
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;
 }
Ejemplo n.º 27
0
 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');
 }
Ejemplo n.º 28
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);
 }
 public function up()
 {
     // Check if the installer already ran when not create new profile field
     // (Typically the installer creates initial data.)
     if (HSetting::isInstalled()) {
         $db = $this->getDbConnection();
         // Get "General" Category Group Id
         $categoryId = $db->createCommand()->select('id')->from('profile_field_category')->where('title=:title', array(':title' => 'General'))->queryScalar();
         // Check if we got a category Id
         if ($categoryId == "") {
             throw new CException("Could not find 'General' profile field category!");
         }
         // Create manually profile field
         $insertCommand = $db->commandBuilder->createInsertCommand('profile_field', array('profile_field_category_id' => $categoryId, 'field_type_class' => 'ProfileFieldTypeSelect', 'field_type_config' => '{"options":"male=>Male\\r\\nfemale=>Female\\r\\ncustom=>Custom"}', 'internal_name' => 'gender', 'title' => 'Gender', 'sort_order' => '350', 'editable' => '1', 'visible' => '1', 'show_at_registration' => '0', 'required' => '0'));
         $insertCommand->execute();
         // Create column for profile field
         $this->addColumn('profile', 'gender', 'varchar(255) DEFAULT NULL');
     }
 }
 /**
  * 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();
 }