/** 
  * 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,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAGVklEQVR4Xu3dPXDURhQH8LdnUofKbUgJheN0KSAmpamS2inOPc6QOp7BmSF1mDi9j8J1UuEyJrigi3EBZaB1BfUZL7Oy5VHk1X69/5NW8dLe6d2+/emtTrfPQlH5l9UMqKxGUwZDBSSzk6CAFJDMZiCz4ZQKKSCZzUBmwykVMjaQZ0fHGjzmJytLi1NwTJFwfx8dTzXRDjL4ytKiswi8FQIGGQ1GjYBGyQlkdBgSKLmARGF89WDvxien6gtNelmROpxP9MsXj1ffcJYObkxUpeQAEoxhJu3aB9pRiu62J19r2j9ZoPVYGGRMBMrQIMEYdzb2pqT0r0Tqencl6Hek1Y/Pt1dnIdUiEZOLMiRIMMbZcqL/cWPUBPrdfKK+9FWKREzENWUokGAMk+Ttjb2/bMtUVxWY5etge/UbV5VIxGx+XmqlDAEShXF2JtO/IUtQ8z3zCX3eVSUSMW3jS0HpGyQKwyR55/7Tb2mi/ogFoVP93fPf7/1pO04iZtf4YlH6BInGqJarH/a2FNHDWBBN9PPBb6tbtuMkYrrGF4PSF0gSxv+hQmIv9H2AJGOYZCTWe4mYIRUcUinSICyMOsnbG0/3lVIrIUmb92itnx1s37t089g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S7xLYsznq5jfSASn1lAHLNaQCROOUbMLEH2j4537i4trjPyKoeezwDk0Rrmv6vQRLOCwjuvkA+fqZ5LUlDSQSQez1SNpi8UieYBiZghRJIPMBNHkWgekIgZAmHeY3sYJuJ5WZcepSRRKRLNAxIxORjmWBEQ9PIl0TwgEZOLIQqCRJFoHoiP6X84cwjIkA9ShlxTUJtezcmSiInAEK+QepCcawpqW7g5YRIxfSC+yqiPF7uGtAeYiiLRPCAR0wUSitFbhXAqReJslojZBRKD0TtIyoVeYr2XiGkDicUYBCQFBdE40Z4wiZjNz0jBGAwkFgXxdIg2iETM+jNSMQYFiUXhPh3CtqRIxORgDA4Si8J5OkTXRRcZk4uRBUgsinm/RPMANyYCIxuQFBTfjVifr6MwsgIZKwoSIzuQsaGgMSAgfS4N5bOIBunLKhPfPQMFJLOzo4AUkMxmILPhlAopIJnNQGbDKRWSGchHZ+U6znsxaNkAAAAASUVORK5CYII=";
     // $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));
 }
 /** 
  * Uploads the identicon profile picture
  * @param int guid
  * @param Base64 Image (identicon)
  */
 private function uploadProfilePicture($guid, $data)
 {
     // Create temporary file
     $temp_file_name = tempnam(sys_get_temp_dir(), 'img') . '.png';
     $fp = fopen($temp_file_name, "w");
     fwrite($fp, file_get_contents($data));
     fclose($fp);
     // Store profile image for user
     $profileImage = new ProfileImage($guid);
     $profileImage->setNew($temp_file_name);
     // Remove temporary file
     unlink($temp_file_name);
 }
Esempio n. 3
0
 /**
  * Crops the profile image of the user
  */
 public function actionCropImage()
 {
     $space = $this->getSpace();
     $model = new CropProfileImageForm();
     $profileImage = new ProfileImage($space->guid);
     if (isset($_POST['CropProfileImageForm'])) {
         $_POST['CropProfileImageForm'] = Yii::app()->input->stripClean($_POST['CropProfileImageForm']);
         $model->attributes = $_POST['CropProfileImageForm'];
         if ($model->validate()) {
             $profileImage->cropOriginal($model->cropX, $model->cropY, $model->cropH, $model->cropW);
             $this->htmlRedirect();
         }
     }
     $output = $this->renderPartial('cropImage', array('model' => $model, 'profileImage' => $profileImage, 'space' => $space));
     Yii::app()->clientScript->render($output);
     echo $output;
     Yii::app()->end();
 }
Esempio n. 4
0
 /**
  * Crops the profile image of the user
  */
 public function actionCropProfileImage()
 {
     $model = new CropProfileImageForm();
     $profileImage = new ProfileImage(Yii::app()->user->guid);
     if (isset($_POST['CropProfileImageForm'])) {
         $_POST['CropProfileImageForm'] = Yii::app()->input->stripClean($_POST['CropProfileImageForm']);
         $model->attributes = $_POST['CropProfileImageForm'];
         if ($model->validate()) {
             $profileImage->cropOriginal($model->cropX, $model->cropY, $model->cropH, $model->cropW);
             $this->htmlRedirect(Yii::app()->user->getModel()->getUrl());
         }
     }
     $this->renderPartial('cropProfileImage', array('model' => $model, 'profileImage' => $profileImage, 'user' => Yii::app()->user->getModel()), false, true);
 }
Esempio n. 5
0
 /**
  * Setup Administrative User
  *
  * This should be the last step, before the user is created also the
  * application secret will created.
  */
 public function actionAdmin()
 {
     Yii::import('installer.forms.*');
     $userModel = new User('register');
     $userPasswordModel = new UserPassword('newPassword');
     $profileModel = $userModel->profile;
     $profileModel->scenario = 'register';
     // Build Form Definition
     $definition = array();
     $definition['elements'] = array();
     // Add User Form
     $definition['elements']['User'] = array('type' => 'form', 'elements' => array('username' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 25), 'email' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 100)));
     // 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)));
     // Add Profile Form
     $definition['elements']['Profile'] = array_merge(array('type' => 'form'), $profileModel->getFormDefinition());
     // Get Form Definition
     $definition['buttons'] = array('save' => array('type' => 'submit', 'class' => 'btn btn-primary', 'label' => Yii::t('InstallerModule.base', 'Create Admin Account')));
     $form = new HForm($definition);
     $form['User']->model = $userModel;
     $form['User']->model->group_id = 1;
     $form['UserPassword']->model = $userPasswordModel;
     $form['Profile']->model = $profileModel;
     if (isset($_POST['Profile'])) {
         $_POST['Profile'] = Yii::app()->input->stripClean($_POST['Profile']);
     }
     if (isset($_GET['Profile'])) {
         $_GET['Profile'] = Yii::app()->input->stripClean($_GET['Profile']);
     }
     if ($form->submitted('save') && $form->validate()) {
         $this->forcePostRequest();
         if (HSetting::Get('secret') == "") {
             HSetting::Set('secret', UUID::v4());
         }
         $form['User']->model->status = User::STATUS_ENABLED;
         $form['User']->model->super_admin = true;
         $form['User']->model->language = '';
         $form['User']->model->last_activity_email = new CDbExpression('NOW()');
         $form['User']->model->save();
         $form['Profile']->model->user_id = $form['User']->model->id;
         $form['Profile']->model->title = "System Administration";
         $form['Profile']->model->save();
         // Save User Password
         $form['UserPassword']->model->user_id = $form['User']->model->id;
         $form['UserPassword']->model->setPassword($form['UserPassword']->model->newPassword);
         $form['UserPassword']->model->save();
         $userId = $form['User']->model->id;
         // Switch Identity
         Yii::import('application.modules_core.user.components.*');
         $newIdentity = new UserIdentity($form['User']->model->username, '');
         $newIdentity->fakeAuthenticate();
         Yii::app()->user->login($newIdentity);
         // Create Welcome Space
         $space = new Space();
         $space->name = 'Welcome Space';
         $space->description = 'Your first sample space to discover the platform.';
         $space->join_policy = Space::JOIN_POLICY_FREE;
         $space->visibility = Space::VISIBILITY_ALL;
         $space->created_by = $userId;
         $space->auto_add_new_members = 1;
         $space->save();
         $profileImage = new ProfileImage($space->guid);
         $profileImage->setNew($this->getModule()->getPath() . DIRECTORY_SEPARATOR . "resources" . DIRECTORY_SEPARATOR . 'welcome_space.jpg');
         // Add Some Post to the Space
         $post = new Post();
         $post->message = "Yay! I've just installed HumHub :-)";
         $post->content->container = $space;
         $post->content->visibility = Content::VISIBILITY_PUBLIC;
         $post->save();
         $this->redirect($this->createUrl('finished'));
     }
     $this->render('admin', array('form' => $form));
 }
Esempio n. 6
0
                 $sufix = ".png";
                 break;
             case "image/gif":
                 $sufix = ".gif";
                 break;
             case "image/jpeg":
                 $sufix = ".jpg";
                 break;
             case "image/jpg":
                 $sufix = ".jpg";
                 break;
             default:
                 $sufix = "";
                 $err[] = "Neznámý typ souboru.";
         }
         $profileImage = new ProfileImage();
         $profileImageNumber = $profileImage->getNumForNextImg();
         $imageName = $profileImageNumber . $sufix;
         $profileImage = $profileImage->setNewImg($imageName, $profile_image['size'], $profil->getId(), $profile_image['type']);
         move_uploaded_file($profile_image['tmp_name'], 'images/profile_images/original/' . $imageName);
         resizeImage(850, 'images/profile_images/large/' . $profileImageNumber, 'images/profile_images/original/' . $imageName);
         resizeImage(100, 'images/profile_images/small/' . $profileImageNumber, 'images/profile_images/original/' . $imageName);
     } else {
         $err[] = "Problém s uložením profilového obrázku.";
     }
 }
 if (isset($_POST['img'])) {
     $imageName = $_POST['img'];
 }
 if (empty($err)) {
     $profil->updateProfil($_POST['firstname'], $_POST['middlename'], $_POST['lastname'], $clubUpdate, $email, $showMail, $tel, $showTel, $_POST['gender'], $about_me, $imageName, $web);