public function actionReply($userId) { Yii::beginProfile('messageReply'); $pmbMessage = new PmbMessages(); $user = UserApi::getUser($userId); if (!$user) { throw new CHttpException(404, 'The requested page does not exist.'); } $pmbMessage->to_user_id = $userId; $pmbMessage->from_user_id = Yii::app()->user->id; $userName = UserApi::getNameByUserId($userId); if (isset($_POST['submit'])) { $pmbMessage->attributes = $_POST['PmbMessages']; if ($pmbMessage->save()) { $data = array(); $user = UserApi::getUserById($pmbMessage->to_user_id); $user ? $data["user"] = $user->id : null; $data["message"] = $pmbMessage->id; EmailApi::sendEmail($user->email_id, "ACTIVITY.MESSAGE.NEW", $data); $this->redirect('/messages/sent'); } } $this->render('reply', array('pmbMessage' => $pmbMessage, 'user' => $user, 'userName' => $userName)); Yii::endProfile('messageReply'); }
public function actionPost() { Yii::beginProfile('project_post'); $model = new Projects(); $modelCity = new GeoCity(); $modelState = new GeoState(); $modelAmenities = new ProjectAmenities(); $modelImages = new ProjectImages(); $amenities = null; if (isset($_POST['submit'])) { $model->attributes = $_POST['Projects']; $modelImages->attributes = $_POST['ProjectImages']; $amenities = isset($_POST['amenity_id']) ? $_POST['amenity_id'] : null; /*if($amenities){ $amenity_data = null; foreach($amenities as $i=>$amenity){ if($i!=0) $amenity_data.=','; $amenity_data.=$amenity; } $amenities = $amenity_data; }*/ $valid = true; $model->user_id = Yii::app()->user->id; $valid = $valid && $model->validate(); if ($amenities == null) { $modelAmenities->addError('amenity_id', 'Amenities cannot be blank.'); $valid = false; } $modelImages->image = CUploadedFile::getInstance($modelImages, 'image'); if ($modelImages->image == "") { $modelImages->addError('image', 'Image cannot be blank.'); $valid = false; } if ($valid) { $data = $_POST['Projects']; $project = ProjectApi::createProject('1', $data); if (!$project->hasErrors()) { $amenities = ProjectAmenitiesApi::addAmenitiesForProject($project->id, $_POST['amenity_id']); $imagePath = ImageUtils::uploadImage($modelImages, 'image'); if ($amenities && $imagePath) { $image = ProjectImagesApi::addImage($project->id, $imagePath); if (!$image) { ProjectApi::deleteProjectById($project->id); ProjectAmenitiesApi::deleteAllAmenitiesForProject($project->id); } if (file_exists($imagePath)) { unlink($imagePath); } $data = array(); $user = UserApi::getUserById($project->user_id); $user ? $data["user"] = $user->id : null; $data["project"] = $project->id; EmailApi::sendEmail($user->email_id, "ACTIVITY.PROJECT.NEW", $data); $this->redirect('/project/' . $project->id); } else { ProjectApi::deleteProjectById($project->id); ProjectAmenitiesApi::deleteAllAmenitiesForProject($project->id); } } else { if (isset($property->id)) { ProjectApi::deleteProjectById($property->id); } } } } $this->render('post', array('model' => $model, 'modelState' => $modelState, 'modelCity' => $modelCity, 'modelAmenities' => $modelAmenities, 'modelImages' => $modelImages, 'amenities' => $amenities)); Yii::endProfile('project_post'); }
public function actionStarRatingAjax($userId, $builderId) { $ratingAjax = isset($_POST['rate']) ? $_POST['rate'] : 0; BuilderRatingApi::addRating($builderId, $userId, $ratingAjax); $data = array(); $userId = BuilderProfileApi::getBuilderProfileById($builderId)->user_id; $user = UserApi::getUserById($userId); $user ? $data["user"] = $user->id : null; $data["builder"] = $builderId; EmailApi::sendEmail($user->email_id, "ACTIVITY.BUILDER.RATING", $data); echo 'Your Rating is ' . $ratingAjax; }
public function actionStarRatingAjax($userId, $agentId) { $ratingAjax = isset($_POST['rate']) ? $_POST['rate'] : 0; AgentRatingApi::addRating($agentId, $userId, $ratingAjax); $data = array(); $userId = AgentProfileApi::getAgentProfileById($agentId)->user_id; $user = UserApi::getUserById($userId); $user ? $data["user"] = $user->id : null; $data["agent"] = $agentId; EmailApi::sendEmail($user->email_id, "ACTIVITY.AGENT.RATING", $data); echo 'Your Rating is ' . $ratingAjax; }
public function actionStarRatingAjax($userId, $specialistId) { $ratingAjax = isset($_POST['rate']) ? $_POST['rate'] : 0; SpecialistRatingApi::addRating($userId, $specialistId, $ratingAjax); $data = array(); $userId = SpecialistProfileApi::getSpecialistProfileById($specialistId)->user_id; $user = UserApi::getUserById($userId); $user ? $data["user"] = $user->id : null; $data["specialist"] = $specialistId; EmailApi::sendEmail($user->email_id, "ACTIVITY.SPECIALIST.RATING", $data); echo 'Your Rating is ' . $ratingAjax; }
public static function sendEmail($to, $scenario, $data = "", $cc = "", $bcc = "") { $model = EmailTemplateApi::getTemplateByScenario($scenario); $template = array(); if ($model) { $template["home_link"] = Yii::app()->createAbsoluteUrl('/'); $template["signin_link"] = Yii::app()->createAbsoluteUrl('/account'); $template["logo_link"] = Yii::app()->createAbsoluteUrl('/') . Yii::app()->theme->baseUrl . '/images/logo-newsletter.jpg'; if ($data) { if (is_array($data)) { foreach ($data as $key => $value) { if ($key == "user") { $user = UserApi::getUser($value); if ($user) { $template["verification_link"] = SecurityUtils::getVerificationLink($user["activation_code"], $user["email_id"]); $template["email_id"] = $user["email_id"]; $template["name"] = UserApi::getNameByUserId($value); } continue; } else { if ($key == "temp_password") { $template["temp_password"] = $value; continue; } else { if ($key == "message") { $message = PmbApi::loadMessage($value); if ($message) { $template["message_subject"] = $message->subject; $template["message_content"] = $message->content; $template["message_body"] = $message->content; $template["message_from"] = UserApi::getNameByUserId($message->from_user_id); } continue; } else { if ($key == "feedback") { $user = UserApi::getUserById($value); $feedback = FeedbackApi::getLatestFeedback($toId, $entityId, $type); if ($user) { $template["first_name"] = $user->first_name; $template["feedback"] = $feedback->feedback; $template["specialist_rating"] = SpecialistRatingApi::getRating($specialist->user_id); } continue; } } } } } } } $htmlEmail = self::changeTemplate($template, $model->body_html); $plainEmail = self::changeTemplate($template, $model->body_plain); $emailData["from_email"] = $model->from_email; $emailData["from_name"] = $model->from_name; $emailData["subject"] = self::changeTemplate($template, $model->subject); $emailData["body_html"] = $htmlEmail; $emailData["body_plain"] = $plainEmail; return EmailQueueApi::addToQueue($to, $cc, $bcc, "", $emailData); } return false; }
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'); }
public function actionView($id) { Yii::beginProfile('view_profile'); //$session = Yii::app()->session; $wheelsImages = array(); $wheelImages = array(); $lastRide = array(); $user = UserApi::getUserById($id); if (!$user) { throw new CHttpException(404, 'The requested page does not exist.'); } $userAge = UserApi::getAge($user->dob); $userAddress = ""; if ($user->city_id) { $userAddress = DbUtils::getAddress($user->city_id); } $imageUserId = array($id); $image = ImagesApi::getPrimaryImageForUsers($imageUserId); if ($image) { $userImage = $image[$id]; } else { $userImage = ImageUtils::getDefaultImage('user'); } $userWheelDefault = ImageUtils::getDefaultImage('wheel'); $userRides = RidesApi::getCountOfUserRides($id); $userEcoMiles = RidesApi::getEcoMilesDrivenByUser($id); $userWheel = WheelApi::getWheelsCount($id); $userPalsCount = UserPalsApi::getPalsCount($id); $entityId = EntityApi::getIdByType("user"); $driverRating = round(FeedbackApi::getRating($id, $entityId, 'DRIVER')); $passengerRating = round(FeedbackApi::getRating($id, $entityId, 'PASSENGER')); $userPals = UserPalsApi::getAllPals($id); $userPalDefaultImage = ImageUtils::getDefaultImage('user'); $lastRide = RidesApi::getLastRide($id); $lastRideWheel = WheelApi::getWheelById($lastRide[0]['wheel_id']); $userWheels = WheelApi::getWheelsByUserId($id); $favoriteWheel = WheelApi::getFavouriteWheel($id); $userFeedback = FeedbackApi::getAllFeedback($id, $entityId); $favWheelDetail = ""; $wheelMake = ""; $wheelModel = ""; $wheelColor = ""; $wheelRides = ""; $wheelEcoMiles = ""; $wheelPals = ""; $wheelPalCnt = ""; if ($favoriteWheel) { $favWheelDetail = WheelApi::getWheelById($favoriteWheel[0]["wheel_id"]); $wheelMake = MakeApi::getMakeById($favWheelDetail->make_id); $wheelModel = ModelApi::getModelById($favWheelDetail->model_id); $wheelColor = ColorApi::getColorById($favWheelDetail->color_id); $wheelRides = RidesApi::getCountOfWheelRides($favWheelDetail->id); $wheelImage = ImagesApi::getPrimaryImageForWheels(array($favoriteWheel[0]["wheel_id"])); if (!$wheelImage) { $wheelImage = $userWheelDefault; } $wheelEcoMiles = RidesApi::getEcoMilesDrivenByWheel($favWheelDetail->id); $wheelPals = WheelApi::getNoOfPalsMetByWheelId($favWheelDetail->id); $wheelPalCnt = $wheelPals[0]['palcnt']; } $i = 0; if ($userFeedback) { foreach ($userFeedback as $feedback) { $fromUserProfile = UserApi::getUserById($feedback->from_user_id); $fromUserIds[$i] = $feedback->from_user_id; $userName = UserApi::getNameByUserId($fromUserProfile->id); $userFeedbackDetails[$i++] = array('from_id' => $feedback->from_user_id, 'userName' => $userName, 'feedback' => $feedback->feedback); } } $i = 0; $j = 0; $userPalList = ""; $palScrollLabel = ""; $mergeArray = array_merge($userPals, $fromUserIds); $userIdList = array_unique($mergeArray); $userImages = ImagesApi::getPrimaryImageForUsers($userIdList); $imageArrayIndex = array_keys($userImages); $imageArrayIndexSize = count($imageArrayIndex); //var_dump($userPals); // var_dump($fromUserIds);die(); if ($userPals) { foreach ($userPals as $userPal) { $userPalList[$i++] = userapi::getUserById($userPal); } } if ($userIdList) { foreach ($userIdList as $userId) { for ($j = 0; $j < $imageArrayIndexSize; $j++) { $palsImages[$userId] = ''; if ($imageArrayIndex[$j] == $userId) { $palsImages[$userId] = $userImages[$userId]; break; } } if ($palsImages[$userId] == '') { $palsImages[$userId] = $userPalDefaultImage; } } } if ($userWheels) { foreach ($userWheels as $wheel) { $wheelIds[$wheel->id] = $wheel->id; } if ($wheelIds) { $wheelImages = ImagesApi::getPrimaryImageForWheels($wheelIds); if ($wheelImages) { $imageArrayIndex = array_keys($wheelImages); $imageArrayIndexSize = count($imageArrayIndex); foreach ($wheelIds as $wheelId) { for ($j = 0; $j < $imageArrayIndexSize; $j++) { $wheelsImages[$wheelId] = ''; if ($imageArrayIndex[$j] == $wheelId) { $wheelsImages[$wheelId] = $wheelImages[$wheelId]; break; } } if ($wheelsImages[$wheelId] == '') { $wheelsImages[$wheelId] = $userWheelDefault; } } } } } /*$palCntArray=ceil($userPalsCount/3); $l=0; if($userPalsCount>2){ for($i=0;$i<$palCntArray-1;$i++){ $palScroll[$i]=array($userPalList[$l],$userPalList[$l+1],$userPalList[$l+2]); $l=$l+3; } } while($l<$userPalsCount) { $palScroll[$palCntArray-1]=array($userPalList[$l]); $l++; } $palScrollLabel=$palScroll[0]; } $k=1; if (isset($_POST['ajxbtn'])){ if($k < $palCntArray) $palScrollLabel=$palScroll[$k]; $k++; } */ $this->render('view', array('user' => $user, 'userAddress' => $userAddress, 'userPalsCount' => $userPalsCount, 'userAge' => $userAge, 'userImage' => $userImage, 'userEcoMiles' => $userEcoMiles, 'userPals' => $userPals, 'userRides' => $userRides, 'userWheel' => $userWheel, 'driverRating' => $driverRating, 'passengerRating' => $passengerRating, 'userPalList' => $userPalList, 'favWheelDetail' => $favWheelDetail, 'wheelMake' => $wheelMake, 'wheelColor' => $wheelColor, 'wheelModel' => $wheelModel, 'wheelRides' => $wheelRides, 'wheelEcoMiles' => $wheelEcoMiles, 'wheelPalCnt' => $wheelPalCnt, 'palScrolls' => $palScrollLabel, 'palImages' => $palsImages, 'userFeedbackDetails' => $userFeedbackDetails, 'wheelsImages' => $wheelsImages, 'userWheels' => $userWheels, 'wheelImage' => $wheelImage, 'lastRide' => $lastRide, 'lastRideWheel' => $lastRideWheel)); Yii::endProfile('view_profile'); }