本文整理汇总了PHP中CRoute::getExternalURL方法的典型用法代码示例。如果您正苦于以下问题:PHP CRoute::getExternalURL方法的具体用法?PHP CRoute::getExternalURL怎么用?PHP CRoute::getExternalURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRoute
的用法示例。
在下文中一共展示了CRoute::getExternalURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: injectTags
/**
* Inject data from paramter to content tags ({}) .
*
* @param $content Original content with content tags.
* @param $params Text contain all values need to be replaced.
* @param $html Auto detect url tag and insert inline.
* @return $text The content after replacing.
**/
public static function injectTags($content, $paramsTxt, $html = false)
{
$params = new CParameter($paramsTxt);
preg_match_all("/{(.*?)}/", $content, $matches, PREG_SET_ORDER);
if (!empty($matches)) {
foreach ($matches as $val) {
$replaceWith = JString::trim($params->get($val[1], null));
if (!is_null($replaceWith)) {
//if the replacement start with 'index.php', we can CRoute it
if (JString::strpos($replaceWith, 'index.php') === 0) {
$replaceWith = CRoute::getExternalURL($replaceWith);
}
if ($html) {
$replaceUrl = $params->get($val[1] . '_url', null);
if (!is_null($replaceUrl)) {
if ($val[1] == 'stream') {
$replaceUrl .= '#activity-stream-container';
}
//if the replacement start with 'index.php', we can CRoute it
if (JString::strpos($replaceUrl, 'index.php') === 0) {
$replaceUrl = CRoute::getExternalURL($replaceUrl);
}
$replaceWith = '<a href="' . $replaceUrl . '">' . $replaceWith . '</a>';
}
}
$content = CString::str_ireplace($val[0], $replaceWith, $content);
}
}
}
return $content;
}
示例2: send
/**
* Do a batch send
*/
function send($total = 100)
{
$mailqModel = CFactory::getModel('mailq');
$userModel = CFactory::getModel('user');
$mails = $mailqModel->get($total);
$jconfig = JFactory::getConfig();
$mailer = JFactory::getMailer();
$config = CFactory::getConfig();
$senderEmail = $jconfig->getValue('mailfrom');
$senderName = $jconfig->getValue('fromname');
if (empty($mails)) {
return;
}
CFactory::load('helpers', 'string');
foreach ($mails as $row) {
// @rule: only send emails that is valid.
// @rule: make sure recipient is not blocked!
$userid = $userModel->getUserFromEmail($row->recipient);
$user = CFactory::getUser($userid);
if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) {
$mailer->setSender(array($senderEmail, $senderName));
$mailer->addRecipient($row->recipient);
$mailer->setSubject($row->subject);
$tmpl = new CTemplate();
$raw = isset($row->params) ? $row->params : '';
$params = new JParameter($row->params);
$base = $config->get('htmlemail') ? 'email.html' : 'email.text';
if ($config->get('htmlemail')) {
$row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
$mailer->IsHTML(true);
} else {
//@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
$row->body = CStringHelper::escape(strip_tags($row->body));
}
$tmpl->set('content', $row->body);
$tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template'));
$tmpl->set('sitename', $config->get('sitename'));
$row->body = $tmpl->fetch($base);
// Replace any occurences of custom variables within the braces scoe { }
if (!empty($row->body)) {
preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$replaceWith = $params->get($val[1], null);
//if the replacement start with 'index.php', we can CRoute it
if (strpos($replaceWith, 'index.php') === 0) {
$replaceWith = CRoute::getExternalURL($replaceWith);
}
if (!is_null($replaceWith)) {
$row->body = JString::str_ireplace($val[0], $replaceWith, $row->body);
}
}
}
unset($tmpl);
$mailer->setBody($row->body);
$mailer->send();
}
$mailqModel->markSent($row->id);
$mailer->ClearAllRecipients();
}
}
示例3: sendEmail
public function sendEmail($type, $user, $password = null, $requireApproval = false)
{
$mainframe = JFactory::getApplication();
$config = CFactory::getConfig();
$modelRegister = $this->getModel('register');
$sitename = $mainframe->getCfg('sitename');
$mailfrom = $mainframe->getCfg('mailfrom');
$fromname = $mainframe->getCfg('fromname');
$siteURL = JURI::base();
$name = $user->get('name');
$email = $user->get('email');
$username = $user->get('username');
$com_user_config = JComponentHelper::getParams('com_users');
$com_user_activation_type = $com_user_config->get('useractivation');
if (is_null($password)) {
$password = $user->get('password');
}
//Disallow control chars in the email
$password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
$params = JComponentHelper::getParams('com_users');
if ($params->get('sendpassword', 1) == 0) {
$password = '***';
}
// Load Super Administrator email list
$rows = $modelRegister->getSuperAdministratorEmail();
//getting superadmin email address.
if (!$mailfrom || !$fromname) {
foreach ($rows as $row) {
if ($row->sendEmail) {
$fromname = $row->name;
$mailfrom = $row->email;
break;
}
}
//if still empty, then we just pick one of the admin email
if (!$mailfrom || !$fromname) {
$fromname = $rows[0]->name;
$mailfrom = $rows[0]->email;
}
}
$subject = JText::sprintf('COM_COMMUNITY_ACCOUNT_DETAILS_FOR', $name, $sitename);
$subject = html_entity_decode($subject, ENT_QUOTES);
$baseUrl = JUri::base();
$activationURL = $baseUrl . 'index.php?option=' . COM_COMMUNITY_NAME . '&view=register&task=activate&' . ACTIVATION_KEYNAME . '=' . $user->get('activation');
switch ($type) {
case 'registration':
// This section will only be called when there are no custom fields created and we just proceed like how Joomla
// registers a user.
if ($requireApproval || $com_user_activation_type == 1) {
$message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_REQUIRES_ACTIVATION', $name, $sitename, $activationURL, $siteURL, $username, $password);
} else {
$message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION', $name, $sitename, $username, $password);
}
break;
case 'registration_uncomplete':
$subject = JText::sprintf('COM_COMMUNITY_ACCOUNT_DETAILS_FOR_WELCOME', $sitename);
$subject = html_entity_decode($subject, ENT_QUOTES);
if ($requireApproval || $com_user_activation_type == 2) {
$message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS_REQUIRES_ACTIVATION', $name, $sitename, $username, $password);
} else {
$message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS', $name, $sitename, $username, $password);
}
break;
case 'registration_complete':
if ($requireApproval || $com_user_activation_type == 2) {
// if approval is required, send an email to both admin and user, admin - to activate the user, user - to wait for admin approval
$message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED_REQUIRES_ADMIN_ACTIVATION', $name, $sitename, $siteURL);
} else {
$message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED_REQUIRES_ACTIVATION', $name, $sitename, $activationURL, $siteURL);
}
break;
case 'resend_activation':
if ($config->get('activationresetpassword')) {
$message = JText::sprintf('COM_COMMUNITY_ACTIVATION_MSG_WITH_PWD', $name, $sitename, $activationURL, $siteURL, $username, $password);
} else {
$message = JText::sprintf('COM_COMMUNITY_ACTIVATION_MSG', $name, $sitename, $activationURL, $siteURL);
}
break;
}
$message = html_entity_decode($message, ENT_QUOTES);
$sendashtml = false;
$copyrightemail = JString::trim($config->get('copyrightemail'));
// this is used to send the username and password email if the settings of user configuration -> send username and password is enabled from the backend
if ($type == 'registration_uncomplete' && $com_user_config->get('sendpassword')) {
//check if HTML emails are set to ON
if ($config->get('htmlemail')) {
$sendashtml = true;
$tmpl = new CTemplate();
$message = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message);
$tmpl->set('name', $name);
$tmpl->set('email', $email);
$message = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=email'), false)->set('content', $message)->set('copyrightemail', $copyrightemail)->set('sitename', $config->get('sitename'))->fetch('email.html');
}
$mail = JFactory::getMailer();
$mail->sendMail($mailfrom, $fromname, $email, $subject, $message, $sendashtml);
}
// Send email to user
//if ( ! ($type == 'registration_complete' && !$requireApproval && !$needActivation))
if ($type != 'registration_uncomplete' && ($com_user_activation_type != 0 || $requireApproval)) {
if ($requireApproval || $com_user_activation_type == 2) {
//.........这里部分代码省略.........
示例4: send
/**
* Do a batch send
*/
public function send($total = 100)
{
$app = JFactory::getApplication();
$mailqModel = CFactory::getModel('mailq');
$userModel = CFactory::getModel('user');
$mails = $mailqModel->get($total);
$mailer = JFactory::getMailer();
$config = CFactory::getConfig();
$senderEmail = $app->getCfg('mailfrom');
$senderName = $app->getCfg('fromname');
$sitename = $app->getCfg('config.sitename');
if (empty($mails)) {
return;
}
foreach ($mails as $row) {
if ($row->email_type === 'etype_friends_invite_users') {
/* for invite email */
$raw = isset($row->params) ? $row->params : '';
$rowParams = new CParameter($row->params);
$userid = JUri::getInstance($rowParams->get('actor_url'))->getVar('userid');
} else {
// @rule: only send emails that is valid.
// @rule: make sure recipient is not blocked!
$userid = $userModel->getUserFromEmail($row->recipient);
}
$user = CFactory::getUser($userid);
//verify user email list settting
$user_params = $user->getParams();
$validate = true;
if (!empty($row->email_type)) {
$validate = $user_params->get($row->email_type, $config->get($row->email_type)) == 1 ? true : false;
}
if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar') && $validate) {
$mailer->setSender(array($senderEmail, $senderName));
$mailer->addRecipient($row->recipient);
// Replace any occurences of custom variables within the braces scoe { }
$row->subject = CContentHelper::injectTags($row->subject, $row->params, false);
$mailer->setSubject($row->subject);
$tmpl = new CTemplate();
$raw = isset($row->params) ? $row->params : '';
$params = new CParameter($row->params);
$base = $config->get('htmlemail') ? 'email.html' : 'email.text';
if ($config->get('htmlemail')) {
$row->body = CString::str_ireplace(array("<p>\r\n", "<p>\r", "<p>\n"), '<p>', $row->body);
$row->body = CString::str_ireplace(array("</p>\r\n", "</p>\r", "</p>\n"), '</p>', $row->body);
$row->body = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
$mailer->IsHTML(true);
} else {
//@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
$row->body = CStringHelper::escape(strip_tags($row->body));
}
$copyrightemail = JString::trim($config->get('copyrightemail'));
$tmpl->set('email_type', $row->email_type);
$tmpl->set('avatar', $user->getAvatar());
$tmpl->set('thumbAvatar', $user->getThumbAvatar());
$tmpl->set('name', $user->getDisplayName());
$tmpl->set('email', $user->email);
$tmpl->set('sitename', $sitename);
$tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=email'), false);
$tmpl->set('userid', $userid);
$tmpl->set('copyrightemail', $copyrightemail);
$tmpl->set('recepientemail', $row->recipient);
$tmpl->set('content', $row->body);
$tmpl->set('template', JURI::root(true) . '/components/com_community/templates/' . $config->get('template'));
$tmpl->set('sitename', $config->get('sitename'));
$row->body = $tmpl->fetch($base);
// Replace any occurences of custom variables within the braces scoe { }
if (!empty($row->body)) {
$row->body = CContentHelper::injectTags($row->body, $row->params, false);
}
unset($tmpl);
$mailer->setBody($row->body);
if ($mailer->send()) {
$validate = true;
} else {
$validate = false;
}
}
if (!$validate) {
//email is blocked by user settings
$mailqModel->markEmailStatus($row->id, 2);
} else {
$mailqModel->markSent($row->id);
}
$mailer->ClearAllRecipients();
}
}
示例5: _sendEMail
private function _sendEMail($type, $user, $password = null, $requireApproval = false)
{
$mainframe =& JFactory::getApplication();
$config = CFactory::getConfig();
$modelRegister =& $this->getModel('register');
$usersConfig =& JComponentHelper::getParams('com_users');
$useractivation = $usersConfig->get('useractivation');
$newAccountActivation = $usersConfig->get('useractivation');
$sitename = $mainframe->getCfg('sitename');
$mailfrom = $mainframe->getCfg('mailfrom');
$fromname = $mainframe->getCfg('fromname');
$siteURL = JURI::base();
$name = $user->get('name');
$email = $user->get('email');
$username = $user->get('username');
if (is_null($password)) {
$password = $user->get('password');
}
//Disallow control chars in the email
$password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
// Load Super Administrator email list
$rows = $modelRegister->getSuperAdministratorEmail();
//getting superadmin email address.
if (!$mailfrom || !$fromname) {
foreach ($rows as $row) {
if ($row->sendEmail) {
$fromname = $row->name;
$mailfrom = $row->email;
break;
}
}
//if still empty, then we just pick one of the admin email
if (!$mailfrom || !$fromname) {
$fromname = $rows[0]->name;
$mailfrom = $rows[0]->email;
}
}
$subject = JText::sprintf('COM_COMMUNITY_ACCOUNT_DETAILS_FOR', $name, $sitename);
$subject = html_entity_decode($subject, ENT_QUOTES);
$needActivation = $usersConfig->get('useractivation');
$activationURL = CRoute::getExternalURL('index.php?option=' . COM_USER_NAME . '&task=' . COM_USER_TAKS_ACTIVATE . '&' . ACTIVATION_KEYNAME . '=' . $user->get('activation'), false);
switch ($type) {
case 'registration':
// This section will only be called when there are no custom fields created and we just proceed like how Joomla
// registers a user.
if ($needActivation) {
$message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION_REQUIRES_ACTIVATION'), $name, $sitename, $activationURL, $siteURL, $username, $password);
} else {
$message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION'), $name, $sitename, $username, $password);
}
break;
case 'registration_uncomplete':
$subject = JText::sprintf('COM_COMMUNITY_ACCOUNT_DETAILS_FOR_WELCOME', $sitename);
$subject = html_entity_decode($subject, ENT_QUOTES);
if ($needActivation) {
$message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS_REQUIRES_ACTIVATION'), $name, $sitename, $username, $password);
} else {
$message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS'), $name, $sitename, $username, $password);
}
break;
case 'registration_complete':
if ($requireApproval) {
//joomla 1.5 does not need email verification if admin approval feature is enable. But Joomla 1.6 requires
if (C_JOOMLA_15) {
$message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED_REQUIRES_APPROVAL'), $name, $sitename, $siteURL);
} else {
$message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED_REQUIRES_ADMIN_ACTIVATION', $name, $sitename, $activationURL, $siteURL);
}
} else {
if ($needActivation) {
$message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED_REQUIRES_ACTIVATION', $name, $sitename, $activationURL, $siteURL);
} else {
$message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED'), $name, $sitename, $siteURL);
}
}
break;
case 'resend_activation':
if ($config->get('activationresetpassword')) {
$message = sprintf(JText::_('COM_COMMUNITY_ACTIVATION_MSG_WITH_PWD'), $name, $sitename, $activationURL, $siteURL, $username, $password);
} else {
$message = sprintf(JText::_('COM_COMMUNITY_ACTIVATION_MSG'), $name, $sitename, $activationURL, $siteURL);
}
break;
}
$message = html_entity_decode($message, ENT_QUOTES);
$sendashtml = false;
$copyrightemail = JString::trim($config->get('copyrightemail'));
// Send email to user
if ($type == 'registration_complete' && !$requireApproval && !$needActivation) {
//don't send email for this case
} else {
//check if HTML emails are set to ON
if ($config->get('htmlemail')) {
$sendashtml = true;
$tmpl = new CTemplate();
$message = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message);
//$tmpl->set( 'avatar', $user->getAvatar());
//$tmpl->set( 'thumbAvatar', $user->getThumbAvatar());
//$tmpl->set( 'template', rtrim( JURI::root() , '/' ) . '/components/com_community/templates/' . $config->get('template') );
$tmpl->set('name', $name);
//.........这里部分代码省略.........
示例6: notifications
/**
*
*/
public function notifications()
{
$mainframe = JFactory::getApplication();
if (!$this->accessAllowed('registered')) {
return;
}
$pathway = $mainframe->getPathway();
$my = CFactory::getUser();
$menu = JFactory::getApplication()->getMenu()->getActive();
$pathway->addItem(JText::_($menu->title), CRoute::getExternalURL($menu->link));
$pathway->addItem(JText::_($my->getDisplayName()), CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
$pathway->addItem(JText::_('COM_COMMUNITY_PROFILE_NOTIFICATIONS'), '');
/**
* Opengraph
*/
CHeadHelper::setType('website', JText::_('COM_COMMUNITY_PROFILE_NOTIFICATIONS'));
$user = CFactory::getUser();
$params = $user->getParams();
$config = CFactory::getConfig();
$modelNotification = CFactory::getModel('notification');
$notifications = $modelNotification->getNotification($my->id, '0', 0);
$app = CAppPlugins::getInstance();
$appFields = $app->triggerEvent('onFormDisplay', array('jsform-profile-notifications'));
$beforeFormDisplay = CFormElement::renderElements($appFields, 'before');
$afterFormDisplay = CFormElement::renderElements($appFields, 'after');
$tmpl = new CTemplate();
echo $tmpl->set('beforeFormDisplay', $beforeFormDisplay)->set('afterFormDisplay', $afterFormDisplay)->set('params', $params)->set('config', $config)->set('submenu', $this->showSubmenu(false))->set('pagination', $modelNotification->getPagination())->set('notifications', $notifications)->fetch('profile.notification');
}
示例7:
</svg>
<span><?php
echo $group->hits;
?>
</span>
</a>
<?php
if ($config->get('enablesharethis') == 1) {
?>
<a class="joms-button--shared" title="<?php
echo JText::_('COM_COMMUNITY_SHARE_THIS');
?>
"
href="javascript:" onclick="joms.api.pageShare('<?php
echo CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
?>
')">
<svg viewBox="0 0 16 16" class="joms-icon">
<use xlink:href="<?php
echo CRoute::getURI();
?>
#joms-icon-redo"></use>
</svg>
</a>
<?php
}
?>
<?php
if ($enableReporting) {
示例8: viewdiscussion
//.........这里部分代码省略.........
// Load necessary library and objects
$groupModel = CFactory::getModel('groups');
$group =& JTable::getInstance('Group', 'CTable');
$discussion =& JTable::getInstance('Discussion', 'CTable');
$group->load($groupId);
$discussion->load($topicId);
$isBanned = $group->isBanned($my->id);
$document->addCustomTag('<link rel="image_src" href="' . $group->getThumbAvatar() . '" />');
// @rule: Test if the group is unpublished, don't display it at all.
if (!$group->published) {
$this->_redirectUnpublishGroup();
return;
}
$feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&topicid=' . $topicId . '&format=feed');
$feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_GROUPS_LATEST_FEED') . '" href="' . $feedLink . '"/>';
$document->addCustomTag($feed);
CFactory::load('helpers', 'owner');
if ($group->approvals == 1 && !$group->isMember($my->id) && !COwnerHelper::isCommunityAdmin()) {
$this->noAccess(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE'));
return;
}
// Execute discussion onDisplay filter
$appsLib =& CAppPlugins::getInstance();
$appsLib->loadApplications();
$args = array();
$args[] =& $discussion;
$appsLib->triggerEvent('onDiscussionDisplay', $args);
// Get the discussion creator info
$creator = CFactory::getUser($discussion->creator);
// Format the date accordingly.
//$discussion->created = CTimeHelper::getDate( $discussion->created );
$dayinterval = ACTIVITY_INTERVAL_DAY;
$timeFormat = $config->get('activitiestimeformat');
$dayFormat = $config->get('activitiesdayformat');
if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) {
$discussion->created = CTimeHelper::getDate($discussion->created)->toFormat(JText::_('DATE_FORMAT_LC2'), true);
} else {
$discussion->created = CTimeHelper::timeLapse(CTimeHelper::getDate($discussion->created));
}
// Set page title
$document->setTitle(JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_TITTLE', $discussion->title));
// Add pathways
$this->_addGroupInPathway($group->id);
$this->addPathway(JText::_('COM_COMMUNITY_GROUPS_DISCUSSION'), CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id));
$this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_TITTLE', $discussion->title));
CFactory::load('helpers', 'owner');
$isGroupAdmin = $groupModel->isAdmin($my->id, $group->id);
if ($my->id == $creator->id || $isGroupAdmin || COwnerHelper::isCommunityAdmin()) {
$title = JText::_('COM_COMMUNITY_DELETE_DISCUSSION');
$titleLock = $discussion->lock ? JText::_('COM_COMMUNITY_UNLOCK_DISCUSSION') : JText::_('COM_COMMUNITY_LOCK_DISCUSSION');
$actionLock = $discussion->lock ? JText::_('COM_COMMUNITY_UNLOCK') : JText::_('COM_COMMUNITY_LOCK');
$this->addSubmenuItem('', $actionLock, "joms.groups.lockTopic('" . $titleLock . "','" . $group->id . "','" . $discussion->id . "');", SUBMENU_RIGHT);
$this->addSubmenuItem('', JText::_('COM_COMMUNITY_DELETE'), "joms.groups.removeTopic('" . $title . "','" . $group->id . "','" . $discussion->id . "');", SUBMENU_RIGHT);
$this->addSubmenuItem('index.php?option=com_community&view=groups&task=editdiscussion&groupid=' . $group->id . '&topicid=' . $discussion->id, JText::_('COM_COMMUNITY_EDIT'), '', SUBMENU_RIGHT);
}
$this->showSubmenu();
CFactory::load('libraries', 'wall');
$wallContent = CWallLibrary::getWallContents('discussions', $discussion->id, $isGroupAdmin, $jconfig->get('list_limit'), 0, 'wall.content', 'groups,discussion');
$wallCount = CWallLibrary::getWallCount('discussions', $discussion->id);
$viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=discussapp&topicid=' . $discussion->id . '&app=walls');
$wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
// Test if the current browser is a member of the group
$isMember = $group->isMember($my->id);
$waitingApproval = false;
// If I have tried to join this group, but not yet approved, display a notice
if ($groupModel->isWaitingAuthorization($my->id, $group->id)) {
$waitingApproval = true;
}
$wallForm = '';
$config = CFactory::getConfig();
// Only get the wall form if user is really allowed to see it.
if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && $isMember && !$isBanned && !$waitingApproval || COwnerHelper::isCommunityAdmin()) {
$outputLock = '<div class="warning">' . JText::_('COM_COMMUNITY_DISCUSSION_LOCKED_NOTICE') . '</div>';
$outputUnLock = CWallLibrary::getWallInputForm($discussion->id, 'groups,ajaxSaveDiscussionWall', 'groups,ajaxRemoveReply');
$wallForm = '<div class="wall-tittle">' . JText::_('COM_COMMUNITY_REPLIES') . '</div>';
$wallForm .= $discussion->lock ? $outputLock : $outputUnLock;
}
if (empty($wallForm)) {
//user must join in order to see this page
$tmpl = new CTemplate();
$wallForm = $tmpl->set('groupid', $groupId)->fetch('groups.joingroup');
$outputLock = '<div class="warning">' . JText::_('COM_COMMUNITY_DISCUSSION_LOCKED_NOTICE') . '</div>';
$outputUnLock = CWallLibrary::getWallInputForm($discussion->id, 'groups,ajaxSaveDiscussionWall', 'groups,ajaxRemoveReply');
$wallForm2 = '<div class="wall-tittle">' . JText::_('COM_COMMUNITY_REPLIES') . '</div>';
$wallForm2 .= $discussion->lock ? $outputLock : $outputUnLock;
$wallForm = $wallForm . '<div style="display:none" class="reply-form">' . $wallForm2 . '</div>';
}
$config = CFactory::getConfig();
// Get creator link
$creatorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $creator->id);
// Get reporting html
CFactory::load('libraries', 'reporting');
$report = new CReportingLibrary();
$reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_GROUPS_DISCUSSION_REPORT'), 'groups,reportDiscussion', array($discussion->id));
CFactory::load('libraries', 'bookmarks');
$bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $group->id . '&topicid=' . $discussion->id));
$bookmarksHTML = $bookmarks->getHTML();
$tmpl = new CTemplate();
echo $tmpl->set('bookmarksHTML', $bookmarksHTML)->set('discussion', $discussion)->set('creator', $creator)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('creatorLink', $creatorLink)->set('reportHTML', $reportHTML)->set('groupid', $groupId)->fetch('groups.viewdiscussion');
}
示例9: getPermalink
public function getPermalink()
{
$url = 'index.php?option=com_community&view=videos&task=video';
if ($this->creator_type == VIDEO_GROUP_TYPE) {
$url .= '&groupid=' . $this->groupid;
} else {
// defaul as user type, VIDEO_USER_TYPE
$url .= '&userid=' . $this->creator;
}
$url .= '&videoid=' . $this->id;
return CRoute::getExternalURL($url, false);
}
示例10: profile
//.........这里部分代码省略.........
// Split the apps into different list for different positon
$appsInPositions = array();
foreach ($appData as &$app) {
$appsInPositions[$app->position][] = $app;
}
$tmpl = new CTemplate();
$contenHTML = array();
$contenHTML['content'] = '';
$contenHTML['sidebar-top'] = '';
$contenHTML['sidebar-bottom'] = '';
$jscript = '';
foreach ($appsInPositions as $position => $appData) {
ob_start();
foreach ($appData as $app) {
// If the apps content is empty, we ignore this app from showing
// the header in profile page.
if (JString::trim($app->data) == "") {
continue;
}
$tmpl->set('app', $app);
$tmpl->set('isOwner', COwnerHelper::isMine($my->id, $user->id));
switch ($position) {
case 'sidebar-top':
case 'sidebar-bottom':
echo $tmpl->fetch('application.widget');
break;
default:
echo $tmpl->fetch('application.box');
}
}
$contenHTML[$position] = ob_get_contents();
ob_end_clean();
}
// Get the config
$config = CFactory::getConfig();
// get total group
$groupsModel = CFactory::getModel('groups');
$totalgroups = $groupsModel->getGroupsCount($user->id);
// get total friend
$friendsModel = CFactory::getModel('friends');
$totalfriends = $user->getFriendCount();
// get total photos
$photosModel = CFactory::getModel('photos');
$totalphotos = $photosModel->getPhotosCount($user->id);
// get total activities
$activitiesModel = CFactory::getModel('activities');
$totalactivities = $activitiesModel->getActivityCount($user->id);
$isMine = COwnerHelper::isMine($my->id, $user->id);
$isCommunityAdmin = COwnerHelper::isCommunityAdmin($user->id);
// Get reporting html
CFactory::load('libraries', 'reporting');
$report = new CReportingLibrary();
$reportHTML = $isMine ? '' : $report->getReportingHTML(JText::_('CC REPORT BAD USER'), 'profile,reportProfile', array($user->id));
// Check if user is blocked
$blockUserModel = CFactory::getModel('block');
$isBlocked = $blockUserModel->getBlockStatus($user->id, $my->id);
// Get block user html
CFactory::load('helpers', 'user');
$blockUserHTML = $isMine || $isCommunityAdmin ? '' : CUserHelper::getBlockUserHTML($user->id, $isBlocked);
CFactory::load('libraries', 'bookmarks');
$bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=profile&userid=' . $user->id));
$bookmarksHTML = $bookmarks->getHTML();
// Get like
// cater for buble, blueface template
$likesHTML = '';
if ($user->getParams()->get('profileLikes', true)) {
CFactory::load('libraries', 'like');
$likes = new CLike();
$likesHTML = $my->id == 0 ? $likes->getHtmlPublic('profile', $user->id) : $likes->getHTML('profile', $user->id, $my->id);
}
$tmpl = new CTemplate();
$tmpl->set('blockUserHTML', $blockUserHTML);
$tmpl->set('bookmarksHTML', $bookmarksHTML);
$tmpl->set('profileOwnerName', $user->getDisplayName());
$tmpl->set('totalgroups', $totalgroups);
$tmpl->set('totalfriends', $totalfriends);
$tmpl->set('totalphotos', $totalphotos);
$tmpl->set('totalactivities', $totalactivities);
$tmpl->set('reportsHTML', $reportHTML);
$tmpl->set('mainframe', $mainframe);
$tmpl->set('config', $config);
$tmpl->set('about', $this->_getProfileHTML($data->profile));
$tmpl->set('friends', $this->_getFriendsHTML());
$tmpl->set('groups', $this->_getGroupsHTML());
$tmpl->set('newsfeed', $this->_getNewsfeedHTML());
$tmpl->set('header', $headerHTML);
$tmpl->set('adminControlHTML', $this->_getAdminControlHTML($user->id));
$tmpl->set('content', $contenHTML['content']);
$tmpl->set('sidebarTop', $contenHTML['sidebar-top']);
$tmpl->set('sidebarBottom', $contenHTML['sidebar-bottom']);
$tmpl->set('isMine', $isMine);
$tmpl->set('jscript', '');
// maintain for 1.8.0 template compatibility
$tmpl->setRef('user', $user);
$tmpl->set('my', $my);
$tmpl->set('videoid', $data->videoid);
$tmpl->set('likesHTML', $likesHTML);
$html = $tmpl->fetch('profile.index');
echo $html;
}
示例11: emailLink
/**
* Method to wrap around getting the correct links within the email
* DEPRECATED since 1.5
*/
static function emailLink($url, $xhtml = false)
{
return CRoute::getExternalURL($url, $xhtml);
}
示例12: getPhotoLink
public function getPhotoLink($external = false, $xhtml = true)
{
$album =& JTable::getInstance('Album', 'CTable');
$album->load($this->albumid);
$url = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id;
$url .= $album->groupid ? '&groupid=' . $album->groupid : '&userid=' . $album->creator;
if ($external) {
return CRoute::getExternalURL($url) . '#photoid=' . $this->id;
}
return CRoute::_($url, $xhtml) . '#photoid=' . $this->id;
}
示例13: activate
/**
* @param $token
* @return int activation_type where 1 = activate by admin, 0 = self activation
*/
public function activate($token)
{
$config = CFactory::getConfig();
$db = $this->getDbo();
$activation_type = 0;
// Find the user with the token supplied
$query = $db->getQuery(true);
$query->select($db->quoteName('id'))->from($db->quoteName('#__users'))->where($db->quoteName('activation') . ' = ' . $db->quote($token))->where($db->quoteName('block') . ' = ' . 1);
$db->setQuery($query);
try {
$userId = (int) $db->loadResult();
} catch (RuntimeException $e) {
return false;
}
// Check for a valid user id.
if (!$userId) {
$this->setError(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
return false;
}
// Load the users plugin group.
JPluginHelper::importPlugin('user');
// Activate the user.
$user = CFactory::getUser($userId);
$user->set('activation', '');
$user->set('block', '0');
$com_user_config = JComponentHelper::getParams('com_users');
$com_user_activation_type = $com_user_config->get('useractivation');
if ($user->_profile_id > 0) {
$multiprofile = JTable::getInstance('MultiProfile', 'CTable');
$multiprofile->load($user->_profile_id);
//lets send an email to the user notifying their account has been activated
if ($multiprofile->approvals == 1 || $com_user_activation_type == 2) {
// Compile the user activated notification mail values.
$activation_type = 1;
// set this to admin activation type
$data = $user->getProperties();
$user->setParam('activate', 0);
$data['fromname'] = $config->get('fromname');
$data['mailfrom'] = $config->get('mailfrom');
$data['sitename'] = $config->get('sitename');
$data['siteurl'] = JUri::base();
$emailSubject = JText::sprintf('COM_COMMUNITY_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_SUBJECT', $data['name'], $data['sitename']);
$emailBody = JText::sprintf('COM_COMMUNITY_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_BODY', $data['name'], $data['siteurl'], $data['username']);
$message = html_entity_decode($emailBody, ENT_QUOTES);
$sendashtml = false;
$copyrightemail = JString::trim($config->get('copyrightemail'));
//check if HTML emails are set to ON
if ($config->get('htmlemail')) {
$sendashtml = true;
$tmpl = new CTemplate();
$message = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message);
$tmpl->set('name', $data['username']);
$tmpl->set('email', $data['email']);
$message = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=preferences#email'), false)->set('content', $message)->set('copyrightemail', $copyrightemail)->set('sitename', $config->get('sitename'))->fetch('email.html');
}
$return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $message, $sendashtml);
// Check for an error.
if ($return !== true) {
$this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
return false;
}
}
} else {
if ($com_user_activation_type == 2 && $user->_profile_id == 0) {
// Compile the user activated notification mail values.
$activation_type = 1;
// set this to admin activation type
$data = $user->getProperties();
$user->setParam('activate', 0);
$data['fromname'] = $config->get('fromname');
$data['mailfrom'] = $config->get('mailfrom');
$data['sitename'] = $config->get('sitename');
$data['siteurl'] = JUri::base();
$emailSubject = JText::sprintf('COM_COMMUNITY_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_SUBJECT', $data['name'], $data['sitename']);
$emailBody = JText::sprintf('COM_COMMUNITY_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_BODY', $data['name'], $data['siteurl'], $data['username']);
$message = html_entity_decode($emailBody, ENT_QUOTES);
$sendashtml = false;
$copyrightemail = JString::trim($config->get('copyrightemail'));
//check if HTML emails are set to ON
if ($config->get('htmlemail')) {
$sendashtml = true;
$tmpl = new CTemplate();
$message = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message);
$tmpl->set('name', $data['username']);
$tmpl->set('email', $data['email']);
$message = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=email'), false)->set('content', $message)->set('copyrightemail', $copyrightemail)->set('sitename', $config->get('sitename'))->fetch('email.html');
}
$return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $message, $sendashtml);
// Check for an error.
if ($return !== true) {
$this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
return false;
}
}
}
// Store the user object.
//.........这里部分代码省略.........
示例14: updateProfile
/**
* Updates user profile
**/
public function updateProfile()
{
$document = JFactory::getDocument();
$viewType = $document->getType();
$viewName = JRequest::getCmd('view', $this->getName());
$view = $this->getView($viewName, '', $viewType);
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
if (!$this->_isEnabled()) {
echo JText::_('COM_COMMUNITY_MULTIPROFILE_IS_CURRENTLY_DISABLED');
return;
}
$appsLib = CAppPlugins::getInstance();
$appsLib->loadApplications();
$mainframe = JFactory::getApplication();
$profileType = JRequest::getInt('profileType', 0);
$model = $this->getModel('Profile');
$my = CFactory::getUser();
$data = $model->getEditableProfile($my->id, $profileType);
$oldProfileType = $my->getProfileType();
// If there is nothing to edit, we should just redirect
if (empty($data['fields'])) {
$multiprofile = JTable::getInstance('MultiProfile', 'CTable');
$multiprofile->load($profileType);
$my->_profile_id = $multiprofile->id;
// Trigger before onProfileTypeUpdate
$args = array();
$args[] = $my->id;
$args[] = $oldProfileType;
$args[] = $multiprofile->id;
$result = $appsLib->triggerEvent('onProfileTypeUpdate', $args);
//CFactory::load( 'helpers' , 'owner' );
// @rule: If profile requires approval, logout user and update block status. This is not
// applicable to site administrators.
if ($multiprofile->approvals && !COwnerHelper::isCommunityAdmin($my->id)) {
$my->set('block', 1);
//CFactory::load( 'helpers' , 'owner' );
$subject = JText::sprintf('COM_COMMUNITY_USER_NEEDS_APPROVAL_SUBJECT', $my->name);
$message = JText::sprintf('COM_COMMUNITY_USER_PROFILE_CHANGED_NEEDS_APPROVAL', $my->name, $my->email, $my->username, $multiprofile->name, CRoute::getExternalURL('index.php?option=com_community&view=profile&userid=' . $my->id));
COwnerHelper::emailCommunityAdmins($subject, $message);
// @rule: Logout user.
$mainframe->logout();
}
$my->save();
$mainframe->redirect(CRoute::_('index.php?option=com_community&view=multiprofile&task=profileupdated&profileType=' . $multiprofile->id, false));
}
if ($jinput->getMethod() == 'POST') {
$model = $this->getModel('Profile');
$values = array();
$profileType = JRequest::getInt('profileType', 0, 'POST');
//CFactory::load( 'libraries' , 'profile' );
$profiles = $model->getAllFields(array('published' => '1'), $profileType);
$errors = array();
// Delete all user's existing profile values and re-add the new ones
// @rule: Bind the user data
foreach ($profiles as $key => $groups) {
foreach ($groups->fields as $data) {
// Get value from posted data and map it to the field.
// Here we need to prepend the 'field' before the id because in the form, the 'field' is prepended to the id.
$postData = JRequest::getVar('field' . $data->id, '', 'POST');
$values[$data->id] = CProfileLibrary::formatData($data->type, $postData);
if (get_magic_quotes_gpc()) {
$values[$data->id] = stripslashes($values[$data->id]);
}
// @rule: Validate custom profile if necessary
if (!CProfileLibrary::validateField($data->id, $data->type, $values[$data->id], $data->required)) {
// If there are errors on the form, display to the user.
$message = JText::sprintf('COM_COMMUNITY_FIELD_CONTAIN_IMPROPER_VALUES', $data->name);
$mainframe->enqueueMessage($message, 'error');
$errors[] = true;
}
}
}
// Rebuild new $values with field code
$valuesCode = array();
foreach ($values as $key => $val) {
$fieldCode = $model->getFieldCode($key);
if ($fieldCode) {
// For backward compatibility, we can't pass in an object. We need it to behave
// like 1.8.x where we only pass values.
$valuesCode[$fieldCode] = $val;
}
}
$args = array();
$args[] = $my->id;
$args[] = $valuesCode;
$saveSuccess = false;
$result = $appsLib->triggerEvent('onBeforeProfileUpdate', $args);
// make sure none of the $result is false
if (!$result || !in_array(false, $result)) {
$saveSuccess = true;
$model->saveProfile($my->id, $values);
}
$mainframe = JFactory::getApplication();
if (!$saveSuccess) {
$mainframe->redirect(CRoute::_('index.php?option=com_community&view=multiprofile&task=updateProfile&profileType=' . $profileType, false), JText::_('COM_COMMUNITY_PROFILE_NOT_SAVED'), 'error');
}
//.........这里部分代码省略.........
示例15: joinGroup
/**
* Method is used to receive POST requests from specific user
* that wants to join a group
*
* @return void
**/
public function joinGroup()
{
$mainframe =& JFactory::getApplication();
$groupId = JRequest::getVar('groupid', '', 'POST');
// Add assertion to the group id since it must be specified in the post request
CError::assert($groupId, '', '!empty', __FILE__, __LINE__);
// Get the current user's object
$my = CFactory::getUser();
if ($my->id == 0) {
return $this->blockUnregister();
}
// Load necessary tables
$groupModel = CFactory::getModel('groups');
if ($groupModel->isMember($my->id, $groupId)) {
$url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId, false);
$mainframe->redirect($url, JText::_('CC ALREADY MEMBER OF GROUP'));
} else {
$url = CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId, false);
$member = $this->_saveMember($groupId);
if ($member->approved) {
$mainframe->redirect($url, JText::_('CC SUCCESS JOIN GROUP'));
}
$mainframe->redirect($url, JText::_('CC USER JOIN GROUP NEED APPROVAL'));
}
}