Example #1
0
 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;
 }
Example #2
0
 public function actionView($id)
 {
     Yii::beginProfile('message_view');
     $message = PmbApi::getMessageById($id);
     if (!$message) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     if ($message->from_user_id != Yii::app()->user->id && $message->to_user_id != Yii::app()->user->id) {
         $this->redirect('/messages');
     }
     $read = PmbApi::markRead(array($id));
     $unread = PmbApi::getUnreadInboxCount(Yii::app()->user->id);
     $this->render('view', array('message' => $message, 'unread' => $unread, 'id' => $id));
     Yii::endProfile('message_view');
 }
Example #3
0
 public function actionIndex()
 {
     $userId = Yii::app()->user->id;
     $projectImages = '';
     $propertyImages = '';
     $projectCount = '';
     $propertyCount = '';
     $propertyTypes = '';
     $propertyLocations = '';
     $propertyid = '';
     $projectLocations = '';
     $projectOwnerships = '';
     $projectTypes = '';
     $users = '';
     $userIds[] = '';
     $myJukeBox = '';
     $jukeBoxcategoryName = '';
     $jukecount = '0';
     $propertyWishList = '';
     $propertyName = '';
     $projectWishlist = '';
     $projectName = '';
     $propertywishlistcount = 0;
     $inbox = PmbApi::getInbox($userId);
     $userName = UserApi::getUserProfileDetails($userId);
     if ($inbox) {
         foreach ($inbox as $messages) {
             $userIds[] = $messages->from_user_id;
         }
         $users = DbUtils::getDbValues(new UserProfiles(), 'user_id', $userIds, 'first_name');
     }
     $properties = PropertyApi::getPropertiesOfUser($userId, Yii::app()->params['dashboardResultsPerPage']);
     $countUnread = PmbApi::getUnreadInboxCount($userId);
     $propertyCount = PropertyApi::getAllPropertiesCount($userId);
     $locations = '';
     if ($properties) {
         foreach ($properties as $location) {
             $locations[] = $location->city_id;
         }
         $propertyLocations = DbUtils::getDbValues(new GeoCity(), 'id', $locations, 'city');
     }
     if ($properties) {
         foreach ($properties as $property) {
             $propertyTypes[] = $property->property_type_id;
             $propertyid[] = $property->id;
         }
         $propertyImages = PropertyImagesApi::getPrimaryImageForProperties($propertyid);
         $propertyTypes = DbUtils::getDbValues(new PropertyTypes(), 'id', $propertyTypes, 'property_type');
     }
     $projects = ProjectApi::getProjectsOfUser($userId, Yii::app()->params['dashboardResultsPerPage']);
     if ($projects) {
         foreach ($projects as $project) {
             $projectLocationIds[] = $project->city_id;
             $projectTypeIds[] = $project->project_type_id;
             $projectOwnershipIds[] = $project->ownership_type_id;
             $projectIds[] = $project->id;
         }
         $projectImages = ProjectImagesApi::getPrimaryImageForProjects($projectIds);
         $projectLocations = DbUtils::getDbValues(new GeoCity(), 'id', $projectLocationIds, 'city');
         $projectTypes = DbUtils::getDbValues(new ProjectTypes(), 'id', $projectTypeIds, 'project_type');
         $projectOwnerships = DbUtils::getDbValues(new CategoryOwnershipTypes(), 'id', $projectOwnershipIds, 'ownership_type');
     }
     $projectCount = ProjectApi::getProjectsofUserCount($userId);
     $isProfile['agent'] = AgentProfileApi::isAgent($userId);
     $isProfile['builder'] = BuilderProfileApi::isBuilder($userId);
     $isProfile['specialist'] = SpecialistProfileApi::isSpecialist($userId);
     //MyJuckbox
     $myJukeBox = JukeboxQuestionsApi::getAllJukeboxQuestionsOfUser($userId, Yii::app()->params['dashboardResultsPerPage']);
     if ($myJukeBox) {
         foreach ($myJukeBox as $jukeBox) {
             $categoryIdArray[] = $jukeBox->category_id;
         }
         $jukeBoxcategoryName = DbUtils::getDbValues(new JukeboxCategory(), 'id', $categoryIdArray, 'category');
         $jukecount = count($myJukeBox);
     }
     //my wishlists
     $propertyWishList = PropertyWishlistApi::getWishlist($userId, Yii::app()->params['dashboardResultsPerPage']);
     if ($propertyWishList) {
         foreach ($propertyWishList as $propertyWish) {
             $propertyWishlistArray[] = $propertyWish->property_id;
         }
         $propertyName = DbUtils::getDbValues(new Property(), 'id', $propertyWishlistArray, 'property_name');
     }
     $propertywishlistcount = PropertyWishlistApi::getWishlistCount($userId);
     $totalWishlistCount = $propertywishlistcount;
     //+$projectwishlistcount;
     //requirements
     $requirements = RequirementApi::getRequirementByUserId($userId, Yii::app()->params['dashboardResultsPerPage']);
     if ($requirements) {
         $requirementscount = count($requirements);
     } else {
         $requirementscount = 0;
     }
     $this->render('index', array('inbox' => $inbox, 'users' => $users, 'properties' => $properties, 'countUnread' => $countUnread, 'propertyLocations' => $propertyLocations, 'propertyTypes' => $propertyTypes, 'projects' => $projects, 'projectLocations' => $projectLocations, 'projectTypes' => $projectTypes, 'projectOwnerships' => $projectOwnerships, 'propertyCount' => $propertyCount, 'projectCount' => $projectCount, 'propertyid' => $propertyid, 'propertyImages' => $propertyImages, 'projectImages' => $projectImages, 'isProfile' => $isProfile, 'myJukeBox' => $myJukeBox, 'jukeBoxcategoryName' => $jukeBoxcategoryName, 'jukecount' => $jukecount, 'propertyWishList' => $propertyWishList, 'propertyName' => $propertyName, 'projectName' => $projectName, 'totalWishlistCount' => $totalWishlistCount, 'requirements' => $requirements, 'requirementscount' => $requirementscount, 'userName' => $userName));
 }
Example #4
0
 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;
 }