function editList($fid = '0', $option = 'com_comprofiler', $task = 'editList') { global $_CB_database, $_CB_framework, $ueConfig; $canEditState = CBuser::getMyInstance()->authoriseAction('core.edit.state'); $row = new moscomprofilerLists($_CB_database); if ($fid) { // load the row from the db table $row->load((int) $fid); // Check if user is a super user: if (!$_CB_framework->acl->amIaSuperAdmin()) { // Check if user belongs to useraccessgroupid: if (!in_array($row->useraccessgroupid, $_CB_framework->acl->get_groups_below_me(null, true))) { echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T('Unauthorized Access')) . "'); window.history.go(-1);</script>\n"; exit; } // Check if user belongs to viewaccesslevel: if (!in_array($row->viewaccesslevel, CBuser::getMyInstance()->getAuthorisedViewLevelsIds(false))) { echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T('Unauthorized Access')) . "'); window.history.go(-1);</script>\n"; exit; } } } else { $row->published = 1; $row->default = 0; $row->col1enabled = '1'; $row->viewaccesslevel = 1; $row->useraccessgroupid = -2; $row->ordering = 999; } $lists['published'] = moscomprofilerHTML::yesnoSelectList('published', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), $row->published); $lists['default'] = moscomprofilerHTML::yesnoSelectList('default', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), $row->default); $gtree2 = array(); if (!$_CB_framework->acl->amIaSuperAdmin() && in_array((int) $row->useraccessgroupid, $_CB_framework->acl->get_groups_below_me(null, true))) { // This should always be the case: // ensure user can't add group higher than themselves: $gtree2 = array_merge($gtree2, $_CB_framework->acl->get_groups_below_me()); // vs $_CB_framework->acl->get_groups_below_me( null, true ) in tab lists } else { // Just in case we missed one, and as super-admin we should see everything: $gtree2 = array_merge($gtree2, $_CB_framework->acl->get_group_children_tree(null, 'USERS', false)); } if (!$fid) { $row->usergroupids = implode(', ', $_CB_framework->acl->get_groups_below_me(null, true)); } $usergids = explode(', ', $row->usergroupids); $ugids = array(); foreach ($usergids as $usergid) { $ugids[] = $usergid; } // build the html select list for the view level access (filtered by View Access Levels visible by the admin if not super user: $accessTree = $_CB_framework->acl->get_access_children_tree(true, false, !$_CB_framework->acl->amIaSuperAdmin()); $lists['viewaccesslevel'] = moscomprofilerHTML::selectList($accessTree, 'viewaccesslevel', 'class="inputbox"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', intval($row->viewaccesslevel), 2); $lists['usergroups'] = moscomprofilerHTML::selectList($gtree2, 'usergroups', 'size="4" MULTIPLE onblur="loadUGIDs(this);" mosReq=1 mosLabel="' . htmlspecialchars(CBTxt::T('User Groups to Include in List')) . '"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', $ugids, 1, false); // We want to use View Access Levels in Joomla 1.6, and hide old method if unused: if (isStillUsingGroupsForViewAccess($row->_tbl)) { $gtree3 = array(); $gtree3[] = moscomprofilerHTML::makeOption(-2, '- ' . CBtxt::T('Everybody') . ' -'); $gtree3[] = moscomprofilerHTML::makeOption(-1, '- ' . CBtxt::T('All Registered Users') . ' -'); if (!$_CB_framework->acl->amIaSuperAdmin() && in_array((int) $row->useraccessgroupid, $_CB_framework->acl->get_groups_below_me(null, true))) { // This should always be the case: // ensure user can't add group higher than themselves: $gtree3 = array_merge($gtree3, $_CB_framework->acl->get_groups_below_me()); // vs $_CB_framework->acl->get_groups_below_me( null, true ) in tab lists } else { // Just in case we missed one, and as super-admin we should see everything: $gtree3 = array_merge($gtree3, $_CB_framework->acl->get_group_children_tree(null, 'USERS', false)); } $lists['useraccessgroup'] = moscomprofilerHTML::selectList($gtree3, 'useraccessgroupid', 'size="4" mosReq=1 mosLabel="' . htmlspecialchars(CBTxt::T('User Group to allow access to')) . '"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', $row->useraccessgroupid, 2, false, false); } else { $lists['useraccessgroup'] = null; } $_CB_database->setQuery("SELECT f.fieldid, f.title" . "\n FROM #__comprofiler_fields AS f" . "\n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)" . "\n WHERE ( ( f.published = 1" . "\n AND f.profile > 0 ) OR ( f.name = 'username' ) " . (in_array($ueConfig['name_format'], array(1, 2, 4)) ? "OR ( f.name = 'name' ) " : '') . ")" . "\n AND p.published = 1" . "\n ORDER BY f.ordering"); $field = $_CB_database->loadObjectList(); $fields = array(); for ($i = 0, $n = count($field); $i < $n; $i++) { $fieldvalue =& $field[$i]; $fields[$fieldvalue->fieldid] = $fieldvalue->title; } //print_r(array_values($fields)); // params: $paramsEditorHtml = array(); $options = array('option' => $option, 'task' => $task, 'cid' => $row->listid); // list-specific own parameters: cbimport('cb.xml.simplexml'); $listXml = new CBSimpleXMLElement(file_get_contents($_CB_framework->getCfg('absolute_path') . '/administrator/components/com_comprofiler/xmlcb/cb.lists.xml')); $null = null; $params = new cbParamsEditorController($row->params, $listXml, $listXml, $null, null, 'cbxml', 'version', '1'); $params->setOptions($options); $listParamsEditHtml = $params->draw(null, 'views', 'view', 'name', 'editlist'); $paramsEditorHtml[] = array('title' => CBTxt::T('List parameters'), 'content' => $listParamsEditHtml); /* // params: $paramsEditorHtml = array(); $options = array( 'option' => $option, 'task' => $task, 'cid' => $row->fieldid ); // field-specific own parameters: $fieldHandler = new cbFieldHandler(); $fieldOwnParamsEditHtml = $fieldHandler->drawParamsEditor( $row, $options ); if ( $fieldOwnParamsEditHtml ) { $paramsEditorHtml[] = array( 'title' => CBTxt::T('Field-specific Parameters'), 'content' => $fieldOwnParamsEditHtml ); } // additional non-specific other parameters: $fieldsParamsPlugins = $_PLUGINS->getUserFieldParamsPluginIds(); foreach ($fieldsParamsPlugins as $pluginId => $fieldParamHandlerClassName ) { $fieldParamHandler = new $fieldParamHandlerClassName( $pluginId, $row ); // cbFieldParamsHandler(); $addParamsHtml = $fieldParamHandler->drawParamsEditor( $options ); if ( $addParamsHtml ) { $addParamsTitle = $fieldParamHandler->getFieldsParamsLabel(); $paramsEditorHtml[] = array( 'title' => $addParamsTitle, 'content' => $addParamsHtml ); } } */ HTML_comprofiler::editList($row, $lists, $fields, $option, $fid, $paramsEditorHtml); }
function editList( $fid='0', $option='com_comprofiler', $task = 'editList') { global $_CB_database, $_CB_framework, $ueConfig; $row = new moscomprofilerLists( $_CB_database ); if ( $fid ) { // load the row from the db table $row->load( (int) $fid ); } else { $row->col1enabled = '1'; } $lists['published'] = moscomprofilerHTML::yesnoSelectList( 'published', 'class="inputbox" size="1"', $row->published ); $lists['default'] = moscomprofilerHTML::yesnoSelectList( 'default', 'class="inputbox" size="1"', $row->default ); /* if ( checkJversion() <= 0 ) { $my_groups = $_CB_framework->acl->get_object_groups( 'users', $_CB_framework->myId(), 'ARO' ); } else { $aro_id = $_CB_framework->acl->get_object_id( 'users', $_CB_framework->myId(), 'ARO' ); $my_groups = $_CB_framework->acl->get_object_groups( $aro_id, 'ARO' ); } */ $gtree2 = array(); $gtree2 = array_merge( $gtree2, $_CB_framework->acl->get_group_children_tree( null, 'USERS', false )); $usergids = explode( ', ', $row->usergroupids ); $ugids = array(); foreach($usergids as $usergid) { $ugids[] = $usergid; } $lists['usergroups'] = moscomprofilerHTML::selectList( $gtree2, 'usergroups', 'size="4" MULTIPLE onblur="loadUGIDs(this);" mosReq=1 mosLabel="' . htmlspecialchars( CBTxt::T('User Groups') ) . '"', 'value', 'text', $ugids, 1, false ); $gtree3 = array(); $gtree3[] = moscomprofilerHTML::makeOption( -2 , '- ' . CBtxt::T('Everybody') . ' -' ); $gtree3[] = moscomprofilerHTML::makeOption( -1 , '- ' . CBtxt::T('All Registered Users') . ' -' ); $gtree3 = array_merge( $gtree3, $_CB_framework->acl->get_group_children_tree( null, 'USERS', false )); $lists['useraccessgroup'] = moscomprofilerHTML::selectList( $gtree3, 'useraccessgroupid', 'size="4"', 'value', 'text', $row->useraccessgroupid, 2, false, false ); $_CB_database->setQuery( "SELECT f.fieldid, f.title" . "\n FROM #__comprofiler_fields AS f" . "\n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)" . "\n WHERE ( ( f.published = 1" . "\n AND f.profile > 0 ) OR ( f.name = 'username' ) " . ( in_array( $ueConfig['name_format'], array( 1, 2, 4 ) ) ? "OR ( f.name = 'name' ) " : '' ) . ")" . "\n AND p.published = 1" . "\n ORDER BY f.ordering" ); $field = $_CB_database->loadObjectList(); $fields = array(); for ( $i = 0, $n = count( $field ) ; $i < $n ; $i++ ) { $fieldvalue =& $field[$i]; $fields[$fieldvalue->title] = $fieldvalue->fieldid; } //print_r(array_values($fields)); // params: $paramsEditorHtml = array(); $options = array( 'option' => $option, 'task' => $task, 'cid' => $row->listid ); // list-specific own parameters: cbimport( 'cb.xml.simplexml' ); $listXml = new CBSimpleXMLElement( file_get_contents( $_CB_framework->getCfg( 'absolute_path' ) . '/administrator/components/com_comprofiler/xmlcb/cb.lists.xml' ) ); $null = null; $params = new cbParamsEditorController( $row->params, $listXml, $listXml, $null, null, 'cbxml', 'version', '1' ); $params->setOptions( $options ); $listParamsEditHtml = $params->draw( null, 'views', 'view', 'name', 'editlist' ); $paramsEditorHtml[] = array( 'title' => CBTxt::T('List parameters'), 'content' => $listParamsEditHtml ); /* // params: $paramsEditorHtml = array(); $options = array( 'option' => $option, 'task' => $task, 'cid' => $row->fieldid ); // field-specific own parameters: $fieldHandler = new cbFieldHandler(); $fieldOwnParamsEditHtml = $fieldHandler->drawParamsEditor( $row, $options ); if ( $fieldOwnParamsEditHtml ) { $paramsEditorHtml[] = array( 'title' => CBTxt::T('Field-specific Parameters'), 'content' => $fieldOwnParamsEditHtml ); } // additional non-specific other parameters: $fieldsParamsPlugins = $_PLUGINS->getUserFieldParamsPluginIds(); foreach ($fieldsParamsPlugins as $pluginId => $fieldParamHandlerClassName ) { $fieldParamHandler = new $fieldParamHandlerClassName( $pluginId, $row ); // cbFieldParamsHandler(); $addParamsHtml = $fieldParamHandler->drawParamsEditor( $options ); if ( $addParamsHtml ) { $addParamsTitle = $fieldParamHandler->getFieldsParamsLabel(); $paramsEditorHtml[] = array( 'title' => $addParamsTitle, 'content' => $addParamsHtml ); } } */ HTML_comprofiler::editList( $row, $lists,$fields, $option, $fid, $paramsEditorHtml ); }