* @version $Revision: 1.1 $ * @since PHP 4.1 */ require_once SGL_MOD_DIR . '/newsletter/classes/NewsletterMgr.php'; require_once SGL_MOD_DIR . '/newsletter/classes/Output.php'; class Newsletter_Block_Subscribe { function init($output) { SGL::logMessage(null, PEAR_LOG_DEBUG); $this->userID = isset($output->loggedOnUserID) ? $output->loggedOnUserID : ''; $this->username = isset($output->loggedOnUser) ? $output->loggedOnUser : ''; return $this->getBlockContent(); } function getBlockContent() { if ($this->username) { $news = & new NewsletterMgr(); $lists = $news->_getList(); $subscribedLists = $news->getSubscribedLists($this->userID); $unsubscribedLists = $news->getUnsubscribedLists($this->userID); $text = ''; if ($subscribedLists) { $subscribedNewsLists = ''; foreach ($subscribedLists as $k => $v) { foreach ($lists as $lKey => $lValue) { if ($lValue['name'] == $v->list) { $this->listID = $lKey; } } $subscribedNewsLists .= ''. $v->list . ' (unsubscribe)
'; } $text .= ' '; } if ($unsubscribedLists) { $unsubscribedNewsLists = ''; foreach ($unsubscribedLists as $k => $v) { $this->listID = $k; $unsubscribedNewsLists .= ''. $v['name'] .' - '. $v['description'] . ' (subscribe)
'; } $text .= ' '; } $text .= '
Current Subscriptions:
'. $subscribedNewsLists .'
Available Subscriptions:
'. $unsubscribedNewsLists .'
'; } else { $news = & new NewsletterMgr(); $lists = $news->_getList(); $newsLists = ''; foreach ($lists as $k => $v) { $newsLists .= ''. ''.$v['description'].'
'; } $text = '
Please login if you are a registered user.
' . SGL_String::translate('Name') . ':
' . SGL_String::translate('Email') . ':
' . SGL_String::translate('Lists') . ':
' . $newsLists . '
' . SGL_String::translate('Action') . ':
' . SGL_String::translate('Subscribe') . '
' . SGL_String::translate('Unsubscribe') . '
'; } return $text; } } ?>