Beispiel #1
0
 public static function searchBlockedUser($data)
 {
     $criteria = new CDbCriteria();
     $condition = null;
     $params = null;
     if ($data != "") {
         $condition .= '(first_name like :keyword || last_name like :keyword)';
         $params[':keyword'] = '%' . $data . '%';
     }
     if ($condition != null) {
         $criteria->select = 'id';
         $criteria->condition = $condition;
         $criteria->params = $params;
     }
     $userProfiles = UserProfiles::model()->findAll($criteria);
     $result = array();
     $i = 0;
     if (!empty($userProfiles)) {
         foreach ($userProfiles as $userProfile) {
             $result["{$i}"] = $userProfile->id;
             $i = $i + 1;
         }
         return $result;
     } else {
         return false;
     }
 }
 public function actionIndex()
 {
     if (isset($_REQUEST)) {
         Yii::import('application.modules.deposit.extensions.Deposit.Deposit');
         $deposit = new Deposit();
         if (!$deposit->init()) {
             app()->end();
         }
         try {
             /**
              * @var Transactions $transaction
              */
             $transaction = $deposit->processed();
             $percents = (double) config('referral_program.percent');
             Yii::log("Deposit::log\n" . print_r($_REQUEST, TRUE), CLogger::LEVEL_INFO, 'application.modules.deposit.controllers.DefaultController::' . __LINE__);
             // Начисляю партнёрку
             if ($percents > 0 && $transaction) {
                 // Смотрю есть ли реферер
                 $referer = Referals::model()->find('referal = :referal', array(':referal' => $transaction->user_id));
                 if ($referer !== NULL) {
                     $refererProfile = UserProfiles::model()->with('user')->find('t.user_id = :user_id', array(':user_id' => $referer->referer));
                     if ($refererProfile) {
                         $gsModel = Gs::model()->findByPk($transaction->getGsId());
                         // Кол-во предметов которые были куплены, от них будет считаться % рефералу
                         $countItems = $transaction->getSum() / $gsModel->deposit_course_payments;
                         $profit = $countItems / 100 * $percents;
                         $refererProfile->balance += $profit;
                         $refererProfile->save(FALSE, array('balance', 'updated_at'));
                         // Логирую
                         $dataDb = array('referer_id' => $refererProfile->user_id, 'referal_id' => $transaction->getUserId(), 'profit' => $profit, 'sum' => $transaction->getSum(), 'percent' => $percents, 'transaction_id' => $transaction->getPrimaryKey(), 'created_at' => date('Y-m-d H:i:s'));
                         db()->createCommand()->insert('{{referals_profit}}', $dataDb);
                         // Отправляю письмо что баланс реферера был пополнен
                         notify()->rechargeBalanceByReferal($refererProfile->user->email, array('profit' => $profit));
                         // Логирую действие юзера
                         if (app()->params['user_actions_log']) {
                             $log = new UserActionsLog();
                             $log->user_id = $transaction->getUserId();
                             $log->action_id = UserActionsLog::ACTION_DEPOSIT_SUCCESS;
                             $log->params = json_encode($dataDb);
                             $log->save();
                         }
                     }
                 }
             }
             echo $deposit->success(Yii::t('main', 'Ваш баланс успешно пополнен.'));
         } catch (Exception $e) {
             echo $deposit->error($e->getMessage());
         }
     } else {
         $this->redirect(array('/index/default/index'));
     }
 }
Beispiel #3
0
 public static function searchPal($data)
 {
     $criteria = new CDbCriteria();
     $condition = null;
     $params = null;
     if ($data['keyword'] != "") {
         $condition .= '(first_name like :keyword || last_name like :keyword)';
         $params[':keyword'] = '%' . $data['keyword'] . '%';
     }
     if ($condition != null) {
         $criteria->condition = $condition;
         $criteria->params = $params;
     }
     $userProfile = UserProfiles::model()->findAll($criteria);
     return $userProfile;
 }
 public function actionIndex()
 {
     $model = UserProfiles::model()->find('user_id = :user_id', array(':user_id' => user()->getId()));
     if (isset($_POST['UserProfiles'])) {
         $model->setScenario('security');
         $model->setAttributes($_POST['UserProfiles']);
         if ($model->validate()) {
             $model->save(FALSE, array('protected_ip'));
             user()->setFlash(FlashConst::MESSAGE_SUCCESS, Yii::t('main', 'Данные сохранены.'));
             $this->refresh();
         }
     }
     if ($model->protected_ip && is_array($model->protected_ip)) {
         $model->protected_ip = implode("\r\n", $model->protected_ip);
     }
     $this->render('//cabinet/security', array('model' => $model));
 }
Beispiel #5
0
 public static function getLocation($cityId)
 {
     $userModel = UserProfiles::model()->find('city_id=:cityId', array(':cityId' => $cityId));
     $address[] = "";
     if ($userModel) {
         $city = GeoCity::model()->findByPk($userModel->city_id);
         $address['city'] = $city ? $city->city : "";
         $state = GeoState::model()->findByPk($city->state_id);
         $address['state'] = $state->state;
         $country = GeoCountry::model()->findByPk($state->country_id);
         $address['country'] = $country->country;
         return $address;
     } else {
         return false;
     }
 }
Beispiel #6
0
 /**
  * This method returns the owner of a particular project.
  * Returns model if successfully found.
  * Returns the false if not found.
  *
  * @param string $projectId
  * @return model || false
  */
 public static function getOwner($projectId)
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'user_id';
     $criteria->condition = 'id=:projectId';
     $criteria->params = array(':projectId' => $projectId);
     $project = Projects::model()->find($criteria);
     if ($userId) {
         $criteria = new CDbCriteria();
         $criteria->condition = 'user_id=:userId';
         $criteria->params = array(':userId' => $project->user_id);
         $userprofile = UserProfiles::model()->find($criteria);
         $usercredentials = UserApi::getUserDetails($project->user_id);
         $userdetails = ArrayUtils::mergeArray($usercredentials->getAttributes(), $userprofile->getAttributes());
         return $userdetails;
     } else {
         return false;
     }
 }
Beispiel #7
0
 public static function getUserList()
 {
     $userProfiles = UserProfiles::model()->findAll();
     $result = null;
     if ($userProfiles) {
         foreach ($userProfiles as $names) {
             $result[$names->user_id] = $names->first_name . " " . $names->last_name;
         }
         return $result;
     }
     return false;
 }
Beispiel #8
0
 public function actionView($id)
 {
     Yii::beginProfile('jukebox_view');
     if (isset($_GET['attributeidC'])) {
         JukeboxAnswersApi::undoCorrectAnswer($_GET['attributeidC']);
     }
     if (isset($_GET['attributeidW'])) {
         JukeboxAnswersApi::undoWrongAnswer($_GET['attributeidW']);
     }
     $jukeboxQuestion = '';
     $userProfile = '';
     $geoCity = '';
     $jukeboxAnswers = '';
     $userdata = '';
     $jukeboxRating = '';
     $juckboxRatingEnable = false;
     $modelJukeboxQuestions = new JukeboxQuestions();
     $jukeboxNewAnswers = new JukeboxAnswers();
     $jukeboxQuestion = JukeboxQuestionsApi::getJukeboxQuestionById($id);
     $userProfile = UserApi::getUserProfileDetails($jukeboxQuestion->user_id);
     $juckboxRatingReadOnly = JukeboxRatingApi::checkUserRating($jukeboxQuestion->id, Yii::app()->user->id);
     if ($userProfile) {
         if (!$juckboxRatingReadOnly) {
             if ($userProfile->id == Yii::app()->user->id) {
                 $juckboxRatingReadOnly = true;
             } else {
                 $juckboxRatingReadOnly = false;
             }
         } else {
             $juckboxRatingReadOnly = true;
         }
     }
     if ($jukeboxQuestion) {
         if (isset($_POST['submit'])) {
             $model = new JukeboxAnswers();
             $model->attributes = $_POST['JukeboxAnswers'];
             $data = JukeboxAnswersApi::addJukeboxAnswer(Yii::app()->user->id, $jukeboxQuestion->id, $model);
             if ($data) {
                 $emailData = array();
                 $user = UserApi::getUserById(Yii::app()->user->id);
                 $user ? $emailData["user"] = $user->id : null;
                 $emailData["answer"] = $data->id;
                 EmailApi::sendEmail($user->email_id, "ACTIVITY.JUKEBOX.RESPONSE", $emailData);
             }
         }
         $geoCity = GeoCityApi::getCitynameByID($userProfile->city_id);
         $jukeboxAnswers = JukeboxAnswersApi::getJukeboxAnswers($jukeboxQuestion->id);
         if ($jukeboxAnswers) {
             foreach ($jukeboxAnswers as $answers) {
                 $jukeboxAnswersID[] = $answers->user_id;
             }
             $criteria = new CDbCriteria();
             $criteria->addInCondition('user_id', $jukeboxAnswersID);
             $users = UserProfiles::model()->findAll($criteria);
             $user_data = '';
             foreach ($users as $user) {
                 $userdata[$user->user_id] = $user->first_name;
             }
         }
         $jukeboxRating = JukeboxRatingApi::getRating($jukeboxQuestion->id);
     } else {
         $jukeboxQuestion->question = "No Questions have been posted by user";
         $jukeboxQuestion->description = '';
         $jukeboxQuestion->id = '';
     }
     $this->render('view', array('modelJukeboxQuestions' => $modelJukeboxQuestions, 'jukeboxNewAnswers' => $jukeboxNewAnswers, 'jukeboxQuestion' => $jukeboxQuestion, 'userProfile' => $userProfile, 'geoCity' => $geoCity, 'jukeboxAnswers' => $jukeboxAnswers, 'userdata' => $userdata, 'jukeboxRating' => $jukeboxRating, 'juckboxRatingReadOnly' => $juckboxRatingReadOnly));
     Yii::endProfile('jukebox_view');
 }
Beispiel #9
0
 /**
  * Поплнение баланса юзеру
  *
  * @param int $userId
  * @param float $sum
  * @param int $curs
  *
  * @return void
  */
 private function recharge($userId, $sum, $curs)
 {
     $userProfilesModel = UserProfiles::model()->find('user_id = :user_id', array('user_id' => $userId));
     $balance = floor($sum / $curs);
     $userProfilesModel->balance += $balance;
     $userProfilesModel->save(FALSE, array('balance', 'updated_at'));
 }