public function getFieldRow( &$field, &$user, $output, $formatting, $reason, $list_compare_types ) { if ( ( ! in_array( $reason, array( 'register', 'edit' ) ) ) || $user->id ) { return null; } return parent::getFieldRow( $field, $user, $output, $formatting, $reason, $list_compare_types ); }
/** * Checks the all data content tables of comprofiler fields and upgrades if needed * Backend-use only. * @access private * * @param boolean $upgrade False: only check table, True: upgrades table (depending on $dryRun) * @param boolean $dryRun True: doesn't do the modifying queries, but lists them, False: does the job * @return string Message to display */ function checkAllCBfieldsDb( $upgrade = false, $dryRun = false ) { cbimport( 'cb.sql.upgrader' ); $this->_sqlUpgrader = new CBSQLupgrader( $this->_db, $this->_silentWhenOK ); $this->_sqlUpgrader->setDryRun( $dryRun ); $this->_db->setQuery( "SELECT f.*" // f.fieldid, f.title, f.name, f.description, f.type, f.required, f.published, " // . "f.profile, f.ordering, f.registration, f.searchable, f.pluginid, f.sys, f.tablecolumns, " // . ", t.title AS 'tab', t.enabled AS 'tabenabled', t.pluginid AS 'tabpluginid', " // . "p.name AS pluginname, p.published AS pluginpublished, " // . "pf.name AS fieldpluginname, pf.published AS fieldpluginpublished " . "\n FROM #__comprofiler_fields AS f" . "\n INNER JOIN #__comprofiler_tabs AS t ON ( (f.tabid = t.tabid) AND (t.fields = 1) ) " . "\n LEFT JOIN #__comprofiler_plugin AS p ON p.id = t.pluginid" . "\n LEFT JOIN #__comprofiler_plugin AS pf ON pf.id = f.pluginid" . "\n ORDER BY t.ordering, f.ordering" ); $rows = $this->_db->loadObjectList( 'fieldid', 'moscomprofilerFields', array( &$this->_db ) ); if ( $this->_db->getErrorNum() ) { echo $this->_db->stderr(); return false; } $ret = true; foreach ( $rows as $field ) { $fieldHandler = new cbFieldHandler(); $success = $fieldHandler->checkFixSQL( $this->_sqlUpgrader, $field, $upgrade ); if ( ! $success ) { $ret = false; // echo $field->_error; } } return $ret; }
/** * Returns a field in specified format * * @param FieldTable $field * @param UserTable $user * @param string $output 'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit' * @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists * @param int $list_compare_types IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search * @return mixed */ public function getField(&$field, &$user, $output, $reason, $list_compare_types) { $return = null; switch ($output) { case 'html': case 'htmledit': if ($reason == 'search') { $fieldName = $field->get('name'); $minNam = $fieldName . '__minval'; $maxNam = $fieldName . '__maxval'; $minVal = $user->get($minNam); $maxVal = $user->get($maxNam); $field->set('name', $minNam); $minHtml = $this->_fieldEditToHtml($field, $user, $reason, 'input', 'text', $minVal, null); $field->set('name', $maxNam); $maxHtml = $this->_fieldEditToHtml($field, $user, $reason, 'input', 'text', $maxVal, null); $field->set('name', $fieldName); $return = $this->_fieldSearchRangeModeHtml($field, $user, $output, $reason, null, $minHtml, $maxHtml, $list_compare_types); } else { $return = $this->formatFieldValueLayout($this->getRatingHTML($field, $user, $reason), $reason, $field, $user); } break; default: $return = parent::getField($field, $user, $output, $reason, $list_compare_types); break; } return $return; }
private function getFieldAjaxError( &$field, &$user, $reason ) { global $_PLUGINS; $errors = $_PLUGINS->getErrorMSG( false ); $title = cbFieldHandler::getFieldTitle( $field, $user, 'text', $reason ); if ( $errors ) foreach ( $errors as $error ) { if ( stristr( $error, $title ) ) { return str_replace( $title . ' : ', '', $error ); } } return null; }
/** * Formatter: * Returns a field in specified format * * @param FieldTable $field * @param UserTable $user * @param string $output 'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit' * @param string $formatting 'tr', 'td', 'div', 'span', 'none', 'table'?? * @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'search' for searches * @param int $list_compare_types IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search * @return mixed */ public function getFieldRow(&$field, &$user, $output, $formatting, $reason, $list_compare_types) { if (!cbforumsClass::getModel()->file) { return null; } else { return parent::getFieldRow($field, $user, $output, $formatting, $reason, $list_compare_types); } }
/** * A more extensive bind method for fields ( //TBD: should got to the moscomprofilerFields class). * * @param moscomprofilerFields $row * @param int $fid * @return boolean */ function _prov_bind_CB_field(&$row, $fid) { global $_PLUGINS, $_POST; if (isset($_POST['cb_default'])) { $_POST['default'] = $_POST['cb_default']; // go around WysywigPro3 bug unset($_POST['cb_default']); } $bindSuccess = $row->bind($_POST); if ($bindSuccess) { // auto-fix description translation in case the editor adds <p> around it: $row->description = cleanEditorsTranslationJunk(trim($row->description)); $pluginid = $_PLUGINS->getUserFieldPluginId($row->type); if ($pluginid != 1) { $row->pluginid = $pluginid; // not core plugin for now as we don't allow changing field types } if (!isset($_POST['params'])) { $_POST['params'] = null; } if ($fid && $row->pluginid) { // handles field-specific parameters: $fieldHandler = new cbFieldHandler(); $row->params = $fieldHandler->getRawParamsRaw($row, $_POST['params']); } else { // if not a plugin-specific field, handle parameters in standard way: $row->params = stripslashes(cbParamsEditorController::getRawParamsUnescaped($_POST['params'], true)); } } return $bindSuccess; }
/** * Mutator: * Prepares field data for saving to database (safe transfer from $postdata to $user) * Override * * @param FieldTable $field * @param UserTable $user RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit) * @param array $postdata Typically $_POST (but not necessarily), filtering required. * @param string $reason 'edit' for save user edit, 'register' for save registration */ public function prepareFieldDataSave( &$field, &$user, &$postdata, $reason ) { $hybrid = new cbconnectHybrid(); $fieldName = $field->get( 'name' ); $provider = $hybrid->getProviderFromField( $fieldName ); $providerId = $hybrid->getIdFromProvider( $provider ); $currentValue = $user->get( $fieldName ); $value = cbGetParam( $postdata, $fieldName ); if ( $currentValue && ( $user->get( 'id' ) == Application::MyUser()->get( 'id' ) ) ) { if ( is_array( $value ) ) { if ( isset( $value[0] ) && ( $value[0] == 1 ) ) { $postdata[$fieldName] = ''; } } $value = cbGetParam( $postdata, $fieldName ); if ( $value === '' ) { try { $adapter = $hybrid->getAdapter( $providerId ); if ( $adapter ) { switch( $provider ) { case 'facebook': /** @noinspection PhpUndefinedMethodInspection */ $adapter->api()->api( '/me/permissions', 'DELETE' ); break; } $adapter->logout(); } } catch ( Exception $e ) {} } } if ( ( ! Application::Cms()->getClientId() ) && $user->get( 'id' ) && $currentValue && ( $value !== '' ) ) { $postdata[$fieldName] = $currentValue; } parent::prepareFieldDataSave( $field, $user, $postdata, $reason ); }
/** * Returns a USERPARAMS field in specified format * * @param moscomprofilerFields $field * @param moscomprofilerUser $user * @param string $output 'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit' * @param string $formatting 'table', 'td', 'span', 'div', 'none' * @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists * @param int $list_compare_types IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search * @return mixed */ function getFieldRow(&$field, &$user, $output, $formatting, $reason, $list_compare_types) { global $_CB_framework, $_CB_database, $ueConfig; $results = null; if (class_exists('JFactory')) { // Joomla 1.5 : $lang = JFactory::getLanguage(); $lang->load('com_users'); } $pseudoFields = array(); //Implementing Joomla's new user parameters such as editor $ui = $_CB_framework->getUi(); $userParams = $this->_getUserParams($ui, $user); if (is_array($userParams) && count($userParams) > 0 && ($ui == 2 || (isset($ueConfig['frontend_userparams']) ? $ueConfig['frontend_userparams'] == 1 : in_array($_CB_framework->getCfg("frontend_userparams"), array('1', null))))) { //Loop through each parameter and prepare rendering appropriately. foreach ($userParams as $k => $userParam) { $paramField = new moscomprofilerFields($_CB_database); $paramField->title = $userParam[0]; $paramField->_html = $userParam[1]; $paramField->description = isset($userParam[2]) && class_exists("JText") ? JText::_($userParam[2]) : null; $paramField->name = isset($userParam[3]) && class_exists("JText") ? JText::_($userParam[3]) : null; // very probably wrong! $paramField->fieldid = 'userparam_' . $k; $paramField->displaytitle = substr($userParam[0], 0, 6) == '<label' ? -1 : 1; // don't redisplay <label for> markup if ($paramField->displaytitle == -1) { if (substr($paramField->title, -9, 1) != ':' && substr($paramField->title, -8) == '</label>') { $paramField->title = substr($paramField->title, 0, -8) . ':</label>'; } } $paramField->type = 'param'; // this is for cb_ftparam class to be correct. $pseudoFields[] = $paramField; } } if ($_CB_framework->getUi() == 2) { if (checkJversion() < 2) { $myGids = CBuser::getMyInstance()->getUserData()->gids; $cms_mod = $_CB_framework->acl->mapGroupNamesToValues('Administrator'); $cms_admin = $_CB_framework->acl->mapGroupNamesToValues('Superadministrator'); } $i_am_super_admin = $_CB_framework->acl->amIaSuperAdmin(); //1.6+ only: $user_is_super_admin = $_CB_framework->acl->checkActionForGroups( $this->gids, 'core.admin', null ); if (checkJversion() == 2) { $cms_admin_title = 'Super Users'; } else { $cms_admin_title = 'Super Administrator'; } $canBlockUser = CBuser::getMyInstance()->authoriseAction('core.edit.state', 'com_users'); $canEmailEvents = $user->id == 0 && (checkJversion() >= 2 ? $canBlockUser : count(array_intersect($myGids, array($cms_mod, $cms_admin)))) || CBuser::getInstance($user->id)->authoriseAction('core.edit.state', 'com_users') || array_intersect($user->gids, getParentGIDS($ueConfig['imageApproverGid'])); // allow also CB isModerator $lists = array(); if ($canBlockUser) { // ensure user can't add group higher than themselves $gtree = $_CB_framework->acl->get_groups_below_me(); if (checkJversion() == 2) { if (!$i_am_super_admin && $user->id && CBuser::getInstance($user->id)->authoriseAction('core.manage', 'com_users') && (CBuser::getInstance($user->id)->authoriseAction('core.edit', 'com_users') || CBuser::getInstance($user->id)->authoriseAction('core.edit.state', 'com_users'))) { $disabled = ' disabled="disabled"'; } else { $disabled = ''; } $strgids = array_map('strval', $user->gids); $lists['gid'] = moscomprofilerHTML::selectList($gtree, 'gid[]', 'class="inputbox" size="11" multiple="multiple"' . $disabled, 'value', 'text', $strgids, 2, false); } else { if (!$i_am_super_admin && (in_array($cms_admin, $user->gids) && in_array($cms_admin, $myGids) || $user->id == $_CB_framework->myId() && in_array($cms_admin, $myGids))) { $lists['gid'] = "<input type=\"hidden\" name=\"gid\" value=\"{$user->gid}\" /><strong>{$cms_admin_title}</strong>"; } else { if (!$i_am_super_admin && (in_array($cms_mod, $myGids) && !in_array($cms_admin, $myGids) && in_array($cms_mod, $user->gids))) { $lists['gid'] = "<input type=\"hidden\" name=\"gid\" value=\"{$user->gid}\" /><strong>Administrator</strong>"; } else { $lists['gid'] = moscomprofilerHTML::selectList($gtree, 'gid', 'class="inputbox" size="11"', 'value', 'text', $user->gid, 2, false); } } } // build the html select list $lists['block'] = moscomprofilerHTML::yesnoSelectList('block', 'class="inputbox" size="1"', $user->block); $list_approved = array(); $list_approved[] = moscomprofilerHTML::makeOption('0', CBTxt::T('Unapproved')); $list_approved[] = moscomprofilerHTML::makeOption('1', CBTxt::T('Approved')); $list_approved[] = moscomprofilerHTML::makeOption('2', CBTxt::T('Disapproved')); $lists['approved'] = moscomprofilerHTML::selectList($list_approved, 'approved', 'class="inputbox" size="1"', 'value', 'text', $user->approved, 2, false); $lists['confirmed'] = moscomprofilerHTML::yesnoSelectList('confirmed', 'class="inputbox" size="1"', $user->confirmed); // build the html select list $lists['sendEmail'] = moscomprofilerHTML::yesnoSelectList('sendEmail', 'class="inputbox" size="1"', $user->sendEmail); $paramField = new moscomprofilerFields($_CB_database); $paramField->title = CBTxt::T('Group'); $paramField->_html = $lists['gid']; $paramField->description = ''; $paramField->name = 'gid'; $pseudoFields[] = $paramField; $paramField = new moscomprofilerFields($_CB_database); $paramField->title = CBTxt::T('Block User'); $paramField->_html = $lists['block']; $paramField->description = ''; $paramField->name = 'block'; $pseudoFields[] = $paramField; $paramField = new moscomprofilerFields($_CB_database); $paramField->title = CBTxt::T('Approve User'); $paramField->_html = $lists['approved']; $paramField->description = ''; $paramField->name = 'approved'; $pseudoFields[] = $paramField; $paramField = new moscomprofilerFields($_CB_database); $paramField->title = CBTxt::T('Confirm User'); $paramField->_html = $lists['confirmed']; $paramField->description = ''; $paramField->name = 'confirmed'; $pseudoFields[] = $paramField; $paramField = new moscomprofilerFields($_CB_database); $paramField->title = CBTxt::T('Receive Moderator Emails'); if ($canEmailEvents || $user->sendEmail) { $paramField->_html = $lists['sendEmail']; } else { $paramField->_html = CBTxt::T('No (User\'s group-level doesn\'t allow this)') . '<input type="hidden" name="sendEmail" value="0" />'; } $paramField->description = ''; $paramField->name = 'sendEmail'; $pseudoFields[] = $paramField; } if ($user->id) { $paramField = new moscomprofilerFields($_CB_database); $paramField->title = CBTxt::T('Register Date'); $paramField->_html = cbFormatDate($user->registerDate); $paramField->description = ''; $paramField->name = 'registerDate'; $pseudoFields[] = $paramField; $paramField = new moscomprofilerFields($_CB_database); $paramField->title = CBTxt::T('Last Visit Date'); $paramField->_html = cbFormatDate($user->lastvisitDate); $paramField->description = ''; $paramField->name = 'lastvisitDate'; $pseudoFields[] = $paramField; } } switch ($output) { case 'htmledit': foreach ($pseudoFields as $paramField) { $paramField->required = $this->_isRequired($field, $user, $reason); $paramField->profile = $field->profile; $results .= parent::getFieldRow($paramField, $user, $output, $formatting, $reason, $list_compare_types); } unset($pseudoFields); return $results; break; default: return null; break; } }
/** * Delete method for fields deleting also fieldvalues, but not the data column in the comprofiler table. * For that, deleteColumn() method must be called separately. * * @param id of row to delete * @return true if successful otherwise returns and error message */ function deleteDataDescr($oid = null) { $fieldHandler = new cbFieldHandler(); $ret = $fieldHandler->adaptSQL($this, 'drop'); if ($ret) { $ret = $this->delete($oid); } return $ret; }
/** * Returns a USERPARAMS field in specified format * * @param moscomprofilerFields $field * @param moscomprofilerUser $user * @param string $output 'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit' * @param string $formatting 'table', 'td', 'span', 'div', 'none' * @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists * @param int $list_compare_types IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search * @return mixed */ function getFieldRow( &$field, &$user, $output, $formatting, $reason, $list_compare_types ) { global $_CB_framework, $_CB_database, $ueConfig; $results = null; if ( class_exists( 'JFactory' ) ) { // Joomla 1.5 : $lang =& JFactory::getLanguage(); $lang->load( 'com_users' ); } $pseudoFields = array(); //Implementing Joomla's new user parameters such as editor $ui = $_CB_framework->getUi(); $userParams = $this->_getUserParams( $ui, $user ); if ( is_array( $userParams ) && ( count( $userParams ) > 0 ) && ( ( $ui == 2 ) || ( ( isset( $ueConfig['frontend_userparams'] ) ) ? ( $ueConfig['frontend_userparams'] == 1 ) : in_array( $_CB_framework->getCfg( "frontend_userparams" ), array( '1', null) ) ) ) ) { //Loop through each parameter and prepare rendering appropriately. foreach ( $userParams AS $k => $userParam ) { $paramField = new moscomprofilerFields( $_CB_database ); $paramField->title = $userParam[0]; $paramField->_html = $userParam[1]; $paramField->description = ( isset( $userParam[2] ) && class_exists("JText") ? JText::_( $userParam[2] ) : null ); $paramField->name = ( isset( $userParam[3] ) && class_exists("JText") ? JText::_( $userParam[3] ) : null ); // very probably wrong! $paramField->fieldid = 'userparam_' . $k; $paramField->displaytitle = substr( $userParam[0], 0, 6 ) == '<label' ? -1 : 1; // don't redisplay <label for> markup $paramField->type = 'param'; // this is for cb_ftparam class to be correct. $pseudoFields[] = $paramField; } } if( $_CB_framework->getUi() == 2 ) { $myGid = userGID( $_CB_framework->myId() ); $cms_mod = $_CB_framework->acl->mapGroupNamesToValues( 'Administrator' ); $cms_admin = $_CB_framework->acl->mapGroupNamesToValues( 'Superadministrator' ); if ( checkJversion() == 2 ) { $cms_admin_title = 'Super Users'; } else { $cms_admin_title = 'Super Administrator'; } $canBlockUser = $_CB_framework->check_acl( 'canBlockUsers', $_CB_framework->myUserType() ); $canEmailEvents = ( ( $user->id == 0 ) && ( in_array( $myGid, array( $cms_mod, $cms_admin ) ) ) ) || $_CB_framework->check_acl( 'canReceiveAdminEmails', $_CB_framework->acl->get_group_name( $user->gid, 'ARO' ) ) || in_array( $user->gid, getParentGIDS( $ueConfig['imageApproverGid'] ) ); // allow also CB isModerator $lists = array(); $user_group = strtolower( $_CB_framework->acl->get_group_name( $user->gid, 'ARO' ) ); if (( $user_group == strtolower( $cms_admin_title ) && $myGid != $cms_admin) || ( $user->id == $_CB_framework->myId() && $myGid == $cms_admin)) { $lists['gid'] = "<input type=\"hidden\" name=\"gid\" value=\"$user->gid\" /><strong>$cms_admin_title</strong>"; } else if ( $myGid == $cms_mod && $user->gid == $cms_mod ) { $lists['gid'] = "<input type=\"hidden\" name=\"gid\" value=\"$user->gid\" /><strong>Administrator</strong>"; } else { // ensure user can't add group higher than themselves 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' ); } if ( is_array( $my_groups ) && ( count( $my_groups ) > 0 ) ) { $ex_groups = $_CB_framework->acl->get_group_children( $my_groups[0], 'ARO', 'RECURSE' ); if ( $ex_groups === null ) { $ex_groups = array(); // mambo fix } } else { $ex_groups = array(); } $gtree = $_CB_framework->acl->get_group_children_tree( null, 'USERS', false ); // remove users 'above' me $i = 0; while ( $i < count( $gtree ) ) { if ( in_array( $gtree[$i]->value, $ex_groups ) ) { array_splice( $gtree, $i, 1 ); } else { $i++; } } if ( checkJversion() == 2 ) { $lists['gid'] = moscomprofilerHTML::selectList( $gtree, 'gid[]', 'class="inputbox" size="11" multiple="multiple"', 'value', 'text', $user->gids, 2, false ); } else { $lists['gid'] = moscomprofilerHTML::selectList( $gtree, 'gid', 'class="inputbox" size="11"', 'value', 'text', $user->gid, 2, false ); } } // build the html select list $lists['block'] = moscomprofilerHTML::yesnoSelectList( 'block', 'class="inputbox" size="1"', $user->block ); $list_approved = array(); $list_approved[] = moscomprofilerHTML::makeOption( '0', CBTxt::T( 'Unapproved' ) ); $list_approved[] = moscomprofilerHTML::makeOption( '1', CBTxt::T( 'Approved' ) ); $list_approved[] = moscomprofilerHTML::makeOption( '2', CBTxt::T( 'Disapproved' ) ); $lists['approved'] = moscomprofilerHTML::selectList( $list_approved, 'approved', 'class="inputbox" size="1"', 'value', 'text', $user->approved, 2, false ); $lists['confirmed'] = moscomprofilerHTML::yesnoSelectList( 'confirmed', 'class="inputbox" size="1"', $user->confirmed ); // build the html select list $lists['sendEmail'] = moscomprofilerHTML::yesnoSelectList( 'sendEmail', 'class="inputbox" size="1"', $user->sendEmail ); $paramField = new moscomprofilerFields( $_CB_database ); $paramField->title = CBTxt::T( 'Group' ); $paramField->_html = $lists['gid']; $paramField->description = ''; $paramField->name = 'gid'; $pseudoFields[] = $paramField; if ( $canBlockUser ) { $paramField = new moscomprofilerFields( $_CB_database ); $paramField->title = CBTxt::T( 'Block User' ); $paramField->_html = $lists['block']; $paramField->description = ''; $paramField->name = 'block'; $pseudoFields[] = $paramField; $paramField = new moscomprofilerFields( $_CB_database ); $paramField->title = CBTxt::T( 'Approve User' ); $paramField->_html = $lists['approved']; $paramField->description = ''; $paramField->name = 'approved'; $pseudoFields[] = $paramField; $paramField = new moscomprofilerFields( $_CB_database ); $paramField->title = CBTxt::T( 'Confirm User' ); $paramField->_html = $lists['confirmed']; $paramField->description = ''; $paramField->name = 'confirmed'; $pseudoFields[] = $paramField; } $paramField = new moscomprofilerFields( $_CB_database ); $paramField->title = CBTxt::T( 'Receive Moderator Emails' ); if ($canEmailEvents || $user->sendEmail) { $paramField->_html = $lists['sendEmail']; } else { $paramField->_html = CBTxt::T('No (User\'s group-level doesn\'t allow this)') . '<input type="hidden" name="sendEmail" value="0" />'; } $paramField->description = ''; $paramField->name = 'sendEmail'; $pseudoFields[] = $paramField; if( $user->id) { $paramField = new moscomprofilerFields( $_CB_database ); $paramField->title = CBTxt::T( 'Register Date' ); $paramField->_html = cbFormatDate( $user->registerDate ); $paramField->description = ''; $paramField->name = 'registerDate'; $pseudoFields[] = $paramField; $paramField = new moscomprofilerFields( $_CB_database ); $paramField->title = CBTxt::T( 'Last Visit Date' ); $paramField->_html = cbFormatDate( $user->lastvisitDate ); $paramField->description = ''; $paramField->name = 'lastvisitDate'; $pseudoFields[] = $paramField; } } switch ( $output ) { case 'htmledit': foreach ( $pseudoFields as $paramField ) { $paramField->required = $this->_isRequired( $field, $user, $reason ); $paramField->profile = $field->profile; $results .= parent::getFieldRow( $paramField, $user, $output, $formatting, $reason, $list_compare_types ); } unset( $pseudoFields ); return $results; break; default: return null; break; } }
/** * Validator: * Validates $value for $field->required and other rules * Override * * @param FieldTable $field * @param UserTable $user RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit) * @param string $columnName Column to validate * @param string $value (RETURNED:) Value to validate, Returned Modified if needed ! * @param array $postdata Typically $_POST (but not necessarily), filtering required. * @param string $reason 'edit' for save user edit, 'register' for save registration * @return boolean True if validate, $this->_setErrorMSG if False */ public function validate( &$field, &$user, $columnName, &$value, &$postdata, $reason ) { if ( ( ! Application::Cms()->getClientId() ) && ( ! Application::MyUser()->isGlobalModerator() ) && in_array( $reason, array( 'register', 'edit' ) ) ) { if ( parent::validate( $field, $user, $columnName, $value, $postdata, $reason ) ) { $captcha = cbantispamCaptcha::getInstance( $field->get( 'name' ), $field->params->get( 'cbantispam_captcha_mode', null ) ); if ( ! $captcha->validateCaptcha() ) { $this->_setValidationError( $field, $user, $reason, ( $captcha->error ? $captcha->error : CBTxt::T( 'Invalid Captcha Code' ) ) ); return false; } } } return true; }
/** * @param FieldTable $field * @param UserTable $user * @param string $output * @param string $formatting * @param string $reason * @param int $list_compare_types * @return mixed|null */ public function getFieldRow( &$field, &$user, $output, $formatting, $reason, $list_compare_types ) { $return = null; if ( ( ! Application::Cms()->getClientId() ) && ( $output == 'htmledit' ) && ( $reason == 'edit' ) && $user->get( 'id' ) && ( ! cbprivacyClass::checkUserModerator( $user->get( 'id' ) ) ) ) { $field->set( 'registration', 0 ); $field->set( 'profile', 0 ); $field->set( 'required', 0 ); $field->set( 'readonly', 0 ); $return = parent::getFieldRow( $field, $user, $output, $formatting, $reason, $list_compare_types ); } return $return; }
/** * Checks the all data content tables of comprofiler fields and upgrades if needed * Backend-use only. * @access private * * @param boolean $upgrade False: only check table, True: upgrades table (depending on $dryRun) * @param boolean $dryRun True: doesn't do the modifying queries, but lists them, False: does the job * @return string Message to display */ function checkAllCBfieldsDb($upgrade = false, $dryRun = false) { cbimport('cb.sql.upgrader'); $this->_sqlUpgrader = new CBSQLupgrader($this->_db, $this->_silentWhenOK); $this->_sqlUpgrader->setDryRun($dryRun); $this->_db->setQuery("SELECT f.*" . "\n FROM #__comprofiler_fields AS f" . "\n INNER JOIN #__comprofiler_tabs AS t ON ( (f.tabid = t.tabid) AND (t.fields = 1) ) " . "\n LEFT JOIN #__comprofiler_plugin AS p ON p.id = t.pluginid" . "\n LEFT JOIN #__comprofiler_plugin AS pf ON pf.id = f.pluginid" . "\n ORDER BY t.ordering, f.ordering"); $rows = $this->_db->loadObjectList('fieldid', 'moscomprofilerFields', array(&$this->_db)); if ($this->_db->getErrorNum()) { echo $this->_db->stderr(); return false; } $ret = true; foreach ($rows as $field) { $fieldHandler = new cbFieldHandler(); $success = $fieldHandler->checkFixSQL($this->_sqlUpgrader, $field, $upgrade); if (!$success) { $ret = false; // echo $field->_error; } } return $ret; }