protected function resolvePhoneAndEmailContent() { $content = null; if ($this->model->officePhone != null) { $content .= Yii::app()->phoneHelper->resolvePersonCardViewOfficePhoneNumberContent($this->model->officePhone, $this->model); } if ($this->model->mobilePhone != null) { $content .= Yii::app()->phoneHelper->resolvePersonCardViewMobilePhoneNumberContent($this->model->mobilePhone, $this->model); } if ($this->model->primaryEmail->emailAddress != null) { $emailContent = EmailMessageUtil::renderEmailAddressAsMailToOrModalLinkStringContent($this->model->primaryEmail->emailAddress, $this->model); $content .= ZurmoHtml::tag('span', array('class' => 'icon-email'), $emailContent); } if ($content != null) { return ZurmoHtml::tag('div', array('class' => 'contact-details'), $content); } }
/** * Renders the noneditable email address content. * If the model is a person, and the user accessing this element has right to access the email module, * then the email address will be clickable. When clicked it will open a modal create email window. * Takes the model attribute value and converts it into * at most 3 items. Email Address display, Opt Out checkbox, * and Invalid Email checkbox. * @return A string containing the element's content. */ protected function renderControlNonEditable() { $addressModel = $this->model->{$this->attribute}; $emailAddress = $addressModel->emailAddress; $optOut = $addressModel->optOut; $isInvalid = $addressModel->isInvalid; $content = null; if (!empty($emailAddress)) { $content .= EmailMessageUtil::renderEmailAddressAsMailToOrModalLinkStringContent($emailAddress, $this->model); if ($optOut || $isInvalid) { $content .= ' ('; } if ($optOut) { $content .= Zurmo::t('EmailMessagesModule', 'Opted Out'); } if ($isInvalid) { if ($optOut) { $content .= ', '; } $content .= Zurmo::t('EmailMessagesModule', 'Invalid'); } if ($optOut || $isInvalid) { $content .= ')'; } } return $content; }
public function testRenderEmailAddressAsMailToOrModalLinkStringContent() { $billy = User::getByUsername('billy'); Yii::app()->user->userModel = $billy; $emailAddress = "*****@*****.**"; $account = new Account(); $content = EmailMessageUtil::renderEmailAddressAsMailToOrModalLinkStringContent($emailAddress, $account); $this->assertEquals('<a href="mailto:a@zurmo.com">a@zurmo.com</a>', $content); $billy->setRight('EmailMessagesModule', EmailMessagesModule::RIGHT_ACCESS_CONFIGURATION); $billy->setRight('EmailMessagesModule', EmailMessagesModule::RIGHT_ACCESS_EMAIL_MESSAGES); $billy->setRight('EmailMessagesModule', EmailMessagesModule::RIGHT_CREATE_EMAIL_MESSAGES); $billy->save(); $content = EmailMessageUtil::renderEmailAddressAsMailToOrModalLinkStringContent($emailAddress, $account); $this->assertEquals('<a href="mailto:a@zurmo.com">a@zurmo.com</a>', $content); //Only if the model is not Account and User as right he can see the email modal link $contact = new Contact(); $content = EmailMessageUtil::renderEmailAddressAsMailToOrModalLinkStringContent($emailAddress, $contact); $this->assertEquals('<a href="#" id="' . ZurmoHtml::ID_PREFIX . (ZurmoHtml::$count - 1) . '">a@zurmo.com</a>', $content); }