/** * Retrieves the html codes for the ratings. * * @param int $uid The unique id for the item that is being rated * @param string $type The unique type for the item that is being rated * @param string $command A textual representation to request user to vote for this item. * @param string $element A dom element id. **/ public function addMailQueue(EasyBlogSubscriptionItem $item) { $config = EasyBlogHelper::getConfig(); // building unsubcribe linke object $obj = new stdClass(); $obj->type = $item->utype; $obj->id = $item->uid; $obj->user_id = $item->user_id; $obj->created = $item->ucreated; // building email data $maildata = array(); $maildata['fullname'] = $item->ufullname; $maildata['target'] = $item->targetname; $maildata['targetlink'] = $item->targetlink; $maildata['type'] = $item->utype; $recipient = new stdClass(); $recipient->email = $item->uemail; $recipient->unsubscribe = EasyBlogHelper::getUnsubscribeLink($obj, true); $emailTitle = JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_CONFIRMATION'); $notification = EasyBlogHelper::getHelper('Notification'); $notification->send(array($recipient), $emailTitle, 'email.subscriptions.confirmation', $maildata); }
public function getSiteSubscriberEmails(&$emails = array()) { $model = EasyBlogHelper::getModel('Subscription'); $subscribers = $model->getSiteSubscribers(); if (!empty($subscribers)) { foreach ($subscribers as $subscriber) { if (!array_key_exists($subscriber->email, $emails)) { $obj = new stdClass(); $obj->email = $subscriber->email; $obj->unsubscribe = EasyBlogHelper::getUnsubscribeLink($subscriber, true); $emails[$subscriber->email] = $obj; } } } }
/** * prepare unsubscribe links * * @since 4.0 * @access public * @param string - email address * strig - format - accept html, array * @return */ public function getUnsubscribeLinks($email) { $db = EB::db(); $query = 'select *,'; $query .= ' (case'; $query .= ' when `utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_SITE) . ' then ' . $db->Quote('sitesubscription'); $query .= ' when `utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_BLOGGER) . ' then ' . $db->Quote('bloggersubscription'); $query .= ' when `utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_CATEGORY) . ' then ' . $db->Quote('categorysubscription'); $query .= ' when `utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_TEAMBLOG) . ' then ' . $db->Quote('teamsubscription'); $query .= ' when `utype` = ' . $db->Quote(EBLOG_SUBSCRIPTION_ENTRY) . ' then ' . $db->Quote('subscription'); $query .= ' end) as `type` from ' . $db->qn('#__easyblog_subscriptions'); $query .= " WHERE `email` = " . $db->Quote($email); $db->setQuery($query); $results = $db->loadObjectList(); $links = array(); $types = array(); $created = ''; if ($results) { foreach ($results as $item) { $link = EasyBlogHelper::getUnsubscribeLink($item, true); $links[$item->type] = $link; $types[$item->type] = $item->id . '|' . $item->created; } if (count($links) > 1) { // lets generate a 'all' type unsubscribe link. $link = EasyBlogHelper::getUnsubscribeLink($types, true, true, $email); $links['all'] = $link; } } return $links; }
function display($tmpl = null) { $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $postTable = EasyBlogHelper::getTable('Blog', 'Table'); $bloggerTable = EasyBlogHelper::getTable('Profile', 'Table'); $catTable = EasyBlogHelper::getTable('Category', 'Table'); $teamTable = EasyBlogHelper::getTable('TeamBlog', 'Table'); $document->setTitle(JText::_('COM_EASYBLOG_SUBSCRIPTIONS_PAGE_TITLE')); if (!EasyBlogRouter::isCurrentActiveMenu('subscription')) { $this->setPathway(JText::_('COM_EASYBLOG_SUBSCRIPTIONS_BREADCRUMB')); } $subscription = array(); if (!empty($my->id)) { $subs = EasyBlogHelper::getSubscriptionbyUser($my->id); if (!empty($subs)) { foreach ($subs as $sub) { $temp = new stdClass(); $temp->id = $sub->id; $temp->type = $sub->type; $temp->unsublink = EasyBlogHelper::getUnsubscribeLink($sub, false); switch ($sub->type) { case 'sitesubscription': $temp->name = ''; $temp->link = ''; break; case 'subscription': $postTable = EasyBlogHelper::getTable('Blog'); $postTable->load($sub->cid); $temp->name = $postTable->title; $temp->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $postTable->id, false); break; case 'bloggersubscription': $bloggerTable = EasyBlogHelper::getTable('Profile'); $bloggerTable->load($sub->cid); $temp->name = $bloggerTable->getName(); $temp->link = $bloggerTable->getProfileLink(); break; case 'categorysubscription': $catTable = EasyBlogHelper::getTable('Category'); $catTable->load($sub->cid); $temp->name = $catTable->title; $temp->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=categories&layout=listings&id=' . $catTable->id, false); break; case 'teamsubscription': $teamTable = EasyBlogHelper::getTable('TeamBlog'); $teamTable->load($sub->cid); $temp->name = $teamTable->title; $temp->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=teamblog&layout=listings&id=' . $teamTable->id, false); break; default: //dont do anything if it is an unrecognize type. } $subscription[$sub->type][] = $temp; } } } $theme = new CodeThemes(); $theme->set('my', $my); $theme->set('subscription', $subscription); $html = $theme->fetch('subscription.php'); echo $html; }