/** * Saves legacy user edit display * * @param string $option * @param string $task */ public function saveUser($option, $task = 'save') { global $_CB_framework, $_CB_Backend_task, $_POST, $_PLUGINS; cbimport('language.all'); cbimport('cb.tabs'); cbimport('cb.params'); cbimport('cb.adminfilesystem'); cbimport('cb.imgtoolbox'); $userIdPosted = (int) cbGetParam($_POST, 'id', 0); if ($userIdPosted == 0) { $_POST['id'] = null; } $msg = $this->_authorizedEdit($userIdPosted); if (!$msg) { if ($userIdPosted != 0) { $msg = checkCBpermissions(array($userIdPosted), 'save', true); } else { $msg = checkCBpermissions(null, 'save', true); } } if ($userIdPosted != 0) { $_PLUGINS->trigger('onBeforeUserProfileSaveRequest', array($userIdPosted, &$msg, 2)); } if ($msg) { cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error'); } $_PLUGINS->loadPluginGroup('user'); // Get current user state: if ($userIdPosted != 0) { $userComplete = CBuser::getUserDataInstance($userIdPosted); if (!($userComplete && $userComplete->id)) { cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('Your profile could not be updated.'), 'error'); } } else { $userComplete = new UserTable(); } // Store new user state: $saveResult = $userComplete->saveSafely($_POST, $_CB_framework->getUi(), 'edit'); if (!$saveResult) { $regErrorMSG = $userComplete->getError(); $msg = checkCBpermissions(array((int) $userComplete->id), 'edit', true); if ($userIdPosted != 0) { $_PLUGINS->trigger('onBeforeUserProfileEditRequest', array((int) $userComplete->id, &$msg, 2)); } if ($msg) { cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error'); } if ($userIdPosted != 0) { $_PLUGINS->trigger('onAfterUserProfileSaveFailed', array(&$userComplete, &$regErrorMSG, 2)); } else { $_PLUGINS->trigger('onAfterUserRegistrationSaveFailed', array(&$userComplete, &$regErrorMSG, 2)); } $_CB_framework->enqueueMessage($regErrorMSG, 'error'); $_CB_Backend_task = 'edit'; // so the toolbar comes up... $_PLUGINS->loadPluginGroup('user'); // resets plugin errors $userView = _CBloadView('user'); /** @var CBController_user $userView */ $userView->edituser($userComplete, $option, $userComplete->user_id != null ? 0 : 1, $_POST); return; } // Checks-in the row: $userComplete->checkin(); if ($userIdPosted != 0) { $_PLUGINS->trigger('onAfterUserProfileSaved', array(&$userComplete, 2)); } else { $messagesToUser = array(); $_PLUGINS->trigger('onAfterSaveUserRegistration', array(&$userComplete, &$messagesToUser, 2)); } if ($task == 'apply') { cbRedirect($_CB_framework->backendViewUrl('edit', false, array('cid' => (int) $userComplete->user_id)), CBTxt::T('SUCCESSFULLY_SAVED_USER_USERNAME', 'Successfully Saved User: [username]', array('[username]' => $userComplete->username))); } else { cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SUCCESSFULLY_SAVED_USER_USERNAME', 'Successfully Saved User: [username]', array('[username]' => $userComplete->username))); } }
function editTab( $tid='0', $option='com_comprofiler', $task='editTab' ) { global $_CB_database, $_CB_framework, $_PLUGINS; $this->_importNeeded(); $row = new moscomprofilerTabs( $_CB_database ); // load the row from the db table $row->load( (int) $tid ); if ( $tid && ! in_array( $row->useraccessgroupid, getChildGIDS( userGID( $_CB_framework->myId() ) ) ) ) { echo "<script type=\"text/javascript\"> alert('" . addslashes( CBTxt::T('Unauthorized Access') ) . "'); window.history.go(-1);</script>\n"; exit; } $lists = array(); if($row->sys=='2') $lists['enabled'] = "Yes"; else $lists['enabled'] = moscomprofilerHTML::yesnoSelectList( 'enabled', 'class="inputbox" size="1"', ( $row->enabled !== null ? $row->enabled : 1 ) ); /* ------------------------- ! head ! !-----------------------! ! ! ! ! ! left ! middle ! right ! ! ! ! ! !-----------------------! ! ! ! tabmain ! ! ! !-----------------------! ! underall ! ------------------------- ! ! ! ! ! L1C1 ! L1C2 ! L1C3 ! L1C1...C9 ! ! ! ! !-----------------------! ! ! ! ! ! L2C1 ! L2C4 ! L2C8 ! ... ! ! ! ! !-----------------------! ! ! ! L4C7 ! ! ! !-----------------------! ! ! ! ! L8C3 ! L8C4 ! ...L9C9 ! ! ! !-----------------------! ! + not_on_profile_1..9 */ $position = array(); $position[] = moscomprofilerHTML::makeOption( 'cb_head', _UE_POS_CB_HEAD ); $position[] = moscomprofilerHTML::makeOption( 'cb_left', _UE_POS_CB_LEFT ); $position[] = moscomprofilerHTML::makeOption( 'cb_middle', _UE_POS_CB_MIDDLE ); $position[] = moscomprofilerHTML::makeOption( 'cb_right', _UE_POS_CB_RIGHT ); $position[] = moscomprofilerHTML::makeOption( 'cb_tabmain', _UE_POS_CB_MAIN ); $position[] = moscomprofilerHTML::makeOption( 'cb_underall', _UE_POS_CB_BOTTOM ); for ( $i = 1 ; $i <= 9; $i++ ) { for ( $j = 1 ; $j <= 9; $j++ ) { $position[] = moscomprofilerHTML::makeOption( 'L'.$i.'C'.$j, CBTxt::T('Line') . ' ' . $i . ' ' . CBTxt::T('Column') . ' ' . $j ); } } for ( $i = 1 ; $i <= 9; $i++ ) { $position[] = moscomprofilerHTML::makeOption( 'not_on_profile_'.$i, CBTxt::T('Not displayed on profile') . ' ' . $i ); } if ( ! $row->position ) { $row->position = 'cb_tabmain'; } $lists['position'] = moscomprofilerHTML::selectList( $position, 'position', 'class="inputbox" size="1"', 'value', 'text', $row->position, 2 ); $displaytype = array(); $displaytype[] = moscomprofilerHTML::makeOption( 'tab', _UE_DISPLAY_TAB ); $displaytype[] = moscomprofilerHTML::makeOption( 'div', _UE_DISPLAY_DIV ); $displaytype[] = moscomprofilerHTML::makeOption( 'rounddiv', _UE_DISPLAY_ROUNDED_DIV ); $displaytype[] = moscomprofilerHTML::makeOption( 'html', _UE_DISPLAY_HTML ); $displaytype[] = moscomprofilerHTML::makeOption( 'overlib', _UE_DISPLAY_OVERLIB ); $displaytype[] = moscomprofilerHTML::makeOption( 'overlibfix', _UE_DISPLAY_OVERLIBFIX ); $displaytype[] = moscomprofilerHTML::makeOption( 'overlibsticky', _UE_DISPLAY_OVERLIBSTICKY ); if ( ! $row->displaytype ) { $row->displaytype = 'tab'; } $lists['displaytype'] = moscomprofilerHTML::selectList( $displaytype, 'displaytype', 'class="inputbox" size="1"', 'value', 'text', $row->displaytype, 2 ); if ($tid) { if ( $row->ordering > -10000 && $row->ordering < 10000 ) { // build the html select list for ordering $query = "SELECT ordering AS value, title AS text" . "\n FROM #__comprofiler_tabs" . "\n WHERE position='" . $_CB_database->getEscaped( $row->position ) . "'" . "\n AND enabled > 0" . "\n AND ordering > -10000" . "\n AND ordering < 10000" . "\n ORDER BY ordering" ; $order = $this->_cbGetOrderingList( $query ); $lists['ordering'] = moscomprofilerHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ), 2 ); } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />' . CBTxt::T('This plugin cannot be reordered') ; } } else { $row->ordering = 999; $row->ordering_register = 10; $row->published = 1; $row->description = ''; $row->useraccessgroupid = -2; $lists['ordering'] = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. CBTxt::T('New items default to the last place. Ordering can be changed after this item is saved.'); } $gtree3=array(); $gtree3[] = moscomprofilerHTML::makeOption( -2 , '- ' . CBtxt::T('Everybody') . ' -' ); $gtree3[] = moscomprofilerHTML::makeOption( -1 , '- ' . CBtxt::T('All Registered Users') . ' -' ); $gtree3 = array_merge( $gtree3, $_CB_framework->acl->get_group_children_tree( null, 'USERS', false )); $lists['useraccessgroup']=moscomprofilerHTML::selectList( $gtree3, 'useraccessgroupid', 'size="4"', 'value', 'text', $row->useraccessgroupid, 2, false ); // params: $paramsEditorHtml = array(); $options = array( 'option' => $option, 'task' => $task, 'cid' => $row->tabid ); // additional non-specific other parameters: $_PLUGINS->loadPluginGroup( 'user' ); $fieldsParamsPlugins = $_PLUGINS->getUserTabParamsPluginIds(); foreach ($fieldsParamsPlugins as $pluginId => $fieldParamHandlerClassName ) { $fieldParamHandler = new $fieldParamHandlerClassName( $pluginId, $row ); // cbFieldParamsHandler(); $addParamsHtml = $fieldParamHandler->drawParamsEditor( $options ); if ( $addParamsHtml ) { $addParamsTitle = $fieldParamHandler->getFieldsParamsLabel(); $paramsEditorHtml[] = array( 'title' => $addParamsTitle, 'content' => $addParamsHtml ); } } $pluginView = _CBloadView( 'tab' ); $pluginView->edittab( $row, $option, $lists, $tid, $paramsEditorHtml ); }
function _cbadmin_emailUsers( &$rows, $emailSubject, $emailBody, $limitstart, $limit, $total, $simulationMode ) { global $_PLUGINS; // simple spoof check security cbSpoofCheck( 'cbadmingui' ); cbRegAntiSpamCheck(); $cbNotification = new cbNotification(); $mode = 1; // html $usernames = ''; foreach ( $rows as $row ) { $user = CBuser::getUserDataInstance( (int) $row->id ); $usernames .= ( $usernames ? ', ' : '' ) . htmlspecialchars( $user->username ); if ( $simulationMode ) { $usernames .= ' (' . htmlspecialchars( CBTxt::T('email not send: simulation mode') ) . ')'; } else { $extraStrings = array(); $_PLUGINS->trigger( 'onBeforeBackendUserEmail', array( &$user, &$emailSubject, &$emailBody, $mode, &$extraStrings, $simulationMode ) ); if ( ! $cbNotification->sendFromSystem( $user, $emailSubject, $this->_cbadmin_makeLinksAbsolute( $emailBody ), true, $mode, null, null, null, $extraStrings, false ) ) { $usernames .= ': <span class="cb_result_error">' . htmlspecialchars( CBTxt::T('Error sending email!') ) . '</span>'; } } } if ( $total < $limit ) { $limit = $total; } ob_start(); $usersView = _CBloadView( 'users' ); $usersView->ajaxResults( $usernames, $emailSubject, $this->_cbadmin_makeLinksAbsolute( $emailBody ), $limitstart, $limit, $total ); $html = ob_get_contents(); ob_end_clean(); $reply = array( 'result' => 1, 'htmlcontent' => $html ); if ( ! ( $total - ( $limitstart + $limit ) > 0 ) ) { $reply['result'] = 2; } echo json_encode( $reply ); sleep(3); }
function editField($fid = 0, $option = 'com_comprofiler', $task = 'editField') { global $_CB_database, $_CB_framework, $_PLUGINS; $this->_importNeeded(); $canEditState = CBuser::getMyInstance()->authoriseAction('core.edit.state'); $row = new moscomprofilerFields($_CB_database); $paramsEditorHtml = null; if ($fid == 0) { // default values for new types: $row->type = 'text'; $row->tabid = 11; // contact info by default $row->profile = 1; $row->registration = 1; $row->displaytitle = 1; $row->published = 1; $row->required = 0; $row->readonly = 0; $paramsEditorHtml = array(array('title' => CBTxt::T('Parameters'), 'content' => "<strong>" . CBTxt::T('To see Parameters, first save new field') . "</strong>")); } else { // load the row from the db table $row->load((int) $fid); $fieldTab = new moscomprofilerTabs($_CB_database); // load the row from the db table $fieldTab->load((int) $row->tabid); // Check if user is a super user: if (!$_CB_framework->acl->amIaSuperAdmin()) { // Check if user belongs to useraccessgroupid: if (!in_array($fieldTab->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($fieldTab->viewaccesslevel, CBuser::getMyInstance()->getAuthorisedViewLevelsIds(false))) { echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T('Unauthorized Access')) . "'); window.history.go(-1);</script>\n"; exit; } } } $_PLUGINS->loadPluginGroup('user'); if ($task == 'reloadField') { if (!$this->_prov_bind_CB_field($row, $fid)) { echo "<script type=\"text/javascript\"> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } } if ($fid == 0) { if ($row->tablecolumns != '' && !in_array($row->type, array('password', 'userparams'))) { $row->searchable = 1; } else { $row->searchable = 0; } } // params: $paramsEditorHtml = array(); $options = array('option' => $option, 'task' => $task, 'cid' => $row->fieldid); // field-specific own parameters: $fieldHandler = new cbFieldHandler(); $fieldOwnParamsEditHtml = $fieldHandler->drawParamsEditor($row, $options); if ($fieldOwnParamsEditHtml) { $paramsEditorHtml[] = array('title' => CBTxt::T('Field-specific Parameters'), 'content' => $fieldOwnParamsEditHtml); } // additional non-specific other parameters: $fieldsParamsPlugins = $_PLUGINS->getUserFieldParamsPluginIds(); foreach ($fieldsParamsPlugins as $pluginId => $fieldParamHandlerClassName) { $fieldParamHandler = new $fieldParamHandlerClassName($pluginId, $row); // cbFieldParamsHandler(); $addParamsHtml = $fieldParamHandler->drawParamsEditor($options); if ($addParamsHtml) { $addParamsTitle = $fieldParamHandler->getFieldsParamsLabel(); $paramsEditorHtml[] = array('title' => $addParamsTitle, 'content' => $addParamsHtml); } } $where = array(); $where[] = "`fields` = 1"; if (!$_CB_framework->acl->amIaSuperAdmin()) { $where[] = "useraccessgroupid IN (" . implode(',', $_CB_framework->acl->get_groups_below_me(null, true)) . ")"; } $_CB_database->setQuery("SELECT tabid, title FROM #__comprofiler_tabs WHERE " . implode(' AND ', $where) . " ORDER BY ordering"); $tabs = $_CB_database->loadObjectList(); $lists = array(); $tablist = array(); for ($i = 0, $n = count($tabs); $i < $n; $i++) { $tab =& $tabs[$i]; $tablist[] = moscomprofilerHTML::makeOption($tab->tabid, getLangDefinition($tab->title)); } $lists['tabs'] = moscomprofilerHTML::selectList($tablist, 'tabid', 'class="inputbox" size="1" mosReq=1 mosLabel="' . htmlspecialchars(CBTxt::T('Tab')) . '"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', $row->tabid, 2); $types = array(); if ($fid == 0) { $typeHandlers = array(); $registeredTypes = $_PLUGINS->getUserFieldTypes(); foreach ($registeredTypes as $typ) { $typeHandlers[$typ] = new cbFieldHandler(); $tmpField = new moscomprofilerFields($_CB_database); $tmpField->type = $typ; $typLabel = $typeHandlers[$typ]->getFieldTypeLabel($tmpField); if ($typLabel) { $types[] = moscomprofilerHTML::makeOption($typ, $typLabel); } } } else { $types[] = moscomprofilerHTML::makeOption($row->type, $fieldHandler->getFieldTypeLabel($row, false)); } $webaddrtypes = array(); $webaddrtypes[] = moscomprofilerHTML::makeOption('0', CBTxt::T('URL only')); $webaddrtypes[] = moscomprofilerHTML::makeOption('2', CBTxt::T('Hypertext and URL')); $profiles = array(); $profiles[] = moscomprofilerHTML::makeOption('0', CBTxt::T('No')); $profiles[] = moscomprofilerHTML::makeOption('1', CBTxt::T('Yes: on 1 Line')); $profiles[] = moscomprofilerHTML::makeOption('2', CBTxt::T('Yes: on 2 Lines')); $fvalues = $_CB_database->setQuery("SELECT fieldtitle " . "\n FROM #__comprofiler_field_values" . "\n WHERE fieldid=" . (int) $fid . "\n ORDER BY ordering"); $fvalues = $_CB_database->loadObjectList(); $lists['webaddresstypes'] = moscomprofilerHTML::selectList($webaddrtypes, 'webaddresstypes', 'class="inputbox" size="1"', 'value', 'text', $row->rows, 2); $lists['type'] = moscomprofilerHTML::selectList($types, 'type', 'class="inputbox" size="1"', 'value', 'text', $row->type, 2); $lists['required'] = moscomprofilerHTML::yesnoSelectList('required', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), $row->required === null ? 0 : $row->required); $lists['published'] = moscomprofilerHTML::yesnoSelectList('published', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), $row->published); $lists['readonly'] = moscomprofilerHTML::yesnoSelectList('readonly', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), $row->readonly === null ? 0 : $row->readonly); $lists['profile'] = moscomprofilerHTML::selectList($profiles, 'profile', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', $row->profile, 2); $lists['displaytitle'] = moscomprofilerHTML::yesnoSelectList('displaytitle', 'class="inputbox" size="1"', $row->displaytitle); if ($row->tablecolumns != '' && !in_array($row->type, array('password', 'userparams'))) { $lists['searchable'] = moscomprofilerHTML::yesnoSelectList('searchable', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), $row->searchable); } else { $lists['searchable'] = _UE_NO . '<input type="hidden" name="searchable" value="0" />'; } $lists['registration'] = moscomprofilerHTML::yesnoSelectList('registration', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), $row->registration); $pluginView = _CBloadView('field'); $pluginView->editfield($row, $lists, $fvalues, $option, $paramsEditorHtml); }
function editPluginSettingsParams( &$row, $option, $task, $uid, &$element, &$params, &$options ) { global $_CB_database, $_CB_framework; $lists = array(); // get list of groups if ($row->access == 99 || $row->client_id == 1) { $lists['access'] = CBTxt::T('Administrator') . '<input type="hidden" name="access" value="99" />'; } else { // build the html select list for the group access $accessTree = $_CB_framework->acl->get_access_children_tree(); $lists['access'] = moscomprofilerHTML::selectList( $accessTree, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ), 2 ); } if ($uid) { $row->checkout( $_CB_framework->myId() ); if ( $row->ordering > -10000 && $row->ordering < 10000 ) { // build the html select list for ordering $query = "SELECT ordering AS value, name AS text" . "\n FROM #__comprofiler_plugin" . "\n WHERE type='" . $_CB_database->getEscaped( $row->type ) . "'" . "\n AND published > 0" . "\n AND ordering > -10000" . "\n AND ordering < 10000" . "\n ORDER BY ordering" ; $order = $this->_cbGetOrderingList( $query ); $lists['ordering'] = moscomprofilerHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ), 2 ); } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />' . CBTxt::T('This plugin cannot be reordered'); } $lists['type'] = '<input type="hidden" name="type" value="'. $row->type .'" />'. $row->type; if ($element && $element->name() == 'cbinstall' && $element->attributes( 'type' ) == 'plugin' ) { $description =& $element->getElementByPath( 'description' ); $row->description = ( $description ) ? trim( $description->data() ) : ''; } } else { $row->folder = ''; $row->ordering = 999; $row->published = 1; $row->description = ''; $folders = cbReadDirectory( $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/' ); $folders2 = array(); foreach ($folders as $folder) { if (is_dir( $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/' . $folder ) && ( $folder <> 'CVS' ) ) { $folders2[] = moscomprofilerHTML::makeOption( $folder ); } } $lists['type'] = moscomprofilerHTML::selectList( $folders2, 'type', 'class="inputbox" size="1"', 'value', 'text', null, 2 ); $lists['ordering'] = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />' . CBTxt::T('New items default to the last place. Ordering can be changed after this item is saved.') ; } $Yesoptions = array(); $Yesoptions[] = moscomprofilerHTML::makeOption( '1', _UE_YES ); if ( ( $row->type == 'language' ) || ( $row->id == 1 ) ) { $row->published = 1; } else { $Yesoptions[] = moscomprofilerHTML::makeOption( '0', _UE_NO ); } $lists['published'] = moscomprofilerHTML::radioList( $Yesoptions, 'published', 'class="inputbox"', 'value', 'text', $row->published, 2 ); $pluginView = _CBloadView( 'plugin' ); $pluginView->editPlugin( $row, $lists, $params, $options ); }
function saveUser( $option ) { global $_CB_framework, $_CB_database, $_POST, $_PLUGINS; $this->_importNeeded(); $this->_importNeededSave(); if ( ! ( isset( $_POST['approved'] ) && isset( $_POST['confirmed'] ) && isset( $_POST['username'] ) ) ) { echo "<script type=\"text/javascript\"> alert('" . addslashes( CBTxt::T('Not Authorized') ) ."'); window.history.go(-1);</script>\n"; exit; } // Check rights to access: $myGid = userGID( $_CB_framework->myId() ); $userIdPosted = (int) cbGetParam($_POST, "id", 0 ); if ( $userIdPosted == 0 ) { $_POST['id'] = null; } $adminGroups = $_CB_framework->acl->mapGroupNamesToValues( array( 'Administrator', 'Superadministrator' ) ); if ( $userIdPosted != 0 ) { $msg = checkCBpermissions( array( $userIdPosted ), 'save', in_array( $myGid, $adminGroups ) ); } else { $msg = checkCBpermissions( null, 'save', in_array( $myGid, $adminGroups ) ); } if ($msg) { echo "<script type=\"text/javascript\"> alert('" . addslashes( $msg ) . "'); window.history.go(-1);</script>\n"; exit; } $_PLUGINS->loadPluginGroup('user'); // Get current user state: $userComplete = new moscomprofilerUser( $_CB_database ); if ( $userIdPosted != 0 ) { if ( ! $userComplete->load( (int) $userIdPosted ) ) { echo "<script type=\"text/javascript\"> alert('" . addslashes( _UE_USER_PROFILE_NOT ) . "'); window.history.go(-1);</script>\n"; return; } } // 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) ); }
/** * Outputs legacy user mass mailer and user reconfirm email display * * @param string $option * @param string $task * @param int[] $cid * @return bool * @deprecated 2.0 */ public function showUsers($option, $task, $cid) { global $_CB_framework, $_CB_database, $ueConfig, $_PLUGINS; cbimport('language.all'); cbimport('cb.tabs'); cbimport('cb.params'); cbimport('cb.pagination'); cbimport('cb.lists'); // We just need the user rows as we've already filtered down the IDs in user management: $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler') . " AS c" . "\n INNER JOIN " . $_CB_database->NameQuote('#__users') . " AS u" . ' ON u.' . $_CB_database->NameQuote('id') . ' = c.' . $_CB_database->NameQuote('id') . "\n WHERE u." . $_CB_database->NameQuote('id') . " IN ( " . implode(', ', cbArrayToInts($cid)) . " )"; $_CB_database->setQuery($query); $rows = $_CB_database->loadObjectList(null, '\\CB\\Database\\Table\\UserTable', array($_CB_database)); $total = count($rows); if ($task == 'resendconfirmationemails') { if (!$rows) { cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => $task)), 'error'); } $count = 0; /** @var UserTable[] $rows */ foreach ($rows as $row) { if ($row->confirmed == 0) { if ($row->cbactivation == '') { // Generate a new confirmation code if the user doesn't have one (requires email confirmation to be enabled): $row->store(); } $cbNotification = new cbNotification(); $cbNotification->sendFromSystem($row->id, CBTxt::T($ueConfig['reg_pend_appr_sub']), CBTxt::T($ueConfig['reg_pend_appr_msg']), true, isset($ueConfig['reg_email_html']) ? (int) $ueConfig['reg_email_html'] : 0); ++$count; } } cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SENT_CONFIRMATION_EMAILS_TO_NUM_USERS_USERS', 'Sent confirmation emails to [NUM_USERS] users', array('[NUM_USERS]' => $count))); } else { $emailSubject = stripslashes(cbGetParam($_POST, 'emailsubject', '')); $emailBody = stripslashes(rawurldecode(cbGetParam($_POST, 'emailbody', '', _CB_ALLOWRAW | _CB_NOTRIM))); $emailAttach = stripslashes(cbGetParam($_POST, 'emailattach', '')); $emailsPerBatch = stripslashes(cbGetParam($_POST, 'emailsperbatch', 50)); $emailsBatch = stripslashes(cbGetParam($_POST, 'emailsbatch', 0)); $emailFromName = stripslashes(cbGetParam($_POST, 'emailfromname', '')); $emailFromAddr = stripslashes(cbGetParam($_POST, 'emailfromaddr', '')); $emailReplyName = stripslashes(cbGetParam($_POST, 'emailreplyname', '')); $emailReplyAddr = stripslashes(cbGetParam($_POST, 'emailreplyaddr', '')); $emailPause = stripslashes(cbGetParam($_POST, 'emailpause', 30)); $simulationMode = stripslashes(cbGetParam($_POST, 'simulationmode', '')); // B/C trigger variables: if (count($cid) > 0 && count($cid) < $total) { $total = count($cid); } $pageNav = new cbPageNav($total, 0, 10); $search = ''; $lists = array(); $inputTextExtras = null; $select_tag_attribs = null; if ($task == 'emailusers') { if (!$rows) { cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => $task)), 'error'); } $pluginRows = $_PLUGINS->trigger('onBeforeBackendUsersEmailForm', array(&$rows, &$pageNav, &$search, &$lists, &$cid, &$emailSubject, &$emailBody, &$inputTextExtras, &$select_tag_attribs, $simulationMode, $option, &$emailAttach, &$emailFromName, &$emailFromAddr, &$emailReplyName, &$emailReplyAddr)); $usersView = _CBloadView('users'); /** @var CBView_users $usersView */ $usersView->emailUsers($rows, $emailSubject, $emailBody, $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsPerBatch, $emailsBatch, $emailPause, $simulationMode, $pluginRows); } elseif ($task == 'startemailusers') { $pluginRows = $_PLUGINS->trigger('onBeforeBackendUsersEmailStart', array(&$rows, $total, $search, $lists, $cid, &$emailSubject, &$emailBody, &$inputTextExtras, $simulationMode, $option, &$emailAttach, &$emailFromName, &$emailFromAddr, &$emailReplyName, &$emailReplyAddr)); $usersView = _CBloadView('users'); /** @var CBView_users $usersView */ $usersView->startEmailUsers($rows, $emailSubject, $emailBody, $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsPerBatch, $emailsBatch, $emailPause, $simulationMode, $pluginRows); } elseif ($task == 'ajaxemailusers') { cbSpoofCheck('cbadmingui'); cbRegAntiSpamCheck(); $cbNotification = new cbNotification(); $mode = 1; // html $errors = 0; $success = array(); $failed = array(); $users = array_slice($rows, $emailsBatch, $emailsPerBatch); if ($simulationMode) { $success = array('<div class="alert alert-info">' . CBTxt::T('Emails do not send in simulation mode') . '</div>'); } else { foreach ($users as $user) { $extraStrings = array(); $_PLUGINS->trigger('onBeforeBackendUserEmail', array(&$user, &$emailSubject, &$emailBody, $mode, &$extraStrings, $simulationMode, &$emailAttach, &$emailFromName, &$emailFromAddr, &$emailReplyName, &$emailReplyAddr)); $attachments = cbReplaceVars($emailAttach, $user, $mode, true, $extraStrings); if ($attachments) { $attachments = preg_split(' *, *', $attachments); } else { $attachments = null; } if (!$cbNotification->sendFromSystem($user, $emailSubject, $this->makeLinksAbsolute($emailBody), true, $mode, null, null, $attachments, $extraStrings, false, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr)) { $failed[] = '<div class="alert alert-danger">' . '<strong>' . htmlspecialchars($user->name . ' <' . $user->email . '>') . '</strong>: ' . CBTxt::Th('ERROR_SENDING_EMAIL_ERRORMSG', 'Error sending email: [ERROR_MSG]', array('[ERROR_MSG]' => $cbNotification->errorMSG)) . '</div>'; ++$errors; } else { $success[] = htmlspecialchars($user->name . ' <' . $user->email . '>'); } } } $usernames = implode(', ', $success) . implode('', $failed); if ($total < $emailsPerBatch) { $limit = $total; } else { $limit = $emailsPerBatch; } ob_start(); $usersView = _CBloadView('users'); /** @var CBView_users $usersView */ $usersView->ajaxResults($usernames, $emailSubject, $this->makeLinksAbsolute($emailBody), $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsBatch, $limit, $total, $errors); $html = ob_get_contents(); ob_end_clean(); $reply = array('result' => 1, 'htmlcontent' => $html); if (!($total - ((int) $emailsBatch + (int) $emailsPerBatch) > 0)) { $reply['result'] = 2; } echo json_encode($reply); } } }
function editTab($tid = '0', $option = 'com_comprofiler', $task = 'editTab') { global $_CB_database, $_CB_framework, $_PLUGINS; $this->_importNeeded(); $canEditState = CBuser::getMyInstance()->authoriseAction('core.edit.state'); $row = new moscomprofilerTabs($_CB_database); if ($tid) { // load the row from the db table $row->load((int) $tid); // Check if user is a super user: if (!$_CB_framework->acl->amIaSuperAdmin()) { // Check if user belongs to useraccessgroupid: if (!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 (!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; } } } $lists = array(); if ($row->sys == '2') { $lists['enabled'] = "Yes"; } else { $lists['enabled'] = moscomprofilerHTML::yesnoSelectList('enabled', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), $row->enabled !== null ? $row->enabled : 1); } /* ------------------------- ! head ! !-----------------------! ! ! ! ! ! left ! middle ! right ! ! ! ! ! !-----------------------! ! ! ! tabmain ! ! ! !-----------------------! ! underall ! ------------------------- ! ! ! ! ! L1C1 ! L1C2 ! L1C3 ! L1C1...C9 ! ! ! ! !-----------------------! ! ! ! ! ! L2C1 ! L2C4 ! L2C8 ! ... ! ! ! ! !-----------------------! ! ! ! L4C7 ! ! ! !-----------------------! ! ! ! ! L8C3 ! L8C4 ! ...L9C9 ! ! ! !-----------------------! ! + not_on_profile_1..9 */ $position = array(); $position[] = moscomprofilerHTML::makeOption('cb_head', _UE_POS_CB_HEAD); $position[] = moscomprofilerHTML::makeOption('cb_left', _UE_POS_CB_LEFT); $position[] = moscomprofilerHTML::makeOption('cb_middle', _UE_POS_CB_MIDDLE); $position[] = moscomprofilerHTML::makeOption('cb_right', _UE_POS_CB_RIGHT); $position[] = moscomprofilerHTML::makeOption('cb_tabmain', _UE_POS_CB_MAIN); $position[] = moscomprofilerHTML::makeOption('cb_underall', _UE_POS_CB_BOTTOM); for ($i = 1; $i <= 9; $i++) { for ($j = 1; $j <= 9; $j++) { $position[] = moscomprofilerHTML::makeOption('L' . $i . 'C' . $j, CBTxt::T('Line') . ' ' . $i . ' ' . CBTxt::T('Column') . ' ' . $j); } } for ($i = 1; $i <= 9; $i++) { $position[] = moscomprofilerHTML::makeOption('not_on_profile_' . $i, CBTxt::T('Not displayed on profile') . ' ' . $i); } if (!$row->position) { $row->position = 'cb_tabmain'; } $lists['position'] = moscomprofilerHTML::selectList($position, 'position', 'class="inputbox" size="1"', 'value', 'text', $row->position, 2); $displaytype = array(); $displaytype[] = moscomprofilerHTML::makeOption('tab', _UE_DISPLAY_TAB); $displaytype[] = moscomprofilerHTML::makeOption('div', _UE_DISPLAY_DIV); $displaytype[] = moscomprofilerHTML::makeOption('rounddiv', _UE_DISPLAY_ROUNDED_DIV); $displaytype[] = moscomprofilerHTML::makeOption('html', _UE_DISPLAY_HTML); $displaytype[] = moscomprofilerHTML::makeOption('overlib', _UE_DISPLAY_OVERLIB); $displaytype[] = moscomprofilerHTML::makeOption('overlibfix', _UE_DISPLAY_OVERLIBFIX); $displaytype[] = moscomprofilerHTML::makeOption('overlibsticky', _UE_DISPLAY_OVERLIBSTICKY); if (!$row->displaytype) { $row->displaytype = 'tab'; } $lists['displaytype'] = moscomprofilerHTML::selectList($displaytype, 'displaytype', 'class="inputbox" size="1"', 'value', 'text', $row->displaytype, 2); if ($tid) { if ($row->ordering > -10000 && $row->ordering < 10000) { // build the html select list for ordering $query = "SELECT ordering AS value, title AS text" . "\n FROM #__comprofiler_tabs" . "\n WHERE position='" . $_CB_database->getEscaped($row->position) . "'" . "\n AND enabled > 0" . "\n AND ordering > -10000" . "\n AND ordering < 10000" . "\n ORDER BY ordering"; $order = $this->_cbGetOrderingList($query); $lists['ordering'] = moscomprofilerHTML::selectList($order, 'ordering', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', intval($row->ordering), 2); } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />' . CBTxt::T('This plugin cannot be reordered'); } } else { $row->ordering = 999; $row->ordering_register = 10; $row->published = 1; $row->description = ''; $row->useraccessgroupid = -2; $row->viewaccesslevel = 1; $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />' . CBTxt::T('New items default to the last place. Ordering can be changed after this item is saved.'); } $lists['ordering_register'] = '<input type="text" name="ordering_register" class="inputbox"' . ($canEditState ? '' : ' disabled="disabled"') . ' size="40" value="' . $row->ordering_register . '" />'; // build the html select list for the view level access (filtered by View Access Levels visible by the admin if not super user: $accessTree = $_CB_framework->acl->get_access_children_tree(true, false, !$_CB_framework->acl->amIaSuperAdmin()); $lists['viewaccesslevel'] = moscomprofilerHTML::selectList($accessTree, 'viewaccesslevel', 'class="inputbox"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', intval($row->viewaccesslevel), 2); // We want to use View Access Levels in Joomla 1.6, and hide old method if unused: if (isStillUsingGroupsForViewAccess($row->_tbl)) { $gtree3 = array(); $gtree3[] = moscomprofilerHTML::makeOption(-2, '- ' . CBtxt::T('Everybody') . ' -'); $gtree3[] = moscomprofilerHTML::makeOption(-1, '- ' . CBtxt::T('All Registered Users') . ' -'); if (!$_CB_framework->acl->amIaSuperAdmin() && in_array((int) $row->useraccessgroupid, $_CB_framework->acl->get_groups_below_me(null, true))) { // This should always be the case: // ensure user can't add group higher than themselves: $gtree3 = array_merge($gtree3, $_CB_framework->acl->get_groups_below_me()); // vs $_CB_framework->acl->get_groups_below_me( null, true ) in tab lists } else { // Just in case we missed one, and as super-admin we should see everything: $gtree3 = array_merge($gtree3, $_CB_framework->acl->get_group_children_tree(null, 'USERS', false)); } $lists['useraccessgroup'] = moscomprofilerHTML::selectList($gtree3, 'useraccessgroupid', 'size="4"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', $row->useraccessgroupid, 2, false); } else { $lists['useraccessgroup'] = null; } // params: $paramsEditorHtml = array(); $options = array('option' => $option, 'task' => $task, 'cid' => $row->tabid); // additional non-specific other parameters: $_PLUGINS->loadPluginGroup('user'); $fieldsParamsPlugins = $_PLUGINS->getUserTabParamsPluginIds(); foreach ($fieldsParamsPlugins as $pluginId => $fieldParamHandlerClassName) { $fieldParamHandler = new $fieldParamHandlerClassName($pluginId, $row); // cbFieldParamsHandler(); $addParamsHtml = $fieldParamHandler->drawParamsEditor($options); if ($addParamsHtml) { $addParamsTitle = $fieldParamHandler->getFieldsParamsLabel(); $paramsEditorHtml[] = array('title' => $addParamsTitle, 'content' => $addParamsHtml); } } $pluginView = _CBloadView('tab'); $pluginView->edittab($row, $option, $lists, $tid, $paramsEditorHtml); }