/** * Template function: Provide link to message form for this Item's author. * * @param string url of the message form * @param string to display before link * @param string to display after link * @param string link text * @param string link title * @param string class name * @return boolean true, if a link was displayed; false if there's no email address for the Item's author. */ function msgform_link($params = array()) { // Make sure we are not missing any param: $params = array_merge(array('before' => ' ', 'after' => ' ', 'text' => '#', 'title' => '#', 'class' => '', 'format' => 'htmlbody', 'form_url' => '#current_blog#'), $params); if ($params['form_url'] == '#current_blog#') { // Get global $Blog; $params['form_url'] = $Blog->get('msgformurl'); } $this->get_creator_User(); $redirect_to = url_add_param($params['form_url'], 'post_id=' . $this->ID . '&recipient_id=' . $this->creator_User->ID, '&'); $params['form_url'] = $this->creator_User->get_msgform_url(url_add_param($params['form_url'], 'post_id=' . $this->ID), $redirect_to); if (empty($params['form_url'])) { return false; } if ($params['title'] == '#') { if ($this->creator_User->get_msgform_possibility() == 'email') { $params['title'] = T_('Send email to post author'); } else { $params['title'] = T_('Send message to post author'); } } if ($params['text'] == '#') { $params['text'] = get_icon('email', 'imgtag', array('class' => 'middle', 'title' => $params['title'])); } echo $params['before']; echo '<a href="' . $params['form_url'] . '" title="' . $params['title'] . '"'; if (!empty($params['class'])) { echo ' class="' . $params['class'] . '"'; } echo ' rel="nofollow">' . $params['text'] . '</a>'; echo $params['after']; return true; }
/** * Provide link to message form for this comment's author * * @param string url of the message form * @param string to display before link * @param string to display after link * @param string link text * @param string link title * @param string class name */ function msgform_link($form_url, $before = ' ', $after = ' ', $text = '#', $title = '#', $class = '') { if ($this->get_author_User()) { // This comment is from a registered user: $msg_type = $this->author_User->get_msgform_possibility(); if (empty($msg_type)) { // message form is not allowed return false; } $form_url = url_add_param($form_url, 'recipient_id=' . $this->author_User->ID); } else { // This comment is from a visitor: if (empty($this->author_email)) { // We have no email for this comment :( return false; } elseif (empty($this->allow_msgform)) { // Anonymous commentator does not allow message form (for this comment) return false; } $msg_type = 'email'; } $form_url = url_add_param($form_url, 'recipient_id=0&comment_id=' . $this->ID . '&post_id=' . $this->item_ID . '&redirect_to=' . rawurlencode(url_rel_to_same_host(regenerate_url('', '', '', '&'), $form_url))); if ($title == '#') { if ($msg_type == 'email') { $title = T_('Send email to comment author'); } else { $title = T_('Send message to comment author'); } } if ($text == '#') { $text = get_icon('email', 'imgtag', array('class' => 'middle', 'title' => $title)); } echo $before; echo '<a href="' . $form_url . '" title="' . $title . '"'; if (!empty($class)) { echo ' class="' . $class . '"'; } // TODO: have an SEO setting for nofollow here, default to nofollow echo ' rel="nofollow"'; echo '>' . $text . '</a>'; echo $after; return true; }