Omit language preVar for RealURL 2.x with multidomain-multilanguage setup? - typo3-6.2.x

In a TYPO3 6.2.30 site, I updated RealURL 1.x to 2.2.1.
It works fine, but it is a multilanguage-multidomain site that doesn't require the language prefix after the domain.
Before I had
www.germandomain.ch/seite
www.frenchdomain.ch/page
Now I get
www.germandomain.ch/de/seite
www.frenchdomain.ch/fr/page
The old paths are still working as an alternative though.
How can I omit the parameter from the URL for both languages - is that still possible with RealURL 2?
Below are the relevant configuration snippets. I don't have domain records defined in the backend / pagetree.
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'de' => '0',
'fr' => '1',
),
//'valueDefault' => 'de',
'noMatch' => 'bypass',
),
array(
'GETvar' => 'no_cache',
'valueMap' => array(
'no_cache' => 1,
),
'noMatch' => 'bypass',
),
),
and
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DOMAINS'] = array(
'encode' => array(
array(
'GETvar' => 'L',
'value' => '',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.germandomain.ch',
),
array(
'GETvar' => 'L',
'value' => '0',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.germandomain.ch',
),
array(
'GETvar' => 'L',
'value' => '1',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.frenchdomain.ch',
),
),
'decode' => array(
'www.germandomain.ch' => array(
'GETvars' => array(
'L' => '0',
),
'useConfiguration' => '_DEFAULT',
),
'www.frenchdomain.ch' => array(
'GETvars' => array(
'L' => '1',
),
'useConfiguration' => '_DEFAULT',
),
),
);
and in TS
config {
sys_language_uid = 0
linkVars = L
language = de
locale_all = de_DE.utf-8
htmlTag_langKey = de
#defaultGetVars.L = 0
}
[globalVar = GP:L = 1]
config {
sys_language_uid = 1
language = fr
locale_all = fr_FR.utf-8
htmlTag_langKey = fr
#defaultGetVars.L = 1
}
[global]

Related

Redirect user after saving data in admin controller Prestashop

I have an admin controller which displays the list of data on clicking edit on an entry or adding a new entry I am showing renderForm() but after saving the data (either by edit or add) I want to redirect the user to another controller in place of showing the same controller list.
Bellow is the code which I am currently using for example of my requirements I trying to do something which I have done below in initcontent() but that is not working so I want to know where should I call this in place of initcontent()
<?php
/**
* The file is controller. Do not modify the file if you want to upgrade the module in future
*
* #author Globo Jsc <contact#globosoftware.net>
* #copyright 2016 Globo., Jsc
* #link http://www.globosoftware.net
* #license please read license in file license.txt
*/
include_once(_PS_MODULE_DIR_ . 'cardelivery/classes/AdditionalServicesModel.php');
class AdminAdditionalServiceController extends ModuleAdminControllerCore {
public $name;
public function __construct() {
$this->name = 'AdminAdditionalService';
$this->className = 'AdditionalServicesModel';
$this->table = 'additional_service';
$this->meta_title = $this->l('Additional Services');
$this->deleted = false;
$this->explicitSelect = true;
$this->context = Context::getContext();
$this->bootstrap = true;
$this->_defaultOrderBy = 'id_additional_service';
$this->filter = true;
if (Shop::isFeatureActive()) {
Shop::addTableAssociation($this->table, array('type' => 'shop'));
}
$this->position_identifier = 'id_additional_service';
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->fields_list = array(
'id_additional_service' => array(
'title' => $this->l('ID'),
'type' => 'int',
'width' => 'auto',
'orderby' => false),
'service_name' => array(
'title' => $this->l('Icon'),
'width' => 'auto',
'orderby' => false,
),
'service_desc' => array(
'title' => $this->l('service_desc'),
'type' => 'text'
),
'active' => array(
'title' => $this->l('Status'),
'width' => 'auto',
'active' => 'status',
'type' => 'bool',
'orderby' => false),
);
parent::__construct();
}
function initContent() {
parent::initContent();
if (Tools::isSubmit('submit')) {
Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminCategories') . '&conf=7');
}
}
public function initPageHeaderToolbar() {
$this->page_header_toolbar_btn['back_to_list'] = array(
'href' => Context::getContext()->link->getAdminLink('AdminGCardeliverycity', true),
'desc' => $this->l('Back to list', null, null, false),
'icon' => 'process-icon-back'
);
parent::initPageHeaderToolbar();
}
public function renderForm() {
$id_citydelivery = (int) Tools::getValue('id_citydelivery');
if ($id_citydelivery == 0) {
$addSerModObj = new AdditionalServicesModel((int) Tools::getValue('id_additional_service'));
$id_citydelivery = $addSerModObj->id_citydelivery;
}
$fields_form_1 = array(
'form' => array(
'legend' => array('title' => $this->l('Additional Service'), 'icon' => 'icon-cogs'),
'input' => array(
array(
'type' => 'hidden',
'name' => 'id_citydelivery'
),
array(
'type' => 'text',
'label' => $this->l('Service_name'),
'name' => 'service_name',
'size' => 255,
'required' => true,
'desc' => $this->l('Enter name of Arrival port')
),
array(
'type' => 'text',
'label' => $this->l('service_desc'),
'name' => 'service_desc',
'size' => 255,
'required' => true,
'desc' => $this->l('Enter name of Arrival port')
),
array(
'type' => 'text',
'label' => $this->l('charge'),
'name' => 'charge',
'size' => 255,
'required' => true,
'desc' => $this->l('Enter name of Arrival port')
),
array(
'type' => 'switch',
'label' => $this->l('Active'),
'name' => 'active',
'required' => false,
'is_bool' => true,
'values' => array(array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Active')), array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Inactive')))),
),
'submit' => array('title' => $this->l('Save')),
'buttons' => array(
array(
'href' => Context::getContext()->link->getAdminLink('AdminGCardeliverycity', true) . '&updatecitydelivery&id_citydelivery=' . $id_citydelivery,
'title' => $this->l('Cancle'),
'icon' => 'process-icon-cancel'
)
)
)
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->module = $this;
$helper->name_controller = $this->name;
$helper->toolbar_scroll = true;
$lang = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$this->fields_form = array();
$helper->identifier = $this->identifier;
$helper->submit_action = 'submit';
$helper->currentIndex = AdminController::$currentIndex;
$helper->token = Tools::getAdminTokenLite($this->name);
$id_additional_service = (int) Tools::getValue('id_additional_service');
$additionalServiceObj = new AdditionalServicesModel($id_additional_service);
$helper->tpl_vars = array(
'fields_value' => $this->getFormValues($additionalServiceObj),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
$_1 = $helper->generateForm(array($fields_form_1));
$return = $_1;
return $return;
}
function getFormValues($additionalServiceObj) {
return array(
'service_name' => Tools::getValue('service_name ', $additionalServiceObj->service_name),
'service_desc' => Tools::getValue('service_desc', $additionalServiceObj->service_desc),
'charge' => Tools::getValue('charge', $additionalServiceObj->charge),
'active' => Tools::getValue('active', $additionalServiceObj->active)
);
}
}
First of all, it seems that you redirect your page to the same URL. Try to use this
Tools::redirectAdmin($this->context->link->getAdminLink('AdminHome'));
where
AdminHome
is a redirect URL, you need to replace it with yours.
And second, try to use
Tools::getIsset('yourButtonName')
instead of
Tools::isSubmit('yourButtonName')
and the last, if nothing mentioned above will not help, try to move
parent::initContent();
and put it after your condition
Probably redirect_after may be useful
$this->redirect_after = 'Your custom address';

AUTHENTICATE 2 LDAP USER IN ITOPS

I have some LDAP users in iTops, and i want to login with all of users in iTops. But i have an error like that "user not found in LDAP".
Which folders that i have to change ? So i can login with all LDAP users.
I appreciate for your responses, all of you. Please help me, thanks.
in config-itop.php
$MyModuleSettings = array(
'authent-ldap' => array (
'host' => '192.168.1.2',
'port' => 389,
'default_user' => 'anonim',
'default_pwd' => 'Admin123',
'base_dn' => 'dc=vokasiub,dc=COM',
'user_query' => '(samaccountname=%1$s)',
'options' => array (
17 => 3,
8 => 0,
),
'start_tls' => false,
'debug' => true,
),
'authent-ldap2' => array (
'host' => '192.168.2.2',
'port' => 389,
'default_user' => 'isoiso',
'default_pwd' => 'Admin123',
'base_dn' => 'ou=users ou, dc=bagusyekti,dc=COM',
'user_query' => '(samaccountname=%1$s)',
'options' => array (
17 => 3,
8 => 0,
),
'start_tls' => false,
'debug' => true,
),
'itop-attachments' => array (
'allowed_classes' => array (
0 => 'Ticket',
),
'position' => 'relations',
'preview_max_width' => 290,
),
'email-reply' => array (
'enabled_default' => true,
),
'itop-backup' => array (
'mysql_bindir' => '',
'week_days' => 'monday, tuesday, wednesday, thursday, friday',
'time' => '23:30',
'retention_count' => 5,
'enabled' => true,
'debug' => true,
),
);
iTop 2.7 and older
This was not possible.
iTop 3.0 and newer
This is now possible, check the full documentation here, but basically you have to set the different LDAP servers like this in the iTop configuration file:
'authent-ldap' => array (
'host' => 'localhost',
'port' => 389,
'default_user' => '',
'default_pwd' => '',
'base_dn' => 'dc=mycompany,dc=com',
'user_query' => '(&(uid=%1$s))',
'options' => array (
17 => 3,
8 => 0,
),
'debug' => false,
'servers' => array(
'MySecond-LDAP-Server' => array(
'host' => 'server1',
'port' => 389,
'default_user' => '',
'default_pwd' => '',
'base_dn' => 'dc=mycompany,dc=com',
'user_query' => '(&(uid=%1$s))',
'options' => array (
17 => 3,
8 => 0,
),
'debug' => false,
),
),
),

ZF2 Child routes for restful API

I'm having some troubles setting up the routes for my restful api in zend framework2. I want to create route in this format: api-rest/wall/user_id/post[/:id].
Now this is my config file:
'router' => array(
'routes' => array(
'api-rest' => array(
'type' => 'segment',
'options' => array(
'route' => '/api-rest/wall[/:id]',
'constraints' => array(
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'ApiRest\Controller\Wall',
),
),
),
),
),
You can try something like this:
'router' => array(
'routes' => array(
'api-rest' => array(
'type' => 'segment',
'options' => array(
'route' => '/api-rest/wall/:userid/posts[/:id]',
'constraints' => array(
'id' => '[0-9]+',
'userid' => '[0-9]+',
),
'defaults' => array(
'controller' => 'ApiRest\Controller\Wall',
),
),
),
),
),
In this configuration userid is mandatory, not optional.
/api-rest/wall/3/posts/2 - Post with id 2 and user with id 3
/api-rest/wall/3/posts - All posts by user with id 3
/api-rest/wall/3 - Won't match
You may also want to take a look child route usage in routing documentation.

not work scopes in Yii

Why my scopes not work?
$criteria = new \CDbCriteria();
$criteria->addCondition('user_id = :user_id');
$criteria->scopes = array(
'applicant' => array(
'scopes' => array('deletedStatus'),
'params' => array(':deletedStatus' => 0)
),
'filePair' => array(
'with' => array(
'category' => array(
'with' => array(
'parent' => array(
'order' => 'parent.order'
)
),
'scopes' => array('enabled')
),
'file' => array(
'scopes' => array('enabled'),
'order' => 'file.order'
)
)
)
);
$criteria->params = array(':user_id' => \Yii::app()->userApp->id);
/** #var \ApplicantDocument[] $models */
$models = \ApplicantDocument::model()->findAll($criteria);
public function scopes()
{
$t = $this->getTableAlias(false, false);
return array(
'deletedStatus' => array(
'condition' => $t.'.is_deleted = :deletedStatus'
),
'applicant' => array(
'condition' => $t.'.role = :role',
'params' => array(':role' => self::APPLICATION_STATUS_APPLICANT)
),
'guarant' => array(
'condition' => $t.'.role = :role',
'params' => array(':role' => self::APPLICATION_STATUS_GUARANTOR)
),
'company' => array(
'condition' => $t.'.role = :role',
'params' => array(':role' => self::APPLICATION_STATUS_COMPANY)
),
'trust' => array(
'condition' => $t.'.role = :role',
'params' => array(':role' => self::APPLICATION_STATUS_TRUST)
),
);
}
This scope does not work, aplicants with is_deleted selected from db
'applicant' => array(
'scopes' => array('deletedStatus'),
'params' => array(':deletedStatus' => 0)
),
Thanks for help!
Scopes not working, coz it call in ApplicantDocument, not in applicant. So i am try it solution and it help me.
$criteria->with = array('applicant');
$criteria->together = true;
$criteria->condition = "applicant.is_deleted = 0";

CakePHP many conditions to one field

This code:
$conditions = array(
'fields' => array(
'User.id'
),
'conditions' => array(
'AND' => array(
'UsersProblem.problem_id' => 38,
'UsersProblem.problem_id' => 34,
),
),
'recursive' => -1
);
$conditions['joins'][] = array(
'table' => 'users_problems',
'alias' => 'UsersProblem',
'type' => 'INNER',
'conditions' => array(
'User.id = UsersProblem.user_id',
));
Is transforming to this SQL query:
SELECT `User`.`id`
FROM `lawyers`.`users`
AS `User`
INNER JOIN `lawyers`.`users_problems`
AS `UsersProblem`
ON (`User`.`id` = `UsersProblem`.`user_id`)
WHERE `UsersProblem`.`problem_id` = 34
Where is AND UsersProblem.problem_id = 38"?
How to create correct find condition to get users with some list of problems? Which are linked as many to many relationship.
Using $this->Problem->find is not possible, beause I need to use 2 joins: users_problems and users_practices. And use for them AND condition, like this:
'AND' => array(
'UsersProblem.problem_id' => 38,
'UsersProblem.problem_id' => 34,
'UsersPractices.practice_id' => 1,
'UsersPractices.practice_id' => 2,
),
You're overwriting 'UsersProblem.problem_id'. Just think about it like the array it is. CakePHP is just using the PHP array structure to do these finds, and that means it follows array rules. But to get around that in cakephp, you're supposed to use a two dimensional array
Like this:
'AND' => array(
array('UsersProblem.problem_id' => 38),
array('UsersProblem.problem_id' => 34)
),
Instead of this:
'AND' => array(
'UsersProblem.problem_id' => 38,
'UsersProblem.problem_id' => 34
),
That way, instead of trying to set the key 'UsersProblem.problem_id' twice, you're making an array that looks like
0 -> array('UsersProblem.problem_id' => 38)
1 -> array('UsersProblem.problem_id' => 34)
And that will work, it's a workaround the CakePHP guys built into the system for this kind of situation.
I think you need to use OR instead of AND:
$conditions = array(
'fields' => array(
'User.id'
),
'conditions' => array(
'OR' => array(
array('UsersProblem.problem_id' => 38),
array('UsersProblem.problem_id' => 34),
),
),
'recursive' => -1
);
You can also roll this up as follows:
$conditions = array(
'fields' => array(
'User.id'
),
'conditions' => array(
'OR' => array(
'UsersProblem.problem_id' => array(34, 38)
),
'recursive' => -1
);
Change your conditions array as shown below:
$options = array(
'fields' => array('User.id'),
'conditions' => array('UsersProblem.problem_id' => array(38,34)),
'recursive' => -1
);
$options['joins'] = array(
array(
'table' => 'users_practices',
'alias' => 'UsersPractices',
'type' => 'INNER',
'conditions' => array(
/CONDITION OF JOIN/
),
array(
'table' => 'users_problems',
'alias' => 'UsersProblem',
'type' => 'INNER',
'conditions' => array(
'User.id = UsersProblem.user_id',
)
);
From User Model:
$this->find('list',$options);
Do not use AND/ OR because they are not optimized for above case.
For reference:
MYSQL OR vs IN performance
and
CakePHP right way to do this (get value from setting's table)
**Try the code for join tables in cakephp.......**
$options = array('joins' => array(
array(
'table' => 'modelname1',
'alias' => 'modelName1',
'type' => 'LEFT',
'foreignKey' => false,
'conditions' => array('modelname1.id = modelname2.mid')
)
),
'fields' => array('modelName1.field1', 'modelName1.field2', 'modelName2.field1', 'modelName2.field2'),
'conditions' => array('modelname.id' => 1, 'modelname2.field1' => ''),
'limit' => 10, 'page' => 1);
$this->modelName2->find($options);