function getJoomlaAvatar($registerType, $profileLink, $user) { $html = ''; if ($registerType == 'jomsocial' && file_exists(JPATH_BASE . '/components/com_community/libraries/core.php')) { $jsUser = CFactory::getUser($user->id); $avatarURL = $jsUser->getThumbAvatar(); $html = $this->getAvatarHtml($avatarURL, $profileLink, "_self"); } else { if ($registerType == 'easysocial' && file_exists(JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php')) { $avatarURL = Foundry::user($user->id)->getAvatar(); $html = $this->getAvatarHtml($avatarURL, $profileLink, "_self"); } else { if ($registerType == "communitybuilder" && file_exists(JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php')) { include_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php'; $cbUser = CBuser::getInstance($user->id); $avatar = $cbUser->getField('avatar', null, 'csv', 'none', 'list'); $html = $this->getAvatarHtml($avatar, $profileLink, "_self"); } else { if ($registerType == 'kunena' && JFolder::exists(JPATH_SITE . '/components/com_kunena')) { $db = JFactory::getDbo(); $query = "SELECT avatar FROM #__kunena_users WHERE userid = " . $user->id; $db->setQuery($query); $avatarURL = $db->loadResult(); if ($avatarURL) { $avatarURL = JRoute::_('media/kunena/avatars/' . $avatarURL, false); } $html = $this->getAvatarHtml($avatarURL, $profileLink, "_self"); } } } } return $html; }
/** * @param string $context * @param object $article */ public function onContentBeforeDisplay( $context, &$article ) { if ( isset( $article->created_by ) || isset( $article->modified_by ) ) { static $CB_loaded = 0; if ( ! $CB_loaded++ ) { if ( ( ! file_exists( JPATH_SITE . '/libraries/CBLib/CBLib/Core/CBLib.php' ) ) || ( ! file_exists( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' ) ) ) { echo 'CB not installed'; return; } include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' ); } if ( ( isset( $article->created_by ) ) && $article->created_by ) { $cbUserCreate = CBuser::getInstance( (int) $article->created_by, false ); if ( isset( $article->author ) ) { $article->author = $cbUserCreate->getField( 'formatname', null, 'html', 'none', 'list', 0, true ); } $article->created_by_alias = $cbUserCreate->getField( 'formatname', null, 'html', 'none', 'list', 0, true ); } if ( ( isset( $article->modified_by ) ) && $article->modified_by ) { $cbUserModify = CBuser::getInstance( (int) $article->modified_by, false ); $article->modified_by_name = $cbUserModify->getField( 'formatname', null, 'html', 'none', 'list', 0, true ); } if ( ( isset( $article->contactid ) ) && $article->contactid ) { $article->contactid = null; } } }
/** * prepare frontend about render * * @param string $return * @param GroupTable $group * @param string $users * @param string $invites * @param array $counters * @param array $buttons * @param array $menu * @param cbTabs $tabs * @param UserTable $user * @return array|null */ public function showAbout( &$return, &$group, &$users, &$invites, &$counters, &$buttons, &$menu, &$tabs, $user ) { global $_CB_framework; if ( CBGroupJive::isModerator( $user->get( 'id' ) ) || ( ( $group->get( 'published' ) == 1 ) && ( CBGroupJive::getGroupStatus( $user, $group ) >= 3 ) ) ) { $menu[] = '<a href="' . $_CB_framework->pluginClassUrl( $this->element, true, array( 'action' => 'about', 'func' => 'edit', 'id' => (int) $group->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'About' ) . '</a>'; } $about = trim( $group->params()->get( 'about_content' ) ); if ( ( ! $about ) || ( $about == '<p></p>' ) ) { return null; } CBGroupJive::getTemplate( 'about', true, true, $this->element ); if ( $this->params->get( 'groups_about_substitutions', 0 ) ) { $about = CBuser::getInstance( (int) $user->get( 'id' ), false )->replaceUserVars( $about, false, false, null, false ); } if ( $this->params->get( 'groups_about_content_plugins', 0 ) ) { $about = Application::Cms()->prepareHtmlContentPlugins( $about ); } return array( 'id' => 'about', 'title' => CBTxt::T( 'About' ), 'content' => HTML_groupjiveAbout::showAbout( $about, $group, $user, $this ) ); }
protected function _getURL($user, $sizex, $sizey) { global $_CB_framework; $app = JFactory::getApplication(); $user = KunenaFactory::getUser($user); if ($app->getClientId() == 0) { $cbclient_id = 1; } if ($app->getClientId() == 1) { $cbclient_id = 2; } $_CB_framework->cbset('_ui', $cbclient_id); // Get CUser object $cbUser = null; if ($user->userid) { $cbUser = CBuser::getInstance($user->userid); } if ($cbUser === null) { if ($sizex <= 90) { return selectTemplate() . 'images/avatar/tnnophoto_n.png'; } return selectTemplate() . 'images/avatar/nophoto_n.png'; } if ($sizex <= 90) { return $cbUser->getField('avatar', null, 'csv'); } return $cbUser->getField('avatar', null, 'csv', 'none', 'list'); }
public function getAvatar($profile) { if (!$this->exists()) { return false; } $user = CBuser::getInstance($profile->id); // @task: Apply guest avatars when necessary. if (!$profile->id) { $avatar = selectTemplate() . 'images/avatar/tnnophoto_n.png'; return $avatar; } if (!$user) { $user = CBuser::getInstance(null); } // Prevent CB from adding anything to the page. ob_start(); $source = $user->getField('avatar', null, 'php'); $reset = ob_get_contents(); ob_end_clean(); unset($reset); $source = $source['avatar']; //incase we view from backend. we need to remove the /administrator/ from the path. $avatar = str_replace('/administrator/', '/', $source); return $avatar; }
function getAvatar($userID, $email = NULL, $width = 50) { jimport('joomla.filesystem.folder'); jimport('joomla.application.component.model'); $mainframe =& JFactory::getApplication(); $params =& K2HelperUtilities::getParams('com_k2'); if (K2_CB && $userID != 'alias') { $cbUser = CBuser::getInstance((int) $userID); if (is_object($cbUser)) { $avatar = $cbUser->getField('avatar', null, 'csv', 'none', 'profile'); return $avatar; } } /* // JomSocial Avatar integration if(JFolder::exists(JPATH_SITE.DS.'components'.DS.'com_community') && $userID>0){ $userInfo = &CFactory::getUser($userID); return $userInfo->getThumbAvatar(); } */ // Check for placeholder overrides if (JFile::exists(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'images' . DS . 'placeholder' . DS . 'user.png')) { $avatarPath = 'templates/' . $mainframe->getTemplate() . '/images/placeholder/user.png'; } else { $avatarPath = 'components/com_k2/images/placeholder/user.png'; } // Continue with default K2 avatar determination if ($userID == 'alias') { $avatar = JURI::root(true) . '/' . $avatarPath; } else { if ($userID == 0) { if ($params->get('gravatar') && !is_null($email)) { $avatar = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $width . '&default=' . urlencode(JURI::root() . $avatarPath); } else { $avatar = JURI::root(true) . '/' . $avatarPath; } } else { if (is_numeric($userID) && $userID > 0) { JModel::addIncludePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models'); $model =& JModel::getInstance('Item', 'K2Model'); $profile = $model->getUserProfile($userID); $avatar = is_null($profile) ? '' : $profile->image; if (empty($avatar)) { if ($params->get('gravatar') && !is_null($email)) { $avatar = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $width . '&default=' . urlencode(JURI::root() . $avatarPath); } else { $avatar = JURI::root(true) . '/' . $avatarPath; } } else { $avatar = JURI::root(true) . '/media/k2/users/' . $avatar; } } } } if (!$params->get('userImageDefault') && $avatar == JURI::root(true) . '/' . $avatarPath) { $avatar = ''; } return $avatar; }
/** * @param TagTable[] $rows * @param Tags $stream * @param int $output 0: Normal, 1: Raw, 2: Inline, 3: Load , 4: Save * @param UserTable $user * @param UserTable $viewer * @param cbPluginHandler $plugin * @return null|string */ static public function showTags( $rows, $stream, $output, $user, $viewer, $plugin ) { global $_PLUGINS; CBActivity::loadHeaders( $output ); $sourceClean = htmlspecialchars( $stream->source() ); $tags = array(); $return = null; $_PLUGINS->trigger( 'activity_onBeforeDisplayTags', array( &$return, &$rows, $stream, $output ) ); if ( $rows ) foreach ( $rows as $row ) { $rowId = $sourceClean . 'Tag' . (int) $row->get( 'id' ); if ( is_numeric( $row->get( 'user' ) ) ) { $name = CBuser::getInstance( (int) $row->get( 'user' ), false )->getField( 'formatname', null, 'html', 'none', 'list', 0, true ); } else { $name = htmlspecialchars( $row->get( 'user' ) ); } if ( ! $name ) { continue; } $tags[] = '<span id="' . $rowId . '" class="streamTag">' . $name . '</span>'; } if ( $tags ) { $return .= ( ! in_array( $output, array( 1, 4 ) ) ? '<span class="' . $sourceClean . 'Tags streamTags">' : null ); if ( count( $tags ) > 2 ) { $tagOne = array_shift( $tags ); $tagTwo = array_shift( $tags ); $moreTooltip = cbTooltip( null, '<div class="streamTagRow">' . implode( '</div><div class="streamTagRow">', $tags ) . '</div>', null, 'auto', null, null, null, 'data-hascbtooltip="true" data-cbtooltip-position-my="bottom center" data-cbtooltip-position-at="top center" data-cbtooltip-open-event="click" data-cbtooltip-close-event="click unfocus" data-cbtooltip-button-hide="true"' ); $more = '<a href="javascript: void(0);"' . $moreTooltip . '>' . CBTxt::T( 'TAGS_MORE', '%%COUNT%% more', array( '%%COUNT%%' => count( $tags ) ) ) . '</a>'; $return .= CBTxt::T( 'TAGS_MORE_THAN_TWO', '[tag_1], [tag_2], and [more]', array( '[tag_1]' => $tagOne, '[tag_2]' => $tagTwo, '[more]' => $more ) ); } elseif ( count( $tags ) > 1 ) { $return .= CBTxt::T( 'TAGS_TWO', '[tag_1] and [tag_2]', array( '[tag_1]' => $tags[0], '[tag_2]' => $tags[1] ) ); } else { $return .= $tags[0]; } $return .= ( ! in_array( $output, array( 1, 4 ) ) ? '</span>' : null ); } $return .= CBActivity::reloadHeaders( $output ); $_PLUGINS->trigger( 'activity_onAfterDisplayTags', array( &$return, $rows, $stream, $output ) ); return $return; }
public function getProfileURL($user, $task='', $xhtml = true) { $user = KunenaFactory::getUser($user); if ($user->userid == 0) return false; // Get CUser object $cbUser = CBuser::getInstance( $user->userid ); if($cbUser === null) return false; return cbSef( 'index.php?option=com_comprofiler&task=userProfile&user=' . $user->userid. getCBprofileItemid(), $xhtml ); }
/** * @param OrderedTable $row * @param UserTable $user * @param stdClass $model * @param PluginTable $plugin */ static function showBlog($row, $user, $model, $plugin) { global $_CB_framework; $_CB_framework->setPageTitle($row->get('title')); $_CB_framework->appendPathWay(htmlspecialchars(CBTxt::T('Blogs')), $_CB_framework->userProfileUrl($row->get('user', $user->get('id')), true, 'cbblogsTab')); $_CB_framework->appendPathWay(htmlspecialchars($row->get('title')), $_CB_framework->pluginClassUrl($plugin->element, true, array('action' => 'blogs', 'func' => 'show', 'id' => (int) $row->get('id')))); $cbUser =& CBuser::getInstance((int) $row->get('user'), false); $return = '<div class="blowShow">' . '<div class="blogsTitle page-header"><h3>' . $row->get('title') . ' <small>' . CBTxt::T('WRITTEN_BY_BLOG_AUTHOR', 'Written by [blog_author]', array('[blog_author]' => $cbUser->getField('formatname', null, 'html', 'none', 'list', 0, true))) . '</small></h3></div>' . '<div class="blogsHeader well well-sm">' . CBTxt::T('CATEGORY_CATEGORY', 'Category: [category]', array('[category]' => $row->get('category'))) . ' / ' . CBTxt::T('CREATED_CREATED', 'Created: [created]', array('[created]' => cbFormatDate($row->get('created')))) . ($row->get('modified') && $row->get('modified') != '0000-00-00 00:00:00' ? ' / ' . CBTxt::T('MODIFIED_MODIFIED', 'Modified: [modified]', array('[modified]' => cbFormatDate($row->get('modified')))) : null) . '</div>' . '<div class="blogsText">' . $row->get('blog_intro') . $row->get('blog_full') . '</div>' . '</div>'; echo $return; }
/** * @param OrderedTable $row * @param UserTable $user * @param stdClass $model * @param PluginTable $plugin */ static function showconsultation( $row, $user, /** @noinspection PhpUnusedParameterInspection */ $model, $plugin, $bids ) { global $_CB_framework; $_CB_framework->setPageTitle( $row->get( 'title' ) ); $_CB_framework->appendPathWay( htmlspecialchars( CBTxt::T( 'consultations' ) ), $_CB_framework->userProfileUrl( $row->get( 'user', $user->get( 'id' ) ), true, 'cbconsultationsTab' ) ); $_CB_framework->appendPathWay( htmlspecialchars( $row->get( 'title' ) ), $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'consultations', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) ) ); $cbUser =& CBuser::getInstance( (int) $row->get( 'user' ), false ); $return = '<div class="blowShow">' . '<div class="consultationsTitle page-header"><h3>' . $row->get( 'title' ) . ' <small>' . CBTxt::T( 'WRITTEN_BY_consultation_AUTHOR', 'Written by [consultation_author]', array( '[consultation_author]' => $cbUser->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) ) ) . '</small></h3></div>' . '<div class="consultationsHeader well well-sm">' . CBTxt::T( 'CATEGORY_CATEGORY', 'Category: [category]', array( '[category]' => $row->get( 'category' ) ) ) . ' / ' . CBTxt::T( 'CREATED_CREATED', 'Created: [created]', array( '[created]' => cbFormatDate( $row->get( 'created' ) ) ) ) . ( $row->get( 'modified' ) && ( $row->get( 'modified' ) != '0000-00-00 00:00:00' ) ? ' / ' . CBTxt::T( 'MODIFIED_MODIFIED', 'Modified: [modified]', array( '[modified]' => cbFormatDate( $row->get( 'modified' ) ) ) ) : null ) . '</div>' . '<div class="consultationsText">' . $row->get( 'consultation_intro' ) . $row->get( 'consultation_full' ) . '</div>' . '</div>'; if($bids!=null){ $return .= '<script > window.___gcfg = { lang: \'ru\', parsetags: \'onload\' }; </script> <script src="https://apis.google.com/js/platform.js" async defer></script> '; $return .= '<h2>Ставки</h2>'; if(empty($bids)){ $return .= "Нет ставок"; }else{ $return .= '<table cellspacing="5" class="consultationsContainer table table-hover table-responsive">'; $return .= '<tr><th>Дата</th><th>Пользователь</th><th>e-mail</th><th>Цена</th><th></th></tr>'; foreach($bids as $key=>$value){ $return .='<tr>'; $return .= '<td>'.$value->bid_date.'</td>'; $return .= '<td>'.$value->name.'</td>'; $return .= '<td>'.$value->email.'</td>'; $return .= '<td>$'.$value->bid_price.'</td>'; $return .= '<td>'; if($key==0){ //Old version was using Goolge Hangouts for communications. //$return .= '<g:hangout render="createhangout" hangout_type="normal" topic="'.addslashes($row->get('title')).'" // invites="[{ id : \''.$value->email.'\', invite_type : \'EMAIL\' }]"> // </g:hangout>'; //New version is using CloudInterpreter $return .= '<a target="_blank" href="http://dev.cloudinterpreter.com:8901/'.md5($row->get('id')).'"><button class="btn btn-success">Начать консультацию</button></a>'; } $return .= '</td>'; $return .='</tr>'; } $return .= '</table>'; } } echo $return; }
/** * Replaces CB variables and general variables left. * * @param string $numberFormat Format for the replacements * @param int $user_id User id for user-variables replacements * @param array $extraStrings Set of extra-strings for additional replacements * @return string|null */ protected static function replaceCbVars($numberFormat, $user_id, $extraStrings) { global $_CB_framework; if ($numberFormat) { list($year, $month, $day) = self::_getYearMonthDay(); $uniqid = uniqid(''); $extraExtraStrings = array('YEAR' => $year, 'YEARSHORT' => substr($year, 2), 'MONTH' => $month, 'DAY' => $day, 'SITENAME' => $_CB_framework->getCfg('sitename'), 'SITEURL' => $_CB_framework->getCfg('live_site'), 'UNIQ_ID' => hexdec(substr($uniqid, 7)) . hexdec(substr($uniqid, 0, 7)), 'GROWING_ID' => $uniqid); return trim(CBuser::getInstance($user_id)->replaceUserVars($numberFormat, false, false, array_merge($extraExtraStrings, $extraStrings), false)); } else { return null; } }
/** * @param cbantispamWhitelistTable $row * @param array $input * @param string $type * @param int|string $tab * @param UserTable $user * @param cbPluginHandler $plugin */ static public function showWhitelist( $row, $input, $type, $tab, $user, $plugin ) { global $_CB_framework; cbValidator::loadValidation(); $name = CBuser::getInstance( (int) $user->get( 'id' ), false )->getField( 'formatname', null, 'html', 'none', 'profile', 0, true ); $pageTitle = CBTxt::T( 'WHITELIST_NAME', 'Whitelist [name]', array( '[name]' => $name ) ); $_CB_framework->setPageTitle( $pageTitle ); $_CB_framework->appendPathWay( htmlspecialchars( CBTxt::T( 'Whitelists' ) ), $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, $tab ) ); $_CB_framework->appendPathWay( htmlspecialchars( $pageTitle ), $_CB_framework->pluginClassUrl( $plugin->element, true, ( $row->get( 'id' ) ? array( 'action' => 'whitelist', 'func' => ( $type ? $type : 'edit' ), 'id' => (int) $row->get( 'id' ), 'usr' => (int) $user->get( 'id' ) ) : array( 'action' => 'whitelist', 'func' => ( $type ? $type : 'new' ), 'usr' => (int) $user->get( 'id' ) ) ) ) ); $return = '<div class="whitelistEdit">' . '<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'whitelist', 'func' => 'save', 'id' => (int) $row->get( 'id' ), 'usr' => (int) $user->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="whitelistForm" id="whitelistForm" class="cb_form whitelistForm form-auto cbValidation">' . ( $pageTitle ? '<div class="whitelistTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null ) . '<div class="cbft_select cbtt_select form-group cb_form_line clearfix">' . '<label for="type" class="col-sm-3 control-label">' . CBTxt::T( 'Type' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['type'] . getFieldIcons( 1, 1, null, CBTxt::T( 'Select the whitelist type. Type determines what value should be supplied.' ) ) . '</div>' . '</div>' . '<div class="cbft_text cbtt_input form-group cb_form_line clearfix">' . '<label for="value" class="col-sm-3 control-label">' . CBTxt::T( 'Value' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['value'] . getFieldIcons( 1, 1, null, CBTxt::T( 'Input whitelist value in relation to the type. User type use the users user_id (e.g. 42). IP Address type use a full valid IP Address (e.g. 192.168.0.1). Email type use a fill valid email address (e.g. invalid@cb.invalid). Email Domain type use a full email address domain after @ (e.g. example.com).' ) ) . '</div>' . '</div>' . '<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">' . '<label for="reason" class="col-sm-3 control-label">' . CBTxt::T( 'Reason' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['reason'] . getFieldIcons( 1, 0, null, CBTxt::T( 'Optionally input whitelist reason. Note this is for administrative purposes only.' ) ) . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<div class="col-sm-offset-3 col-sm-9">' . '<input type="submit" value="' . htmlspecialchars( ( $row->get( 'id' ) ? CBTxt::T( 'Update Whitelist' ) : CBTxt::T( 'Create Whitelist' ) ) ) . '" class="whitelistButton whitelistButtonSubmit btn btn-primary"' . cbValidator::getSubmitBtnHtmlAttributes() . ' /> ' . ' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="whitelistButton whitelistButtonCancel btn btn-default" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), false, $tab ) . '\'; }" />' . '</div>' . '</div>' . cbGetSpoofInputTag( 'plugin' ) . '</form>' . '</div>'; echo $return; }
/** * Builds and sends e-mail * * @param UserTable $user * @param string $mailFrom_email * @param string $mailFrom_name * @param string $mailTo * @param string $mailSubject * @param string $mailBody * @param string $mailHtml * @param string $mailCC * @param string $mailBCC * @param string $mailAttachments * @param string[] $extraStrings * @return void */ protected function sendMail( $user, $mailFrom_email, $mailFrom_name, $mailTo, $mailSubject, $mailBody, $mailHtml, $mailCC, $mailBCC, $mailAttachments, $extraStrings ) { global $_CB_framework; cbimport( 'cb.tabs' ); $cbUser = CBuser::getInstance( $user->id ); if ( ! $cbUser ) { return; } $mailFrom_email = trim( $cbUser->replaceUserVars( $mailFrom_email, false, false, array(), false ) ); $mailFrom_name = trim( $cbUser->replaceUserVars( $mailFrom_name, false, false, array(), false ) ); $mailTo = trim( $cbUser->replaceUserVars( $mailTo, false, false, array(), false ) ); $mailCC = trim( $cbUser->replaceUserVars( $mailCC, false, false, array(), false ) ); $mailBCC = trim( $cbUser->replaceUserVars( $mailBCC, false, false, array(), false ) ); $mailSubject = trim( $cbUser->replaceUserVars( CBPTXT::T( $mailSubject ), false, false, $extraStrings, false ) ); $mailBody = trim( $cbUser->replaceUserVars( CBPTXT::T( $mailBody ), false, false, $extraStrings, false ) ); $mailAttachments = trim( $mailAttachments ); if ( $mailTo != '' ) { $mailTo = preg_split( '/ *, */', $mailTo ); } else { return; } if ( $mailCC != '' ) { $mailCC = preg_split( '/ *, */', $mailCC ); } else { $mailCC = null; } if ( $mailBCC != '' ) { $mailBCC = preg_split( '/ *, */', $mailBCC ); } else { $mailBCC = null; } if ( $mailAttachments != '' ) { $mailAttachments = preg_split( '/ *, */', $mailAttachments ); } else { $mailAttachments = null; } if ( $mailTo && ( $mailSubject || $mailBody ) ) { comprofilerMail( $mailFrom_email, $mailFrom_name, $mailTo, $_CB_framework->getCfg( 'sitename' ).' - '.$mailSubject, $mailBody, $mailHtml, $mailCC, $mailBCC, $mailAttachments ); } }
protected function getCBUserid() { global $_CB_framework; $cbpath = JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php'; if (file_exists($cbpath)) { require_once $cbpath; } else { return null; } $userid = $_CB_framework->myId(); $cbUser = CBuser::getInstance((int) $userid); if ($cbUser === null) { return null; } return $userid; }
function editUser( $uid = '0', $option = 'users' ) { global $_CB_framework, $_PLUGINS; $this->_importNeeded(); $msg = checkCBpermissions( array($uid), "edit", true ); if ($msg) { echo "<script type=\"text/javascript\"> alert('".$msg."'); window.history.go(-1);</script>\n"; exit; } $_PLUGINS->loadPluginGroup('user'); $cbUser =& CBuser::getInstance( $uid ); $cmsUserExists = ( $uid != 0 ) && ( $cbUser !== null ); if ( ! $cmsUserExists ) { $cbUser =& CBuser::getInstance( null ); } $user =& $cbUser->getUserData(); /* $user = new moscomprofilerUser( $_CB_database ); $cmsUserExists = $user->load( (int) $uid ); */ $comprofilerExists = ( $user->user_id != null ); if ( $cmsUserExists && $comprofilerExists ) { // Edit existing CB user: $newCBuser = '******'; } else { $newCBuser = '******'; if ( $cmsUserExists ) { // Edit existing CMS (but new CB) user: $user->approved = '1'; $user->confirmed = '1'; } else { // New user: $user->block = '0'; $user->approved = '1'; $user->confirmed = '1'; $user->sendEmail = '0'; $user->gid = $_CB_framework->acl->get_group_id( $_CB_framework->getCfg( 'new_usertype' ), 'ARO' ); $user->gids = array( $user->gid ); } } $null = null; $usersView = _CBloadView( 'user' ); $usersView->edituser( $user, $option, $newCBuser, $null ); }
public function getInboxLink ($text) { if (!$text) $text = JText::_('COM_KUNENA_PMS_INBOX'); global $_CB_framework; $cbpath = JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php'; if (file_exists($cbpath)) require_once($cbpath); else return; $userid = $_CB_framework->myId(); $cbUser =& CBuser::getInstance( (int) $userid ); if($cbUser === null) return; $itemid = getCBprofileItemid(); return CKunenaLink::GetHrefLink ( cbSef ('index.php?option=com_comprofiler&task=userProfile&user='******'', 'follow'); }
/** * Outputs legacy user edit display * * @param int $uid * @param string $option */ public function editUser($uid = 0, $option = 'users') { global $_CB_framework, $_PLUGINS; cbimport('language.all'); cbimport('cb.tabs'); cbimport('cb.params'); $msg = $this->_authorizedEdit((int) $uid); if (!$msg) { $msg = checkCBpermissions(array((int) $uid), 'edit', true); } $_PLUGINS->trigger('onBeforeUserProfileEditRequest', array((int) $uid, &$msg, 2)); if ($msg) { cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error'); } $_PLUGINS->loadPluginGroup('user'); $cbUser =& CBuser::getInstance((int) $uid); $cmsUserExists = (int) $uid != 0 && $cbUser !== null; if (!$cmsUserExists) { $cbUser =& CBuser::getInstance(null); } $user =& $cbUser->getUserData(); if ($cmsUserExists && $user->user_id != null) { // Edit existing CB user: $newCBuser = 0; } else { $newCBuser = 1; if ($cmsUserExists) { // Edit existing CMS (but new CB) user: $user->approved = 1; $user->confirmed = 1; $user->banned = 0; } else { // New user: $user->block = 0; $user->approved = 1; $user->confirmed = 1; $user->sendEmail = 0; $user->banned = 0; $user->gids = array((int) $_CB_framework->getCfg('new_usertype')); } } $null = null; $userView = _CBloadView('user'); /** @var CBController_user $userView */ $userView->edituser($user, $option, $newCBuser, $null); }
function showUsers( $option, $task, $cid ) { global $_CB_database, $_CB_framework, $_POST, $_PLUGINS, $_CB_TxtIntStore; $this->_importNeeded(); $limit = (int) $_CB_framework->getCfg( 'list_limit' ); if ( $limit == 0 ) { $limit = 10; } $filter_type = $_CB_framework->getUserStateFromRequest( "filter_type{$option}", 'filter_type', 0 ); $filter_status = $_CB_framework->getUserStateFromRequest( "filter_status{$option}", 'filter_status', 0 ); $filter_logged = intval( $_CB_framework->getUserStateFromRequest( "filter_logged{$option}", 'filter_logged', 0 ) ); $lastCBlist = $_CB_framework->getUserState( "view{$option}lastCBlist", null ); if( $lastCBlist == 'showusers' ) { if ( $task == 'showusers' ) { $limit = $_CB_framework->getUserStateFromRequest( "viewlistlimit", 'limit', $limit ); $limitstart = $_CB_framework->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); } $lastSearch = $_CB_framework->getUserState( "search{$option}", null ); $search = $_CB_framework->getUserStateFromRequest( "search{$option}", 'search', '' ); if ( $lastSearch != $search ) { $limitstart = 0; $_CB_framework->setUserState( "view{$option}limitstart", $limitstart ); } $search = stripslashes( trim( ( $_CB_TxtIntStore->_iso != 'UTF-8' ) ? strtolower( $search ) : ( is_callable( 'mb_convert_case' ) ? mb_convert_case( $search, MB_CASE_LOWER, "UTF-8") : utf8_encode(strtolower(utf8_decode( $search ) ) ) ) ) ); } else { $filter_type = 0; $filter_status = 0; $filter_logged = 0; clearSearchBox(); $search = ''; $limitstart = 0; $_CB_framework->setUserState( "view{$option}limitstart", $limitstart ); $_CB_framework->setUserState( "view{$option}lastCBlist", "showusers" ); } if ( $task !== 'showusers' ) { if ( $task == 'ajaxemailusers' ) { $limitstart = cbGetParam( $_POST, 'limitstart', 0 ); $limit = cbGetParam( $_POST, 'limit', 0 ); } else { $limitstart = 0; if ( $task == 'emailusers' ) { $limit = 101; // so that first 100 users and more... is displayed. } else { $limit = cbGetParam( $_POST, 'limit', 0 ); } } } $tablesSQL = array( 'u' => '#__users AS u' ); $joinsSQL = array( 'ue' => 'LEFT JOIN #__comprofiler AS ue ON u.id = ue.id' ); $tablesWhereSQL = array(); if ( isset( $search ) && ( $search != "") ) { $tablesWhereSQL[] = "(u.username LIKE '%" . $_CB_database->getEscaped( $search, true ) . "%' OR u.email LIKE '%" . $_CB_database->getEscaped( $search, true ) . "%' OR u.name LIKE '%" . $_CB_database->getEscaped( $search, true ) . "%')"; } if ( $filter_type ) { if ( checkJversion() == 2 ) { $tablesWhereSQL[] = "aro.group_id = " . (int) $filter_type; } else { if ( $filter_type == 'Public Frontend' ) { $tablesWhereSQL[] = "(u.usertype = 'Registered' OR u.usertype = 'Author' OR u.usertype = 'Editor'OR u.usertype = 'Publisher')"; } else if ( $filter_type == 'Public Backend' ) { $tablesWhereSQL[] = "( u.usertype = 'Manager' OR u.usertype = 'Administrator' OR u.usertype = 'Super Administrator' )"; } else { $tablesWhereSQL[] = "u.usertype = " . $_CB_database->Quote( $filter_type ); } } } $tBlocked = CBTxt::T('Blocked'); $tEnabled = CBTxt::T('Enabled'); $tUnconfirmed = CBTxt::T('Unconfirmed'); $tConfirmed = CBTxt::T('Confirmed'); $tUnapproved = CBTxt::T('Unapproved'); $tDisapproved = CBTxt::T('Disapproved'); $tApproved = CBTxt::T('Approved'); $tBanned = CBTxt::T('Banned'); $p = ' + '; $userstates = array( $tBlocked => 'u.block = 1', $tEnabled => 'u.block = 0', $tUnconfirmed => 'ue.confirmed = 0', $tConfirmed => 'ue.confirmed = 1', $tUnapproved => 'ue.approved = 0', $tDisapproved => 'ue.approved = 2', $tApproved => 'ue.approved = 1', $tBanned => 'ue.banned <> 0', $tBlocked . $p . $tUnconfirmed . $p . $tUnapproved => '(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 0)', $tEnabled . $p . $tUnconfirmed . $p . $tUnapproved => '(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 0)', $tBlocked . $p . $tConfirmed . $p . $tUnapproved => '(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 0)', $tEnabled . $p . $tConfirmed . $p . $tUnapproved => '(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 0)', $tBlocked . $p . $tUnconfirmed . $p . $tDisapproved => '(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 2)', $tEnabled . $p . $tUnconfirmed . $p . $tDisapproved => '(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 2)', $tBlocked . $p . $tConfirmed . $p . $tDisapproved => '(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 2)', $tEnabled . $p . $tConfirmed . $p . $tDisapproved => '(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 2)', $tBlocked . $p . $tUnconfirmed . $p . $tApproved => '(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 1)', $tEnabled . $p . $tUnconfirmed . $p . $tApproved => '(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 1)', $tBlocked . $p . $tConfirmed . $p . $tApproved => '(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 1)', $tEnabled . $p . $tConfirmed . $p . $tApproved => '(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 1)', CBTxt::T('Avatar not approved') => "(ue.avatar > '' AND ue.avatarapproved = 0)" ); if ( $filter_status ) { $tablesWhereSQL[] = $userstates[$filter_status]; } if ( $filter_logged == 1 ) { $tablesWhereSQL[] = "s.userid = u.id"; } else if ($filter_logged == 2) { $tablesWhereSQL[] = "s.userid IS NULL"; } // exclude any child group id's for this user //$_CB_framework->acl->_debug = true; $pgids = $_CB_framework->acl->get_group_children( userGID( $_CB_framework->myId() ), 'ARO', 'RECURSE' ); if ( is_array( $pgids ) && (count( $pgids ) > 0 ) ) { if ( checkJversion() == 2 ) { $tablesWhereSQL[] = "( aro.group_id NOT IN ( " . implode( ',', $pgids ) . " ) )"; } else { $tablesWhereSQL[] = "( u.gid NOT IN ( " . implode( ',', $pgids ) . " ) )"; } } // Filter the checkmarked users only: if ( $task !== 'showusers' ) { if ( is_array( $cid ) && ( count( $cid ) > 0 ) ) { cbArrayToInts( $cid ); $tablesWhereSQL[] = "( u.id IN ( " . implode( ',', $cid ) . " ) )"; } } // Advanced searches: $myCbUser =& CBuser::getInstance( $_CB_framework->myId() ); $myUser =& $myCbUser->getUserData(); $tabs = $myCbUser->_getCbTabs(); // new cbTabs( 0, 1 ); //TBD: later: this private method should not be called here, but the whole users-list should go into there and be called here. $allFields = $tabs->_getTabFieldsDb( null, $myUser, 'adminfulllist' ); foreach ( $allFields as $k => $v ) { if ( in_array( $v->type, array( 'pm', 'status', 'formatname', 'hidden', 'delimiter', 'userparams' ) ) ) { unset( $allFields[$k] ); // delimiter, userparams do not have search for now! } } $searchVals = new stdClass(); $list_compare_types = 1; // Advanced: all possibilities (WARNING: can be slow) $tableReferences = array( '#__comprofiler' => 'ue', '#__users' => 'u' ); $searchesFromFields = $tabs->applySearchableContents( $allFields, $searchVals, $_POST, $list_compare_types ); $whereFields = $searchesFromFields->reduceSqlFormula( $tableReferences, $joinsSQL, TRUE ); if ( $whereFields ) { $tablesWhereSQL[] = '(' . $whereFields . ')'; } $searchTabContent = $tabs->getSearchablesContents( $allFields, $myUser, $searchVals, $list_compare_types ); if ($filter_logged == 1 || $filter_logged == 2) { $joinsSQL[] .= "\n INNER JOIN #__session AS s ON s.userid = u.id"; // } else { done later, to avoid blocking site: // $joinsSQL[] .= "\n LEFT JOIN #__session AS s ON s.userid = u.id"; } if ( checkJversion() == 2 ) { $joinsSQL[] = "INNER JOIN #__user_usergroup_map AS aro ON aro.user_id = u.id"; // map user to aro for selection (and display if no selection) if ( $filter_type ) { $joinsSQL[] = "LEFT JOIN #__user_usergroup_map AS arodisplay ON arodisplay.user_id = u.id"; // map user to aro for display of all groups $joinsSQL[] = "INNER JOIN #__usergroups AS g ON g.id = arodisplay.group_id"; // map aro to group for display group name } else { $joinsSQL[] = "INNER JOIN #__usergroups AS g ON g.id = aro.group_id"; // map aro to group } } $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger( 'onBeforeBackendUsersListBuildQuery', array( &$tablesSQL, &$joinsSQL, &$tablesWhereSQL, $option ) ); $queryFrom = "\n FROM " . implode( ', ', $tablesSQL ) . ( count( $joinsSQL ) ? "\n " . implode( "\n ", $joinsSQL ) : '' ) . ( count( $tablesWhereSQL ) ? "\n WHERE " . implode( ' AND ', $tablesWhereSQL ) : '' ) ; // Counting query: $query = "SELECT COUNT(DISTINCT u.id)" . $queryFrom ; $_CB_database->setQuery( $query ); $total = $_CB_database->loadResult(); if ( $total === null ) { echo $_CB_database->getErrorMsg(); } if ( $total <= $limitstart ) { $limitstart = 0; } cbimport( 'cb.pagination' ); $pageNav = new cbPageNav( $total, $limitstart, $limit ); if ( checkJversion() == 2 ) { $grp_name = 'title'; } elseif ( checkJversion() == 1 ) { $grp_name = 'name'; $joinsSQL[] = "INNER JOIN #__core_acl_aro AS aro ON aro.value = u.id"; // map user to aro $joinsSQL[] = "INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id"; // map aro to group $joinsSQL[] = "INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id"; $tablesWhereSQL[] = "aro.section_value = 'users'"; } else { $grp_name = 'name'; $joinsSQL[] = "INNER JOIN #__core_acl_aro AS aro ON aro.value = u.id"; // map user to aro $joinsSQL[] = "INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.aro_id"; // map aro to group $joinsSQL[] = "INNER JOIN #__core_acl_aro_groups AS g ON g.group_id = gm.group_id"; $tablesWhereSQL[] = "aro.section_value = 'users'"; } $queryFrom = "\n FROM " . implode( ', ', $tablesSQL ) . ( count( $joinsSQL ) ? "\n " . implode( "\n ", $joinsSQL ) : '' ) . ( count( $tablesWhereSQL ) ? "\n WHERE " . implode( ' AND ', $tablesWhereSQL ) : '' ) ; // Main query: if ( checkJversion() == 2 ) { $query = "SELECT u.*, GROUP_CONCAT( DISTINCT g.$grp_name ORDER BY g.$grp_name SEPARATOR ', ') AS groupname, ue.approved, ue.confirmed" . $queryFrom . ' GROUP BY u.id' ; } else { $query = "SELECT DISTINCT u.*, g.$grp_name AS groupname, ue.approved, ue.confirmed" . $queryFrom ; } $_CB_database->setQuery( $query, (int) $pageNav->limitstart, (int) $pageNav->limit ); $rows = $_CB_database->loadObjectList( null, 'moscomprofilerUser', array( &$_CB_database ) ); if ($_CB_database->getErrorNum()) { echo $_CB_database->stderr(); return false; } // creates the CBUsers in cache corresponding to the $users: foreach ( array_keys( $rows ) as $k) { // do not do this otherwise substitutions do not work: // CBuser::setUserGetCBUserInstance( $rows[$k] ); } $template = 'SELECT COUNT(s.userid) FROM #__session AS s WHERE s.userid = '; $n = count( $rows ); for ( $i = 0; $i < $n; $i++ ) { $row = &$rows[$i]; $query = $template . (int) $row->id; $_CB_database->setQuery( $query ); $row->loggedin = $_CB_database->loadResult(); } $select_tag_attribs = 'class="inputbox" size="1" onchange="document.adminForm.submit( );"'; $inputTextExtras = ''; if ( $task != 'showusers' ) { $inputTextExtras = ' disabled="disabled"'; $select_tag_attribs .= $inputTextExtras; } // get list of Log Status for dropdown filter $logged[] = moscomprofilerHTML::makeOption( 0, CBTxt::T('- Select Login State -')); $logged[] = moscomprofilerHTML::makeOption( 1, CBTxt::T('Logged In')); $lists['logged'] = moscomprofilerHTML::selectList( $logged, 'filter_logged', $select_tag_attribs, 'value', 'text', "$filter_logged", 2 ); // get list of Groups for dropdown filter if ( checkJversion() == 2 ) { $query = "SELECT id AS value, title AS text" . "\n FROM #__usergroups"; } else { $query = "SELECT name AS value, name AS text" . "\n FROM #__core_acl_aro_groups" . "\n WHERE name != 'ROOT'" . "\n AND name != 'USERS'"; } $types[] = moscomprofilerHTML::makeOption( '0', CBTxt::T('- Select Group -') ); $_CB_database->setQuery( $query ); $types = array_merge( $types, $_CB_database->loadObjectList() ); $lists['type'] = moscomprofilerHTML::selectList( $types, 'filter_type', $select_tag_attribs, 'value', 'text', "$filter_type", 2 ); $status[] = moscomprofilerHTML::makeOption( 0, CBTxt::T('- Select User Status -')); foreach ( array_keys( $userstates ) as $k ) { $status[] = moscomprofilerHTML::makeOption( $k, $k ); } $lists['status'] = moscomprofilerHTML::selectList( $status, 'filter_status', $select_tag_attribs, 'value', 'text', "$filter_status", 2 ); $pluginAdditions = $_PLUGINS->trigger( 'onAfterBackendUsersList', array( 1, &$rows, &$pageNav, &$search, &$lists, $option, $select_tag_attribs ) ); $pluginColumns = array(); foreach ( $pluginAdditions as $addition ) { if ( is_array( $addition ) ) { $pluginColumns = array_merge( $pluginColumns, $addition ); } } if ( $task == 'showusers' ) { $usersView = _CBloadView( 'users' ); $usersView->showUsers( $rows, $pageNav, $search, $option, $lists, $pluginColumns, $inputTextExtras, $searchTabContent ); } else { $emailSubject = stripslashes( cbGetParam( $_POST, 'emailsubject', '' ) ); $emailBody = stripslashes( cbGetParam( $_POST, 'emailbody', '', _CB_ALLOWRAW | _CB_NOTRIM ) ); $emailsPerBatch = stripslashes( cbGetParam( $_POST, 'emailsperbatch', 50 ) ); $emailPause = stripslashes( cbGetParam( $_POST, 'emailpause', 30 ) ); $simulationMode = stripslashes( cbGetParam( $_POST, 'simulationmode', '' ) ); if ( count( $cid ) > 0 && count( $cid ) < $total ) { $total = count( $cid ); } if ( $task == 'emailusers' ) { $pluginRows = $_PLUGINS->trigger( 'onBeforeBackendUsersEmailForm', array( &$rows, &$pageNav, &$search, &$lists, &$cid, &$emailSubject, &$emailBody, &$inputTextExtras, &$select_tag_attribs, $simulationMode, $option ) ); $usersView = _CBloadView( 'users' ); $usersView->emailUsers( $rows, $total, $search, $option, $lists, $cid, $inputTextExtras, $searchTabContent, $emailSubject, $emailBody, $emailsPerBatch, $emailPause, $simulationMode, $pluginRows ); } elseif ( $task == 'startemailusers' ) { $pluginRows = $_PLUGINS->trigger( 'onBeforeBackendUsersEmailStart', array( &$rows, $total, $search, $lists, $cid, &$emailSubject, &$emailBody, &$inputTextExtras, $simulationMode, $option ) ); $usersView = _CBloadView( 'users' ); $usersView->startEmailUsers( $rows, $search, $option, $lists, $cid, $inputTextExtras, $searchTabContent, $emailSubject, $emailBody, $emailsPerBatch, $emailPause, $total, $simulationMode, $pluginRows ); } elseif ( $task == 'ajaxemailusers' ) { $this->_cbadmin_emailUsers( $rows, $emailSubject, $emailBody, $limitstart, $limit, $total, $simulationMode ); } } return true; }
/** * Replaces [fieldname] by the content of the user row (except for [password]) * * @param string $msg * @param UserTable|\stdClass $row * @param boolean|array $htmlspecialchars on replaced values only: FALSE : no htmlspecialchars, TRUE: do htmlspecialchars, ARRAY: callback method * @param boolean $menuStats * @param array $extraStrings * @param boolean $translateLanguage on $msg only * @return string */ function cbReplaceVars($msg, $row, $htmlspecialchars = true, $menuStats = true, $extraStrings = null, $translateLanguage = true) { if ($extraStrings === null) { $extraStrings = array(); } if (isset($row->id) && is_object($row) && $row instanceof UserTable) { $cbUser =& CBuser::getInstance($row->id); } else { $cbUser = new CBuser(); $cbUser->loadCbRow($row); } return $cbUser->replaceUserVars($msg, $htmlspecialchars, $menuStats, $extraStrings, $translateLanguage); }
/** * @param \CB\Database\Table\TabTable $tab the tab database entry * @param \CB\Database\Table\UserTable $user the user being displayed * @param int $ui 1 for front-end, 2 for back-end * @return boolean */ public function getMenuAndStatus($tab, $user, $ui) { global $_CB_framework, $_CB_database, $ueConfig, $_REQUEST, $_POST; $params = $this->params; $userId = $user->id && $_CB_framework->myId() == $user->id ? null : $user->id; $firstMenuName = $params->get('firstMenuName', ''); // CBTxt::T( '_UE_MENU_CB', 'Community' ) $firstSubMenuName = $params->get('firstSubMenuName', ''); // CBTxt::T( '_UE_MENU_ABOUT_CB', 'About Community Builder...' ) $firstSubMenuHref = $params->get('firstSubMenuHref', ''); $secondSubMenuName = $params->get('secondSubMenuName', ''); $secondSubMenuHref = $params->get('secondSubMenuHref', ''); // ----- CUSTOM MENU ----- if ($firstMenuName != '') { $customMenu = array(); $customMenu['arrayPos'] = $firstMenuName; $customMenu['position'] = 'menuBar'; $customMenu['caption'] = CBTxt::T($firstMenuName); $this->addMenu($customMenu); if ($firstSubMenuName != '') { // Custom 1: $first = array(); $first['arrayPos'] = array($firstMenuName => array('_UE_FIRST' => null)); $first['position'] = 'menuBar'; $first['caption'] = CBTxt::T($firstSubMenuName); $first['url'] = $firstSubMenuHref == '' ? "javascript: void( 0 );" : cbSef($firstSubMenuHref); $first['target'] = ''; $first['img'] = ''; $first['tooltip'] = ''; $this->addMenu($first); if ($secondSubMenuName != '') { // Custom 2: $second = array(); $second['arrayPos'] = array($firstMenuName => array('_UE_SECOND' => null)); $second['position'] = 'menuBar'; $second['caption'] = CBTxt::T($secondSubMenuName); $second['url'] = $secondSubMenuHref == '' ? "javascript: void( 0 );" : cbSef($secondSubMenuHref); $second['target'] = ''; $second['img'] = ''; $second['tooltip'] = ''; $this->addMenu($second); } } } // ----- VIEW MENU ----- $viewMenu = array(); $viewMenu['arrayPos'] = '_UE_MENU_VIEW'; $viewMenu['position'] = 'menuBar'; $viewMenu['caption'] = CBTxt::T('_UE_MENU_VIEW', 'View'); $this->addMenu($viewMenu); if ($_CB_framework->myId() > 0) { if ($_CB_framework->displayedUser() === null || $_CB_framework->myId() != $user->id && $_CB_framework->displayedUser() !== null) { // View My Profile: $myProfile = array(); $myProfile['arrayPos'] = array('_UE_MENU_VIEW' => array('_UE_MENU_VIEWMYPROFILE' => null)); $myProfile['position'] = 'menuBar'; $myProfile['caption'] = CBTxt::T('UE_MENU_VIEWMYPROFILE', 'View Your Profile'); $myProfile['url'] = $_CB_framework->userProfileUrl(); $myProfile['target'] = ''; $myProfile['img'] = '<span class="fa fa-home"></span> '; $myProfile['tooltip'] = CBTxt::T('UE_MENU_VIEWMYPROFILE_DESC', 'View your own profile'); $this->addMenu($myProfile); } } // ----- EDIT MENU ----- $editMenu = array(); $editMenu['arrayPos'] = '_UE_MENU_EDIT'; $editMenu['position'] = 'menuBar'; $editMenu['caption'] = CBTxt::T('_UE_MENU_EDIT', 'Edit'); $this->addMenu($editMenu); if (!cbCheckIfUserCanPerformUserTask($user->id, 'allowModeratorsUserEdit')) { if ($user->id == $_CB_framework->myId()) { $menuTexts = array('_UE_UPDATEPROFILE' => CBTxt::T('UE_UPDATEPROFILE', 'Update Your Profile'), '_UE_MENU_UPDATEPROFILE_DESC' => CBTxt::T('UE_MENU_UPDATEPROFILE_DESC', 'Change your profile settings')); } else { $menuTexts = array('_UE_UPDATEPROFILE' => CBTxt::T('UE_MOD_MENU_UPDATEPROFILE', 'Update user profile'), '_UE_MENU_UPDATEPROFILE_DESC' => CBTxt::T('UE_MOD_MENU_UPDATEPROFILE_DESC', 'Change profile settings of this user profile')); } // Update Profile: $updateProfile = array(); $updateProfile['arrayPos'] = array('_UE_MENU_EDIT' => array('_UE_UPDATEPROFILE' => null)); $updateProfile['position'] = 'menuBar'; $updateProfile['caption'] = $menuTexts['_UE_UPDATEPROFILE']; $updateProfile['url'] = $_CB_framework->userProfileEditUrl($userId); $updateProfile['target'] = ''; $updateProfile['img'] = '<span class="fa fa-edit"></span> '; $updateProfile['tooltip'] = $menuTexts['_UE_MENU_UPDATEPROFILE_DESC']; $this->addMenu($updateProfile); } // ----- MESSAGES MENU ----- $messagesMenu = array(); $messagesMenu['arrayPos'] = '_UE_MENU_MESSAGES'; $messagesMenu['position'] = 'menuBar'; $messagesMenu['caption'] = CBTxt::T('_UE_MENU_MESSAGES', 'Messages'); $this->addMenu($messagesMenu); if ($_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0) { global $_CB_PMS; $resultArray = $_CB_PMS->getPMSlinks($user->id, $_CB_framework->myId(), '', '', 1); if (count($resultArray) > 0) { foreach ($resultArray as $res) { if (is_array($res)) { // Send Private Message: $sendMessage = array(); $sendMessage['arrayPos'] = array('_UE_MENU_MESSAGES' => array('_UE_PM_USER' => null)); $sendMessage['position'] = 'menuBar'; $sendMessage['caption'] = $res['caption']; // Already translated in CB Menu $sendMessage['url'] = cbSef($res['url']); $sendMessage['target'] = ''; $sendMessage['img'] = '<span class="fa fa-comment"></span> '; $sendMessage['tooltip'] = $res['tooltip']; // Already translated in CB Menu $this->addMenu($sendMessage); } } } } if ($ueConfig['allow_email_display'] != 4 && $_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0) { switch ($ueConfig['allow_email_display']) { case 1: // Display Email only $caption = moscomprofilerHTML::emailCloaking(htmlspecialchars($user->email), 0); $url = "javascript: void( 0 );;"; $desc = CBTxt::T('UE_MENU_USEREMAIL_DESC', 'Email address of this user'); break; case 2: // Display Email with link $caption = moscomprofilerHTML::emailCloaking(htmlspecialchars($user->email), 1); $url = "javascript: void( 0 );;"; $desc = CBTxt::T('UE_MENU_SENDUSEREMAIL_DESC', 'Send an Email to this user'); break; case 3: // Display Email-to text with link to web-form // Display Email-to text with link to web-form default: $caption = CBTxt::T('UE_MENU_SENDUSEREMAIL', 'Send Email to User'); $url = $_CB_framework->viewUrl('emailuser', true, array('uid' => $userId)); $desc = CBTxt::T('UE_MENU_SENDUSEREMAIL_DESC', 'Send an Email to this user'); break; } // Send Email: $sendEmail = array(); $sendEmail['arrayPos'] = array('_UE_MENU_MESSAGES' => array('_UE_MENU_SENDUSEREMAIL' => null)); $sendEmail['position'] = 'menuBar'; $sendEmail['caption'] = $caption; $sendEmail['url'] = $url; $sendEmail['target'] = ''; $sendEmail['img'] = '<span class="fa fa-envelope"></span> '; $sendEmail['tooltip'] = $desc; $this->addMenu($sendEmail); } // ----- CONNECTIONS MENU ----- $connectionsMenu = array(); $connectionsMenu['arrayPos'] = '_UE_MENU_CONNECTIONS'; $connectionsMenu['position'] = 'menuBar'; $connectionsMenu['caption'] = CBTxt::T('_UE_MENU_CONNECTIONS', 'Connections'); $this->addMenu($connectionsMenu); if ($ueConfig['allowConnections'] && $_CB_framework->myId() > 0) { // Manage My Connections: $manageConnections = array(); $manageConnections['arrayPos'] = array('_UE_MENU_CONNECTIONS' => array('_UE_MENU_MANAGEMYCONNECTIONS' => null)); $manageConnections['position'] = 'menuBar'; $manageConnections['caption'] = CBTxt::T('UE_MENU_MANAGEMYCONNECTIONS', 'Manage Your Connections'); $manageConnections['url'] = $_CB_framework->viewUrl('manageconnections'); $manageConnections['target'] = ''; $manageConnections['img'] = '<span class="fa fa-users"></span> '; $manageConnections['tooltip'] = CBTxt::T('UE_MENU_MANAGEMYCONNECTIONS_DESC', 'Manage your existing connections and pending connections actions'); $this->addMenu($manageConnections); if ($_CB_framework->myId() != $user->id) { $cbConnection = new cbConnection((int) $_CB_framework->myId()); $cbUser =& CBuser::getInstance((int) $user->id, false); $connClass = null; $connLink = null; $connDesc = null; $connMsg = null; $connImg = null; $isConnection = $cbConnection->isConnected((int) $user->id); if ($isConnection) { $isApproved = $cbConnection->isConnectionApproved((int) $user->id); $isAccepted = $cbConnection->isConnectionAccepted((int) $user->id); } else { $isApproved = false; $isAccepted = false; } if (!$isConnection) { $connUrl = $_CB_framework->viewUrl('addconnection', true, array('connectionid' => (int) $user->id)); if ($ueConfig['useMutualConnections'] == 1) { $connClass = 'UE_ADDCONNECTIONREQUEST'; $connMsg = CBTxt::T('UE_ADDCONNECTIONREQUEST', 'Request Connection'); $connDesc = CBTxt::T('UE_ADDCONNECTIONREQUEST_DESC', 'Request a Connection to that user'); } else { $connClass = 'UE_ADDCONNECTION'; $connMsg = CBTxt::T('UE_ADDCONNECTION', 'Add Connection'); $connDesc = CBTxt::T('UE_ADDCONNECTION_DESC', 'Add a Connection to that user'); } if ($ueConfig['conNotifyType'] != 0) { cbValidator::loadValidation(); $tooltipTitle = sprintf(CBTxt::T('UE_CONNECTTO', 'Connect to %s'), $cbUser->getField('formatname', null, 'html', 'none', 'profile', 0, true)); $connectionInvitationMsg = CBTxt::T('UE_CONNECTIONINVITATIONMSG', 'Personalize your invitation to connect by adding a message that will be included with your connection.'); $tooltip = null; if ($connectionInvitationMsg) { $tooltip .= '<div class="form-group cb_form_line clearfix">' . $connectionInvitationMsg . '</div>'; } $tooltip .= '<form action="' . $connUrl . '" method="post" id="connOverForm" name="connOverForm" class="cb_form cbValidation">' . '<div class="form-group cb_form_line clearfix">' . '<label for="message" class="control-label">' . CBTxt::T('UE_MESSAGE', 'Message') . '</label>' . '<div class="cb_field">' . '<textarea cols="40" rows="8" name="message" class="form-control"></textarea>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="submit" class="btn btn-primary cbConnReqSubmit" value="' . htmlspecialchars(CBTxt::Th('UE_SENDCONNECTIONREQUEST', 'Request Connection')) . '"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . ' <input type="button" id="cbConnReqCancel" class="btn btn-default cbConnReqCancel cbTooltipClose" value="' . htmlspecialchars(CBTxt::Th('UE_CANCELCONNECTIONREQUEST', 'Cancel')) . '" />' . '</div>' . '</form>'; $connLink = cbTooltip($ui, $tooltip, $tooltipTitle, 400, null, '<span class="fa fa-heart"></span> ' . CBTxt::Th($connMsg), 'javascript: void( 0 );', 'data-hascbtooltip="true" data-cbtooltip-modal="true"'); } else { $connLink = $connUrl; $connImg = '<span class="fa fa-heart"></span> '; } } else { if ($isAccepted) { $connUrl = $_CB_framework->viewUrl('removeconnection', true, array('connectionid' => (int) $user->id)); if ($isApproved) { $connClass = 'UE_REMOVECONNECTION'; $connMsg = CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection'); $connDesc = CBTxt::T('UE_REMOVECONNECTION_DESC', 'Remove Connection to that user'); } else { $connClass = 'UE_REVOKECONNECTIONREQUEST'; $connMsg = CBTxt::T('UE_REVOKECONNECTIONREQUEST', 'Revoke Connection Request'); $connDesc = CBTxt::T('UE_REVOKECONNECTIONREQUEST_DESC', 'Cancel the Connection Request to that user'); } $js = "if ( typeof confirmSubmit != 'function' ) {" . "function confirmSubmit() {" . "if ( confirm( '" . addslashes(CBTxt::T('UE_CONFIRMREMOVECONNECTION', 'Are you sure you want to remove this connection?')) . "' ) ) {" . "return true;" . "} else {" . "return false;" . "}" . "};" . "}"; $_CB_framework->document->addHeadScriptDeclaration($js); $connLink = $connUrl . '" onclick="return confirmSubmit();'; $connImg = '<span class="fa fa-heart-o"></span> '; } else { $connClass = null; $connMsg = null; } } if ($connMsg) { // Request/Add/Remove/Revoke Connection: $connectionRequest = array(); $connectionRequest['arrayPos'] = array('_UE_MENU_CONNECTIONS' => array($connClass => null)); $connectionRequest['position'] = 'menuBar'; $connectionRequest['caption'] = $connMsg; $connectionRequest['url'] = $connLink; $connectionRequest['target'] = ''; $connectionRequest['img'] = $connImg; $connectionRequest['tooltip'] = $connDesc; $this->addMenu($connectionRequest); } } } // ----- MODERATE MENU ----- $moderateMenu = array(); $moderateMenu['arrayPos'] = '_UE_MENU_MODERATE'; $moderateMenu['position'] = 'menuBar'; $moderateMenu['caption'] = CBTxt::T('_UE_MENU_MODERATE', 'Moderate'); $this->addMenu($moderateMenu); if ($_CB_framework->myId() == $user->id) { if ($user->banned == 1 && $this->cbUserIsModerator == 0 && $ueConfig['allowUserBanning'] == 1) { // Request Unban: $requestUnban = array(); $requestUnban['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_REQUESTUNBANPROFILE' => null)); $requestUnban['position'] = 'menuBar'; $requestUnban['caption'] = CBTxt::T('UE_REQUESTUNBANPROFILE', 'Submit Unban Request'); $requestUnban['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 2, 'reportform' => 1, 'uid' => (int) $user->id)); $requestUnban['target'] = ''; $requestUnban['img'] = '<span class="fa fa-envelope"></span> '; $requestUnban['tooltip'] = CBTxt::T('UE_MENU_REQUESTUNBANPROFILE_DESC', 'Submit a request to the site moderator to unban your profile'); $this->addMenu($requestUnban); } } else { if ($ueConfig['allowUserReports'] == 1 && $this->cbUserIsModerator == 0 && $_CB_framework->myId() > 0) { // Report User: $reportUser = array(); $reportUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_REPORTUSER' => null)); $reportUser['position'] = 'menuBar'; $reportUser['caption'] = CBTxt::T('UE_REPORTUSER', 'Report User'); $reportUser['url'] = $_CB_framework->viewUrl('reportuser', true, array('uid' => (int) $user->id)); $reportUser['target'] = ''; $reportUser['img'] = '<span class="fa fa-bullhorn"></span> '; $reportUser['tooltip'] = CBTxt::T('UE_MENU_REPORTUSER_DESC', 'Report this user to the site moderator so that he can take appropriate action'); $this->addMenu($reportUser); } if ($this->cbMyIsModerator == 1 && $this->cbUserIsModerator == 0) { $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_userreports') . "\n WHERE " . $_CB_database->NameQuote('reporteduser') . " = " . (int) $user->id . "\n AND " . $_CB_database->NameQuote('reportedstatus') . " = 0"; $_CB_database->setQuery($query); $pendingReports = $_CB_database->loadResult(); $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_userreports') . "\n WHERE " . $_CB_database->NameQuote('reporteduser') . " = " . (int) $user->id; $_CB_database->setQuery($query); $processedReports = $_CB_database->loadResult(); if ($ueConfig['allowUserBanning'] == 1) { if ($user->banned != 0) { // Unban Profile: $unbanUser = array(); $unbanUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_UNBANPROFILE' => null)); $unbanUser['position'] = 'menuBar'; $unbanUser['caption'] = CBTxt::T('UE_UNBANPROFILE', 'Unban Profile'); $unbanUser['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 0, 'reportform' => 0, 'uid' => (int) $user->id)); $unbanUser['target'] = ''; $unbanUser['img'] = '<span class="fa fa-check-circle-o"></span> '; $unbanUser['tooltip'] = CBTxt::T('UE_MENU_UNBANPROFILE_DESC', 'As Site Moderator: Unban this profile, making it visible to other users'); $this->addMenu($unbanUser); } else { // Ban Profile: $banUser = array(); $banUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_BANPROFILE' => null)); $banUser['position'] = 'menuBar'; $banUser['caption'] = CBTxt::T('UE_BANPROFILE', 'Ban Profile'); $banUser['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 1, 'uid' => (int) $user->id)); $banUser['target'] = ''; $banUser['img'] = '<span class="fa fa-ban"></span> '; $banUser['tooltip'] = CBTxt::T('UE_MENU_BANPROFILE_DESC', 'As Site Moderator: Ban this profile, making it invisible to other users'); $this->addMenu($banUser); } if ($user->bannedby) { // Ban History: $banHistory = array(); $banHistory['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_MENU_BANPROFILE_HISTORY' => null)); $banHistory['position'] = 'menuBar'; $banHistory['caption'] = CBTxt::T('UE_MENU_BANPROFILE_HISTORY', 'Ban history'); $banHistory['url'] = $_CB_framework->viewUrl('moderatebans', true, array('act' => 2, 'uid' => (int) $user->id)); $banHistory['target'] = ''; $banHistory['img'] = '<span class="fa fa-book"></span> '; $banHistory['tooltip'] = CBTxt::T('UE_MENU_BANPROFILE_HISTORY_DESC', 'As Site Moderator: See ban history of this profile'); $this->addMenu($banHistory); } } if ($ueConfig['allowUserReports'] == 1 && $pendingReports > 0) { // View Pending Reports: $userReports = array(); $userReports['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_VIEWUSERREPORTS' => null)); $userReports['position'] = 'menuBar'; $userReports['caption'] = CBTxt::T('UE_VIEWUSERREPORTS', 'View User Reports'); $userReports['url'] = $_CB_framework->viewUrl('viewreports', true, array('uid' => (int) $user->id)); $userReports['target'] = ''; $userReports['img'] = '<span class="fa fa-warning"></span> '; $userReports['tooltip'] = CBTxt::T('UE_MENU_VIEWUSERREPORTS_DESC', 'As Site Moderator: View User Reports for this user'); $this->addMenu($userReports); } elseif ($ueConfig['allowUserReports'] == 1 && $processedReports > 0) { // View Processed Reports: $userReports = array(); $userReports['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_VIEWUSERREPORTS' => null)); $userReports['position'] = 'menuBar'; $userReports['caption'] = CBTxt::T('UE_MOD_MENU_VIEWOLDUSERREPORTS', 'View processed user reports'); $userReports['url'] = $_CB_framework->viewUrl('viewreports', true, array('act' => 1, 'uid' => (int) $user->id)); $userReports['target'] = ''; $userReports['img'] = '<span class="fa fa-warning"></span> '; $userReports['tooltip'] = CBTxt::T('UE_MOD_MENU_VIEWOLDUSERREPORTS_DESC', 'As site moderator: View processed user reports for this user'); $this->addMenu($userReports); } } } }
/** * Translates, prepares the HTML $htmlText with triggering CMS Content Plugins, replaces CB substitutions and extra HTML and non-HTML substitutions * @see CBuser::replaceUserVars * * @param string $mainText * @param int $user_id * @param boolean $html * @param boolean $translateMainText * @param boolean $prepareHtmlContentPlugins * @param array|null $extraHtmlStrings * @param array|null $extraNonHtmlStrings * @return string */ public static function replaceUserVars( $mainText, $user_id, $html, $translateMainText = true, $prepareHtmlContentPlugins = false, $extraHtmlStrings = null, $extraNonHtmlStrings = null ) { if ( $translateMainText ) { $mainText = $html ? parent::Th( $mainText ) : parent::T( $mainText ); } if ( $prepareHtmlContentPlugins ) { $mainText = Application::Cms()->prepareHtmlContentPlugins( $mainText ); if ( ! $html ) { $mainText = strip_tags( $mainText ); } } $cbUser = CBuser::getInstance( (int) $user_id ); if ( ! $cbUser ) { $cbUser = CBuser::getInstance( null ); } $mainText = $cbUser->replaceUserVars( $mainText, true, false, $extraNonHtmlStrings, false ); if ( $extraHtmlStrings ) { foreach ( $extraHtmlStrings as $k => $v ) { $mainText = str_replace( "[$k]", $html ? $v : strip_tags( $v ), $mainText ); } } return $mainText; }
function getAvatar($user, $extension, $default_avatar) { $avatar = 0; if ($user->get('id') == 0) { $avatar = !empty($default_avatar) ? $default_avatar : 0; } elseif ($extension == 1) { require_once JPATH_ADMINISTRATOR . '/components/com_rokbridge/helper.php'; $rokbridge = new RokBridgeHelper(); $phpbb_db = $rokbridge->phpbb_db; $query = "SELECT user_id, user_type, username, user_unread_privmsg, user_new_privmsg, user_avatar, user_avatar_type, user_avatar_width, user_avatar_height, user_lastvisit, FROM_UNIXTIME(user_lastvisit,'%a %b %D %x %h:%i %p') AS LastVisit FROM #__users WHERE " . $rokbridge->getWhereClause($user->username); $phpbb_db->setQuery($query); $fuser = $phpbb_db->loadObject(); $avatar = $rokbridge->getAvatar($fuser, 35, "", $default_avatar); $avatar = substr($avatar, strpos($avatar, '"') + 1); $avatar = substr($avatar, 0, strpos($avatar, '"')); } elseif ($extension == 2) { $jspath = JPATH_BASE . DS . 'components/com_community'; include_once $jspath . DS . 'libraries/core.php'; $user =& CFactory::getUser($user->get('id')); $avatar = $user->getThumbAvatar(); } elseif ($extension == 3) { $jspath = JPATH_ADMINISTRATOR . '/components/com_comprofiler'; include_once $jspath . DS . 'plugin.foundation.php'; cbimport('cb.database'); $user =& CBuser::getInstance($user->get('id')); $avatar = $user->avatarFilePath(1); if (empty($avatar)) { $avatar = $default_avatar; } } elseif ($extension == 4) { $ini = JFile::read(JPATH_ADMINISTRATOR . '/components/com_juser/config.ini'); $juserparams = new JParameter($ini); $avatar_save_path = $juserparams->get('general::avatars_dir'); if (file_exists(JPATH_ROOT . DS . $avatar_save_path . DS . $user->get('username') . '.jpg')) { $avatar = JURI::root() . str_replace('\\', '/', $avatar_save_path) . '/' . $user->get('username') . '.jpg'; } else { $avatar = JURI::root() . '/components/com_juser/images/default_avatar.png'; } } elseif ($extension == 5) { require_once JPATH_BASE . DS . 'components/com_kunena/class.kunena.php'; $kunena_user = KunenaFactory::getUser($user->get('id')); $username = $kunena_user->getName(); $avatar = $kunena_user->getAvatarURL(); } return $avatar; }
/** * Evaluate an user attribute * Private function: DO NOT USE AS PUBLIC! * (it is public because PHP 5.3 does not support $this in anonymous functions within function _evaluateIfs() below) * * @param string $userAttrVal Attribute value ('#me', '#displayed', '#displayedOrMe', '1231' (user-id)) * @return CBuser CB User corresponding to $userAttrValue */ public function &_evaluateUserAttrib($userAttrVal) { global $_CB_framework; if ($userAttrVal !== '') { $uid = null; if ($userAttrVal == '#displayed' || $userAttrVal == '#displayedOrMe') { $uid = (int) $_CB_framework->displayedUser(); } if (!$uid && ($userAttrVal == '#displayedOrMe' || $userAttrVal == '#me')) { $uid = (int) Application::MyUser()->getUserId(); } if (!$uid && preg_match('/^[1-9][0-9]*$/', $userAttrVal)) { $uid = (int) $userAttrVal; } if ($uid) { if ($uid == $this->_cbuser->id) { $user = $this; } else { $user = CBuser::getInstance((int) $uid, false); } } else { $user = CBuser::getInstance(null); } } else { $user = $this; } return $user; }
function acymailing_replaceusertags(&$email, &$user, $send = true) { $match = '#(?:{|%7B)cbtag:(.*)(?:}|%7D)#Ui'; $variables = array('subject', 'body', 'altbody'); $found = false; foreach ($variables as $var) { if (empty($email->{$var})) { continue; } $found = preg_match_all($match, $email->{$var}, $results[$var]) || $found; if (empty($results[$var][0])) { unset($results[$var]); } } if (!$found) { return; } $uservalues = null; $db = JFactory::getDBO(); if (!empty($user->userid)) { $db->setQuery('SELECT * FROM ' . acymailing_table('comprofiler', false) . ' WHERE user_id = ' . $user->userid . ' LIMIT 1'); $uservalues = $db->loadObject(); } include_once ACYMAILING_ROOT . 'administrator' . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin.foundation.php'; cbimport('cb.database'); $pluginsHelper = acymailing_get('helper.acyplugins'); $currentCBUser = null; $tags = array(); foreach ($results as $var => $allresults) { foreach ($allresults[0] as $i => $oneTag) { if (isset($tags[$oneTag])) { continue; } $arguments = explode('|', $allresults[1][$i]); $field = $arguments[0]; unset($arguments[0]); $mytag = new stdClass(); $mytag->default = $this->params->get('default_' . $field, ''); if (!empty($arguments)) { foreach ($arguments as $onearg) { $args = explode(':', $onearg); if (isset($args[1])) { $mytag->{$args}[0] = $args[1]; } else { $mytag->{$args}[0] = 1; } } } $values = new stdClass(); if (!empty($mytag->info) and $mytag->info == 'sender') { if (empty($this->sendervalues[$email->mailid]) and !empty($email->userid)) { $db->setQuery('SELECT * FROM #__comprofiler WHERE user_id = ' . $email->userid . ' LIMIT 1'); $this->sendervalues[$email->mailid] = $db->loadObject(); } if (!empty($this->sendervalues[$email->mailid])) { $values = $this->sendervalues[$email->mailid]; } } else { $values = $uservalues; } if (substr($field, 0, 6) == 'cbapi_') { if (!empty($mytag->info) and $mytag->info == 'sender') { if (empty($this->sendervalues[$email->mailid]->{$field}) and !empty($email->userid)) { $currentSender = CBuser::getInstance($email->userid); $values->{$field} = $currentSender->getField(substr($field, 6), $mytag->default, 'html', 'none', 'profile', 0, true); $this->sendervalues[$email->mailid]->{$field} = $values->{$field}; } elseif (!empty($this->sendervalues[$email->mailid]->{$field})) { $values->{$field} = @$this->sendervalues[$email->mailid]->{$field}; } } elseif (!empty($user->userid)) { if (empty($currentCBUser)) { $currentCBUser = CBuser::getInstance($user->userid); } if (!empty($currentCBUser)) { $values->{$field} = $currentCBUser->getField(substr($field, 6), $mytag->default, 'html', 'none', 'profile', 0, true); } } } $replaceme = isset($values->{$field}) ? $values->{$field} : $mytag->default; if (!empty($mytag->type)) { if ($mytag->type == 'image' and !empty($replaceme)) { $replaceme = '<img src="' . ACYMAILING_LIVE . 'images/comprofiler/' . $replaceme . '" alt="' . htmlspecialchars(@$user->name, ENT_COMPAT, 'UTF-8') . '" />'; } } if ($field == 'thumb') { $replaceme = '<img src="' . ACYMAILING_LIVE . 'images/comprofiler/tn' . $values->avatar . '" alt="' . htmlspecialchars(@$user->name, ENT_COMPAT, 'UTF-8') . '" />'; } elseif ($field == 'avatar') { $replaceme = '<img src="' . ACYMAILING_LIVE . 'images/comprofiler/' . $values->avatar . '" alt="' . htmlspecialchars(@$user->name, ENT_COMPAT, 'UTF-8') . '" />'; } $tags[$oneTag] = $replaceme; $pluginsHelper->formatString($tags[$oneTag], $mytag); } } foreach ($results as $var => $allresults) { $email->{$var} = str_replace(array_keys($tags), $tags, $email->{$var}); } }
/** * Checks if the subscription is valid given its current status, expiry date and a given time * * @param int $time UNIX-formatted time (default: now) * @return boolean TRUE if valid (not expired), FALSE otherwise */ public function checkIfValid( $time = null ) { global $_CB_framework; if ( $this->status == 'A' ) { if ( $this->expiry_date == '0000-00-00 00:00:00' ) { // lifetime subscription: return true; } $plan = $this->getPlan(); if ( $plan ) { $valid = $plan->checkValid( $this->expiry_date, $time ); if ( $valid ) { return true; } // check for the case of a free autorecurring plan: if ( $plan->get( 'autorecurring' ) ) { $max_occur = $plan->get( 'recurring_max_times' ); if ( $max_occur != 0 ) { $occurence = $this->getOccurrence(); if ( $occurence >= $max_occur ) { return false; } } $now = $_CB_framework->now(); $params =& cbpaidApp::settingsParams(); $currency_code = $params->get( 'currency_code', 'USD' ); $rate = $this->getPriceOfNextPayment( $currency_code, $now, 1, 'R' ); // N=New, R=Renew + U = Upgrade if ( ( $rate !== false ) && ( $rate == 0 ) ) { $cbUser = CBuser::getInstance( (int) $this->user_id ); if ( $cbUser ) { $user = $cbUser->getUserData(); } else { $user = new UserTable( $this->_db ); } $this->activate( $user, $now, true, 'R', 1, 2, 2 ); return true; // trigger_error('WOULD RENEW NOW', E_USER_NOTICE ); // $this->activate(); } } } } return false; }
/** * Checks if a user is create limited for a specific type * * @param UserTable $user * @param string $type * @param bool $folder * @return bool */ static public function canUserCreate( $user, $type, $folder ) { global $_CB_database, $_PLUGINS; $userId = (int) $user->get( 'id' ); if ( ! $userId ) { return false; } static $mods = array(); if ( ! isset( $mods[$userId] ) ) { $mods[$userId] = Application::User( (int) $userId )->isGlobalModerator(); } if ( $mods[$userId] ) { return true; } static $params = null; if ( ! $params ) { $plugin = $_PLUGINS->getLoadedPlugin( 'user', 'cbgallery' ); $params = $_PLUGINS->getPluginParams( $plugin ); } if ( ( ! $folder ) && ( ! $params->get( $type . '_item_upload', 1 ) ) && ( ! $params->get( $type . '_item_link', 0 ) ) ) { return false; } static $cache = array(); if ( ! isset( $cache[$userId][$type][$folder] ) ) { $canCreate = false; if ( Application::User( (int) $userId )->canViewAccessLevel( (int) $params->get( $type . ( $folder ? '_folder_create_access' : '_item_create_access' ), 2 ) ) ) { $itemLimit = $params->get( $type . ( $folder ? '_folder_limit' : '_item_limit' ), null ); if ( ! $itemLimit ) { $itemLimit = (int) $params->get( $type . ( $folder ? '_folder_limit_custom' : '_item_limit_custom' ), null ); } else { $limitField = CBuser::getInstance( (int) $userId, false )->getField( $itemLimit, null, 'php', 'none', 'profile', 0, true ); if ( is_array( $limitField ) ) { $itemLimit = array_shift( $limitField ); if ( is_array( $itemLimit ) ) { $itemLimit = implode( '|*|', $itemLimit ); } } else { $itemLimit = $user->get( $limitField, 0 ); } $itemLimit = (int) $itemLimit; } if ( $itemLimit ) { $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote( ( $folder ? '#__comprofiler_plugin_gallery_folders' : '#__comprofiler_plugin_gallery_items' ) ) . "\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( $type ) . "\n AND " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $userId; $_CB_database->setQuery( $query ); $total = $_CB_database->loadResult(); if ( $total < $itemLimit ) { $canCreate = true; } } else { $canCreate = true; } } $cache[$userId][$type][$folder] = $canCreate; } return $cache[$userId][$type][$folder]; }
/** * Create a payment item for a payment basket to be created * * @param int $quantity Quantity * @param string $currency_code The currency of the payment basket (so the payment item must be converted into that currency * @param string $artNumber Text for the article number * @param string $prefixText Text to prefix before the item descriptions //TBD this should be on a per-item basis * @param string $reason payment reason: 'N'=new subscription (default), 'R'=renewal, 'U'=update * @param int $now unix time of now (single now time for consistency in db) * @param boolean $tryAutorecurring try to build the payment basket as autorecurring * @return cbpaidPaymentItem return FALSE if can't be purchased/subscribed */ public function & createPaymentItem( $quantity, $currency_code, $artNumber, $prefixText, $reason, $now, $tryAutorecurring ) { $item = new cbpaidPaymentItem( $this->_db ); $item->callIntegrations( 'beforeCreatePaymentItem', $this, null ); $planId = $this->plan_id; $start_date = date( 'Y-m-d H:i:s', $now ); $rate = $this->getPriceOfNextPayment( $currency_code, $now, $quantity, $reason ); // N=New, R=Renew + U = Upgrade if ( $rate === false ) { $false = false; return $false; } // build item description line, default: [ITEM_ALIAS] and [PREFIX_TEXT] [PLANS_TITLE]: [ITEM_NAME][VALIDITY_IF_NOT_AUTORECURRING] for [USERNAME] cbimport( 'cb.tabs' ); // cbFormatDate needs this and cbreplaceVars too $extraStrings = $this->substitutionStringsForItemDetailed( false, $reason, false ); $cbUser = CBuser::getInstance( $this->user_id ); $itemDescription = $cbUser->replaceUserVars( CBPTXT::T( $this->getPlanAttribute( 'item_text' ) ), false, false, $extraStrings, false ); $itemAlias = $cbUser->replaceUserVars( CBPTXT::T( $this->getPlanAttribute( 'item_alias' ) ), false, false, $extraStrings, false ); $item->createItem( strtolower( $this->recordName() ), $quantity, $artNumber, $itemDescription, $itemAlias, $currency_code, $rate, $this->getPlanAttribute( 'owner' ), $reason ); $validity = '0000-00-00 00:00:00'; $stop_date = '0000-00-00 00:00:00'; $second_stop_date = '0000-00-00 00:00:00'; $autorecurring = 0; $recurring_max_times = 0; $first_rate = null; $first_validity = null; $bonustime = '0000-00-00 00:00:00'; $prorate_discount = 0.0; $item->setSubscriptionVars( $this->id, $planId, $validity, $start_date, $stop_date, $second_stop_date, $autorecurring, $recurring_max_times, $first_rate, $first_validity, $bonustime, $prorate_discount ); $item->callIntegrations( 'afterCreatePaymentItem', $this, null ); return $item; }
/** * @param ActivityTable[] $rows * @param Activity $stream * @param int $output 0: Normal, 1: Raw, 2: Inline, 3: Load, 4: Save * @param UserTable $user * @param UserTable $viewer * @param cbPluginHandler $plugin * @return null|string */ static public function showActivity( $rows, $stream, $output, $user, $viewer, $plugin ) { global $_CB_framework, $_PLUGINS; $showActions = (int) $stream->get( 'actions', 1 ); $showLocations = (int) $stream->get( 'locations', 1 ); $showLinks = (int) $stream->get( 'links', 1 ); $showTags = (int) $stream->get( 'tags', 1 ); CBActivity::loadHeaders( $output ); $_CB_framework->outputCbJQuery( "$( '.activityStream' ).cbactivity();" ); $canCreate = CBActivity::canCreate( $user, $viewer, $stream ); $cbModerator = CBActivity::isModerator( (int) $viewer->get( 'id' ) ); $sourceClean = htmlspecialchars( $stream->source() ); $newForm = null; $moreButton = null; if ( ( $output != 4 ) && $stream->get( 'paging' ) && $stream->get( 'limit' ) && $rows ) { $moreButton = '<a href="' . $stream->endpoint( 'show', array( 'limitstart' => ( $stream->get( 'limitstart' ) + $stream->get( 'limit' ) ), 'limit' => $stream->get( 'limit' ) ) ) . '" class="activityButton activityButtonMore streamMore btn btn-primary btn-sm btn-block">' . CBTxt::T( 'More' ) . '</a>'; } $return = null; $_PLUGINS->trigger( 'activity_onBeforeDisplayActivity', array( &$return, &$rows, $stream, $output ) ); if ( ! in_array( $output, array( 1, 4 ) ) ) { $return .= '<div class="' . $sourceClean . 'Activity activityStream streamContainer ' . ( $stream->direction() ? 'streamContainerUp' : 'streamContainerDown' ) . '" data-cbactivity-direction="' . (int) $stream->direction() . '">'; if ( ( $stream->source() != 'hidden' ) && ( ! $stream->get( 'id' ) ) && ( ! $stream->get( 'filter' ) ) ) { $newForm = self::showNew( $stream, $output, $user, $viewer, $plugin ); } } $return .= ( $stream->direction() ? $moreButton : $newForm ) . ( ! in_array( $output, array( 1, 4 ) ) ? '<div class="' . $sourceClean . 'ActivityItems activityStreamItems streamItems">' : null ); if ( $rows ) foreach ( $rows as $row ) { $rowId = $stream->id() . '_' . (int) $row->get( 'id' ); $rowOwner = ( $viewer->get( 'id' ) == $row->get( 'user_id' ) ); $typeClass = ( $row->get( 'type' ) ? ucfirst( strtolower( preg_replace( '/[^-a-zA-Z0-9_]/', '', $row->get( 'type' ) ) ) ) : null ); $subTypeClass = ( $row->get( 'subtype' ) ? ucfirst( strtolower( preg_replace( '/[^-a-zA-Z0-9_]/', '', $row->get( 'subtype' ) ) ) ) : null ); $isStatus = ( ( $row->get( 'type' ) == 'status' ) || ( $row->get( 'subtype' ) == 'status' ) ); $cbUser = CBuser::getInstance( (int) $row->get( 'user_id' ), false ); $title = ( $row->get( 'title' ) ? ( $isStatus ? htmlspecialchars( $row->get( 'title' ) ) : CBTxt::T( $row->get( 'title' ) ) ) : null ); $message = ( $row->get( 'message' ) ? ( $isStatus ? htmlspecialchars( $row->get( 'message' ) ) : CBTxt::T( $row->get( 'message' ) ) ) : null ); $date = null; $insert = null; $footer = null; $menu = array(); $extras = array(); $_PLUGINS->trigger( 'activity_onDisplayActivity', array( &$row, &$title, &$date, &$message, &$insert, &$footer, &$menu, &$extras, $stream, $output ) ); $title = $stream->parser( $title )->parse( array( 'linebreaks' ) ); $message = $stream->parser( $message )->parse(); if ( $isStatus ) { if ( ( in_array( $row->get( 'type' ), array( 'status', 'field' ) ) ) && $row->get( 'parent' ) && ( $row->get( 'parent' ) != $_CB_framework->displayedUser() ) && ( $row->get( 'parent' ) != $row->get( 'user_id' ) ) ) { $targetUser = CBuser::getInstance( (int) $row->get( 'parent' ) ); if ( $targetUser !== null ) { $title = ' <span class="fa fa-caret-right"></span> <strong>' . $targetUser->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) . '</strong>'; } } $action = ( $showActions ? $stream->parser( $row->action() )->parse( array( 'linebreaks' ) ) : null ); $location = ( $showLocations ? $row->location() : null ); $tags = null; if ( $showTags && $row->get( '_tags' ) ) { $tagsStream = $row->tags( $stream->source() ); if ( $tagsStream && $tagsStream->data( true ) ) { $tags = trim( CBTxt::T( 'ACTIVITY_STATUS_TAGS', 'with [tags]', array( '[tags]' => $tagsStream->stream( true ) ) ) ); } } if ( $action || $location || $tags ) { $subContent = ( $action ? $action : null ) . ( $location ? ( $action ? ' ' : null ) . $location : null ) . ( $tags ? ( $action || $location ? ' ' : null ) . $tags : null ); if ( $title ) { $message .= '<div class="streamItemSubContent">— ' . $subContent . '</div>'; } else { $title = $subContent; } } } elseif ( $row->get( 'type' ) == 'activity' ) { if ( ! $row->get( 'item' ) ) { continue; } $row->set( '_comments', false ); $row->set( '_tags', false ); $row->set( '_links', false ); $title = CBTxt::T( 'ACTIVITY_OF_ACTIVITY_TITLE', '[title] [date]', array( '[title]' => $title, '[date]' => cbFormatDate( $row->get( 'date' ), true, 'timeago' ) ) ); $message = null; $footer = null; $subActivity = new Activity( 'activity', $cbUser->getUserData() ); CBActivity::loadStreamDefaults( $subActivity, $stream ); $subActivity->set( 'id', $row->get( 'item' ) ); if ( $row->get( 'subtype' ) == 'comment' ) { $subActivity->set( 'comments', 1 ); } elseif ( $row->get( 'subtype' ) == 'tag' ) { $subActivity->set( 'tags', 1 ); } $insert = $subActivity->stream( true ); if ( ! $insert ) { continue; } } else { $title = ( $title ? $cbUser->replaceUserVars( $title, false, false, $extras, false ) : null ); $message = ( $message ? $cbUser->replaceUserVars( $message, false, false, $extras, false ) : null ); } $links = array(); if ( ( ( $isStatus && $showLinks ) || ( ! $isStatus ) ) && ( $row->get( '_links' ) !== false ) ) { $links = $row->attachments(); } if ( ( $stream->source() != 'hidden' ) && $stream->get( 'comments' ) && ( $row->get( '_comments' ) !== false ) ) { $comments = $row->comments( 'activity', $cbUser->getUserData() ); if ( $comments ) { CBActivity::loadStreamDefaults( $comments, $stream, 'comments_' ); $footer .= $comments->stream( true, ( $row->get( '_comments' ) ? true : false ) ); } } $return .= '<div id="' . $rowId . '" class="streamItem streamPanel activityContainer' . ( $typeClass ? ' activityContainer' . $typeClass : null ) . ( $subTypeClass ? ' activityContainer' . $typeClass . $subTypeClass : null ) . ' panel panel-default" data-cbactivity-id="' . (int) $row->get( 'id' ) . '">' . '<div class="streamItemInner">' . '<div class="streamMedia streamPanelHeading activityContainerHeader media panel-heading clearfix">' . '<div class="streamMediaLeft activityContainerLogo media-left">' . $cbUser->getField( 'avatar', null, 'html', 'none', 'list', 0, true ) . '</div>' . '<div class="streamMediaBody activityContainerTitle media-body">' . '<div class="activityContainerTitleTop text-muted">' . '<strong>' . $cbUser->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) . '</strong>' . ( $title ? ' ' . $title : null ) . '</div>' . '<div class="activityContainerTitleBottom text-muted small">' . cbFormatDate( $row->get( 'date' ), true, 'timeago' ) . ( $row->params()->get( 'modified' ) ? ' <span class="streamIconEdited fa fa-edit" title="' . htmlspecialchars( CBTxt::T( 'Edited' ) ) . '"></span>' : null ) . ( $date ? ' ' . $date : null ) . '</div>' . '</div>' . '</div>'; if ( $message ) { $return .= '<div class="streamPanelBody streamItemDisplay activityContainerContent panel-body">' . '<div class="activityContainerContentInner cbMoreLess">' . '<div class="streamItemContent cbMoreLessContent">' . $message . '</div>' . '<div class="cbMoreLessOpen fade-edge hidden">' . '<a href="javascript: void(0);" class="cbMoreLessButton">' . CBTxt::T( 'See More' ) . '</a>' . '</div>' . '</div>' . '</div>'; } $return .= ( $insert ? '<div class="streamItemDisplay streamItemDivider activityContainerInsert border-default">' . $insert . '</div>' : null ); if ( $links ) { $return .= '<div class="streamPanelBody streamItemDisplay streamItemDivider activityContainerAttachments panel-body border-default">' . '<div class="activityContainerAttachmentsInner">' . self::showAttachments( $row, $stream, $output, $user, $viewer, $plugin ) . '</div>' . '</div>'; } $return .= ( $footer ? '<div class="streamPanelFooter streamItemDisplay activityContainerFooter panel-footer">' . $footer . '</div>' : null ); if ( $isStatus && ( $cbModerator || $rowOwner ) && $canCreate ) { $return .= self::showEdit( $row, $stream, $output, $user, $viewer, $plugin ); } if ( $cbModerator || $rowOwner || ( $viewer->get( 'id' ) && ( ! $rowOwner ) ) || $menu ) { $menuItems = '<ul class="streamItemMenuItems activityMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'; if ( $isStatus && ( $cbModerator || $rowOwner ) && $canCreate ) { $menuItems .= '<li class="streamItemMenuItem activityMenuItem"><a href="javascript: void(0);" class="activityMenuItemEdit streamItemEditDisplay" data-cbactivity-container="#' . $rowId . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>'; } if ( $viewer->get( 'id' ) && ( ! $rowOwner ) ) { if ( $stream->source() == 'hidden' ) { $menuItems .= '<li class="streamItemMenuItem activityMenuItem"><a href="' . $stream->endpoint( 'unhide', array( 'id' => (int) $row->get( 'id' ) ) ) . '" class="activityMenuItemUnhide streamItemAction" data-cbactivity-container="#' . $rowId . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Unhide' ) . '</a></li>'; } else { $menuItems .= '<li class="streamItemMenuItem activityMenuItem"><a href="' . $stream->endpoint( 'hide', array( 'id' => (int) $row->get( 'id' ) ) ) . '" class="activityMenuItemHide streamItemAction" data-cbactivity-container="#' . $rowId . '" data-cbactivity-confirm="' . htmlspecialchars( CBTxt::T( 'Are you sure you want to hide this Activity?' ) ) . '" data-cbactivity-confirm-button="' . htmlspecialchars( CBTxt::T( 'Hide Activity' ) ) . '"><span class="fa fa-times"></span> ' . CBTxt::T( 'Hide' ) . '</a></li>'; } } if ( $cbModerator || $rowOwner ) { $menuItems .= '<li class="streamItemMenuItem activityMenuItem"><a href="' . $stream->endpoint( 'delete', array( 'id' => (int) $row->get( 'id' ) ) ) . '" class="activityMenuItemDelete streamItemAction" data-cbactivity-container="#' . $rowId . '" data-cbactivity-confirm="' . htmlspecialchars( CBTxt::T( 'Are you sure you want to delete this Activity?' ) ) . '" data-cbactivity-confirm-button="' . htmlspecialchars( CBTxt::T( 'Delete Activity' ) ) . '"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'; } if ( $menu ) { $menuItems .= '<li class="streamItemMenuItem activityMenuItem">' . implode( '</li><li class="streamItemMenuItem activityMenuItem">', $menu ) . '</li>'; } $menuItems .= '</ul>'; $menuAttr = cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="fa fa-chevron-down text-muted" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle" data-cbtooltip-open-classes="open"' ); $return .= '<div class="streamItemMenu activityContainerMenu">' . '<span ' . trim( $menuAttr ) . '></span>' . '</div>'; } $return .= '</div>' . '</div>'; } elseif ( $output != 2 ) { $return .= '<div class="streamItemEmpty text-center text-muted small">'; if ( $output == 1 ) { $return .= CBTxt::T( 'No more activity to display.' ); } else { $return .= CBTxt::T( 'No activity to display.' ); } $return .= '</div>'; } elseif ( ( $output == 2 ) && ( ! $newForm ) ) { return null; } $return .= ( ! in_array( $output, array( 1, 4 ) ) ? '</div>' : null ) . ( ! $stream->direction() ? $moreButton : $newForm ) . ( ! in_array( $output, array( 1, 4 ) ) ? '</div>' : null ) . CBActivity::reloadHeaders( $output ); $_PLUGINS->trigger( 'activity_onAfterDisplayActivity', array( &$return, $rows, $stream, $output ) ); return $return; }
/** * @param string $message * @param UserTable $row * @param int $mode * @param array $extras * @return string */ public function _replaceVariables($message, $row, $mode = 0, $extras = array()) { global $_CB_framework, $ueConfig; // Always build the confirm link for substitution: $confirmLink = $_CB_framework->rawViewUrl('confirm', false, array('confirmcode' => $row->cbactivation)); // Lets build the confirm output only if confirmation is enabled: if ($ueConfig['reg_confirmation'] == 1) { if ($row->confirmed) { $confirm = "\n" . CBTxt::T('UE_USER_EMAIL_CONFIRMED', 'Email address is already confirmed') . "\n"; } else { $confirm = "\n" . $confirmLink . "\n"; } } else { $confirm = null; } // Lets fix linebreaks encase the message was sent as a plain string: $message = str_replace(array('\\r\\n', '\\n'), array("\r\n", "\n"), $message); // Prepare default substitution extras (note how we push some normal substitutions as extras so non-existing users can still substitute information): $extraStrings = array('emailaddress' => $row->email, 'email' => $row->email, 'formatname' => getNameFormat($row->name, $row->username, $ueConfig['name_format']), 'name' => $row->name, 'username' => $row->username, 'details' => $this->_getUserDetails($row, isset($ueConfig['emailpass']) ? $ueConfig['emailpass'] : 0), 'confirm' => $confirm, 'confirmlink' => $confirmLink, 'sitename' => $_CB_framework->getCfg('sitename'), 'siteurl' => $_CB_framework->getCfg('live_site')); // Combine default substitutions with extras supplied: if ($extras && is_array($extras)) { $extraStrings = array_merge($extraStrings, $extras); } if ($row instanceof UserTable && $row->id) { return CBuser::getInstance($row->id)->replaceUserVars($message, true, true, $extraStrings, false); } return cbReplaceVars($message, $row, $mode, true, $extraStrings, false); }
/** * Returns HTML or TEXT rendering the validity period and pricing for that given plan. * (public because can be used as call-back in onCPayAfterDisplayProductPeriodPrice event handlers) * * @param float $price price of plan * @param float|null $firstPeriodFullPrice regular price of plan in first period * @param float|null $firstPeriodPrice real price of plan in first period (with discount) * @param boolean $prorateDiscount is a discount applied to first price ? * @param int $expiryTime expiry time of plan * @param int $startTime starting time of plan * @param boolean $autorecurring is plan autorecurring ? * @param int $recurring_max_times if autorecurring, maximum total number of occurrences * @param string $reason payment reason: 'N'=new subscription (default), 'R'=renewal, 'U'=update * @param int $occurrence Occurence of the payment for that item * @param boolean $html TRUE for HTML, FALSE for TEXT * @param boolean $roundings TRUE: do round, FALSE: do not round display * @param boolean $displayPeriod TRUE: display price and period, FALSE: display price only (ONLY for single prices) * @param boolean $displaySecondaryCurrency TRUE: display secondary currencies, FALSE: only display in $this->currency() * @return string HTML or TEXT */ public function renderPeriodPrice( $price, $firstPeriodFullPrice, $firstPeriodPrice, $prorateDiscount, $expiryTime, $startTime, $autorecurring, $recurring_max_times, $reason, $occurrence, $html, $roundings = true, $displayPeriod = true, $displaySecondaryCurrency = true ) { global $_CB_framework; $params =& cbpaidApp::settingsParams(); $return = ''; $priceDisplay = $this->getPriceDisplay(); // This is used in this class if available (it's actually only available in derived class cbpaidProduct and in all its derived classes) if ( $priceDisplay == null ) { $priceDisplay = '[automatic]'; } else { $priceDisplay = ( $html ? CBPTXT::Th( $priceDisplay ) : CBPTXT::T( $priceDisplay ) ); } $period_for_price_text = $params->get('period_for_price_text', '%1s%2s%3s' ); $textFor = ' ' . ( $html ? CBPTXT::Th($params->get('regtextFor')) : CBPTXT::T($params->get('regtextFor')) ) . ' '; $priceText = $this->renderPricesWithConversion( $price, $html, $roundings, $displaySecondaryCurrency ); if ( $firstPeriodFullPrice !== null ) { $firstPeriodFullPriceText = $this->renderPricesWithConversion( $firstPeriodFullPrice, $html, $roundings, $displaySecondaryCurrency ); } else { $firstPeriodFullPriceText = null; } if ( $firstPeriodPrice !== null ) { $discountedPriceText = $this->renderPricesWithConversion( $firstPeriodPrice, $html, $roundings, $displaySecondaryCurrency ); } else { $discountedPriceText = null; } if ( $firstPeriodFullPrice !== null ) { $effectiveFirstPeriodFullPrice = $firstPeriodFullPrice; $effectiveFirstPeriodFullPriceText = $firstPeriodFullPriceText; } else { $effectiveFirstPeriodFullPrice = $price; $effectiveFirstPeriodFullPriceText = $priceText; } $firstPeriodRendered = null; if ( ( $this->bonustime!='0000-00-00 00:00:00' && $reason!='R') || ( ( $firstPeriodPrice || $prorateDiscount ) && ( $effectiveFirstPeriodFullPrice != $firstPeriodPrice ) ) ) { if ( ( $firstPeriodPrice || $prorateDiscount ) && ( $effectiveFirstPeriodFullPrice != $firstPeriodPrice ) ) { if ( $autorecurring ) { if ( $reason == 'U' ) { if ( $prorateDiscount ) { $subTxt = CBPTXT::T( $params->get( 'subscription_name', 'subscription' ) ); $t = sprintf( CBPTXT::T("The first payment of the upgrade for %s, taking in account your current %s, is %s instead of %s."), '%s', $subTxt, '%s', '%s' ); } else { $t = CBPTXT::T("The first payment of the upgrade for %s is %s instead of %s."); } } elseif ( $reason == 'R' ) { if ( $prorateDiscount ) { $t = CBPTXT::T("The first payment of the renewal for %s, pro-rata temporis, is %s instead of %s."); } else { $t = CBPTXT::T("The first payment of the renewal for %s is %s instead of %s."); } } else { if ( $prorateDiscount ) { $t = CBPTXT::T("The first payment for %s, pro-rata temporis, is %s instead of %s."); } else { $t = CBPTXT::T("The first payment for %s is %s instead of %s."); } } } else { if ( $reason == 'U' ) { if ( $prorateDiscount ) { $subTxt = CBPTXT::T( $params->get( 'subscription_name', 'subscription' ) ); $t = sprintf( CBPTXT::T("The price of the upgrade for %s, taking in account your current %s, is %s instead of %s."), '%s', $subTxt, '%s', '%s' ); } else { $t = CBPTXT::T("The price of the upgrade for %s is %s instead of %s."); } } elseif ( $reason == 'R' ) { if ( $prorateDiscount ) { $t = CBPTXT::T("The price of the renewal for %s, pro-rata temporis, is %s instead of %s."); } else { $t = CBPTXT::T("The price of the renewal for %s is %s instead of %s."); } } else { if ( $prorateDiscount ) { $t = CBPTXT::T("The price for %s, pro-rata temporis, is %s instead of %s."); } else { $t = CBPTXT::T("The price for %s is %s instead of %s."); } } } $varName = $this->getPlanVarName( $reason, $occurrence, 'validity' ); $firstPeriodRendered = sprintf( $t, $this->getFormattedValidity( $expiryTime, $startTime, $varName, $reason, 1, true, $html ), $discountedPriceText, $effectiveFirstPeriodFullPriceText ); } else { if ( $autorecurring ) { if ( $reason == 'U' ) { $t = CBPTXT::T("The first period for the upgrade will be %s."); } elseif ( $reason == 'R' ) { $t = CBPTXT::T("The first period for the renewal will be %s."); } else { $t = CBPTXT::T("The first period will be %s."); } $varName = $this->getPlanVarName( $reason, $occurrence, 'validity' ); $firstPeriodRendered = sprintf( $t, $this->getFormattedValidity( $expiryTime, $startTime, $varName, $reason, 1, true, $html ) ); } } } cbimport( 'cb.tabs' ); //needed for CBuser and replacements if ( ( $firstPeriodFullPrice === null ) && ! $autorecurring ) { $validityText = $this->getFormattedValidity( $expiryTime, $startTime, 'validity', $reason, 1, true, $html ); if ( ( $validityText != '' ) && $displayPeriod ) { $period = $this->_span( $validityText, $html, 'cbregTimeframe', false ); $for = $this->_span( $textFor , $html, 'cbregFor', false ); } else { $period = ''; // in case 'lifetime' text is '' $for = ''; } if ( $priceText != '' ) { $money = $this->_span( $priceText , $html, 'cbregRate', false ); } else { $for = ''; // in case 'Free' text is '' $money = ''; } $automatic = sprintf( $period_for_price_text, $period, $for, $money ); if ( strtolower( $priceDisplay ) == '[automatic]' ) { $return .= $automatic; } else { $per = $this->_span( ' ' . ( $html ? CBPTXT::Th("per") : CBPTXT::T("per") ) . ' ' , $html, 'cbregFor', false ); $cbUser = CBuser::getInstance( $_CB_framework->myId() ); $return = $cbUser->replaceUserVars( $priceDisplay, true, false ); $return = str_ireplace( array( '[price]', '[for]', '[period]', '[per]', '[automatic]' ), array( $money, $for, $period, $per, $automatic ), $return ); } } else { if ( $firstPeriodFullPrice !== null ) { $moneyFirst = $this->_span( $firstPeriodFullPriceText , $html, 'cbregRate', false ); $forFirst = $this->_span( $textFor , $html, 'cbregFor', false ); $varName = $this->getPlanVarName( $reason, $occurrence, 'validity' ); $periodFirst = $this->_span( $this->_renderPeriodOfValiditiy( $varName, 1 ) , $html, 'cbregTimeframe' ); $then = $this->_span( ( $html ? CBPTXT::Th(", then ") : CBPTXT::T(", then ") ) , $html, 'cbregFor', false ); // $automatic .= $this->_timedObject->getFormattedValidity( $expiryTime, $startTime, false ); $automatic = sprintf( $period_for_price_text, $periodFirst, $forFirst, $moneyFirst ) . $then; } else { $moneyFirst = null; $forFirst = null; $periodFirst = null; $then = null; $automatic = ''; } $money = $this->_span( $priceText , $html, 'cbregRate', false ); if ( $price ) { $per = $this->_span( ' ' . ( $html ? CBPTXT::Th("per") : CBPTXT::T("per") ) . ' ' , $html, 'cbregFor', false ); $period = $this->_span( $this->_renderPeriodOfValiditiy( 'validity', 1, false ) , $html, 'cbregTimeframe' ); $automatic .= sprintf( '%3$s%2$s%1$s', $period, $per, $money ); } else { $per = null; $period = null; $automatic .= $money; } if ( $recurring_max_times ) { $during = $this->_span( ', ' . ( $html ? CBPTXT::Th("during") : CBPTXT::T("during") ) . ' ', $html, 'cbregFor', false ); $periodTot = $this->_span( $this->_renderPeriodOfValiditiy( 'validity', $recurring_max_times, true, false ) , $html, 'cbregTimeframe' ); $automatic .= $during . $periodTot; } else { $during = null; $periodTot = null; } if ( strtolower( $priceDisplay ) == '[automatic]' ) { $return .= $automatic; } else { $cbUser = CBuser::getInstance( $_CB_framework->myId() ); $return = $cbUser->replaceUserVars( $priceDisplay, true, false ); $return = str_ireplace( array( '[price]', '[per]', '[period]', '[for]', '[firstperiod]', '[firstfor]', '[firstprice]', '[then]', '[during]', '[totalperiod]', '[automatic]' ), array( $money, $per, $period, $textFor, $periodFirst, $forFirst, $moneyFirst, $then, $during, $periodTot, $automatic ), $return ); } } if ( $firstPeriodRendered ) { $return .= ' ' . $this->_span( $firstPeriodRendered , $html, 'cbregDiscountRate', false ); } return $return; }