global $_CB_Admin_Done, $_CB_database; if (!$_CB_Admin_Done) { if (defined('JPATH_ADMINISTRATOR')) { $_CB_joomla_adminpath = JPATH_ADMINISTRATOR; } else { $_CB_joomla_adminpath = $mainframe->getCfg('absolute_path') . '/administrator'; } ob_start(); require_once $_CB_joomla_adminpath . '/components/com_comprofiler/admin.comprofiler.controller.php'; $_CB_Admin_Done = ob_get_contents(); ob_end_clean(); } // Backend toolbar is now in comprofiler.toolbar.php, except for plugin_menus: switch ($task) { case 'pluginmenu': $plugin = new moscomprofilerPlugin($_CB_database); $result = $plugin->load((int) cbGetParam($_GET, 'pluginid', -1)); if ($result != null) { global $_PLUGINS; $pluginMenuToolbarFile = $_CB_framework->getCfg('absolute_path') . '/' . $_PLUGINS->getPluginRelPath($plugin) . '/toolbar.' . $plugin->element . '.php'; if (file_exists($pluginMenuToolbarFile)) { require_once $mainframe->getPath('toolbar_html'); include_once $pluginMenuToolbarFile; break; } } // done in comprofiler.toolbar.php: TOOLBAR_usersextras::_DEFAULT_PLUGIN(); break; default: break; }
function editfield( &$row, $lists, $fieldvalues, $option, $paramsEditorHtml ) { global $_CB_framework, $_CB_database; _CBsecureAboveForm('editfield'); outputCbTemplate( 2 ); outputCbJs( 2 ); initToolTip( 2 ); global $_CB_Backend_Title; $_CB_Backend_Title = array( 0 => array( 'cbicon-48-fields', CBTxt::T('Community Builder Field') . ': <small>' . ( $row->fieldid ? CBTxt::T('Edit') . ' [ ' . htmlspecialchars( getLangDefinition( $row->title ) ) . ' ] ' : CBTxt::T('New') ) . '</small>' ) ); if ( $row->fieldid && ( ! $row->published ) ) { echo '<div class="cbWarning">' . CBTxt::T('Field is not published') . '</div>' . "\n"; } if ( $row->pluginid ) { $plugin = new moscomprofilerPlugin( $_CB_database ); if ( ! $plugin->load( (int) $row->pluginid ) ) { echo '<div class="cbWarning">' . CBTxt::T('Plugin is not installed') . '</div>' . "\n"; } else { if ( ! $plugin->published ) { echo '<div class="cbWarning">' . CBTxt::T('Plugin is not published') . '</div>' . "\n"; } } } // $_CB_framework->outputCbJQuery( "var cbTypeState = $('#type').val(); $('#type').change(function() { if ( cbTypeState != $('#type').val() ) submitbutton('reloadField') } ).change();" ); // outputCbJs( 2 ); if($row->fieldid > 0) { $_CB_framework->outputCbJQuery( 'document.adminForm.name.readOnly=true; document.adminForm.name.disabled=true; document.adminForm.type.disabled=true;'); } // disableAll(); // selType('".$row->type."'); $editorSave_description = $_CB_framework->saveCmsEditorJS( 'description' ); $editorSave_default = $_CB_framework->saveCmsEditorJS( 'default' ); ob_start(); ?> function submitbutton(pressbutton) { if ( (pressbutton == 'showField') || (pressbutton == 'reloadField') ) { document.adminForm.type.disabled=false; <?php echo $editorSave_description; if ( $row->type == 'editorta' ) { echo $editorSave_default; } ?> submitform(pressbutton); return; } var coll = document.adminForm; var errorMSG = ''; var iserror=0; if (coll != null) { var elements = coll.elements; // loop through all input elements in form for (var i=0; i < elements.length; i++) { // check if element is mandatory; here mosReq=1 if ( (typeof(elements.item(i).getAttribute('mosReq')) != "undefined") && (elements.item(i).getAttribute('mosReq') == 1) ) { if (elements.item(i).value == '') { //alert(elements.item(i).getAttribute('mosLabel') + ':' + elements.item(i).getAttribute('mosReq')); // add up all error messages errorMSG += elements.item(i).getAttribute('mosLabel') + ' : <?php echo _UE_REQUIRED_ERROR; ?>\n'; // notify user by changing background color, in this case to red elements.item(i).style.backgroundColor = "red"; iserror=1; } } } } if(iserror==1) { alert(errorMSG); } else { document.adminForm.type.disabled=false; <?php echo $editorSave_description; if ( $row->type == 'editorta' ) { echo $editorSave_default; } ?> submitform(pressbutton); } } <?php $jsTop = ob_get_contents(); ob_end_clean(); $_CB_framework->document->addHeadScriptDeclaration( $jsTop ); ob_start(); ?> function insertRow() { // Create and insert rows and cells into the first body. // var i = $('#adminForm input[name=valueCount]').val( Number( $('#adminForm input[name=valueCount]').val() ) + 1 ).val(); // $('#fieldValuesBody').append('<tr><td><input id=\"vNames'+i+'\" name=\"vNames[' + i + ']\" /></td></tr>'); var i = $('#adminForm input[name=valueCount]').val( Number( $('#adminForm input[name=valueCount]').val() ) + 1 ).val(); $('#fieldValuesList').append('<li><input id=\"vNames'+i+'\" name=\"vNames[]\" /></li>'); $('#vNames'+i).hide().slideDown('medium').focus(); } function disableAll() { $('#divValues,#divColsRows,#divWeb,#divText').hide().css('visibility','visible'); $('#vNames0').attr('mosReq','0'); } function selType(sType) { var elem; //alert(sType); disableAll(); switch (sType) { case 'editorta': case 'textarea': $('#divText,#divColsRows').show(); break; case 'emailaddress': case 'password': case 'text': case 'integer': case 'predefined': $('#divText').show(); break; case 'select': case 'multiselect': $('#divValues').show(); $('#vNames0').attr('mosReq','1'); break; case 'radio': case 'multicheckbox': $('#divValues,#divColsRows').show(); $('#vNames0').attr('mosReq','1'); break; case 'webaddress': $('#divText,#divWeb').show(); break; case 'delimiter': default: } } function prep4SQL(o){ if(o.value!='') { var cbsqloldvalue, cbsqlnewvalue; o.value=o.value.replace('cb_',''); cbsqloldvalue = o.value; o.value=o.value.replace(/[^a-zA-Z0-9]+/g,''); cbsqlnewvalue = o.value; o.value='cb_' + o.value; if (cbsqloldvalue != cbsqlnewvalue) { alert('<?php echo addslashes( CBTxt::T('Warning: SQL name of field has been changed to fit SQL constraints') ); ?>'); } } } var cbTypeState = $('#type').val(); $('#type').change(function() { selType(this.options[this.selectedIndex].value); if ( cbTypeState != $('#type').val() ) submitbutton('reloadField') } ).change(); $('#name').change(function() { if ( ! $('#name').attr('disabled') ) { prep4SQL(this); } } ).change(); $('#insertrow').click(function() { insertRow(); } ); $('#fieldValuesList').sortable( { items: 'li', containment: 'parent', animated: true, placeholder: 'fieldValuesList-selected' } ); // $('#mainparams').sortable( { items: 'tr', containment: 'parent', animated: true } ); /* $('#adminForm').submit(function() { return submitbutton(''); } ); */ disableAll(); selType('<?php echo $row->type; ?>'); <?php $jsContent = ob_get_contents(); ob_end_clean(); $_CB_framework->outputCbJQuery( $jsContent, 'ui-all' ); ?> <form action="<?php echo $_CB_framework->backendUrl( 'index.php?option=com_comprofiler&task=saveField' ); ?>" method="POST" id="adminForm" name="adminForm"> <?php if ( $paramsEditorHtml ) { ?> <table cellspacing="0" cellpadding="0" width="100%"> <tr valign="top"> <td width="60%" valign="top"> <?php } ?> <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform" id="mainparams"> <tr> <td width="20%"><?php echo CBTxt::T('Type'); ?>:</td> <td width="20%"><?php echo $lists['type']; ?></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('Tab'); ?>:</td> <td width="20%"><?php echo $lists['tabs']; ?></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('Name'); ?>:</td> <td align=left width="20%"><input type="text" id="name" name="name" maxlength='64' mosReq="1" mosLabel="<?php echo htmlspecialchars( CBTxt::T('Name') ); ?>" class="inputbox" value="<?php echo htmlspecialchars( $row->name ); ?>" /></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('Title'); ?>:</td> <td width="20%" align=left><input type="text" name="title" mosReq="1" mosLabel="<?php echo htmlspecialchars( CBTxt::T('Title') ); ?>" class="inputbox" value="<?php echo htmlspecialchars( $row->title ); ?>" /></td> <td> </td> </tr> <tr> <td colspan="3"><?php echo CBTxt::T('Description/"i" field-tip: text or HTML'); ?>:</td> </tr> <tr> <td colspan="3" align=left><?php echo $_CB_framework->displayCmsEditor( 'description', $row->description, 600 /* ( $row->type == 'delimiter' ? 600 : 286 ) */ , 200, 50, 7 ); // <textarea name="description" cols="40" rows="6" maxlength='255' mosReq="0" mosLabel="Description" class="inputbox">< ?php echo htmlspecialchars( $row->description ); ? ></textarea> ?></td> </tr> <?php if ( $row->type != 'delimiter' ) { ?> <tr> <?php if ( $row->type == 'editorta' ) { ?> <td colspan="3"><?php echo CBTxt::T('Pre-filled default value at registration only'); ?>:</td> </tr> <tr> <td colspan="3"><?php echo $_CB_framework->displayCmsEditor( 'cb_default', $row->default, 600, 200, 50, 7 ); ?></td> <?php } else { ?> <td width="20%"><?php echo CBTxt::T('Pre-filled default value at registration only'); ?>:</td> <td width="20%"> <input type="text" name="cb_default" mosLabel="<?php echo htmlspecialchars( CBTxt::T('Default value') ); ?>" class="inputbox" value="<?php echo htmlspecialchars( $row->default ); ?>" /> </td> <td> </td><?php } ?> </tr> <?php } ?> <tr> <td width="20%"><?php echo CBTxt::T('Required'); ?>?:</td> <td width="20%"><?php echo $lists['required']; ?></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('Show on Profile'); ?>?:</td> <td width="20%"><?php echo $lists['profile']; ?></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('Display field title in Profile'); ?>?:</td> <td width="20%"><?php echo $lists['displaytitle']; ?></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('Searchable in users-lists'); ?>?:</td> <td width="20%"><?php echo $lists['searchable']; ?></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('User Read Only'); ?>?:</td> <td width="20%"><?php echo $lists['readonly']; ?></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('Show at Registration'); ?>?:</td> <td width="20%"><?php echo $lists['registration']; ?></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('Published'); ?>:</td> <td width="20%"><?php echo ( $row->sys == 1 ? ( $row->published ? _UE_YES : _UE_NO ) . ' (' . CBTxt::T('System-fields cannot be published/unpublished here.') . ( in_array( $row->name, array( 'name', 'firstname', 'middlename', 'lastname' ) ) ? ' ' . CBTxt::T('Name-fields publishing depends on your setting in global CB config.') . ')' : ')' ) : $lists['published'] ); ?></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('Size'); ?>:</td> <td width="20%"><input type="text" name="size" mosLabel="<?php echo htmlspecialchars( CBTxt::T('Size') ); ?>" class="inputbox" value="<?php echo htmlspecialchars( $row->size ); ?>" /></td> <td> </td> </tr> </table> <div id="page1" class="pagetext"> </div> <div id="divText" class="pagetext"> <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform"> <tr> <td width="20%"><?php echo CBTxt::T('Max Length'); ?>:</td> <td width="20%"><input type="text" name="maxlength" mosLabel="<?php echo htmlspecialchars( CBTxt::T('Max Length') ); ?>" class="inputbox" value="<?php echo htmlspecialchars( $row->maxlength ); ?>" /></td> <td> </td> </tr> </table> </div> <div id="divColsRows" class="pagetext"> <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform"> <tr> <td width="20%"><?php echo CBTxt::T('Cols'); ?>:</td> <td width="20%"><input type="text" name="cols" mosLabel="<?php echo htmlspecialchars( CBTxt::T('Cols') ); ?>" class="inputbox" value="<?php echo htmlspecialchars( $row->cols ); ?>" /></td> <td> </td> </tr> <tr> <td width="20%"><?php echo CBTxt::T('Rows'); ?>:</td> <td width="20%"><input type="text" name="rows" mosLabel="<?php echo htmlspecialchars( CBTxt::T('Rows') ); ?>" class="inputbox" value="<?php echo htmlspecialchars( $row->rows ); ?>" /></td> <td> </td> </tr> </table> </div> <div id="divWeb" class="pagetext"> <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform"> <tr> <td width="20%"><?php echo CBTxt::T('Type'); ?>:</td> <td width="20%"><?php echo $lists['webaddresstypes']; ?></td> <td> </td> </tr> </table> </div> <div id="divValues" style="text-align:left;"> <?php echo CBTxt::T('Use the table below to add new values.'); ?><br /> <input type=button id="insertrow" value="<?php echo htmlspecialchars( CBTxt::T('Add a Value') ); ?>" /> <table align="left" id="divFieldValues" cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform" > <thead> <tr> <th width="20%"><?php echo CBTxt::T('Name'); ?></th> </tr> </thead> <tbody id="fieldValuesBody"> <tr> <td> <ul id="fieldValuesList"> <?php //echo "count:".count( $fieldvalues ); //print_r (array_values($fieldvalues)); for ($i=0, $n=count( $fieldvalues ); $i < $n; $i++) { //print "count:".$i; $fieldvalue = $fieldvalues[$i]; if ($i==0) $req =1; else $req = 0; echo "\n<li><input type='text' mosReq='$req' mosLabel='" . htmlspecialchars( CBTxt::T('Value') ) . "' value=\"" . htmlspecialchars( $fieldvalue->fieldtitle ) . "\" name=\"vNames[]\" id=\"vNames".$i."\" /></li>\n"; } if(count( $fieldvalues )< 1) { echo "\n<li><input type='text' mosReq='0' mosLabel='" . htmlspecialchars( CBTxt::T('Value') ) . "' value='' name='vNames[]' /></li>\n"; $i=0; } ?> </ul> </td> </tr> </tbody> </table> </div> <?php /* //echo "count:".count( $fieldvalues ); //print_r (array_values($fieldvalues)); for ($i=0, $n=count( $fieldvalues ); $i < $n; $i++) { //print "count:".$i; $fieldvalue = $fieldvalues[$i]; if ($i==0) $req =1; else $req = 0; echo "<tr>\n<td width=\"20%\"><input type='text' mosReq='$req' mosLabel='" . htmlspecialchars( CBTxt::T('Value') ) . "' value=\"" . htmlspecialchars( $fieldvalue->fieldtitle ) . "\" name=\"vNames[".$i."]\" id=\"vNames".$i."\" /></td></tr>\n"; } if(count( $fieldvalues )< 1) { echo "<tr>\n<td width=\"20%\"><input type='text' mosReq='0' mosLabel='" . htmlspecialchars( CBTxt::T('Value') ) . "' value='' name=vNames[0] /></td></tr>\n"; $i=0; } ?> </tbody> </table> </div> <?php */ if ( $paramsEditorHtml ) { ?> </td> <td width="40%" valign="top"> <?php 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> <?php } ?> <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform"> <tr> <td colspan="3"> </td> </tr> </table> <input type="hidden" name="valueCount" value=<?php echo $i; ?> /> <input type="hidden" name="oldtabid" value="<?php echo htmlspecialchars( $row->tabid ); ?>" /> <input type="hidden" name="fieldid" value="<?php echo (int) $row->fieldid; ?>" /> <input type="hidden" name="ordering" value="<?php echo htmlspecialchars( $row->ordering ); ?>" /> <input type="hidden" name="option" value="<?php echo $option; ?>" /> <input type="hidden" name="task" value="" /> <?php echo cbGetSpoofInputTag( 'field' ); ?> </form> <?php }
/** * Custom install method * @param boolean True if installing from directory */ function install($p_fromdir = null) { global $_CB_framework, $_CB_database, $ueConfig, $_PLUGINS; if (!$this->preInstallCheck($p_fromdir, $this->elementType)) { return false; } $cbInstallXML =& $this->i_xmldocument; // Get name $e =& $cbInstallXML->getElementByPath('name'); $this->elementName($e->data()); $cleanedElementName = strtolower(str_replace(array(" ", "."), array("", "_"), $this->elementName())); // Get plugin filename $files_element =& $cbInstallXML->getElementByPath('files'); foreach ($files_element->children() as $file) { if ($file->attributes("plugin")) { $this->elementSpecial($file->attributes("plugin")); } } $fileNopathNoext = null; $matches = array(); if (preg_match("/^.*[\\/\\\\](.*)\\..*\$/", $this->installFilename(), $matches)) { $fileNopathNoext = $matches[1]; } if (!($fileNopathNoext && $this->elementSpecial() == $fileNopathNoext)) { $this->setError(1, 'Installation filename `' . $fileNopathNoext . '` (with .xml) does not match main php file plugin attribute `' . $this->elementSpecial() . '` in the plugin xml file<br />'); return false; } $cleanedMainFileName = strtolower(str_replace(array(" ", "."), array("", "_"), $this->elementSpecial())); // check version $v =& $cbInstallXML->getElementByPath('version'); $version = $v->data(); if ($version == $ueConfig['version'] || ($version == "1.9" || $version == "1.9 RC" || $version == "1.8.1" || $version == "1.8" || $version == "1.8 RC3" || $version == "1.8 RC2" || $version == "1.8 RC" || $version == "1.7.1" || $version == "1.7" || $version == "1.7 RC" || $version == "1.4" || $version == "1.4 RC" || $version == "1.3.1" || $version == "1.3" || $version == "1.2.3" || $version == "1.2.2" || $version == "1.2.1" || $version == "1.2" || $version == "1.2 RC 4" || $version == "1.2 RC 3" || $version == "1.2 RC 2" || $version == "1.2 RC" || $version == "1.0 RC 2" || $version == "1.0" || $version == "1.0.1" || $version == "1.0.2" || $version == "1.1")) { } else { $this->setError(1, 'Plugin version (' . $version . ') different from Community Builder version (' . $ueConfig['version'] . ')'); return false; } $backendMenu = ""; $adminmenusnode =& $cbInstallXML->getElementByPath('adminmenus'); if ($adminmenusnode) { $menusArr = array(); //cycle through each menu foreach ($adminmenusnode->children() as $menu) { if ($menu->name() == "menu") { $action = $menu->attributes('action'); $text = getLangDefinition($menu->data()); $menusArr[] = $text . ":" . $action; } } $backendMenu = implode(",", $menusArr); } $folder = strtolower($cbInstallXML->attributes('group')); if (cbStartOfStringMatch($folder, '/')) { $this->elementDir($_CB_framework->getCfg('absolute_path') . $folder . '/'); $subFolder = $folder; } else { $subFolder = ($folder == 'user' ? 'plug_' : '') . $cleanedElementName; $this->elementDir($_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/' . $folder . '/' . $subFolder . '/'); } $upgradeMethod = $this->installMethod($cbInstallXML->attributes('method')); if (file_exists($this->elementDir()) && !$upgradeMethod) { $this->setError(1, 'Another plugin is already using directory: "' . $this->elementDir() . '"'); return false; } $parentFolder = preg_replace('/\\/[^\\/]*\\/?$/', '/', $this->elementDir()); if (!file_exists($parentFolder)) { $this->setError(1, sprintf('The directory in which the plugin should install does not exist: probably the parent extension is not installed. Install parent extension first. Plugin parent directory missing: "%s" and plugin directory specified by installer for installation "%s"', $parentFolder, $this->elementDir())); return false; } if (!file_exists($this->elementDir()) && !$this->mosMakePath($this->elementDir())) { $this->setError(1, 'Failed to create directory' . ' "' . $this->elementDir() . '"'); return false; } // Copy files from package: if ($this->parseFiles('files', 'plugin', 'No file is marked as plugin file') === false) { $this->cleanupInstall(null, $this->elementDir()); // try removing directory and content just created successfully return false; } // Copy XML file from package (needed for creating fields of new types and so on): if ($this->copySetupFile('front') === false) { $this->cleanupInstall(null, $this->elementDir()); // try removing directory and content just created successfully return false; } // Check to see if plugin already exists in db $_CB_database->setQuery("SELECT id FROM #__comprofiler_plugin WHERE element = '" . $this->elementSpecial() . "' AND folder = '" . $subFolder . "'"); if (!$_CB_database->query()) { $this->setError(1, 'SQL error' . ': ' . $_CB_database->stderr(true)); $this->cleanupInstall(null, $this->elementDir()); // try removing directory and content just created successfully return false; } $pluginid = $_CB_database->loadResult(); $pluginRowWasNotExisting = !$pluginid; $row = new moscomprofilerPlugin($_CB_database); $row->id = $pluginid; if (!$pluginid) { $row->name = $this->elementName(); $row->ordering = 99; } $row->type = $folder; if ($row->type == 'language') { $row->published = 1; } $row->folder = $subFolder; $row->backend_menu = $backendMenu; $row->iscore = 0; $row->access = 0; $row->client_id = 0; $row->element = $this->elementSpecial(); if (!$row->store()) { $this->setError(1, 'SQL error' . ': ' . $row->getError()); $this->cleanupInstall(null, $this->elementDir()); // try removing directory and content just created successfully return false; } if (!$pluginid) { $pluginid = $_CB_database->insertid(); } $_PLUGINS->_setLoading($row, true); // Are there any Database statements ?? $db =& $cbInstallXML->getElementByPath('database'); if ($db !== false && count($db->children()) > 0) { cbimport('cb.sql.upgrader'); $sqlUpgrader = new CBSQLupgrader($_CB_database, false); //$sqlUpgrader->setDryRun( true ); $success = $sqlUpgrader->checkXmlDatabaseDescription($db, $cleanedElementName, true, null); /* var_dump( $success ); echo "<br>\nERRORS: " . $sqlUpgrader->getErrors( "<br /><br />\n\n", "<br />\n" ); echo "<br>\nLOGS: " . $sqlUpgrader->getLogs( "<br /><br />\n\n", "<br />\n" ); exit; */ if (!$success) { $this->setError(1, "Plugin database XML SQL Error " . $sqlUpgrader->getErrors()); if ($pluginRowWasNotExisting) { $this->deleteTabAndFieldsOfPlugin($row->id); // delete tabs and private fields of plugin $row->delete(); } $this->cleanupInstall(null, $this->elementDir()); // try removing directory and content just created successfully return false; } } $e =& $cbInstallXML->getElementByPath('description'); if ($e !== false) { $desc = $this->elementName() . '<div>' . $e->data() . '</div>'; $this->setError(0, $desc); } //If type equals user then check for tabs and fields if ($folder == 'user') { $tabsnode =& $cbInstallXML->getElementByPath('tabs'); if ($tabsnode) { //cycle through each tab foreach ($tabsnode->children() as $tab) { if ($tab->name() == 'tab') { //install each tab $tabid = $this->installTab($pluginid, $tab); if ($tabid) { //get all fields in the tab $fieldsnode = $tab->getElementByPath('fields'); if ($fieldsnode) { //cycle through each field foreach ($fieldsnode->children() as $field) { if ($field->name() == "field") { //install each field //echo "installing field..."; $fieldid = $this->installField($pluginid, $tabid, $field); //get all fieldvalues for the field //cycle through each fieldValue foreach ($field->children() as $fieldValue) { if ($fieldValue->name() == "fieldvalue") { $this->installFieldValue($fieldid, $fieldValue); } } } } } } else { if ($pluginRowWasNotExisting) { if ($db) { $success = $sqlUpgrader->checkXmlDatabaseDescription($db, $cleanedElementName, 'drop', null); } $this->deleteTabAndFieldsOfPlugin($row->id); // delete tabs and private fields of plugin $row->delete(); } $this->cleanupInstall(null, $this->elementDir()); // try removing directory and content just created successfully return false; } } } } // (re)install field types of plugin: $fieldtypes =& $cbInstallXML->getElementByPath('fieldtypes'); if ($fieldtypes) { foreach ($fieldtypes->children() as $typ) { if ($typ->name() == 'field') { $this->installFieldType($pluginid, $typ->attributes('type')); } } } } // Are there any SQL queries?? $query_element =& $cbInstallXML->getElementByPath('install/queries'); if ($query_element) { foreach ($query_element->children() as $query) { $_CB_database->setQuery(trim($query->data())); if (!$_CB_database->query()) { $this->setError(1, "SQL Error " . $_CB_database->stderr(true)); if ($pluginRowWasNotExisting) { if ($db) { $success = $sqlUpgrader->checkXmlDatabaseDescription($db, $cleanedElementName, 'drop', null); } $this->deleteTabAndFieldsOfPlugin($row->id); // delete tabs and private fields of plugin $row->delete(); } $this->cleanupInstall(null, $this->elementDir()); // try removing directory and content just created successfully return false; } } } // Is there an installfile $installfile_elemet =& $cbInstallXML->getElementByPath('installfile'); if ($installfile_elemet) { // check if parse files has already copied the install.component.php file (error in 3rd party xml's!) if (!file_exists($this->elementDir() . $installfile_elemet->data())) { if (!$this->copyFiles($this->installDir(), $this->elementDir(), array($installfile_elemet->data()), $this->installMethod())) { $this->setError(1, 'Could not copy PHP install file.'); if ($pluginRowWasNotExisting) { if ($db) { $success = $sqlUpgrader->checkXmlDatabaseDescription($db, $cleanedElementName, 'drop', null); } $this->deleteTabAndFieldsOfPlugin($row->id); // delete tabs and private fields of plugin $row->delete(); } $this->cleanupInstall(null, $this->elementDir()); // try removing directory and content just created successfully return false; } } $this->hasInstallfile(true); $this->installFile($installfile_elemet->data()); } // Is there an uninstallfile $uninstallfile_elemet =& $cbInstallXML->getElementByPath('uninstallfile'); if ($uninstallfile_elemet) { if (!file_exists($this->elementDir() . $uninstallfile_elemet->data())) { if (!$this->copyFiles($this->installDir(), $this->elementDir(), array($uninstallfile_elemet->data(), $this->installMethod()))) { $this->setError(1, 'Could not copy PHP uninstall file'); if ($pluginRowWasNotExisting) { if ($db) { $success = $sqlUpgrader->checkXmlDatabaseDescription($db, $cleanedElementName, 'drop', null); } $this->deleteTabAndFieldsOfPlugin($row->id); // delete tabs and private fields of plugin $row->delete(); } $this->cleanupInstall(null, $this->elementDir()); // try removing directory and content just created successfully return false; } } } if ($this->hasInstallfile()) { if (is_file($this->elementDir() . $this->installFile())) { require_once $this->elementDir() . $this->installFile(); $ret = call_user_func_array('plug_' . $cleanedMainFileName . '_install', array()); if ($ret != '') { $this->setError(0, $desc . $ret); } } } if ($db !== false && count($db->children()) > 0) { HTML_comprofiler::fixcbdbShowResults($sqlUpgrader, true, false, $success, array(), array(), $this->elementName(), 1, false); } return true; }
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> </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 }
/** * changes the access level of a record * @param integer The increment to reorder by */ function accessMenu($uid, $access, $option) { global $_CB_framework, $_CB_database; switch ($access) { case 'accesspublic': $access = 0; break; case 'accessregistered': $access = 1; break; case 'accessspecial': $access = 2; break; } $row = new moscomprofilerPlugin($_CB_database); $row->load((int) $uid); $row->access = $access; if (!$row->check()) { return $row->getError(); } if (!$row->store()) { return $row->getError(); } cbRedirect($_CB_framework->backendUrl("index.php?option={$option}&task=showPlugins")); return null; }
/** * 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 pluginMenu( $option, $uid) { global $_CB_database, $_CB_framework, $_PLUGINS, $_GET; if ( ! $uid ) { echo "<script type=\"text/javascript\">alert('" . addslashes( CBTxt::T('No plugin selected') ) . "'); document.location.href='" . $_CB_framework->backendUrl( "index.php?option=$option" ) . "'</script>\n"; exit(0); } $this->_importNeeded(); $row = new moscomprofilerPlugin($_CB_database); // load the row from the db table $row->load( (int) $uid ); // fail if checked out not by 'me' if ($row->checked_out && $row->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'), $row->name) ) . "'); document.location.href='" . $_CB_framework->backendUrl( "index.php?option=$option" ) . "'</script>\n"; exit(0); } $basepath = $_CB_framework->getCfg('absolute_path') . '/' . $_PLUGINS->getPluginRelPath( $row ) . '/'; $phpfile = $basepath . "admin." . $row->element . '.php'; // see if there is an xml install file, must be same name as element if (file_exists( $phpfile )) { // get params values if ( $row->type !== "language" ) { $_PLUGINS->loadPluginGroup($row->type,array( (int) $row->id), 0); } $menu = cbGetParam( $_REQUEST, 'menu' ); $element =& $_PLUGINS->loadPluginXML( 'menu', $menu, $row->id ); // xml file for plugin $params = new cbParamsEditorController( $row->params, $element, $element, $row ); if ( cbGetParam( $_GET, 'no_html', 0 ) != 1 ) { outputCbTemplate( 2 ); outputCbJs( 2 ); initToolTip( 2 ); } require_once( $phpfile ); $classname = $row->element . "Admin"; $adminClass = new $classname(); echo $adminClass->menu( $row, $menu, $params ); } else { echo "<script type=\"text/javascript\">alert('" . addslashes( sprintf(CBTxt::T('The plugin %s has no administrator file %s'), $row->name, $phpfile . '-' .$uid ) ) . "'); document.location.href='" . $_CB_framework->backendUrl( "index.php?option=$option" ) . "'</script>\n"; exit(0); } }
/** * save config * * @param array $config */ private function saveConfig( $config, $user, $plugin ) { global $_CB_database; $row = new moscomprofilerPlugin( $_CB_database ); if ( $plugin->id ) { $row->load( $plugin->id ); } $params = cbgjClass::parseParams( $config, true ); $row->params = trim( $params->toIniString() ); if ( $row->getError() || ( ! $row->store() ) ) { $this->showConfig( $user, $plugin, CBTxt::P( 'Config failed to save! Error: [error]', array( '[error]' => $row->getError() ) ) ); return; } cbgjClass::getPluginURL( array( 'config' ), CBTxt::T( 'Config saved successfully!' ), false, true ); }