/** * * Enter description here ... * @param JForm $form * @param unknown $data */ function onContentPrepareForm($form, $data) { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $this->template = $this->getTemplateName(); if ($this->template && ($app->isAdmin() && $form->getName() == 'com_templates.style' || $app->isSite() && ($form->getName() == 'com_config.templates' || $form->getName() == 'com_templates.style'))) { jimport('joomla.filesystem.path'); //JForm::addFormPath( dirname(__FILE__) . DS. 'includes' . DS .'assets' . DS . 'admin' . DS . 'params'); $plg_file = JPath::find(dirname(__FILE__) . DS . 'includes' . DS . 'assets' . DS . 'admin' . DS . 'params', 'template.xml'); $tpl_file = JPath::find(JPATH_ROOT . DS . 'templates' . DS . $this->template, 'templateDetails.xml'); if (!$plg_file) { return false; } if ($tpl_file) { $form->loadFile($plg_file, false, '//form'); $form->loadFile($tpl_file, false, '//config'); } else { $form->loadFile($plg_file, false, '//form'); } if ($app->isSite()) { $jmstorage_fields = $form->getFieldset('jmstorage'); foreach ($jmstorage_fields as $name => $field) { $form->removeField($name, 'params'); } $form->removeField('config', 'params'); } if ($app->isAdmin()) { $doc->addStyleDeclaration('#jm-ef3plugin-info, .jm-row > .jm-notice {display: none !important;}'); } } }
public static function getInstance(JForm $form) { if (!array_key_exists($form->getName(), self::$instances)) { self::$instances[$form->getName()] = new RokSubfieldForm($form); } self::$instances[$form->getName()]->updateDataParams(); return self::$instances[$form->getName()]; }
/** * Method to test if the Captcha is correct. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. * @param JForm $form The form object for which the field is being tested. * * @return boolean True if the value is valid, false otherwise. * * @since 2.5 */ public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null) { $app = JFactory::getApplication(); $plugin = $app->get('captcha'); if ($app->isSite()) { $plugin = $app->getParams()->get('captcha', $plugin); } $namespace = $element['namespace'] ?: $form->getName(); // Use 0 for none if ($plugin === 0 || $plugin === '0') { return true; } else { $captcha = JCaptcha::getInstance((string) $plugin, array('namespace' => (string) $namespace)); } // Test the value. if (!$captcha->checkAnswer($value)) { $error = $captcha->getError(); if ($error instanceof Exception) { return $error; } else { return new JException($error); } } return true; }
/** * Event method that runs on content preparation * * @param JForm $form The form object * @param integer $data The form data * * @return bool */ public function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } $name = $form->getName(); if (!in_array($name, array('com_content.article'))) { return true; } $include_categories = $this->params->get('include_categories'); if (empty($include_categories)) { return true; } if (empty($data)) { $input = JFactory::getApplication()->input; $data = (object) $input->post->get('jform', array(), 'array'); } if (is_array($data)) { jimport('joomla.utilities.arrayhelper'); $data = JArrayHelper::toObject($data); } if (empty($data->catid)) { return true; } if (!in_array($data->catid, $include_categories)) { return true; } JForm::addFormPath(__DIR__ . '/form'); $form->loadFile('form'); if (!empty($data->id)) { $data = $this->loadTest($data); } return true; }
/** * Injects several fields into specific forms. * * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * * @since 2.0 */ public function onContentPrepareForm($form, $data) { // Check we are manipulating a valid form if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check if the password field needs injecting if ($this->params->get('use_ldap_password', false) && in_array($form->getName(), $this->passwordForms)) { // Check if this user should have a profile if (SHLdapHelper::isUserLdap(isset($data->id) ? $data->id : 0)) { if ($this->params->get('ldap_password_layout_edit', true)) { // Check if this is in the 'edit' layout or in the save state if (strtolower(JFactory::getApplication()->input->get('layout')) === 'edit' || strtolower(JFactory::getApplication()->input->get('task')) === 'save') { $form->loadFile(realpath(__DIR__) . '/forms/ldap_password.xml', false, false); } } else { $form->loadFile(realpath(__DIR__) . '/forms/ldap_password.xml', false, false); } } } // Check if the domain field needs injecting if ($this->params->get('use_ldap_domain', false) && in_array($form->getName(), $this->domainForms)) { $form->loadFile(realpath(__DIR__) . '/forms/ldap_domain.xml', false, false); } return true; }
/** * adds additional fields to the user editing form * * @param JForm $form The form to be altered. * @param mixed $data The associated data for the form. * * @return boolean * * @since 1.6 */ public function onContentPrepareForm($form, $data) { $version = new JVersion(); if (!$version->isCompatible('3.4')) { return true; } if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } $params = JComponentHelper::getParams('com_jce'); if ((bool) $params->get('replace_media_manager', 1) === false) { return; } // get form name. $name = $form->getName(); $valid = array('com_akrecipes.recipe', 'com_categories.categorycom_akrecipes', 'com_akrecipes.ingredient', 'com_akrecipes.brand', 'com_akrecipes.cuisine', 'com_akrecipes.brand', 'com_akrecipes.product'); // only allow some forms, see - https://github.com/joomla/joomla-cms/pull/8657 if (!in_array($name, $valid)) { return true; } $config = JFactory::getConfig(); $user = JFactory::getUser(); if ($user->getParam('editor', $config->get('editor')) !== "jce") { return true; } if (!JPluginHelper::getPlugin('editors', 'jce')) { return true; } $hasMedia = false; $fields = $form->getFieldset(); foreach ($fields as $field) { $type = $field->getAttribute('type'); if (strtolower($type) === "media") { // get filter value for field, eg: images, media, files $filter = $field->getAttribute('filter', 'images'); // get file browser link $link = $this->getLink($filter); // link not available for environment if (empty($link)) { continue; } $name = $field->getAttribute('name'); $group = (string) $field->group; $form->setFieldAttribute($name, 'link', $link, $group); $form->setFieldAttribute($name, 'class', 'input-large wf-media-input', $group); $hasMedia = true; } } if ($hasMedia) { // Include jQuery JHtml::_('jquery.framework'); $document = JFactory::getDocument(); $document->addScriptDeclaration('jQuery(document).ready(function($){$(".wf-media-input").removeAttr("readonly");});'); } return true; }
/** * Event onContentPrepareForm * * @param JForm $form * @param array $data * * @return bool */ public function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } $context = $form->getName(); if (!in_array($context, $this->allowedContext)) { return true; } JForm::addFormPath(__DIR__ . '/form'); $form->loadFile('form', false); return true; }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean */ public function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating a valid form. if (!in_array($form->getName(), array('com_admin.profile', 'com_users.user', 'com_users.registration', 'com_users.profile'))) { return true; } // Add the registration fields to the form. JForm::addFormPath(dirname(__FILE__) . '/form'); $form->loadFile('socialmetatags', false); return true; }
/** * adds additional fields to the user editing form * * @param JForm $form The form to be altered. * @param mixed $data The associated data for the form. * * @return boolean * * @since 1.6 */ public function onContentPrepareForm($form, $data) { $version = new JVersion(); if (!$version->isCompatible('3.4')) { return true; } if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // get form name. $name = $form->getName(); $valid = array('com_content.article', 'com_categories.categorycom_content', 'com_templates.style', 'com_tags.tag', 'com_banners.banner', 'com_contact.contact', 'com_newsfeeds.newsfeed'); // only allow some forms :( if (!in_array($name, $valid)) { return true; } $config = JFactory::getConfig(); $user = JFactory::getUser(); if ($user->getParam('editor', $config->get('editor')) !== "jce") { return true; } if (!JPluginHelper::getPlugin('editors', 'jce')) { return true; } $link = $this->getLink(); $hasMedia = false; if ($link) { $fields = $form->getFieldset(); foreach ($fields as $field) { $type = $field->getAttribute('type'); if (strtolower($type) === "media") { $name = $field->getAttribute('name'); $group = (string) $field->group; $form->setFieldAttribute($name, 'link', $link, $group); $form->setFieldAttribute($name, 'class', 'input-large wf-media-input', $group); $hasMedia = true; } } if ($hasMedia) { // Include jQuery JHtml::_('jquery.framework'); $document = JFactory::getDocument(); $document->addScriptDeclaration('jQuery(document).ready(function($){$(".wf-media-input").removeAttr("readonly");});'); } } return true; }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 1.6 */ function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating a valid form. $name = $form->getName(); if (!in_array($name, array('com_users.registration'))) { return true; } // Add the registration fields to the form. JForm::addFormPath(dirname(__FILE__) . '/forms'); $form->loadFile('hprecaptcha', false); return true; }
/** * Event method that runs on content preparation * * @param JForm $form The form object * @param integer $data The form data * * @return bool */ public function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } $name = $form->getName(); if (!in_array($name, array('com_content.article'))) { return true; } JForm::addFormPath(__DIR__ . '/form'); $form->loadFile('form'); if (!empty($data->id)) { $data = $this->loadTest($data); } return true; }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 2.5 */ public function onContentPrepareForm($form, $data) { // Ensure that data is an object $data = (object) $data; // Check we have a form if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating a valid form. $app = JFactory::getApplication(); if ($form->getName() != 'com_plugins.plugin' || isset($data->name) && $data->name != 'plg_system_languagecode' || empty($data) && !$app->getUserState('plg_system_language_code.edit')) { return true; } // Mark the plugin as being edited $app->setUserState('plg_system_language_code.edit', $data->name == 'plg_system_languagecode'); // Get site languages if ($languages = JLanguage::getKnownLanguages(JPATH_SITE)) { // Inject fields into the form foreach ($languages as $tag => $language) { $form->load(' <form> <fields name="params"> <fieldset name="languagecode" label="PLG_SYSTEM_LANGUAGECODE_FIELDSET_LABEL" description="PLG_SYSTEM_LANGUAGECODE_FIELDSET_DESC" > <field name="' . strtolower($tag) . '" type="text" description="' . htmlspecialchars(JText::sprintf('PLG_SYSTEM_LANGUAGECODE_FIELD_DESC', $language['name']), ENT_COMPAT, 'UTF-8') . '" translate_description="false" label="' . $tag . '" translate_label="false" size="7" filter="cmd" /> </fieldset> </fields> </form> '); } } return true; }
function onContentPrepareForm(JForm $form, $data) { $name = $form->getName(); if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) { return true; } // Add the extra fields JForm::addFormPath(dirname(__FILE__) . '/profiles'); $form->loadFile('profile', false); // If we're admin we can do some extra things if ($name != "com_users.user") { $form->setFieldAttribute("programmename", "readonly", true, "swg_extras"); // $form->setFieldAttrib("leaderid", "readonly", ) $form->removeField("leaderid", "swg_extras"); $form->removeField("leadersetup", "swg_extras"); } return true; }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 1.6 */ public function onContentPrepareForm($form, $data) { // Get application $application = JFactory::getApplication(); // Get settings $params = JComponentHelper::getParams('com_k2'); // Get form name $name = $form->getName(); // Valid forms $forms = array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'); // Rendering condition if ($application->isSite() && $params->get('K2UserProfile') == 'native' && in_array($name, $forms)) { // Add K2 profile fields to the form JForm::addFormPath(__DIR__ . '/forms'); $form->loadFile('profile', false); } // Return return true; }
/** * Adds additional fields to the user editing form * * @param JForm $form The form to be altered. * @param mixed $data The associated data for the form. * * @return boolean */ public function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // We only work with com_users.* and com_admin.profile: $form_name = $form->getName(); if (!in_array($form_name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) { return true; } //JLog::add("onContentPrepareForm ".htmlentities($form_name)); $app = JFactory::getApplication(); if ($app->isSite() && $form_name == 'com_users.registration') { $lang = JFactory::getLanguage()->getTag(); $form->removeField("email2"); $grpoptions = ""; foreach (explode(",", $this->params->get('altgroups')) as $grp) { $grp = htmlentities(trim($grp)); $grpoptions .= " <option value=\"{$grp}\">" . ($lang == "ru-RU" ? "Я -" : "I'm") . " {$grp}</option>\n"; } /* Append "altgroup.groupname" field to "default" fieldset * so that it would be rendered in the same "block" as * core user fields like "username/email/password": */ $form->load('<form>' . ' <fields name="altgroup">' . ' <fieldset name="default">' . ' <field name="groupname" type="radio"' . ' label=' . ($lang == "ru-RU" ? '"Кто вы?"' : '"Who are you?"') . ' required="true">' . $grpoptions . ' </field>' . ' </fieldset>' . ' </fields>' . '</form>'); /* JLog::add("input=".self::_str( $form->getInput("groupname", "altgroup"))); JLog::add("form=".self::_str($form));*/ } elseif ($form_name == 'com_users.profile') { $lang = JFactory::getLanguage()->getTag(); $form->removeField("email2"); $group_names = array(); if (isset($data->altgroup['groups'])) { foreach ($data->altgroup['groups'] as $g) { $group_names[] = $g[1]; } } /* Append "altgroup.groupnames" field to "core" * fieldset: */ $form->load('<form>' . ' <fields name="altgroup">' . ' <fieldset name="core">' . ' <field name="groupnames" type="text"' . ' disabled="true"' . ' label=' . ($lang == "ru-RU" ? '"Вы:"' : '"You are:"') . ' default="' . htmlentities(implode(", ", $group_names)) . '"' . ' />' . ' </fieldset>' . ' </fields>' . '</form>'); } return true; }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 1.6 */ function onContentPrepareForm($form, $data) { // Exit if an admin form if ($this->app->isAdmin()) { return; } if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating a valid form. if (!in_array($form->getName(), array('com_contact.contact'))) { return true; } // Add the fields to the form. JForm::addFormPath(dirname(__FILE__) . '/forms'); $form->loadFile('customform', false); return true; }
/** * Validates uploaded files from a form. * * @param array $files Array containing the files to validate. * @param array $data Other data from the form. * @param MonitorModelAttachments $modelAttachments Model to use. * * @return array|null A filtered array if all files are valid, null if not. */ public function validateFiles($files, $data, $modelAttachments = null) { if (!$modelAttachments) { $modelAttachments = new MonitorModelAttachments($this->app); } foreach ($files as $i => $file) { if ($file[0]['error'] === UPLOAD_ERR_NO_FILE) { unset($files[$i]); } } if (!$modelAttachments->canUpload($files)) { // Store data for redirects. if (!$this->form) { $this->loadForm(); } $this->app->setUserState($this->form->getName() . '.data', $data); return null; } return $files; }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 2.5 */ public function onContentPrepareForm($form, $data) { // if user not logged-in if (!$this->_enable_for) { return true; } if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating a valid form. $name = $form->getName(); if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile'))) { return true; } // Add the registration fields to the form. JForm::addFormPath(dirname(__FILE__) . '/forms'); $form->loadFile('TFA', false); return true; }
/** * Prepare form. * * @param JForm $form The form to be altered. * @param mixed $data The associated data for the form. * * @return boolean * * @since 2.5 */ public function onContentPrepareForm($form, $data) { // Check we have a form. if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating the languagecode plugin. if ($form->getName() != 'com_plugins.plugin' || !$form->getField('languagecodeplugin', 'params')) { return true; } // Get site languages. if ($languages = JLanguage::getKnownLanguages(JPATH_SITE)) { // Inject fields into the form. foreach ($languages as $tag => $language) { $form->load(' <form> <fields name="params"> <fieldset name="languagecode" label="PLG_SYSTEM_LANGUAGECODE_FIELDSET_LABEL" description="PLG_SYSTEM_LANGUAGECODE_FIELDSET_DESC" > <field name="' . strtolower($tag) . '" type="text" description="' . htmlspecialchars(JText::sprintf('PLG_SYSTEM_LANGUAGECODE_FIELD_DESC', $language['name']), ENT_COMPAT, 'UTF-8') . '" translate_description="false" label="' . $tag . '" translate_label="false" size="7" filter="cmd" /> </fieldset> </fields> </form> '); } } return true; }
/** * @param JForm $form Joomla XML form * @param array|object $data Form data (j2.5 is array, j3.0 is object, converted to array for easy usage between both) */ public function onContentPrepareForm($form, $data) { if ($form instanceof JForm && $form->getName() == 'com_menus.item') { $data = (array) $data; if (isset($data['request']['option']) && $data['request']['option'] == 'com_comprofiler' && isset($data['request']['view']) && $data['request']['view'] == 'pluginclass') { $element = isset($data['request']['plugin']) ? $data['request']['plugin'] : 'cb.core'; if ($element) { $db = JFactory::getDBO(); $query = 'SELECT ' . $db->quoteName('type') . ', ' . $db->quoteName('folder') . "\n FROM " . $db->quoteName('#__comprofiler_plugin') . "\n WHERE " . $db->quoteName('element') . " = " . $db->quote($element); $db->setQuery($query); $plugin = $db->loadAssoc(); if ($plugin) { $path = JPATH_ROOT . '/components/com_comprofiler/plugin/' . $plugin['type'] . '/' . $plugin['folder'] . '/xml'; if (file_exists($path)) { JForm::addFormPath($path); $form->loadFile('metadata', false); } } } } } }
/** * Add additional field to the user editing form * * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * * @since 1.0.0 */ public function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { throw new RuntimeException(JText::_('JERROR_NOT_A_FORM')); return false; } // Only run in front-end. if (!JFactory::getApplication()->isSite()) { return true; } // Check we are manipulating a valid form. $name = $form->getName(); if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) { return true; } $folder = $this->params->get('folder', ''); $avatarFolder = JPATH_ROOT . '/' . $folder; // If the avatar folder doesn't exist, we don't display the fields. if (!JFolder::exists($avatarFolder)) { return true; } $layout = JFactory::getApplication()->input->get('layout', 'default'); if ($layout != 'default' || $layout == 'default' && $this->params->get('display_avatar_in_profile', 0) == 1) { JForm::addFormPath(__DIR__ . '/profiles'); $form->loadFile('profile', false); } return true; }
function store(&$error) { global $mainframe; $db = JFactory::getDBO(); $userParams = JComponentHelper::getParams('com_users'); // the_user_status will have 3 values: // 0 - it's not a registered user and also the username doesn't exists // 1 - it's not a registered user but the username exists // - we display a message forcing him to login first to activate the advertiser status // 2 - it's a registered user that will activate it's status $the_user_status = 0; $item_id = JRequest::getInt('Itemid', '0', 'get'); if ($item_id != 0) { $Itemid = "&Itemid=" . $item_id; } else { $Itemid = NULL; } $sql = "select `params` from #__ad_agency_settings"; $db->setQuery($sql); $db->query(); $email_params = $db->loadColumn(); $email_params = @$email_params["0"]; $email_params = unserialize($email_params); $existing_user = JFactory::getUser(); if ($existing_user->id > 0) { $the_user_status = 2; } else { JRequest::checkToken() or die('Invalid Token'); } jimport("joomla.database.table.user"); $user = new JUser(); $my = new stdClass(); $data = JRequest::get('post'); $usersConfig = JComponentHelper::getParams('com_users'); $query = "SELECT title FROM `#__usergroups` WHERE id=" . intval($usersConfig->get('new_usertype')) . ""; $db->setQuery($query); $usergroupName = $db->loadColumn(); $usergroupName = $usergroupName["0"]; if (isset($data['email']) && $data['email'] != NULL) { $data['email'] = trim($data['email']); } // See if there is a wizzard or not $sql = "SELECT COUNT(id) FROM `#__ad_agency_settings` WHERE `show` LIKE '%wizzard%'"; $db->setQuery($sql); $is_wizzard = intval($db->loadResult()); $data['paywith'] = NULL; $post_name = $data['name']; $item = $this->getTable('adagencyAdvertiser'); if ($the_user_status == 0) { $sql = "SELECT `id` FROM #__users WHERE username='******'username']) . "'"; $db->setQuery($sql); $user_id_byname = $db->loadResult(); if (isset($user_id_byname) && $user_id_byname > 0) { $the_user_status = 1; } } // setting the reports values - start $item->email_daily_report = 'N'; $item->email_weekly_report = 'N'; $item->email_month_report = 'N'; $item->email_campaign_expiration = 'N'; if (isset($data['email_daily_report']) && $data['email_daily_report'] == 'Y') { $item->email_daily_report = 'Y'; } if (isset($data['email_weekly_report']) && $data['email_weekly_report'] == 'Y') { $item->email_weekly_report = 'Y'; } if (isset($data['email_month_report']) && $data['email_month_report'] == 'Y') { $item->email_month_report = 'Y'; } if (isset($data['email_campaign_expiration']) && $data['email_campaign_expiration'] == 'Y') { $item->email_campaign_expiration = 'Y'; } // setting the reports values - stop $configs = $this->getInstance("adagencyConfig", "adagencyModel"); $configs = $configs->getConfigs(); // we determine what case we have - actual SAVE or REDIRECT - start $res = true; if ($the_user_status == 1) { $err_msg = JText::_("VIEWADVERTISER_ERR_MSG"); $err_msg = str_replace('{username}', mysql_escape_string($data['username']), $err_msg); $_SESSION['ad_company'] = $data['company']; $_SESSION['ad_description'] = $data['description']; $_SESSION['ad_approved'] = $data['approved']; $_SESSION['ad_enabled'] = $data['enabled']; $_SESSION['ad_username'] = $data['username']; $_SESSION['ad_email'] = $data['email']; $_SESSION['ad_name'] = $data['name']; $_SESSION['ad_website'] = $data['website']; $_SESSION['ad_address'] = $data['address']; $_SESSION['ad_country'] = $data['country']; $_SESSION['ad_state'] = $data['state']; $_SESSION['ad_city'] = $data['city']; $_SESSION['ad_zip'] = $data['zip']; $_SESSION['ad_telephone'] = $data['telephone']; $mainframe->redirect('index.php?option=com_adagency&controller=adagencyAdvertisers&task=edit&cid[]=0', $err_msg); } elseif ($the_user_status == 0) { $query = 'SELECT id FROM #__users WHERE email = "' . addslashes(trim($data['email'])) . '"'; $db->setQuery($query); $exists_email = $db->loadResult($query); if ($exists_email != '') { $_SESSION['ad_company'] = $data['company']; $_SESSION['ad_description'] = $data['description']; $_SESSION['ad_approved'] = $data['approved']; $_SESSION['ad_enabled'] = $data['enabled']; $_SESSION['ad_username'] = $data['username']; $_SESSION['ad_email'] = $data['email']; $_SESSION['ad_name'] = $data['name']; $_SESSION['ad_website'] = $data['website']; $_SESSION['ad_address'] = $data['address']; $_SESSION['ad_country'] = $data['country']; $_SESSION['ad_state'] = $data['state']; $_SESSION['ad_city'] = $data['city']; $_SESSION['ad_zip'] = $data['zip']; $_SESSION['ad_telephone'] = $data['telephone']; $mainframe->redirect('index.php?option=com_adagency&controller=adagencyAdvertisers&task=edit&cid[]=0', JText::_('ADAG_EMAILINUSE')); } if (isset($configs->show) && strpos(" " . $configs->show, 'calculation') > 0) { if (!isset($_SESSION['ADAG_CALC']) || $_SESSION['ADAG_CALC'] != $data['calculation']) { $_SESSION['ad_company'] = $data['company']; $_SESSION['ad_description'] = $data['description']; $_SESSION['ad_approved'] = $data['approved']; $_SESSION['ad_enabled'] = $data['enabled']; $_SESSION['ad_username'] = $data['username']; $_SESSION['ad_email'] = $data['email']; $_SESSION['ad_name'] = $data['name']; $_SESSION['ad_website'] = $data['website']; $_SESSION['ad_address'] = $data['address']; $_SESSION['ad_country'] = $data['country']; $_SESSION['ad_state'] = $data['state']; $_SESSION['ad_city'] = $data['city']; $_SESSION['ad_zip'] = $data['zip']; $_SESSION['ad_telephone'] = $data['telephone']; $mainframe->redirect('index.php?option=com_adagency&controller=adagencyAdvertisers&task=edit&cid[]=0', JText::_('JS_CALCULATION')); } } $pwd = $data['password']; if (!$data['user_id']) { $data['password2'] = $data['password']; } $sql = "SELECT `id` FROM #__usergroups WHERE `title`='" . $usergroupName . "'"; $db->setQuery($sql); $advgroup = $db->loadResult(); if (!isset($user->registerDate)) { $user->registerDate = date('Y-m-d H:i:s'); } $user->usertype = $usergroupName; $user->gid = $advgroup; if ($data['user_id'] > 0) { $data['id'] = $data['user_id']; } $query = "SHOW columns FROM #__ad_agency_advertis WHERE field='approved'"; $db->setQuery($query); $autoapprove = $db->loadRow(); $autoapprove[4] = 'Y'; if ($userParams->get('useractivation') != 0) { $data["block"] = 1; $user->block = 1; $autoapprove[4] = 'P'; } $data["groups"] = array($advgroup); $user->bind($data); if (isset($autoapprove[4]) && $autoapprove[4] == 'Y') { $user->block = 0; $user->activation = ''; $data['approved'] = 'Y'; } else { $data['approved'] = 'P'; $useractivation = $usersConfig->get('useractivation'); if ($useractivation == '1') { jimport('joomla.user.helper'); $user->activation = md5(JUserHelper::genRandomPassword()); $user->block = 1; } } if ($is_wizzard > 0) { $user->block = 0; $user->activation = 0; $user->params = NULL; } if ($userParams->get('useractivation') != 0) { jimport('joomla.user.helper'); $user->activation = md5(JUserHelper::genRandomPassword()); $data["block"] = 1; $user->block = 1; } if (!$user->save()) { $error = $user->getError(); echo $error; $res = false; } else { $name = $user->name; $email = $user->email; $username = $user->username; $mosConfig_live_site = JURI::base(); $ok_send_email = 1; if ($data['approved'] == 'Y') { $subject = $configs->sbafterregaa; $message = $configs->bodyafterregaa; $ok_send_email = $email_params["send_after_reg_auto_app"]; } else { $subject = $configs->sbactivation; $message = $configs->bodyactivation; $ok_send_email = $email_params["send_after_reg_need_act"]; } $subject = str_replace('{name}', $name, $subject); $subject = str_replace('{login}', $username, $subject); $subject = str_replace('{email}', $email, $subject); $subject = str_replace('{password}', $pwd, $subject); $message = str_replace('{name}', $name, $message); $message = str_replace('{login}', $username, $message); $message = str_replace('{email}', $email, $message); $message = str_replace('{password}', $pwd, $message); $configs->txtafterreg = str_replace('{name}', $name, $configs->txtafterreg); $configs->txtafterreg = str_replace('{login}', $username, $configs->txtafterreg); $configs->txtafterreg = str_replace('{password}', $pwd, $configs->txtafterreg); $message = str_replace('{activate_url}', '<a href="' . $mosConfig_live_site . 'index.php?option=com_users&task=registration.activate&token=' . $user->activation . '" target="_blank">' . $mosConfig_live_site . 'index.php?option=com_users&task=registration.activate&token=' . $user->activation . '</a>', $message); $message = html_entity_decode($message, ENT_QUOTES); if ($ok_send_email == 1) { JFactory::getMailer()->sendMail($configs->fromemail, $configs->fromname, $email, $subject, $message, 1); } } $ask = "SELECT `id` FROM `#__users` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $where = $db->loadResult(); $user->id = $where; if (!$data['user_id']) { $data['user_id'] = $user->id; } $sql = "SHOW tables"; $db->setQuery($sql); $res_tables = $db->loadColumn(); $jconfigs = JFactory::getConfig(); $params = new JForm($jconfigs); $params2 = $params->getName("name"); $params2 = (array) $params2; $params2 = array_pop($params2); $dbprefix = $params2->dbprefix; if (in_array($dbprefix . "comprofiler", $res_tables) && $data['user_id']) { $sql = "INSERT INTO `#__comprofiler` (`id`, `user_id`) VALUES ('" . intval($data['user_id']) . "', '" . intval($data['user_id']) . "');"; $db->setQuery($sql); $db->query(); } $data['key'] = md5(rand(1000, 9999)); $sql = "SELECT params FROM `#__ad_agency_settings` LIMIT 1"; $db->setQuery($sql); $cpr = @unserialize($db->loadResult()); if (!isset($cpr['timeformat'])) { $data['fax'] = 10; } else { $data['fax'] = intval($cpr['timeformat']); } if (!$item->bind($data)) { $res = false; } if (!$item->check()) { $res = false; } if (!$item->store()) { $res = false; } // Send notification to administrator below //if(!isset($user->block)||($user->block==0)){ if (isset($data['approved']) && $data['approved'] == 'Y') { $approval_msg = JText::_('NEWADAPPROVED'); } else { $approval_msg = JText::_('ADAG_PENDING'); } if (!isset($data['address']) || $data['address'] == '') { $data['address'] = "N/A"; } if (!isset($data['state']) || $data['state'] == '') { $data['state'] = "N/A"; } if (!isset($data['website']) || $data['website'] == '') { $data['website'] = "N/A"; } if (!isset($data['company']) || $data['company'] == '') { $data['company'] = "N/A"; } if (!isset($data['country']) || $data['country'] == '') { $data['country'] = "N/A"; } if (!isset($data['description']) || $data['description'] == '') { $data['description'] = "N/A"; } if (!isset($data['telephone']) || $data['telephone'] == '') { $data['telephone'] = "N/A"; } if (!isset($data['zip']) || $data['zip'] == '') { $data['zip'] = "N/A"; } $eapprove = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAdvertisers&task=manage&action=approve&key=" . $data['key'] . "&cid=" . $data['user_id'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAdvertisers&task=manage&action=approve&key=" . $data['key'] . "&cid=" . $data['user_id'] . "</a>"; $edecline = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAdvertisers&task=manage&action=decline&key=" . $data['key'] . "&cid=" . $data['user_id'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAdvertisers&task=manage&action=decline&key=" . $data['key'] . "&cid=" . $data['user_id'] . "</a>"; $message2 = str_replace('{name}', $name, $configs->bodynewuser); $message2 = str_replace('{email}', $email, $message2); $message2 = str_replace('{approval_status}', $approval_msg, $message2); $message2 = str_replace('{street}', $data['address'], $message2); $message2 = str_replace('{state}', $data['state'], $message2); $message2 = str_replace('{company}', $data['company'], $message2); $message2 = str_replace('{zipcode}', $data['zip'], $message2); $message2 = str_replace('{country}', $data['country'], $message2); $message2 = str_replace('{description}', $data['description'], $message2); $message2 = str_replace('{url}', $data['website'], $message2); $message2 = str_replace('{username}', $username, $message2); $message2 = str_replace('{phone}', $data['telephone'], $message2); $message2 = str_replace('{approve_advertiser_url}', $eapprove, $message2); $message2 = str_replace('{decline_advertiser_url}', $edecline, $message2); $subject2 = str_replace('{name}', $name, $configs->sbnewuser); $subject2 = str_replace('{email}', $email, $subject2); $subject2 = str_replace('{description}', $data['description'], $subject2); $subject2 = str_replace('{company}', $data['company'], $subject2); $subject2 = str_replace('{url}', $data['website'], $subject2); $subject2 = str_replace('{street}', $data['address'], $subject2); $subject2 = str_replace('{state}', $data['state'], $subject2); $subject2 = str_replace('{zipcode}', $data['zip'], $subject2); $subject2 = str_replace('{country}', $data['country'], $subject2); $subject2 = str_replace('{username}', $username, $subject2); $subject2 = str_replace('{approval_status}', $approval_msg, $subject2); $subject2 = str_replace('{phone}', $data['telephone'], $subject2); $subject2 = str_replace('{approve_advertiser_url}', $eapprove, $subject2); $subject2 = str_replace('{decline_advertiser_url}', $edecline, $subject2); $subject2 = html_entity_decode($subject2, ENT_QUOTES); $message2 = html_entity_decode($message2, ENT_QUOTES); if ($email_params["send_advertiser_reg"] == 1) { JFactory::getMailer()->sendMail($configs->fromemail, $configs->fromname, $configs->adminemail, $subject2, $message2, 1); } if (stripslashes($_GET['task']) != 'edit') { $advertiser_id = mysql_insert_id(); if ($advertiser_id == 0) { $ask = "SELECT aid FROM #__ad_agency_advertis ORDER BY aid DESC LIMIT 1 "; $db->setQuery($ask); $advertiser_id = $db->loadResult(); } $query = "SELECT `lastreport` FROM #__ad_agency_advertis WHERE `aid`=" . intval($advertiser_id); $db->setQuery($query); $lastreport = $db->loadResult(); $secs = time(); if (!empty($lastreport)) { $querry = "UPDATE #__ad_agency_advertis SET `lastreport` = " . intval($secs) . " WHERE `aid`=" . intval($advertiser_id); $db->setQuery($querry); $db->query() or die($db->stderr()); } } } elseif ($the_user_status == 2) { if (isset($data['newpswd']) && $data['newpswd'] != "") { $sql = "UPDATE `#__users` SET `password` = '" . md5($data['newpswd']) . "' WHERE `id` =" . intval($existing_user->id) . " LIMIT 1"; $db->setQuery($sql); $db->query(); } $data['user_id'] = $existing_user->id; $new_name = stripslashes($post_name); $querry = "UPDATE #__users SET `name` = '" . addslashes(trim($new_name)) . "' WHERE `id`=" . intval($existing_user->id); $db->setQuery($querry); $db->query(); if (!$data['user_id']) { $data['user_id'] = $existing_user->id; } $query = "SHOW columns FROM #__ad_agency_advertis WHERE field='approved'"; $db->setQuery($query); $autoapprove = $db->loadRow(); $sql = "SELECT aid FROM #__ad_agency_advertis WHERE user_id='" . intval($existing_user->id) . "' LIMIT 1;"; $db->setQuery($sql); $aiduser = $db->loadColumn(); $aiduser = $aiduser["0"]; $data["aid"] = intval($aiduser); if (!$aiduser) { $data['key'] = md5(rand(1000, 9999)); } if (!$item->bind($data)) { $res = false; } if (!$item->check()) { $res = false; } if (!$item->store()) { $res = false; } if (!$aiduser) { $sql = "SELECT * FROM #__users WHERE id = " . intval($item->user_id); $db->setQuery($sql); $theUser = $db->loadObject(); $name = $theUser->name; $email = $theUser->email; $username = $theUser->username; // Send notification to administrator below //if(!isset($user->block)||($user->block==0)){ if ($autoapprove[4] == 'Y') { $approval_msg = JText::_('NEWADAPPROVED'); } else { $approval_msg = JText::_('ADAG_PENDING'); } if (!isset($data['address']) || $data['address'] == '') { $data['address'] = "N/A"; } if (!isset($data['state']) || $data['state'] == '') { $data['state'] = "N/A"; } if (!isset($data['website']) || $data['website'] == '') { $data['website'] = "N/A"; } if (!isset($data['company']) || $data['company'] == '') { $data['company'] = "N/A"; } if (!isset($data['country']) || $data['country'] == '') { $data['country'] = "N/A"; } if (!isset($data['description']) || $data['description'] == '') { $data['description'] = "N/A"; } if (!isset($data['telephone']) || $data['telephone'] == '') { $data['telephone'] = "N/A"; } if (!isset($data['zip']) || $data['zip'] == '') { $data['zip'] = "N/A"; } $eapprove = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAdvertisers&task=manage&action=approve&key=" . $data['key'] . "&cid=" . $data['user_id'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAdvertisers&task=manage&action=approve&key=" . $data['key'] . "&cid=" . $data['user_id'] . "</a>"; $edecline = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAdvertisers&task=manage&action=decline&key=" . $data['key'] . "&cid=" . $data['user_id'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAdvertisers&task=manage&action=decline&key=" . $data['key'] . "&cid=" . $data['user_id'] . "</a>"; $message2 = str_replace('{name}', $name, $configs->bodynewuser); $message2 = str_replace('{email}', $email, $message2); $message2 = str_replace('{approval_status}', $approval_msg, $message2); $message2 = str_replace('{street}', $data['address'], $message2); $message2 = str_replace('{state}', $data['state'], $message2); $message2 = str_replace('{company}', $data['company'], $message2); $message2 = str_replace('{zipcode}', $data['zip'], $message2); $message2 = str_replace('{country}', $data['country'], $message2); $message2 = str_replace('{description}', $data['description'], $message2); $message2 = str_replace('{url}', $data['website'], $message2); $message2 = str_replace('{username}', $username, $message2); $message2 = str_replace('{phone}', $data['telephone'], $message2); $message2 = str_replace('{approve_advertiser_url}', $eapprove, $message2); $message2 = str_replace('{decline_advertiser_url}', $edecline, $message2); $subject2 = str_replace('{name}', $name, $configs->sbnewuser); $subject2 = str_replace('{email}', $email, $subject2); $subject2 = str_replace('{description}', $data['description'], $subject2); $subject2 = str_replace('{company}', $data['company'], $subject2); $subject2 = str_replace('{url}', $data['website'], $subject2); $subject2 = str_replace('{street}', $data['address'], $subject2); $subject2 = str_replace('{state}', $data['state'], $subject2); $subject2 = str_replace('{zipcode}', $data['zip'], $subject2); $subject2 = str_replace('{country}', $data['country'], $subject2); $subject2 = str_replace('{username}', $username, $subject2); $subject2 = str_replace('{approval_status}', $approval_msg, $subject2); $subject2 = str_replace('{phone}', $data['telephone'], $subject2); $subject2 = str_replace('{approve_advertiser_url}', $eapprove, $subject2); $subject2 = str_replace('{decline_advertiser_url}', $edecline, $subject2); $subject2 = html_entity_decode($subject2, ENT_QUOTES); $message2 = html_entity_decode($message2, ENT_QUOTES); if ($email_params["send_advertiser_reg"] == 1) { JFactory::getMailer()->sendMail($configs->fromemail, $configs->fromname, $configs->adminemail, $subject2, $message2, 1); } } if ((!isset($aiduser) || $aiduser < 1) && $autoapprove[4] == 'Y') { $mainframe->redirect("index.php?option=com_adagency&controller=adagencyAds&task=addbanners" . $Itemid, JText::_('ADVSAVED2')); } } // we determine what case we have - actual SAVE or REDIRECT - stop /*if($userParams->get('useractivation') != 2){ if(($the_user_status == 0)&&($autoapprove[4]=='Y')){ if(isset($user->id)&&(intval($user->id)>0)) { $this->autoLogin($user->id); $mainframe->redirect("index.php?option=com_adagency&controller=adagencyAds&task=addbanners".$Itemid,JText::_('ADVSAVED2')); } } elseif(($the_user_status == 0)&&($autoapprove[4]!='Y')&&($is_wizzard > 0)){ if(isset($user->id)&&(intval($user->id)>0)) { $this->autoLogin($user->id); $mainframe->redirect("index.php?option=com_adagency&controller=adagencyAds&task=addbanners".$Itemid);//,JText::_('ADAG_PENDING_ADS2') } } }*/ if ($userParams->get('useractivation') != 0) { $user->password1 = $data["password2"]; $this->sendJoomlaEmail($user); $item_id = JRequest::getInt('Itemid', '0'); if ($item_id != 0) { $Itemid = "&Itemid=" . intval($item_id); } else { $Itemid = NULL; } $link = JRoute::_("index.php?option=com_adagency" . $Itemid, false); $mainframe->redirect($link, JText::_("ADAG_ADVERTISER_SAVED_PENDING"), "notice"); return true; } return $res; }
/** * Add JA Extended menu parameter - used for Joomla 1.6 * * @param JForm $form The form to be altered. * @param array $data The associated data for the form * * @return null */ function onContentPrepareForm($form, $data) { if ($form->getName() == 'com_menus.item') { JForm::addFormPath(JPATH_SITE . DS . T3_CORE . DS . 'params'); $form->loadFile('params', false); } if (T3Common::detect() && !JFactory::getApplication()->isAdmin() && $form->getName() == 'com_config.templates') { JForm::addFormPath(JPATH_SITE . DS . T3_CORE . DS . 'admin'); $form->loadFile('frontedit', false); } }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 1.0 */ function onContentPrepareForm($form, $data) { // Load user_profile plugin language $lang = JFactory::getLanguage(); $lang->load('plg_user_profilepicture', JPATH_ADMINISTRATOR); if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating a valid form. //if (!in_array($form->getName(), array('com_admin.profile','com_users.user', 'com_users.registration','com_users.profile'))) { if (!in_array($form->getName(), array('com_admin.profile', 'com_users.user', 'com_users.profile'))) { return true; } // Add the registration fields to the form. if ($_GET["task"] != "registration.register" && $_POST["task"] != "register") { JForm::addFormPath(dirname(__FILE__) . '/profiles'); $form->loadFile('profilepicture', false); } return true; }
/** * Add JA Extended menu parameter in administrator * * @param JForm $form The form to be altered. * @param array $data The associated data for the form * * @return null */ function onContentPrepareForm($form, $data) { if (defined('T3_PLUGIN')) { $form_name = $form->getName(); // make it compatible with AMM if ($form_name == 'com_advancedmodules.module') { $form_name = 'com_modules.module'; } if (T3::detect() && ($form_name == 'com_templates.style' || $form_name == 'com_config.templates')) { $_form = clone $form; $_form->loadFile(T3_PATH . '/params/template.xml', false); //custom config in custom/etc/assets.xml $cusXml = T3Path::getPath('etc/assets.xml'); if ($cusXml && file_exists($cusXml)) { $_form->loadFile($cusXml, true, '//config'); } // extend parameters T3Bot::prepareForm($form); //search for global parameters and store in user state $app = JFactory::getApplication(); $gparams = array(); foreach ($_form->getGroup('params') as $param) { if ($_form->getFieldAttribute($param->fieldname, 'global', 0, 'params')) { $gparams[] = $param->fieldname; } } $this->gparams = $gparams; } $tmpl = T3::detect() ? T3::detect() : (T3::getDefaultTemplate(true) ? T3::getDefaultTemplate(true) : false); if ($tmpl) { $tplpath = JPATH_ROOT . '/templates/' . (is_object($tmpl) && !empty($tmpl->tplname) ? $tmpl->tplname : $tmpl); $formpath = $tplpath . '/etc/form/'; JForm::addFormPath($formpath); $extended = $formpath . $form_name . '.xml'; if (is_file($extended)) { JFactory::getLanguage()->load('tpl_' . $tmpl, JPATH_SITE); $form->loadFile($form_name, false); } // load extra fields for specified module in format com_modules.module.module_name.xml if ($form_name == 'com_modules.module') { $module = isset($data->module) ? $data->module : ''; if (!$module) { $jform = JFactory::getApplication()->input->get("jform", null, 'array'); $module = $jform['module']; } $extended = $formpath . $module . '.xml'; if (is_file($extended)) { JFactory::getLanguage()->load('tpl_' . $tmpl, JPATH_SITE); $form->loadFile($module, false); } } //extend extra fields T3Bot::extraFields($form, $data, $tplpath); } // Extended by T3 $extended = T3_ADMIN_PATH . '/admin/form/' . $form_name . '.xml'; if (is_file($extended)) { $form->loadFile($extended, false); } } }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 1.6 */ function onContentPrepareForm($form, $data) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } if (!JHtml::isRegistered('users.url')) { JHtml::register('users.url', array(__CLASS__, 'url')); } if (!JHtml::isRegistered('users.calendar')) { JHtml::register('users.calendar', array(__CLASS__, 'calendar')); } if (!JHtml::isRegistered('users.tos')) { JHtml::register('users.tos', array(__CLASS__, 'tos')); } // Check we are manipulating a valid form. $context = $form->getName(); // The frontend and backend editor use the same form... if (!in_array($context, array('com_content.article'))) { return true; } // Note: The frontend form is generated by a custom view, we // have to alter it using template override to use our new fields // Load all needed field types (these are provided by the component) JForm::addFieldPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplegeotag' . DS . 'models' . DS . 'fields'); // Add the geotag fields to the form. JForm::addFormPath(dirname(__FILE__) . '/geotag'); $form->loadFile('geotag', false); //throw new Exception(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplegeotag' . DS . 'models' . DS . 'fields'); // Set whether location is requried $form->setFieldAttribute('latitude', 'required', $this->params->get('require_location') == 2, 'metadata'); $form->setFieldAttribute('longitude', 'required', $this->params->get('require_location') == 2, 'metadata'); return true; }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean */ public function onContentPrepareForm($form, $data) { // Check we are manipulating a valid form. $name = $form->getName(); if (!in_array($name, $this->allow_context)) { return true; } // Include UserXTD core API. $this->initComponent(); $result = null; $UXParams = JComponentHelper::getParams('com_userxtd'); // Prepare Data // ============================================================================ // Set Chosen JHtmlFormbehavior::chosen('select'); // Prepare Form // ============================================================================ // Get Form if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Hide some fields in registration $context = $this->getContext(); $array = array(); $reg_context = array('com_users.registration', 'com_userxtd.registration'); $profile_context = array('com_users.profile'); $catid = null; if (in_array($context, $reg_context) || $this->get('hide_registration_field')) { $array['hide_in_registration'] = true; $catid = $UXParams->get('CoreRegistration_Categories', array('*')); } elseif (in_array($context, $profile_context)) { $catid = $UXParams->get('CoreRegistration_Categories_InUserInfo', array('*')); } // Set category if (!is_array($catid)) { $catid = array($catid); } if (!in_array('*', $catid)) { $catid = implode(',', $catid); } else { $catid = null; } $form = \Userxtd\Form\FormHelper::getFieldsByCategory($catid, $form, $array); return $result; }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 1.6 */ function onContentPrepareForm($form, $data) { // Load user_profile plugin language $lang = JFactory::getLanguage(); $lang->load('plg_user_profile', JPATH_ADMINISTRATOR); if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating a valid form. if (!in_array($form->getName(), array('com_admin.profile', 'com_users.user', 'com_users.registration', 'com_users.profile'))) { return true; } // Add the registration fields to the form. JForm::addFormPath(dirname(__FILE__) . '/profiles'); $form->loadFile('profile', false); // Toggle whether the address1 field is required. if ($this->params->get('register-require_address1', 1) > 0) { $form->setFieldAttribute('address1', 'required', $this->params->get('register-require_address1') == 2, 'profile'); } else { $form->removeField('address1', 'profile'); } // Toggle whether the address2 field is required. if ($this->params->get('register-require_address2', 1) > 0) { $form->setFieldAttribute('address2', 'required', $this->params->get('register-require_address2') == 2, 'profile'); } else { $form->removeField('address2', 'profile'); } // Toggle whether the city field is required. if ($this->params->get('register-require_city', 1) > 0) { $form->setFieldAttribute('city', 'required', $this->params->get('register-require_city') == 2, 'profile'); } else { $form->removeField('city', 'profile'); } // Toggle whether the region field is required. if ($this->params->get('register-require_region', 1) > 0) { $form->setFieldAttribute('region', 'required', $this->params->get('register-require_region') == 2, 'profile'); } else { $form->removeField('region', 'profile'); } // Toggle whether the country field is required. if ($this->params->get('register-require_country', 1) > 0) { $form->setFieldAttribute('country', 'required', $this->params->get('register-require_country') == 2, 'profile'); } else { $form->removeField('country', 'profile'); } // Toggle whether the postal code field is required. if ($this->params->get('register-require_postal_code', 1) > 0) { $form->setFieldAttribute('postal_code', 'required', $this->params->get('register-require_postal_code') == 2, 'profile'); } else { $form->removeField('postal_code', 'profile'); } // Toggle whether the phone field is required. if ($this->params->get('register-require_phone', 1) > 0) { $form->setFieldAttribute('phone', 'required', $this->params->get('register-require_phone') == 2, 'profile'); } else { $form->removeField('phone', 'profile'); } // Toggle whether the website field is required. if ($this->params->get('register-require_website', 1) > 0) { $form->setFieldAttribute('website', 'required', $this->params->get('register-require_website') == 2, 'profile'); } else { $form->removeField('website', 'profile'); } // Toggle whether the favoritebook field is required. if ($this->params->get('register-require_favoritebook', 1) > 0) { $form->setFieldAttribute('favoritebook', 'required', $this->params->get('register-require_favoritebook') == 2, 'profile'); } else { $form->removeField('favoritebook', 'profile'); } // Toggle whether the aboutme field is required. if ($this->params->get('register-require_aboutme', 1) > 0) { $form->setFieldAttribute('aboutme', 'required', $this->params->get('register-require_aboutme') == 2, 'profile'); } else { $form->removeField('aboutme', 'profile'); } // Toggle whether the tos field is required. if ($this->params->get('register-require_tos', 1) > 0) { $form->setFieldAttribute('tos', 'required', $this->params->get('register-require_tos') == 2, 'profile'); } else { $form->removeField('tos', 'profile'); } // Toggle whether the dob field is required. if ($this->params->get('register-require_dob', 1) > 0) { $form->setFieldAttribute('dob', 'required', $this->params->get('register-require_dob') == 2, 'profile'); } else { $form->removeField('dob', 'profile'); } return true; }
/** * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * @since 1.6 */ public function onRoomTypePrepareForm($form, $data) { // Load solidres plugin language $lang = JFactory::getLanguage(); $lang->load('plg_extension_solidres', JPATH_ADMINISTRATOR); if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating a valid form. if (!in_array($form->getName(), array('com_solidres.roomtype'))) { return true; } // Add the registration fields to the form. JForm::addFormPath(__DIR__ . '/fields'); $form->loadFile('roomtype', false); // Toggle whether the checkin time field is required. if ($this->params->get('param_roomtype_room_facilities', 1) > 0) { $form->setFieldAttribute('room_facilities', 'required', $this->params->get('param_roomtype_room_facilities') == 2, 'roomtype_custom_fields'); } else { $form->removeField('room_facilities', 'roomtype_custom_fields'); } // Toggle whether the checkout time field is required. if ($this->params->get('param_roomtype_room_size', 1) > 0) { $form->setFieldAttribute('room_size', 'required', $this->params->get('param_roomtype_room_size') == 2, 'roomtype_custom_fields'); } else { $form->removeField('room_size', 'roomtype_custom_fields'); } // Toggle whether the cancellation prepayment field is required. if ($this->params->get('param_roomtype_bed_size', 1) > 0) { $form->setFieldAttribute('bed_size', 'required', $this->params->get('param_roomtype_bed_size') == 2, 'roomtype_custom_fields'); } else { $form->removeField('bed_size', 'roomtype_custom_fields'); } return true; }
/** * Loads the profile XML and passes it to the form to load the fields (excluding data). * * @param JForm $form The form to be altered. * @param array $data The associated data for the form. * * @return boolean * * @since 2.0 */ public function onContentPrepareForm($form, $data) { // Check if the profile parameter is enabled if (!$this->use_profile) { return true; } if (!($form instanceof JForm)) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } // Check we are manipulating a valid form if (!in_array($form->getName(), $this->permittedForms)) { return true; } $showForm = true; $domain = null; // Check if this user should have a profile if ($userId = isset($data->id) ? $data->id : 0) { if (SHLdapHelper::isUserLdap($userId)) { $domain = SHUserHelper::getDomainParam($data); } else { $showForm = false; } } elseif (!JFactory::getUser()->guest) { /* * Sometimes the $data variable is not populated even when an edit is required. * This means we have to check the form post data directly for the user ID. * We do not worry about frontend registrations as we check for guest. * If there is no form posted then this could be a backend registration. */ if ($inForm = JFactory::getApplication()->input->get('jform', false, 'array')) { $id = SHUtilArrayhelper::getValue($inForm, 'id', 0, 'int'); if ($id === 0) { // Ask all plugins if there is a plugin willing to deal with user creation for ldap if (count($results = SHFactory::getDispatcher('ldap')->trigger('askUserCreation'))) { // Due to being unaware of the domain for this new user, we are forced to use the default domain $domain = SHFactory::getConfig()->get('ldap.defaultconfig'); } else { // LDAP creation not enabled $showForm = false; } } else { if (SHLdapHelper::isUserLdap($id)) { // Existing ldap user $domain = SHUserHelper::getDomainParam($id); } else { // Existing non-ldap user $showForm = false; } } } } if ($showForm) { // We have to launch the getxmlfields to correctly include languages $this->getXMLFields($domain); // Get the File and Path for the Profile XML $file = $this->getXMLFileName($domain); $xmlPath = $this->profile_base . '/' . $file . '.xml'; // Load in the profile XML file to the form if (($xml = JFactory::getXML($xmlPath, true)) && ($form->load($xml, false, false))) { // Successfully loaded in the XML return true; } } }