Ejemplo n.º 1
0
 public function actionView($userId)
 {
     Yii::beginProfile('specialist_view');
     $session = Yii::app()->session;
     $specialist = SpecialistProfileApi::getSpecialistDetails($userId);
     if (!$specialist) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $specialistInfo = UserApi::getUserProfileDetails($specialist->user_id);
     $specialistAddress = DbUtils::getAddress($specialist->city_id);
     $specialistTypes = SpecialistTypeApi::getSpecialistTypeByUserId($specialist->user_id);
     $specialistProjects = SpecialistApi::getSpecialistProjectsByUserId($specialist->user_id);
     $specialistRatingReadOnly = SpecialistRatingApi::isRated($specialist->id, Yii::app()->user->id);
     $specialistRating = SpecialistRatingApi::getRating($specialist->user_id);
     $specialistLocations = UserSpecialistLocationsApi::getLocations($specialist->id);
     $specialistPropertyLocations = "";
     if ($specialistLocations) {
         foreach ($specialistLocations as $specialistLocation) {
             $specialistPropertyLocations[] = DbUtils::getAddress($specialistLocation->city_id);
         }
     }
     if (!$specialistRatingReadOnly) {
         if ($specialist->user_id == Yii::app()->user->id) {
             $specialistRatingReadOnly = true;
         } else {
             $specialistRatingReadOnly = false;
         }
     } else {
         $specialistRatingReadOnly = true;
     }
     $this->render('view', array('specialist' => $specialist, 'specialistInfo' => $specialistInfo, 'specialistAddress' => $specialistAddress, 'specialistTypes' => $specialistTypes, 'specialistProjects' => $specialistProjects, 'specialistRatingReadOnly' => $specialistRatingReadOnly, 'specialistRating' => $specialistRating, 'specialistPropertyLocations' => $specialistPropertyLocations));
     Yii::endProfile('specialist_view');
 }
Ejemplo n.º 2
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;
 }