本文整理汇总了PHP中CBuser类的典型用法代码示例。如果您正苦于以下问题:PHP CBuser类的具体用法?PHP CBuser怎么用?PHP CBuser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBuser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onContentBeforeDisplay
/**
* @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;
}
}
}
示例2: activityQuery
/**
* @param bool $count
* @param array $select
* @param array $where
* @param array $join
* @param CB\Plugin\Activity\Activity $stream
*/
public function activityQuery( $count, &$select, &$where, &$join, &$stream )
{
global $_CB_database;
$join[] = 'LEFT JOIN ' . $_CB_database->NameQuote( '#__groupjive_plugin_photo' ) . ' AS gj_p'
. ' ON a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' )
. ' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' = ' . $_CB_database->Quote( 'group.photo' )
. ' AND a.' . $_CB_database->NameQuote( 'item' ) . ' = gj_p.' . $_CB_database->NameQuote( 'id' );
if ( ! CBGroupJive::isModerator() ) {
$user = CBuser::getMyUserDataInstance();
$where[] = '( ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' )
. ' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' = ' . $_CB_database->Quote( 'group.photo' )
. ' AND gj_p.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL'
. ' AND ( gj_p.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $user->get( 'id' )
. ' OR ( gj_p.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
. ' AND ( gj_g.' . $_CB_database->NameQuote( 'type' ) . ' IN ( 1, 2 )'
. ' OR gj_u.' . $_CB_database->NameQuote( 'status' ) . ' > 0 ) ) ) )'
. ' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' != ' . $_CB_database->Quote( 'groupjive' )
. ' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' )
. ' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' != ' . $_CB_database->Quote( 'group.photo' ) . ' ) ) )';
} else {
$where[] = '( ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' )
. ' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' = ' . $_CB_database->Quote( 'group.photo' )
. ' AND gj_p.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL )'
. ' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' != ' . $_CB_database->Quote( 'groupjive' )
. ' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' )
. ' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' != ' . $_CB_database->Quote( 'group.photo' ) . ' ) ) )';
}
}
示例3: getAvatar
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;
}
示例4: _getURL
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');
}
示例5: showAbout
/**
* 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 )
);
}
示例6: getCBpluginComponent
/**
* @param TabTable $tab Current tab
* @param UserTable $user Current user
* @param int $ui 1 front, 2 admin UI
* @param array $postdata Raw unfiltred POST data
* @return string HTML
*/
public function getCBpluginComponent( $tab, $user, $ui, $postdata )
{
$format = $this->input( 'format', null, GetterInterface::STRING );
if ( $format != 'raw' ) {
outputCbJs();
outputCbTemplate();
}
$action = $this->input( 'action', null, GetterInterface::STRING );
$function = $this->input( 'func', null, GetterInterface::STRING );
$id = (int) $this->input( 'id', null, GetterInterface::INT );
$user = CBuser::getMyUserDataInstance();
if ( $format != 'raw' ) {
ob_start();
}
switch ( $action ) {
case 'wall':
switch ( $function ) {
case 'publish':
$this->stateWall( 1, $id, $user );
break;
case 'unpublish':
$this->stateWall( 0, $id, $user );
break;
case 'delete':
$this->deleteWall( $id, $user );
break;
case 'new':
$this->showWallEdit( null, $user );
break;
case 'edit':
$this->showWallEdit( $id, $user );
break;
case 'save':
cbSpoofCheck( 'plugin' );
$this->saveWallEdit( $id, $user );
break;
}
break;
}
if ( $format != 'raw' ) {
$html = ob_get_contents();
ob_end_clean();
$class = $this->_gjParams->get( 'general_class', null );
$return = '<div class="cbGroupJive' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
. '<div class="cbGroupJiveInner">'
. $html
. '</div>'
. '</div>';
echo $return;
}
}
示例7: getAvatar
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;
}
示例8: showTags
/**
* @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;
}
示例9: getProfileURL
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 );
}
示例10: showBlog
/**
* @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;
}
示例11: showconsultation
/**
* @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;
}
示例12: replaceCbVars
/**
* 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;
}
}
示例13: getCBpluginComponent
/**
* @param null $tab
* @param UserTable $user
* @param int $ui
* @param array $postdata
*/
public function getCBpluginComponent( $tab, $user, $ui, $postdata )
{
global $_CB_framework;
outputCbJs( 1 );
outputCbTemplate( 1 );
$action = $this->input( 'action', null, GetterInterface::STRING );
$function = $this->input( 'func', null, GetterInterface::STRING );
$id = $this->input( 'id', null, GetterInterface::INT );
$user = CBuser::getMyUserDataInstance();
$tab = new TabTable();
$tab->load( array( 'pluginclass' => 'cbinvitesTab' ) );
$profileUrl = $_CB_framework->userProfileUrl( $user->get( 'id' ), false, 'cbinvitesTab' );
if ( ! ( $tab->enabled && Application::MyUser()->canViewAccessLevel( $tab->viewaccesslevel ) ) ) {
cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
}
ob_start();
switch ( $action ) {
case 'preparaty':
switch ( $function ) {
case 'delete':
$this->deletePreparaty( $id, $user );
break;
}
break;
default:
cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
break;
}
$html = ob_get_contents();
ob_end_clean();
$class = $this->params->get( 'general_class', null );
$return = '<div id="cbInvites" class="cbInvites' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
. '<div id="cbInvitesInner" class="cbInvitesInner">'
. $html
. '</div>'
. '</div>';
echo $return;
}
示例14: showWhitelist
/**
* @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;
}
示例15: sqlCleanQuote
/**
* Cleans the field value by type in a secure way for SQL
*
* @param mixed $fieldValue
* @param string $type const,sql,param : string,int,float,datetime,formula
* @param GetterInterface $pluginParams
* @param DatabaseDriverInterface $db
* @param array|null $extDataModels
* @return string|boolean STRING: sql-safe value, Quoted or type-casted to int or float, or FALSE in case of type error
*/
public static function sqlCleanQuote($fieldValue, $type, GetterInterface $pluginParams, DatabaseDriverInterface $db, array $extDataModels = null)
{
$typeArray = explode(':', $type, 3);
if (count($typeArray) < 2) {
$typeArray = array('const', $type);
}
if ($typeArray[0] == 'param') {
$fieldValue = $pluginParams->get($fieldValue);
} elseif ($typeArray[0] == 'user') {
// TODO: Change this to use Inversion Of Control, and allow XML valuetypes to be extended dynamically (e.g. instead of calling specifically CBLib\CB\User or similar when available, it is CB that adds the type and a closure to handle that type.
if ($fieldValue == 'viewaccesslevels') {
$fieldValue = Application::MyUser()->getAuthorisedViewLevels();
} else {
if ($fieldValue == 'usergroups') {
$fieldValue = Application::MyUser()->getAuthorisedGroups(false);
} else {
$fieldValue = \CBuser::getMyUserDataInstance()->get($fieldValue);
}
}
} elseif (in_array($typeArray[0], array('request', 'get', 'post', 'cookie', 'cbcookie', 'session', 'server', 'env'))) {
$fieldValue = self::_globalConv($typeArray[0], $fieldValue);
} elseif ($typeArray[0] == 'ext') {
if (isset($typeArray[2]) && $extDataModels && isset($extDataModels[$typeArray[2]])) {
$model = $extDataModels[$typeArray[2]];
if (is_object($model)) {
if ($model instanceof ParamsInterface) {
$fieldValue = $model->get($fieldValue);
} elseif (isset($model->{$fieldValue})) {
$fieldValue = $model->{$fieldValue};
}
} elseif (is_array($model)) {
if (isset($model[$fieldValue])) {
$fieldValue = $model[$fieldValue];
}
} else {
$fieldValue = $model;
}
} else {
trigger_error('SQLXML::sqlCleanQuote: ERROR: ext valuetype "' . htmlspecialchars($type) . '" has not been setExternalDataTypeValues.', E_USER_NOTICE);
}
// } elseif ( ( $typeArray[0] == 'const' ) || ( $cnt_valtypeArray[0] == 'sql' ) {
// $fieldValue = $fieldValue;
}
if (is_array($fieldValue)) {
return self::cleanArrayType($fieldValue, $typeArray[1], $db);
}
return self::cleanScalarType($fieldValue, $typeArray[1], $db);
}