コード例 #1
0
ファイル: EmailUtils.php プロジェクト: romeo14/wallfeet
 public static function sendEmail($scenario, $userId = "", $messageId = "", $tempPassword = "", $cc = "", $bcc = "")
 {
     $model = EmailTemplateApi::getTemplateByScenario($scenario);
     if ($userId) {
         $user = UserApi::getUser($userId);
     }
     if ($user) {
         $data["verification_link"] = SecurityUtils::getVerificationLink($user["activation_code"]);
         $data["email_id"] = $user["email_id"];
         $data["name"] = UserApi::getNameByUserId($userId);
     }
     if ($tempPassword) {
         $data["temp_password"] = $tempPassword;
     }
     if ($messageId) {
         $message = PmbApi::loadMessage($messageId);
     }
     if ($message) {
         $data["message_subject"] = $message->subject;
         $data["message_content"] = $message->content;
         $data["message_from"] = UserApi::getNameByUserId($message->from_user_id);
     }
     if ($model) {
         $htmlEmail = self::changeTemplate($data, $model->body_html);
         $plainEmail = self::changeTemplate($data, $model->body_plain);
         $emailData["from_email"] = $model->from_email;
         $emailData["from_name"] = $model->from_name;
         $emailData["subject"] = $model->subject;
         $emailData["body_html"] = $htmlEmail;
         $emailData["body_plain"] = $plainEmail;
         return EmailQueueApi::addToQueue($user["email_id"], $cc, $bcc, "", $emailData);
     }
     return false;
 }
コード例 #2
0
ファイル: PmbController.php プロジェクト: romeo14/wallfeet
 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');
 }
コード例 #3
0
 public function actionProfile($id)
 {
     Yii::beginProfile('account_profile');
     $userProfile = UserApi::getUser($id);
     if (!$userProfile) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $userProfile = UserApi::getUserProfileDetails($id);
     $userAddress = DbUtils::getAddress($userProfile->city_id);
     $userImages = UserPhotosApi::getAllImages($id);
     $agentAddress = "";
     $agentImage = "";
     $agentProfile = AgentProfileApi::getAgentDetails($id);
     if ($agentProfile) {
         $agentAddress = DbUtils::getAddress($agentProfile->city_id);
         $agentImage = AgentProfileApi::getImage($id);
     }
     $builderAddress = "";
     $builderImage = "";
     $builderProfile = BuilderProfileApi::getBuilderDetails($id);
     if ($builderProfile) {
         $builderAddress = DbUtils::getAddress($builderProfile->city_id);
         $builderImage = BuilderProfileApi::getImage($id);
     }
     $specialistAddress = "";
     $specialistImage = "";
     $specialistProfile = SpecialistProfileApi::getSpecialistDetails($id);
     $specialistProjects = "";
     if ($specialistProfile) {
         $specialistAddress = DbUtils::getAddress($specialistProfile->city_id);
         $specialistImage = SpecialistProfileApi::getImage($id);
         $specialistProjects = SpecialistApi::getSpecialistProjects($id);
     }
     $this->render('profile', array('userProfile' => $userProfile, 'userAddress' => $userAddress, 'userImages' => $userImages, 'agentProfile' => $agentProfile, 'agentAddress' => $agentAddress, 'builderProfile' => $builderProfile, 'builderAddress' => $builderAddress, 'specialistProfile' => $specialistProfile, 'specialistAddress' => $specialistAddress, 'specialistProjects' => $specialistProjects, 'agentImage' => $agentImage, 'builderImage' => $builderImage, 'specialistImage' => $specialistImage));
     Yii::endProfile('account_profile');
 }
コード例 #4
0
 public function actionView($id)
 {
     Yii::beginProfile('property_view');
     $session = Yii::app()->session;
     $property = PropertyApi::getPropertyById($id);
     if (!$property) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     if (!$property->furnished) {
         $property->furnished = '-';
     }
     if (!$property->floor_number) {
         $property->floor_number = '-';
     }
     if (!$property->total_floors) {
         $property->total_floors = '-';
     }
     if (!$property->facing) {
         $property->facing = '-';
     }
     $recentlyViewed = UserApi::getUserProfileDetails($property->recently_viewed);
     $propertyAgentInfo = AgentProfileApi::getAgentDetails($property->user_id);
     $propertyUser = "";
     $propertyAgent = "";
     $propertyBuilder = "";
     $propertyBuilderInfo = "";
     $propertySpecialist = "";
     $propertySpecialistInfo = "";
     $propertyRating = "";
     $propertyRating = PropertyRatingApi::getRating($id);
     if ($propertyAgentInfo) {
         $propertyAgent = UserApi::getUserProfileDetails($propertyAgentInfo->user_id);
     } else {
         $propertyBuilderInfo = BuilderProfileApi::getBuilderDetails($property->user_id);
         if ($propertyBuilderInfo) {
             $propertyBuilder = UserApi::getUserProfileDetails($propertyBuilderInfo->user_id);
         } else {
             $propertySpecialistInfo = SpecialistProfileApi::getSpecialistDetails($property->user_id);
             if ($propertySpecialistInfo) {
                 $propertySpecialist = UserApi::getUserProfileDetails($propertySpecialistInfo->user_id);
             } else {
                 $propertyUser = UserApi::getUser($property->user_id);
             }
         }
     }
     $propertySimilar = PropertyApi::getSimilarProperties($property, 3, $id);
     $propertySimilarAddress = "";
     $propertySimilarUser = "";
     if ($propertySimilar) {
         foreach ($propertySimilar as $similar) {
             $propertySimilarAddress[$similar->id] = PropertyApi::getLocation($similar->id);
             $propertySimilarUser[$similar->id] = UserApi::getUserProfileDetails($similar->user_id);
         }
     }
     $recentlyViewedIds[] = '';
     $recentlyViewedIds_total = $session['properties'];
     if ($recentlyViewedIds_total) {
         $re_array = array_reverse($recentlyViewedIds_total);
         $i = 0;
         foreach ($re_array as $re) {
             $recentlyViewedIds = $re;
             $i++;
             if ($i > 2) {
                 break;
             }
         }
     }
     $property_ids[] = $recentlyViewedIds;
     $property_ids[] = $id;
     $session['properties'] = array_unique($property_ids);
     $propertyRecentlyViewed = "";
     $propertyRecentlyViewedAddress = "";
     $propertyRecentlyViewedUser = "";
     if ($recentlyViewedIds) {
         foreach ($recentlyViewedIds as $recent) {
             $modelProperty = PropertyApi::getPropertyById($recent);
             if ($modelProperty) {
                 $propertyRecentlyViewed[] = $modelProperty;
                 $propertyRecentlyViewedAddress[] = PropertyApi::getLocation($recent);
                 $propertyRecentlyViewedUser[] = UserApi::getUserProfileDetails($modelProperty->user_id);
             }
         }
     }
     $propertyImages = PropertyImagesApi::getAllImages($property->id);
     $propertyType = PropertyTypesApi::getPropertyTypeById($property->property_type_id);
     $transactionType = PropertyTransactionTypesApi::getTransactionTypeById($property->transaction_type_id);
     $ownershipType = OwnershipTypesApi::getOwnershipTypeById($property->ownership_type_id);
     $propertyAge = PropertyAgeOfConstructionApi::getpropertyAgeById($property->age_of_construction);
     $propertyAmenities = PropertyAmenitiesApi::getAmenitiesForProperty($property->id);
     $propertyAddress = PropertyApi::getLocation($property->id);
     $propertyRating = PropertyRatingApi::getRating($property->id);
     $propertyWishlist = PropertyWishlistApi::getWishlistUserOnProperty($property->id, Yii::app()->user->id);
     $this->render('view', array('property' => $property, 'recentlyViewed' => $recentlyViewed, 'propertyAgentInfo' => $propertyAgentInfo, 'propertyBuilderInfo' => $propertyBuilderInfo, 'propertySpecialistInfo' => $propertySpecialistInfo, 'propertyUser' => $propertyUser, 'propertyAgent' => $propertyAgent, 'propertyBuilder' => $propertyBuilder, 'propertySpecialist' => $propertySpecialist, 'propertySimilar' => $propertySimilar, 'propertySimilarAddress' => $propertySimilarAddress, 'propertySimilarUser' => $propertySimilarUser, 'propertyRecentlyViewed' => $propertyRecentlyViewed, 'propertyRecentlyViewedAddress' => $propertyRecentlyViewedAddress, 'propertyRecentlyViewedUser' => $propertyRecentlyViewedUser, 'propertyImages' => $propertyImages, 'propertyType' => $propertyType, 'propertyAddress' => $propertyAddress, 'transactionType' => $transactionType, 'ownershipType' => $ownershipType, 'propertyAge' => $propertyAge, 'propertyAmenities' => $propertyAmenities, 'propertyRating' => $propertyRating, 'propertyWishlist' => $propertyWishlist));
     Yii::endProfile('property_view');
 }
コード例 #5
0
 public function actionView($id)
 {
     Yii::beginProfile('project_view');
     $session = Yii::app()->session;
     $project = ProjectApi::getProjectById($id);
     if (!$project) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $recentlyViewed = UserApi::getUserProfileDetails($project->recently_viewed);
     $projectAgentInfo = AgentProfileApi::getAgentDetails($project->user_id);
     $projectUser = "";
     $projectAgent = "";
     $projectBuilder = "";
     $projectBuilderInfo = "";
     $projectSpecialist = "";
     $projectSpecialistInfo = "";
     $projectRating = '';
     if ($projectAgentInfo) {
         $projectAgent = UserApi::getUserProfileDetails($projectAgentInfo->user_id);
     } else {
         $projectBuilderInfo = BuilderProfileApi::getBuilderDetails($project->user_id);
         if ($projectBuilderInfo) {
             $projectBuilder = UserApi::getUserProfileDetails($projectBuilderInfo->user_id);
         } else {
             $projectSpecialistInfo = SpecialistProfileApi::getSpecialistDetails($project->user_id);
             if ($projectSpecialistInfo) {
                 $projectSpecialist = UserApi::getUserProfileDetails($projectSpecialistInfo->user_id);
             } else {
                 $projectUser = UserApi::getUser($project->user_id);
             }
         }
     }
     $projectSimilar = ProjectApi::getSimilarProjects($project, 3);
     $projectSimilarAddress = "";
     $projectSimilarUser = "";
     if ($projectSimilar) {
         foreach ($projectSimilar as $similar) {
             $projectSimilarAddress[$similar->id] = ProjectApi::getLocation($similar->id);
             $projectSimilarUser[$similar->id] = UserApi::getUserProfileDetails($similar->user_id);
         }
     }
     $recentlyViewedIds = $session['projects'];
     $project_ids = $recentlyViewedIds;
     $project_ids[] = $id;
     $session['projects'] = array_unique($project_ids);
     $projectRecentlyViewed = "";
     $projectRecentlyViewedAddress = "";
     $projectRecentlyViewedUser = "";
     if ($recentlyViewedIds) {
         foreach ($recentlyViewedIds as $recent) {
             $modelProject = ProjectApi::getProjectById($recent);
             $projectRecentlyViewed[] = $modelProject;
             $projectRecentlyViewedAddress[] = ProjectApi::getLocation($recent);
             $projectRecentlyViewedUser[] = UserApi::getUserProfileDetails($modelProject->user_id);
         }
     }
     $projectImages = ProjectImagesApi::getAllImages($project->id);
     $projectType = ProjectTypesApi::getProjectTypeById($project->project_type_id);
     $ownershipType = OwnershipTypesApi::getOwnershipTypeById($project->ownership_type_id);
     $projectAmenities = ProjectAmenitiesApi::getAmenitiesForProject($project->id);
     $projectAddress = ProjectApi::getLocation($project->id);
     $projectProperties = ProjectPropertiesApi::getPropertiesModel($project->id);
     $projectWishlist = ProjectWishlistApi::getWishlistUserOnProject($project->id, Yii::app()->user->id);
     $projectRating = ProjectRatingApi::getRating($project->id);
     $projectViews = ProjectApi::getViews($project->id);
     ProjectApi::setViews($project->id);
     $this->render('view', array('project' => $project, 'recentlyViewed' => $recentlyViewed, 'projectAgentInfo' => $projectAgentInfo, 'projectBuilderInfo' => $projectBuilderInfo, 'projectSpecialistInfo' => $projectSpecialistInfo, 'projectUser' => $projectUser, 'projectAgent' => $projectAgent, 'projectBuilder' => $projectBuilder, 'projectSpecialist' => $projectSpecialist, 'projectSimilar' => $projectSimilar, 'projectSimilarAddress' => $projectSimilarAddress, 'projectSimilarUser' => $projectSimilarUser, 'projectRecentlyViewed' => $projectRecentlyViewed, 'projectRecentlyViewedAddress' => $projectRecentlyViewedAddress, 'projectRecentlyViewedUser' => $projectRecentlyViewedUser, 'projectImages' => $projectImages, 'projectType' => $projectType, 'projectAddress' => $projectAddress, 'ownershipType' => $ownershipType, 'projectAmenities' => $projectAmenities, 'projectProperties' => $projectProperties, 'projectRating' => $projectRating, 'projectWishlist' => $projectWishlist, 'projectViews' => $projectViews));
     Yii::endProfile('project_view');
 }
コード例 #6
0
 public function actionCreate()
 {
     Yii::beginProfile('builder_create');
     $userId = Yii::app()->user->id;
     $model = BuilderProfileApi::getBuilderDetails($userId);
     if ($model) {
         $this->redirect('/builder/' . $userId);
     }
     $model = new UserBuilderProfile();
     $model_data = UserApi::getUser($userId);
     $projectType = new UserBuilderProjectType();
     $projecttypes = '';
     $modelState = new GeoState();
     $locationCity = new UserBuilderLocations();
     $locations = '';
     $this->performAjaxValidation($model);
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'builder-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['submit'])) {
         $model->attributes = $_POST['UserBuilderProfile'];
         $valid = true;
         $model->user_id = $userId;
         $valid = $valid && $model->validate();
         if (!isset($_POST['project_type_id'])) {
             $projectType->addError('UserBuilderProjectType', 'Project Type cannot be blank.');
             $valid = false;
         }
         if (!isset($_POST['city_id'])) {
             $locationCity->addError('city_id', 'City cannot be blank.');
             $valid = false;
         }
         if ($valid) {
             $data = $_POST['UserBuilderProfile'];
             $data['image'] = $model->image;
             $imagePath = ImageUtils::uploadImage($model, 'image');
             if ($imagePath) {
                 $image = BuilderProfileApi::addImage($userId, $imagePath);
                 if ($image) {
                     $data['image'] = $image;
                     $builder = BuilderProfileApi::createBuilderProfile($userId, $data);
                     $projecttypes = UserBuilderProjectTypeApi::createProjectTypes($builder->id, $_POST['project_type_id']);
                     $locations = UserBuilderLocationsApi::createLocations($builder->id, $_POST['city_id']);
                     ImageUtils::deleteImage($imagePath);
                     if ($builder) {
                         $data = array();
                         $user = UserApi::getUserById(Yii::app()->user->id);
                         $user ? $data["user"] = $user->id : null;
                         $data["builder"] = $builder->id;
                         EmailApi::sendEmail($user->email_id, "ACTIVITY.BUILDER.CREATE", $data);
                         Yii::app()->user->setFlash('success', 'You are Successfully created Builder Profile.');
                         $this->redirect('/builder/' . $userId);
                     }
                 }
             }
         }
     }
     $model->mobile = $model_data['mobile'];
     $model->telephone = $model_data['telephone'];
     $model->email = $model_data['email_id'];
     $this->render('create', array('model' => $model, 'projectType' => $projectType, 'projecttypes' => $projecttypes, 'modelState' => $modelState, 'locationCity' => $locationCity, 'locations' => $locations));
     Yii::endProfile('builder_create');
 }
コード例 #7
0
 public function actionCreate()
 {
     Yii::beginProfile('specialist_create');
     $userId = Yii::app()->user->id;
     $model = SpecialistProfileApi::getSpecialistDetails($userId);
     if ($model) {
         $this->redirect('/specialist/' . $userId);
     }
     $model = new UserSpecialistProfile();
     $modelState = new GeoState();
     $modelCity = new UserSpecialistLocations();
     $model_data = UserApi::getUser($userId);
     $specialistType = new UserSpecialistType();
     $specialists = "";
     $this->performAjaxValidation($model);
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'specialist-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['submit'])) {
         $model->attributes = $_POST['UserSpecialistProfile'];
         $specialists = isset($_POST['specialist_type_id']) ? $_POST['specialist_type_id'] : null;
         $valid = true;
         $model->user_id = $userId;
         $valid = $valid && $model->validate();
         if ($specialists == null) {
             $specialistType->addError('specialist_type_id', 'Specialist Type cannot be blank.');
             $valid = false;
         }
         if (!isset($_POST['city_id'])) {
             $modelCity->addError('city_id', 'City cannot be blank.');
             $valid = false;
         }
         if ($valid) {
             $data = $_POST['UserSpecialistProfile'];
             $imagePath = ImageUtils::uploadImage($model, 'image');
             if ($imagePath) {
                 $image = SpecialistApi::addImage($userId, $imagePath);
                 if ($image) {
                     $data['image'] = $image;
                     $specialist = SpecialistProfileApi::createSpecialistProfile($userId, $data);
                     $specialists = SpecialistTypeApi::createSpecialistTypes($userId, $_POST['specialist_type_id']);
                     $locations = UserSpecialistLocationsApi::createLocations($specialist->id, $_POST['city_id']);
                     ImageUtils::deleteImage($imagePath);
                     if ($specialist) {
                         $data = array();
                         $user = UserApi::getUserById(Yii::app()->user->id);
                         $user ? $data["user"] = $user->id : null;
                         $data["specialist"] = $specialist->id;
                         EmailApi::sendEmail($user->email_id, "ACTIVITY.SPECIALIST.CREATE", $data);
                         Yii::app()->user->setFlash('success', 'You are Successfully created Specialist Profile.');
                         $this->redirect('/specialist/' . $userId);
                     }
                 }
             }
         }
     }
     $model->mobile = $model_data['mobile'];
     $model->telephone = $model_data['telephone'];
     $model->email = $model_data['email_id'];
     $this->render('create', array('model' => $model, 'modelState' => $modelState, 'modelCity' => $modelCity, 'specialistType' => $specialistType, 'specialists' => $specialists));
     Yii::endProfile('specialist_create');
 }
コード例 #8
0
<?php

require_once "Swagger.php";
require_once "UserApi.php";
require_once "models/User.php";
$apiServer = "http://localhost:8080";
$apiKey = "";
$apiClient = new APIClient("http://localhost:8080", "");
$userApi = new UserApi($apiClient);
$user = $userApi->getUser(1);
var_dump($user);
$searchApi = new SearchApi($apiClient);
$users = $searchApi->searchUsers("T");
var_dump($users);
コード例 #9
0
ファイル: EmailApi.php プロジェクト: romeo14/pow
 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;
 }
コード例 #10
0
ファイル: ProfileDetails.php プロジェクト: romeo14/wallfeet
 public function run()
 {
     $userId = Yii::app()->user->id;
     $model = UserApi::getUser($userId);
     $this->render('profiledetails', array('model' => $model));
 }