admin.comprofiler.controller.php
上传用户:stephen_wu
上传日期:2008-07-05
资源大小:1757k
文件大小:164k
源码类别:
网络
开发平台:
Unix_Linux
- <?php
- /**
- * Joomla/Mambo Community Builder
- * @version $Id: admin.comprofiler.php 610 2006-12-13 17:33:44Z beat $
- * @package Community Builder
- * @subpackage admin.comprofiler.php
- * @author JoomlaJoe and Beat, database check function by Nick
- * @copyright (C) JoomlaJoe and Beat, www.joomlapolis.com
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2
- */
- // ensure this file is being included by a parent file
- if ( ! ( defined( '_VALID_CB' ) || defined( '_JEXEC' ) || defined( '_VALID_MOS' ) ) ) { die( 'Direct Access to this location is not allowed.' ); }
- $memMax = trim( @ini_get( 'memory_limit' ) );
- if ( $memMax ) {
- $last = strtolower( $memMax{strlen( $memMax ) - 1} );
- switch( $last ) {
- case 'g':
- $memMax *= 1024;
- case 'm':
- $memMax *= 1024;
- case 'k':
- $memMax *= 1024;
- }
- if ( $memMax < 16000000 ) {
- @ini_set( 'memory_limit', '16M' );
- }
- if ( $memMax < 32000000 ) {
- @ini_set( 'memory_limit', '32M' );
- }
- if ( $memMax < 48000000 ) {
- @ini_set( 'memory_limit', '48M' ); // DOMIT XML parser can be very memory-hungry on PHP < 5.1.3
- }
- }
- /**
- * CB framework
- * @global CBframework $_CB_framework
- */
- global $_CB_framework;
- global $mainframe, $option, $_CB_Admin_Done;
- require_once( $mainframe->getPath( 'admin_html' ) );
- /** @global string $_CB_adminpath
- * @global string $_CB_joomla_adminpath
- * @global array $ueConfig
- */
- global $_CB_joomla_adminpath, $_CB_adminpath, $ueConfig;
- if ( defined( 'JPATH_ADMINISTRATOR' ) ) {
- $_CB_joomla_adminpath = JPATH_ADMINISTRATOR;
- $option = JRequest::getString( 'option' );
- $task = JRequest::getString( 'task' );
- } else {
- $_CB_joomla_adminpath = $mainframe->getCfg( 'absolute_path' ) . '/administrator';
- global $option, $task;
- }
- $_CB_adminpath = $_CB_joomla_adminpath . '/components/com_comprofiler';
- include_once( $_CB_adminpath . '/ue_config.php' );
- include_once( $_CB_adminpath . '/plugin.class.php' );
- $_CB_framework->cbset( '_ui', 2 ); // : we're in 1: frontend, 2: admin back-end
- if($_CB_framework->getCfg( 'debug' )) {
- ini_set( 'display_errors', true );
- error_reporting( E_ALL );
- }
- $UElanguagePath = $_CB_framework->getCfg( 'absolute_path' ) . '/components/com_comprofiler/plugin/language';
- $UElanguage = $_CB_framework->getCfg( 'lang' );
- if ( ! file_exists( $UElanguagePath . '/' . $UElanguage . '/' . $UElanguage . '.php' ) ) {
- $UElanguage = 'default_language';
- }
- @include_once( $UElanguagePath . '/' . $UElanguage . '/' . $UElanguage . '.php' );
- if ( class_exists( 'JFactory' ) ) { // Joomla 1.5 : for string WARNREG_EMAIL_INUSE used in error js popup.
- $lang =& JFactory::getLanguage();
- $lang->load( "com_users" );
- }
- include_once( $_CB_adminpath . '/comprofiler.class.php' );
- cbimport( 'cb.adminfilesystem' );
- cbimport( 'cb.installer' );
- cbimport( 'cb.params' );
- cbimport( 'cb.pagination' );
- include_once( $_CB_adminpath . '/imgToolbox.class.php' );
- if ( ! $_CB_framework->check_acl( 'canManageUsers', $_CB_framework->myUserType() ) ) {
- cbRedirect( 'index2.php', _UE_NOT_AUTHORIZED, 'error' );
- }
- /** Backend menu: 'show' : only displays close button, 'edit' : special close button
- * @global stdClass $_CB_Backend_Menu */
- global $_CB_Backend_Menu;
- $_CB_Backend_Menu = new stdClass();
- global $_CB_Backend_Title, $_CB_Backend_task;
- $_CB_Backend_Title = array();
- $_CB_Backend_task = $task;
- //$task = trim( cbGetParam( $_REQUEST, 'task', null ) );
- $cid = cbGetParam( $_REQUEST, 'cid', array( 0 ) );
- $uid = cbGetParam( $_REQUEST, 'uid', array( 0 ) );
- if ( ! is_array( $cid )) {
- $cid = array ( (int) $cid );
- }
- $oldignoreuserabort = ignore_user_abort( true );
- $taskPart1 = strtok( $task, '.' );
- ob_start();
- // remind step 2 if forgotten/failed:
- $tgzFile = $_CB_framework->getCfg( 'absolute_path' ) . '/administrator/components/com_comprofiler/pluginsfiles.tgz';
- if ( file_exists( $tgzFile ) ) {
- if ( in_array( $taskPart1, array( 'showusers', 'showconfig', 'showTab', 'showField', 'showLists', 'tools', 'showPlugins', '' ) ) ) {
- echo '<div class="cbWarning">Warning: file ' . $tgzFile . ' still exists. This is probably due to the fact that first installation step did not complete, or second installation step did not take place. If you are sure that first step has been performed, you need to execute second installation step before using CB. You can do this now by clicking here: '
- . '<a href="index2.php?option=com_comprofiler&task=finishinstallation">please click here to continue next and last installation step</a>.</div>';
- }
- }
- switch ( $taskPart1 ) {
- case "new":
- editUser( 0, $option );
- break;
- case "edit":
- editUser( intval( $cid[0] ), $option );
- break;
- case "save":
- cbSpoofCheck( 'user' );
- saveUser( $option );
- break;
- case "remove":
- cbSpoofCheck( 'user' );
- removeUsers( $cid, $option );
- break;
- case "block":
- cbSpoofCheck( 'user' );
- changeUserBlock( $cid, 1, $option );
- break;
- case "unblock":
- cbSpoofCheck( 'user' );
- changeUserBlock( $cid, 0, $option );
- break;
- case "approve":
- cbSpoofCheck( 'user' );
- approveUser( $cid, 1, $option );
- break;
- case "reject":
- cbSpoofCheck( 'user' );
- approveUser( $cid, 0, $option );
- break;
- case "showconfig":
- showConfig( $option );
- break;
- case "showinstruction":
- showInstructions($_CB_database, $option, $_CB_framework->getCfg( 'lang' ));
- break;
- case "saveconfig":
- cbSpoofCheck( 'config' );
- saveConfig( $option );
- break;
- case "newTab":
- editTab( 0, $option);
- break;
- case "editTab":
- editTab( intval( $cid[0] ), $option );
- break;
- case "saveTab":
- cbSpoofCheck( 'tab' );
- saveTab( $option );
- break;
- case "removeTab":
- cbSpoofCheck( 'tab' );
- removeTabs( $cid, $option );
- break;
- case "showTab":
- showTab( $option );
- break;
- case "orderupTab":
- case "orderdownTab":
- cbSpoofCheck( 'tab' );
- orderTabs( $cid[0], ($task == 'orderupTab' ? -1 : 1), $option);
- break;
- case "newField":
- editField( 0, $option, $task );
- break;
- case "editField":
- editField( intval( $cid[0] ), $option, $task );
- break;
- case "reloadField":
- cbSpoofCheck( 'field' );
- editField( (int) cbGetParam( $_POST, 'fieldid', 0 ), $option, $task );
- break;
- case "saveField":
- case "applyField":
- cbSpoofCheck( 'field' );
- saveField( $option, $task );
- break;
- case "removeField":
- cbSpoofCheck( 'field' );
- removeField( $cid, $option );
- break;
- case "showField":
- showField( $option );
- break;
- case "orderupField":
- cbSpoofCheck( 'field' );
- orderFields( $cid[0], -1, $option );
- break;
- case "orderdownField":
- cbSpoofCheck( 'field' );
- orderFields( $cid[0], 1, $option );
- break;
- case "saveList":
- cbSpoofCheck( 'list' );
- saveList($option );
- break;
- case "editList":
- editList( $cid[0], 1, $option );
- break;
- case "newList":
- editList( 0, $option);
- break;
- case "showLists":
- showLists( $option );
- break;
- case "removeList":
- cbSpoofCheck( 'list' );
- removeList( $cid, $option );
- break;
- case "orderupList":
- cbSpoofCheck( 'list' );
- orderLists( $cid[0], -1, $option );
- break;
- case "orderdownList":
- cbSpoofCheck( 'list' );
- orderLists( $cid[0], 1, $option );
- break;
- case "fieldPublishedYes":
- cbSpoofCheck( 'field' );
- publishField( $cid, 1, $option );
- break;
- case "fieldPublishedNo":
- cbSpoofCheck( 'field' );
- publishField( $cid, 0, $option );
- break;
- case "fieldRequiredYes":
- cbSpoofCheck( 'field' );
- requiredField( $cid, 1, $option );
- break;
- case "fieldRequiredNo":
- cbSpoofCheck( 'field' );
- requiredField( $cid, 0, $option );
- break;
- case "fieldProfileYes1":
- cbSpoofCheck( 'field' );
- profileField( $cid, 1, $option );
- break;
- case "fieldProfileYes2":
- cbSpoofCheck( 'field' );
- profileField( $cid, 2, $option );
- break;
- case "fieldProfileNo":
- cbSpoofCheck( 'field' );
- profileField( $cid, 0, $option );
- break;
- case "fieldRegistrationYes":
- cbSpoofCheck( 'field' );
- registrationField( $cid, 1, $option );
- break;
- case "fieldRegistrationNo":
- cbSpoofCheck( 'field' );
- registrationField( $cid, 0, $option );
- break;
- case "fieldSearchableYes":
- cbSpoofCheck( 'field' );
- searchableField( $cid, 1, $option );
- break;
- case "fieldSearchableNo":
- cbSpoofCheck( 'field' );
- searchableField( $cid, 0, $option );
- break;
- case "listPublishedYes":
- cbSpoofCheck( 'list' );
- listPublishedField( $cid, 1, $option );
- break;
- case "listPublishedNo":
- cbSpoofCheck( 'list' );
- listPublishedField( $cid, 0, $option );
- break;
- case "listDefaultYes":
- cbSpoofCheck( 'list' );
- listDefaultField( $cid, 1, $option );
- break;
- case "listDefaultNo":
- cbSpoofCheck( 'list' );
- listDefaultField( $cid, 0, $option );
- break;
- case "tabPublishedYes":
- cbSpoofCheck( 'tab' );
- tabPublishedField( $cid, 1, $option );
- break;
- case "tabPublishedNo":
- cbSpoofCheck( 'tab' );
- tabPublishedField( $cid, 0, $option );
- break;
- case "tools":
- loadTools();
- break;
- case "loadSampleData":
- cbSpoofCheck( 'cbtools', 'GET' );
- loadSampleData();
- break;
- case "syncUsers":
- cbSpoofCheck( 'cbtools', 'GET' );
- syncUsers();
- break;
- case "checkcbdb":
- cbSpoofCheck( 'cbtools', 'GET' );
- checkcbdb( (int) cbGetParam( $_GET, 'databaseid', 0 ) );
- break;
- case "fixcbdb":
- cbSpoofCheck( 'cbtools', 'GET' );
- fixcbdb( (int) cbGetParam( $_GET, 'dryrun', 1 ), (int) cbGetParam( $_GET, 'databaseid', 0 ) );
- break;
- case "showusers":
- showUsers( $option );
- break;
- case 'savetaborder':
- cbSpoofCheck( 'tab' );
- saveTabOrder( $cid );
- break;
- case 'savefieldorder':
- cbSpoofCheck( 'field' );
- saveFieldOrder( $cid );
- break;
- case 'savelistorder':
- cbSpoofCheck( 'list' );
- saveListOrder( $cid );
- break;
- case 'newPlugin':
- case 'editPlugin':
- editPlugin( $option, $task, $cid[0] );
- break;
- case 'savePlugin':
- case 'applyPlugin':
- cbSpoofCheck( 'plugin' );
- savePlugin( $option, $task );
- break;
- case 'deletePlugin':
- cbSpoofCheck( 'plugin' );
- removePlugin( $cid, $option );
- break;
- case 'cancelPlugin':
- cancelPlugin( $option );
- break;
- case 'cancelPluginAction':
- cancelPluginAction( $option );
- break;
- case 'publishPlugin':
- case 'unpublishPlugin':
- cbSpoofCheck( 'plugin' );
- publishPlugin( $cid, ($task == 'publishPlugin'), $option );
- break;
- case 'orderupPlugin':
- case 'orderdownPlugin':
- cbSpoofCheck( 'plugin' );
- orderPlugin( $cid[0], ($task == 'orderupPlugin' ? -1 : 1), $option);
- break;
- case 'accesspublic':
- case 'accessregistered':
- case 'accessspecial':
- cbSpoofCheck( 'plugin' );
- accessMenu( $cid[0], $task, $option );
- break;
- case 'savepluginorder':
- cbSpoofCheck( 'plugin' );
- savePluginOrder( $cid );
- break;
- case 'showPlugins':
- viewPlugins( $option);
- break;
- case 'installPluginUpload':
- cbSpoofCheck( 'plugin' );
- installPluginUpload();
- break;
- case 'installPluginDir':
- cbSpoofCheck( 'plugin' );
- installPluginDir();
- break;
- case 'installPluginURL':
- cbSpoofCheck( 'plugin' );
- installPluginURL();
- break;
- case 'pluginmenu':
- pluginMenu( $option, cbGetParam( $_REQUEST, 'pluginid', 0 ) );
- break;
- case 'latestVersion':
- latestVersion();
- break;
- case "fieldclass":
- case "tabclass":
- case "pluginclass":
- tabClass( $option, $task, cbGetParam( $_REQUEST, 'user', 0 ) );
- break;
- case "finishinstallation":
- finishInstallation( $option );
- break;
- default:
- // var_export( $ _POST ); //DEBUG!
- teamCredits(2);
- break;
- }
- echo $_CB_framework->getAllJsPageCodes();
- $html = ob_get_contents();
- ob_end_clean();
- if ( in_array( $taskPart1, array( 'fieldclass', 'tabclass', 'pluginclass' ) ) ) {
- echo $html;
- } else {
- // fix the backend toolbar icons taking full width in joomla 1.5:
- ?>
- <!--[if lte IE 7]>
- <style type="text/css">
- .cbtoolbarbar .cbtoolbar {
- width: 48px;
- }
- </style>
- <![endif]-->
- <div style="margin:0px;border-width:0px;padding:0px;float:left;width:100%;text-align:left;"><div id="cbAdminMainWrapper" style="margin:0px;border-width:0px;padding:0px;float:none;width:auto;">
- <?php
- echo '<div style="float:right;">';
- include( $_CB_adminpath . '/comprofiler.toolbar.php' );
- echo '</div>';
- if ( count( $_CB_Backend_Title ) > 0 ) {
- echo '<div class="header' . ( isset( $_CB_Backend_Title[0][0] ) ? ' ' . $_CB_Backend_Title[0][0] : '' ) . '">';
- echo $_CB_Backend_Title[0][1];
- echo '</div>';
- echo '<div style="clear:both;">';
- echo '</div>';
- }
- echo '<div style="float:left;width:100%;">';
- echo $html;
- echo '</div>';
- echo '<div style="clear:both;">';
- echo '</div>';
- echo '</div></div>';
- }
- if (!is_null($oldignoreuserabort)) ignore_user_abort($oldignoreuserabort);
- // END OF MAIN.
- function saveList( $option ) {
- global $_CB_database, $_POST;
- $row = new moscomprofilerLists( $_CB_database );
- if (!$row->bind( $_POST )) {
- echo "<script type="text/javascript"> alert('".$row->getError()."'); window.history.go(-1); </script>n";
- exit();
- }
- $row->params = cbParamsEditorController::getRawParams( $_POST['params'] );
- if(isset($_POST['col1'])) { $row->col1fields = implode("|*|",$_POST['col1']); } else { $row->col1fields = null; } ;
- if(isset($_POST['col2'])) { $row->col2fields = implode("|*|",$_POST['col2']); } else { $row->col2fields = null; } ;
- if(isset($_POST['col3'])) { $row->col3fields = implode("|*|",$_POST['col3']); } else { $row->col3fields = null; } ;
- if(isset($_POST['col4'])) { $row->col4fields = implode("|*|",$_POST['col4']); } else { $row->col4fields = null; } ;
- if ($row->col1enabled != 1) $row->col1enabled=0;
- if ($row->col2enabled != 1) $row->col2enabled=0;
- if ($row->col3enabled != 1) $row->col3enabled=0;
- if ($row->col4enabled != 1) $row->col4enabled=0;
- if ($row->col1captions != 1) $row->col1captions=0;
- if ($row->col2captions != 1) $row->col2captions=0;
- if ($row->col3captions != 1) $row->col3captions=0;
- if ($row->col4captions != 1) $row->col4captions=0;
- if (!$row->store( (int) $_POST['listid'],true)) {
- echo "<script type="text/javascript"> alert('".$row->getError()."'); window.history.go(-2); </script>n";
- exit();
- }
- cbRedirect( "index2.php?option=$option&task=showLists", "Successfully Saved List: ". $row->title );
- }
- function showLists( $option ) {
- global $_CB_database, $_CB_framework, $_CB_joomla_adminpath;
- $limit = (int) $_CB_framework->getCfg( 'list_limit' );
- if ( $limit == 0 ) {
- $limit = 10;
- }
- $limit = $_CB_framework->getUserStateFromRequest( "viewlistlimit", 'limit', $limit );
- $lastCBlist = $_CB_framework->getUserState( "view{$option}lastCBlist", null );
- if($lastCBlist=='showlists') {
- $limitstart = $_CB_framework->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 );
- $lastSearch = $_CB_framework->getUserState( "search{$option}", null );
- $search = $_CB_framework->getUserStateFromRequest( "search{$option}", 'search', '' );
- if ($lastSearch != $search) {
- $limitstart = 0;
- $_CB_framework->setUserState( "view{$option}limitstart", $limitstart );
- }
- $search = trim( strtolower( $search ) );
- } else {
- clearSearchBox();
- $search="";
- $limitstart = 0;
- $_CB_framework->setUserState( "view{$option}limitstart", $limitstart );
- $_CB_framework->setUserState( "view{$option}lastCBlist", "showlists" );
- }
- $where = array();
- if (isset( $search ) && $search!= "") {
- $search = cbEscapeSQLsearch( trim( strtolower( cbGetEscaped($search))));
- $where[] = "(a.title LIKE '%$search%' OR a.description LIKE '%$search%')";
- }
- $_CB_database->setQuery( "SELECT COUNT(*)"
- . "n FROM #__comprofiler_lists AS a"
- . (count( $where ) ? "nWHERE " . implode( ' AND ', $where ) : "")
- );
- $total = $_CB_database->loadResult();
- echo $_CB_database->getErrorMsg();
- if ($total <= $limitstart) $limitstart = 0;
- cbimport( 'cb.pagination' );
- $pageNav = new cbPageNav( $total, $limitstart, $limit );
- $_CB_database->setQuery( "SELECT listid, title, description, published,`default`,ordering,useraccessgroupid"
- . "nFROM #__comprofiler_lists a"
- . (count( $where ) ? "nWHERE " . implode( ' AND ', $where ) : "")
- . "n ORDER BY ordering"
- . "nLIMIT ". (int) $pageNav->limitstart . ", " . (int) $pageNav->limit
- );
- $rows = $_CB_database->loadObjectList();
- if ($_CB_database->getErrorNum()) {
- echo $_CB_database->stderr();
- return false;
- }
- HTML_comprofiler::showLists( $rows, $pageNav, $search, $option );
- return true;
- }
- function editList( $fid='0', $option='com_comprofiler', $task = 'editList') {
- global $_CB_database, $_CB_framework;
- $row = new moscomprofilerLists( $_CB_database );
- if ( $fid ) {
- // load the row from the db table
- $row->load( (int) $fid );
- } else {
- $row->col1enabled = '1';
- }
- $lists['published'] = moscomprofilerHTML::yesnoSelectList( 'published', 'class="inputbox" size="1"', $row->published );
- $lists['default'] = moscomprofilerHTML::yesnoSelectList( 'default', 'class="inputbox" size="1"', $row->default );
- /*
- if ( checkJversion() <= 0 ) {
- $my_groups = $_CB_framework->acl->get_object_groups( 'users', $_CB_framework->myId(), 'ARO' );
- } else {
- $aro_id = $_CB_framework->acl->get_object_id( 'users', $_CB_framework->myId(), 'ARO' );
- $my_groups = $_CB_framework->acl->get_object_groups( $aro_id, 'ARO' );
- }
- */
- $gtree2 = array();
- $gtree2 = array_merge( $gtree2, $_CB_framework->acl->get_group_children_tree( null, 'USERS', false ));
- $usergids = explode( ', ', $row->usergroupids );
- $ugids = array();
- foreach($usergids as $usergid) {
- $ugids[]->value = $usergid;
- }
- $lists['usergroups'] = moscomprofilerHTML::selectList( $gtree2, 'usergroups', 'size="4" MULTIPLE onblur="loadUGIDs(this);" mosReq=1 mosLabel="User Groups"', 'value', 'text', $ugids,1 );
- $gtree3 = array();
- $gtree3[] = moscomprofilerHTML::makeOption( -2 , '- Everybody -' );
- $gtree3[] = moscomprofilerHTML::makeOption( -1, '- 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 );
- $_CB_database->setQuery( "SELECT f.fieldid, f.title"
- . "n FROM #__comprofiler_fields AS f"
- . "n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)"
- . "n WHERE f.published = 1"
- . "n AND f.profile > 0"
- . "n AND p.published = 1"
- . "n ORDER BY f.ordering"
- );
- $field = $_CB_database->loadObjectList();
- $fields = array();
- for ( $i = 0, $n = count( $field ) ; $i < $n ; $i++ ) {
- $fieldvalue =& $field[$i];
- $fields[$fieldvalue->title] = $fieldvalue->fieldid;
- }
- //print_r(array_values($fields));
- // params:
- $paramsEditorHtml = array();
- $options = array( 'option' => $option, 'task' => $task, 'cid' => $row->listid );
- // list-specific own parameters:
- cbimport( 'cb.xml.simplexml' );
- $listXml = new CBSimpleXMLElement( file_get_contents( $_CB_framework->getCfg( 'absolute_path' ) . '/administrator/components/com_comprofiler/xmlcb/cb.lists.xml' ) );
- $null = null;
- $params =& new cbParamsEditorController( $row->params, $listXml, $listXml, $null, null, 'cbxml', $attrname='version', $attrvalue='1' );
- $params->setOptions( $options );
- $listParamsEditHtml = $params->draw( null, 'views', 'view', 'name', 'editlist' );
- $paramsEditorHtml[] = array( 'title' => "List parameters", 'content' => $listParamsEditHtml );
- /*
- // 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' => "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 );
- }
- }
- */
- HTML_comprofiler::editList( $row, $lists,$fields, $option, $fid, $paramsEditorHtml );
- }
- function removeList( $cid, $option ) {
- global $_CB_database;
- if (!is_array( $cid ) || count( $cid ) < 1) {
- echo "<script type="text/javascript"> alert('Select an item to delete'); window.history.go(-1);</script>n";
- exit;
- }
- $msg = '';
- if (count( $cid )) {
- $obj = new moscomprofilerLists( $_CB_database );
- foreach ($cid as $id) {
- $obj->delete( $id );
- }
- }
- //if($msg!='') echo "<script type="text/javascript"> alert('".$msg."'); window.history.go(-1);</script>n";
- cbRedirect( "index2.php?option=$option&task=showLists", $msg );
- }
- function orderLists( $lid, $inc, $option ) {
- global $_CB_database;
- $row = new moscomprofilerLists( $_CB_database );
- $row->load( (int) $lid );
- $row->move( $inc );
- cbRedirect( "index2.php?option=$option&task=showLists" );
- }
- function showField( $option ) {
- global $_CB_database, $_CB_framework, $_CB_joomla_adminpath;
- $limit = (int) $_CB_framework->getCfg( 'list_limit' );
- if ( $limit == 0 ) {
- $limit = 10;
- }
- $limit = $_CB_framework->getUserStateFromRequest( "viewlistlimit", 'limit', $limit );
- $lastCBlist = $_CB_framework->getUserState( "view{$option}lastCBlist", null );
- if($lastCBlist=='showfields') {
- $limitstart = $_CB_framework->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 );
- $lastSearch = $_CB_framework->getUserState( "search{$option}", null );
- $search = $_CB_framework->getUserStateFromRequest( "search{$option}", 'search', '' );
- if ($lastSearch != $search) {
- $limitstart = 0;
- $_CB_framework->setUserState( "view{$option}limitstart", $limitstart );
- }
- $search = trim( strtolower( $search ) );
- } else {
- clearSearchBox();
- $search="";
- $limitstart = 0;
- $_CB_framework->setUserState( "view{$option}limitstart", $limitstart );
- $_CB_framework->setUserState( "view{$option}lastCBlist", "showfields" );
- }
- $where = array();
- // $where[] = "(f.sys = 0)";
- if (isset( $search ) && $search!= "") {
- $search = cbEscapeSQLsearch( trim( strtolower( cbGetEscaped($search))));
- $where[] = "(f.name LIKE '%$search%' OR f.type LIKE '%$search%')";
- }
- $where[] = "t.useraccessgroupid IN (".implode(',',getChildGIDS(userGID( $_CB_framework->myId() ))).")";
- $_CB_database->setQuery( "SELECT COUNT(*)"
- . "n FROM #__comprofiler_fields AS f, #__comprofiler_tabs AS t"
- . "n WHERE (f.tabid = t.tabid) AND (t.fields = 1)" . ( count( $where ) ? ( " AND " . implode( ' AND ', $where ) ) : "" )
- );
- $total = $_CB_database->loadResult();
- echo $_CB_database->getErrorMsg();
- if ($total <= $limitstart) $limitstart = 0;
- cbimport( 'cb.pagination' );
- $pageNav = new cbPageNav( $total, $limitstart, $limit );
- $_CB_database->setQuery( "SELECT f.fieldid, f.title, f.name, f.description, f.type, f.required, f.published, "
- . "f.profile, f.ordering, f.registration, f.searchable, f.pluginid, f.sys, f.tablecolumns, "
- . "t.title AS 'tab', t.enabled AS 'tabenabled', t.pluginid AS 'tabpluginid', "
- . "p.name AS pluginname, p.published AS pluginpublished, "
- . "pf.name AS fieldpluginname, pf.published AS fieldpluginpublished "
- . "n FROM #__comprofiler_fields AS f"
- . "n INNER JOIN #__comprofiler_tabs AS t ON ( (f.tabid = t.tabid) AND (t.fields = 1) ) "
- . "n LEFT JOIN #__comprofiler_plugin AS p ON p.id = t.pluginid"
- . "n LEFT JOIN #__comprofiler_plugin AS pf ON pf.id = f.pluginid"
- . (count( $where ) ? "n WHERE " . implode( ' AND ', $where ) : "")
- . "n ORDER BY t.ordering, f.ordering"
- . "n LIMIT " . (int) $pageNav->limitstart . ", " . (int) $pageNav->limit
- );
- $rows = $_CB_database->loadObjectList();
- if ($_CB_database->getErrorNum()) {
- echo $_CB_database->stderr();
- return false;
- }
- HTML_comprofiler::showFields( $rows, $pageNav, $search, $option );
- return true;
- }
- function editField( $fid = 0, $option = 'com_comprofiler', $task = 'editField' ) {
- global $_CB_database, $_CB_framework, $_PLUGINS;
- $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;
- $paramsEditorHtml = array( array( 'title' => "Parameters", 'content' => "<strong>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 );
- if ( ! in_array( $fieldTab->useraccessgroupid, getChildGIDS( userGID( $_CB_framework->myId() ) ) ) ) {
- echo "<script type="text/javascript"> alert('Unauthorized Access'); window.history.go(-1);</script>n";
- exit;
- }
- }
- $_PLUGINS->loadPluginGroup( 'user' );
- if ( $task == 'reloadField' ) {
- if ( ! _prov_bind_CB_field( $row, $fid ) ) {
- echo "<script type="text/javascript"> alert('" . $row->getError() . "'); window.history.go(-1); </script>n";
- exit();
- }
- }
- // 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' => "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";
- $where[] = "useraccessgroupid IN (".implode(',',getChildGIDS(userGID( $_CB_framework->myId() ))).")";
- $_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="Tab"', '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', 'URL only' );
- $webaddrtypes[] = moscomprofilerHTML::makeOption( '2', 'Hypertext and URL' );
- $profiles = array();
- $profiles[] = moscomprofilerHTML::makeOption( '0', 'No' );
- $profiles[] = moscomprofilerHTML::makeOption( '1', 'Yes: on 1 Line' );
- $profiles[] = moscomprofilerHTML::makeOption( '2', '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"', $row->required );
- $lists['published'] = moscomprofilerHTML::yesnoSelectList( 'published', 'class="inputbox" size="1"', $row->published );
- $lists['readonly'] = moscomprofilerHTML::yesnoSelectList( 'readonly', 'class="inputbox" size="1"', $row->readonly );
- $lists['profile'] = moscomprofilerHTML::selectList( $profiles, 'profile', 'class="inputbox" size="1"', '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"', $row->searchable );
- } else {
- $lists['searchable'] = _UE_NO . '<input type="hidden" name="searchable" value="0" />';
- }
- $lists['registration'] = moscomprofilerHTML::yesnoSelectList( 'registration', 'class="inputbox" size="1"', $row->registration );
- HTML_comprofiler::editfield( $row, $lists, $fvalues, $option, $paramsEditorHtml );
- }
- /**
- * A more extensive bind method for fields ( //TBD: should got to the moscomprofilerFields class).
- *
- * @param moscomprofilerFields $row
- * @param int $fid
- * @return boolean
- */
- function _prov_bind_CB_field( &$row, $fid ) {
- global $_PLUGINS, $_POST;
- $bindSuccess = $row->bind( $_POST );
- if ( $bindSuccess ) {
- $pluginid = $_PLUGINS->getUserFieldPluginId( $row->type );
- if ( $pluginid != 1 ) {
- $row->pluginid = $pluginid; // not core plugin for now as we don't allow changing field types
- }
- if ( ! isset( $_POST['params'] ) ) {
- $_POST['params'] = null;
- }
- if ( $fid && $row->pluginid ) {
- // handles field-specific parameters:
- $fieldHandler = new cbFieldHandler();
- $row->params = $fieldHandler->getRawParams( $row, $_POST['params'] );
- } else {
- // if not a plugin-specific field, handle parameters in standard way:
- $row->params = cbParamsEditorController::getRawParams( $_POST['params'] );
- }
- }
- return $bindSuccess;
- }
- function saveField( $option, $task ) {
- global $_CB_database, $_CB_framework, $_POST, $_PLUGINS;
- if ( ( $task == 'showField' ) || ! ( isset( $_POST['oldtabid'] ) && isset( $_POST['tabid'] ) && isset( $_POST['fieldid'] ) ) ) {
- cbRedirect( 'index2.php?option=' . $option . '&task=' . $task );
- return;
- }
- $fid = (int) $_POST['fieldid'];
- $row = new moscomprofilerFields( $_CB_database );
- $fieldHandler = null;
- if ( $fid ) {
- // load the row from the db table
- if ( ! $row->load( (int) $fid ) ) {
- echo "<script type="text/javascript"> alert('Innexistant field'); window.history.go(-1);</script>n";
- exit;
- }
- $fieldTab = new moscomprofilerTabs( $_CB_database );
- // load the row from the db table
- $fieldTab->load( (int) $row->tabid );
- if ( ! in_array( $fieldTab->useraccessgroupid, getChildGIDS( userGID( $_CB_framework->myId() ) ) ) ) {
- echo "<script type="text/javascript"> alert('Unauthorized Access'); window.history.go(-1);</script>n";
- exit;
- }
- }
- $_PLUGINS->loadPluginGroup( 'user' );
- if ( ! _prov_bind_CB_field( $row, $fid ) ) {
- echo "<script type="text/javascript"> alert('" . $row->getError() . "'); window.history.go(-1); </script>n";
- exit();
- }
- // in case the above changed perms.... really ?
- $fieldTab = new moscomprofilerTabs( $_CB_database );
- $fieldTab->load( (int) $row->tabid );
- if ( ! in_array( $fieldTab->useraccessgroupid, getChildGIDS( userGID( $_CB_framework->myId() ) ) ) ) {
- echo "<script type="text/javascript"> alert('Unauthorized Access'); window.history.go(-1);</script>n";
- exit;
- }
- if ($row->type == 'webaddress') {
- $row->rows = $_POST['webaddresstypes'];
- if ( !(($row->rows == 0) || ($row->rows == 2)) ) {
- $row->rows = 0;
- }
- }
- if ( $_POST['oldtabid'] != $_POST['tabid'] ) {
- if ( $_POST['oldtabid'] !== '' ) {
- //Re-order old tab
- $sql = "UPDATE #__comprofiler_fields SET ordering = ordering-1 WHERE ordering > ".(int) $_POST['ordering']." AND tabid = ".(int) $_POST['oldtabid'];
- $_CB_database->setQuery($sql);
- $_CB_database->query();
- }
- //Select Last Order in New Tab
- $sql = "SELECT MAX(ordering) FROM #__comprofiler_fields WHERE tabid=".(int) $_POST['tabid'];
- $_CB_database->SetQuery($sql);
- $max = $_CB_database->LoadResult();
- $row->ordering = max( $max + 1, 1 );
- }
- if ( cbStartOfStringMatch( $row->name, 'cb_' ) ) {
- $row->name = str_replace(" ", "", strtolower($row->name));
- }
- if ( ! $row->check() ) {
- echo "<script type="text/javascript"> alert('".$row->getError()."'); window.history.go(-2); </script>n";
- exit();
- }
- if ( ! $row->store( (int) $fid ) ) {
- echo "<script type="text/javascript"> alert('".$row->getError()."'); window.history.go(-2); </script>n";
- exit();
- }
- $fieldNames = array();
- $fieldNames = $_POST['vNames'];
- $j = 1;
- if( $row->fieldid > 0 ) {
- $_CB_database->setQuery( "DELETE FROM #__comprofiler_field_values"
- . " WHERE fieldid = " . (int) $row->fieldid );
- if( $_CB_database->query() === false ) {
- echo $_CB_database->getErrorMsg();
- }
- } else {
- $_CB_database->setQuery( "SELECT MAX(fieldid) FROM #__comprofiler_fields");
- $maxID = $_CB_database->loadResult();
- $row->fieldid = $maxID;
- echo $_CB_database->getErrorMsg();
- }
- //for($i=0, $n=count( $fieldNames ); $i < $n; $i++) {
- foreach ($fieldNames as $fieldName) {
- if(trim($fieldName)!=null || trim($fieldName)!='') {
- $_CB_database->setQuery( "INSERT INTO #__comprofiler_field_values (fieldid,fieldtitle,ordering)"
- . " VALUES( " . (int) $row->fieldid . ",'".cbGetEscaped($fieldName)."', " . (int) $j . ")"
- );
- if ( $_CB_database->query() === false ) {
- echo $_CB_database->getErrorMsg();
- }
- $j++;
- }
- }
- switch ( $task ) {
- case 'applyField':
- $msg = 'Successfully Saved changes to Field: '. $row->name;
- cbRedirect( 'index2.php?option='. $option .'&task=editField&cid='. $row->fieldid, $msg );
- break;
- case 'saveField':
- default:
- $msg = 'Successfully Saved Field: '. $row->name;
- cbRedirect( 'index2.php?option='. $option .'&task=showField' , $msg );
- break;
- }
- }
- function removeField( $cid, $option ) {
- global $_CB_database, $_CB_framework;
- if (!is_array( $cid ) || count( $cid ) < 1) {
- echo "<script type="text/javascript"> alert('Select an item to delete'); window.history.go(-1);</script>n";
- exit;
- }
- $msg = '';
- if (count( $cid )) {
- $obj = new moscomprofilerFields( $_CB_database );
- $deletedOkNames = array();
- foreach ($cid as $id) {
- $id = (int) $id;
- $obj->load( $id );
- $fieldTab = new moscomprofilerTabs( $_CB_database );
- $fieldTab->load( (int) $obj->tabid );
- if ( ! in_array( $fieldTab->useraccessgroupid, getChildGIDS( userGID( $_CB_framework->myId() ) ) ) ) {
- echo "<script type="text/javascript"> alert('Unauthorized Access'); window.history.go(-1);</script>n";
- exit;
- }
- $noDelete = 0;
- $_CB_database->setQuery("SELECT COUNT(*) FROM #__comprofiler_lists".
- " WHERE col1fields like '%|*|$id' OR col1fields like '$id|*|%' OR col1fields like '%|*|$id|*|%' OR col1fields='$id'".
- " OR col2fields like '%|*|$id' OR col2fields like '$id|*|%' OR col2fields like '%|*|$id|*|%' OR col2fields='$id'".
- " OR col3fields like '%|*|$id' OR col3fields like '$id|*|%' OR col3fields like '%|*|$id|*|%' OR col3fields='$id'".
- " OR col4fields like '%|*|$id' OR col4fields like '$id|*|%' OR col4fields like '%|*|$id|*|%' OR col4fields='$id'");
- $onList = $_CB_database->loadResult();
- if ($onList > 0) {
- $msg .= getLangDefinition($obj->title) . " cannot be deleted because it is on a List. n";
- $noDelete = 1;
- }
- if ($obj->sys==1) {
- $msg .= getLangDefinition($obj->title) ." cannot be deleted because it is a system field. n";
- $noDelete = 1;
- }
- if ($noDelete != 1) {
- if ( $obj->deleteDataDescr( $id ) ) {
- $sql="UPDATE #__comprofiler_fields SET ordering = ordering-1 WHERE ordering > ".(int) $obj->ordering." AND tabid = ".(int) $obj->tabid;
- $_CB_database->setQuery($sql);
- $_CB_database->query();
- $deletedOkNames[] = $obj->title;
- }
- }
- }
- }
- if ( ! $msg ) {
- $msg = 'Successfully Deleted Fields: '. implode( ', ', $deletedOkNames );
- }
- cbRedirect( "index2.php?option=$option&task=showField", $msg );
- }
- function orderFields( $fid, $inc, $option ) {
- global $_CB_database, $_CB_framework;
- $row = new moscomprofilerFields( $_CB_database );
- $row->load( (int) $fid );
- $fieldTab = new moscomprofilerTabs( $_CB_database );
- $fieldTab->load( (int) $row->tabid );
- if ( ! in_array( $fieldTab->useraccessgroupid, getChildGIDS( userGID( $_CB_framework->myId() ) ) ) ) {
- echo "<script type="text/javascript"> alert('Unauthorized Access'); window.history.go(-1);</script>n";
- exit;
- }
- $row->move( $inc , "tabid='$row->tabid'");
- cbRedirect( "index2.php?option=$option&task=showField" );
- }
- function showTab( $option ) {
- global $_CB_database, $_CB_framework, $_CB_joomla_adminpath;
- $limit = (int) $_CB_framework->getCfg( 'list_limit' );
- if ( $limit == 0 ) {
- $limit = 10;
- }
- $limit = $_CB_framework->getUserStateFromRequest( "viewlistlimit", 'limit', $limit );
- $lastCBlist = $_CB_framework->getUserState( "view{$option}lastCBlist", null );
- if($lastCBlist=='showtab') {
- $limitstart = $_CB_framework->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 );
- $lastSearch = $_CB_framework->getUserState( "search{$option}", null );
- $search = $_CB_framework->getUserStateFromRequest( "search{$option}", 'search', '' );
- if ($lastSearch != $search) {
- $limitstart = 0;
- $_CB_framework->setUserState( "view{$option}limitstart", $limitstart );
- }
- $search = trim( strtolower( $search ) );
- } else {
- clearSearchBox();
- $search="";
- $limitstart = 0;
- $_CB_framework->setUserState( "view{$option}limitstart", $limitstart );
- $_CB_framework->setUserState( "view{$option}lastCBlist", "showtab" );
- }
- $where = array();
- if (isset( $search ) && $search!= "") {
- $search = cbEscapeSQLsearch( trim( strtolower( cbGetEscaped($search))));
- $where[] = "(a.title LIKE '%$search%')";
- }
- $where[] = "a.useraccessgroupid IN (".implode(',',getChildGIDS(userGID( $_CB_framework->myId() ))).")";
- $_CB_database->setQuery( "SELECT COUNT(*)"
- . "nFROM #__comprofiler_tabs AS a"
- . (count( $where ) ? "nWHERE " . implode( ' AND ', $where ) : "")
- );
- $total = $_CB_database->loadResult();
- echo $_CB_database->getErrorMsg();
- if ($total <= $limitstart) $limitstart = 0;
- cbimport( 'cb.pagination' );
- $pageNav = new cbPageNav( $total, $limitstart, $limit );
- $_CB_database->setQuery( "SELECT a.*, p.name AS pluginname, p.published AS pluginpublished "
- . "nFROM #__comprofiler_tabs AS a"
- . "n LEFT JOIN #__comprofiler_plugin AS p ON p.id = a.pluginid"
- . (count( $where ) ? "nWHERE " . implode( ' AND ', $where ) : "")
- . "n ORDER BY position, ordering"
- . "nLIMIT " . (int) $pageNav->limitstart . ", " . (int) $pageNav->limit
- );
- $rows = $_CB_database->loadObjectList();
- if ($_CB_database->getErrorNum()) {
- echo $_CB_database->stderr();
- return false;
- }
- HTML_comprofiler::showTabs( $rows, $pageNav, $search, $option );
- return true;
- }
- /**
- * @param string $sql SQL with ordering As value and 'name field' AS text
- * @param int $chop The length of the truncated headline
- * @param boolean $translate translate to CB language
- * @return array of makeOption
- * @access private
- */
- function _cbGetOrderingList( $sql, $chop = 30, $translate = true ) {
- global $_CB_database;
- $order = array();
- $_CB_database->setQuery( $sql );
- if ( false === ( $orders = $_CB_database->loadObjectList() ) ) {
- if ( $_CB_database->getErrorNum() ) {
- echo $_CB_database->stderr();
- return false;
- } else {
- $order[] = moscomprofilerHTML::makeOption( 1, 'first' );
- return $order;
- }
- }
- $order[] = moscomprofilerHTML::makeOption( 0, '0 ' . 'first' );
- for ( $i=0, $n = count( $orders ); $i < $n; $i++ ) {
- if ( $translate ) {
- $text = getLangDefinition( $orders[$i]->text );
- } else {
- $text = $orders[$i]->text;
- }
- if ( strlen( $text ) > $chop ) {
- $text = substr( $text, 0, $chop ) . '...';
- }
- $order[] = moscomprofilerHTML::makeOption( $orders[$i]->value, $orders[$i]->value . ' (' . $text . ')' );
- }
- if ( isset( $orders[$i - 1] ) ) {
- $order[] = moscomprofilerHTML::makeOption( $orders[$i - 1]->value + 1, ( $orders[$i - 1]->value + 1 ) . ' ' . 'last' );
- }
- return $order;
- }
- function editTab( $tid='0', $option='com_comprofiler' ) {
- global $_CB_database, $_CB_framework;
- $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('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 );
- /*
- -------------------------
- ! head !
- !-----------------------!
- ! ! ! !
- ! left ! middle ! right !
- ! ! ! !
- !-----------------------!
- ! !
- ! tabmain !
- ! !
- !-----------------------!
- ! underall !
- -------------------------
- ! ! ! !
- ! L1C1 ! L1C2 ! L1C3 !
- ! ! ! !
- !-----------------------!
- ! ! ! !
- ! L2C1 ! L2C4 ! L2C8 !
- ! ! ! !
- !-----------------------!
- ! !
- ! L4C7 !
- ! !
- !-----------------------!
- ! ! !
- ! L8C3 ! L8C4 !
- ! ! !
- !-----------------------!
- */
- $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, 'Line ' . $i . ' Column ' . $j );
- }
- }
- 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( '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 );
- $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 = _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 .'" />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
- .'" />New items default to the last place. Ordering can be changed after this item is saved.';
- }
- $gtree3=array();
- $gtree3[] = moscomprofilerHTML::makeOption( -2 , '- Everybody -' );
- $gtree3[] = moscomprofilerHTML::makeOption( -1, '- 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 );
- HTML_comprofiler::edittab( $row, $option, $lists, $tid );
- }
- function saveTab( $option ) {
- global $_CB_database, $_CB_framework, $_POST;
- if ( isset( $_POST['params'] ) ) {
- $_POST['params'] = cbParamsEditorController::getRawParams( $_POST['params'] );
- } else {
- $_POST['params'] = '';
- }
- if ( ! isset( $_POST['tabid'] ) || ( count( $_POST ) == 0 ) ) {
- echo "<script type="text/javascript"> alert('Missing post values'); window.history.go(-2); </script>n";
- exit();
- }
- if ( $_POST['tabid'] ) {
- $oldrow = new moscomprofilerTabs( $_CB_database );
- if ( $oldrow->load( (int) $_POST['tabid'] )
- && ( ! in_array( $oldrow->useraccessgroupid, getChildGIDS( userGID( $_CB_framework->myId() ) ) ) ) ) {
- echo "<script type="text/javascript"> alert('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();
- }
- if ( ! $row->ordering_register ) {
- $row->ordering_register = 10;
- }
- if (!$row->check()) {
- echo "<script type="text/javascript"> alert('".$row->getError()."'); window.history.go(-2); </script>n";
- exit();
- }
- if ( ! $row->store( (int) $_POST['tabid'] ) ) {
- echo "<script type="text/javascript"> alert('".$row->getError()."'); window.history.go(-2); </script>n";
- exit();
- }
- $row->checkin();
- cbRedirect( "index2.php?option=$option&task=showTab", "Successfully Saved Tab: ". $row->title );
- }
- function removeTabs( $cid, $option ) {
- global $_CB_database, $_CB_framework;
- if (!is_array( $cid ) || count( $cid ) < 1) {
- echo "<script type="text/javascript"> alert('Select an item to delete'); window.history.go(-1);</script>n";
- exit;
- }
- $msg = '';
- if (count( $cid )) {
- $obj = new moscomprofilerTabs( $_CB_database );
- foreach ($cid as $id) {
- $noDelete = 0;
- $obj->load( (int) $id );
- if ( ! in_array( $obj->useraccessgroupid, getChildGIDS( userGID( $_CB_framework->myId() ) ) ) ) {
- echo "<script type="text/javascript"> alert('Unauthorized Access'); window.history.go(-1);</script>n";
- exit;
- }
- $_CB_database->setQuery( "SELECT COUNT(*) FROM #__comprofiler_fields WHERE tabid=" . (int) $id );
- $onField = $_CB_database->loadResult();
- if( $obj->sys > 0 ) {
- $msg .= getLangDefinition($obj->title) ." cannot be deleted because it is a system tab. n";
- $noDelete = 1;
- }
- if( $obj->pluginid ) {
- $plugin = new moscomprofilerPlugin( $_CB_database );
- if ( $plugin->load( $obj->pluginid ) ) {
- $msg .= getLangDefinition($obj->title) ." cannot be deleted because it is a tab belonging to an installed plugin. n";
- $noDelete = 1;
- }
- }
- if( $onField > 0 ) {
- $msg .= getLangDefinition($obj->title) ." is being referenced by an existing field and cannot be deleted!";
- $noDelete = 1;
- }
- if( $noDelete == 0 ) {
- $obj->delete( $id );
- $msg .= $obj->getError();
- }
- }
- }
- if ( $msg ) {
- echo "<script type="text/javascript"> alert('" . str_replace( "n", '\n', addslashes( $msg ) ) . "'); window.history.go(-1);</script>n";
- exit;
- }
- cbRedirect( "index2.php?option=$option&task=showTab" );
- }
- function orderTabs( $tid, $inc, $option ) {
- global $_CB_database, $_CB_framework;
- $row = new moscomprofilerTabs( $_CB_database );
- $row->load( (int) $tid );
- if ( ! in_array( $row->useraccessgroupid, getChildGIDS( userGID( $_CB_framework->myId() ) ) ) ) {
- echo "<script type="text/javascript"> alert('Unauthorized Access'); window.history.go(-1);</script>n";
- exit;
- }
- $row->move( $inc, "position='$row->position' AND ordering > -10000 AND ordering < 10000 " );
- cbRedirect( "index2.php?option=$option&task=showTab" );
- }
- function showUsers( $option ) {
- global $_CB_database, $_CB_framework,$_POST, $_CB_joomla_adminpath, $_PLUGINS;
- $limit = (int) $_CB_framework->getCfg( 'list_limit' );
- if ( $limit == 0 ) {
- $limit = 10;
- }
- $limit = $_CB_framework->getUserStateFromRequest( "viewlistlimit", 'limit', $limit );
- $filter_type = $_CB_framework->getUserStateFromRequest( "filter_type{$option}", 'filter_type', 0 );
- $filter_status = $_CB_framework->getUserStateFromRequest( "filter_status{$option}", 'filter_status', 0 );
- $filter_logged = intval( $_CB_framework->getUserStateFromRequest( "filter_logged{$option}", 'filter_logged', 0 ) );
- $lastCBlist = $_CB_framework->getUserState( "view{$option}lastCBlist", null );
- if( $lastCBlist == 'showusers' ) {
- $limitstart = $_CB_framework->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 );
- $lastSearch = $_CB_framework->getUserState( "search{$option}", null );
- $search = $_CB_framework->getUserStateFromRequest( "search{$option}", 'search', '' );
- if ( $lastSearch != $search ) {
- $limitstart = 0;
- $_CB_framework->setUserState( "view{$option}limitstart", $limitstart );
- }
- $search = trim( strtolower( $search ) );
- } else {
- $filter_type = 0;
- $filter_status = 0;
- $filter_logged = 0;
- clearSearchBox();
- $search = '';
- $limitstart = 0;
- $_CB_framework->setUserState( "view{$option}limitstart", $limitstart );
- $_CB_framework->setUserState( "view{$option}lastCBlist", "showusers" );
- }
- $tablesSQL = array();
- $joinsSQL = array();
- $tablesWhereSQL = array();
- if ( isset( $search ) && ( $search != "") ) {
- $tablesWhereSQL[] = "(u.username LIKE '%" . cbEscapeSQLsearch( $_CB_database->getEscaped( $search ) ) . "%' OR u.email LIKE '%" . cbEscapeSQLsearch( $_CB_database->getEscaped( $search ) ) . "%' OR u.name LIKE '%" . cbEscapeSQLsearch( $_CB_database->getEscaped( $search ) ) . "%')";
- }
- if ( $filter_type ) {
- if ( $filter_type == 'Public Frontend' ) {
- $tablesWhereSQL[] = "(u.usertype = 'Registered' OR u.usertype = 'Author' OR u.usertype = 'Editor'OR u.usertype = 'Publisher')";
- } else if ( $filter_type == 'Public Backend' ) {
- $tablesWhereSQL[] = "(u.usertype = 'Manager' OR u.usertype = 'Administrator' OR u.usertype = 'Super Administrator')";
- } else {
- $tablesWhereSQL[] = "u.usertype = " . $_CB_database->Quote( $filter_type );
- }
- }
- $userstates = array( 'Blocked' => 'u.block = 1',
- 'Enabled' => 'u.block = 0',
- 'Unconfirmed' => 'ue.confirmed = 0',
- 'Confirmed' => 'ue.confirmed = 1',
- 'Unapproved' => 'ue.approved = 0',
- 'Disapproved' => 'ue.approved = 2',
- 'Approved' => 'ue.approved = 1',
- 'Banned' => 'ue.banned <> 0',
- 'Blocked + Unconfirmed + Unapproved' => '(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 0)',
- 'Enabled + Unconfirmed + Unapproved' => '(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 0)',
- 'Blocked + Confirmed + Unapproved' => '(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 0)',
- 'Enabled + Confirmed + Unapproved' => '(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 0)',
- 'Blocked + Unconfirmed + Disapproved' => '(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 2)',
- 'Enabled + Unconfirmed + Disapproved' => '(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 2)',
- 'Blocked + Confirmed + Disapproved' => '(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 2)',
- 'Enabled + Confirmed + Disapproved' => '(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 2)',
- 'Blocked + Unconfirmed + Approved' => '(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 1)',
- 'Enabled + Unconfirmed + Approved' => '(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 1)',
- 'Blocked + Confirmed + Approved' => '(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 1)',
- 'Enabled + Confirmed + Approved' => '(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 1)' );
- if ( $filter_status ) {
- $tablesWhereSQL[] = $userstates[$filter_status];
- }
- if ( $filter_logged == 1 ) {
- $tablesWhereSQL[] = "s.userid = u.id";
- } else if ($filter_logged == 2) {
- $tablesWhereSQL[] = "s.userid IS NULL";
- }
- // exclude any child group id's for this user
- //$_CB_framework->acl->_debug = true;
- $pgids = $_CB_framework->acl->get_group_children( userGID( $_CB_framework->myId() ), 'ARO', 'RECURSE' );
- if ( is_array( $pgids ) && (count( $pgids ) > 0 ) ) {
- $tablesWhereSQL[] = "(u.gid NOT IN (" . implode( ',', $pgids ) . "))";
- }
- if ($filter_logged == 1 || $filter_logged == 2) {
- $joinsSQL[] .= "n INNER JOIN #__session AS s ON s.userid = u.id";
- // } else { done later, to avoid blocking site:
- // $joinsSQL[] .= "n LEFT JOIN #__session AS s ON s.userid = u.id";
- }
- $_PLUGINS->loadPluginGroup('user');
- $_PLUGINS->trigger( 'onBeforeBackendUsersListBuildQuery', array( &$tablesSQL, &$joinsSQL, &$tablesWhereSQL, $option ) ); //TBD: $tablesSQL still not used
- $queryFrom = "FROM " . implode( ', ', $tablesSQL ) . " " . implode( "n ", $joinsSQL ) . "n WHERE " . implode( "n AND ", $tablesWhereSQL );
- $query = "SELECT COUNT(u.id)"
- . "n FROM #__users AS u"
- . "n LEFT JOIN #__comprofiler AS ue ON u.id = ue.id"
- . ( count( $joinsSQL ) ? "n " . implode( "n ", $joinsSQL ) : '' )
- . ( count( $tablesWhereSQL ) ? "n WHERE " . implode( ' AND ', $tablesWhereSQL ) : '' )
- ;
- $_CB_database->setQuery( $query );
- $total = $_CB_database->loadResult();
- if ( $total === null ) {
- echo $_CB_database->getErrorMsg();
- }
- if ( $total <= $limitstart ) {
- $limitstart = 0;
- }
- cbimport( 'cb.pagination' );
- $pageNav = new cbPageNav( $total, $limitstart, $limit );
- if ( checkJversion() <= 0 ) {
- $query = "SELECT DISTINCT u.*, g.name AS groupname, ue.approved,ue.confirmed"
- . "n FROM #__users AS u"
- . "n LEFT JOIN #__comprofiler AS ue ON u.id = ue.id"
- . "n INNER JOIN #__core_acl_aro AS aro ON aro.value = u.id" // map user to aro
- . "n INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.aro_id" // map aro to group
- . "n INNER JOIN #__core_acl_aro_groups AS g ON g.group_id = gm.group_id"
- . ( count( $joinsSQL ) ? "n " . implode( "n ", $joinsSQL ) : '' )
- ;
- } else {
- $query = "SELECT DISTINCT u.*, g.name AS groupname, ue.approved, ue.confirmed"
- . "n FROM #__users AS u"
- . "n LEFT JOIN #__comprofiler AS ue ON u.id = ue.id"
- . "n INNER JOIN #__core_acl_aro AS aro ON aro.value = u.id" // map user to aro
- . "n INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id" // map aro to group
- . "n INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id"
- . ( count( $joinsSQL ) ? "n " . implode( "n ", $joinsSQL ) : '' )
- ;
- }
- $query .= "n WHERE aro.section_value = 'users' "
- . (count( $tablesWhereSQL ) ? "n AND " . implode( ' AND ', $tablesWhereSQL ) : "")
- . "n LIMIT " . (int) $pageNav->limitstart . ", " . (int) $pageNav->limit
- ;
- $_CB_database->setQuery( $query );
- $rows = $_CB_database->loadObjectList();
- if ($_CB_database->getErrorNum()) {
- echo $_CB_database->stderr();
- return false;
- }
- $template = 'SELECT COUNT(s.userid) FROM #__session AS s WHERE s.userid = ';
- $n = count( $rows );
- for ( $i = 0; $i < $n; $i++ ) {
- $row = &$rows[$i];
- $query = $template . (int) $row->id;
- $_CB_database->setQuery( $query );
- $row->loggedin = $_CB_database->loadResult();
- }
- // get list of Log Status for dropdown filter
- $logged[] = moscomprofilerHTML::makeOption( 0, '- Select Login State - ');
- $logged[] = moscomprofilerHTML::makeOption( 1, 'Logged In');
- $lists['logged'] = moscomprofilerHTML::selectList( $logged, 'filter_logged', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_logged", 2 );
- // get list of Groups for dropdown filter
- $query = "SELECT name AS value, name AS text"
- . "n FROM #__core_acl_aro_groups"
- . "n WHERE name != 'ROOT'"
- . "n AND name != 'USERS'"
- ;
- $types[] = moscomprofilerHTML::makeOption( '0', '- Select Group -' );
- $_CB_database->setQuery( $query );
- $types = array_merge( $types, $_CB_database->loadObjectList() );
- $lists['type'] = moscomprofilerHTML::selectList( $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_type", 2 );
- $status[] = moscomprofilerHTML::makeOption( 0, '- Select User Status - ');
- foreach ( array_keys( $userstates ) as $k ) {
- $status[] = moscomprofilerHTML::makeOption( $k, $k );
- }
- $lists['status'] = moscomprofilerHTML::selectList( $status, 'filter_status', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_status", 2 );
- $pluginAdditions = $_PLUGINS->trigger( 'onAfterBackendUsersList', array( 1, &$rows, &$pageNav, &$search, &$lists, $option ) );
- $pluginColumns = array();
- foreach ( $pluginAdditions as $addition ) {
- if ( is_array( $addition ) ) {
- $pluginColumns = array_merge( $pluginColumns, $addition );
- }
- }
- HTML_comprofiler::showUsers( $rows, $pageNav, stripslashes($search), $option, $lists, $pluginColumns );
- return true;
- }
- function editUser( $uid = '0', $option = 'users' ) {
- global $_CB_framework, $_CB_database, $_PLUGINS;
- $msg = checkCBpermissions( array($uid), "edit", true );
- if ($msg) {
- echo "<script type="text/javascript"> alert('".$msg."'); window.history.go(-1);</script>n";
- exit;
- }
- $_PLUGINS->loadPluginGroup('user');
- $user = new moscomprofilerUser( $_CB_database );
- $cmsUserExists = $user->load( (int) $uid );
- $comprofilerExists = ( $user->user_id != null );
- if ( $cmsUserExists && $comprofilerExists ) {
- // Edit existing CB user:
- $newCBuser = '0';
- } else {
- $newCBuser = '1';
- if ( $cmsUserExists ) {
- // Edit existing CMS (but new CB) user:
- $user->approved = '1';
- $user->confirmed = '1';
- } else {
- // New user:
- $user->block = '0';
- $user->approved = '1';
- $user->confirmed = '1';
- $user->sendEmail = '0';
- $user->gid = $_CB_framework->acl->get_group_id( $_CB_framework->getCfg( 'new_usertype' ), 'ARO' );
- }
- }
- $null = null;
- HTML_comprofiler::edituser( $user, $option, $newCBuser, $null );
- }
- function saveUser( $option ) {
- global $_CB_framework, $_CB_database, $ueConfig, $_POST, $_PLUGINS, $task;
- if ( ! ( isset( $_POST['approved'] ) && isset( $_POST['confirmed'] ) && isset( $_POST['username'] ) ) ) {
- echo "<script type="text/javascript"> alert('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 ) {
- $msg = checkCBpermissions( array( $userIdPosted ), 'save', in_array( $myGid, array( 24, 25 ) ) );
- } else {
- $msg = checkCBpermissions( null, 'save', in_array( $myGid, array( 24, 25 ) ) );
- }
- 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(), 'profile' );
- if ( ! $saveResult ) {
- $regErrorMSG = $userComplete->getError();
- $msg = checkCBpermissions( array( $userComplete->id ), "edit", true );
- if ($msg) {
- echo "<script type="text/javascript"> alert('".$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...
- HTML_comprofiler::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( "index2.php?option=$option&task=showusers", "Successfully Saved User: ". $userComplete->username );
- }
- function deleteUsers( $cid, $inComprofilerOnly = false ) {
- global $_CB_framework, $_CB_database;
- $msg = checkCBpermissions( $cid, "delete" );
- if (!$msg && is_array( $cid ) && count( $cid )) {
- $tabs = new cbTabs( 0, 2, null, false ); // loads plugins
- foreach ($cid as $id) {
- $obj =& $_CB_framework->_getCmsUserObject( (int) $id );
- if ( ( $obj !== null ) || $inComprofilerOnly ) {
- $count = 2;
- if ( ( $obj !== null ) && ( $obj->gid == 25 ) ) {
- // count number of active super admins
- $query = "SELECT COUNT( id )"
- . "n FROM #__users"
- . "n WHERE gid = 25"
- . "n AND block = 0"
- ;
- $_CB_database->setQuery( $query );
- $count = $_CB_database->loadResult();
- }
- if ( $count <= 1 && $obj->gid == 25 ) {
- // cannot delete Super Admin where it is the only one that exists
- $msg .= "You cannot delete this Super Administrator as it is the only active Super Administrator for your site";
- } else {
- // delete user
- $result = cbDeleteUser( $id, null, $inComprofilerOnly );
- if ( $result === null ) {
- $msg .= "User not found";
- } elseif (is_string( $result ) && ( $result != "" ) ) {
- $msg .= $result;
- }
- }
- } else {
- $msg .= "User not found";
- }
- }
- }
- return $msg;
- }
- function removeUsers( $cid, $option ) {
- if (!is_array( $cid ) || count( $cid ) < 1) {
- echo "<script type="text/javascript"> alert('Select an item to delete'); window.history.go(-1);</script>n";
- exit;
- }
- $msg = deleteUsers($cid);
- if ($msg) {
- echo "<script type="text/javascript"> alert('".$msg."'); window.history.go(-1);</script>n";
- exit;
- }
- cbRedirect( "index2.php?option=$option&task=showusers", $msg );
- }
- /**
- * Blocks or Unblocks one or more user records
- * @param array An array of unique category id numbers
- * @param integer 0 if unblock, 1 if blocking
- * @param string The current url option
- */
- function changeUserBlock( $cid=null, $block=1, $option ) {
- $action = $block ? 'block' : 'unblock';
- changeUsersStatus( $cid, $action, $block, $option );
- }
- /**
- * Approves or Rejects one or more user records
- * @param array An array of unique category id numbers
- * @param integer 0 if reject, 1 if approve
- * @param string The current url option
- */
- function approveUser( $cid=null, $approved=1, $option ) {
- $action = $approved ? 'Approve' : 'Reject';
- changeUsersStatus( $cid, $action, $approved, $option );
- }
- /**
- * Change users status
- *
- * @param array of int $cid
- * @param string $action ( Approve, Reject, block, unblock )
- * @param int $actionValue
- * @param string $option
- */
- function changeUsersStatus( $cid=null, $action, $actionValue, $option ) {
- global $_CB_database, $ueConfig, $_PLUGINS;
- if (count( $cid ) < 1) {
- echo "<script type="text/javascript"> alert('Select an item to $action'); window.history.go(-1);</script>n";
- exit;
- }
- $msg = checkCBpermissions( $cid, $action );
- if ($msg) {
- echo "<script type="text/javascript"> alert('".$msg."'); window.history.go(-1);</script>n";
- exit;
- }
- cbArrayToInts($cid);
- $cids = implode( ',', $cid );
- $_PLUGINS->loadPluginGroup('user');
- $query = "SELECT * FROM #__comprofiler c, #__users u WHERE c.id=u.id AND c.id IN ( " . $cids . " )";
- $_CB_database->setQuery($query);
- $users = $_CB_database->loadObjectList();
- foreach ( $users as $row ) {
- switch ( $action ) {
- case 'Approve':
- case 'Reject':
- if ($actionValue == 0) {
- $approved = 2; // "rejected"
- } else {
- $approved = $actionValue;
- }
- $_PLUGINS->trigger( 'onBeforeUserApproval', array( $row, $approved ) );
- $_CB_database->setQuery( "UPDATE #__comprofiler SET approved=" . (int) $approved . " WHERE id = " . (int) $row->id );
- if ($_CB_database->query()) {
- if($approved==1) {
- if( isset( $ueConfig['emailpass'] ) && ( $ueConfig['emailpass'] == "1" ) ) {
- $pwd = cbMakeRandomString( 8, true );
- $row->password = $pwd;
- $pwd = cbHashPassword( $pwd );
- $_CB_database->setQuery( "UPDATE #__users SET password='" . $_CB_database->getEscaped($pwd) . "' WHERE id = " . (int) $row->id );
- $_CB_database->query();
- //createEmail($row, 'welcome', $ueConfig,null,1);
- }
- $_PLUGINS->trigger('onAfterUserApproval',array($row,$approved,true));
- if ($row->approved == 0 && $approved == 1 && $row->confirmed == 1 ) {
- $row->approved = 1;
- activateUser($row, 2, "UserApproval", false);
- }
- //$tabs = new cbTabs( 0, 2);
- //$tabs->confirmRegistrationPluginTabs($row);
- }
- }
- break;
- case 'block':
- case 'unblock':
- $_PLUGINS->trigger( 'onBeforeUserBlocking', array( $row, $actionValue ) );
- $_CB_database->setQuery( "UPDATE #__users SET block = " . (int) $actionValue . " WHERE id = " . (int) $row->id );
- if ($_CB_database->query()) {
- // if action is to block a user, delete user acounts active sessions
- if ( $actionValue == 1 ) {
- $query = "DELETE FROM #__session"
- . "n WHERE userid = " . (int) $row->id;
- $_CB_database->setQuery( $query );
- $_CB_database->query();
- }
- }
- break;
- default:
- echo "<script type="text/javascript"> alert('unknown action ".$action."'); window.history.go(-1);</script>n";
- exit;
- break;
- }
- }
- cbRedirect( "index2.php?option=$option&task=showusers" );
- }
- function cbIsEmail($email){
- $rBool=false;
- if(preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $email)){
- $rBool=true;
- }
- return $rBool;
- }
- function showConfig( $option ) {
- global $_CB_framework, $_CB_database,$ueConfig;
- global $_CB_adminpath;
- cbimport( 'cb.adminfilesystem' );
- $adminFS =& cbAdminFileSystem::getInstance();
- $configfile = $_CB_adminpath."/ue_config.php";
- //Add code to check if config file is writeable.
- if ( $adminFS->isUsingStandardPHP() && ! is_writable($configfile)) {
- @chmod ($configfile, 0766);
- $permission = is_writable($configfile);
- if (!$permission) {
- echo "<center><h1><font color=red>" . _UE_WARNING . "...</font></h1><BR>";
- echo "<b>" . _UE_YOUR_CONFIG_FILE . ": $configfile <font color=red>" . _UE_IS_NOT_WRITABLE . "</font></b><br />";
- echo "<b>" . _UE_NEED_TO_CHMOD_CONFIG . "</b></center><br /><br />";
- }
- }
- $lists = array();
- // make a standard yes/no list
- $yesno = array();
- $yesno[] = moscomprofilerHTML::makeOption( '0', _UE_NO );
- $yesno[] = moscomprofilerHTML::makeOption( '1', _UE_YES );
- $admin_allowcbregistration = array();
- $admin_allowcbregistration[] = moscomprofilerHTML::makeOption( '0', _UE_REG_ALLOWREG_SAME_AS_GLOBAL );
- $admin_allowcbregistration[] = moscomprofilerHTML::makeOption( '1', _UE_REG_ALLOWREG_YES );
- $conNotifyTypes=array();
- $conNotifyTypes[] = moscomprofilerHTML::makeOption( '0', _UE_NONE );
- $conNotifyTypes[] = moscomprofilerHTML::makeOption( '1', 'Email' );
- $conNotifyTypes[] = moscomprofilerHTML::makeOption( '2', 'PMS' );
- $conNotifyTypes[] = moscomprofilerHTML::makeOption( '3', 'PMS+Email' );
- $dateformats = array();
- $dateformats[] = moscomprofilerHTML::makeOption('Y/m/d','yyyy/mm/dd');
- $dateformats[] = moscomprofilerHTML::makeOption('d/m/y','dd/mm/yy');
- $dateformats[] = moscomprofilerHTML::makeOption('y/m/d','yy/mm/dd');
- $dateformats[] = moscomprofilerHTML::makeOption('d/m/Y','dd/mm/yyyy');
- $dateformats[] = moscomprofilerHTML::makeOption('m/d/y','mm/dd/yy');
- $dateformats[] = moscomprofilerHTML::makeOption('m/d/Y','mm/dd/yyyy');
- $dateformats[] = moscomprofilerHTML::makeOption('Y-m-d','yyyy-mm-dd');
- $dateformats[] = moscomprofilerHTML::makeOption('d-m-y','dd-mm-yy');
- $dateformats[] = moscomprofilerHTML::makeOption('y-m-d','yy-mm-dd');
- $dateformats[] = moscomprofilerHTML::makeOption('d-m-Y','dd-mm-yyyy');
- $dateformats[] = moscomprofilerHTML::makeOption('m-d-y','mm-dd-yy');
- $dateformats[] = moscomprofilerHTML::makeOption('m-d-Y','mm-dd-yyyy');
- $dateformats[] = moscomprofilerHTML::makeOption('Y.m.d','yyyy.mm.dd');
- $dateformats[] = moscomprofilerHTML::makeOption('d.m.y','dd.mm.yy');
- $dateformats[] = moscomprofilerHTML::makeOption('y.m.d','yy.mm.dd');
- $dateformats[] = moscomprofilerHTML::makeOption('d.m.Y','dd.mm.yyyy');
- $dateformats[] = moscomprofilerHTML::makeOption('m.d.y','mm.dd.yy');
- $dateformats[] = moscomprofilerHTML::makeOption('m.d.Y','mm.dd.yyyy');
- $calendartypes = array();
- $calendartypes[] = moscomprofilerHTML::makeOption('2', _UE_CALENDAR_TYPE_DROPDOWN_POPUP );
- $calendartypes[] = moscomprofilerHTML::makeOption('1', _UE_CALENDAR_TYPE_POPUP );
- $nameformats = array();
- $nameformats[] = moscomprofilerHTML::makeOption('1', _UE_REG_NAMEFORMAT_NAME_ONLY );
- $nameformats[] = moscomprofilerHTML::makeOption('2', _UE_REG_NAMEFORMAT_NAME_USERNAME );
- $nameformats[] = moscomprofilerHTML::makeOption('3', _UE_REG_NAMEFORMAT_USERNAME_ONLY );
- $nameformats[] = moscomprofilerHTML::makeOption('4', _UE_REG_NAMEFORMAT_USERNAME_NAME );
- $imgToolBox = new imgToolBox();
- $imgToolBox->_IM_path = $ueConfig['im_path'];
- $imgToolBox->_NETPBM_path = $ueConfig['netpbm_path'];
- $imageLibs = $imgToolBox->getImageLibs();
- $conversiontype = array();
- if(array_key_exists('imagemagick',$imageLibs)|| ($ueConfig['conversiontype']=='1')) $conversiontype[] = moscomprofilerHTML::makeOption('1','ImageMagick');
- if(array_key_exists('netpbm',$imageLibs) || ($ueConfig['conversiontype']=='2')) $conversiontype[] = moscomprofilerHTML::makeOption('2','NetPBM');
- if(array_key_exists('gd1',$imageLibs['gd']) || ($ueConfig['conversiontype']=='3')) $conversiontype[] = moscomprofilerHTML::makeOption('3','GD1 library');
- if(array_key_exists('gd2',$imageLibs['gd']) || ($ueConfig['conversiontype']=='4')) $conversiontype[] = moscomprofilerHTML::makeOption('4','GD2 library');
- $namestyles = array();
- $namestyles[] = moscomprofilerHTML::makeOption('1', _UE_REG_NAMEFORMAT_SINGLE_FIELD );
- $namestyles[] = moscomprofilerHTML::makeOption('2', _UE_REG_NAMEFORMAT_TWO_FIELDS );
- $namestyles[] = moscomprofilerHTML::makeOption('3', _UE_REG_NAMEFORMAT_THREE_FIELDS );
- $emailhandling = array();
- $emailhandling[] = moscomprofilerHTML::makeOption('1', _UE_REG_EMAILDISPLAY_EMAIL_ONLY );
- $emailhandling[] = moscomprofilerHTML::makeOption('2', _UE_REG_EMAILDISPLAY_EMAIL_W_MAILTO );
- $emailhandling[] = moscomprofilerHTML::makeOption('3', _UE_REG_EMAILDISPLAY_EMAIL_W_FORM );
- $emailhandling[] = moscomprofilerHTML::makeOption('4', _UE_REG_EMAILDISPLAY_EMAIL_NO );
- $emailreplyto = array();
- $emailreplyto[] = moscomprofilerHTML::makeOption('1',_UE_A_FROM_USER );
- $emailreplyto[] = moscomprofilerHTML::makeOption('2',_UE_A_FROM_ADMIN );
- $email_checker = array();
- $email_checker[] = moscomprofilerHTML::makeOption( '0', _UE_NO );
- $email_checker[] = moscomprofilerHTML::makeOption( '1', _UE_REG_EMAILCHECKER_VALID_EMAIL_ONLY );
- $email_checker[] = moscomprofilerHTML::makeOption( '2', _UE_REG_EMAILCHECKER_NOT_REGISTERED_AND_VALID_EMAIL );
- $connectionDisplay = array();
- $connectionDisplay[] = moscomprofilerHTML::makeOption( '0', _UE_PUBLIC );