本文整理汇总了PHP中CBuser::getMyInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP CBuser::getMyInstance方法的具体用法?PHP CBuser::getMyInstance怎么用?PHP CBuser::getMyInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuser
的用法示例。
在下文中一共展示了CBuser::getMyInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCBprofileItemid
/**
* gets Itemid of CB profile, or by default of homepage
* (If possible, use $_CB_framework->userProfiler...Url and ->viewUrl from CB 1.2.3 on)
*
* @param boolean $htmlspecialchars TRUE if should return "&:Itemid...." instead of "&Itemid..." (with FALSE as default), === 0 if return only int
* @param string $task task/view e.g. 'userslist' (since CB 1.2.3)
* @return string "&Itemid=xxx"
*/
function getCBprofileItemid($htmlspecialchars = false, $task = 'userprofile')
{
global $_CB_database, $_CB_framework;
static $cacheItemids = array();
if (!isset($cacheItemids[$task])) {
if (class_exists('moscomprofilerUser', false)) {
$viewLevels = CBuser::getMyInstance()->getAuthorisedViewLevelsIds(checkJversion() >= 2 ? false : true);
} else {
// Compute View Level using CMS without loading cb.table and cb.database if they are not already loaded (e.g. when using this function in modules):
if (checkJversion() >= 2) {
$viewLevels = JUser::getInstance()->getAuthorisedViewLevels();
} else {
$viewLevels = range(0, $_CB_framework->myCmsGid());
}
}
$cleanedANDpubAccess = ' AND published = 1 AND access IN (' . implode(',', cbArrayToInts($viewLevels)) . ')';
if (checkJversion() >= 2) {
$cleanedANDpubAccess .= ' AND ' . $_CB_database->NameQuote('language') . ' IN ( ' . $_CB_database->Quote($_CB_framework->getCfg('lang_tag')) . ', ' . $_CB_database->Quote('*') . ', ' . $_CB_database->Quote('') . ' )';
}
if ($task !== 'userprofile' && is_string($task)) {
$_CB_database->setQuery('SELECT id FROM #__menu WHERE link LIKE ' . $_CB_database->Quote('index.php?option=com_comprofiler&task=' . $_CB_database->getEscaped($task, true) . '%', false) . $cleanedANDpubAccess);
$Itemid = (int) $_CB_database->loadResult();
} else {
$Itemid = null;
}
if ($task === 'userprofile' || !$Itemid && !in_array($task, array('login', 'logout', 'registers', 'lostpassword'))) {
// $task used to be a boolean before CB 1.2.3 but with no effect:
$task = 'userprofile';
$_CB_database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_comprofiler'" . $cleanedANDpubAccess);
$Itemid = (int) $_CB_database->loadResult();
if (!$Itemid) {
// if no user profile, try getting itemid of the default list:
$_CB_database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_comprofiler&task=usersList'" . $cleanedANDpubAccess);
$Itemid = (int) $_CB_database->loadResult();
}
}
$cacheItemids[$task] = $Itemid;
}
if ($cacheItemids[$task]) {
if (is_bool($htmlspecialchars)) {
return ($htmlspecialchars ? "&" : "&") . "Itemid=" . $cacheItemids[$task];
} else {
return $cacheItemids[$task];
}
} else {
return null;
}
}
示例2: getDisplayTab
function getDisplayTab($tab, $user, $ui)
{
global $_CB_framework, $_CB_database, $mainframe;
$jVer = checkJversion();
$showHits = $_CB_framework->getCfg('hits');
$showRating = $_CB_framework->getCfg('vote');
$return = '';
if ($jVer >= 2) {
$curTz = date_default_timezone_get();
date_default_timezone_set('UTC');
$now = date('Y-m-d H:i:s');
date_default_timezone_set($curTz);
} else {
$now = date('Y-m-d H:i:s', $_CB_framework->now() + $_CB_framework->getCfg('offset') * 60 * 60);
}
$query = "SELECT a.id, a.catid, a.title, a.hits,a.created, ROUND( r.rating_sum / r.rating_count ) AS rating,r.rating_count";
if ($jVer >= 1) {
$query .= ', CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug';
}
$query .= "\n FROM #__content AS a" . "\n LEFT JOIN #__content_rating AS r ON r.content_id=a.id";
if ($jVer < 2) {
$query .= "\n INNER JOIN #__sections AS s ON s.id=a.sectionid AND s.title != 'Mamblog'";
}
if ($jVer >= 1) {
$query .= "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid";
}
$query .= "\n WHERE a.created_by=" . (int) $user->id . "" . "\n AND a.state = 1 " . "\n AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= '{$now}')" . "\n AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= '{$now}')" . "\n AND a.access IN (" . implode(',', CBuser::getMyInstance()->getAuthorisedViewLevelsIds($jVer >= 2 ? false : true)) . ')' . "\n ORDER BY a.created DESC";
$_CB_database->setQuery($query);
//print $_CB_database->getQuery();
$items = $_CB_database->loadObjectList();
if (!count($items) > 0) {
$return .= "<br /><br /><div class=\"cbNoArticles\" style=\"width:95%;\">";
$return .= _UE_NOARTICLES;
$return .= "</div>";
return $return;
}
$return .= $this->_writeTabDescription($tab, $user);
$return .= "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"95%\">";
$return .= "<tr class=\"sectiontableheader\">";
$return .= "<th>" . _UE_ARTICLEDATE . "</th>";
$return .= "<th>" . _UE_ARTICLETITLE . "</th>";
if ($showHits) {
$return .= "<th>" . _UE_ARTICLEHITS . "</th>";
}
if ($showRating) {
$return .= "<th>" . _UE_ARTICLERATING . "</th>";
}
$return .= "</tr>";
$i = 1;
$hits = "";
$rating = "";
foreach ($items as $item) {
if (isset($mainframe) && is_callable(array($mainframe, "getItemid"))) {
$itemid = $mainframe->getItemid($item->id);
} elseif (is_callable("JApplicationHelper::getItemid")) {
$itemid = JApplicationHelper::getItemid($item->id);
} else {
$itemid = null;
}
$itemidtxt = $itemid ? "&Itemid=" . (int) $itemid : "";
$i = $i == 1 ? 2 : 1;
if (is_callable(array("mosAdminMenus", "ImageCheck"))) {
$starImageOn = mosAdminMenus::ImageCheck('rating_star.png', '/images/M_images/');
$starImageOff = mosAdminMenus::ImageCheck('rating_star_blank.png', '/images/M_images/');
} else {
// Mambo 4.5.0:
$starImageOn = '<img src="' . $_CB_framework->getCfg('live_site') . '/images/M_images/rating_star.png" alt="" align="middle" style="border:0px;" />';
$starImageOff = '<img src="' . $_CB_framework->getCfg('live_site') . '/images/M_images/rating_star_blank.png" alt="" align="middle" style="border:0px;" />';
}
$img = "";
if ($showRating) {
for ($j = 0; $j < $item->rating; $j++) {
$img .= $starImageOn;
}
for ($j = $item->rating; $j < 5; $j++) {
$img .= $starImageOff;
}
$rating = '<td><span class="content_rating">';
$rating .= $img . ' / ';
$rating .= intval($item->rating_count);
$rating .= "</span></td>\n";
}
if ($showHits) {
$hits = "<td>" . $item->hits . "</td>";
}
if ($jVer == 2) {
require_once $_CB_framework->getCfg('absolute_path') . '/components/com_content/helpers/route.php';
$url = ContentHelperRoute::getArticleRoute($item->id, $item->catid);
if (!stristr($url, 'Itemid')) {
$url = $_CB_framework->getCfg('live_site') . '/' . $url;
} else {
$url = cbSef($url);
}
} elseif ($jVer == 1) {
$url = cbSef('index.php?option=com_content&view=article&id=' . $item->slug . '&catid=' . $item->catslug . $itemidtxt);
} else {
$url = cbSef('index.php?option=com_content&task=view&id=' . (int) $item->id . $itemidtxt);
}
$return .= "<tr class=\"sectiontableentry{$i}\"><td>" . cbFormatDate($item->created) . "</td><td><a href=\"" . $url . "\">" . $item->title . "</a></td>" . $hits . $rating . "</tr>\n";
}
//.........这里部分代码省略.........
示例3: prepareFieldDataSave
/**
* Prepares field data for saving to database (safe transfer from $postdata to $user)
* Override
*
* @param moscomprofilerFields $field
* @param moscomprofilerUser $user RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
* @param array $postdata Typically $_POST (but not necessarily), filtering required.
* @param string $reason 'edit' for save profile edit, 'register' for registration, 'search' for searches
*/
function prepareFieldDataSave(&$field, &$user, &$postdata, $reason)
{
$this->_prepareFieldMetaSave($field, $user, $postdata, $reason);
global $_CB_framework, $ueConfig;
// Nb. frontend registration setting of usertype, gid, block, sendEmail, confirmed, approved
// are handled in moscomprofilerUser::bindSafely() so they are available to other plugins.
// this is (for now) handled in the core of CB... except params and block/email/approved/confirmed:
if ($_CB_framework->getUi() == 2) {
$canBlockUser = CBuser::getMyInstance()->authoriseAction('core.edit.state', 'com_users');
if ($canBlockUser) {
if (checkJversion() == 2) {
$user->gids = cbGetParam($postdata, 'gid', array(0));
$user->gid = (int) $_CB_framework->acl->getBackwardsCompatibleGid($user->gids);
} else {
$user->gid = cbGetParam($postdata, 'gid', 0);
$user->gids = array($user->gid);
}
if (isset($postdata['block'])) {
$user->block = cbGetParam($postdata, 'block', 0);
}
if (isset($postdata['approved'])) {
$user->approved = cbGetParam($postdata, 'approved', 0);
}
if (isset($postdata['confirmed'])) {
$user->confirmed = cbGetParam($postdata, 'confirmed', 0);
}
if (isset($postdata['sendEmail'])) {
$user->sendEmail = cbGetParam($postdata, 'sendEmail', 0);
}
}
}
if ($_CB_framework->getUi() == 2 || (isset($ueConfig['frontend_userparams']) ? $ueConfig['frontend_userparams'] == 1 : in_array($_CB_framework->getCfg("frontend_userparams"), array('1', null)))) {
// save user params
$params = cbGetParam($_POST, 'params', null);
//TBD: verify if stripslashes is needed here: it might be needed...leaving as is for now.
if ($params != null) {
if (is_array($params)) {
if (checkJversion() == 2) {
$registry = new JRegistry($params);
$value = $registry->toArray();
$valueString = $registry->toString();
} else {
$txt = array();
foreach ($params as $k => $v) {
$txt[] = $k . '=' . $v;
}
$value = implode("\n", $txt);
$valueString = $value;
}
if ((string) $user->params !== (string) $valueString) {
$this->_logFieldUpdate($field, $user, $reason, $user->params, $value);
}
$user->params = $value;
}
}
} else {
if (checkJversion() == 2) {
// Joomla 2.5 has a bug, where an untouched $user->params string is not saved correctly: So let's workaround this here:
if ($user->id) {
$juser = JUser::getInstance($user->id);
} else {
$juser = JUser::getInstance();
}
$user->params = $juser->getParameters(true)->toArray();
}
}
}
示例4: saveSafely
/**
* Saves a new or existing CB+CMS user
* WARNINGS:
* - You must verify authorization of user to perform this (user checkCBpermissions() )
* - You must $this->load() existing user first
*
* @param array $array Raw unfiltered input, typically $_POST
* @param int $ui 1 = Front-end (limitted rights), 2 = Backend (almost unlimitted), 0 = automated (full)
* @param string $reason 'edit' or 'register'
* @return boolean
*/
function saveSafely(&$array, $ui, $reason)
{
global $_CB_framework, $_CB_database, $ueConfig, $_PLUGINS;
// Get current user state and store it into $oldUserComplete:
$oldUserComplete = new moscomprofilerUser($this->_db);
foreach (array_keys(get_object_vars($this)) as $k) {
if (substr($k, 0, 1) != '_') {
// ignore internal vars
$oldUserComplete->{$k} = $this->{$k};
}
}
if ($oldUserComplete->gids === null) {
$oldUserComplete->gids = array();
}
// 1) Process and validate the fields in form by CB field plugins:
// 2) Bind the fields to CMS User:
$bindResults = $this->bindSafely($array, $ui, $reason, $oldUserComplete);
if ($bindResults) {
// During bindSafely, in saveTabContents, the validations have already taken place, for mandatory fields.
if ($this->name == '' && $this->username == '' && $this->email != '') {
$this->username = $this->email;
$this->_cmsUser->username = $this->username;
}
// Checks that name is set. If not, uses the username as name, as Mambo/Joola mosUser::store() uses name for ACL
// and ACL bugs with no name.
if ($this->name == '') {
$this->name = $this->username;
$this->_cmsUser->name = $this->name;
} elseif ($this->username == '') {
$this->username = $this->name;
$this->_cmsUser->username = $this->username;
}
if (!$this->checkSafely()) {
$bindResults = false;
}
}
// For new registrations or backend user creations, set registration date and password if neeeded:
$isNew = !$this->id;
$newCBuser = $oldUserComplete->user_id == null;
if ($isNew) {
if (checkJversion() != 1) {
// J1.5 works better with null here... has bug that it offsets the time by server date, others need this:
$this->registerDate = $_CB_framework->dateDbOfNow();
}
}
if ($bindResults) {
if ($isNew) {
if ($this->password == null) {
$this->setRandomPassword();
$ueConfig['emailpass'] = 1;
// set this global to 1 to force password to be sent to new users.
}
}
// In backend only: if group has been changed and where original group was a Super Admin: check if there is at least a super-admin left:
if ($ui == 2) {
$myGids = $_CB_framework->acl->get_groups_below_me(null, true);
$cms_admin = $_CB_framework->acl->mapGroupNamesToValues('Administrator');
$cms_super_admin = $_CB_framework->acl->mapGroupNamesToValues('Superadministrator');
$i_am_super_admin = $_CB_framework->acl->amIaSuperAdmin();
$i_am_admin = in_array($cms_admin, $myGids);
if (!$isNew) {
if (checkJversion() == 2) {
if ($i_am_super_admin && $_CB_framework->myId() == $this->id) {
// Check that a fool Super User does not block himself:
if ($this->block && !$oldUserComplete->block) {
$this->_error = 'Super Users can not block themselves';
return false;
}
// Check that a fool Super User does not demote himself from Super-User rights:
if ($this->gids != $oldUserComplete->gids) {
$staysSuperUser = $_CB_framework->acl->authorizeGroupsForAction($this->gids, 'core.admin', null);
if (!$staysSuperUser) {
$this->_error = 'You cannot demote yourself from your Super User permission';
return false;
}
}
}
// Check that a non-Super User/non-admin does not demote an admin or a Super user:
if ($this->gids != $oldUserComplete->gids) {
if (!$i_am_super_admin && !(CBuser::getMyInstance()->authoriseAction('core.admin') || CBuser::getMyInstance()->authoriseAction('core.manage', 'com_users') && CBuser::getMyInstance()->authoriseAction('core.edit', 'com_users') && CBuser::getMyInstance()->authoriseAction('core.edit.state', 'com_users'))) {
// I am not a Super User and not an Users administrator:
$userIsSuperUser = JUser::getInstance($this->id)->authorise('core.admin');
// User is super-user: Check if he stays so:
if ($userIsSuperUser) {
$staysSuperUser = $_CB_framework->acl->authorizeGroupsForAction($this->gids, 'core.admin', null);
if (!$staysSuperUser) {
$this->_error = 'You cannot remove a Super User permission. Only Super Users can do that.';
return false;
}
//.........这里部分代码省略.........
示例5: editPluginView
/**
* render backend edit plugin view
*
* @param object $row
* @param string $option
* @param string $task
* @param int $uid
* @param string $action
* @param string $element
* @param int $mode
* @param object $pluginParams
*/
public function editPluginView( $row, $option, $task, $uid, $action, $element, $mode, $pluginParams ) {
global $_CB_framework, $_CB_database, $_CB_Backend_Menu, $_CB_Backend_task, $_GJ_Backend_Title, $_PLUGINS;
if ( ! CBuser::getMyInstance()->authoriseAction( 'core.manage' ) ) {
cbRedirect( $_CB_framework->backendUrl( 'index.php' ), _UE_NOT_AUTHORIZED, 'error' );
}
outputCbJs( 2 );
outputCbTemplate( 2 );
$plugin = cbgjClass::getPlugin();
$_CB_framework->document->addHeadStyleSheet( $plugin->livePath . '/admin.' . $plugin->element . '.css' );
require_once( $plugin->absPath . '/admin.' . $plugin->element . '.html.php' );
$_CB_Backend_task = $task;
$_GJ_Backend_Title = array();
$_CB_Backend_Menu->mode = $plugin->element . 'Admin';
$actions = explode( '.', $action );
$action = ( isset( $actions[0] ) ? $actions[0] : null );
$function = ( isset( $actions[1] ) ? $actions[1] : null );
$id = cbGetParam( $_REQUEST, 'id', array( 0 ) );
$order = cbGetParam( $_REQUEST, 'order', array( 0 ) );
$user =& CBuser::getUserDataInstance( $_CB_framework->myId() );
if ( ! is_array( $id ) ) {
$id = array( $id );
}
if ( ! $id ) {
$id = array( 0 );
}
if ( ! is_array( $order ) ) {
$order = array( $order );
}
if ( ! $order ) {
$order = array( 0 );
}
$save_mode = ( $mode == 'applyPlugin' ? 'apply' : $function );
ob_start();
switch ( $action ) {
case 'categories':
switch ( $function ) {
case 'menu':
$this->createCategoryMenu( $id[0], $user, $plugin );
break;
case 'publish':
cbSpoofCheck( 'plugin' );
$this->stateCategory( $id, 1, $user, $plugin );
break;
case 'unpublish':
cbSpoofCheck( 'plugin' );
$this->stateCategory( $id, 0, $user, $plugin );
break;
case 'order':
cbSpoofCheck( 'plugin' );
$this->orderCategory( $id, $order, $user, $plugin );
break;
case 'orderup':
cbSpoofCheck( 'plugin' );
$this->orderCategory( $id[0], -1, $user, $plugin );
break;
case 'orderdown':
cbSpoofCheck( 'plugin' );
$this->orderCategory( $id[0], 1, $user, $plugin );
break;
case 'batch':
$this->batchCategory( $id, $user, $plugin );
break;
case 'copy':
$this->copyCategory( $id, $user, $plugin );
break;
case 'delete':
cbSpoofCheck( 'plugin' );
$this->deleteCategory( $id, $user, $plugin );
break;
case 'new':
$this->showCategoryEdit( null, $user, $plugin );
break;
case 'edit':
$this->showCategoryEdit( $id[0], $user, $plugin );
break;
//.........这里部分代码省略.........
示例6: getColumns
/**
* Get the field columns for $listId
*
* @param int $listId The list id to parse
* @param int $userId The user id to use for substitutions
* @return array
*/
public static function getColumns($listId, $userId = null)
{
$row = self::getInstance($listId);
if (!$row) {
return '';
}
if ($userId) {
$cbUser = CBuser::getInstance((int) $userId, false);
} else {
$cbUser = CBuser::getMyInstance();
}
$columns = array();
$params = new Registry($row->params);
$cols = $params->get('columns');
if ($cols) {
foreach ($cols as $i => $column) {
$colFields = array();
if (isset($column['fields']) && $column['fields']) {
foreach ($column['fields'] as $colField) {
if (isset($colField['field']) && $colField['field']) {
$colFields[] = array('fieldid' => $colField['field'], 'display' => isset($colField['display']) ? (int) $colField['display'] : 4);
}
}
}
$col = new stdClass();
$col->fields = $colFields;
$col->title = isset($column['title']) ? $column['title'] : null;
$col->titleRendered = $cbUser->replaceUserVars($col->title);
$col->size = isset($column['size']) ? (int) $column['size'] : 3;
$col->cssclass = isset($column['cssclass']) ? $column['cssclass'] : null;
$columns[$i] = $col;
}
}
return $columns;
}
示例7: cbimport
}
global $_CB_framework, $_CB_database;
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';
cbimport('cb.html');
cbimport('language.front');
outputCbTemplate();
require_once dirname(__FILE__) . '/helper.php';
if ((int) $params->get('cb_plugins', 1)) {
global $_PLUGINS;
$_PLUGINS->loadPluginGroup('user');
}
$cbUser = CBuser::getMyInstance();
$user = $cbUser->getUserData();
$templateClass = 'cb_template cb_template_' . selectTemplate('dir');
$mode = (int) $params->get('mode', 1);
if ($params->get('pretext')) {
$preText = $cbUser->replaceUserVars($params->get('pretext'));
} else {
$preText = null;
}
if ($params->get('posttext')) {
$postText = $cbUser->replaceUserVars($params->get('posttext'));
} else {
$postText = null;
}
if ($mode < 6) {
$limit = (int) $params->get('limit', 30);
示例8: _getTabFieldsDb
function _getTabFieldsDb($tabid, &$user, $reason, $fieldIdOrName = null, $prefetchFields = true, $fullAccess = false)
{
static $prefetched = array();
static $fieldsByName = null;
$preIdx = $fullAccess ? 'full' : $reason;
if (!$prefetchFields || !isset($prefetched[$preIdx])) {
global $_CB_framework, $_CB_database, $ueConfig;
$where = array();
$ordering = array();
if ($fieldIdOrName && !$prefetchFields) {
if (is_int($fieldIdOrName)) {
$where[] = 'f.fieldid = ' . (int) $fieldIdOrName;
} else {
$where[] = 'f.name = ' . $_CB_database->Quote($fieldIdOrName);
}
}
if ($reason == 'list' && in_array($ueConfig['name_format'], array(1, 2, 4))) {
$where[] = "( f.published = 1 OR f.name = 'name' )";
} elseif ($reason != 'adminfulllist') {
$where[] = 'f.published = 1';
}
if (!$fullAccess) {
switch ($reason) {
case 'profile':
$where[] = 'f.profile != 0';
break;
case 'list':
$where[] = "( f.profile != 0 OR f.name = 'username'" . (in_array($ueConfig['name_format'], array(1, 2, 4)) ? " OR f.name = 'name'" : '') . ')';
break;
case 'register':
$where[] = 'f.registration = 1';
break;
case 'adminfulllist':
default:
break;
}
if ($tabid && !$prefetchFields) {
$where[] = 'f.tabid = ' . (int) $tabid;
} else {
if ($reason != 'adminfulllist') {
$where[] = 't.enabled = 1';
}
if ($reason != 'register' && !($_CB_framework->getUi() == 2 && $_CB_framework->acl->amIaSuperAdmin())) {
$where[] = 't.viewaccesslevel IN (' . implode(',', CBuser::getMyInstance()->getAuthorisedViewLevelsIds(false)) . ')';
$where[] = 't.useraccessgroupid IN (' . implode(',', $_CB_framework->acl->get_groups_below_me(null, true)) . ')';
}
}
if (($reason == 'profile' || $reason == 'list') && $ueConfig['allow_email_display'] == 0 && $reason != 'adminfulllist') {
$where[] = 'f.type != ' . $_CB_database->Quote('emailaddress');
}
}
if (!$tabid || $prefetchFields) {
if ($reason == 'register') {
$ordering[] = 't.ordering_register';
}
$ordering[] = 't.position';
$ordering[] = 't.ordering';
}
$ordering[] = 'f.ordering';
$sql = 'SELECT f.*';
if ($reason == 'register') {
$sql .= ', t.ordering_register AS tab_ordering_register, t.position AS tab_position, t.ordering AS tab_ordering';
}
$sql .= ' FROM #__comprofiler_fields f';
if (!$tabid || $prefetchFields) {
// don't get fields which are not assigned to tabs:
$sql .= "\n INNER JOIN #__comprofiler_tabs AS t ON (f.tabid = t.tabid)";
}
$sql .= ($where ? "\n WHERE " . implode(' AND ', $where) : '') . "\n ORDER BY " . implode(', ', $ordering);
$_CB_database->setQuery($sql);
if ($prefetchFields) {
$fieldsByName = $_CB_database->loadObjectList('name', 'moscomprofilerFields', array(&$_CB_database), true);
// true means strtolower array indexes of name
if (!$_CB_database->getErrorNum()) {
foreach (array_keys($fieldsByName) as $i) {
$fieldsByName[$i]->params = new cbParamsBase($fieldsByName[$i]->params);
$prefetched[$preIdx][(int) $fieldsByName[$i]->tabid][$fieldsByName[$i]->fieldid] = $fieldsByName[$i];
}
}
} else {
$fields = $_CB_database->loadObjectList(null, 'moscomprofilerFields', array(&$_CB_database));
if (!$_CB_database->getErrorNum()) {
for ($i = 0, $n = count($fields); $i < $n; $i++) {
$fields[$i]->params = new cbParamsBase($fields[$i]->params);
}
}
}
}
if (isset($prefetched[$preIdx])) {
if ($tabid) {
if (isset($prefetched[$preIdx][(int) $tabid])) {
$fields = $prefetched[$preIdx][(int) $tabid];
} else {
$fields = array();
}
} elseif ($fieldIdOrName) {
if (is_int($fieldIdOrName)) {
$fields = array();
foreach (array_keys($prefetched[$preIdx]) as $k) {
if (isset($prefetched[$preIdx][$k][$fieldIdOrName])) {
//.........这里部分代码省略.........
示例9: saveTab
function saveTab($option)
{
global $_CB_database, $_CB_framework, $_POST;
$this->_importNeeded();
$this->_importNeededSave();
if (isset($_POST['params'])) {
$_POST['params'] = cbParamsEditorController::getRawParamsMagicgpcEscaped($_POST['params']);
} else {
$_POST['params'] = '';
}
if (!isset($_POST['tabid']) || count($_POST) == 0) {
echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T('Missing post values')) . "'); window.history.go(-2); </script>\n";
exit;
}
$oldrow = new moscomprofilerTabs($_CB_database);
if (isset($_POST['tabid']) && $_POST['tabid']) {
$oldrow->load((int) $_POST['tabid']);
// Check if user is a super user:
if (!$_CB_framework->acl->amIaSuperAdmin()) {
// Check if user belongs to useraccessgroupid:
if (!in_array($oldrow->useraccessgroupid, $_CB_framework->acl->get_groups_below_me(null, true))) {
echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T('Unauthorized Access')) . "'); window.history.go(-1);</script>\n";
exit;
}
// Check if user belongs to viewaccesslevel:
if (!in_array($oldrow->viewaccesslevel, CBuser::getMyInstance()->getAuthorisedViewLevelsIds(false))) {
echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T('Unauthorized Access')) . "'); window.history.go(-1);</script>\n";
exit;
}
}
}
$row = new moscomprofilerTabs($_CB_database);
if (!$row->bind($_POST)) {
echo "<script type=\"text/javascript\"> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
exit;
}
// Set defaults if nothing is found
// Also check if oldrow value to use its current value or default otherwise
// This prevents a tab from storing to database with null values when some inputs are set disabled:
if ($row->useraccessgroupid == '') {
$row->useraccessgroupid = $oldrow->useraccessgroupid != '' ? $oldrow->useraccessgroupid : -2;
}
if ($row->viewaccesslevel == '') {
$row->viewaccesslevel = $oldrow->viewaccesslevel != '' ? $oldrow->viewaccesslevel : 1;
}
if ($row->ordering == '') {
$row->ordering = $oldrow->ordering != '' ? $oldrow->ordering : 999;
}
if ($row->ordering_register == '') {
$row->ordering_register = $oldrow->ordering_register != '' ? $oldrow->ordering_register : 10;
}
if ($row->enabled == '') {
$row->enabled = $oldrow->enabled != '' ? $oldrow->enabled : 1;
}
$row->description = cleanEditorsTranslationJunk(trim($row->description));
if (!$row->check()) {
echo "<script type=\"text/javascript\"> alert('" . $row->getError() . "'); window.history.go(-2); </script>\n";
exit;
}
$row->tabid = (int) cbGetParam($_POST, 'tabid', 0);
// Check if user is a super user:
if (!$_CB_framework->acl->amIaSuperAdmin()) {
$canEditState = CBuser::getMyInstance()->authoriseAction('core.edit.state');
// Check if user belongs to useraccessgroupid
if ($row->useraccessgroupid != '' && !in_array($row->useraccessgroupid, $_CB_framework->acl->get_groups_below_me(null, true))) {
echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T('Unauthorized Access')) . "'); window.history.go(-1);</script>\n";
exit;
}
// Check if user belongs to viewaccesslevel
if ($row->viewaccesslevel != '' && !in_array($row->viewaccesslevel, CBuser::getMyInstance()->getAuthorisedViewLevelsIds(false))) {
echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T('Unauthorized Access')) . "'); window.history.go(-1);</script>\n";
exit;
}
// Check if user can edit status (and if not, that status are as expected):
if (!$canEditState) {
$failed = false;
// Check if row exists and if useraccessgroupid is different from existing row
// Check if row doesn't exist and if useraccessgroupid is different from default
if ($oldrow->tabid && ($row->useraccessgroupid != '' && $oldrow->useraccessgroupid != $row->useraccessgroupid) || !$oldrow->tabid && ($row->useraccessgroupid != '' && $row->useraccessgroupid != -2)) {
$failed = true;
}
// Check if row exists and if viewaccesslevel is different from existing row
// Check if row doesn't exist and if viewaccesslevel is different from default
// Check if user can edit status:
if ($oldrow->tabid && ($row->viewaccesslevel != '' && $oldrow->viewaccesslevel != $row->viewaccesslevel) || !$oldrow->tabid && ($row->viewaccesslevel != '' && $row->viewaccesslevel != 1)) {
$failed = true;
}
// Check if row exists and if ordering is different from existing row
// Check if row doesn't exist and if ordering is different from default
// Check if user can edit status:
if ($oldrow->tabid && ($row->ordering != '' && $oldrow->ordering != $row->ordering) || !$oldrow->tabid && ($row->ordering != '' && $row->ordering != 999)) {
$failed = true;
}
// Check if row exists and if ordering_register is different from existing row
// Check if row doesn't exist and if ordering_register is different from default
// Check if user can edit status:
if ($oldrow->tabid && ($row->ordering_register != '' && $oldrow->ordering_register != $row->ordering_register) || !$oldrow->tabid && ($row->ordering_register != '' && $row->ordering_register != 10)) {
$failed = true;
}
// Check if row exists and if publish is different from existing row
//.........这里部分代码省略.........
示例10: reportUser
function reportUser($option, $form = 1, $uid = 0)
{
global $_CB_framework, $ueConfig, $_PLUGINS, $_POST;
if ($ueConfig['allowUserReports'] == 0) {
$msg = CBTxt::Th('UE_FUNCTIONALITY_DISABLED', 'This functionality is currently disabled.');
} elseif (!CBuser::getMyInstance()->authoriseView('profile', $uid)) {
$msg = CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!');
} else {
$msg = null;
}
$_PLUGINS->loadPluginGroup('user');
$_PLUGINS->trigger('onBeforeReportUserRequest', array($uid, &$msg, $form));
if ($msg) {
$_CB_framework->enqueueMessage($msg, 'error');
return;
}
$reportedByUser = CBuser::getUserDataInstance($_CB_framework->myId());
$reportedUser = CBuser::getUserDataInstance($uid);
if ($form == 1) {
$results = $_PLUGINS->trigger('onBeforeReportUserForm', array($uid, &$reportedByUser, &$reportedUser));
if ($_PLUGINS->is_errors()) {
$_CB_framework->enqueueMessage($_PLUGINS->getErrorMSG('<br />'), 'error');
return;
}
if (implode('', $results) != "") {
$return = '<div class="cb_template cb_template_' . selectTemplate('dir') . '">' . '<div>' . implode('</div><div>', $results) . '</div>' . '</div>';
echo $return;
return;
}
HTML_comprofiler::reportUserForm($option, $uid, $reportedByUser, $reportedUser);
} else {
cbSpoofCheck('reportuser');
$row = new UserReportTable();
$_PLUGINS->trigger('onStartSaveReportUser', array(&$row, &$reportedByUser, &$reportedUser));
if ($_PLUGINS->is_errors()) {
cbRedirect($_CB_framework->viewUrl('reportuser', false), $_PLUGINS->getErrorMSG(), 'error');
return;
}
if (!$row->bind($_POST)) {
cbRedirect($_CB_framework->viewUrl('reportuser', false), $row->getError(), 'error');
return;
}
$row->reportedondate = htmlspecialchars($row->reportedondate, ENT_QUOTES);
//TBD: remove this: not urgent but isn't right
$row->reportexplaination = htmlspecialchars($row->reportexplaination, ENT_QUOTES);
//TBD: remove this: not urgent but isn't right
$row->reportedondate = $_CB_framework->getUTCDate();
if (!$row->check()) {
cbRedirect($_CB_framework->viewUrl('reportuser', false), $row->getError(), 'error');
return;
}
$_PLUGINS->trigger('onBeforeSaveReportUser', array(&$row, &$reportedByUser, &$reportedUser));
if (!$row->store()) {
cbRedirect($_CB_framework->viewUrl('reportuser', false), $row->getError(), 'error');
return;
}
if ($ueConfig['moderatorEmail'] == 1) {
$cbNotification = new cbNotification();
$cbNotification->sendToModerators(CBTxt::T('UE_USERREPORT_SUB', 'User Report Pending Review'), CBTxt::T('UE_USERREPORT_MSG', 'A user has submitted a report regarding a user that requires your review. Please log in and take the appropriate action.'));
}
$_PLUGINS->trigger('onAfterSaveReportUser', array(&$row, &$reportedByUser, &$reportedUser));
$_CB_framework->enqueueMessage(CBTxt::Th('UE_USERREPORT_SUCCESSFUL', 'User report submitted successfully.'));
}
}
示例11: saveUser
function saveUser($option)
{
global $_CB_framework, $_CB_database, $_POST, $_PLUGINS;
$this->_importNeeded();
$this->_importNeededSave();
// Check rights to access:
$myGids = CBuser::getMyInstance()->getUserData()->gids;
$userIdPosted = (int) cbGetParam($_POST, "id", 0);
if ($userIdPosted == 0) {
$_POST['id'] = null;
}
$this->_authorizedEdit($userIdPosted);
if ($userIdPosted != 0) {
$msg = checkCBpermissions(array($userIdPosted), 'save', true);
} else {
$msg = checkCBpermissions(null, 'save', true);
}
if ($msg) {
echo "<script type=\"text/javascript\"> alert('" . addslashes($msg) . "'); window.history.go(-1);</script>\n";
exit;
}
$_PLUGINS->loadPluginGroup('user');
// Get current user state:
if ($userIdPosted != 0) {
$userComplete = CBuser::getUserDataInstance((int) $userIdPosted);
if (!($userComplete && $userComplete->id)) {
echo "<script type=\"text/javascript\"> alert('" . addslashes(_UE_USER_PROFILE_NOT) . "'); window.history.go(-1);</script>\n";
return;
}
} else {
$userComplete = new moscomprofilerUser($_CB_database);
}
// Store new user state:
$saveResult = $userComplete->saveSafely($_POST, $_CB_framework->getUi(), 'edit');
if (!$saveResult) {
$regErrorMSG = $userComplete->getError();
$msg = checkCBpermissions(array($userComplete->id), "edit", true);
if ($msg) {
echo "<script type=\"text/javascript\"> alert('" . addslashes($msg) . "'); window.history.go(-1);</script>\n";
exit;
}
echo "<script type=\"text/javascript\">alert('" . str_replace('\\\\n', '\\n', addslashes(strip_tags(str_replace('<br />', '\\n', $regErrorMSG)))) . "'); </script>\n";
global $_CB_Backend_task;
$_CB_Backend_task = 'edit';
// so the toolbar comes up...
$_PLUGINS->loadPluginGroup('user');
// resets plugin errors
$usersView = _CBloadView('user');
$usersView->edituser($userComplete, $option, $userComplete->user_id != null ? '0' : '1', $_POST);
// echo "<script type=\"text/javascript\">alert('" . addslashes( str_replace( '<br />', '\n', $userComplete->getError() ) ) . "'); window.history.go(-1);</script>\n";
return;
}
// Checks-in the row:
$userComplete->checkin();
cbRedirect($_CB_framework->backendUrl("index.php?option={$option}&task=showusers"), sprintf(CBTxt::T('Successfully Saved User: %s'), $userComplete->username));
}
示例12: checkCanAdminPlugins
/**
* Checks if operation is allowed, and exits to previous page if not, as it should not be possible at all.
*
* @since 1.8
*
* @param string $action Action to perform: core.admin, core.manage, core.create, core.delete, core.edit, core.edit.state, core.edit.own, ...
* @param array|int $cid Plugin-id
* @param string $assetname OPTIONAL: asset name e.g. com_comprofiler.plugin.$pluginId
* @return void
*/
function checkCanAdminPlugins($actions, $cid = null, $assetname = 'com_comprofiler')
{
$allowed = false;
foreach ((array) $actions as $action) {
$allowed = CBuser::getMyInstance()->authoriseAction($action, $assetname);
if ($allowed) {
break;
}
}
if (!$allowed) {
echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T("Operation not allowed by the Permissions of your group(s).")) . "'); window.history.go(-1); </script>\n";
exit;
}
}
示例13: getDisplayTab
/**
* Generates the HTML to display the user profile tab
* @param moscomprofilerTab $tab the tab database entry
* @param moscomprofilerUser $user the user being displayed
* @param int $ui 1 for front-end, 2 for back-end
* @return mixed either string HTML for tab content, or false if ErrorMSG generated
*/
function getDisplayTab($tab, $user, $ui)
{
global $_CB_framework, $ueConfig, $_POST, $_CB_OneTwoRowsStyleToggle;
if (!$_CB_framework->myId()) {
return null;
}
$return = "";
$params = $this->params;
$pmsType = $params->get('pmsType', '1');
$showTitle = $params->get('showTitle', "1");
$showSubject = $params->get('showSubject', "1");
$width = $params->get('width', "30");
$height = $params->get('height', "5");
$capabilities = $this->getPMScapabilites();
if (!$this->_checkPMSinstalled($pmsType) || $capabilities === false) {
return false;
}
if ($_CB_framework->myId() == $user->id) {
return null;
}
$newsub = null;
$newmsg = null;
// send PMS from this tab form input:
if (cbGetParam($_POST, $this->_getPagingParamName("sndnewmsg")) == _UE_PM_SENDMESSAGE) {
$sender = $this->_getReqParam("sender", null);
$recip = $this->_getReqParam("recip", null);
if ($sender && $recip && $sender == $_CB_framework->myId() && $recip == $user->id && CBuser::getMyInstance()->authoriseView('profile', $user->id)) {
cbSpoofCheck('pms');
$newsub = htmlspecialchars($this->_getReqParam("newsub", null));
//urldecode done in _getReqParam
if ($pmsType == '3' || $pmsType == '4') {
$newmsg = $this->_getReqParam("newmsg", null);
} else {
$newmsg = htmlspecialchars($this->_getReqParam("newmsg", null));
//don't allow html input on user profile!
}
if (($newsub || $newmsg) && isset($_POST[$this->_getPagingParamName("protect")])) {
$parts = explode('_', $this->_getReqParam('protect', ''));
if (count($parts) == 3 && $parts[0] == 'cbpms1' && strlen($parts[2]) == 32 && $parts[1] == md5($parts[2] . $user->id . $user->lastvisitDate)) {
if (!$newsub && $capabilities["subject"]) {
$newsub = _UE_PM_PROFILEMSG;
}
if ($this->sendUserPMS($recip, $sender, $newsub, $newmsg, $systemGenerated = false, $escaped = true)) {
$return .= "\n<script type='text/javascript'>alert('" . _UE_PM_SENTSUCCESS . "')</script>";
$newsub = null;
$newmsg = null;
} else {
$return .= "\n<script type='text/javascript'>alert('" . $this->getErrorMSG() . "')</script>";
}
} else {
$return .= "\n<script type='text/javascript'>alert('" . _UE_SESSIONTIMEOUT . " " . _UE_PM_NOTSENT . " " . _UE_TRYAGAIN . "')</script>";
}
} else {
$return .= "\n<script type='text/javascript'>alert('" . _UE_PM_EMPTYMESSAGE . " " . _UE_PM_NOTSENT . "')</script>";
}
}
}
// display Quick Message tab:
$return .= "\n\t<div class=\"sectiontableentry" . $_CB_OneTwoRowsStyleToggle . "\" style=\"padding-bottom:5px;\">\n";
$_CB_OneTwoRowsStyleToggle = $_CB_OneTwoRowsStyleToggle == 1 ? 2 : 1;
if ($showTitle) {
$return .= "\t\t<div class=\"titleCell\" style=\"align: left; text-align:left; margin-left: 0px;\">" . cbUnHtmlspecialchars(getLangDefinition($tab->title)) . ($showSubject && $capabilities["subject"] ? "" : ":") . "</div>\n";
}
$return .= $this->_writeTabDescription($tab, $user);
$base_url = $this->_getAbsURLwithParam(array());
$return .= '<form method="post" action="' . $base_url . '">';
$return .= '<table cellspacing="0" cellpadding="5" class="contentpane" style="border:0px;align:left;width:90%;">';
if ($showSubject && $capabilities["subject"]) {
$return .= '<tr><td><b>' . _UE_EMAILFORMSUBJECT . '</b></td>';
$return .= '<td><input type="text" class="inputbox" name="' . $this->_getPagingParamName("newsub") . '" size="' . ($width - 8) . '" value="' . stripslashes($newsub) . '" /></td></tr>';
$return .= '<tr class="sectiontableentry1"><td colspan="2"><b>' . _UE_EMAILFORMMESSAGE . '</b></td></tr>';
}
$return .= '<tr><td colspan="2"><textarea name="' . $this->_getPagingParamName("newmsg") . '" class="inputbox" rows="' . $height . '" cols="' . $width . '">' . stripslashes($newmsg) . '</textarea></td></tr>';
$return .= '<tr><td colspan="2"><input type="submit" class="button" name="' . $this->_getPagingParamName("sndnewmsg") . '" value="' . _UE_PM_SENDMESSAGE . '" /></td></tr>';
$return .= '</table>';
$return .= "<input type=\"hidden\" name=\"" . $this->_getPagingParamName("sender") . "\" value=\"" . $_CB_framework->myId() . "\" />";
$return .= "<input type=\"hidden\" name=\"" . $this->_getPagingParamName("recip") . "\" value=\"{$user->id}\" />";
$salt = cbMakeRandomString(32);
$return .= "<input type=\"hidden\" name=\"" . $this->_getPagingParamName("protect") . "\" value=\"" . 'cbpms1_' . md5($salt . $user->id . $user->lastvisitDate) . '_' . $salt . "\" />";
$return .= cbGetSpoofInputTag('pms');
$return .= '</form>';
$return .= "</div>";
return $return;
}
示例14: reportUser
function reportUser($option, $form = 1, $uid = 0)
{
global $_CB_framework, $_CB_database, $ueConfig, $_POST;
if ($ueConfig['allowUserReports'] == 0) {
echo _UE_FUNCTIONALITY_DISABLED;
exit;
}
if (!CBuser::getMyInstance()->authoriseView('profile', $uid)) {
echo _UE_NOT_AUTHORIZED;
return;
}
if ($form == 1) {
HTML_comprofiler::reportUserForm($option, $uid);
} else {
// simple spoof check security
cbSpoofCheck('reportUserForm');
$row = new moscomprofilerUserReport($_CB_database);
$Itemid = $_CB_framework->itemid();
if (!$row->bind($_POST)) {
cbRedirect(cbSef("index.php?option={$option}&task=reportUser" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), $row->getError(), 'error');
return;
}
_cbMakeHtmlSafe($row);
//TBD: remove this: not urgent but isn't right
$row->reportedondate = date("Y-m-d H:i:s");
if (!$row->check()) {
cbRedirect(cbSef("index.php?option={$option}&task=reportUser" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), $row->getError(), 'error');
return;
}
if (!$row->store()) {
cbRedirect(cbSef("index.php?option={$option}&task=reportUser" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), $row->getError(), 'error');
return;
}
if ($ueConfig['moderatorEmail'] == 1) {
$cbNotification = new cbNotification();
$cbNotification->sendToModerators(_UE_USERREPORT_SUB, _UE_USERREPORT_MSG);
}
echo _UE_USERREPORT_SUCCESSFUL;
}
}
示例15: getItemid
/**
* prepare GroupJive Itemid if not found return CB Itemid
*
* @param boolean $htmlspecialchars
* @param string $task
* @return string
*/
static public function getItemid( $htmlspecialchars = false, $task = null ) {
global $_CB_framework, $_CB_database;
static $Itemid = array();
if ( ! isset( $Itemid[$task] ) ) {
$plugin = cbgjClass::getPlugin();
$generalItemid = $plugin->params->get( 'general_itemid', null );
$url = 'index.php?option=com_comprofiler&task=pluginclass&plugin=cbgroupjive';
if ( $task ) {
$url .= $task;
}
$url .= '%';
if ( ( ! $generalItemid ) || $task ) {
$query = 'SELECT ' . $_CB_database->NameQuote( 'id' )
. "\n FROM " . $_CB_database->NameQuote( '#__menu' )
. "\n WHERE " . $_CB_database->NameQuote( 'link' ) . " LIKE " . $_CB_database->Quote( $url )
. "\n AND " . $_CB_database->NameQuote( 'published' ) . " = 1"
. "\n AND " . $_CB_database->NameQuote( 'access' ) . " IN ( " . implode( ',', cbToArrayOfInt( CBuser::getMyInstance()->getAuthorisedViewLevelsIds( ( checkJversion() >= 2 ? false : true ) ) ) ) . " )"
. ( checkJversion() >= 2 ? "\n AND " . $_CB_database->NameQuote( 'language' ) . " IN ( " . $_CB_database->Quote( $_CB_framework->getCfg( 'lang_tag' ) ) . ", '*', '' )" : null );
$_CB_database->setQuery( $query );
$Itemid[$task] = $_CB_database->loadResult();
if ( ( ! $Itemid[$task] ) && $task ) {
$Itemid[$task] = cbgjClass::getItemid( 0 );
} elseif ( ! $Itemid[$task] ) {
$Itemid[$task] = getCBprofileItemid( null );
}
} else {
$Itemid[$task] = $generalItemid;
}
}
if ( is_bool( $htmlspecialchars ) ) {
return ( $htmlspecialchars ? '&' : '&' ) . 'Itemid=' . $Itemid[$task];
} else {
return $Itemid[$task];
}
}