private function _authorizedEdit($userIdPosted)
 {
     global $_CB_framework;
     $myCBuser = CBuser::getMyInstance();
     if (checkJversion() >= 2) {
         $iAmAdmin = $_CB_framework->acl->amIaSuperAdmin();
         if (!$iAmAdmin) {
             if ($myCBuser->authoriseAction('core.manage', 'com_users')) {
                 if ($userIdPosted == 0) {
                     $action = 'core.create';
                 } elseif ($userIdPosted == $_CB_framework->myId()) {
                     $action = 'core.edit.own';
                 } else {
                     $action = 'core.edit';
                 }
                 $iAmAdmin = $myCBuser->authoriseAction($action, 'com_users') && !$_CB_framework->acl->amIaSuperAdmin((int) $userIdPosted);
             }
         }
     } else {
         $myGids = $myCBuser->getUserData()->gids;
         $adminGroups = $_CB_framework->acl->mapGroupNamesToValues(array('Administrator', 'Superadministrator'));
         $iAmAdmin = count(array_intersect($myGids, $adminGroups)) > 0;
     }
     if (!$iAmAdmin) {
         echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T("Not Authorized")) . "'); window.history.go(-1);</script>\n";
         exit;
     }
 }
/**
 * Installs CBSubs, final part (ECHOs banners)
 *
 * @return void
 */
function plug_cbpaidsubscriptions_install()
{
    global $_CB_framework, $_CB_database;
    $installedVersion = '4.0.0';
    //CBSUBS_VERSION_AUTOMATICALLY_SET_DO_NOT_EDIT!!!
    ?>
<div style="width:100%;text-align:center">

	<div>
		<img alt="CBSubs Logo" height="300" width="300" src="<?php 
    echo $_CB_framework->getCfg('live_site');
    ?>
/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/icons/normal/cbsubs_logo_300.jpg" />
	</div>
	<h1>CBSubs <?php 
    echo $installedVersion;
    ?>
</h1>
    <p><strong>Copyright &copy; 2007-2015 and Trademark of Lightning MultiCom SA, Switzerland - www.joomlapolis.com - and its licensors, all rights reserved</strong></p>
    <p><strong>CBSubs is a Trademark of Lightning MultiCom SA, Switzerland, and its licensors. CB, Community Builder and Joomlapolis are also a trademark of joomlapolis.com and may not be used without permission from the trademark holders.</strong></p>
    <p>The copyright holders have spent massive time on this software and are continuing to improve it. A corresponding membership at Joomlapolis.com is required for ongoing maintenance and support.</p>
    <p>All copyright statements must be kept.</p> 
    <p><em>Official site: <a href="http://www.joomlapolis.com?pk_campaign=in-cb&amp;pk_kwd=installed-cbsubs">www.joomlapolis.com</a></em></p>
		
</div>

<?php 
    // Temporary fix in CBSubs 1.2.2 only for CBSubs 1.2.1 bug:
    if (checkJversion() >= 1 && $installedVersion == '1.2.2') {
        $sql = "UPDATE #__users" . " SET password = concat(md5(concat(password,'12345678901234567890123456789012')),':','12345678901234567890123456789012')" . " WHERE ( LENGTH(password) < 65 )" . " AND ( LENGTH(password) > 3 )" . " AND ( registerDate > '2011-07-13 12:00:00' )";
        $_CB_database->setQuery($sql);
        $_CB_database->query();
    }
    // Temporary fix in CBSubs 1.3.0 for CBSubs 1.2.x bug:
    // Ogone gateway was not transfering address from basket:
    $sql = 'UPDATE #__cbsubs_payments p' . ' LEFT JOIN #__cbsubs_payment_baskets b ON p.payment_basket_id = b.id' . ' SET ' . ' p.`address_street` = b.`address_street`,' . ' p.`address_city` = b.`address_city`,' . ' p.`address_state` = b.`address_state`,' . ' p.`address_zip` = b.`address_zip`,' . ' p.`address_country` = b.`address_country`,' . ' p.`address_country_code` = b.`address_country_code`,' . ' p.`payer_business_name` = b.`payer_business_name`,' . ' p.`payer_email` = b.`payer_email`,' . ' p.`contact_phone` = b.`contact_phone`,' . ' p.`vat_number` = b.`vat_number`' . " WHERE p.payment_method IN ('ogone','swisspostfinance')" . ' AND ISNULL(p.`address_country_code`);';
    $_CB_database->setQuery($sql);
    $_CB_database->query();
    cbimport('cb.adminfilesystem');
    $adminFS = cbAdminFileSystem::getInstance();
    $cbsubsDir = $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions';
    // Remove old 2Checkout files if there is no 2Checkout gateway configured, as TwoCheckout is not part anymore in CBSubs 1.3:
    $sql = 'SELECT COUNT(*) FROM #__cbsubs_gateway_accounts' . ' WHERE gateway_type = "processors.twocheckout";';
    $_CB_database->setQuery($sql);
    $hasTwoCheckoutInstalled = $_CB_database->loadResult();
    $twocheckoutdir = $cbsubsDir . '/processors/twocheckout';
    if ($hasTwoCheckoutInstalled == 0 && file_exists($twocheckoutdir)) {
        $adminFS->deldir($twocheckoutdir . '/');
    }
    // Remove old 1.x and 2.x files:
    $oldfiles = array('admin.cbpaidsubscriptions.ctrl.php', 'cbpaidsubscriptions.condition.php', 'cbpaidsubscriptions.countries.php', 'cbpaidsubscriptions.crosstotalizer.php', 'cbpaidsubscriptions.ctrl.php', 'cbpaidsubscriptions.currency.php', 'cbpaidsubscriptions.gui.php', 'cbpaidsubscriptions.guisubs.php', 'cbpaidsubscriptions.importer.php', 'cbpaidsubscriptions.scheduler.php', 'cbpaidsubscriptions.sql.php', 'cbpaidsubscriptions.userparams.php');
    foreach ($oldfiles as $file) {
        $pathFile = $cbsubsDir . '/' . $file;
        if ($file && file_exists($pathFile)) {
            $adminFS->unlink($pathFile);
        }
    }
}
示例#3
0
	/**
	 * Gets the model description for CB articles
	 *
	 * @param  int|null  $cms
	 * @param  boolean   $include
	 * @return stdClass
	 */
	static public function getModel( $cms = null, $include = true )
	{
		global $_CB_framework;

		static $cache				=	array();

		if ( $cms ) {
			$cms					=	(int) $cms;
		}

		if ( ! isset( $cache[$cms] ) ) {
			$plugin					=	cbarticlesClass::getPlugin();

			if ( ! $cms ) {
				$cms				=	$plugin->params->get( 'article_model', 1 );
			}

			$model					=	new stdClass();

			if ( in_array( $cms, array( 1, 4, 6 ) ) && checkJversion() >= 2 ) {
				$cms				=	( checkJversion( '3.0+' ) ? 6 : 4 );

				$model->file		=	$plugin->absPath . '/models/joomla25.php';
				$model->detected	=	( $cms == 6 ? CBTxt::T( 'Joomla 3.x' ) : CBTxt::T( 'Joomla 2.x' ) );
				$model->type		=	$cms;
			} elseif ( in_array( $cms, array( 1, 5 ) ) && is_dir( $_CB_framework->getCfg( 'absolute_path' ) . '/administrator/components/com_k2' ) && class_exists( 'K2Model' ) ) {
				$model->file		=	$plugin->absPath . '/models/k2.php';
				$model->detected	=	CBTxt::T( 'K2' );
				$model->type		=	5;
			} else {
				if ( checkJversion( '3.0+' ) ) {
					$cms			=	6;
				} else {
					$cms			=	4;
				}

				$model				=	cbarticlesClass::getModel( $cms, false );
			}

			if ( $include ) {
				/** @noinspection PhpIncludeInspection */
				require_once( $model->file );

				$model->class		=	new cbarticlesModel();
			}

			$cache[$cms]			=	$model;
		}

		return $cache[$cms];
	}
示例#4
0
	/**
	 * Gets the model description for CB docman
	 *
	 * @param  int|null  $cms
	 * @param  boolean   $include
	 * @return stdClass
	 */
	static public function getModel( $cms = null, $include = true )
	{
		global $_CB_framework;

		static $cache				=	array();

		if ( $cms ) {
			$cms					=	(int) $cms;
		}

		if ( ! isset( $cache[$cms] ) ) {
			$plugin					=	cbdocmanClass::getPlugin();

			if ( ! $cms ) {
				$cms				=	1;
			}

			$model					=	new stdClass();

			
				$cms				=	( checkJversion( '3.0+' ) ? 6 : 4 );

				$model->file		=	$plugin->absPath . '/models/joomla25.php';
				$model->detected	=	( $cms == 6 ? CBTxt::T( 'Joomla 3.x' ) : CBTxt::T( 'Joomla 2.x' ) );
				$model->type		=	$cms;
			

			if ( $include ) {
				/** @noinspection PhpIncludeInspection */
				require_once( $model->file );

				$model->class		=	new cbdocmanModel();
			}

			$cache[$cms]			=	$model;
		}

		return $cache[$cms];
	}
示例#5
0
	function showUsers( $option, $task, $cid ) {
		global $_CB_database, $_CB_framework, $_POST, $_PLUGINS, $_CB_TxtIntStore;

		$this->_importNeeded();

		$limit						=	(int) $_CB_framework->getCfg( 'list_limit' );
		if ( $limit == 0 ) {
			$limit					=	10;
		}
		$filter_type				=	$_CB_framework->getUserStateFromRequest( "filter_type{$option}", 'filter_type', 0 );
		$filter_status				=	$_CB_framework->getUserStateFromRequest( "filter_status{$option}", 'filter_status', 0 );
		$filter_logged				=	intval( $_CB_framework->getUserStateFromRequest( "filter_logged{$option}", 'filter_logged', 0 ) );
		$lastCBlist					=	$_CB_framework->getUserState( "view{$option}lastCBlist", null );
		if( $lastCBlist == 'showusers' ) {
			if ( $task == 'showusers' ) {
				$limit				=	$_CB_framework->getUserStateFromRequest( "viewlistlimit", 'limit', $limit );
				$limitstart			=	$_CB_framework->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 );
			}
			$lastSearch 			=	$_CB_framework->getUserState( "search{$option}", null );
			$search					=	$_CB_framework->getUserStateFromRequest( "search{$option}", 'search', '' );
			if ( $lastSearch != $search ) {
				$limitstart			=	0;
				$_CB_framework->setUserState( "view{$option}limitstart", $limitstart );
			}
			$search					=	stripslashes( trim( ( $_CB_TxtIntStore->_iso != 'UTF-8' ) ? strtolower( $search ) : ( is_callable( 'mb_convert_case' ) ? mb_convert_case( $search, MB_CASE_LOWER, "UTF-8") : utf8_encode(strtolower(utf8_decode( $search ) ) ) ) ) );
		} else {
			$filter_type			=	0;
			$filter_status			=	0;
			$filter_logged			=	0;
			clearSearchBox();
			$search					=	'';
			$limitstart				=	0;
			$_CB_framework->setUserState( "view{$option}limitstart", $limitstart );
			$_CB_framework->setUserState( "view{$option}lastCBlist", "showusers" );
		}
	
		if ( $task !== 'showusers' ) {
			if ( $task == 'ajaxemailusers' ) {
				$limitstart			=	cbGetParam( $_POST, 'limitstart', 0 );
				$limit				=	cbGetParam( $_POST, 'limit', 0 );
			} else {
				$limitstart			=	0;
				if ( $task == 'emailusers' ) {
					$limit			=	101;		// so that first 100 users and more... is displayed.
				} else {
					$limit			=	cbGetParam( $_POST, 'limit', 0 );
				}
			}
		}
		
		$tablesSQL					=	array( 'u'	=> '#__users AS u' );
		$joinsSQL					=	array( 'ue'	=> 'LEFT JOIN #__comprofiler AS ue ON u.id = ue.id' );
		$tablesWhereSQL				=	array();
	
		if ( isset( $search ) && ( $search != "") ) {
			$tablesWhereSQL[]		=	"(u.username LIKE '%" . $_CB_database->getEscaped( $search, true ) . "%' OR u.email LIKE '%" . $_CB_database->getEscaped( $search, true ) . "%' OR u.name LIKE '%" . $_CB_database->getEscaped( $search, true ) . "%')";
		}
		if ( $filter_type ) {
			if ( checkJversion() == 2 ) {
				$tablesWhereSQL[]	=	"aro.group_id = " . (int)  $filter_type;
			} else {
				if ( $filter_type == 'Public Frontend' ) {
					$tablesWhereSQL[]	=	"(u.usertype = 'Registered' OR u.usertype = 'Author' OR u.usertype = 'Editor'OR u.usertype = 'Publisher')";
				} else if ( $filter_type == 'Public Backend' ) {
					$tablesWhereSQL[]	=	"( u.usertype = 'Manager' OR u.usertype = 'Administrator' OR u.usertype = 'Super Administrator' )";
				} else {
					$tablesWhereSQL[]	=	"u.usertype = " . $_CB_database->Quote( $filter_type );
				}
			}
		}
		$tBlocked					=	CBTxt::T('Blocked');
		$tEnabled					=	CBTxt::T('Enabled');
		$tUnconfirmed				=	CBTxt::T('Unconfirmed');
		$tConfirmed					=	CBTxt::T('Confirmed');
		$tUnapproved				=	CBTxt::T('Unapproved');
		$tDisapproved				=	CBTxt::T('Disapproved');
		$tApproved					=	CBTxt::T('Approved');
		$tBanned					=	CBTxt::T('Banned');
		$p							=	' + ';
		$userstates	=	array(
						$tBlocked											=>	'u.block = 1',
						$tEnabled											=>	'u.block = 0',
						$tUnconfirmed										=>	'ue.confirmed = 0',
						$tConfirmed											=>	'ue.confirmed = 1',
						$tUnapproved										=>	'ue.approved = 0',
						$tDisapproved										=>	'ue.approved = 2',
						$tApproved											=>	'ue.approved = 1',
						$tBanned											=>	'ue.banned <> 0',
						$tBlocked . $p . $tUnconfirmed . $p . $tUnapproved	=>	'(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 0)',
						$tEnabled . $p . $tUnconfirmed . $p . $tUnapproved	=>	'(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 0)',
						$tBlocked . $p . $tConfirmed   . $p . $tUnapproved	=>	'(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 0)',
						$tEnabled . $p . $tConfirmed   . $p . $tUnapproved	=>	'(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 0)',
						$tBlocked . $p . $tUnconfirmed . $p . $tDisapproved	=>	'(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 2)',
						$tEnabled . $p . $tUnconfirmed . $p . $tDisapproved	=>	'(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 2)',
						$tBlocked . $p . $tConfirmed   . $p . $tDisapproved	=>	'(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 2)',
						$tEnabled . $p . $tConfirmed   . $p . $tDisapproved	=>	'(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 2)',
						$tBlocked . $p . $tUnconfirmed . $p . $tApproved	=>	'(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 1)',
						$tEnabled . $p . $tUnconfirmed . $p . $tApproved	=>	'(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 1)',
						$tBlocked . $p . $tConfirmed   . $p . $tApproved	=>	'(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 1)',
						$tEnabled . $p . $tConfirmed   . $p . $tApproved	=>	'(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 1)',
						CBTxt::T('Avatar not approved')						=>	"(ue.avatar > '' AND ue.avatarapproved = 0)" );
		if ( $filter_status ) {
			$tablesWhereSQL[]		=	$userstates[$filter_status];
		}
		if ( $filter_logged == 1 ) {
			$tablesWhereSQL[]		=	"s.userid = u.id";
		} else if ($filter_logged == 2) {
			$tablesWhereSQL[]		=	"s.userid IS NULL";
		}
	
		// exclude any child group id's for this user
		//$_CB_framework->acl->_debug = true;
		$pgids						=	$_CB_framework->acl->get_group_children( userGID( $_CB_framework->myId() ), 'ARO', 'RECURSE' );
		if ( is_array( $pgids ) && (count( $pgids ) > 0 ) ) {
			if ( checkJversion() == 2 ) {
				$tablesWhereSQL[]	=	"( aro.group_id NOT IN ( " . implode( ',', $pgids ) . " ) )";
			} else {
				$tablesWhereSQL[]	=	"( u.gid NOT IN ( " . implode( ',', $pgids ) . " ) )";
			}
		}
		// Filter the checkmarked users only:
		if ( $task !== 'showusers' ) {
			if ( is_array( $cid ) && ( count( $cid ) > 0 ) ) {
				cbArrayToInts( $cid );
				$tablesWhereSQL[]		=	"( u.id IN ( " . implode( ',', $cid ) . " ) )";
			}
		}
	
		// Advanced searches:
		$myCbUser				=&	CBuser::getInstance( $_CB_framework->myId() );
		$myUser					=&	$myCbUser->getUserData();
		$tabs					=	$myCbUser->_getCbTabs();		//	new cbTabs( 0, 1 );		//TBD: later: this private method should not be called here, but the whole users-list should go into there and be called here.
		$allFields				=	$tabs->_getTabFieldsDb( null, $myUser, 'adminfulllist' );
		foreach ( $allFields as $k => $v ) {
			if ( in_array( $v->type, array( 'pm', 'status', 'formatname', 'hidden', 'delimiter', 'userparams' ) ) ) {
				unset( $allFields[$k] );		// delimiter, userparams do not have search for now!
			}
		}
		$searchVals				=	new stdClass();
		$list_compare_types		=	1;		// Advanced: all possibilities (WARNING: can be slow)
		$tableReferences		=	array( '#__comprofiler' => 'ue', '#__users' => 'u' );
		$searchesFromFields		=	$tabs->applySearchableContents( $allFields, $searchVals, $_POST, $list_compare_types );
		$whereFields			=	$searchesFromFields->reduceSqlFormula( $tableReferences, $joinsSQL, TRUE );
		if ( $whereFields ) {
			$tablesWhereSQL[]	=	'(' . $whereFields . ')';
		}
		$searchTabContent		=	$tabs->getSearchablesContents( $allFields, $myUser, $searchVals, $list_compare_types );
		
		if ($filter_logged == 1 || $filter_logged == 2) {
			$joinsSQL[]				.=	"\n INNER JOIN #__session AS s ON s.userid = u.id";
		// } else {		done later, to avoid blocking site:
		//	$joinsSQL[]				.=	"\n LEFT JOIN #__session AS s ON s.userid = u.id";
		}
	
		if ( checkJversion() == 2 ) {
			$joinsSQL[]				=	"INNER JOIN #__user_usergroup_map AS aro ON aro.user_id = u.id";			// map user to aro for selection (and display if no selection)
			if ( $filter_type ) {
				$joinsSQL[]			=	"LEFT JOIN #__user_usergroup_map AS arodisplay ON arodisplay.user_id = u.id";	// map user to aro for display of all groups
				$joinsSQL[]			=	"INNER JOIN #__usergroups AS g ON g.id = arodisplay.group_id"; 					// map aro to group for display group name
			} else {
				$joinsSQL[]			=	"INNER JOIN #__usergroups AS g ON g.id = aro.group_id"; 					// map aro to group
			}
		}
	
	   	$_PLUGINS->loadPluginGroup('user');
		$_PLUGINS->trigger( 'onBeforeBackendUsersListBuildQuery', array( &$tablesSQL, &$joinsSQL, &$tablesWhereSQL, $option ) );
	
		$queryFrom					=	"\n FROM " . implode( ', ', $tablesSQL )
									.	( count( $joinsSQL ) ? "\n " . implode( "\n ", $joinsSQL ) : '' )
									.	( count( $tablesWhereSQL ) ? "\n WHERE " . implode( ' AND ', $tablesWhereSQL ) : '' )
									;
	
		// Counting query:
		$query						=	"SELECT COUNT(DISTINCT u.id)"
									.	$queryFrom
									;
		$_CB_database->setQuery( $query );
		$total						=	$_CB_database->loadResult();
		if ( $total === null ) {
			echo $_CB_database->getErrorMsg();
		}
		if ( $total <= $limitstart ) {
			$limitstart				=	0;
		}
	
		cbimport( 'cb.pagination' );
		$pageNav					=	new cbPageNav( $total, $limitstart, $limit  );
	
		if ( checkJversion() == 2 ) {
			$grp_name				=	'title';
		} elseif ( checkJversion() == 1 ) {
			$grp_name				=	'name';
			$joinsSQL[]				=	"INNER JOIN #__core_acl_aro AS aro ON aro.value = u.id";					// map user to aro
			$joinsSQL[]				=	"INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id";		// map aro to group
			$joinsSQL[]				=	"INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id";
			$tablesWhereSQL[]		=	"aro.section_value = 'users'";
		} else {
			$grp_name				=	'name';
			$joinsSQL[]				=	"INNER JOIN #__core_acl_aro AS aro ON aro.value = u.id";					// map user to aro
			$joinsSQL[]				=	"INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.aro_id";	// map aro to group
			$joinsSQL[]				=	"INNER JOIN #__core_acl_aro_groups AS g ON g.group_id = gm.group_id";
			$tablesWhereSQL[]		=	"aro.section_value = 'users'";
		}
	
		$queryFrom					=	"\n FROM " . implode( ', ', $tablesSQL )
									.	( count( $joinsSQL ) ? "\n " . implode( "\n ", $joinsSQL ) : '' )
									.	( count( $tablesWhereSQL ) ? "\n WHERE " . implode( ' AND ', $tablesWhereSQL ) : '' )
									;
	
		// Main query:
		if ( checkJversion() == 2 ) {
			$query					=	"SELECT u.*, GROUP_CONCAT( DISTINCT g.$grp_name ORDER BY g.$grp_name SEPARATOR ', ') AS groupname, ue.approved, ue.confirmed"
									.	$queryFrom
									.	' GROUP BY u.id'
									;
		} else {
			$query					=	"SELECT DISTINCT u.*, g.$grp_name AS groupname, ue.approved, ue.confirmed"
									.	$queryFrom
									;
		}
		$_CB_database->setQuery( $query, (int) $pageNav->limitstart, (int) $pageNav->limit );
		$rows						=	$_CB_database->loadObjectList( null, 'moscomprofilerUser', array( &$_CB_database ) );
		if ($_CB_database->getErrorNum()) {
			echo $_CB_database->stderr();
			return false;
		}
		// creates the CBUsers in cache corresponding to the $users:
		foreach ( array_keys( $rows ) as $k) {
			// do not do this otherwise substitutions do not work: 
			// CBuser::setUserGetCBUserInstance( $rows[$k] );
		}
	
		$template				=	'SELECT COUNT(s.userid) FROM #__session AS s WHERE s.userid = ';
		$n						=	count( $rows );
		for ( $i = 0; $i < $n; $i++ ) {
			$row				=	&$rows[$i];
			$query				=	$template . (int) $row->id;
			$_CB_database->setQuery( $query );
			$row->loggedin		=	$_CB_database->loadResult();
		}
	
		$select_tag_attribs		=	'class="inputbox" size="1" onchange="document.adminForm.submit( );"';
		$inputTextExtras		=	'';
		if ( $task != 'showusers' ) {
			$inputTextExtras	=	' disabled="disabled"';
			$select_tag_attribs	.=	$inputTextExtras;
		}
	
		// get list of Log Status for dropdown filter
		$logged[]				=	moscomprofilerHTML::makeOption( 0, CBTxt::T('- Select Login State -'));
		$logged[]				=	moscomprofilerHTML::makeOption( 1, CBTxt::T('Logged In'));
		$lists['logged']		=	moscomprofilerHTML::selectList( $logged, 'filter_logged', $select_tag_attribs, 'value', 'text', "$filter_logged", 2 );
	
		// get list of Groups for dropdown filter
		if ( checkJversion() == 2 ) {
			$query				=	"SELECT id AS value, title AS text"
								.	"\n FROM #__usergroups";
		} else {
			$query				=	"SELECT name AS value, name AS text"
								.	"\n FROM #__core_acl_aro_groups"
								.	"\n WHERE name != 'ROOT'"
								.	"\n AND name != 'USERS'";
		}
	
		$types[]				=	moscomprofilerHTML::makeOption( '0', CBTxt::T('- Select Group -') );
		$_CB_database->setQuery( $query );
		$types					=	array_merge( $types, $_CB_database->loadObjectList() );
		$lists['type']			=	moscomprofilerHTML::selectList( $types, 'filter_type', $select_tag_attribs, 'value', 'text', "$filter_type", 2 );
	
		$status[]				=	moscomprofilerHTML::makeOption( 0, CBTxt::T('- Select User Status -'));
		foreach ( array_keys( $userstates ) as $k ) {
			$status[]			=	moscomprofilerHTML::makeOption( $k, $k );
		}
		$lists['status']		=	moscomprofilerHTML::selectList( $status, 'filter_status', $select_tag_attribs, 'value', 'text', "$filter_status", 2 );
	
		$pluginAdditions		=	$_PLUGINS->trigger( 'onAfterBackendUsersList', array( 1, &$rows, &$pageNav, &$search, &$lists, $option, $select_tag_attribs ) );
		$pluginColumns			=	array();
		foreach ( $pluginAdditions as $addition ) {
			if ( is_array( $addition ) ) {
				$pluginColumns	=	array_merge( $pluginColumns, $addition );
			}
		}
	
		if ( $task == 'showusers' ) {
			$usersView			=	_CBloadView( 'users' );
			$usersView->showUsers( $rows, $pageNav, $search, $option, $lists, $pluginColumns, $inputTextExtras, $searchTabContent );
		} else {
			$emailSubject		=	stripslashes( cbGetParam( $_POST, 'emailsubject', '' ) );
			$emailBody			=	stripslashes( cbGetParam( $_POST, 'emailbody', '', _CB_ALLOWRAW | _CB_NOTRIM ) );
			$emailsPerBatch		=	stripslashes( cbGetParam( $_POST, 'emailsperbatch', 50 ) );
			$emailPause			=	stripslashes( cbGetParam( $_POST, 'emailpause', 30 ) );
			$simulationMode		=	stripslashes( cbGetParam( $_POST, 'simulationmode', '' ) );
			if ( count( $cid ) > 0 && count( $cid ) < $total ) {
				$total			=	count( $cid );
			}
			if ( $task == 'emailusers' ) {
				$pluginRows		=	$_PLUGINS->trigger( 'onBeforeBackendUsersEmailForm', array( &$rows, &$pageNav, &$search, &$lists, &$cid, &$emailSubject, &$emailBody, &$inputTextExtras, &$select_tag_attribs, $simulationMode, $option ) );
				$usersView		=	_CBloadView( 'users' );
				$usersView->emailUsers( $rows, $total, $search, $option, $lists, $cid, $inputTextExtras, $searchTabContent, $emailSubject, $emailBody, $emailsPerBatch, $emailPause, $simulationMode, $pluginRows );
			} elseif ( $task == 'startemailusers' ) {
				$pluginRows		=	$_PLUGINS->trigger( 'onBeforeBackendUsersEmailStart', array( &$rows, $total, $search, $lists, $cid, &$emailSubject, &$emailBody, &$inputTextExtras, $simulationMode, $option ) );
				$usersView		=	_CBloadView( 'users' );
				$usersView->startEmailUsers( $rows, $search, $option, $lists, $cid, $inputTextExtras, $searchTabContent, $emailSubject, $emailBody, $emailsPerBatch, $emailPause, $total, $simulationMode, $pluginRows );
			} elseif ( $task == 'ajaxemailusers' ) {
				$this->_cbadmin_emailUsers( $rows, $emailSubject, $emailBody, $limitstart, $limit, $total, $simulationMode );
			}
		}
		return true;
	}
    function showUsers(&$rows, &$pageNav, $search, $option, &$lists, &$pluginColumns, $inputTextExtras, $searchTabContent, $canAdmin, $canManage, $canCreate, $canEdit, $canEditOwn, $canEditState)
    {
        global $_CB_framework;
        _CBsecureAboveForm('showUsers');
        outputCbTemplate(2);
        outputCbJs(2);
        global $_CB_Backend_Title;
        $_CB_Backend_Title = array(0 => array('cbicon-48-user', CBTxt::T('CB User Manager')));
        /*
         * 		Auto-submission was a pain: added 2 buttons in advanced search.
        		ob_start();
        $('#cbUserListsSearcher select,#cbUserListsSearcher input,#cbUserListsSearcher textarea').live('change', function() {
        	if ( $(this).parent('div').hasClass('cbSearchKind') ) {
        		if ( $(this).val() == '' ) {
        			$(this).parents('form')[0].submit();
        		}
        	} else {
        		$(this).parents('form')[0].submit();
        	}
        });
        
        			$cbjavascript	=	ob_get_contents();
        			ob_end_clean();
        			$_CB_framework->outputCbJQuery( $cbjavascript );
        */
        $_CB_framework->outputCbJQuery('');
        $colspans = 13 + count($pluginColumns);
        ?>
<form action="<?php 
        echo $_CB_framework->backendUrl('index.php');
        ?>
" method="post" name="adminForm" class="cb_form" id="cbshowusersform">
<?php 
        $this->_userslistFilters($search, $lists, $inputTextExtras, $searchTabContent);
        ?>
  <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
   <thead>
    <tr>
      <th align="center" colspan="<?php 
        echo $colspans;
        ?>
"> <?php 
        echo $pageNav->writePagesLinks();
        ?>
</th>
    </tr>
    <tr>
      <th width="1%" class="title"><?php 
        echo CBTxt::T('#');
        ?>
</th>
      <th width="3%" class="title">
      	<input type="checkbox" name="toggle" value="" <?php 
        echo 'onClick="cbToggleAll( this, ' . count($rows) . ', \'cb\' );"';
        ?>
 />
      </th>
      <th width="23%" class="title"><?php 
        echo CBTxt::T('Name');
        ?>
</th>
      <th width="12%" class="title"><?php 
        echo CBTxt::T('UserName');
        ?>
</th>
      <th width="3%" class="title" nowrap="nowrap"><?php 
        echo CBTxt::T('Logged In');
        ?>
</th>
<?php 
        foreach ($pluginColumns as $name => $content) {
            ?>
	  <th width="15%" class="title"><?php 
            echo $name;
            ?>
</th>

<?php 
        }
        ?>
      <th width="12%" class="title"><?php 
        echo CBTxt::T('Group');
        ?>
</th>
      <th width="13%" class="title"><?php 
        echo CBTxt::T('E-Mail');
        ?>
</th>
      <th width="8%" class="title"><?php 
        echo CBTxt::T('Registered');
        ?>
</th>
      <th width="8%" class="title" nowrap="nowrap"><?php 
        echo CBTxt::T('Last Visit');
        ?>
</th>
      <th width="3%" class="title"><?php 
        echo CBTxt::T('Enabled');
        ?>
</th>
      <th width="3%" class="title"><?php 
        echo CBTxt::T('Confirmed');
        ?>
</th>
      <th width="3%" class="title"><?php 
        echo CBTxt::T('Approved');
        ?>
</th>
      <th width="1%" class="title"><?php 
        echo CBTxt::T('ID');
        ?>
</th>
    </tr>
   </thead>
   <tbody>
<?php 
        $k = 0;
        $imgpath = '../components/com_comprofiler/images/';
        for ($i = 0, $n = count($rows); $i < $n; $i++) {
            $row =& $rows[$i];
            $img = $row->block ? 'publish_x.png' : 'tick.png';
            $task = $row->block ? 'unblock' : 'block';
            $hover1 = $row->block ? CBTxt::T('Blocked') : CBTxt::T('Enabled');
            switch ($row->approved) {
                case 0:
                    $img2 = 'pending.png';
                    $task2 = 'approve';
                    $hover = CBTxt::T('Pending Approval');
                    break;
                case 1:
                    $img2 = 'tick.png';
                    $task2 = 'reject';
                    $hover = CBTxt::T('Approved');
                    break;
                case 2:
                    $img2 = 'publish_x.png';
                    $task2 = 'approve';
                    $hover = CBTxt::T('Rejected');
                    break;
            }
            $img3 = $row->confirmed ? 'tick.png' : 'publish_x.png';
            // $task3 = $row->confirmed ?   'reject' : 'approve';
            $hover3 = $row->confirmed ? CBTxt::T('confirmed') : CBTxt::T('unconfirmed');
            ?>
    <tr class="<?php 
            echo "row{$k}";
            ?>
">
      <td><?php 
            echo $i + 1 + $pageNav->limitstart;
            ?>
</td>
      <td>
      	<input type="checkbox" id="cb<?php 
            echo $i;
            ?>
" name="cid[]" value="<?php 
            echo $row->id;
            ?>
" onClick="cbIsChecked(this.checked);" />
      </td>
      <td>
      	<?php 
            if ($canEdit && $row->id != $_CB_framework->myId() || $canEditOwn && $row->id == $_CB_framework->myId()) {
                ?>
        <a href="#edit" onClick="return cbListItemTask( this, 'edit', null, null, 'cb', '<?php 
                echo $i;
                ?>
' )">
        <?php 
                echo htmlspecialchars($row->name);
                ?>
 
        </a>
        <?php 
            } else {
                echo htmlspecialchars($row->name);
            }
            if (checkJversion() >= 2) {
                ?>
      		<div class="fltrt">
			<?php 
                if (version_compare(checkJversion('release'), '2.5', '>=') && $canManage) {
                    if ($row->note_count) {
                        // Filter notes:
                        echo '<a href="' . JRoute::_('index.php?option=com_users&view=notes&filter_search=uid:' . (int) $row->id) . '">' . JHtml::_('image', 'admin/filter_16.png', 'COM_USERS_NOTES', array('title' => JText::_('COM_USERS_FILTER_NOTES'), 'height' => '16', 'width' => '16'), true) . '</a>';
                        // Show notes:
                        echo '<a class="modal"' . ' href="' . JRoute::_('index.php?option=com_users&view=notes&tmpl=component&layout=modal&u_id=' . (int) $row->id) . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 450}}">' . JHtml::_('image', 'menu/icon-16-user-note.png', 'COM_USERS_NOTES', array('title' => JText::plural('COM_USERS_N_USER_NOTES', $row->note_count), 'height' => '16', 'width' => '16'), true) . '</a>';
                    }
                    if ($canCreate) {
                        echo '<a href="' . JRoute::_('index.php?option=com_users&task=note.add&u_id=' . (int) $row->id) . '">' . JHtml::_('image', 'admin/note_add_16.png', 'COM_USERS_NOTES', array('title' => JText::_('COM_USERS_ADD_NOTE'), 'height' => '16', 'width' => '16'), true) . '</a>';
                    }
                }
                ?>
			</div>
		<?php 
                if (($_CB_framework->acl->amIaSuperAdmin() || $canAdmin && $canManage) && $_CB_framework->getCfg('debug')) {
                    ?>
			<div class="fltrt">
				<a href="<?php 
                    echo JRoute::_('index.php?option=com_users&view=debuguser&user_id=' . (int) $row->id);
                    ?>
">
					<?php 
                    echo JHtml::_('image', 'menu/icon-16-stats.png', 'COM_USERS_DEBUG_USER', array('title' => JText::_('COM_USERS_DEBUG_USER'), 'height' => '16', 'width' => '16'), true);
                    ?>
</a></div>
		<?php 
                }
            }
            ?>
      </td>
      <td><?php 
            echo htmlspecialchars($row->username);
            ?>
</td>
      <td align="center"><?php 
            echo $row->loggedin ? '<img src="' . $imgpath . 'tick.png" width="16" height="16" border="0" alt="" />' : '';
            ?>
</td>
<?php 
            foreach ($pluginColumns as $name => $content) {
                ?>
	  <td><?php 
                echo $content[$row->id];
                ?>
</td>

<?php 
            }
            ?>
      <td><?php 
            echo $row->groupname;
            ?>
</td>
      <td><a href="mailto:<?php 
            echo htmlspecialchars($row->email);
            ?>
"><?php 
            echo htmlspecialchars($row->email);
            ?>
</a></td>
      <td><?php 
            echo cbFormatDate($row->registerDate);
            ?>
</td>
      <td><?php 
            echo cbFormatDate($row->lastvisitDate);
            ?>
</td>
      <td width="10%">
      	<?php 
            if ($canEditState) {
                ?>
      	<a href="javascript: void(0);" onClick="return cbListItemTask( this, '<?php 
                echo $task;
                ?>
', null, null, 'cb', '<?php 
                echo $i;
                ?>
' )">
      	<?php 
            }
            ?>
      		<img src="<?php 
            echo $imgpath . $img;
            ?>
" width="16" height="16" border="0" title="<?php 
            echo $hover1;
            ?>
" alt="<?php 
            echo $hover1;
            ?>
" />
      	<?php 
            if ($canEditState) {
                ?>
      	</a>
      	<?php 
            }
            ?>
      </td>
      <td width="10%">
      	<img src="<?php 
            echo $imgpath . $img3;
            ?>
" width="16" height="16" border="0" title="<?php 
            echo $hover3;
            ?>
" alt="<?php 
            echo $hover3;
            ?>
" />
      </td>
      <td width="10%">
      	<?php 
            if ($canEditState) {
                ?>
      	<a href="javascript: void(0);" onClick="return cbListItemTask( this, '<?php 
                echo $task2;
                ?>
', null, null, 'cb', '<?php 
                echo $i;
                ?>
' )">
      	<?php 
            }
            ?>
      		<img src="<?php 
            echo $imgpath . $img2;
            ?>
" width="16" height="16" border="0" title="<?php 
            echo $hover;
            ?>
" alt="<?php 
            echo $hover;
            ?>
" />
      	<?php 
            if ($canEditState) {
                ?>
      	</a>
      	<?php 
            }
            ?>
      </td>
      <td><?php 
            echo $row->id;
            ?>
</td>

    </tr>
    <?php 
            $k = 1 - $k;
        }
        ?>
   </tbody>
   <tfoot>
    <tr>
      <th align="center" colspan="<?php 
        echo $colspans;
        ?>
"> <?php 
        echo $pageNav->getListFooter();
        ?>
</th>
    </tr>
   </tfoot>
  </table>
  <input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
  <input type="hidden" name="task" value="showusers" />
  <input type="hidden" name="boxchecked" value="0" />
  <?php 
        echo cbGetSpoofInputTag('user');
        ?>
</form>
<?php 
    }
示例#7
0
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework, $_CB_database;

		foreach ( $trigger->getParams()->subTree( 'query' ) as $row ) {
			/** @var ParamsInterface $row */
			if ( $row->get( 'mode', 0, GetterInterface::BOOLEAN ) ) {
				$host					=	$row->get( 'host', null, GetterInterface::STRING );

				if ( ! $host ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_NO_HOST', ':: Action [action] :: Query skipped due to missing host', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$username				=	$row->get( 'username', null, GetterInterface::STRING );

				if ( ! $username ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_NO_USERNAME', ':: Action [action] :: Query skipped due to missing username', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$password				=	$row->get( 'password', null, GetterInterface::STRING );

				if ( ! $password ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_NO_PSWD', ':: Action [action] :: Query skipped due to missing password', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$database				=	$row->get( 'database', null, GetterInterface::STRING );

				if ( ! $database ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_NO_DB', ':: Action [action] :: Query skipped due to missing database', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$charset				=	$row->get( 'charset', null, GetterInterface::STRING );
				$prefix					=	$row->get( 'prefix', null, GetterInterface::STRING );

				if ( ! $prefix ) {
					$prefix				=	$_CB_framework->getCfg( 'dbprefix' );
				}

				$driver					=	$_CB_framework->getCfg( 'dbtype' );
				$options				=	array ( 'driver' => $driver, 'host' => $host, 'user' => $username, 'password' => $password, 'database' => $database, 'prefix' => $prefix );

				if ( is_callable( array( 'JDatabaseDriver', 'getInstance' ) ) ) {
					try {
						$_J_database	=&	JDatabaseDriver::getInstance( $options );
					} catch ( RuntimeException $e ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_EXT_DB_FAILED', ':: Action [action] :: Query external database failed. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $e->getMessage() ) ) );
						}

						continue;
					}
				} else {
					try {
						$_J_database	=&	JDatabase::getInstance( $options );
					} catch ( RuntimeException $e ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_EXT_DB_FAILED', ':: Action [action] :: Query external database failed. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $e->getMessage() ) ) );
						}

						continue;
					}
				}

				$_SQL_database			=	new CmsDatabaseDriver( $_J_database, $prefix, checkJversion( 'release' ) );

				if ( $charset ) {
					$_SQL_database->setQuery( 'SET NAMES ' . $_SQL_database->Quote( $charset ) );
					$_SQL_database->query();
				}
			} else {
				$_SQL_database			=	$_CB_database;
			}

			if ( $_SQL_database ) {
				$queries				=	preg_split( '/(;\s*[\r\n])/', trim( $trigger->getSubstituteString( $row->get( 'sql', null, GetterInterface::RAW ), array( 'cbautoactionsClass', 'escapeSQL' ) ) ) );

				if ( $queries ) foreach ( $queries as $query ) {
					if ( $query ) {
						$_SQL_database->setQuery( $query );
						$_SQL_database->query();
					}
				}
			}
		}
	}
 /**
  * Adjusts user's ACL and block user if no subscriptions left.
  *
  * @param  UserTable  $user
  * @param  string     $cause          cause of the change
  * @param  int        $block          1: block user, 0: don't block
  * @param  int[]      $gids           new ACL gids (in Joomla < 1.6: only 1 entry)
  * @param  int[]      $removeGids     old ACL gids from plans that just expired
  * @param  array      $oldChldGids    old ACL gids and children
  * @param  string     $reason         reason of change: 'N'=new subscription (default), 'R'=renewal, 'U'=update + 'X'=expiries
  */
 protected function _adjustUserAclBlock($user, $cause, $block, $gids, $removeGids, $oldChldGids, $reason)
 {
     global $_CB_framework;
     if ($user && $user->id) {
         if (self::_anyValueOfArrayInArray((array) $user->gids, $oldChldGids)) {
             // test above is to not degrade higher-level users !
             $wasBlocked = $user->block;
             $gidsUniqueSorted = array_unique($gids);
             sort($gidsUniqueSorted, SORT_NUMERIC);
             $userGids = array_unique((array) $user->gids);
             sort($userGids, SORT_NUMERIC);
             if ($block != $wasBlocked || $userGids != $gidsUniqueSorted) {
                 $superadministratorgid = $_CB_framework->acl->mapGroupNamesToValues('Superadministrator');
                 $k_SA = array_search($superadministratorgid, $removeGids);
                 if ($k_SA !== false) {
                     unset($removeGids[$k_SA]);
                 }
                 $user->gids = array_unique(array_merge(array_diff($userGids, $removeGids), $gidsUniqueSorted));
                 sort($user->gids, SORT_NUMERIC);
                 if ($block && !in_array($superadministratorgid, (array) $user->gids)) {
                     $user->block = 1;
                 }
                 $oldPwd = $user->password;
                 $user->password = null;
                 // don't update cleartext password in case of registration
                 $user->store();
                 // takes care of Mambo/Joomla ACL tables and many other stuff
                 $user->password = $oldPwd;
                 if (checkJversion() == 2) {
                     // This is needed for instant adding of groups to logged-in user (fixing bug #3581): Can be removed once CB 1.9 is released:
                     $session = JFactory::getSession();
                     $jUser = $session->get('user');
                     if ($jUser && $jUser->id == $user->id) {
                         JAccess::clearStatics();
                         $session->set('user', new JUser((int) $user->id));
                     }
                 }
                 if ($block == 0 && $wasBlocked == 1) {
                     $messagesToUser = $reason == 'N' && (!$user->lastvisitDate || $user->lastvisitDate == '0000-00-00 00:00:00');
                     activateUser($user, 0, 'PaidSubscription', $messagesToUser, $messagesToUser);
                     //TBD:	//FIXME		Don't ACTIVATE user 2nd time if this function is called from subscription->activate as a result of onUserActivate?
                 }
             }
         }
     } else {
         user_error(sprintf('AdjustUserAclBlock: user id %d not found in users table.', $user->id), E_USER_NOTICE);
     }
 }
示例#9
0
	function phpCleanType( $fieldValue, $type ) {
		$typeArray		=	explode( ':', $type, 3 );
		if ( count( $typeArray ) < 2 ) {
			$typeArray	=	array( 'const' , $type );
		}
		switch ( $typeArray[0] ) {
			case 'const':
				break;
			case 'param':
				$fieldValue	=	$this->getModelOfData()->get( $fieldValue );
				break;
			case 'pluginparams':
				$fieldValue	=	$this->_pluginParams->get( $fieldValue );
				break;
			case 'cmsversion':
				$fieldValue	=	checkJversion( $fieldValue ? $fieldValue : 'api' );
				break;
			case 'cbconfig':
				global $ueConfig;
				$fieldValue	=	( array_key_exists( $fieldValue, $ueConfig ) ? $ueConfig[$fieldValue] : '' );
				break;
			case 'datavalue':
				$fieldValue	=	$this->get( $fieldValue );					//TBD: missing default value, but not easy to find, as it's in the view param for now: $param->attributes( 'default' ) );
				break;
			default:
				trigger_error( 'XMLifCondition::phpCleanQuote:name: ERROR_UNKNOWN_TYPE: ' . htmlspecialchars( $type ), E_USER_NOTICE );
				break;
		}
		switch ( $typeArray[1] ) {
			case 'int':
				$value		=	(int) $fieldValue;
				break;
			case 'float':
				$value		=	(float) $fieldValue;
				break;
			case 'formula':
				$value		=	$fieldValue;
				break;
			case 'datetime':
				if ( preg_match( '/[0-9]{4}-[01][0-9]-[0-3][0-9] [0-2][0-9](:[0-5][0-9]){2}/', $fieldValue ) ) {
					$value	=	$fieldValue;
				} else {
					$value	=	'';
				}
				break;
			case 'date':
				if ( preg_match( '/[0-9]{4}-[01][0-9]-[0-3][0-9]/', $fieldValue ) ) {
					$value	=	$fieldValue;
				} else {
					$value	=	'';
				}
				break;
			case 'time':
				if ( preg_match( '/-?[0-9]{1,3}(:[0-5][0-9]){2}/', $fieldValue ) ) {
					$value	=	$fieldValue;
				} else {
					$value	=	'';
				}
				break;
			case 'string':
				$value		=	$fieldValue;
				break;
			case 'null':
				$value		=	null;
				break;

			default:
				//CB2.0: uncomment: trigger_error( 'XMLifCondition::phpCleanQuote:value: ERROR_UNKNOWN_TYPE: ' . htmlspecialchars( $type ), E_USER_NOTICE );
				$value		=	$fieldValue;
				break;
		}
		return $value;
	}
 /**
  * View for <param  type="private" class="cbpaidParamsExt" method="checkifpluginInstalled">...
  *
  * @param  string              $value                  Stored Data of Model Value associated with the element
  * @param  ParamsInterface     $pluginParams           Main settigns parameters of the plugin
  * @param  string              $name                   Name attribute
  * @param  CBSimpleXMLElement  $param                  This XML node
  * @param  string              $control_name           Name of the control
  * @param  string              $control_name_name      css id-encode of the names of the controls surrounding this node
  * @param  boolean             $view                   TRUE: view, FALSE: edit
  * @param  cbpaidTable         $modelOfData            Data of the Model corresponding to this View
  * @param  cbpaidTable[]       $modelOfDataRows        Displayed Rows if it is a table
  * @param  int                 $modelOfDataRowsNumber  Total Number of rows
  * @return null|string
  */
 public function checkifpluginInstalled($value, &$pluginParams, $name, &$param, $control_name, $control_name_name, $view, &$modelOfData, &$modelOfDataRows, &$modelOfDataRowsNumber)
 {
     global $_CB_framework, $_CB_database;
     $return = '';
     $botname = $param->attributes('value');
     if ($botname) {
         $filePath = $_CB_framework->getCfg('absolute_path') . (checkJversion() >= 1 ? '/plugins' : '/mambots') . '/system/' . (checkJversion() >= 2 ? $botname . '/' : '') . $botname . '.php';
         $readable = @file_exists($filePath) && @is_readable($filePath);
         if ($readable) {
             $sql = "SELECT enabled FROM #__extensions WHERE `type` = 'plugin' AND element = " . $_CB_database->Quote($botname);
             $object = null;
             $_CB_database->setQuery($sql, 0, 1);
             if ($_CB_database->loadResult($object)) {
                 return $this->checkSystemsVersions($value, $pluginParams, $name, $param, $control_name, $control_name_name, $view, $modelOfData, $modelOfDataRows, $modelOfDataRowsNumber);
             } else {
                 return '<div class="cbWarning">' . sprintf(CBPTXT::Th("The needed mambot/plugin '%s' is installed but not published."), htmlspecialchars($botname)) . '</div>';
             }
         }
         $return = '<div class="cbWarning">' . sprintf(CBPTXT::T("The needed mambot/plugin '%s' is not installed."), htmlspecialchars($botname)) . '</div>';
     } else {
         $return .= $this->_outputGreenRed('', false, '', "Error: value of plugin to check missing.");
     }
     return $return;
 }
 /**
  * store() function override, instead of storing it imports.
  *
  * @param  boolean  $updateNulls
  * @return boolean
  */
 public function store($updateNulls = false)
 {
     $return = '';
     // Check if file uploads are enabled
     if (!(bool) ini_get('file_uploads')) {
         $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("The importer can't continue before file uploads are enabled in PHP settings.");
         return false;
     }
     if (!$this->import_type) {
         $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No import type selected");
         return false;
     }
     $fromFile = cbStartOfStringMatch($this->import_type, 'file_');
     if ($fromFile) {
         $userfile = $_FILES['userfile'];
         if (!$userfile || $userfile == null) {
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No file selected");
             return false;
         }
         if (isset($userfile['error']) && $userfile['error']) {
             $errors_array = array(1 => CBPTXT::T("The uploaded file exceeds the upload_max_filesize directive in php.ini."), 2 => CBPTXT::T("The uploaded file exceeds the maximum size allowed by this form."), 3 => CBPTXT::T("The uploaded file was only partially uploaded."), 4 => CBPTXT::T("No file was selected and uploaded."), 6 => CBPTXT::T("Missing a temporary folder in php.ini."), 7 => CBPTXT::T("Failed to write file to disk."), 8 => CBPTXT::T("File upload stopped by extension."));
             if (in_array($userfile['error'], $errors_array)) {
                 $fileErrorTxt = $errors_array[$userfile['error']];
             } else {
                 $fileErrorTxt = CBPTXT::T("File upload error number ") . htmlspecialchars($userfile['error']);
             }
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . $fileErrorTxt;
             return false;
         }
         if (!$userfile['tmp_name'] || !is_uploaded_file($userfile['tmp_name'])) {
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No temporary file name");
             return false;
         }
         if ($userfile['size'] == 0) {
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("Empty file");
             return false;
         }
     } else {
         $userfile = null;
     }
     if ($this->import_type == 'cms_acl') {
         if (!$this->usergroup) {
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No usergroup selected");
             return false;
         }
     }
     if ($this->import_type == 'subscription') {
         if (!$this->from_plan) {
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No subscription plan selected");
             return false;
         }
         if (!$this->from_sub_status) {
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No subscription status selected");
             return false;
         }
     }
     if ($this->import_type != 'file_uid_plan_exp') {
         if (!$this->plan) {
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No plan selected");
             return false;
         }
         if (!$this->state) {
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No subscription state selected");
             return false;
         }
         if (!$this->date) {
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No subscription date selected");
             return false;
         }
     }
     if ($fromFile) {
         $tmpName = $userfile['tmp_name'];
         $fileSize = (int) $userfile['size'];
         // $fileType = $userfile['type'];
     } else {
         $tmpName = null;
         $fileSize = null;
     }
     $planStateDate = array();
     switch ($this->import_type) {
         case 'file_uid':
             $fp = fopen($tmpName, 'r');
             $content = fread($fp, $fileSize);
             fclose($fp);
             unlink($tmpName);
             $userIdList = explode(',', trim($content));
             break;
         case 'file_uid_plan_exp':
             $userIdList = array();
             $fp = fopen($tmpName, 'r');
             if ($fp) {
                 $n = 0;
                 while (!feof($fp)) {
                     $line = trim(str_replace('"', '', fgets($fp, 256)));
                     $n += 1;
                     if (strlen($line) > 0) {
                         $matches = null;
                         if (preg_match('/([1-9][0-9]*),([1-9][0-9]*),([AXC]),([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9][0-9]:[0-9][0-9]:[0-9][0-9])/', $line, $matches)) {
                             if (!in_array((int) $matches[1], $userIdList)) {
                                 $userIdList[] = (int) $matches[1];
                             }
                             $planStateDate[(int) $matches[1]][] = array('plan' => (int) $matches[2], 'status' => $matches[3], 'date' => $matches[4]);
                         } else {
                             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . sprintf(CBPTXT::T("Line %s does not match the format userid,planid,status,date, e.g. 63,1,A,2009-01-01 00:00:00, and is instead: %s ."), $n, htmlspecialchars($line));
                             fclose($fp);
                             unlink($tmpName);
                             return false;
                         }
                     }
                 }
             }
             fclose($fp);
             unlink($tmpName);
             break;
         case 'cms_acl':
             if (checkJversion() >= 2) {
                 $sql = 'SELECT id FROM #__users u' . ' JOIN #__user_usergroup_map m ON ( u.id = m.user_id )' . ' WHERE m.group_id = ' . (int) $this->usergroup;
             } else {
                 $sql = 'SELECT id FROM #__users' . ' WHERE gid = ' . (int) $this->usergroup;
             }
             $this->_db->setQuery($sql);
             $userIdList = $this->_db->loadResultArray();
             break;
         case 'subscription':
             $statuses = $this->from_sub_status;
             foreach (array_keys($statuses) as $k) {
                 $statuses[$k] = $this->_db->Quote($statuses[$k][0]);
             }
             $sql = 'SELECT s.user_id FROM #__cbsubs_subscriptions s' . ' JOIN #__users u ON ( u.id = s.user_id AND u.block = 0 )' . ' JOIN #__comprofiler c ON ( c.id = s.user_id AND c.confirmed = 1 AND c.approved = 1 )' . ' WHERE s.plan_id = ' . (int) $this->from_plan . ' AND s.status IN (' . implode(',', $statuses) . ')';
             $this->_db->setQuery($sql);
             $userIdList = $this->_db->loadResultArray();
             break;
         default:
             $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("Import type not implemented!");
             return false;
             break;
     }
     if (count($userIdList) == 0) {
         $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No user to import");
         return false;
     }
     $plansMgr = cbpaidPlansMgr::getInstance();
     if ($this->import_type != 'file_uid_plan_exp') {
         $plan = $plansMgr->loadPlan((int) $this->plan);
         $subscriptionTime = (int) $plan->strToTime($this->date);
         foreach ($userIdList as $key => $value) {
             if (!is_numeric($value)) {
                 $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("non-numeric userid value: ") . str_replace("\n", ' ', htmlspecialchars($value));
                 return false;
             }
             $userIdList[$key] = (int) $value;
         }
     } else {
         $plan = null;
         $subscriptionTime = null;
     }
     $this->_db->setQuery("SELECT u.id, u.username FROM #__comprofiler c, #__users u WHERE c.id=u.id AND u.block = 0 AND c.approved = 1 AND c.confirmed = 1 AND c.id IN (" . implode(',', $userIdList) . ")");
     $users = $this->_db->loadObjectList('id');
     if (count($userIdList) != count($users)) {
         if (is_array($users)) {
             foreach ($users as $u) {
                 $keys = array_keys($userIdList, $u->id);
                 unset($userIdList[$keys[0]]);
                 unset($planStateDate[(int) $u->id]);
             }
         }
         $idList = implode(', ', $userIdList);
         $this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("Not all userId exist, are active (confirmed, approved and enabled) ! innexistant or inactive ids: ") . $idList;
         return false;
     }
     $this->_db->setQuery("SELECT DISTINCT user_id FROM #__cbsubs_subscriptions WHERE user_id IN (" . implode(',', $userIdList) . ")" . " ORDER BY user_id");
     $usersSubscribed = $this->_db->loadResultArray();
     $incompatibleUsersSubs = array();
     if ($this->import_type != 'file_uid_plan_exp') {
         foreach ($users as $user) {
             @set_time_limit(60);
             $incompatible = false;
             if (in_array($user->id, $usersSubscribed)) {
                 if ($plan->get('exclusive') && $plan->get('item_type') == 'usersubscription') {
                     $paidUserExtension = cbpaidUserExtension::getInstance($user->id);
                     $subscriptions = $paidUserExtension->getUserSubscriptions(null, false);
                     foreach ($subscriptions as $s) {
                         if ($s->parent_plan == $plan->get('parent') && $s->checkIfValid()) {
                             $sPlan = $s->getPlan();
                             if ($sPlan->get('exclusive') && $sPlan->get('item_type') == 'usersubscription') {
                                 // check if any other exclusive subscription with same parent plan is active:
                                 $incompatible = true;
                                 break;
                             }
                         }
                     }
                 }
             }
             if (!$incompatible) {
                 if ($plan->get('parent')) {
                     $plansMgr = cbpaidPlansMgr::getInstance();
                     $parentPlan = $plansMgr->loadPlan($plan->get('parent'));
                     $parentSub = $parentPlan->loadLatestSomethingOfUser($user->id, null);
                     if (!$parentSub) {
                         $incompatible = true;
                     }
                 }
             }
             if ($incompatible) {
                 if (!in_array($user->id, $incompatibleUsersSubs)) {
                     $incompatibleUsersSubs[] = $user->id;
                 }
                 continue;
             }
             if (!$this->dryrun) {
                 $userFull = CBuser::getUserDataInstance($user->id);
                 $this->createSomething($plan, $userFull, $this->state, $subscriptionTime);
                 CBuser::unsetUsersNotNeeded(array((int) $user->id));
             }
         }
     } else {
         $cbpaidTimes = cbpaidTimes::getInstance();
         $systemTimeZone = new DateTimeZone($cbpaidTimes->systemTimeZone());
         foreach ($users as $user) {
             @set_time_limit(60);
             foreach ($planStateDate[(int) $user->id] as $psd) {
                 $plan = $plansMgr->loadPlan((int) $psd['plan']);
                 $status = $psd['status'];
                 if ($psd['date']) {
                     $date = DateTime::createFromFormat('Y-m-d H:i:s', $psd['date'], $systemTimeZone);
                     $subscriptionTime = $date->getTimestamp();
                 } else {
                     $subscriptionTime = $cbpaidTimes->startTime();
                 }
                 $incompatible = false;
                 if (in_array($user->id, $usersSubscribed)) {
                     if ($plan->get('exclusive') && $plan->get('item_type') == 'usersubscription') {
                         $paidUserExtension = cbpaidUserExtension::getInstance($user->id);
                         $subscriptions = $paidUserExtension->getUserSubscriptions(null, false);
                         foreach ($subscriptions as $s) {
                             if ($s->parent_plan == $plan->get('parent') && $s->checkIfValid()) {
                                 $sPlan = $s->getPlan();
                                 if ($sPlan->get('exclusive') && $sPlan->get('item_type') == 'usersubscription') {
                                     // check if any other exclusive subscription with same parent plan is active:
                                     $incompatible = true;
                                     break;
                                 }
                             }
                         }
                     }
                 }
                 if (!$incompatible) {
                     if ($plan->get('parent')) {
                         $plansMgr = cbpaidPlansMgr::getInstance();
                         $parentPlan = $plansMgr->loadPlan($plan->get('parent'));
                         $parentSub = $parentPlan->loadLatestSomethingOfUser($user->id, null);
                         if (!$parentSub) {
                             $incompatible = true;
                         }
                     }
                 }
                 if ($incompatible) {
                     if (!in_array($user->id, $incompatibleUsersSubs)) {
                         $incompatibleUsersSubs[] = $user->id;
                     }
                     continue;
                 }
                 if (!$this->dryrun) {
                     $userFull = CBuser::getUserDataInstance($user->id);
                     $this->createSomething($plan, $userFull, $status, $subscriptionTime);
                     CBuser::unsetUsersNotNeeded(array((int) $user->id));
                 }
             }
         }
     }
     if (count($userIdList) > 0 && count($incompatibleUsersSubs) == 0) {
         $resultText = CBPTXT::T("Success");
     } elseif (count($userIdList) > count($incompatibleUsersSubs)) {
         $resultText = CBPTXT::T("Partial Success");
     } elseif (count($userIdList) == count($incompatibleUsersSubs)) {
         $resultText = CBPTXT::T("Import failed");
     } else {
         $resultText = CBPTXT::T("Unknown Result");
     }
     $return .= '<h1>' . $resultText . ($this->dryrun ? ' [' . CBPTXT::T("DRY-RUN - NO REAL SUBSCRIPTION") . ']' : '') . ':</h1>';
     if (count($incompatibleUsersSubs) > 0) {
         $idList = implode(', ', $incompatibleUsersSubs);
         $return .= '<p>' . CBPTXT::T("Some users have already subscriptions: user ids: ") . $idList . '</p>';
         // $this->_error		=	CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("Some users have already subscriptions: user ids: ") . $idList;
         // return false;
     }
     if ($this->import_type != 'file_uid_plan_exp') {
         $return .= '<p>' . sprintf(CBPTXT::T("%d users subscribed to plan: %s , with state: %s"), count($userIdList) - count($incompatibleUsersSubs), $plan->get('name'), CBPTXT::T($this->_states[$this->state])) . '</p>';
         if (count($userIdList) - count($incompatibleUsersSubs) > 0) {
             $return .= '<p>' . CBPTXT::T("Users subscribed (usernames):") . '</p>';
             $return .= '<p>';
             foreach ($users as $user) {
                 if (!in_array($user->id, $incompatibleUsersSubs)) {
                     $return .= $user->username . ' ';
                 }
             }
             $return .= '</p>';
         }
     } else {
         $return .= '<p>' . sprintf(CBPTXT::T("%d users subscribed"), count($userIdList) - count($incompatibleUsersSubs)) . '</p>';
         if (count($userIdList) - count($incompatibleUsersSubs) > 0) {
             $return .= '<p>' . CBPTXT::T("Users subscribed (usernames):") . '</p>';
             foreach ($users as $user) {
                 if (!in_array($user->id, $incompatibleUsersSubs)) {
                     $return .= '<p>' . $user->username . ' ' . CBPTXT::T("to") . ' ';
                     foreach ($planStateDate[(int) $user->id] as $psd) {
                         $plan = $plansMgr->loadPlan((int) $psd['plan']);
                         $status = $psd['status'];
                         $return .= sprintf(CBPTXT::T("plan: %s , with state: %s") . ' ', $plan->get('name'), CBPTXT::T($this->_states[$status]));
                     }
                 }
             }
             $return .= '</p>';
         }
     }
     if (count($incompatibleUsersSubs) > 0) {
         $return .= '<p>' . CBPTXT::T("Following Users could not be subscribed (usernames) because either: (A) an exclusive active subscription exists that would conflict with the imported user subscription, or: (B) it is a children plan but the parent plan subscription does not exist:") . '</p>';
         $return .= '<p>';
         foreach ($incompatibleUsersSubs as $uid) {
             if (isset($users[$uid])) {
                 $return .= $users[$uid]->username . ' ';
             }
         }
         $return .= '</p>';
     }
     $this->_resultOfStore = $return;
     return true;
 }
示例#12
0
	/**
	 * Implements a form permissions for asset assetname
	 *
	 * @param  string              $name          The name of the form element
	 * @param  string              $value         The value of the element
	 * @param  SimpleXMLElement  $node          The xml element for the parameter
	 * @param  string              $control_name  The control name
	 * @return string                             The html for the element
	 */
	function _form_permissions( $name, /** @noinspection PhpUnusedParameterInspection */ $value, &$node, $control_name ) {
		if ( checkJversion() >= 2 ) {
			return $this->getPermissionsForm( $name, $node, $control_name )->getInput( 'rules' );
		} else {
			return null;
		}
	}
示例#13
0
 /**
  * Retrieve joomla standard user parameters so that they can be displayed in user edit mode.
  *
  * @param  int        $ui        1 for front-end, 2 for back-end
  * @param  UserTable  $user      the user being displayed
  * @param  string     $name      Name of variable
  * @return array                 of user parameter attributes (title,value)
  */
 function _getUserParams($ui, $user, $name = "params")
 {
     global $_CB_framework;
     $juser = $_CB_framework->_getCmsUserObject($user->id);
     $result = array();
     if (checkJversion('3.0+')) {
         // Include jQuery
         JHtml::_('jquery.framework');
     }
     jimport('joomla.form.form');
     JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_users/models/forms');
     $form = JForm::getInstance('com_users.params', 'user', array('load_data' => true));
     $params = $juser->getParameters(true)->toArray();
     if ($params) {
         foreach ($params as $k => $v) {
             $form->setValue($k, 'params', $v);
         }
     }
     $fields = $form->getFieldset('settings');
     if ($fields) {
         foreach ($fields as $fieldId => $field) {
             $admin_field = strpos($field->name, 'admin') || strpos($field->name, 'help');
             if ($admin_field && ($juser->authorise('canManageUsers') || !$user->id) || !$admin_field) {
                 $result[] = array($field->title, $field->input, $field->description, $field->name, $fieldId);
             }
         }
     }
     return $result;
 }
示例#14
0
 static function getTwoFactorMethods()
 {
     global $_CB_framework;
     if (checkJversion('3.2+')) {
         require_once $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_users/helpers/users.php';
         return UsersHelper::getTwoFactorMethods();
     } else {
         return array();
     }
 }
示例#15
0
 /**
  * Implements a form permissions for asset assetname
  *
  * @param  string              $name          The name of the form element
  * @param  string              $value         The value of the element
  * @param  SimpleXMLElement  $node          The xml element for the parameter
  * @param  string              $control_name  The control name
  * @return string                             The html for the element
  */
 function _form_permissions($name, $value, &$node, $control_name)
 {
     if (checkJversion() >= 2) {
         return $this->getPermissionsForm($name, $node, $control_name)->getInput('rules');
     } else {
         return null;
     }
 }
    function edittab(&$row, $option, &$lists, $tabid, &$paramsEditorHtml)
    {
        global $_CB_framework, $task, $_CB_database, $_PLUGINS;
        _CBsecureAboveForm('edittab');
        outputCbTemplate(2);
        outputCbJs(2);
        initToolTip(2);
        $_CB_framework->outputCbJQuery('');
        global $_CB_Backend_Title;
        $_CB_Backend_Title = array(0 => array('cbicon-48-tabs', CBTxt::T('Community Builder Tab') . ": <small>" . ($row->tabid ? CBTxt::T('Edit') . ' [ ' . htmlspecialchars(getLangDefinition($row->title)) . ' ]' : CBTxt::T('New')) . '</small>'));
        if ($row->tabid && !$row->enabled) {
            echo '<div class="cbWarning">' . CBTxt::T('Tab is not published') . '</div>' . "\n";
        }
        $editorSave_description = $_CB_framework->saveCmsEditorJS('description');
        ob_start();
        ?>
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'showTab') {
		        <?php 
        echo $editorSave_description;
        ?>
				cbsubmitform( pressbutton );
				return;
			}
			var r = new RegExp("[^0-9A-Za-z]", "i");

			// do field validation
			if (jQuery.trim(form.title.value) == "") {
				alert('<?php 
        echo addslashes(CBTxt::T('You must provide a title.'));
        ?>
');
			} else {
		        <?php 
        echo $editorSave_description;
        ?>
				cbsubmitform( pressbutton );
			}
		}
<?php 
        $js = ob_get_contents();
        ob_end_clean();
        $_CB_framework->document->addHeadScriptDeclaration($js);
        ?>
	<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>

	<form action="<?php 
        echo $_CB_framework->backendUrl('index.php?option=com_comprofiler&task=saveTab');
        ?>
" method="POST" name="adminForm">
	<table cellspacing="0" cellpadding="0" width="100%">
	<tr valign="top">
		<td width="60%" valign="top">
			<table class="adminform">
			<tr>
				<th colspan="3">
				<?php 
        echo CBTxt::T('Tab Details');
        ?>
				</th>
			</tr>
			<tr>
				<td width="20%"><?php 
        echo CBTxt::T('Title');
        ?>
:</td>
				<td width="35%"><input type="text" name="title" class="inputbox" size="40" value="<?php 
        echo htmlspecialchars($row->title);
        ?>
" /></td>
				<td width="45%"><?php 
        echo CBTxt::T('Title as will appear on tab.');
        ?>
</td>
			</tr>
			<tr>
				<td colspan="3"><?php 
        echo CBTxt::T('Description: This description appears only on user edit, not on profile (For profile text, use delimiter fields)');
        ?>
:</td>
			</tr>
			<tr>
				<td colspan="3" align="left"><?php 
        echo $_CB_framework->displayCmsEditor('description', $row->description, 600, 200, 50, 10);
        // <textarea name="description" class="inputbox" cols="40" rows="10">< ?php echo htmlspecialchars( $row->description ); ? ></textarea>
        ?>
</td>
			</tr>
			<tr>
				<td><?php 
        echo CBTxt::T('Publish');
        ?>
:</td>
				<td><?php 
        echo $lists['enabled'];
        ?>
</td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td><?php 
        echo CBTxt::T('Profile ordering');
        ?>
:</td>
				<td><?php 
        echo $lists['ordering'];
        ?>
</td>
				<td><?php 
        echo CBTxt::T('Tabs and fields on profile are ordered as follows:');
        ?>
<ol>
				    <li><?php 
        echo CBTxt::T('position of tab on user profile (top-down, left-right)');
        ?>
</li>
				    <li><?php 
        echo CBTxt::T('This ordering of tab on position of user profile');
        ?>
</li>
				    <li><?php 
        echo CBTxt::T('ordering of field within tab position of user profile.');
        ?>
</li></ol>
				</td>
			</tr>
			<tr>
				<td><?php 
        echo CBTxt::T('Registration ordering');
        ?>
<br /><?php 
        echo CBTxt::T('(default value: 10)');
        ?>
:</td>
				<td><?php 
        echo $lists['ordering_register'];
        ?>
</td>
				<td><?php 
        echo CBTxt::T('Tabs and fields on registration are ordered as follows:');
        ?>
<ol>
					<li><?php 
        echo CBTxt::T('This registration ordering of tab');
        ?>
</li>
				    <li><?php 
        echo CBTxt::T('position of tab on user profile (top-down, left-right)');
        ?>
</li>
				    <li><?php 
        echo CBTxt::T('ordering of tab on position of user profile');
        ?>
</li>
				    <li><?php 
        echo CBTxt::T('ordering of field within tab position of user profile.');
        ?>
</li></ol>
				</td>
			</tr>
			<tr>
				<td><?php 
        echo CBTxt::T('Position');
        ?>
:</td>
				<td><?php 
        echo $lists['position'];
        ?>
</td>
				<td><?php 
        echo CBTxt::T('Position on profile and ordering on registration.');
        ?>
</td>
			</tr>
			<tr>
				<td><?php 
        echo CBTxt::T('Display type');
        ?>
:</td>
				<td><?php 
        echo $lists['displaytype'];
        ?>
</td>
				<td><?php 
        echo CBTxt::T('In which way the content of this tab will be displayed on the profile.');
        ?>
</td>
			</tr>
			<tr>
				<td><?php 
        echo CBTxt::Th('View Access Level');
        ?>
:</td>
				<td><?php 
        echo $lists['viewaccesslevel'];
        ?>
</td>
				<td><?php 
        echo CBTxt::Th('Only users which are in groups assigned to this View Access Level will see this tab.') . ($lists['useraccessgroup'] ? ' (' . CBTxt::Th('New method working in all Joomla and Mambo versions') . ')' : '');
        ?>
</td>
			</tr>
			<?php 
        if ($lists['useraccessgroup']) {
            ?>
			<tr>
				<td><?php 
            echo CBTxt::Th('User Group to allow access to') . (checkJversion() >= 2 ? '<br /><em>(' . CBTxt::Th("Old deprecated method of Joomla 1.5, do not use here") . '. ' . CBTxt::Th('Keep setting "-- Everybody --" and Use View Access Level above instead') . ')</em>' : '');
            ?>
:</td>
				<td><?php 
            echo $lists['useraccessgroup'];
            ?>
</td>
				<td><?php 
            echo CBTxt::Ph('Old Joomla [VERSION] method', array('[VERSION]' => '1.0 and 1.5 and Mambo')) . ': ' . CBTxt::Th('This method is kept for backwards compatibility but will be removed at next major Community Builder version.') . '<br />' . CBTxt::Th('Use View Access Level above instead and set this Group setting to - "Everybody" -.') . ' ' . CBTxt::Th('All groups above that level will also have access to this tab.');
            ?>
				</td>
			</tr>
			<?php 
        }
        ?>
			</table>
		</td>
		<td width="40%">
			<table class="adminform">
			<tr>
				<th colspan="2">
				<?php 
        echo CBTxt::T('Parameters');
        ?>
				</th>
			</tr>
			<tr>
				<td>
				<?php 
        if ($row->tabid && $row->pluginid > 0) {
            $plugin = new moscomprofilerPlugin($_CB_database);
            $plugin->load((int) $row->pluginid);
            // fail if checked out not by 'me'
            if ($plugin->checked_out && $plugin->checked_out != $_CB_framework->myId()) {
                echo "<script type=\"text/javascript\">alert('" . addslashes(sprintf(CBTxt::T('The plugin %s is currently being edited by another administrator'), $plugin->name)) . "'); document.location.href='" . $_CB_framework->backendUrl("index.php?option={$option}") . "'</script>\n";
                exit(0);
            }
            // get params values
            if ($plugin->type !== "language" && $plugin->id) {
                $_PLUGINS->loadPluginGroup($plugin->type, array((int) $plugin->id), 0);
            }
            $element = $_PLUGINS->loadPluginXML('editTab', $row->pluginclass, $plugin->id);
            /*
            					$xmlfile = $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/' .$plugin->type . '/'.$plugin->folder . '/' . $plugin->element .'.xml';
            					// $params = new cbParameters( $row->params, $xmlfile );
            					cbimport('cb.xml.simplexml');
            					$xmlDoc = new CBSimpleXML();
            					if ( $xmlDoc->loadFile( $xmlfile ) ) {
            						$element =& $xmlDoc->document;
            					} else {
            						$element = null;
            					}
            */
            $pluginParams = new cbParamsBase($plugin->params);
            $params = new cbParamsEditorController($row->params, $element, $element, $plugin, $row->tabid);
            $params->setPluginParams($pluginParams);
            $options = array('option' => $option, 'task' => $task, 'pluginid' => $row->pluginid, 'tabid' => $row->tabid);
            $params->setOptions($options);
            echo $params->draw('params', 'tabs', 'tab', 'class', $row->pluginclass);
        } else {
            echo '<em>' . CBTxt::T('No Parameters') . '</em>';
        }
        if ($paramsEditorHtml) {
            foreach ($paramsEditorHtml as $paramsEditorHtmlBlock) {
                ?>
					<table class="adminform" cellspacing="0" cellpadding="0" width="100%">
						<tr>
							<th colspan="2">
								<?php 
                echo $paramsEditorHtmlBlock['title'];
                ?>
							</th>
						</tr>
						<tr>
							<td>
								<?php 
                echo $paramsEditorHtmlBlock['content'];
                ?>
							</td>
						</tr>
					</table>
<?php 
            }
        }
        ?>
				</td>
			</tr>
			</table>
		</td>
	</tr>
	</table>
  <input type="hidden" name="tabid" value="<?php 
        echo $row->tabid;
        ?>
" />
  <input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
  <input type="hidden" name="task" value="" />
  <?php 
        if (!$lists['useraccessgroup']) {
            ?>
  <input type="hidden" name="useraccessgroupid" value="-2" />
  <?php 
        }
        echo cbGetSpoofInputTag('tab');
        ?>
</form>
<?php 
    }
示例#17
0
	function get_user_group_id( $user_id ) {
		global $_CB_database;

		static $gid				=	array();

		$user_id				=	(int) $user_id;

		if ( ! isset( $gid[$user_id] ) ) {
			if ( checkJversion() == 2 ) {
				$query			=	'SELECT ' . $_CB_database->NameQuote( 'group_id' )
								.	"\n FROM " . $_CB_database->NameQuote( '#__user_usergroup_map' )
								.	"\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user_id;
				$_CB_database->setQuery( $query );
				$gid[$user_id]	=	(int) $_CB_database->loadResult();
			} else {
				$query			=	'SELECT ' . $_CB_database->NameQuote( 'gid' )
								.	"\n FROM " . $_CB_database->NameQuote( '#__users' )
								.	"\n WHERE " . $_CB_database->NameQuote( 'id' ) . " = " . (int) $user_id;
				$_CB_database->setQuery( $query );
				$gid[$user_id]	=	(int) $_CB_database->loadResult();
			}
		}

		return $gid[$user_id];
	}
示例#18
0
 /**
  * @param  array  $component  The parent menu node
  * @param  array  $items      The menu items to output
  * @param  bool   $disabled   If the menu item should be disabled (grayed)
  * @param  int    $depth      The depth of the menu items
  * @return null|string
  */
 private static function getMenuItems($component, $items = array(), $disabled = false, $depth = 0)
 {
     $parentTitleCleanHtml = isset($component['title']) ? $component['title'] : null;
     $parentAccess = isset($component['access']) ? $component['access'] : null;
     $return = null;
     if ($parentTitleCleanHtml && modCBAdminHelper::checkAccess($parentAccess)) {
         if (!$disabled) {
             if (!$depth) {
                 $return .= '<li class="' . (checkJversion('3.0+') ? 'dropdown' : 'node') . '">' . '<a' . (checkJversion('3.0+') ? ' class="dropdown-toggle" data-toggle="dropdown"' : null) . ' href="#">' . $parentTitleCleanHtml . (checkJversion('3.0+') ? ' <span class="caret"></span>' : null) . '</a>';
             }
             if ($items) {
                 $menu = null;
                 foreach ($items as $item) {
                     $title = isset($item['title']) ? $item['title'] : null;
                     $link = isset($item['link']) ? $item['link'] : null;
                     $access = isset($item['access']) ? $item['access'] : null;
                     $icon = isset($item['icon']) ? $item['icon'] : null;
                     $target = isset($item['target']) ? $item['target'] : null;
                     $subMenu = isset($item['submenu']) ? $item['submenu'] : array();
                     if ($title && $link && modCBAdminHelper::checkAccess($access)) {
                         $subMenu = $subMenu ? modCBAdminHelper::getMenuItems($item, $subMenu, false, $depth + 1) : null;
                         $menu .= '<li' . ($subMenu ? ' class="' . (checkJversion('3.0+') ? 'dropdown-submenu' : 'node') . '"' : null) . '>' . '<a' . ($icon ? ' class="' . (checkJversion('3.0+') ? 'menu-' : 'icon-16-') . htmlspecialchars($icon) . '"' : null) . ' href="' . htmlspecialchars($link) . '"' . ($target ? ' target="' . htmlspecialchars($target) . '"' : null) . '>' . '<span>' . $title . '</span>' . '</a>' . $subMenu . '</li>';
                     } elseif ($title == 'spacer') {
                         $menu .= '<li class="' . (checkJversion('3.0+') ? 'divider' : 'separator') . '"><span></span></li>';
                     }
                 }
                 if ($menu) {
                     $return .= '<ul' . (checkJversion('3.0+') ? ' class="dropdown-menu"' : null) . '>' . $menu . '</ul>';
                 }
             }
             if (!$depth) {
                 $return .= '</li>';
             }
         } elseif (!$depth) {
             $return .= '<li class="disabled">' . '<a href="#">' . $parentTitleCleanHtml . '</a>' . '</li>';
         }
     }
     return $return;
 }
ob_end_clean();
$_CB_framework->getAllJsPageCodes();
$html = ob_get_contents();
ob_end_clean();
if (in_array($taskPart1, array('fieldclass', 'tabclass', 'pluginclass')) || cbGetParam($_GET, 'no_html', 0) == 1 || cbGetParam($_GET, 'format') == 'raw') {
    echo $html;
} else {
    echo $_CB_framework->document->outputToHead();
    ?>
<div class="cbAdminMain cb_template cb_template_<?php 
    echo selectTemplate('dir');
    ?>
" style="margin:0; border-width: 0; padding: 0;width: 100% ;text-align: left;">
	<div class="cbAdminMainInner" id="cbAdminMainWrapper" style="margin: 0; border-width: 0; padding: 0; float: none; width: auto;">
<?php 
    if (checkJversion() >= 2 && !checkJversion('j3.0+')) {
        /** @noinspection PhpDeprecationInspection */
        JSubMenuHelper::addEntry(CBTxt::T('Control Panel'), 'index.php?option=com_comprofiler', $taskPart1 == '');
        if (Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.manage', 'com_users')) {
            /** @noinspection PhpDeprecationInspection */
            JSubMenuHelper::addEntry(CBTxt::T('User Management'), 'index.php?option=com_comprofiler&view=showusers', $taskPart1 == 'showusers');
        }
        if (Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.manage', 'com_comprofiler.tabs')) {
            /** @noinspection PhpDeprecationInspection */
            JSubMenuHelper::addEntry(CBTxt::T('Tab Management'), 'index.php?option=com_comprofiler&view=showTab', $taskPart1 == 'showTab');
        }
        if (Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.manage', 'com_comprofiler.fields')) {
            /** @noinspection PhpDeprecationInspection */
            JSubMenuHelper::addEntry(CBTxt::T('Field Management'), 'index.php?option=com_comprofiler&view=showField', $taskPart1 == 'showField');
        }
        if (Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.manage', 'com_comprofiler.lists')) {
 /**
  * @param  SimpleXMLElement[]  $xmlToolbarMenuArray
  * @return void
  */
 static function _PLUGIN_MENU($xmlToolbarMenuArray)
 {
     if ($xmlToolbarMenuArray && count($xmlToolbarMenuArray) > 0) {
         $started = false;
         foreach ($xmlToolbarMenuArray as $xmlTBmenu) {
             if ($xmlTBmenu && count($xmlTBmenu->children()) > 0) {
                 foreach ($xmlTBmenu->children() as $menu) {
                     /** @var SimpleXMLElement $menu */
                     if ($menu->getName() == 'menu') {
                         // $name			=	$menu->attributes( 'name' );
                         $action = $menu->attributes('action');
                         $task = $menu->attributes('task');
                         $label = $menu->attributes('label');
                         $class = RegistryEditView::buildClasses($menu);
                         $description = $menu->attributes('description');
                         if (in_array($action, get_class_methods('CBtoolmenuBar')) || in_array(strtolower($action), get_class_methods('CBtoolmenuBar'))) {
                             // PHP 5 || PHP 4
                             if (!$started) {
                                 CBtoolmenuBar::startTable();
                                 $started = true;
                             }
                             switch ($action) {
                                 case 'custom':
                                 case 'customX':
                                     $icon = $menu->attributes('icon');
                                     $iconOver = $menu->attributes('iconover');
                                     CBtoolmenuBar::$action($task, $icon, $iconOver, $label, false, null, $class);
                                     break;
                                 case 'editList':
                                     CBtoolmenuBar::editListNoSelect($task, $label);
                                     break;
                                 case 'deleteList':
                                 case 'deleteListX':
                                     $message = $menu->attributes('message');
                                     CBtoolmenuBar::$action($message, $task, $label);
                                     break;
                                 case 'trash':
                                     CBtoolmenuBar::$action($task, $label, false);
                                     break;
                                 case 'preview':
                                     $popup = $menu->attributes('popup');
                                     CBtoolmenuBar::$action($popup, true);
                                     break;
                                 case 'help':
                                     $ref = $menu->attributes('href');
                                     if (!$ref) {
                                         // Backwards compatibility to CB 1.x:
                                         $ref = $menu->attributes('ref');
                                     }
                                     CBtoolmenuBar::$action($ref, true);
                                     break;
                                 case 'divider':
                                 case 'spacer':
                                     CBtoolmenuBar::$action();
                                     break;
                                 case 'back':
                                     $href = $menu->attributes('href');
                                     CBtoolmenuBar::$action($label, $href);
                                     break;
                                 case 'media_manager':
                                     $directory = $menu->attributes('directory');
                                     CBtoolmenuBar::$action($directory, $label);
                                     break;
                                 case 'linkAction':
                                     $urllink = $menu->attributes('urllink');
                                     if ($menu->attributes('task') == 'new') {
                                         CBtoolmenuBar::$action($task, $urllink, $label, $class ? $class : (checkJversion('j3.0+') ? 'btn-success' : null));
                                     } else {
                                         CBtoolmenuBar::$action($task, $urllink, $label, $class);
                                     }
                                     break;
                                 default:
                                     CBtoolmenuBar::$action($task, $label);
                                     break;
                             }
                         } elseif ($action == 'permissions') {
                             if ($description) {
                                 $headerHtml = '<div class="cbbejeoptionsintro cbbejeoptionsintro' . htmlspecialchars($task) . '">' . $description . '</div>';
                             } else {
                                 $headerHtml = null;
                             }
                             self::_PERMISSIONS($task, $headerHtml);
                             if ($label) {
                                 self::_TRANSLATECONFIGTITLE($task, $label);
                             }
                         }
                         // if ( in_array( $action, array(	'customX', 'addNew', 'addNewX', 'publish', 'publishList', 'makeDefault', 'assign', 'unpublish', 'unpublishList',
                         //								'archiveList', 'unarchiveList', ) ) ) {
                         // nothing
                         // }
                     }
                 }
             }
         }
         if ($started) {
             CBtoolmenuBar::endTable();
         }
     }
 }
    function edituser($user, $option, $newCBuser, &$postdata)
    {
        global $_CB_framework, $_PLUGINS;
        $results = $_PLUGINS->trigger('onBeforeUserProfileEditDisplay', array(&$user, 2));
        if ($_PLUGINS->is_errors()) {
            echo "<script type=\"text/javascript\">alert(\"" . str_replace(array("\n", '<br />'), array('\\n', '\\n'), addslashes($_PLUGINS->getErrorMSG())) . "\"); window.history.go(-1); </script>\n";
            exit;
        }
        _CBsecureAboveForm('edituser');
        outputCbTemplate(2);
        initToolTip(2);
        $tabs = new cbTabs($_CB_framework->getUi() == 2 && !isset($_REQUEST['tab']) ? 1 : 0, 2);
        // use cookies in backend to remember selected tab.
        $tabcontent = $tabs->getEditTabs($user, $postdata);
        outputCbJs(2);
        global $_CB_Backend_Title;
        //OLD:	$_CB_Backend_Title	=	array( 0 => array( 'cbicon-48-users', "Community Builder User: <small>" . ( $user->id ? "Edit" . ' [ '. $user->username .' ]' : "New" ) . '</small>' ) );
        //NEW:
        $_CB_Backend_Title = array(0 => array('cbicon-48-users', CBTxt::T('Community Builder User') . ": <small>" . ($user->id ? CBTxt::T('Edit') . ' [ ' . $user->username . ' ]' : CBTxt::T('New')) . '</small>'));
        ob_start();
        if (defined('_CB_VALIDATE_NEW')) {
            cbimport('cb.validator');
            cbValidator::renderGenericJs();
            ?>

$('div.cbtoolbaractions .cbtoolbaraction').click( function() {
		if ( $(this).attr('href') ) {
			var taskVal = $(this).attr('href').substring(1);
		} else if ( $(this).attr('value') ) {
			taskVal = $(this).attr('value').substring(1);
		}
		$('#cbcheckedadminForm input[name=task]').val( taskVal );
		if (taskVal == 'showusers') {
			$('#cbcheckedadminForm')[0].submit();
		} else {
			$('#cbcheckedadminForm').submit();
		}
		return false;
	} );

<?php 
            $cbjavascript = ob_get_contents();
            ob_end_clean();
            $_CB_framework->outputCbJQuery($cbjavascript, array('metadata', 'validate'));
        } else {
            // old way:
            ?>
var cbDefaultFieldbackgroundColor;
function cbFrmSubmitButton() {
	var me = this.elements;
<?php 
            $version = checkJversion();
            if ($version == 1) {
                // var r = new RegExp("^[a-zA-Z](([\.\-a-zA-Z0-9@])?[a-zA-Z0-9]*)*$", "i");
                ?>
	var r = new RegExp("^[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]*$", "i");
<?php 
            } elseif ($version == -1) {
                ?>
	var r = new RegExp("[^A-Za-z0-9]", "i");
<?php 
            } else {
                ?>
	var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
<?php 
            }
            ?>
	var errorMSG = '';
	var iserror=0;
	if (cbDefaultFieldbackgroundColor === undefined) cbDefaultFieldbackgroundColor = ((me['username'].style.getPropertyValue) ? me['username'].style.getPropertyValue("backgroundColor") : me['username'].style.backgroundColor);
<?php 
            echo $tabs->fieldJS;
            ?>
	if (me['username'].value == "") {
		errorMSG += "<?php 
            echo str_replace(array("\n", "\r"), ' ', CBTxt::html_entity_decode(_REGWARN_UNAME));
            ?>
\n";
		me['username'].style.backgroundColor = "red";
		iserror=1;
	} else if (r.exec(me['username'].value) || (me['username'].value.length < 3)) {
		errorMSG += "<?php 
            echo str_replace(array("\n", "\r"), ' ', sprintf(CBTxt::html_entity_decode(_VALID_AZ09), CBTxt::html_entity_decode(_PROMPT_UNAME), 2));
            ?>
\n";
		me['username'].style.backgroundColor = "red";
		iserror=1;
	} else if (me['username'].style.backgroundColor.slice(0,3)=="red") {
		me['username'].style.backgroundColor = cbDefaultFieldbackgroundColor;
	}
	if ((me['password'].value != "") && (me['password'].value != me['password__verify'].value)){
		errorMSG += "<?php 
            echo CBTxt::html_entity_decode(_REGWARN_VPASS2);
            ?>
\n";
		me['password'].style.backgroundColor = "red"; me['password__verify'].style.backgroundColor = "red";
		iserror=1;
	} else {
		if (me['password'].style.backgroundColor.slice(0,3)=="red") me['password'].style.backgroundColor = cbDefaultFieldbackgroundColor;
		if (me['password__verify'].style.backgroundColor.slice(0,3)=="red") me['password__verify'].style.backgroundColor = cbDefaultFieldbackgroundColor;
	}
	if (!$('input[name^=\"gid\"],select[name^=\"gid\"]').val()) {
		errorMSG += '<?php 
            echo addslashes(CBTxt::T('You must assign user to a group.'));
            ?>
' + "\n";
		iserror=1;
	}

	// loop through all input elements in form
	var fieldErrorMessages = new Array;
	for (var i=0; i < me.length; i++) {
		// check if element is mandatory; here mosReq=1
		if ( (typeof(me[i].getAttribute('mosReq')) != "undefined") && ( me[i].getAttribute('mosReq') == 1) ) {
			if (me[i].type == 'radio' || me[i].type == 'checkbox') {
				var rOptions = me[me[i].getAttribute('name')];
				var rChecked = 0;
				if(rOptions.length > 1) {
					for (var r=0; r < rOptions.length; r++) {
						if ( (typeof(rOptions[r].getAttribute('mosReq')) != "undefined") && ( rOptions[r].getAttribute('mosReq') == 1) ) {
							if (rOptions[r].checked) {
								rChecked=1;
							}
						}
					}
				} else {
					if (me[i].checked) {
						rChecked=1;
					}
				}
				if(rChecked==0) {
					for (var k=0; k < me.length; k++) {
						if (me[i].getAttribute('name') == me[k].getAttribute('name')) {
							if (me[k].checked) {
								rChecked=1;
								break;
							}
						}
					}
				}
				if(rChecked==0) {
					var alreadyFlagged = false;
					for (var j = 0, n = fieldErrorMessages.length; j < n; j++) {
						if (fieldErrorMessages[j] == me[i].getAttribute('name')) {
							alreadyFlagged = true;
							break
						}
					}
					if ( ! alreadyFlagged ) {
						fieldErrorMessages.push(me[i].getAttribute('name'));
						// add up all error messages
						errorMSG += me[i].getAttribute('mosLabel') + ' : <?php 
            echo CBTxt::html_entity_decode(_UE_REQUIRED_ERROR);
            ?>
\n';
						// notify user by changing background color, in this case to red
						me[i].style.backgroundColor = "red";
						iserror=1;
					}
				} else if (me[i].style.backgroundColor.slice(0,3)=="red") me[i].style.backgroundColor = cbDefaultFieldbackgroundColor;
			}
			if (me[i].value == '') {
				// add up all error messages
				errorMSG += me[i].getAttribute('mosLabel') + ' : <?php 
            echo CBTxt::html_entity_decode(_UE_REQUIRED_ERROR);
            ?>
\n';
				// notify user by changing background color, in this case to red
				me[i].style.backgroundColor = "red";
				iserror=1;
			} else if (me[i].style.backgroundColor.slice(0,3)=="red") me[i].style.backgroundColor = cbDefaultFieldbackgroundColor;
		}
	}
	if(iserror==1) {
		alert(errorMSG);
		return false;
	} else {
		return true;
	}
}
$('#cbcheckedadminForm').submit( cbFrmSubmitButton );
$('div.cbtoolbaractions .cbtoolbaraction').click( function() {
		if ( $(this).attr('href') ) {
			var taskVal = $(this).attr('href').substring(1);
		} else if ( $(this).attr('value') ) {
			taskVal = $(this).attr('value').substring(1);
		}
		$('#cbcheckedadminForm input[name=task]').val( taskVal );
		if (taskVal == 'showusers') {
			$('#userEditTable input').val('');
			$('#cbcheckedadminForm')[0].submit();
		} else {
			$('#cbcheckedadminForm').submit();
		}
		return false;
	} );
<?php 
            $cbjavascript = ob_get_contents();
            ob_end_clean();
            $_CB_framework->outputCbJQuery($cbjavascript);
            // end of old way
        }
        if (is_array($results)) {
            echo implode('', $results);
        }
        $this->_overideWebFxLayout();
        ?>
<div id="cbErrorMessages"></div>
<form action="<?php 
        echo $_CB_framework->backendUrl('index.php');
        ?>
" method="post" name="adminForm" id="cbcheckedadminForm" enctype="multipart/form-data" autocomplete="off">
<?php 
        echo "<table cellspacing='0' cellpadding='4' border='0' width='100%' id='userEditTable'><tr><td width='100%'>\n";
        echo $tabcontent;
        echo "</td></tr></table>";
        ?>
  <input type="hidden" name="id" value="<?php 
        echo $user->id;
        ?>
" />
  <input type="hidden" name="newCBuser" value="<?php 
        echo $newCBuser;
        ?>
" />
  <input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
  <input type="hidden" name="task" value="save" />
  <?php 
        echo cbGetSpoofInputTag('user');
        ?>
</form>
<div style="align:center;">
<?php 
        echo getFieldIcons(2, true, true, "", "", true);
        if (isset($_REQUEST['tab'])) {
            $_CB_framework->outputCbJQuery("showCBTab( '" . addslashes(urldecode(stripslashes(cbGetParam($_REQUEST, 'tab')))) . "' );");
        }
        ?>
</div>
<?php 
    }
 /**
  * Loads the appropriate UddeIM API lib
  *
  * @param string $jVersion
  */
 private function loadLib($jVersion = 'auto')
 {
     global $_CB_framework;
     $absPath = $_CB_framework->getCfg('absolute_path');
     if (file_exists($absPath . '/components/com_uddeim/uddeimlib.php')) {
         /** @noinspection PhpIncludeInspection */
         require_once $absPath . '/components/com_uddeim/uddeimlib.php';
     } elseif (checkJversion('3.3+') && $jVersion == 'auto' || $jVersion == '3.3') {
         if (file_exists($absPath . '/components/com_uddeim/uddeimlib33.php')) {
             /** @noinspection PhpIncludeInspection */
             require_once $absPath . '/components/com_uddeim/uddeimlib33.php';
         } else {
             $this->loadLib('3.2');
         }
     } elseif (checkJversion('3.2+') && $jVersion == 'auto' || $jVersion == '3.2') {
         if (file_exists($absPath . '/components/com_uddeim/uddeimlib32.php')) {
             /** @noinspection PhpIncludeInspection */
             require_once $absPath . '/components/com_uddeim/uddeimlib32.php';
         } else {
             $this->loadLib('3.1');
         }
     } elseif (checkJversion('3.1+') && $jVersion == 'auto' || $jVersion == '3.1') {
         if (file_exists($absPath . '/components/com_uddeim/uddeimlib31.php')) {
             /** @noinspection PhpIncludeInspection */
             require_once $absPath . '/components/com_uddeim/uddeimlib31.php';
         } else {
             $this->loadLib('3.0');
         }
     } elseif (checkJversion('3.0+') && $jVersion == 'auto' || $jVersion == '3.0') {
         if (file_exists($absPath . '/components/com_uddeim/uddeimlib30.php')) {
             /** @noinspection PhpIncludeInspection */
             require_once $absPath . '/components/com_uddeim/uddeimlib30.php';
         } else {
             $this->loadLib('2.5');
         }
     } elseif (checkJversion('2.5+') && $jVersion == 'auto' || $jVersion == '2.5') {
         if (file_exists($absPath . '/components/com_uddeim/uddeimlib25.php')) {
             /** @noinspection PhpIncludeInspection */
             require_once $absPath . '/components/com_uddeim/uddeimlib25.php';
         }
     }
 }
示例#23
0
 /**
  * Get highest group id
  *
  * @deprecated 1.8
  *
  * @param  int  $user_id
  * @return int
  */
 function get_user_group_id($user_id)
 {
     global $_CB_database;
     static $gid = array();
     $user_id = (int) $user_id;
     if (!isset($gid[$user_id])) {
         if ($user_id == 0) {
             $gid[$user_id] = (int) $this->mapGroupNamesToValues('Public');
         } else {
             if (checkJversion() == 2) {
                 $query = 'SELECT ' . $_CB_database->NameQuote('group_id') . "\n FROM " . $_CB_database->NameQuote('#__user_usergroup_map') . "\n WHERE " . $_CB_database->NameQuote('user_id') . " = " . (int) $user_id;
                 $_CB_database->setQuery($query);
                 $gids = $_CB_database->loadResultArray();
                 $gid[$user_id] = (int) $this->getBackwardsCompatibleGid($gids);
             } else {
                 $query = 'SELECT ' . $_CB_database->NameQuote('gid') . "\n FROM " . $_CB_database->NameQuote('#__users') . "\n WHERE " . $_CB_database->NameQuote('id') . " = " . (int) $user_id;
                 $_CB_database->setQuery($query);
                 $gid[$user_id] = (int) $_CB_database->loadResult();
             }
         }
     }
     return $gid[$user_id];
 }
示例#24
0
	function drawUsersList( $uid, $listid, $searchFormValuesRAW ) {
		global $_CB_database, $_CB_framework, $ueConfig, $Itemid, $_PLUGINS;
	
		$search					=	null;
		$searchGET				=	cbGetParam( $searchFormValuesRAW, 'search' );
		$limitstart				=	(int) cbGetParam( $searchFormValuesRAW, 'limitstart', 0 );
		$searchmode				=	(int) cbGetParam( $searchFormValuesRAW, 'searchmode', 0 );
		$randomParam			=	(int) cbGetParam( $searchFormValuesRAW, 'rand', 0 );
	
		// old search on formated name:
	
	/*	if ( $searchPOST || count( $_POST ) ) {
			// simple spoof check security
			cbSpoofCheck( 'usersList' );
			if ( cbGetParam( $searchFormValuesRAW, "action" ) == "search" ) {
				$search			=	$searchPOST;
			}
		} else
			if ( isset( $searchFormValuesRAW['limitstart'] ) ) {
				$search				=	stripslashes( $searchGET );
			}
	*/
		// get my user and gets the list of user lists he is allowed to see (ACL):
	
		$myCbUser				=&	CBuser::getInstance( $uid );
		if ( $myCbUser === null ) {
			$myCbUser			=&	CBuser::getInstance( null );
		}
		$myUser					=&	$myCbUser->getUserData();
	/*
		$myUser					=	new moscomprofilerUser( $_CB_database );
		if ( $uid ) {
			$myUser->load( (int) $uid );
		}
	*/
		$useraccessgroupSQL		=	" AND useraccessgroupid IN (".implode(',',getChildGIDS(userGID($uid))).")";
		$_CB_database->setQuery( "SELECT listid, title FROM #__comprofiler_lists WHERE published=1" . $useraccessgroupSQL . " ORDER BY ordering" );
		$plists					=	$_CB_database->loadObjectList();
		$lists					=	array();
		$publishedlists			=	array();
	
		for ( $i=0, $n=count( $plists ); $i < $n; $i++ ) {
			$plist				=&	$plists[$i];
			$listTitleNoHtml	=	strip_tags( cbReplaceVars( getLangDefinition( $plist->title ), $myUser, false, false ) );
		   	$publishedlists[]	=	moscomprofilerHTML::makeOption( $plist->listid, $listTitleNoHtml );
		}
	
		// select either list selected or default list to which he has access (ACL):
	
		if ( $listid == 0 ) {
			$_CB_database->setQuery( "SELECT listid FROM #__comprofiler_lists "
			. "\n WHERE `default`=1 AND published=1" . $useraccessgroupSQL );
			$listid				=	(int) $_CB_database->loadresult();
			if ( $listid == 0 && ( count( $plists ) > 0 ) ) {
				$listid			=	(int) $plists[0]->listid;
			}
		}
		if ( ! ( $listid > 0 ) ) {
			echo _UE_NOLISTFOUND;
			return;
		}
	
		// generates the drop-down list of lists:
	
		if ( count( $plists ) > 1 ) {
			$lists['plists']	=	moscomprofilerHTML::selectList( $publishedlists, 'listid', 'class="inputbox" size="1" onchange="this.form.submit();"', 'value', 'text', $listid, 1 );
		}
	
		// loads the list record:
	
		$row					=	new moscomprofilerLists( $_CB_database );
		if ( ( ! $row->load( (int) $listid ) ) || ( $row->published != 1 ) ) {
			echo _UE_LIST_DOES_NOT_EXIST;
			return;
		}
		if ( ! allowAccess( $row->useraccessgroupid,'RECURSE', userGID($uid) ) ) {
			echo _UE_NOT_AUTHORIZED;
			return;
		}
	
		$params					=	new cbParamsBase( $row->params );
	
		$hotlink_protection		=	$params->get( 'hotlink_protection', 0 );
		if ( $hotlink_protection == 1 ) {
			if ( ( $searchGET !== null ) || $limitstart ) {
				cbSpoofCheck( 'usersList', 'GET' );
			}
		}
	
		$limit					=	(int) $params->get( 'list_limit' );
		if ( $limit == 0 ) {
			$limit				=	(int) $ueConfig['num_per_page'];
		}
	
		$showPaging				=	$params->get( 'list_paging', 1 );
		if ( $showPaging != 1 ) {
			$limitstart			=	0;
		}
	
		$isModerator			=	isModerator( $_CB_framework->myId() );
	
		$_PLUGINS->loadPluginGroup( 'user' );
		// $plugSearchFieldsArray	=	$_PLUGINS->trigger( 'onStartUsersList', array( &$listid, &$row, &$search, &$limitstart, &$limit ) );
		$_PLUGINS->trigger( 'onStartUsersList', array( &$listid, &$row, &$search, &$limitstart, &$limit ) );
	
		// handles the users allowed to be listed in the list by ACL:
	
		$allusergids			=	array();
		$usergids				=	explode( ',', $row->usergroupids );
	/*	This was a bug tending to list admins when "public backend" was checked, and all frontend users when "public backend was checked. Now just ignore them:
		foreach( $usergids AS $usergid ) {
			$allusergids[]		=	$usergid;
			if ($usergid==29 || $usergid==30) {
				$groupchildren	=	array();
				$groupchildren	=	$_CB_framework->acl->get_group_children( $usergid, 'ARO','RECURSE' );
				$allusergids	=	array_merge($allusergids,$groupchildren);
			}
		}
	*/
		$allusergids			=	array_diff( $usergids, array( 29, 30 ) );
		$usergids				=	implode( ",", $allusergids );
	
		// build SQL Select query:
	
		$random					=	0;
		if( $row->sortfields != '' ) {
			$matches			=	null;
			if ( preg_match( '/^RAND\(\)\s(ASC|DESC)$/', $row->sortfields, $matches ) ) {
				// random sorting needs to have same seed on pages > 1 to not have probability to show same users:
				if ( $limitstart ) {
					$random		=	(int) $randomParam;
				}
				if ( ! $random ) {
					$random		=	rand( 0, 32767 );
				}
				$row->sortfields =	'RAND(' . (int) $random . ') ' . $matches[1];
			}
			$orderby			=	"\n ORDER BY " . $row->sortfields;
		}
		$filterby				=	'';
		if ( $row->filterfields != '' ) {
			$filterRules		=	utf8RawUrlDecode( substr( $row->filterfields, 1 ) );
	
			if ( $_CB_framework->myId() ) {
				$user			=	new moscomprofilerUser( $_CB_database );
				if ( $user->load( (int) $_CB_framework->myId() ) ) {
					$filterRules	=	cbReplaceVars( $filterRules, $user, array( $_CB_database, 'getEscaped' ), false, array() );
				}
			}
			$filterby			=	" AND ". $filterRules;
		}
	
		// Prepare part after SELECT .... " and before "FROM" :
	
		$tableReferences		=	array( '#__comprofiler' => 'ue', '#__users' => 'u' );
	
		// Fetch all fields:
	
		$tabs					=	$myCbUser->_getCbTabs();		//	new cbTabs( 0, 1 );		//TBD: later: this private method should not be called here, but the whole users-list should go into there and be called here.
	
		$allFields				=	$tabs->_getTabFieldsDb( null, $myUser, 'list' );
		// $_CB_database->setQuery( "SELECT * FROM #__comprofiler_fields WHERE published = 1" );
		// $allFields				=	$_CB_database->loadObjectList( 'fieldid', 'moscomprofilerFields', array( &$_CB_database ) );
	
	
		//Make columns array. This array will later be constructed from the tabs table:
	
		$columns				=	array();
	
		for ( $i = 1; $i < 50; ++$i ) {
			$enabledVar			=	"col".$i."enabled";
	
			if ( ! isset( $row->$enabledVar ) ) {
				break;
			}
			$titleVar			=	"col".$i."title";
			$fieldsVar			=	"col".$i."fields";
			$captionsVar		=	"col".$i."captions";
	
			if ( $row->$enabledVar == 1 ) {
				$col			=	new stdClass();
				$col->fields	=	( $row->$fieldsVar ? explode( '|*|', $row->$fieldsVar ) : array() );
				$col->title		=	$row->$titleVar;
				$col->titleRendered		=	$myCbUser->replaceUserVars( $col->title );
				$col->captions	=	$row->$captionsVar;
				// $col->sort	=	1; //All columns can be sorted
				$columns[$i]	=	$col;
			}
		}
	
		// build fields and tables accesses, also check for searchable fields:
	
		$searchableFields		=	array();
		$fieldsSQL				=	cbUsersList::getFieldsSQL( $columns, $allFields, $tableReferences, $searchableFields, $params );
	
		$_PLUGINS->trigger( 'onAfterUsersListFieldsSql', array( &$columns, &$allFields, &$tableReferences ) );
	
		$tablesSQL				=	array();
		$joinsSQL				=	array();
		$tablesWhereSQL			=	array(	'block'		=>	'u.block = 0',
											'approved'	=>	'ue.approved = 1',
											'confirmed'	=>	'ue.confirmed = 1'
										 );
	
		if ( checkJversion() == 2 ) {
			$joinsSQL[]				=	'JOIN #__user_usergroup_map g ON g.`user_id` = u.`id`';
		}
	
		if ( ! $isModerator ) {
			$tablesWhereSQL['banned']	=	'ue.banned = 0';
		}
		if ( $usergids ) {
			if ( checkJversion() == 2 ) {
				$tablesWhereSQL['gid']	=	'g.group_id IN (' . $usergids . ')';
			} else {
				$tablesWhereSQL['gid']	=	'u.gid IN (' . $usergids . ')';
			}
		}
	
		foreach ( $tableReferences as $table => $name ) {
			$tablesSQL[]				=	$table . ' ' . $name;
			if ( $name != 'u' ) {
				$tablesWhereSQL[]		=	"u.`id` = " . $name . ".`id`";
			}
		}
	
		// handles search criterias:
	
		$list_compare_types		=	$params->get( 'list_compare_types', 0 );
		$searchVals				=	new stdClass();
		$searchesFromFields		=	$tabs->applySearchableContents( $searchableFields, $searchVals, $searchFormValuesRAW, $list_compare_types );
		$whereFields			=	$searchesFromFields->reduceSqlFormula( $tableReferences, $joinsSQL, TRUE );
		if ( $whereFields ) {
			$tablesWhereSQL[]	=	'(' . $whereFields . ')';
	/*
			if ( $search === null ) {
				$search			=	'';
			}
	*/
		}
	
		$_PLUGINS->trigger( 'onBeforeUsersListBuildQuery', array( &$tablesSQL, &$joinsSQL, &$tablesWhereSQL ) );
	
		$queryFrom				=	"FROM " . implode( ', ', $tablesSQL )
								.	( count( $joinsSQL ) ? "\n " . implode( "\n ", $joinsSQL ) : '' )
								.	"\n WHERE " . implode( "\n AND ", $tablesWhereSQL );
	
		// handles old formatted names search:
	/*
		if ( $search != '' ) {
			$searchSQL			=	cbEscapeSQLsearch( strtolower( $_CB_database->getEscaped( $search ) ) );
			$queryFrom 			.=	" AND (";
	
			$searchFields		=	array();
			if ( $ueConfig['name_format']!='3' ) {
				$searchFields[]	=	"u.name LIKE '%%s%'";
			}
			if ( $ueConfig['name_format']!='1' ) {
				$searchFields[]	=	"u.username LIKE '%%s%'";
			}
			if ( is_array( $plugSearchFieldsArray ) ) {
				foreach ( $plugSearchFieldsArray as $v ) {
					if ( is_array( $v ) ) {
						$searchFields	=	array_merge( $searchFields, $v );
					}
				}
			}
			$queryFrom			.=	str_replace( '%s', $searchSQL, implode( " OR ", $searchFields ) );
			$queryFrom			.=	")";
		}
	*/
		$queryFrom				.=	" " . $filterby;
	
		$_PLUGINS->trigger( 'onBeforeUsersListQuery', array( &$queryFrom, 1, $listid ) );	// $uid = 1
	
		$errorMsg		=	null;
	
		// counts number of users and loads the listed fields of the users if not in search-form-only mode:
	
		if ( $searchmode == 0 ) {
			if ( checkJversion() == 2 ) {
				$_CB_database->setQuery( "SELECT COUNT(DISTINCT u.id) " . $queryFrom );
			} else {
			$_CB_database->setQuery( "SELECT COUNT(*) " . $queryFrom );
			}
			$total					=	$_CB_database->loadResult();
	
			if ( ( $limit > $total ) || ( $limitstart >= $total ) ) {
				$limitstart			=	0;
			}
	
			// $query					=	"SELECT u.id, ue.banned, '' AS 'NA' " . ( $fieldsSQL ? ", " . $fieldsSQL . " " : '' ) . $queryFrom . " " . $orderby
			if ( checkJversion() == 2 ) {
				$query				=	"SELECT DISTINCT ue.*, u.*, '' AS 'NA' " . ( $fieldsSQL ? ", " . $fieldsSQL . " " : '' ) . $queryFrom . " " . $orderby;
			} else {
				$query				=	"SELECT ue.*, u.*, '' AS 'NA' " . ( $fieldsSQL ? ", " . $fieldsSQL . " " : '' ) . $queryFrom . " " . $orderby;
			}
			$_CB_database->setQuery( $query, (int) $limitstart, (int) $limit );
			$users				=	$_CB_database->loadObjectList( null, 'moscomprofilerUser', array( &$_CB_database ) );
	
			if ( ! $_CB_database->getErrorNum() ) {
				// creates the CBUsers in cache corresponding to the $users:
				foreach ( array_keys( $users ) as $k) {
					CBuser::setUserGetCBUserInstance( $users[$k] );
				}
			} else {
				$users			=	array();
				$errorMsg		=	_UE_ERROR_IN_QUERY_TURN_SITE_DEBUG_ON_TO_VIEW;
			}
	
			if ( count( get_object_vars( $searchVals ) ) > 0 ) {
				$search			=	'';
			} else {
				$search			=	null;
			}
	
		} else {
			$total				=	null;
			$users				=	array();
			if ( $search === null ) {
				$search			=	'';
			}
		}
	
		// Compute itemId of users in users-list:
	
		if ( $Itemid ) {
			$option_itemid		=	(int) $Itemid;
		} else {
			$option_itemid		=	getCBprofileItemid( 0 );
		}
		HTML_comprofiler::usersList( $row, $users, $columns, $allFields, $lists, $listid, $search, $searchmode, $option_itemid, $limitstart, $limit, $total, $myUser, $searchableFields, $searchVals, $tabs, $list_compare_types, $showPaging, $hotlink_protection, $errorMsg, $random );
	}
示例#25
0
 /**
  * returns plugins xml version
  *
  * @param  null|PluginTable|int  $plugin    The plugin id or object to check version for
  * @param  bool                  $raw       1/True: version only (no farm), 0/False: Formatted version (green/red/shortened), 2: array of version information ( $version, $latestVersion, $isLatest, $latestURL )
  * @param  int                   $duration  The duration to cache the plugin version xml file (null/0 for no limit)
  * @param  int                   $length    The maximum version length to display (null/0 for no limit)
  * @return null|string
  */
 public function getPluginVersion($plugin, $raw = false, $duration = 24, $length = 0)
 {
     global $_CB_framework, $ueConfig;
     cbimport('cb.snoopy');
     static $plgVersions = null;
     if ($plgVersions === null) {
         $cacheFile = $_CB_framework->getCfg('absolute_path') . '/cache/cbpluginsversions.xml';
         $plgVersionsXML = null;
         if (file_exists($cacheFile)) {
             if (!$duration || intval(($_CB_framework->now() - filemtime($cacheFile)) / 3600) > $duration) {
                 $request = true;
             } else {
                 $plgVersionsXML = new SimpleXMLElement(trim(file_get_contents($cacheFile)));
                 $request = false;
             }
         } else {
             $request = true;
         }
         if ($request) {
             $s = new CBSnoopy();
             $s->read_timeout = 30;
             $s->referer = $_CB_framework->getCfg('live_site');
             @$s->fetch('http://update.joomlapolis.net/cbpluginsversions20.xml');
             if ((int) $s->status == 200) {
                 try {
                     $plgVersionsXML = new SimpleXMLElement($s->results);
                     $plgVersionsXML->saveXML($cacheFile);
                 } catch (Exception $e) {
                 }
             }
         }
         if ($plgVersionsXML) {
             $plgVersions = $plgVersionsXML->getElementByPath('cb_plugins/' . (checkJversion() >= 2 ? 'j30' : 'j15'));
         } else {
             $plgVersions = false;
         }
     }
     $plugin = $this->getCachedPluginObject($plugin);
     if (!$plugin) {
         return $raw === 2 ? array(null, null, null, null) : null;
     }
     static $cache = array();
     $pluginId = (int) $plugin->id;
     if (!isset($cache[$pluginId][$raw])) {
         $xmlFile = $this->getPluginXmlPath($plugin);
         $version = null;
         $latestVersion = null;
         $isLatest = null;
         $latestURL = null;
         if (file_exists($xmlFile)) {
             try {
                 $xml = new SimpleXMLElement(trim(file_get_contents($xmlFile)));
             } catch (\Exception $e) {
                 $xml = null;
                 echo "{$xmlFile} not an XML file!!!";
             }
             if ($xml !== null) {
                 $ver = null;
                 if (isset($xml->release)) {
                     // New release XML variable used by incubator projects:
                     $ver = $xml->release;
                 } elseif (isset($xml->cbsubsversion)) {
                     // CBSubs plugin versions are same as the CBSubs version; lets grab them:
                     $cbsubsVer = $xml->cbsubsversion->attributes();
                     if (isset($cbsubsVer['version'])) {
                         $ver = $cbsubsVer['version'];
                     }
                 } elseif (isset($xml->description)) {
                     // Attempt to parse plugin description for a version using logical naming:
                     if (preg_match('/(?:plugin|field|fieldtype|ver|version|' . preg_quote($plugin->name) . ') ((?:[0-9]+(?:\\.)?(?:(?: )?RC)?(?:(?: )?B)?(?:(?: )?BETA)?)+)/i', $xml->description, $matches)) {
                         $ver = $matches[1];
                     }
                 }
                 // Check if version was found; if it was lets clean it up:
                 if ($ver) {
                     if (preg_match('/^\\d+(\\.\\d+)+(-[a-z]+\\.\\d+)?(\\+\\w)?$/', $ver)) {
                         $version = $ver;
                     } else {
                         $version = preg_replace('/\\.*([a-zA-Z]+)\\.*/i', '.$1.', preg_replace('/^[a-zA-Z]+/i', '', str_replace(array('-', '_', '+'), '.', str_replace(' ', '', strtoupper($ver)))));
                     }
                     if (is_integer($version)) {
                         $version = implode('.', str_split($version));
                     } elseif (preg_match('/^(\\d{2,})(\\.[a-zA-Z].+)/i', $version, $matches)) {
                         $version = implode('.', str_split($matches[1])) . $matches[2];
                     }
                     $version = trim(str_replace('..', '.', $version), '.');
                     // Encase the version is too long lets cut it short for readability and display full version as mouseover title:
                     if ($version && $length && cbIsoUtf_strlen($version) > $length) {
                         $versionName = rtrim(trim(cbIsoUtf_substr($version, 0, $length)), '.') . '&hellip;';
                         $versionShort = true;
                     } else {
                         $versionName = $version;
                         $versionShort = false;
                     }
                     // Lets try and parse out latest version and latest url from versions xml data:
                     if ($plgVersions) {
                         foreach ($plgVersions as $plgVersion) {
                             $plgName = (string) $plgVersion->name;
                             $plgFile = (string) $plgVersion->file;
                             if ($plgName == $plugin->name || strpos($plgName, $plugin->name) !== false || strpos($plgFile, $plugin->folder) !== false) {
                                 $latestVersion = (string) $plgVersion->version;
                                 $latestURL = (string) $plgVersion->url;
                             }
                         }
                     }
                     if ($latestVersion) {
                         if (version_compare($version, $latestVersion) >= 0) {
                             $isLatest = true;
                         } else {
                             $isLatest = false;
                         }
                     }
                     // Format version display:
                     if (!$raw) {
                         if ($latestVersion) {
                             if ($isLatest) {
                                 $version = '<span class="text-success"' . ($versionShort ? ' title="' . htmlspecialchars($version) . '"' : null) . '><strong>' . $versionName . '</strong></span>';
                             } else {
                                 $version = '<span class="text-danger" title="' . htmlspecialchars($latestVersion) . '"><strong>' . $versionName . '</strong></span>';
                                 if ($latestURL) {
                                     $version = '<a href="' . htmlspecialchars($latestURL) . '" target="_blank">' . $version . '</a>';
                                 }
                             }
                         } else {
                             if ($versionShort) {
                                 $version = '<span title="' . htmlspecialchars($version) . '">' . $versionName . '</span>';
                             } else {
                                 $version = $versionName;
                             }
                         }
                     }
                 }
             }
         }
         if (!$version && !$raw) {
             if ($plugin->iscore) {
                 // core plugins are same version as CB it self:
                 if ($length && cbIsoUtf_strlen($ueConfig['version']) > $length) {
                     $version = '<span title="' . htmlspecialchars($ueConfig['version']) . '">' . rtrim(trim(cbIsoUtf_substr($ueConfig['version'], 0, $length)), '.') . '&hellip;</span>';
                 } else {
                     $version = $ueConfig['version'];
                 }
             } else {
                 $version = '-';
             }
         }
         if ($raw === 2) {
             $version = array($version, $latestVersion, $isLatest, $latestURL);
         }
         $cache[$pluginId][$raw] = $version;
     }
     return $cache[$pluginId][$raw];
 }
	/**
	* Writes a list of the defined modules
	* @param array An array of category objects
	*/
	static function showPlugins( &$rows, &$pageNav, $option, &$lists, $search ) {
		global $_CB_framework, $_PLUGINS;

		HTML_comprofiler::secureAboveForm('showPlugins');

		outputCbTemplate( 2 );
		outputCbJs( 2 );
	    initToolTip( 2 );

		global $_CB_Backend_Title;
		$_CB_Backend_Title	=	array( 0 => array( 'cbicon-48-plugins', htmlspecialchars( CBTxt::T('CB Plugin Manager') )
											 . ' <small><small> &nbsp;&nbsp;&nbsp;&nbsp; <a href="#getplugins">' . htmlspecialchars( CBTxt::T('Get Plugins') ) . '</a></small></small>'
											 . ' &nbsp;&nbsp;&nbsp;'
											 . ' <small><small> &nbsp;&nbsp;&nbsp;&nbsp; <a href="#install">' . htmlspecialchars( CBTxt::T('Install Plugin') ) . '</a></small></small>' ) );
											 
		HTML_comprofiler::_saveOrderJs( 'savepluginorder' );
		ob_start();
	?>
		function submitbutton3(pressbutton) {
			var form = document.adminForm_dir;

			// do field validation
			if (form.userfile.value == ""){
				alert('<?php echo addslashes( CBTxt::T('Please select a directory') ); ?>');
			} else {
				form.submit();
			}
		}
<?php
		$js			=	ob_get_contents();
		ob_end_clean();
		$_CB_framework->document->addHeadScriptDeclaration( $js );
?>
		<form action="<?php echo $_CB_framework->backendUrl( 'index.php' ); ?>" method="post" name="adminForm">

		<table class="adminheading" style="width:100%">
		<tr>
			<td style="width:80%">
			<?php echo htmlspecialchars( CBTxt::T('Filter') ); ?>: <input type="text" name="search" value="<?php echo htmlspecialchars( $search );?>" class="text_area" onChange="document.adminForm.submit();" />
			</td>
			<td align="right">
			<?php echo $lists['type'];?>
			</td>
		</tr>
		</table>

		<table class="adminlist">
		<thead>
		  <tr>
			<th width="20"><?php echo htmlspecialchars( CBTxt::T('#') ); ?></th>
			<th width="20">
			<input type="checkbox" name="toggle" value="" <?php echo 'onclick="checkAll(' . count( $rows ) . ');"';?> />
			</th>
			<th class="title">
			<?php echo htmlspecialchars( CBTxt::T('Plugin Name') ); ?>
			</th>
			<th nowrap="nowrap" width="5%">
	  		<?php echo htmlspecialchars( CBTxt::T('Installed') ); ?>
			</th>
			<th nowrap="nowrap" width="5%">
	  		<?php echo htmlspecialchars( CBTxt::T('Published') ); ?>
			</th>
			<th colspan="2" nowrap="nowrap" width="5%">
			<?php echo htmlspecialchars( CBTxt::T('Reorder') ); ?>
			</th>
			<th width="2%">
			<?php echo htmlspecialchars( CBTxt::T('Order') ); ?>
			</th>
			<th width="4%">
			<a href="javascript: cbsaveorder( <?php echo count( $rows )-1; ?> )"><img src="../components/com_comprofiler/plugin/templates/luna/images/mini-icons/icon-16-filesave.png" border="0" width="16" height="16" alt="<?php echo htmlspecialchars( CBTxt::T('Save Order') ); ?>" /></a>
			</th>
			<th nowrap="nowrap" align="left" width="10%">
			<?php echo htmlspecialchars( CBTxt::T('Access') ); ?>
			</th>
			<th nowrap="nowrap" align="left" width="10%">
			<?php echo htmlspecialchars( CBTxt::T('Type') ); ?>
			</th>
			<th nowrap="nowrap" align="left" width="10%">
			<?php echo htmlspecialchars( CBTxt::T('Directory') ); ?>
			</th>
		  </tr>
		</thead>
		<tbody>
		<?php
		$k = 0;
		for ($i=0, $n=count( $rows ); $i < $n; $i++) {
			$row 	= &$rows[$i];

			$xmlfile			=	$_PLUGINS->getPluginXmlPath( $row );
			$filesInstalled		=	file_exists($xmlfile);

			$link = $_CB_framework->backendUrl( "index.php?option=com_comprofiler&task=editPlugin&cid=$row->id" );

			//Access
			if ( !$row->access ) {
				$color_access = 'style="color: green;"';
				$task_access = 'accessregistered';
			} else if ( $row->access == 1 ) {
				$color_access = 'style="color: red;"';
				$task_access = 'accessspecial';
			} else {
				$color_access = 'style="color: black;"';
				$task_access = 'accesspublic';
			}

			$access = '	<a href="javascript: void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task_access .'\')" '. $color_access .'>
			'. $row->groupname .'
			</a>';

			//Checked Out
			if ( $filesInstalled && $row->checked_out ) {
				$hover = '';
				$date 				= cbFormatDate( $row->checked_out_time );
				$checked_out_text 	= '<table>';
				$checked_out_text 	.= '<tr><td>'. addslashes($row->editor) .'</td></tr>';
				$checked_out_text 	.= '<tr><td>'. $date .'</td></tr>';
				$checked_out_text 	.= '</table>';
				$hover = 'onMouseOver="return overlib(\''. htmlspecialchars( $checked_out_text ) .'\', CAPTION, \'Checked Out\', BELOW, RIGHT);" onMouseOut="return nd();"';

				if ( checkJversion() == 2 ) {
					$checked_img	 = 'templates/hathor/images/admin/checked_out.png';
				} else {
					$checked_img	 = 'images/checked_out.png';
				}

				$checked	 		= '<img src="'. $checked_img .'" '. $hover .'/>';
			} else {
				$checked = '<input type="checkbox" id="cb'.$i.'" name="cid[]" value="'.$row->id.'" onclick="isChecked(this.checked);" />';
			}

			$imgpath='../components/com_comprofiler/images/';
			//Installedg
			$instImg 	= $filesInstalled ? 'tick.png' : 'publish_x.png';
			$instAlt 	= htmlspecialchars( $filesInstalled ? CBTxt::T('Installed') : CBTxt::T('Plugin Files missing') );
			$installed  = '<img src="' . $imgpath . $instImg .'" border="0" alt="'. $instAlt .'"  title="'. $instAlt .'" />';

			//Published
			$img 	= $row->published ? 'publish_g.png' : 'publish_x.png';
			$task 	= $row->published ? 'unpublishPlugin' : 'publishPlugin';
			$alt 	= $row->published ? CBTxt::T('Published') : CBTxt::T('Unpublished');
			$action	= $row->published ? CBTxt::T('Unpublish Item') : CBTxt::T('Publish item');
			if ( ( $row->type == "language" ) && $row->published ) {
				$published = '<img src="' . $imgpath . 'publish_g.png" border="0" alt="' . htmlspecialchars( CBTxt::T('Published') ) . '" title="' . htmlspecialchars( CBTxt::T('language plugins cannot be unpublished, only uninstalled') ) . '" />';
			} elseif ( ( $row->id == 1 ) && $row->published ) {
				$published = '<img src="' . $imgpath . 'publish_g.png" border="0" alt="' . htmlspecialchars( CBTxt::T('Published') ) . '" title="' . htmlspecialchars( CBTxt::T('CB core plugin cannot be unpublished') ) . '" />';
			} else {
				$published = '<a href="javascript: void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task .'\')" title="'. htmlspecialchars( $action ) .'">
			<img src="'. $imgpath . $img .'" border="0" alt="'. htmlspecialchars( $alt ) .'" />
			</a>';
			}

			//Backend plugin menu:
			$backendPluginMenus = array();
			if ( isset( $row->backend_menu ) && $row->backend_menu ) {
				$backend = explode( ",", $row->backend_menu );
				foreach ( $backend as $backendAction ) {
					$backendActionParts = explode( ":", $backendAction );
					$backendActionLink = $_CB_framework->backendUrl( "index.php?option=com_comprofiler&task=pluginmenu&pluginid=$row->id&menu=$backendActionParts[1]" );
					$backendPluginMenus[] = '&nbsp; [<a href="' . $backendActionLink . '">' . $backendActionParts[0] . '</a>] ';
				}
			}

			?>
			<tr class="<?php echo "row$k"; ?>">
				<td align="right"><?php echo $i + 1 + $pageNav->limitstart ?></td>
				<td>
				<?php echo $checked; ?>
				</td>
				<td>
				<?php
				if ( ($row->checked_out && ( $row->checked_out != $_CB_framework->myId() )) || !$filesInstalled ) {
					if ( ! $filesInstalled ) {
						echo '<span title="' . $instAlt , '">';
					}
					echo $row->name;
					if ( ! $filesInstalled ) {
						echo "</span>";
					}
				} else {
					?>
					<a href="<?php echo $link; ?>">
					<?php echo htmlspecialchars( $row->name ); ?>
					</a>
					<?php
					echo implode( '', $backendPluginMenus );
				}
				?>
				</td>
				<td align="center">
				<?php echo $installed;?>
				</td>
				<td align="center">
				<?php echo $published;?>
				</td>
				<td>
				<?php    if (($i > 0 || ($i+$pageNav->limitstart > 0)) && $row->type == @$rows[$i-1]->type) { ?>
			         <a href="#reorder" onClick="return listItemTask('cb<?php echo $i;?>','orderupPlugin')">
			            <img src="../components/com_comprofiler/plugin/templates/luna/images/mini-icons/icon-12-uparrow.png" width="12" height="12" border="0" alt="<?php echo htmlspecialchars( CBTxt::T('Move Up') ); ?>" />
			         </a>
				<?php    } ?>
			      </td>
			      <td>
				<?php    if (($i < $n-1 || $i+$pageNav->limitstart < $pageNav->total-1) && $row->type == @$rows[$i+1]->type) { ?>
			         <a href="#reorder" onClick="return listItemTask('cb<?php echo $i;?>','orderdownPlugin')">
			            <img src="../components/com_comprofiler/plugin/templates/luna/images/mini-icons/icon-12-downarrow.png" width="12" height="12" border="0" alt="<?php echo htmlspecialchars( CBTxt::T('Move Down') ); ?>" />
			         </a>
				<?php    } ?>
				</td>
				<td align="center" colspan="2">
				<input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" class="text_area" style="text-align: center" />
				</td>
				<td align="left">
				<?php echo $access;?>
				</td>
				<td align="left" nowrap="nowrap">
				<?php echo $row->type;?>
				</td>
				<td align="left" nowrap="nowrap">
				<?php
			if ( ! $filesInstalled ) {
				echo '<span style="text-decoration:line-through" title="' . $instAlt , '">';
			}
			echo $row->element;
			if ( ! $filesInstalled ) {
				echo "</span>";
			}
				?>
				</td>
			</tr>
			<?php
			$k = 1 - $k;
		}
		?>
	</tbody>
	<tfoot>
     <tr>
      <th align="center" colspan="12"> <?php echo $pageNav->getListFooter(); ?></th>
     </tr>
    </tfoot>
  </table>
		<input type="hidden" name="option" value="<?php echo $option;?>" />
		<input type="hidden" name="task" value="showPlugins" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="hidemainmenu" value="0" />
		<?php
	echo cbGetSpoofInputTag( 'plugin' );
		?>
</form>


	<div style="clear:both; margin:20px 0px;">
		<table class="adminheading">
		<tr>
			<th class="install">
				<a name="getplugins"><?php echo htmlspecialchars( CBTxt::T('Get Plugins') ); ?></a>
			</th>
		</tr>
		<tr>
			<td align="left" style="padding-bottom:10px;">
				<a href="http://www.joomlapolis.com/cb-solutions" target="_blank"><?php echo htmlspecialchars( CBTxt::T('Click here to see more CB Plugins (Languages, Fields, Tabs, Signup-Connect, Paid Memberships and over 30 more) by CB Team at joomlapolis.com') ); ?></a>
			</td>
		</tr>
		<tr>
			<td align="left" style="padding-bottom:10px;">
				<a href="http://www.joomlapolis.com/cb-solutions/directory" target="_blank"><?php echo htmlspecialchars( CBTxt::T('Click here to see CB Directory listing hundreds of CB extensions at joomlapolis.com') ); ?></a>
			</td>
		</tr>
		<tr>
			<td align="left" style="padding-bottom:10px;">
				<a href="http://extensions.joomla.org/extensions/clients-a-communities/communities/210" target="_blank"><?php echo htmlspecialchars( CBTxt::T('Click here to Check our CB listing on JED and find more third-party free add-ons for your website') ); ?></a>
			</td>
		</tr>
		</table>
	</div>



	<div style="clear:both;">
		<table class="adminheading">
		<tr>
			<th class="install">
			<a name="install"><?php echo htmlspecialchars( CBTxt::T('Install New Plugin') ); ?></a>
			</th>
		</tr>
		</table>

		<form enctype="multipart/form-data" action="<?php echo $_CB_framework->backendUrl( 'index.php' ); ?>" method="post" name="filename">
		<table class="adminform">
		<tr>
			<th>
			<?php echo htmlspecialchars( CBTxt::T('Upload Package File') ); ?>
			</th>
		</tr>
		<tr>
			<td align="left">
			<?php echo htmlspecialchars( CBTxt::T('Package File:') ); ?>
			<input class="text_area" name="userfile" type="file" size="70"/>
			<input class="button" type="submit" value="<?php echo htmlspecialchars( CBTxt::T('Upload File & Install') ); ?>" />
			<?php echo CBTxt::P( 'Maximum upload size: <strong>[filesize]</strong> <em>(upload_max_filesize setting in file [php.ini] )</em>',
							 array( '[filesize]' => ini_get( 'upload_max_filesize' ),
							 		'[php.ini]' => ( is_callable( 'php_ini_loaded_file' ) && php_ini_loaded_file() ? htmlspecialchars( php_ini_loaded_file() ) : 'php.ini' ) ) ); ?>
			</td>
		</tr>
		</table>

		<input type="hidden" name="task" value="installPluginUpload"/>
		<input type="hidden" name="option" value="com_comprofiler"/>
		<input type="hidden" name="client" value=""/>
		<?php
	echo cbGetSpoofInputTag( 'plugin' );
		?>
		</form>
		<br />

		<form enctype="multipart/form-data" action="<?php echo $_CB_framework->backendUrl( 'index.php' ); ?>" method="post" name="adminForm_dir">
		<table class="adminform">
		<tr>
			<th>
			<?php echo htmlspecialchars( CBTxt::T('Install from directory') ); ?>
			</th>
		</tr>
		<tr>
			<td align="left">
			<?php echo htmlspecialchars( CBTxt::T('Install directory') ); ?>:&nbsp;
			<input type="text" name="userfile" class="text_area" size="65" value=""/>&nbsp;
			<input type="button" class="button" value="<?php echo htmlspecialchars( CBTxt::T('Install') ); ?>" onclick="submitbutton3()" />
			</td>
		</tr>
		</table>

		<input type="hidden" name="task" value="installPluginDir" />
		<input type="hidden" name="option" value="com_comprofiler"/>
		<input type="hidden" name="client" value=""/>
		<?php
	echo cbGetSpoofInputTag( 'plugin' );
		?>
		</form>
		<br />

		<form enctype="multipart/form-data" action="<?php echo $_CB_framework->backendUrl( 'index.php' ); ?>" method="post" name="adminForm_URL">
		<table class="adminform">
		<tr>
			<th>
			<?php echo htmlspecialchars( CBTxt::T('Install package from web (http/https)') ); ?>
			</th>
		</tr>
		<tr>
			<td align="left">
			<?php echo htmlspecialchars( CBTxt::T('Installation package URL') ); ?>:&nbsp;
			<input type="text" name="userfile" class="text_area" size="65" value=""/>&nbsp;
			<input class="button" type="submit" value="<?php echo htmlspecialchars( CBTxt::T('Download Package & Install') ); ?>" />
			</td>
		</tr>
		</table>

		<input type="hidden" name="task" value="installPluginURL" />
		<input type="hidden" name="option" value="com_comprofiler"/>
		<input type="hidden" name="client" value=""/>
		<?php
	echo cbGetSpoofInputTag( 'plugin' );
		?>
		</form>
		<br />
		<table class="content">
		<?php
	if (!is_callable(array("JFile","write")) || ($_CB_framework->getCfg('ftp_enable') != 1)) {
			writableCell( 'components/com_comprofiler/plugin/user' );
			// writableCell( 'components/com_comprofiler/plugin/fieldtypes' );
			writableCell( 'components/com_comprofiler/plugin/templates' );
			writableCell( 'components/com_comprofiler/plugin/language' );
	}
		writableCell( 'media' );

		?>
		</table>
	</div>
		<?php
	}
function com_install()
{
    global $_CB_framework, $_CB_database, $_CB_adminpath, $ueConfig, $mainframe;
    // Ensure PHP version is adaquete for CB:
    if (version_compare(phpversion(), '5.0.0', '<')) {
        echo '<div class="cbError error" style="font-size:120%;color:red;font-weight:bold;margin-bottom:20px;">' . htmlspecialchars(sprintf("As stated in README and prerequisites list, PHP Version %s, which is obsolete since 2008-08-08 and insecure, is not compatible with %s: Please upgrade to PHP %s or greater (CB is also compatible with PHP 5.3.x) as soon as possible.", phpversion(), 'Community Builder', sprintf("at least version %s, recommended version %s", '5.0.0', '5.2.6'))) . '</div>';
        echo '<div class="cbError error" style="font-size:140%;color:red;font-weight:bold;">' . htmlspecialchars(sprintf('Installation failed. In all cases, please require your hoster to upgrade your PHP version as soon as possible.')) . '</div>';
        return;
    }
    // Determine path to CBs backend file structure:
    if (defined('JPATH_ADMINISTRATOR')) {
        $_CB_adminpath = JPATH_ADMINISTRATOR . '/components/com_comprofiler/';
    } else {
        $_CB_adminpath = $mainframe->getCfg('absolute_path') . '/administrator/components/com_comprofiler/';
    }
    // CB Configuration missing; try to copy default:
    if (!file_exists($_CB_adminpath . 'ue_config.php')) {
        include_once $_CB_adminpath . 'library/cb/cb.adminfilesystem.php';
        $adminFS =& cbAdminFileSystem::getInstance();
        if (!$adminFS->copy($_CB_adminpath . 'ue_config_first.php', $_CB_adminpath . 'ue_config.php')) {
            echo sprintf('Error copying initial configuration file in place from %s to %s', $_CB_adminpath . 'ue_config_first.php', $_CB_adminpath . 'ue_config.php') . "<br /><br />\n";
            return;
        }
    }
    include_once $_CB_adminpath . 'plugin.foundation.php';
    // Set location to backend:
    $_CB_framework->cbset('_ui', 2);
    if ($_CB_framework->getCfg('debug')) {
        ini_set('display_errors', true);
        error_reporting(E_ALL);
    }
    // Load in CB API:
    cbimport('cb.tabs');
    cbimport('cb.adminfilesystem');
    cbimport('cb.xml.simplexml');
    cbimport('cb.dbchecker');
    // Define CB backend filesystem API:
    $adminFS =& cbAdminFileSystem::getInstance();
    // If J1.6 or greater ensure XML and backend root component file is present:
    if (checkJversion() >= 2) {
        if (!$adminFS->copy($_CB_adminpath . 'comprofileg.xml', $_CB_adminpath . 'comprofiler.xml')) {
            echo sprintf('Error copying initial xml file in place from %s to %s', $_CB_adminpath . 'comprofileg.xml', $_CB_adminpath . 'comprofiler.xml') . "<br /><br />\n";
            return false;
        }
        if (!$adminFS->copy($_CB_adminpath . 'admin.comprofiler.php', $_CB_adminpath . 'comprofiler.php')) {
            echo sprintf('Error copying admin file in place from %s to %s', $_CB_adminpath . 'admin.comprofiler.php', $_CB_adminpath . 'comprofiler.php') . "<br /><br />\n";
            return false;
        }
    }
    $return = '<div style="text-align:left;margin-bottom:10px;">' . '<table width="100%" border="0">' . '<tr>' . '<td>' . '<img alt="CB Logo" src="../components/com_comprofiler/images/smcblogo.gif" />' . '</td>' . '</tr>' . '<tr>' . '<td>' . '<br />Copyright 2004-2012 MamboJoe/JoomlaJoe, Beat and CB team on joomlapolis.com . This component is released under the GNU/GPL version 2 License. All copyright statements must be kept. Derivate work must prominently duly acknowledge original work and include visible online links. Official site: <a href="http://www.joomlapolis.com">www.joomlapolis.com</a><br />' . '</td>' . '</tr>' . '<tr>' . '<td style="background-color:#F0F0F0;" colspan="2">' . '<code>' . 'Installation Process:<br />';
    // Fix admin menu links:
    if (checkJversion() >= 2) {
        $query = 'SELECT ' . $_CB_database->NameQuote('extension_id') . "\n FROM " . $_CB_database->NameQuote('#__extensions') . "\n WHERE " . $_CB_database->NameQuote('type') . " = " . $_CB_database->Quote('component') . "\n AND " . $_CB_database->NameQuote('element') . " = " . $_CB_database->Quote('com_comprofiler') . "\n ORDER BY " . $_CB_database->NameQuote('extension_id') . " DESC";
        $_CB_database->setQuery($query, 0, 1);
        $componentId = $_CB_database->loadResult();
        if ($componentId) {
            $query = 'UPDATE ' . $_CB_database->NameQuote('#__menu') . "\n SET " . $_CB_database->NameQuote('component_id') . " = " . (int) $componentId . "\n WHERE " . $_CB_database->NameQuote('type') . " = " . $_CB_database->Quote('component') . "\n AND " . $_CB_database->NameQuote('link') . " LIKE " . $_CB_database->Quote('%option=com_comprofiler%');
            $_CB_database->setQuery($query);
            $_CB_database->query();
        }
    } elseif (checkJversion() <= 1) {
        $iconResults = array();
        // Userlist Management icon:
        if (checkJversion() >= 1) {
            $icon = 'js/ThemeOffice/static.png';
        } else {
            $icon = 'js/ThemeOffice/content.png';
        }
        $query = 'UPDATE ' . $_CB_database->NameQuote('#__components') . "\n SET " . $_CB_database->NameQuote('admin_menu_img') . " = " . $_CB_database->Quote($icon) . "\n WHERE " . $_CB_database->NameQuote('admin_menu_link') . " = " . $_CB_database->Quote('option=com_comprofiler&task=showLists');
        $_CB_database->setQuery($query);
        $iconResults[0] = $_CB_database->query();
        // Field Management icon:
        $query = 'UPDATE ' . $_CB_database->NameQuote('#__components') . "\n SET " . $_CB_database->NameQuote('admin_menu_img') . " = " . $_CB_database->Quote('js/ThemeOffice/content.png') . "\n WHERE " . $_CB_database->NameQuote('admin_menu_link') . " = " . $_CB_database->Quote('option=com_comprofiler&task=showField');
        $_CB_database->setQuery($query);
        $iconResults[1] = $_CB_database->query();
        // Tab Management iocn:
        if (checkJversion() >= 1) {
            $icon = 'js/ThemeOffice/article.png';
        } else {
            $icon = 'js/ThemeOffice/content.png';
        }
        $query = 'UPDATE ' . $_CB_database->NameQuote('#__components') . "\n SET " . $_CB_database->NameQuote('admin_menu_img') . " = " . $_CB_database->Quote($icon) . "\n WHERE " . $_CB_database->NameQuote('admin_menu_link') . " = " . $_CB_database->Quote('option=com_comprofiler&task=showTab');
        $_CB_database->setQuery($query);
        $iconResults[2] = $_CB_database->query();
        // Configuration icon:
        $query = 'UPDATE ' . $_CB_database->NameQuote('#__components') . "\n SET " . $_CB_database->NameQuote('admin_menu_img') . " = " . $_CB_database->Quote('js/ThemeOffice/config.png') . "\n WHERE " . $_CB_database->NameQuote('admin_menu_link') . " = " . $_CB_database->Quote('option=com_comprofiler&task=showconfig');
        $_CB_database->setQuery($query);
        $iconResults[3] = $_CB_database->query();
        // User Management icon:
        if (checkJversion() >= 1) {
            $icon = 'js/ThemeOffice/user.png';
        } else {
            $icon = 'js/ThemeOffice/users.png';
        }
        $query = 'UPDATE ' . $_CB_database->NameQuote('#__components') . "\n SET " . $_CB_database->NameQuote('admin_menu_img') . " = " . $_CB_database->Quote($icon) . "\n WHERE " . $_CB_database->NameQuote('admin_menu_link') . " = " . $_CB_database->Quote('option=com_comprofiler&task=showusers');
        $_CB_database->setQuery($query);
        $iconResults[4] = $_CB_database->query();
        // Plugin Management icon:
        if (checkJversion() >= 1) {
            $icon = 'js/ThemeOffice/plugin.png';
        } else {
            $icon = 'js/ThemeOffice/install.png';
        }
        $query = 'UPDATE ' . $_CB_database->NameQuote('#__components') . "\n SET " . $_CB_database->NameQuote('admin_menu_img') . " = " . $_CB_database->Quote($icon) . "\n WHERE " . $_CB_database->NameQuote('admin_menu_link') . " = " . $_CB_database->Quote('option=com_comprofiler&task=showPlugins');
        $_CB_database->setQuery($query);
        $iconResults[5] = $_CB_database->query();
        // Community Builder icon:
        $query = 'UPDATE ' . $_CB_database->NameQuote('#__components') . "\n SET " . $_CB_database->NameQuote('admin_menu_img') . " = " . $_CB_database->Quote('../components/com_comprofiler/plugin/templates/luna/images/header/icon-16-cb.png') . "\n WHERE " . $_CB_database->NameQuote('admin_menu_link') . " = " . $_CB_database->Quote('option=com_comprofiler');
        $_CB_database->setQuery($query);
        $iconResults[6] = $_CB_database->query();
        foreach ($iconResults as $i => $iconResult) {
            if (!$iconResult) {
                $return .= '<span style="color:red;">ERROR:</span> Image of administration menu entry $i could not be corrected.<br />';
            }
        }
        // Delete invalid components:
        $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote('#__components') . "\n WHERE " . $_CB_database->NameQuote('link') . " = " . $_CB_database->Quote('option=com_comprofiler');
        $_CB_database->setQuery($query);
        $components = $_CB_database->loadResult();
        if ($components >= 1) {
            $query = 'SELECT ' . $_CB_database->NameQuote('id') . "\n FROM " . $_CB_database->NameQuote('#__components') . "\n WHERE " . $_CB_database->NameQuote('link') . " = " . $_CB_database->Quote('option=com_comprofiler') . "\n ORDER BY " . $_CB_database->NameQuote('id') . " DESC";
            $_CB_database->setQuery($query, 0, 1);
            $componentId = $_CB_database->loadResult();
            if ($componentId) {
                $query = 'DELETE ' . "\n FROM " . $_CB_database->NameQuote('#__components') . "\n WHERE " . $_CB_database->NameQuote('link') . " = " . $_CB_database->Quote('option=com_comprofiler') . "\n AND " . $_CB_database->NameQuote('id') . " != " . (int) $componentId;
                $_CB_database->setQuery($query);
                $_CB_database->query();
                $query = 'DELETE ' . "\n FROM " . $_CB_database->NameQuote('#__components') . "\n WHERE " . $_CB_database->NameQuote('option') . " = " . $_CB_database->Quote('com_comprofiler') . "\n AND " . $_CB_database->NameQuote('id') . " != " . (int) $componentId . "\n AND " . $_CB_database->NameQuote('parent') . " != " . (int) $componentId;
                $_CB_database->setQuery($query);
                $_CB_database->query();
                $query = 'UPDATE ' . $_CB_database->NameQuote('#__menu') . "\n SET " . $_CB_database->NameQuote('componentid') . " = " . (int) $componentId . "\n WHERE " . $_CB_database->NameQuote('type') . " = " . $_CB_database->Quote('component') . "\n AND " . $_CB_database->NameQuote('link') . " LIKE " . $_CB_database->Quote('%option=com_comprofiler%');
                $_CB_database->setQuery($query);
                $_CB_database->query();
            }
            $return .= '<span style="color:green;">Administrator and frontend menus corrected.</span><br />';
        }
    }
    $dbUpgrades = array();
    // Beta 3 upgrades:
    $dbUpgrades[0]['test'] = array('default', '#__comprofiler_lists');
    $dbUpgrades[0]['updates'][0] = "ALTER TABLE `#__comprofiler_lists`" . "\n ADD `default` TINYINT( 1 ) DEFAULT '0' NOT NULL," . "\n ADD `usergroupids` VARCHAR( 255 )," . "\n ADD `sortfields` VARCHAR( 255 )," . "\n ADD `ordering` INT( 11 ) DEFAULT '0' NOT NULL AFTER `published`";
    $dbUpgrades[0]['updates'][1] = "UPDATE #__comprofiler_lists SET `default`=1 WHERE published =1";
    $dbUpgrades[0]['updates'][2] = "UPDATE #__comprofiler_lists SET usergroupids = '29, 18, 19, 20, 21, 30, 23, 24, 25', sortfields = '`username` ASC'";
    $dbUpgrades[0]['updates'][3] = "ALTER TABLE `#__comprofiler` ADD `acceptedterms` TINYINT( 1 ) DEFAULT '0' NOT NULL AFTER `bannedreason`";
    $dbUpgrades[0]['message'] = "1.0 Beta 2 to 1.0 Beta 3";
    // Beta 4 upgrades:
    $dbUpgrades[1]['test'] = array('firstname', '#__comprofiler');
    $dbUpgrades[1]['updates'][0] = "ALTER TABLE #__comprofiler ADD `firstname` VARCHAR( 100 ) AFTER `user_id` ," . "\n ADD `middlename` VARCHAR( 100 ) AFTER `firstname` ," . "\n ADD `lastname` VARCHAR( 100 ) AFTER `middlename` ";
    $dbUpgrades[1]['updates'][1] = "ALTER TABLE `#__comprofiler_fields` ADD `readonly` TINYINT( 1 ) DEFAULT '0' NOT NULL AFTER `profile`";
    $dbUpgrades[1]['updates'][3] = "ALTER TABLE `#__comprofiler_tabs` ADD `width` VARCHAR( 10 ) DEFAULT '.5' NOT NULL AFTER `ordering` ," . "\n ADD `enabled` TINYINT( 1 ) DEFAULT '1' NOT NULL AFTER `width` ," . "\n ADD `plugin` VARCHAR( 255 ) DEFAULT NULL AFTER `enabled`";
    $dbUpgrades[1]['message'] = "1.0 Beta 3 to 1.0 Beta 4";
    // RC 1 upgrades:
    $dbUpgrades[2]['test'] = array('fields', '#__comprofiler_tabs');
    $dbUpgrades[2]['updates'][0] = "ALTER TABLE #__comprofiler_tabs ADD `plugin_include` VARCHAR( 255 ) AFTER `plugin` ," . "\n ADD `fields` TINYINT( 1 ) DEFAULT '1' NOT NULL AFTER `plugin_include` ";
    $dbUpgrades[2]['updates'][1] = "INSERT INTO `#__comprofiler_tabs` ( `title`, `description`, `ordering`, `width`, `enabled`, `plugin`, `plugin_include`, `fields`, `sys`) VALUES " . "\n ( '_UE_CONTACT_INFO_HEADER', '', -4, '1', 1, 'getContactTab', NULL, 1, 1)," . "\n ( '_UE_AUTHORTAB', '', -3, '1', 0, 'getAuthorTab', NULL, 0, 1)," . "\n ( '_UE_FORUMTAB', '', -2, '1', 0, 'getForumTab', NULL, 0, 1)," . "\n ( '_UE_BLOGTAB', '', -1, '1', 0, 'getBlogTab', NULL, 0, 1);";
    $dbUpgrades[2]['updates'][2] = "ALTER TABLE `#__comprofiler_lists` ADD `filterfields` VARCHAR( 255 ) AFTER `sortfields`;";
    $dbUpgrades[2]['message'] = "1.0 Beta 4 to 1.0 RC 1";
    // RC 2 Part 1 upgrades:
    $dbUpgrades[3]['test'] = array('description', '#__comprofiler_fields');
    $dbUpgrades[3]['updates'][0] = "ALTER TABLE `#__comprofiler_fields` ADD `description` MEDIUMTEXT  NOT NULL default '' AFTER `title` ";
    $dbUpgrades[3]['updates'][1] = "ALTER TABLE `#__comprofiler_fields` CHANGE `title` `title` VARCHAR( 255 ) NOT NULL";
    $dbUpgrades[3]['updates'][2] = "INSERT INTO `#__comprofiler_tabs` (`title`, `description`, `ordering`, `width`, `enabled`, `plugin`, `plugin_include`, `fields`, `sys`) VALUES " . "\n ( '_UE_CONNECTION', '',99, '1', 0, 'getConnectionTab', NULL, 0, 1);";
    $dbUpgrades[3]['updates'][3] = "INSERT INTO `#__comprofiler_tabs` (`title`, `description`, `ordering`, `width`, `enabled`, `plugin`, `plugin_include`, `fields`, `sys`) VALUES " . "\n ( '_UE_NEWSLETTER_HEADER', '_UE_NEWSLETTER_INTRODCUTION', 99, '1', 0, 'getNewslettersTab', NULL, 0, 1);";
    $dbUpgrades[3]['updates'][4] = "UPDATE `#__comprofiler_tabs` SET sys=2, enabled=1 WHERE plugin='getContactTab' ";
    $dbUpgrades[3]['updates'][5] = "ALTER TABLE `#__comprofiler_lists` ADD `useraccessgroupid` INT( 9 ) DEFAULT '18' NOT NULL AFTER `usergroupids` ";
    $dbUpgrades[3]['message'] = "1.0 RC 1 to 1.0 RC 2 part 1";
    // RC 2 Part 2 upgrades:
    $dbUpgrades[4]['test'] = array('params', '#__comprofiler_tabs');
    $dbUpgrades[4]['updates'][0] = "ALTER TABLE `#__comprofiler_tabs` CHANGE `plugin` `pluginclass` VARCHAR( 255 ) DEFAULT NULL , " . "\n CHANGE `plugin_include` `pluginid` INT( 11 ) DEFAULT NULL ";
    $dbUpgrades[4]['updates'][1] = "ALTER TABLE `#__comprofiler_tabs` ADD `params` MEDIUMTEXT AFTER `fields` ;";
    $dbUpgrades[4]['updates'][2] = "ALTER TABLE `#__comprofiler_fields` ADD `pluginid` INT( 11 ) , " . "\n ADD `params` MEDIUMTEXT; ";
    $dbUpgrades[4]['updates'][3] = "UPDATE `#__comprofiler_tabs` SET pluginid=1 WHERE pluginclass='getContactTab' ";
    $dbUpgrades[4]['updates'][4] = "UPDATE `#__comprofiler_tabs` SET pluginid=1 WHERE pluginclass='getConnectionTab' ";
    $dbUpgrades[4]['updates'][5] = "UPDATE `#__comprofiler_tabs` SET pluginid=3 WHERE pluginclass='getAuthorTab' ";
    $dbUpgrades[4]['updates'][6] = "UPDATE `#__comprofiler_tabs` SET pluginid=4 WHERE pluginclass='getForumTab' ";
    $dbUpgrades[4]['updates'][7] = "UPDATE `#__comprofiler_tabs` SET pluginid=5 WHERE pluginclass='getBlogTab' ";
    $dbUpgrades[4]['updates'][8] = "UPDATE `#__comprofiler_tabs` SET pluginid=6 WHERE pluginclass='getNewslettersTab' ";
    $dbUpgrades[4]['message'] = "1.0 RC 1 to 1.0 RC 2 part 2";
    // RC 2 Part 3 upgrades:
    $dbUpgrades[5]['test'] = array('position', '#__comprofiler_tabs');
    $dbUpgrades[5]['updates'][1] = "ALTER TABLE `#__comprofiler_tabs`" . "\n ADD `position` VARCHAR( 255 ) DEFAULT '' NOT NULL," . "\n ADD `displaytype` VARCHAR( 255 ) DEFAULT '' NOT NULL AFTER `sys`";
    $dbUpgrades[5]['updates'][2] = "UPDATE `#__comprofiler_tabs` SET position='cb_tabmain', displaytype='tab' ";
    $dbUpgrades[5]['updates'][3] = "INSERT INTO `#__comprofiler_tabs` (`title`, `description`, `ordering`, `width`, `enabled`, `pluginclass`, `pluginid`, `fields`, `sys`, `position`, `displaytype`) VALUES " . "\n ( '_UE_MENU', '', -10, '1', 1, 'getMenuTab', 14, 0, 1, 'cb_head', 'html')," . "\n ( '_UE_CONNECTIONPATHS', '', -9, '1', 1, 'getConnectionPathsTab', 2, 0, 1, 'cb_head', 'html')," . "\n ( '_UE_PROFILE_PAGE_TITLE', '', -8, '1', 1, 'getPageTitleTab', 1, 0, 1, 'cb_head', 'html')," . "\n ( '_UE_PORTRAIT', '', -7, '1', 1, 'getPortraitTab', 1, 0, 1, 'cb_middle', 'html')," . "\n ( '_UE_USER_STATUS', '', -6, '.5', 1, 'getStatusTab', 14, 0, 1, 'cb_right', 'html')," . "\n ( '_UE_PMSTAB', '', -5, '.5', 0, 'getmypmsproTab', 15, 0, 1, 'cb_right', 'html');";
    $dbUpgrades[5]['updates'][5] = "UPDATE `#__comprofiler_tabs` SET pluginid=2 WHERE pluginclass='getConnectionTab' ";
    $dbUpgrades[5]['updates'][6] = "ALTER TABLE `#__comprofiler_members` ADD `reason` MEDIUMTEXT default NULL AFTER `membersince` ";
    $dbUpgrades[5]['updates'][7] = "UPDATE `#__comprofiler_tabs` SET `pluginclass`=NULL, `pluginid`=NULL WHERE `pluginclass` != 'getContactTab' AND `fields` = 1";
    $dbUpgrades[5]['message'] = "1.0 RC 1 to 1.0 RC 2 part 3";
    // 1.0.2 upgrades:
    $dbUpgrades[6]['test'] = array('cbactivation', '#__comprofiler');
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_fields` CHANGE `default` `default` MEDIUMTEXT DEFAULT NULL;";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_fields` CHANGE `tabid` `tabid` int(11) DEFAULT NULL;";
    if (checkJversion() < 2) {
        $dbUpgrades[6]['updates'][] = "UPDATE `#__users` SET usertype='Registered' WHERE usertype='';";
    }
    $dbUpgrades[6]['updates'][] = "UPDATE `#__comprofiler_fields` SET `table`='#__users' WHERE name='email';";
    $dbUpgrades[6]['updates'][] = "UPDATE `#__comprofiler_fields` SET `table`='#__users' WHERE name='lastvisitDate';";
    $dbUpgrades[6]['updates'][] = "UPDATE `#__comprofiler_fields` SET `table`='#__users' WHERE name='registerDate';";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE #__comprofiler ADD `registeripaddr` VARCHAR( 50 ) DEFAULT '' NOT NULL AFTER `lastupdatedate`;";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE #__comprofiler ADD `cbactivation` VARCHAR( 50 ) DEFAULT '' NOT NULL AFTER `registeripaddr`;";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE #__comprofiler ADD `message_last_sent` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `hits`;";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE #__comprofiler ADD `message_number_sent` INT( 11 ) DEFAULT 0 NOT NULL AFTER `message_last_sent`;";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_field_values` ADD INDEX fieldid_ordering (`fieldid`, `ordering` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_fields` ADD INDEX `tabid_pub_prof_order` ( `tabid` , `published` , `profile` , `ordering` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_fields` ADD INDEX `readonly_published_tabid` ( `readonly` , `published` , `tabid` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_fields` ADD INDEX `registration_published_order` ( `registration` , `published` , `ordering` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_members` ADD INDEX `pamr` ( `pending` , `accepted` , `memberid` , `referenceid` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_members` ADD INDEX `aprm` ( `accepted` , `pending` , `referenceid` , `memberid` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_members` ADD INDEX `membrefid` ( `memberid` , `referenceid` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_plugin` ADD INDEX `type_pub_order` ( `type` , `published` , `ordering` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_tabs` ADD INDEX `enabled_position_ordering` ( `enabled` , `position` , `ordering` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_lists` ADD INDEX `pub_ordering` ( `published` , `ordering` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_lists` ADD INDEX `default_published` ( `default` , `published` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_userreports` ADD INDEX `status_user_date` ( `reportedstatus` , `reporteduser` , `reportedondate` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_userreports` ADD INDEX `reportedbyuser_ondate` ( `reportedbyuser` , `reportedondate` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_views` ADD INDEX `lastview` ( `lastview` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler_views` ADD INDEX `profile_id_lastview` (`profile_id`,`lastview`);";
    $dbUpgrades[6]['updates'][] = "UPDATE `#__comprofiler` SET `user_id`=`id` WHERE 1>0;";
    // fix in case something corrupt for unique key
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler` ADD UNIQUE KEY user_id (`user_id`);";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler` ADD INDEX `apprconfbanid` ( `approved` , `confirmed` , `banned` , `id` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler` ADD INDEX `avatappr_apr_conf_ban_avatar` ( `avatarapproved` , `approved` , `confirmed` , `banned` , `avatar` );";
    $dbUpgrades[6]['updates'][] = "ALTER TABLE `#__comprofiler` ADD INDEX `lastupdatedate` ( `lastupdatedate` );";
    $dbUpgrades[6]['message'] = "1.0 RC 2, 1.0 and 1.0.1 to 1.0.2";
    // 1.1 upgrades:
    $dbUpgrades[7]['test'] = array('ordering_register', '#__comprofiler_tabs');
    $dbUpgrades[7]['updates'][] = "ALTER TABLE `#__comprofiler_plugin` ADD `backend_menu` VARCHAR(255) NOT NULL DEFAULT '' AFTER `folder`;";
    $dbUpgrades[7]['updates'][] = "ALTER TABLE `#__comprofiler_tabs` ADD `ordering_register` int(11) NOT NULL DEFAULT 10 AFTER `ordering`;";
    $dbUpgrades[7]['updates'][] = "ALTER TABLE `#__comprofiler_tabs` ADD `useraccessgroupid` int(9) DEFAULT -2 NOT NULL AFTER `position`;";
    $dbUpgrades[7]['updates'][] = "ALTER TABLE `#__comprofiler_tabs` ADD INDEX `orderreg_enabled_pos_order` ( `enabled` , `ordering_register` , `position` , `ordering` );";
    $dbUpgrades[7]['updates'][] = "ALTER TABLE `#__comprofiler` ADD `unbannedby` int(11) default NULL AFTER `bannedby`;";
    $dbUpgrades[7]['updates'][] = "ALTER TABLE `#__comprofiler` ADD `unbanneddate` datetime default NULL AFTER `banneddate`;";
    $dbUpgrades[7]['updates'][] = "ALTER TABLE `#__comprofiler_field_values` CHANGE `fieldtitle` `fieldtitle` VARCHAR(255) NOT NULL DEFAULT '';";
    $dbUpgrades[7]['message'] = "1.0.2 to 1.1";
    // Perform database upgrades:
    foreach ($dbUpgrades as $dbUpgrade) {
        if (!cbInstaller_field_exists($dbUpgrade['test'][1], $dbUpgrade['test'][0])) {
            foreach ($dbUpgrade['updates'] as $query) {
                $_CB_database->setQuery($query);
                if (!$_CB_database->query()) {
                    $return .= '<span style="color:red;">' . $dbUpgrade['message'] . ' failed! Error: ' . $_CB_database->stderr(true) . '</span><br />';
                }
            }
            $return .= '<span style="color:green;">' . $dbUpgrade['message'] . ' Upgrade Applied Successfully.</span><br />';
        }
    }
    // Correct userlist orders:
    $query = 'SELECT ' . $_CB_database->NameQuote('listid') . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_lists') . "\n ORDER BY " . $_CB_database->NameQuote('ordering') . " ASC, " . $_CB_database->NameQuote('published') . " DESC";
    $_CB_database->setQuery($query);
    $lists = $_CB_database->loadObjectList();
    $order = 0;
    if ($lists) {
        foreach ($lists as $list) {
            $query = 'UPDATE ' . $_CB_database->NameQuote('#__comprofiler_lists') . "\n SET " . $_CB_database->NameQuote('ordering') . " = " . (int) $order . "\n WHERE " . $_CB_database->NameQuote('listid') . " = " . (int) $list->listid;
            $_CB_database->setQuery($query);
            $_CB_database->query();
            $order++;
        }
    }
    // Core database fixes:
    $dbChecker = new CBdbChecker($_CB_database);
    $result = $dbChecker->checkCBMandatoryDb(false);
    if (!$result) {
        $dbChecker = new CBdbChecker($_CB_database);
        $result = $dbChecker->checkCBMandatoryDb(true, false);
        if ($result == true) {
            $return .= '<p><span style="color:green;">Automatic database fixes of old core tabs and fields applied successfully.</span></p>';
        } elseif (is_string($result)) {
            $return .= '<p><span style="color:red;">' . $result . '</span></p>';
        } else {
            $errors = $dbChecker->getErrors(false);
            if ($errors) {
                $return .= '<div style="color:red;">' . '<h3><span style="color:red;">Database fixing errors:</span></h3>';
                foreach ($errors as $error) {
                    $return .= '<div style="font-size:115%">' . $error[0];
                    if ($error[1]) {
                        $return .= '<div style="font-size:90%">' . $error[1] . '</div>';
                    }
                    $return .= '</div>';
                }
                $return .= '</div>';
            }
        }
        if (checkJversion() < 1 || $_CB_framework->getCfg('session_handler') != 'database') {
            $logs = $dbChecker->getLogs(false);
            if (count($logs) > 0) {
                $return .= '<div><a href="#" id="cbdetailsLinkShowOld" onclick="document.getElementById(\'cbdetailsdbcheckOld\').style.display=\'\';return false;">Click to Show details</a></div>' . '<div id="cbdetailsdbcheckOld" style="color:green;display:none;">';
                foreach ($logs as $log) {
                    $return .= '<div>' . $log[0];
                    if ($log[1]) {
                        $return .= '<div style="font-size:90%">' . $log[1] . '</div>';
                    }
                    $return .= '</div>';
                }
                $return .= '</div>';
            }
        }
    }
    $dbChecker = new CBdbChecker($_CB_database);
    $result = $dbChecker->checkDatabase(true, false);
    if ($result == true) {
        $return .= '<p><span style="color:green;">Automatic database upgrade to current version applied successfully.</span></p>';
    } elseif (is_string($result)) {
        $return .= '<p><span style="color:red;">' . $result . '</span></p>';
    } else {
        $errors = $dbChecker->getErrors(false);
        if ($errors) {
            $return .= '<div style="color:red;">' . '<h3><span style="color:red;">Database fixing errors:</span></h3>';
            foreach ($errors as $error) {
                $return .= '<div style="font-size:115%">' . $error[0];
                if ($error[1]) {
                    $return .= '<div style="font-size:90%">' . $error[1] . '</div>';
                }
                $return .= '</div>';
            }
            $return .= '</div>';
        }
    }
    if (checkJversion() < 1 || $_CB_framework->getCfg('session_handler') != 'database') {
        $logs = $dbChecker->getLogs(false);
        if (count($logs) > 0) {
            $return .= '<div><a href="#" id="cbdetailsLinkShow" onclick="document.getElementById(\'cbdetailsdbcheck\').style.display=\'\';return false;">Click to Show details</a></div>' . '<div id="cbdetailsdbcheck" style="color:green;display:none;">';
            foreach ($logs as $log) {
                $return .= '<div>' . $log[0];
                if ($log[1]) {
                    $return .= '<div style="font-size:90%">' . $log[1] . '</div>';
                }
                $return .= '</div>';
            }
            $return .= '</div>';
        }
    }
    $return .= '<p>Core CB database upgrades done. If all lines above are in green, database upgrade completed successfully. Otherwise, please report exact errors and queries to forum, and try checking database again in components : community builder : tools : check database.</p>' . '</code>' . '</td>' . '</tr>' . '<tr>' . '<td>';
    // Fix images:
    $imagesPath = $_CB_framework->getCfg('absolute_path') . '/images';
    $cbImages = $imagesPath . '/comprofiler';
    $cbImagesGallery = $cbImages . '/gallery';
    if ($adminFS->isUsingStandardPHP() && !$adminFS->file_exists($cbImages) && !$adminFS->is_writable($_CB_framework->getCfg('absolute_path') . '/images/')) {
        $return .= '<span style="color:red;">' . $imagesPath . '/ is not writable!</span><br />';
    } else {
        if (!$adminFS->file_exists($cbImages)) {
            if ($adminFS->mkdir($cbImages)) {
                $return .= '<span style="color:green;">' . $cbImages . '/ Successfully added.</span><br />';
            } else {
                $return .= '<span style="color:red;">' . $cbImages . '/ failed to be to be created, please do so manually!</span><br />';
            }
        }
        if (!$adminFS->file_exists($cbImagesGallery)) {
            if ($adminFS->mkdir($cbImagesGallery)) {
                $return .= '<span style="color:green;">' . $cbImagesGallery . '/ Successfully added.</span><br />';
            } else {
                $return .= '<span style="color:red;">' . $cbImagesGallery . '/ failed to be to be created, please do so manually!</span><br />';
            }
        }
        if ($adminFS->file_exists($cbImages)) {
            if (!is_writable($cbImages)) {
                if (!$adminFS->chmod($cbImages, 0775)) {
                    if (!@chmod($cbImages, 0775)) {
                        $return .= '<span style="color:red;">' . $cbImages . '/ failed to chmod to 775 please do so manually!</span><br />';
                    }
                }
            }
            if (!is_writable($cbImages)) {
                $return .= '<span style="color:red;">' . $cbImages . '/ is not writable and failed to chmod to 775 please do so manually!</span><br />';
            }
        }
        if ($adminFS->file_exists($cbImagesGallery)) {
            if (!is_writable($cbImagesGallery)) {
                if (!$adminFS->chmod($cbImagesGallery, 0775)) {
                    if (!@chmod($cbImagesGallery, 0775)) {
                        $return .= '<span style="color:red;">' . $cbImagesGallery . '/ failed to chmod to 775 please do so manually!</span><br />';
                    }
                }
            }
            if (!is_writable($cbImagesGallery)) {
                $return .= '<span style="color:red;">' . $cbImagesGallery . '/ is not writable and failed to chmod to 775 please do so manually!</span><br />';
            }
            $galleryFiles = array('airplane.gif', 'ball.gif', 'butterfly.gif', 'car.gif', 'dog.gif', 'duck.gif', 'fish.gif', 'frog.gif', 'guitar.gif', 'kick.gif', 'pinkflower.gif', 'redflower.gif', 'skater.gif', 'index.html');
            foreach ($galleryFiles as $galleryFile) {
                if (!(file_exists($cbImagesGallery . '/' . $galleryFile) && is_readable($cbImagesGallery . '/' . $galleryFile))) {
                    $result = @copy($_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/images/gallery/' . $galleryFile, $cbImagesGallery . '/' . $galleryFile);
                    if (!$result) {
                        $result = $adminFS->copy($_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/images/gallery/' . $galleryFile, $cbImagesGallery . '/' . $galleryFile);
                    }
                    if (!$result) {
                        $return .= '<span style="color:red;">' . $galleryFile . ' failed to be added to the gallery please do so manually!</span><br />';
                    }
                }
            }
        }
    }
    if (!($adminFS->file_exists($cbImages) && is_writable($cbImages) && $adminFS->file_exists($cbImagesGallery))) {
        $return .= '<br /><span style="color:red;">Manually do the following:<br /> 1.) create ' . $cbImages . '/ directory <br /> 2.) chmod it to 755 or if needed to 775 <br /> 3.) create ' . $cbImagesGallery . '/ <br /> 4.) chmod it to 755 or if needed to 775 <br />5.) copy ' . $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/images/gallery/ and its contents to ' . $cbImagesGallery . '/</span><br />';
    }
    $return .= '</td>' . '</tr>' . '</table>' . '</div>';
    $_CB_framework->setUserState('com_comprofiler_install', $return);
    if (is_callable(array($_CB_framework, 'backendUrl'))) {
        $stepTwoUrl = $_CB_framework->backendUrl('index.php?option=com_comprofiler&task=finishinstallation', false);
    } else {
        $stepTwoUrl = (checkJversion() < 1 ? 'index2.php' : 'index.php') . '?option=com_comprofiler&task=finishinstallation';
    }
    $return = '<div id="cbInstallNextStep" style="font-weight:bold;font-size:120%;background:#ffffdd;border:2px orange solid;padding:5px;">WAIT PLEASE: DO NOT INTERRUPT INSTALLATION PROCESS: PERFORMING SECOND INSTALLATION STEP: UNCOMPRESSING CORE PLUGINS: THIS CAN TAKE UP TO 2 MINUTES.</div>' . $return;
    echo $return;
    $jsStepTwo = "\$( '#cbInstallNextStep' ).hide().fadeIn( '1500', function() {" . "\$( this ).fadeOut( '1000', function() {" . "\$( this ).fadeIn( '1500', function() {" . "window.location = '" . addslashes($stepTwoUrl) . "';" . "})" . "})" . "});";
    $_CB_framework->document->_outputToHeadCollectionStart();
    if (checkJversion() > 1) {
        $_CB_framework->document->setCmsDoc(null);
    }
    $_CB_framework->outputCbJQuery($jsStepTwo);
    $_CB_framework->getAllJsPageCodes();
    echo $_CB_framework->document->_outputToHead();
    return true;
}
 function sendToModerators($sub, $message, $replaceVariables = false, $mode = 0, $cc = null, $bcc = null, $attachment = null)
 {
     global $_CB_database, $ueConfig;
     $moderators = implode(',', getParentGIDS($ueConfig['imageApproverGid']));
     if ($moderators) {
         $query = 'SELECT u.id' . "\n FROM #__users u" . "\n INNER JOIN #__comprofiler c" . ' ON u.id = c.id';
         if (checkJversion() == 2) {
             $query .= "\n INNER JOIN #__user_usergroup_map g" . ' ON c.id = g.user_id' . "\n WHERE g.group_id IN ( {$moderators} )";
         } else {
             $query .= "\n WHERE u.gid IN ( {$moderators} )";
         }
         $query .= "\n AND u.block = 0" . "\n AND c.confirmed = 1" . "\n AND c.approved = 1" . "\n AND u.sendEmail = 1";
         $_CB_database->setQuery($query);
         $mods = $_CB_database->loadObjectList();
         foreach ($mods as $mod) {
             $this->sendFromSystem($mod->id, $sub, $message, $replaceVariables, $mode, $cc, $bcc, $attachment);
         }
     }
 }
 /**
  * Gets the limitstart parameter from $arr, that got set in writePagesLinks()
  *
  * @since 1.9
  * @deprecated 2.0 use cbPageNav
  *
  * @param  array     $arr
  * @return int|null
  */
 function getPagesLimitStart($arr)
 {
     $limitstart = cbGetParam($arr, 'limitstart');
     if ($limitstart === null && checkJversion() == 2) {
         // Joomla 3.0 introduces a wonderful new feature: Break $_GET variables: copy limitstart to start, and unset limitstart:
         $limitstart = cbGetParam($arr, 'start');
     }
     if ($limitstart !== null) {
         $limitstart = (int) $limitstart;
     }
     return $limitstart;
 }
示例#30
0
 /**
  * Remap literal groups (such as in default values) to the hardcoded CMS values
  * @deprecated 2.0 No use anymore for such functionality: Except for getting Public group: $_CB_framework->getCfg( 'guest_usergroup' )
  *
  * @param  string|array  $name  of int|string
  * @return int|array of int
  */
 public function mapGroupNamesToValues($name)
 {
     static $ps = null;
     $selected = (array) $name;
     foreach ($selected as $k => $v) {
         if (!is_numeric($v)) {
             if (!$ps) {
                 $ps = array('Root' => 0, 'Users' => 0, 'Public' => 1, 'Registered' => 2, 'Author' => 3, 'Editor' => 4, 'Publisher' => 5, 'Backend' => 0, 'Manager' => 6, 'Administrator' => 7, 'Superadministrator' => 8, 'Guest' => 9);
                 if (!checkJversion('j3.0+')) {
                     $ps['Guest'] = 0;
                 }
             }
             if (array_key_exists($v, $ps)) {
                 if ($ps[$v] != 0) {
                     $selected[$k] = $ps[$v];
                 } else {
                     unset($selected[$k]);
                 }
             } else {
                 $selected[$k] = $v;
             }
         }
     }
     if (!is_array($name)) {
         $selected = $selected[0];
     }
     return $selected;
 }