acl_check( 'administration', 'manage', 'users', $my->usertype, 'components', 'com_users' )) { mosRedirect( 'index2.php', _NOT_AUTH ); } $UElanguagePath=$mainframe->getCfg( 'absolute_path' ).'/components/com_comprofiler/plugin/language'; if (file_exists($UElanguagePath.'/'.$mosConfig_lang.'/'.$mosConfig_lang.'.php')) { include_once($UElanguagePath.'/'.$mosConfig_lang.'/'.$mosConfig_lang.'.php'); } else include_once($UElanguagePath.'/default_language/default_language.php'); require_once( $mainframe->getPath( 'admin_html' ) ); /** @global string $_CB_adminpath * @global string $_CB_joomla_adminpath * @global array $ueConfig */ global $_CB_joomla_adminpath, $_CB_adminpath, $ueConfig; $_CB_joomla_adminpath = $mainframe->getCfg( 'absolute_path' ). "/administrator"; $_CB_adminpath = $_CB_joomla_adminpath. "/components/com_comprofiler"; include_once($_CB_adminpath."/ue_config.php" ); include_once($_CB_adminpath."/plugin.class.php"); include_once($_CB_adminpath."/comprofiler.class.php"); include_once($_CB_adminpath."/imgToolbox.class.php"); if(!isset($mosConfig_emailpass) || is_null($mosConfig_emailpass)) $mosConfig_emailpass=0; $rid = trim( mosGetParam( $_REQUEST, 'rid', null ) ); $task = trim( mosGetParam( $_REQUEST, 'task', null ) ); $cid = mosGetParam( $_REQUEST, 'cid', array( 0 ) ); $uid = mosGetParam( $_REQUEST, 'uid', array( 0 ) ); if (!is_array( $cid )) { $ocid=$cid; $cid = array (); $cid[]=$ocid; } $oldignoreuserabort = ignore_user_abort(true); switch ($task) { case "new": editUser( 0, $option); break; case "edit": editUser( intval( $cid[0] ), $option ); break; case "save": saveUser( $option ); break; case "remove": removeUsers( $cid, $option ); break; case "block": changeUserBlock( $cid, 1, $option ); break; case "unblock": changeUserBlock( $cid, 0, $option ); break; case "approve": approveUser( $cid, 1, $option ); break; case "reject": approveUser( $cid, 0, $option ); break; case "showconfig": showConfig( $option ); break; case "showinstruction": showInstructions($database, $option, $mosConfig_lang); break; case "showsubscription": showSubscription($database, $option, $mosConfig_lang); break; case "saveconfig": saveConfig( $option ); break; case "newTab": editTab( 0, $option); break; case "editTab": editTab( intval( $cid[0] ), $option ); break; case "saveTab": saveTab( $option ); break; case "removeTab": removeTabs( $cid, $option ); break; case "showTab": showTab( $option ); break; case "orderupTab": case "orderdownTab": orderTabs( $cid[0], ($task == 'orderupTab' ? -1 : 1), $option); break; case "newField": editField( 0, $option); break; case "editField": editField( intval( $cid[0] ), $option ); break; case "saveField": saveField( $option ); break; case "removeField": removeField( $cid, $option ); break; case "showField": showField( $option ); break; case "orderupField": orderFields( $cid[0], -1, $option ); break; case "orderdownField": orderFields( $cid[0], 1, $option ); break; case "saveList": saveList($option ); break; case "editList": editList( $cid[0], 1, $option ); break; case "newList": editList( 0, $option); break; case "showLists": showLists( $option ); break; case "removeList": removeList( $cid, $option ); break; case "orderupList": orderLists( $cid[0], -1, $option ); break; case "orderdownList": orderLists( $cid[0], 1, $option ); break; case "fieldPublishedYes": publishField( $cid, 1, $option ); break; case "fieldPublishedNo": publishField( $cid, 0, $option ); break; case "fieldRequiredYes": requiredField( $cid, 1, $option ); break; case "fieldRequiredNo": requiredField( $cid, 0, $option ); break; case "fieldProfileYes": profileField( $cid, 1, $option ); break; case "fieldProfileNo": profileField( $cid, 0, $option ); break; case "fieldRegistrationYes": registrationField( $cid, 1, $option ); break; case "fieldRegistrationNo": registrationField( $cid, 0, $option ); break; case "listPublishedYes": listPublishedField( $cid, 1, $option ); break; case "listPublishedNo": listPublishedField( $cid, 0, $option ); break; case "listDefaultYes": listDefaultField( $cid, 1, $option ); break; case "listDefaultNo": listDefaultField( $cid, 0, $option ); break; case "tabPublishedYes": tabPublishedField( $cid, 1, $option ); break; case "tabPublishedNo": tabPublishedField( $cid, 0, $option ); break; case "tools": loadTools(); break; case "loadSampleData": loadSampleData(); break; case "syncUsers": syncUsers(); break; case "showusers": showUsers( $option ); break; case 'savetaborder': saveTabOrder( $cid ); break; case 'savefieldorder': saveFieldOrder( $cid ); break; case 'savelistorder': saveListOrder( $cid ); break; case 'newPlugin': case 'editPlugin': editPlugin( $option, $cid[0] ); break; case 'savePlugin': case 'applyPlugin': savePlugin( $option, $task ); break; case 'deletePlugin': removePlugin( $cid, $option ); break; case 'cancelPlugin': cancelPlugin( $option ); break; case 'publishPlugin': case 'unpublishPlugin': publishPlugin( $cid, ($task == 'publishPlugin'), $option ); break; case 'orderupPlugin': case 'orderdownPlugin': orderPlugin( $cid[0], ($task == 'orderupPlugin' ? -1 : 1), $option); break; case 'accesspublic': case 'accessregistered': case 'accessspecial': accessMenu( $cid[0], $task, $option ); break; case 'savepluginorder': savePluginOrder( $cid ); break; case 'showPlugins': viewPlugins( $option); break; case 'installPluginUpload': installPluginUpload(); break; case 'installPluginDir': installPluginDir(); break; case 'installPluginURL': installPluginURL(); break; case 'latestVersion': latestVersion(); break; case 'resendActivation': resendActivation(); break; default: teamCredits(2); break; } if (!is_null($oldignoreuserabort)) ignore_user_abort($oldignoreuserabort); function saveList( $option ) { global $database, $my, $_POST, $mosConfig_live_site, $ueConfig; $row = new moscomprofilerLists( $database ); if (!$row->bind( $_POST )) { echo "\n"; exit(); } if(isset($_POST['col1'])) { $row->col1fields = implode("|*|",$_POST['col1']); } else { $row->col1fields = null; } ; if(isset($_POST['col2'])) { $row->col2fields = implode("|*|",$_POST['col2']); } else { $row->col2fields = null; } ; if(isset($_POST['col3'])) { $row->col3fields = implode("|*|",$_POST['col3']); } else { $row->col3fields = null; } ; if(isset($_POST['col4'])) { $row->col4fields = implode("|*|",$_POST['col4']); } else { $row->col4fields = null; } ; if ($row->col1enabled != 1) $row->col1enabled=0; if ($row->col2enabled != 1) $row->col2enabled=0; if ($row->col3enabled != 1) $row->col3enabled=0; if ($row->col4enabled != 1) $row->col4enabled=0; if ($row->col1captions != 1) $row->col1captions=0; if ($row->col2captions != 1) $row->col2captions=0; if ($row->col3captions != 1) $row->col3captions=0; if ($row->col4captions != 1) $row->col4captions=0; if (!$row->store(cbGetEscaped($_POST['listid']),true)) { echo "\n"; exit(); } mosRedirect( "index2.php?option=$option&task=showLists", "Successfully Saved List: ". $row->title ); } function showLists( $option ) { global $database, $mainframe, $my, $acl,$mosConfig_list_limit, $_CB_joomla_adminpath; if(!isset($mosConfig_list_limit) || !$mosConfig_list_limit) $limit = 10; else $limit = $mosConfig_list_limit; $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $limit ); $lastCBlist = $mainframe->getUserState( "view{$option}lastCBlist", null ); if($lastCBlist=='showlists') { $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); $lastSearch = $mainframe->getUserState( "search{$option}", null ); $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); if ($lastSearch != $search) { $limitstart = 0; $mainframe->setUserState( "view{$option}limitstart", $limitstart ); } $search = trim( strtolower( $search ) ); } else { clearSearchBox(); $search=""; $limitstart = 0; $mainframe->setUserState( "view{$option}limitstart", $limitstart ); $mainframe->setUserState( "view{$option}lastCBlist", "showlists" ); } $where = array(); if (isset( $search ) && $search!= "") { $where[] = "(a.title LIKE '%$search%' OR a.description LIKE '%$search%')"; } $database->setQuery( "SELECT COUNT(*)" . "\nFROM #__comprofiler_lists AS a" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") ); $total = $database->loadResult(); echo $database->getErrorMsg(); if ($total <= $limitstart) $limitstart = 0; require_once( $_CB_joomla_adminpath . "/includes/pageNavigation.php" ); $pageNav = new mosPageNav( $total, $limitstart, $limit ); $database->setQuery( "SELECT listid, title, description, published,`default`,ordering" . "\nFROM #__comprofiler_lists a" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") . "\n ORDER BY ordering" . "\nLIMIT $pageNav->limitstart, $pageNav->limit" ); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } HTML_comprofiler::showLists( $rows, $pageNav, $search, $option ); return true; } function editList( $fid='0', $option='com_comprofiler' ) { global $database, $my, $acl; $row = new moscomprofilerLists( $database ); // load the row from the db table $row->load( $fid ); $lists['published'] = mosHTML::yesnoSelectList( 'published', 'class="inputbox" size="1"', $row->published ); $lists['default'] = mosHTML::yesnoSelectList( 'default', 'class="inputbox" size="1"', $row->default ); $my_groups = $acl->get_object_groups( 'users', $my->id, 'ARO' ); $gtree2=array(); $gtree2 = array_merge( $gtree2, $acl->get_group_children_tree( null, 'USERS', false )); $usergids=explode(",",$row->usergroupids); $ugids = array(); foreach($usergids as $usergid) { $ugids[]->value=$usergid; } $lists['usergroups'] = moscomprofilerHTML::selectList( $gtree2, 'usergroups', 'size="4" MULTIPLE onblur="loadUGIDs(this);" mosReq=1 mosLabel="User Groups"', 'value', 'text', $ugids,1 ); $gtree3=array(); $gtree3[] = mosHTML::makeOption( -2 , '- Everybody -' ); $gtree3[] = mosHTML::makeOption( -1, '- All Registered Users -' ); $gtree3 = array_merge( $gtree3, $acl->get_group_children_tree( null, 'USERS', false )); $lists['useraccessgroup']=mosHTML::selectList( $gtree3, 'useraccessgroupid', 'size="4"', 'value', 'text', $row->useraccessgroupid ); $database->setQuery( "SELECT f.fieldid, f.title" . "\nFROM #__comprofiler_fields AS f" . "\nWHERE f.published = 1 AND f.profile=1" . "\n ORDER BY f.ordering" ); //echo $database->getQuery(); $field = $database->loadObjectList(); $fields = array(); //print_r(array_values($field)); for ($i=0, $n=count( $field ); $i < $n; $i++) { $fieldvalue = array(); $fieldvalue =& $field[$i]; //print "fieldid = ".$fieldvalue->fieldid; $fields[$fieldvalue->title] = $fieldvalue->fieldid; } //print_r(array_values($fields)); HTML_comprofiler::editList( $row, $lists,$fields, $option, $fid ); } function removeList( $cid, $option ) { global $database, $acl, $ueConfig; if (!is_array( $cid ) || count( $cid ) < 1) { echo "\n"; exit; } $msg = ''; if (count( $cid )) { $obj = new moscomprofilerLists( $database ); foreach ($cid as $id) { $obj->delete( $id ); } } //if($msg!='') echo "\n"; mosRedirect( "index2.php?option=$option&task=showLists", $msg ); } function orderLists( $lid, $inc, $option ) { global $database; $row = new moscomprofilerLists( $database ); $row->load( $lid ); $row->move( $inc ); mosRedirect( "index2.php?option=$option&task=showLists" ); } function showField( $option ) { global $database, $mainframe, $my, $acl,$_POST,$mosConfig_list_limit, $_CB_joomla_adminpath; if(!isset($mosConfig_list_limit) || !$mosConfig_list_limit) $limit = 10; else $limit = $mosConfig_list_limit; $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $limit ); $lastCBlist = $mainframe->getUserState( "view{$option}lastCBlist", null ); if($lastCBlist=='showfields') { $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); $lastSearch = $mainframe->getUserState( "search{$option}", null ); $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); if ($lastSearch != $search) { $limitstart = 0; $mainframe->setUserState( "view{$option}limitstart", $limitstart ); } $search = trim( strtolower( $search ) ); } else { clearSearchBox(); $search=""; $limitstart = 0; $mainframe->setUserState( "view{$option}limitstart", $limitstart ); $mainframe->setUserState( "view{$option}lastCBlist", "showfields" ); } $where = array(); $where[] = "(f.sys = 0)"; if (isset( $search ) && $search!= "") { $where[] = "(f.name LIKE '%$search%' OR f.type LIKE '%$search%')"; } $where[] = "(f.tabid = t.tabid)"; $where[] = "(t.fields = 1)"; $database->setQuery( "SELECT COUNT(*)" . "\nFROM #__comprofiler_fields AS f, #__comprofiler_tabs AS t" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") ); $total = $database->loadResult(); echo $database->getErrorMsg(); if ($total <= $limitstart) $limitstart = 0; require_once( $_CB_joomla_adminpath . "/includes/pageNavigation.php" ); $pageNav = new mosPageNav( $total, $limitstart, $limit ); $database->setQuery( "SELECT f.fieldid, f.title, f.name, f.description, f.type, f.required, f.published, f.profile, f.ordering, f.registration, t.title AS 'tab'" . "\nFROM #__comprofiler_fields AS f, #__comprofiler_tabs AS t" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") . "\n ORDER BY t.ordering, f.ordering" . "\nLIMIT $pageNav->limitstart, $pageNav->limit" ); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } HTML_comprofiler::showFields( $rows, $pageNav, $search, $option ); return true; } function editField( $fid='0', $option='com_comprofiler' ) { global $database, $my, $acl; $row = new moscomprofilerFields( $database ); // load the row from the db table $row->load( $fid ); $tabs = $database->setQuery("SELECT tabid, title FROM #__comprofiler_tabs WHERE `fields`=1 ORDER BY ordering"); $tabs = $database->loadObjectList(); $lists = array(); $tablist = array(); for ($i=0, $n=count( $tabs ); $i < $n; $i++) { $tab =& $tabs[$i]; $tablist[] = mosHTML::makeOption( $tab->tabid, getLangDefinition($tab->title) ); } $lists['tabs'] = mosHTML::selectList( $tablist, 'tabid', 'class="inputbox" size="1" mosReq=1 mosLabel="Tab"', 'value', 'text', $row->tabid ); $types = array(); $types[] = mosHTML::makeOption( 'checkbox', 'Check Box (Single)' ); $types[] = mosHTML::makeOption( 'multicheckbox', 'Check Box (Muliple)' ); $types[] = mosHTML::makeOption( 'date', 'Date' ); $types[] = mosHTML::makeOption( 'select', 'Drop Down (Single Select)' ); $types[] = mosHTML::makeOption( 'multiselect', 'Drop Down (Multi-Select)' ); $types[] = mosHTML::makeOption( 'emailaddress', 'Email Address' ); //$types[] = mosHTML::makeOption( 'password', 'Password Field' ); $types[] = mosHTML::makeOption( 'editorta', 'Editor Text Area' ); $types[] = mosHTML::makeOption( 'textarea', 'Text Area' ); $types[] = mosHTML::makeOption( 'text', 'Text Field' ); $types[] = mosHTML::makeOption( 'radio', 'Radio Button' ); $types[] = mosHTML::makeOption( 'webaddress', 'Web Address' ); $types[] = mosHTML::makeOption( 'delimiter', 'Fields delimiter' ); $webaddrtypes = array(); $webaddrtypes[] = mosHTML::makeOption( '0', 'URL only' ); $webaddrtypes[] = mosHTML::makeOption( '2', 'Hypertext and URL' ); $fvalues = $database->setQuery( "SELECT fieldtitle " . "\n FROM #__comprofiler_field_values" . "\n WHERE fieldid=$fid" . "\n ORDER BY ordering" ); $fvalues = $database->loadObjectList(); $lists['webaddresstypes'] = mosHTML::selectList( $webaddrtypes, 'webaddresstypes', 'class="inputbox" size="1"', 'value', 'text', $row->rows ); $lists['type'] = mosHTML::selectList( $types, 'type', 'class="inputbox" size="1" onchange="selType(this.options[this.selectedIndex].value);"', 'value', 'text', $row->type ); $lists['required'] = mosHTML::yesnoSelectList( 'required', 'class="inputbox" size="1"', $row->required ); $lists['published'] = mosHTML::yesnoSelectList( 'published', 'class="inputbox" size="1"', $row->published ); $lists['readonly'] = mosHTML::yesnoSelectList( 'readonly', 'class="inputbox" size="1"', $row->readonly ); $lists['profile'] = mosHTML::yesnoSelectList( 'profile', 'class="inputbox" size="1"', $row->profile ); $lists['registration'] = mosHTML::yesnoSelectList( 'registration', 'class="inputbox" size="1"', $row->registration ); HTML_comprofiler::editfield( $row, $lists, $fvalues, $option, $fid ); } function saveField( $option ) { global $database, $my, $_POST, $mosConfig_live_site, $ueConfig; $row = new moscomprofilerFields( $database ); if (!$row->bind( $_POST )) { echo "\n"; exit(); } if ($row->type == 'webaddress') { $row->rows = $_POST['webaddresstypes']; if ( !(($row->rows == 0) || ($row->rows == 2)) ) $row->rows = 0; } if($_POST['oldtabid'] != $_POST['tabid']) { //Re-order old tab $sql="UPDATE #__comprofiler_fields SET ordering = ordering-1 WHERE ordering > ".cbGetEscaped($_POST['ordering'])." AND tabid = ".cbGetEscaped($_POST['oldtabid'])." "; $database->setQuery($sql); $database->loadResult(); //print $database->getquery(); //Select Last Order in New Tab $sql="Select max(ordering) from #__comprofiler_fields WHERE tabid=".cbGetEscaped($_POST['tabid']); $database->SetQuery($sql); $max = $database->LoadResult(); $row->ordering=$max+1; } mosMakeHtmlSafe($row); $row->name = str_replace(" ", "", strtolower($row->name)); if (!$row->check()) { echo "\n"; exit(); } if (!$row->store(cbGetEscaped($_POST['fieldid']))) { echo "\n"; exit(); } $fieldValues = array(); $fieldNames = array(); $fieldNames=$_POST['vNames']; $j=1; if($row->fieldid > 0) { $database->setQuery( "DELETE FROM #__comprofiler_field_values" . " WHERE fieldid='".cbGetEscaped($row->fieldid)."'" ); if(!$database->loadResult()) echo $database->getErrorMsg(); } else { $database->setQuery( "SELECT MAX(fieldid) FROM #__comprofiler_fields"); $maxID=$database->loadResult(); $row->fieldid=$maxID; echo $database->getErrorMsg(); } //for($i=0, $n=count( $fieldNames ); $i < $n; $i++) { foreach ($fieldNames as $fieldName) { if(trim($fieldName)!=null || trim($fieldName)!='') { $database->setQuery( "INSERT INTO #__comprofiler_field_values (fieldid,fieldtitle,ordering)" . " VALUES('$row->fieldid','".cbGetEscaped(htmlspecialchars($fieldName))."',$j)" ); if(!$database->loadResult()) echo $database->getErrorMsg(); $j++; } } $limit = intval( mosGetParam( $_REQUEST, 'limit', 10 ) ); $limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) ); mosRedirect( "index2.php?option=$option&task=showField", "Successfully Saved Field: ". $row->name); } function removeField( $cid, $option ) { global $database, $acl, $ueConfig; if (!is_array( $cid ) || count( $cid ) < 1) { echo "\n"; exit; } $msg = ''; if (count( $cid )) { $obj = new moscomprofilerFields( $database ); foreach ($cid as $id) { $obj->load($id); $noDelete = 0; $database->setQuery("SELECT COUNT(*) FROM #__comprofiler_lists". " WHERE col1fields like '%|*|$id' OR col1fields like '$id|*|%' OR col1fields like '%|*|$id|*|%' OR col1fields='$id'". " OR col2fields like '%|*|$id' OR col2fields like '$id|*|%' OR col2fields like '%|*|$id|*|%' OR col2fields='$id'". " OR col3fields like '%|*|$id' OR col3fields like '$id|*|%' OR col3fields like '%|*|$id|*|%' OR col3fields='$id'". " OR col4fields like '%|*|$id' OR col4fields like '$id|*|%' OR col4fields like '%|*|$id|*|%' OR col4fields='$id'"); $onList = $database->loadResult(); if ($onList > 0) { $msg .= getLangDefinition($obj->title) . " cannot be deleted because it is on a List. \n"; $noDelete = 1; } if ($obj->sys==1) { $msg .= getLangDefinition($obj->title) ." cannot be deleted because it is a system field. \n"; $noDelete = 1; } if ($noDelete != 1) { $obj->deleteColumn('#__comprofiler',$obj->name); $obj->delete( $id ); $sql="UPDATE #__comprofiler_fields SET ordering = ordering-1 WHERE ordering > ".$obj->ordering." AND tabid = ".$obj->tabid." "; $database->setQuery($sql); $database->loadResult(); //print $database->getquery(); } } } //if($msg!='') echo "\n"; mosRedirect( "index2.php?option=$option&task=showField", $msg ); } function orderFields( $fid, $inc, $option ) { global $database; $row = new moscomprofilerFields( $database ); $row->load( $fid ); $row->move( $inc , "tabid='$row->tabid'"); mosRedirect( "index2.php?option=$option&task=showField" ); } function showTab( $option ) { global $database, $mainframe, $my, $acl,$mosConfig_list_limit, $_CB_joomla_adminpath; if(!isset($mosConfig_list_limit) || !$mosConfig_list_limit) $limit = 10; else $limit = $mosConfig_list_limit; $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $limit ); $lastCBlist = $mainframe->getUserState( "view{$option}lastCBlist", null ); if($lastCBlist=='showtab') { $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); $lastSearch = $mainframe->getUserState( "search{$option}", null ); $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); if ($lastSearch != $search) { $limitstart = 0; $mainframe->setUserState( "view{$option}limitstart", $limitstart ); } $search = trim( strtolower( $search ) ); } else { clearSearchBox(); $search=""; $limitstart = 0; $mainframe->setUserState( "view{$option}limitstart", $limitstart ); $mainframe->setUserState( "view{$option}lastCBlist", "showtab" ); } $where = array(); if (isset( $search ) && $search!= "") { $where[] = "(title LIKE '%$search%')"; } $database->setQuery( "SELECT COUNT(*)" . "\nFROM #__comprofiler_tabs AS a" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") ); $total = $database->loadResult(); echo $database->getErrorMsg(); if ($total <= $limitstart) $limitstart = 0; require_once( $_CB_joomla_adminpath . "/includes/pageNavigation.php" ); $pageNav = new mosPageNav( $total, $limitstart, $limit ); $database->setQuery( "SELECT * " . "\nFROM #__comprofiler_tabs AS a" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") . "\n ORDER BY position, ordering" . "\nLIMIT $pageNav->limitstart, $pageNav->limit" ); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } HTML_comprofiler::showTabs( $rows, $pageNav, $search, $option ); return true; } function editTab( $tid='0', $option='com_comprofiler' ) { global $database, $my, $acl; $row = new moscomprofilerTabs( $database ); // load the row from the db table $row->load( $tid ); $lists = array(); if($row->sys=='2') $lists['enabled'] = "Yes"; else $lists['enabled'] = mosHTML::yesnoSelectList( 'enabled', 'class="inputbox" size="1"', $row->enabled ); /* ------------------------- ! head ! !-----------------------! ! ! ! ! ! left ! middle ! right ! ! ! ! ! !-----------------------! ! ! ! tabmain ! ! ! !-----------------------! ! underall ! ------------------------- */ $position = array(); $position[] = mosHTML::makeOption( 'cb_head', _UE_POS_CB_HEAD ); $position[] = mosHTML::makeOption( 'cb_left', _UE_POS_CB_LEFT ); $position[] = mosHTML::makeOption( 'cb_middle', _UE_POS_CB_MIDDLE ); $position[] = mosHTML::makeOption( 'cb_right', _UE_POS_CB_RIGHT ); $position[] = mosHTML::makeOption( 'cb_tabmain', _UE_POS_CB_MAIN ); $position[] = mosHTML::makeOption( 'cb_underall', _UE_POS_CB_BOTTOM ); if (!$row->position) $row->position = 'cb_tabmain'; $lists['position'] = mosHTML::selectList( $position, 'position', 'class="inputbox" size="1"', 'value', 'text', $row->position ); $displaytype = array(); $displaytype[] = mosHTML::makeOption( 'tab', _UE_DISPLAY_TAB ); $displaytype[] = mosHTML::makeOption( 'div', _UE_DISPLAY_DIV ); $displaytype[] = mosHTML::makeOption( 'html', _UE_DISPLAY_HTML ); $displaytype[] = mosHTML::makeOption( 'overlib', _UE_DISPLAY_OVERLIB ); $displaytype[] = mosHTML::makeOption( 'overlibfix', _UE_DISPLAY_OVERLIBFIX ); $displaytype[] = mosHTML::makeOption( 'overlibsticky', _UE_DISPLAY_OVERLIBSTICKY ); $lists['displaytype'] = mosHTML::selectList( $displaytype, 'displaytype', 'class="inputbox" size="1"', 'value', 'text', $row->displaytype ); HTML_comprofiler::edittab( $row, $option, $lists, $tid ); } function saveTab( $option ) { global $database, $my, $mosConfig_live_site, $_POST, $ueConfig; $params = mosGetParam( $_POST, 'params', '' ); $_POST['params'] = cbParameters::getRawParams( $params ); $row = new moscomprofilerTabs( $database ); if (!$row->bind( $_POST )) { echo "\n"; exit(); } mosMakeHtmlSafe($row); if (!$row->check()) { echo "\n"; exit(); } if (!$row->store()) { echo "\n"; exit(); } $row->checkin(); $limit = intval( mosGetParam( $_REQUEST, 'limit', 10 ) ); $limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) ); mosRedirect( "index2.php?option=$option&task=showTab", "Successfully Saved Tab: ". $row->title ); } function removeTabs( $cid, $option ) { global $database, $acl, $ueConfig; if (!is_array( $cid ) || count( $cid ) < 1) { echo "\n"; exit; } $msg = ''; if (count( $cid )) { $obj = new moscomprofilerTabs( $database ); foreach ($cid as $id) { $obj->load($id); $database->setQuery("SELECT COUNT(*) FROM #__comprofiler_fields WHERE tabid='$id'"); $onField = $database->loadResult(); if($obj->sys > 0) { $msg .= getLangDefinition($obj->title) ." cannot be deleted because it is a system tab. \n"; $noDelete = 1; } if($onField>0) { $msg .= getLangDefinition($obj->title) ." is being referenced by an existing field and cannot be deleted!"; $noDelete = 1; } if($noDelete == 0) { $obj->delete( $id ); $msg .= $obj->getError(); } $noDelete = 0; } } $limit = intval( mosGetParam( $_REQUEST, 'limit', 10 ) ); $limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) ); mosRedirect( "index2.php?option=$option&task=showTab", $msg ); } function orderTabs( $tid, $inc, $option ) { global $database; $row = new moscomprofilerTabs( $database ); $row->load( $tid ); $row->move( $inc, "position='$row->position' AND ordering > -10000 AND ordering < 10000 " ); mosRedirect( "index2.php?option=$option&task=showTab" ); } function showUsers( $option ) { global $database, $mainframe, $my, $acl,$mosConfig_list_limit,$_POST, $_CB_joomla_adminpath; if(!isset($mosConfig_list_limit) || !$mosConfig_list_limit) $limit = 10; else $limit = $mosConfig_list_limit; $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $limit ); $lastCBlist = $mainframe->getUserState( "view{$option}lastCBlist", null ); if($lastCBlist=='showusers') { $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); $lastSearch = $mainframe->getUserState( "search{$option}", null ); $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); if ($lastSearch != $search) { $limitstart = 0; $mainframe->setUserState( "view{$option}limitstart", $limitstart ); } $search = trim( strtolower( $search ) ); } else { clearSearchBox(); $search=""; $limitstart = 0; $mainframe->setUserState( "view{$option}limitstart", $limitstart ); $mainframe->setUserState( "view{$option}lastCBlist", "showusers" ); } $where = array(); if (isset( $search ) && $search!= "") { $where[] = "(a.username LIKE '%$search%' OR a.email LIKE '%$search%' OR a.name LIKE '%$search%')"; } // exclude any child group id's for this user //$acl->_debug = true; $pgids = $acl->get_group_children( $my->gid, 'ARO', 'RECURSE' ); if (is_array( $pgids ) && count( $pgids ) > 0) { $where[] = "(a.gid NOT IN (" . implode( ',', $pgids ) . "))"; } $database->setQuery( "SELECT COUNT(*)" . "\nFROM #__users AS a" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") ); $total = $database->loadResult(); echo $database->getErrorMsg(); if ($total <= $limitstart) $limitstart = 0; require_once( $_CB_joomla_adminpath . "/includes/pageNavigation.php" ); $pageNav = new mosPageNav( $total, $limitstart, $limit ); if (checkJversion() <= 0) { $database->setQuery( "SELECT DISTINCT a.*, g.name AS groupname, s.userid AS loggedin,ue.approved,ue.confirmed" . "\nFROM #__users AS a" . "\nLEFT JOIN #__comprofiler AS ue ON a.id = ue.id" . "\nINNER JOIN #__core_acl_aro AS aro ON aro.value = a.id" // map user to aro . "\nINNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.aro_id" // map aro to group . "\nINNER JOIN #__core_acl_aro_groups AS g ON g.group_id = gm.group_id" . "\n LEFT JOIN #__session AS s ON s.userid = a.id" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") . "\nLIMIT $pageNav->limitstart, $pageNav->limit" ); } else { $database->setQuery( "SELECT DISTINCT a.*, g.name AS groupname, s.userid AS loggedin,ue.approved,ue.confirmed" . "\nFROM #__users AS a" . "\nLEFT JOIN #__comprofiler AS ue ON a.id = ue.id" . "\nINNER JOIN #__core_acl_aro AS aro ON aro.value = a.id" // map user to aro . "\nINNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id" // map aro to group . "\nINNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id" . "\n LEFT JOIN #__session AS s ON s.userid = a.id" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") . "\nLIMIT $pageNav->limitstart, $pageNav->limit" ); } $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } HTML_comprofiler::showUsers( $rows, $pageNav, stripslashes($search), $option ); } function editUser( $uid='0', $option='users' ) { global $database, $my, $acl,$ueConfig; $msg = checkCBpermissions( array($uid), "edit", true ); if ($msg) { echo "\n"; exit; } $database->setQuery( "SELECT * FROM #__comprofiler c, #__users u WHERE c.id=u.id AND c.id='".$uid."'"); $users = $database->loadObjectList(); if (count($users)>0) { $newCBuser = '0'; $user = $users[0]; } else { $newCBuser = '1'; $database->setQuery( "SELECT * FROM #__users u WHERE u.id='".$uid."'"); $users = $database->loadObjectList(); if (count($users)>0) { $user = $users[0]; $user->approved = '0'; $user->confirmed = '1'; } else { $user = new mosUser( $database ); $user->approved = '1'; $user->confirmed = '1'; } $user->firstname = ''; $user->middlename = ''; $user->lastname = ''; $database->setQuery( "SELECT f.* FROM #__comprofiler_fields f, #__comprofiler_tabs t" . "\n WHERE f.published=1 and f.tabid = t.tabid AND t.enabled=1" ); $rowFields = $database->loadObjectList(); for($i=0, $n=count( $rowFields ); $i < $n; $i++) { $field=$rowFields[$i]->name; $value=$rowFields[$i]->default; if (!isset($user->$field)) { $user->$field=$value; } } } HTML_comprofiler::edituser( $user, $option, $uid, $newCBuser); } function saveUser( $option ) { global $database, $my; global $mosConfig_live_site,$_POST,$ueConfig,$_PLUGINS,$mosConfig_emailpass; $userIdPosted = mosGetParam($_POST, "id"); if ($userIdPosted) { $msg = checkCBpermissions( array($userIdPosted), "save" ); if ($msg) { echo "\n"; exit; } } $row = new mosUser( $database ); if (!$row->bind( $_POST )) { echo "\n"; exit(); } $isNew = !$row->id; $pwd = ''; if ($isNew) { // new user stuff if ($row->password == '') { $pwd = mosMakePassword(); $row->password = md5( $pwd ); } else { $pwd = $row->password; $row->password = md5( $row->password ); } $row->registerDate = date("Y-m-d H:i:s"); } else { // existing user stuff if ($row->password == '') { // password set to null if empty $row->password = null; } else { $row->password = md5( $row->password ); } } $query = "SELECT name" . "\n FROM #__core_acl_aro_groups" . "\n WHERE group_id = $row->gid" ; $database->setQuery( $query ); $usertype = $database->loadResult(); $row->usertype = $usertype; SWITCH ($ueConfig['name_style']) { case 2: $row->name = cbGetUnEscaped(((isset($_POST['firstname'])) ? $_POST['firstname'] : "") . ' ' . ((isset($_POST['lastname'])) ? $_POST['lastname'] : "")); break; case 3: $row->name = cbGetUnEscaped(((isset($_POST['firstname'])) ? $_POST['firstname'] : "") . ' ' . ((isset($_POST['middlename'])) ? ($_POST['middlename'] . ' ') : "") . ((isset($_POST['lastname'])) ? $_POST['lastname'] : "")); break; } mosMakeHtmlSafe($row); if (!$row->check()) { echo "\n"; exit(); } $sqlFormat = "Y-m-d"; $selFields = ''; $database->setQuery( "SELECT f.* FROM #__comprofiler_fields f, #__comprofiler_tabs t" . "\n WHERE f.published=1 and f.tabid = t.tabid AND t.enabled=1" ); $rowFields = $database->loadObjectList(); $cbFields=new cbFields(); $rowExtras = new moscomprofiler($database); for($i=0, $n=count( $rowFields ); $i < $n; $i++) { $field=cbGetEscaped($rowFields[$i]->name); $value=null; if(isset($_POST[$rowFields[$i]->name])) $value=$cbFields->prepareFieldDataSave($rowFields[$i]->type,$rowFields[$i]->name,$_POST[$rowFields[$i]->name]); $rowExtras->$field=$value; } $rowExtras->id=$row->id; $rowExtras->user_id=$row->id; $rowExtras->firstname=cbGetUnEscaped((isset($_POST['firstname']) ? $_POST['firstname'] : "")); $rowExtras->middlename=cbGetUnEscaped((isset($_POST['middlename']) ? $_POST['middlename'] : "")); $rowExtras->lastname=cbGetUnEscaped((isset($_POST['lastname']) ? $_POST['lastname'] : "")); $rowExtras->approved=cbGetUnEscaped($_POST['approved']); $rowExtras->confirmed=cbGetUnEscaped($_POST['confirmed']); $_PLUGINS->loadPluginGroup('user'); $newCBuser = (isset($_POST['newCBuser'])) ? ($_POST['newCBuser']=="1") : true; // save user params $params = mosGetParam( $_POST, 'cbparams', null ); //echo "params:".print_r($params); if($params != null) { if (is_array( $params )) { $txt = array(); foreach ( $params as $k=>$v) { $txt[] = "$k=$v"; } $row->params = implode( "\n", $txt ); } } // Security check to avoid creating/editing user to higher level than himself: response to artf4529. if (!in_array($row->gid,getChildGIDS($my->gid))) { echo "illegal attempt to set user at higher level than allowed !"; exit(); } if($isNew || $newCBuser) { $_PLUGINS->trigger( 'onBeforeNewUser', array(&$row,&$rowExtras, false)); if($_PLUGINS->is_errors()) { echo "\n"; exit(); } if ($isNew && !$row->store()) { // first store to get new user id if id is not set (needed for savePluginTabs) // echo "\n"; echo $row->getError(); exit(); } $database->setQuery("SELECT id FROM #__users WHERE username = '".cbGetEscaped($_POST['username'])."'"); $uid = $database->loadResult(); $row->id = $uid; // this is only for mambo 4.5.0 backwards compatibility. 4.5.2.3 $row->store() updates id on insert $rowExtras->id = $row->id; $rowExtras->user_id = $row->id; $userComplete =& moscomprofiler::dbObjectsMerge($row, $rowExtras); $tabs = new cbTabs( 0, 2); $tabs->savePluginTabs($userComplete, $_POST); // this changes $row and $rowExtras by reference in $userComplete if (!$row->store()) { // echo "\n"; echo $row->getError(); exit(); } if(!$database->insertObject( '#__comprofiler', $rowExtras)) { // escapes // echo "\n"; echo $database->stderr(true); exit(); } $_PLUGINS->trigger( 'onAfterNewUser', array($row, $rowExtras, false, true)); if($rowExtras->approved == 1 && $rowExtras->confirmed) activateUser($row, false, false); } else { $uid = $row->id; // get previous state for triggering the activation event: $database->setQuery( "SELECT * FROM #__comprofiler c, #__users u WHERE c.id=u.id AND c.id='".$uid."'"); $previousState = $database->loadObjectList(); if (count($previousState)>0) { $previousState = $previousState[0]; } $rowExtras->id = $uid; $rowExtras->user_id = $uid; $_PLUGINS->trigger( 'onBeforeUpdateUser', array(&$row,&$rowExtras)); if($_PLUGINS->is_errors()) { echo "\n"; exit(); } $userComplete =& moscomprofiler::dbObjectsMerge($row, $rowExtras); $tabs = new cbTabs( 0, 2); $tabs->savePluginTabs($userComplete, $_POST); // this changes $row and $rowExtras by reference in $userComplete if (!$row->store()) { // echo "\n"; echo $row->getError(); exit(); } if(!$database->updateObject( '#__comprofiler', $rowExtras,'id', false)) { // escapes // echo "\n"; echo $database->stderr(true); exit(); } $_PLUGINS->trigger( 'onAfterUpdateUser', array($row, $rowExtras, true)); if (!(($previousState->approved == 1 || $previousState->approved == 2) && $previousState->confirmed) && ($rowExtras->approved == 1 && $rowExtras->confirmed)) { activateUser($userComplete, false); } } // update the ACL if ($isNew) { } else { $database->setQuery( "SELECT aro_id FROM #__core_acl_aro WHERE value='$row->id'" ); $aro_id = $database->loadResult(); $database->setQuery( "UPDATE #__core_acl_groups_aro_map" . "\nSET group_id = '$row->gid'" . "\nWHERE aro_id = '$aro_id'" ); $database->query() or die( $database->stderr() ); } $row->checkin(); if ($isNew) { $query = "SELECT * FROM #__comprofiler c, #__users u WHERE c.id=u.id AND c.id =" . $uid; $database->setQuery($query); $user = $database->loadObjectList(); $user[0]->password=$pwd; // set password in cleartext for email to new users //set this to 1 to force password to be sent to new users. $mosConfig_emailpass=1; $cbNotification = new cbNotification(); $cbNotification->sendFromSystem($user[0],getLangDefinition($ueConfig['reg_welcome_sub']),getLangDefinition($ueConfig['reg_welcome_msg'])); } mosRedirect( "index2.php?option=$option&task=showusers", "Successfully Saved User: ". $row->username ); } /** * Check if users are of lower permissions than current user (if not super-admin) and if the user himself is not included * * @param array of userId $cid * @param string $actionName to insert in message. * @return string of error if error, otherwise null */ function checkCBpermissions( $cid, $actionName, $allowActionToMyself = false ) { global $database, $acl,$_PLUGINS, $ueConfig, $my; $msg = null; if (is_array( $cid ) && count( $cid )) { $obj = new mosUser( $database ); foreach ($cid as $id) { $obj->load( $id ); $groups = $acl->get_object_groups( 'users', $id, 'ARO' ); $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); if ( !$allowActionToMyself && $id == $my->id ){ $msg .= "You cannot ".$actionName." Yourself! "; } else if (($obj->gid == $my->gid && $my->gid != 25) || ($obj->gid && !in_array($obj->gid,getChildGIDS($my->gid)))) { $msg .= "You cannot ".$actionName." a `".$this_group."`. Only higher-level users have this power. "; } } } return $msg; } function deleteUsers( $cid ) { global $database, $acl,$_PLUGINS, $ueConfig, $my; $msg = checkCBpermissions( $cid, "delete" ); if (!$msg && is_array( $cid ) && count( $cid )) { $obj = new mosUser( $database ); $obj2 = new moscomprofiler( $database ); $tabs = new cbTabs( 0, 2); foreach ($cid as $id) { $obj->load( $id ); // check for a super admin ... can't delete them /* done above $groups = $acl->get_object_groups( 'users', $id, 'ARO' ); $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); if ( $this_group == 'super administrator' && $my->gid != 25 ) { $msg .= "You cannot delete a Super Administrator"; } else if ( $id == $my->id ){ $msg .= "You cannot delete Yourself!"; } else if ( ( $this_group == 'administrator' ) && ( $my->gid == 24 ) ){ $msg .= "You cannot delete another `Administrator` only `Super Administrators` have this power"; } else if (($obj->gid == $my->gid && $my->gid != 25) || !in_array($obj->gid,getChildGIDS($my->gid))) { $msg .= "You cannot delete a `".$this_group."`. Only higher-level users have this power"; } else */ { $count = 2; if ( $obj->gid == 25 ) { // count number of active super admins $query = "SELECT COUNT( id )" . "\n FROM #__users" . "\n WHERE gid = 25" . "\n AND block = 0" ; $database->setQuery( $query ); $count = $database->loadResult(); } if ( $count <= 1 && $obj->gid == 25 ) { // cannot delete Super Admin where it is the only one that exists $msg .= "You cannot delete this Super Administrator as it is the only active Super Administrator for your site"; } else { // delete user $query = "SELECT * FROM #__comprofiler c LEFT JOIN #__users u ON c.id=u.id WHERE c.id = " . cbGetEscaped($id); $database->setQuery($query); $user = $database->loadObjectList(); $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger( 'onBeforeDeleteUser', array($user[0])); deleteAvatar($user[0]->avatar); $obj->delete( $id ); $obj2->delete( $id ); $msg .= $obj->getError(); $msg .= $obj2->getError(); // delete user acounts active sessions $query = "DELETE FROM #__session" . "\n WHERE userid=$id" ; $database->setQuery( $query ); $database->query(); $_PLUGINS->trigger( 'onAfterDeleteUser', array($user[0],true)); } } } } return $msg; } function removeUsers( $cid, $option ) { if (!is_array( $cid ) || count( $cid ) < 1) { echo "\n"; exit; } $msg = deleteUsers($cid); if ($msg) { echo "\n"; exit; } $limit = intval( mosGetParam( $_REQUEST, 'limit', 10 ) ); $limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) ); mosRedirect( "index2.php?option=$option&task=showusers", $msg ); } /** * Blocks or Unblocks one or more user records * @param array An array of unique category id numbers * @param integer 0 if unblock, 1 if blocking * @param string The current url option */ function changeUserBlock( $cid=null, $block=1, $option ) { global $database, $my; $action = $block ? 'block' : 'unblock'; if (count( $cid ) < 1) { echo "\n"; exit; } $msg = checkCBpermissions( $cid, $action ); if ($msg) { echo "\n"; exit; } $cids = implode( ',', $cid ); $database->setQuery( "UPDATE #__users SET block='$block'" . "\nWHERE id IN ($cids)" ); if (!$database->query()) { echo "\n"; exit(); } // if action is to block a user, delete user acounts active sessions if ( $block == 1 ) { $query = "DELETE FROM #__session" . "\n WHERE userid IN ( $cids )" ; $database->setQuery( $query ); $database->query(); } mosRedirect( "index2.php?option=$option&task=showusers" ); } function is_email($email){ $rBool=false; if(preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $email)){ $rBool=true; } return $rBool; } function showConfig( $option ) { global $database,$ueConfig,$acl,$my,$mosConfig_absolute_path; global $mosConfig_lang, $_PLUGINS, $_CB_adminpath, $mainframe; $configfile = $_CB_adminpath."/ue_config.php"; @chmod ($configfile, 0766); if (!is_callable(array("JFile","write")) || ($mainframe->getCfg('ftp_enable') != 1)) { $permission = is_writable($configfile); if (!$permission) { echo "
Added ".$affected." new entries to Community Builder from users Table.
"; } // 2. remove excessive comprofiler entries (e.g. if admin used joomla! delete user function: $sql = "SELECT c.id FROM #__comprofiler c LEFT JOIN #__users u ON u.id = c.id WHERE u.id IS NULL"; $database->setQuery($sql); $users = $database->loadResultArray(); if (count($users)) { print "Removing ".count($users)." entries from Community Builder missing in users Table.
"; } if ($database->getErrorNum()) { print("SQL error" . $database->stderr(true)."".$msg."
"; print "Joomla/Mambo User Table and Joomla Community Builder User Table now in sync!"; } function loadTools() { HTML_comprofiler::showTools(); } /** * Compacts the ordering sequence of the selected records * @param array of table key ids which need to get saved ($row[]->ordering contains old ordering and $_POST['order'] contains new ordering) * @param object derived from comprofilerDBTable of corresponding class * @param string Additional "WHERE" query to limit ordering to a particular subset of records */ function saveOrder( &$cid, &$row, $conditionStatement ) { global $database,$_POST; $total = count( $cid ); $order = mosGetParam( $_POST, 'order', array(0) ); $conditions = array(); $cidsChanged = array(); // update ordering values for( $i=0; $i < $total; $i++ ) { $row->load( $cid[$i] ); if ($row->ordering != $order[$i]) { $row->ordering = $order[$i]; if (!$row->store($cid[$i])) { echo "\n"; exit(); } // if $cidsChanged[] = $cid[$i]; // remember to updateOrder this group if multiple groups (conditionStatement gives the group) if ($conditionStatement) { $condition=null; // to make php checker happy: the next line defines $condition eval($conditionStatement); $found = false; foreach ( $conditions as $cond ) if ($cond[1]==$condition) { $found = true; break; } // if if (!$found) $conditions[] = array($cid[$i], $condition); } } // if } // for if ($conditionStatement) { // execute updateOrder for each group foreach ( $conditions as $cond ) { $row->load( $cond[0] ); $row->updateOrder( $cond[1], $cidsChanged ); } // foreach } else if ($cidsChanged) { $row->load( $cidsChanged[0] ); $row->updateOrder( null, $cidsChanged ); } return 'New ordering saved'; } // saveOrder function saveFieldOrder( &$cid ) { global $database; $row = new moscomprofilerFields( $database ); $msg = saveOrder( $cid, $row, "\$condition = \"tabid='\$row->tabid'\";" ); mosRedirect( 'index2.php?option=com_comprofiler&task=showField', $msg ); } // saveFieldOrder function saveTabOrder( &$cid ) { global $database; $row = new moscomprofilerTabs( $database ); $msg = saveOrder( $cid, $row, "\$condition = \"position='\$row->position' AND ordering > -10000 AND ordering < 10000 \";" ); mosRedirect( 'index2.php?option=com_comprofiler&task=showTab', $msg ); } // saveTabOrder saveOrder function saveListOrder( &$cid ) { global $database; $row = new moscomprofilerLists( $database ); $msg = saveOrder( $cid, $row, null ); mosRedirect( 'index2.php?option=com_comprofiler&task=showLists', $msg ); } // saveListOrder saveOrder //plugin function viewPlugins( $option ) { global $database, $mainframe, $mosConfig_list_limit, $_CB_joomla_adminpath; global $mosConfig_absolute_path; if(!isset($mosConfig_list_limit) || !$mosConfig_list_limit) $limit = 10; else $limit = $mosConfig_list_limit; $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $limit ); $lastCBlist = $mainframe->getUserState( "view{$option}lastCBlist", null ); if ($lastCBlist == 'showplugins') { $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); $lastSearch = $mainframe->getUserState( "search{$option}", null ); $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); if ($lastSearch != $search) { $limitstart = 0; $mainframe->setUserState( "view{$option}limitstart", $limitstart ); } $search = trim( strtolower( $search ) ); $filter_type = $mainframe->getUserStateFromRequest( "filter_type{$option}", 'filter_type', "0" ); } else { clearSearchBox(); $search=""; $limitstart = 0; $mainframe->setUserState( "view{$option}limitstart", $limitstart ); $mainframe->setUserState( "view{$option}lastCBlist", "showplugins" ); $filter_type = "0"; $mainframe->setUserState( "filter_type{$option}", $filter_type ); } $where=array(); // used by filter if ( $filter_type ) { $where[] = "m.type = '$filter_type'"; } if ( $search ) { $where[] = "LOWER( m.name ) LIKE '%$search%'"; } // get the total number of records $query = "SELECT count(*) FROM #__comprofiler_plugin As m ". ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : '' ); $database->setQuery( $query ); $total = $database->loadResult(); if ($total <= $limitstart) $limitstart = 0; require_once( $_CB_joomla_adminpath . "/includes/pageNavigation.php" ); $pageNav = new mosPageNav( $total, $limitstart, $limit ); $query = "SELECT m.*, u.name AS editor, g.name AS groupname" . "\n FROM #__comprofiler_plugin AS m" . "\n LEFT JOIN #__users AS u ON u.id = m.checked_out" . "\n LEFT JOIN #__groups AS g ON g.id = m.access" . ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : '' ) . "\n GROUP BY m.id" . "\n ORDER BY m.type ASC, m.ordering ASC, m.name ASC" . "\n LIMIT $pageNav->limitstart,$pageNav->limit" ; $database->setQuery( $query ); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } // get list of Positions for dropdown filter $query = "SELECT type AS value, type AS text" . "\n FROM #__comprofiler_plugin" . "\n GROUP BY type" . "\n ORDER BY type" ; $types[] = mosHTML::makeOption( '0', (!defined('_SEL_TYPE')) ? '- Select Type -' : _SEL_TYPE ); // Mambo 4.5.1 Compatibility $database->setQuery( $query ); $types = array_merge( $types, $database->loadObjectList() ); $lists['type'] = mosHTML::selectList( $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_type ); HTML_comprofiler::showPlugins( $rows, $pageNav, $option, $lists, $search ); } /** * Saves the module after an edit form submit */ function savePlugin( $option, $task ) { global $database; if($task=='showPlugins') { mosRedirect( 'index2.php?option='. $option .'&task=showPlugins'); return; } $params = mosGetParam( $_POST, 'params', '' ); $_POST['params'] = cbParameters::getRawParams( $params ); $row = new moscomprofilerPlugin( $database ); if (!$row->bind( $_POST )) { echo "\n"; exit(); } if (!$row->check()) { echo "\n"; exit(); } if (!$row->store()) { echo "\n"; exit(); } $row->checkin(); $row->updateOrder( "type='$row->type' AND ordering > -10000 AND ordering < 10000 " ); switch ( $task ) { case 'applyPlugin': $msg = 'Successfully Saved changes to Plugin: '. $row->name; mosRedirect( 'index2.php?option='. $option .'&task=editPlugin&cid='. $row->id, $msg ); case 'savePlugin': default: $msg = 'Successfully Saved Plugin: '. $row->name; mosRedirect( 'index2.php?option='. $option .'&task=showPlugins' , $msg ); break; } } /** * Compiles information to add or edit a plugin * @param string The current GET/POST option * @param integer The unique id of the record to edit */ function editPlugin( $option, $uid) { global $database, $my, $mainframe, $mosConfig_absolute_path, $_PLUGINS; $lists = array(); $row = new moscomprofilerPlugin($database); // load the row from the db table $row->load( $uid ); // fail if checked out not by 'me' if ($row->checked_out && $row->checked_out <> $my->id) { echo "\n"; exit(0); } // get list of groups if ($row->access == 99 || $row->client_id == 1) { $lists['access'] = 'Administrator'; } else { // build the html select list for the group access if (is_callable(array("mosAdminMenus","Access"))) { $lists['access'] = mosAdminMenus::Access( $row ); } else { /* Mambo 4.5.0 support: */ $database->setQuery( 'SELECT id AS value, name AS text FROM #__groups ORDER BY id' ); $lists['access'] = mosHTML::selectList( $database->loadObjectList(), 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ) ); } } if ($uid) { $row->checkout( $my->id ); if ( $row->ordering > -10000 && $row->ordering < 10000 ) { // build the html select list for ordering $query = "SELECT ordering AS value, name AS text" . "\n FROM #__comprofiler_plugin" . "\n WHERE type='$row->type'" . "\n AND published > 0" . "\n AND ordering > -10000" . "\n AND ordering < 10000" . "\n ORDER BY ordering" ; $order = mosGetOrderingList( $query ); $lists['ordering'] = mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); } else { $lists['ordering'] = 'This plugin cannot be reordered'; } $lists['type'] = ''. $row->type; // XML library require_once( $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php' ); // xml file for module $xmlfile = $mosConfig_absolute_path . '/components/com_comprofiler/plugin/' .$row->type . '/'.$row->folder . '/' . $row->element .'.xml'; if (!file_exists($xmlfile)) { $row->description = 'Plugin not installed'; } else { $xmlDoc =& new DOMIT_Lite_Document(); $xmlDoc->resolveErrors( true ); if ($xmlDoc->loadXML( $xmlfile, false, true )) { $element = &$xmlDoc->documentElement; if ($element->getTagName() == 'cbinstall' && $element->getAttribute( 'type' ) == 'plugin' ) { $element = &$xmlDoc->getElementsByPath( 'description', 1 ); $row->description = $element ? trim( $element->getText() ) : ''; } } } } else { $row->folder = ''; $row->ordering = 999; $row->published = 1; $row->description = ''; $folders = mosReadDirectory( $mosConfig_absolute_path . '/components/com_comprofiler/plugin/' ); $folders2 = array(); foreach ($folders as $folder) { if (is_dir( $mosConfig_absolute_path . '/components/com_comprofiler/plugin/' . $folder ) && ( $folder <> 'CVS' ) ) { $folders2[] = mosHTML::makeOption( $folder ); } } $lists['type'] = mosHTML::selectList( $folders2, 'type', 'class="inputbox" size="1"', 'value', 'text', null ); $lists['ordering'] = 'New items default to the last place. Ordering can be changed after this item is saved.'; $xmlfile = null; } $Yesoptions = array(); $Yesoptions[] = mosHTML::makeOption( '1', _CMN_YES ); if ($row->type == "language") { $row->published = '1'; } else { $Yesoptions[] = mosHTML::makeOption( '0', _CMN_NO ); } if (is_callable(array("mosHTML","radioList"))) { // mambo 4.5.0 compatibility: $lists['published'] = mosHTML::radioList( $Yesoptions, 'published', 'class="inputbox"', $row->published ); } else { $lists['published'] = mosHTML::selectList( $Yesoptions, 'published', 'class="inputbox"', 'value', 'text', $row->published ); } // get params definitions if ($row->type !== "language") { $_PLUGINS->loadPluginGroup($row->type,array($row->id), 0); } $params =& new cbParameters( $row->params, $xmlfile ); HTML_comprofiler::editPlugin( $row, $lists, $params, $option ); } /** * Deletes one or more plugins * * Also deletes associated entries in the #__comprofiler_plugin table. * @param array An array of unique category id numbers */ function removePlugin( &$cid, $option ) { global $database, $my; if (count( $cid ) < 1) { echo "\n"; exit; } $installer = new cbInstallerPlugin(); foreach($cid AS $id) { $ret=$installer->uninstall($id,$option); } HTML_comprofiler::showInstallMessage( $installer->getError(), 'Uninstall Plugin - '.($ret ? 'Success' : 'Failed'), $installer->returnTo( $option, 'showPlugins' ) ); } /** * Publishes or Unpublishes one or more plugins * @param array An array of unique category id numbers * @param integer 0 if unpublishing, 1 if publishing */ function publishPlugin( $cid=null, $publish=1, $option ) { global $database, $my; if (count( $cid ) < 1) { $action = $publish ? 'publish' : 'unpublish'; echo "\n"; exit; } $cids = implode( ',', $cid ); $query = "UPDATE #__comprofiler_plugin SET published='$publish'" . "\n WHERE id IN ($cids)" . "\n AND (checked_out=0 OR (checked_out='$my->id'))" ; $database->setQuery( $query ); if (!$database->query()) { echo "\n"; exit(); } if (count( $cid ) == 1) { $row = new moscomprofilerPlugin( $database ); $row->checkin( $cid[0] ); } mosRedirect( 'index2.php?option='. $option .'&task=showPlugins' ); } /** * Cancels an edit operation */ function cancelPlugin( $option) { global $database; $row = new moscomprofilerPlugin( $database ); $row->bind( $_POST ); $row->checkin(); mosRedirect( 'index2.php?option='. $option .'&task=showPlugins' ); } /** * Moves the order of a record * @param integer The unique id of record * @param integer The increment to reorder by */ function orderPlugin( $uid, $inc, $option ) { global $database; $row = new moscomprofilerPlugin( $database ); $row->load( $uid ); $row->move( $inc, "type='$row->type' AND ordering > -10000 AND ordering < 10000 " ); mosRedirect( 'index2.php?option='. $option .'&task=showPlugins' ); } /** * changes the access level of a record * @param integer The increment to reorder by */ function accessMenu( $uid, $access, $option ) { global $database; switch ( $access ) { case 'accesspublic': $access = 0; break; case 'accessregistered': $access = 1; break; case 'accessspecial': $access = 2; break; } $row = new moscomprofilerPlugin( $database ); $row->load( $uid ); $row->access = $access; if ( !$row->check() ) { return $row->getError(); } if ( !$row->store() ) { return $row->getError(); } mosRedirect( 'index2.php?option='. $option .'&task=showPlugins' ); } function savePluginOrder( &$cid ) { global $database; $row = new moscomprofilerPlugin( $database ); $msg = saveOrder( $cid, $row, "\$condition = \"type='\$row->type' AND ordering > -10000 AND ordering < 10000 \";" ); mosRedirect( 'index2.php?option=com_comprofiler&task=showPlugins', $msg ); } // savePluginOrder function installPluginUpload() { global $mainframe,$_FILES; $option="com_comprofiler"; $task="showPlugins"; $client=0; //echo "installPluginUpload"; $installer = new cbInstallerPlugin(); // Check if file uploads are enabled if (!(bool)ini_get('file_uploads')) { HTML_comprofiler::showInstallMessage( "The installer can't continue before file uploads are enabled. Please use the install from directory method.", 'Installer - Error', $installer->returnTo( $option, $task, $client ) ); exit(); } // Check that the zlib is available if(!extension_loaded('zlib')) { HTML_comprofiler::showInstallMessage( "The installer can't continue before zlib is installed", 'Installer - Error', $installer->returnTo( $option, $task, $client ) ); exit(); } $userfile = mosGetParam( $_FILES, 'userfile', null ); if (!$userfile || $userfile==null) { HTML_comprofiler::showInstallMessage( 'No file selected', 'Upload new plugin - error', $installer->returnTo( $option, $task, $client )); exit(); } $userfile_name = $userfile['name']; $msg = ''; //echo "step-uploadfile/media
directory.';
}
} else {
$msg = 'Upload failed as /media
directory is not writable.';
}
} else {
$msg = 'Upload failed as /media
directory does not exist.';
}
return false;
}
function installPluginDir() {
global $mainframe,$_FILES;
$option="com_comprofiler";
$task="showPlugins";
$client=0;
// echo "installPluginDir";
$installer = new cbInstallerPlugin();
$userfile = mosGetParam( $_REQUEST, 'userfile', null );
// Check if file name exists
if (!$userfile) {
HTML_comprofiler::showInstallMessage( 'No file selected', 'Install new plugin from directory - error',
$installer->returnTo( $option, $task, $client ) );
exit();
}
$path = mosPathName( $userfile );
if (!is_dir( $path )) {
$path = dirname( $path );
}
$ret = $installer->install( $path);
HTML_comprofiler::showInstallMessage( $installer->getError(), 'Install new plugin from directory '.$userfile.' - '.($ret ? 'Success' : 'Failed'),
$installer->returnTo( $option, $task, $client ) );
}
function installPluginURL() {
global $mainframe,$_FILES;
$option="com_comprofiler";
$task="showPlugins";
$client=0;
// echo "installPluginURL";
$installer = new cbInstallerPlugin();
// Check that the zlib is available
if(!extension_loaded('zlib')) {
HTML_comprofiler::showInstallMessage( "The installer can't continue before zlib is installed",
'Installer - Error', $installer->returnTo( $option, $task, $client ) );
exit();
}
$userfileURL = mosGetParam( $_REQUEST, 'userfile', null );
if (!$userfileURL) {
HTML_comprofiler::showInstallMessage( 'No URL selected', 'Upload new plugin - error',
$installer->returnTo( $option, $task, $client ));
exit();
}
$msg = '';
$userfileName = "comprofiler_temp.zip";
//echo "step-uploadfile'.$userfileURL
.'
to /media
directory due to following error: '.$s->error;
}
} else {
$msg = 'Upload failed as /media
directory is not writable.';
}
} else {
$msg = 'Upload failed as /media
directory does not exist.';
}
return false;
}
function clearSearchBox(){
global $mainframe;
$mainframe->setUserState('searchcom_comprofiler','');
}
// Ajax: administrator/index3.php?option=com_comprofiler&task=latestVersion&no_html=1 :
function latestVersion(){
global $mosConfig_absolute_path, $mosConfig_live_site, $ueConfig;
include_once( $mosConfig_absolute_path . '/administrator/components/com_comprofiler/Snoopy.class.php' );
$s = new Snoopy();
$s->read_timeout = 90;
$s->referer = $mosConfig_live_site;
@$s->fetch('http://www.joomlapolis.com/versions/comprofilerversion.php?currentversion='.urlencode($ueConfig['version']));
$version_info = $s->results;
$version_info_pos = strpos($version_info, ":");
if ($version_info_pos === false) {
$version = $version_info;
$info = null;
} else {
$version = substr( $version_info, 0, $version_info_pos );
$info = substr( $version_info, $version_info_pos + 1 );
}
if($s->error || $s->status != 200){
echo 'Connection to update server failed: ERROR: ' . $s->error . ($s->status == -100 ? 'Timeout' : $s->status).'';
} else if($version == $ueConfig['version']){
echo '' . $version . '' . $info;
} else {
echo '' . $version . '' . $info;
}
}
// Ajax: administrator/index3.php?option=com_comprofiler&task=resendActivation&no_html=1&rid=X :
function resendActivation(){
global $database, $mosConfig_absolute_path, $mosConfig_live_site, $ueConfig, $rid;
$i=0;
if( !empty( $rid ) )
{
$row_ids = explode(",",$rid);
foreach( $row_ids as $row_id )
{
if( !empty( $row_id ) )
{
$query = "SELECT * FROM #__comprofiler c, #__users u WHERE c.id=u.id AND c.id =" . $row_id;
$database->setQuery($query);
$user = $database->loadObjectList();
$cbNotification = new cbNotification();
$cbNotification->sendFromSystem($user[0],getLangDefinition($ueConfig['reg_confirm_resend_sub']),getLangDefinition($ueConfig['reg_confirm_resend_msg'])) || die('error');
$i++;
}
}
}
else echo 'Nothing to process.';
echo ($i>0)?($i>1)?$i.' sent!':'sent!':'';
}
?>