Ok I reproduce the bug.

Thanks

Le 21/01/2015 09:20, Moron, Olivier a écrit :

I agree with the choice you’ve made regarding translation of not-translated intermediate items.

That’s not the problem in fact, I’ll explain:

In fact completename for Test 3-2 is "fr: Test 3 > test 3-1 > test 3-2"

But must be "fr: Test 3 >  test 3-2"

The problem is that the name of the previous sibling is added to the completename…

And this is due to the fact the completename is concatenated with all previous names in the generateCompletenamefunction

Regards,

*Olivier MORON
*Miscellaneous Program Member

*RAYNET SNC*
Tel : +33 4 76 33 49 52
Fax: +33 4 76 70 56 63

*From:*Glpi-user [mailto:[email protected]] *On Behalf Of *Julien Dombre
*Sent:* Wednesday, January 21, 2015 9:10 AM
*To:* [email protected]
*Subject:* Re: [Glpi-user] Fix proposal for: http://www.glpi-project.org/forum/viewtopic.php?id=46119

In fact I read again your post and I do not understand...
Translations are take into account and you tjink it is not normal for items which are not translated to use translated sons ?

It is the choice we done : all translated parents are used to create all translated values (sons...)

In your example your are not completly logic because :
Test 3-1 -> "fr: Test 3 > Test 3-1" -> OK
but
Test 3-2 -> "fr: Test 3 > test 3-1 > test 3-2" -> NOK

These 2 cases are the same no ?

Regards



Le 21/01/2015 08:53, Julien Dombre a écrit :

    Le 21/01/2015 08:47, Moron, Olivier a écrit :

        0.85.1: see my forum post, I explain how to reproduce this bug


    I have already tru to reproduce... without succes.
    Will try another time...


    *Regards,*

    *Olivier MORON
    *Miscellaneous Program Member

    *RAYNET SNC*
    Tel : +33 4 76 33 49 52
    Fax: +33 4 76 70 56 63

    *From:*Glpi-user [mailto:[email protected]] *On Behalf Of
    *Julien Dombre
    *Sent:* Wednesday, January 21, 2015 7:59 AM
    *To:* [email protected] <mailto:[email protected]>
    *Subject:* Re: [Glpi-user] Fix proposal for:
    http://www.glpi-project.org/forum/viewtopic.php?id=46119

    Hi,

    which GLPI version ?
    I do not reproduce on 0.85 version.

    Regards


    Le 20/01/2015 16:00, Moron, Olivier a écrit :

        Dear all,

        I propose the following fix for the bug explained in this
        post: http://www.glpi-project.org/forum/viewtopic.php?id=46119

        /**

        *Generate completename associated with a tree dropdown

        *

        *@paraminput array of user values

        *@paramadd true if translation is added, false if update

        *

        *@returnnothing

        */

        functiongenerateCompletename($input, $add= true) {

        //If there's already a completename for this language, get
        it's ID, otherwise 0

        $completenames_id= self::getTranslationID($input['items_id'],
        $input['itemtype'],

        'completename', $input['language']);

        $item= new$input['itemtype']();

        //Completename is used only for tree dropdowns !

        if($iteminstanceofCommonTreeDropdown &&
        isset($input['language'])) {

        $item->getFromDB($input['items_id']);

        //Regenerate completename : look for item's ancestors

        $completename= "";

        //Get ancestors as an array

        $cache= getAncestorsOf($item->getTable(), $item->getID());

        if(!empty($cache)) {

        foreach($cacheas$ancestor) {

        if($completename!= ''&& $ancestor!= $item->getID()) {

        $completename.= " > ";

        }

        $completename.= self::getTranslatedValue($ancestor,
        $input['itemtype'], 'name',

        $input['language']);

        }

        }

        if($completename!= '') {

        $completename.= " > ";

        }

        $completename.= self::getTranslatedValue($item->getID(),
        $input['itemtype'], 'name',

        $input['language']);

        //Add or update completename for this language

        $translation= newself();

        $tmp['items_id'] = $input['items_id'];

        $tmp['itemtype'] = $input['itemtype'];

        $tmp['field'] = 'completename';

        $tmp['value'] = addslashes($completename);

        $tmp['language'] = $input['language'];

        $tmp['_no_completename'] = true;

        if($completenames_id) {

        $tmp['id'] = $completenames_id;

        $translation->update($tmp);

        } else{

        $translation->add($tmp);

        }

        }

        $completenames= array( ) ;

        $completenames[ $input['items_id'] ] = $completename;

        $foreignKey= $item->getForeignKeyField() ;

        foreach(getSonsOf($item->getTable(), $item->getID()) as$son) {

        //Try to regenerate translated completename only if a
        completename already exists

        //for this son

        $completenames_id= self::getTranslationID($son,
        $input['itemtype'],

        'completename', $input['language']);

        if($son!= $item->getID()) {

        //get son value

        $son_item= new$input['itemtype']();

        $son_item->getFromDB($son);

        //$completename .= " > ".self::getTranslatedValue($son,
        $input['itemtype'], 'name',

        // $input['language'],

        // $son_item->fields['name']);

        $completenames[ $son] = $completenames[ $son_item->fields[
        $foreignKey] ] ." > ". self::getTranslatedValue($son,
        $input['itemtype'], 'name', $input['language'],
        $son_item->fields['name']);

        unset($tmp['id']);

        $tmp['items_id'] = $son;

        $tmp['itemtype'] = $input['itemtype'];

        $tmp['field'] = 'completename';

        $tmp['value'] = addslashes($completenames[ $son]);

        $tmp['language'] = $input['language'];

        $tmp['_no_completename'] = true;

        if($completenames_id) {

        $tmp['id'] = $completenames_id;

        $translation->update($tmp);

        } else{

        $translation->add($tmp);

        }

        }

        }

        }

        Is there someone who can push this to GLPI repo?

        Thank you,

        Regards,

        Olivier MORON

        Miscellaneous Program Member

        RAYNET SNC

        Tel : +33 4 76 33 49 52

        Fax: +33 4 76 70 56 63





        _______________________________________________

        Glpi-user mailing list

        [email protected]  <mailto:[email protected]>

        https://mail.gna.org/listinfo/glpi-user




    _______________________________________________

    Glpi-user mailing list

    [email protected]  <mailto:[email protected]>

    https://mail.gna.org/listinfo/glpi-user





    _______________________________________________

    Glpi-user mailing list

    [email protected]  <mailto:[email protected]>

    https://mail.gna.org/listinfo/glpi-user



_______________________________________________
Glpi-user mailing list
[email protected]
https://mail.gna.org/listinfo/glpi-user

_______________________________________________
Glpi-user mailing list
[email protected]
https://mail.gna.org/listinfo/glpi-user

Reply via email to