Le 21/01/2015 16:38, Moron, Olivier a écrit :

I believe the problem is that in glpi_taskcategories table, the ancestors_cache field is NULL in my DB for Test 3-1-1

I don’t know why…


I think the trouble is for the first translation done...
I am trying to fix it.

*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:glpi-user-boun...@gna.org] *On Behalf Of *Julien Dombre
*Sent:* Wednesday, January 21, 2015 4:31 PM
*To:* glpi-user@gna.org
*Subject:* Re: [Glpi-user] Fix proposal for: http://www.glpi-project.org/forum/viewtopic.php?id=46119

My tests do not shown such a problem...
Will try again...


Le 21/01/2015 16:22, Moron, Olivier a écrit :

    I’ve redone the complete test from empty tables
    (glpi_taskcategories and glpi_dropdownstranslations for
    itemtype=’TaskCategory’), and I got the following results redoing
    the exact test explained on the forum post:

    Add following TaskCategories:

    *Task categories*

        

    *Sub-task*

        

    *Sub-task*

        

    *TaskCategory table completename field*

    Test 1

        

        

        

    Test 1

    Test 2

        

        

        

    Test 2

    Test 3

        

        

        

    Test 3

        

    Test 3-1

        

        

    Test 3 > Test 3-1

        

        

    Test 3-1-1

        

    Test 3 > Test 3-1 > Test 3-1-1

        

        

    Test 3-1-2

        

    Test 3 > Test 3-1 > Test 3-1-2

        

    Test 3-2

        

        

    Test 3 > Test 3-2

    Results after assigned a translation to Test 3-1-1:

    *Task categories*

        

    *Sub-task*

        

    *Sub-task*

        

    *DropdownTranslations table completename*

        

    *Should have been this*

    Test 1

        

        

        

        

    Test 2

        

        

        

        

    Test 3

        

        

        

        

        

    Test 3-1

        

        

        

        

        

    Test 3-1-1

        

    Fr: Test 3-1-1

        

    Test 3 > Test 3-1 > Fr: Test 3-1-1

        

        

    Test 3-1-2

        

        

        

    Test 3-2

        

        

        

    *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:glpi-user-boun...@gna.org] *On Behalf Of
    *Julien Dombre
    *Sent:* Wednesday, January 21, 2015 11:03 AM
    *To:* glpi-user@gna.org <mailto:glpi-user@gna.org>
    *Subject:* Re: [Glpi-user] Fix proposal for:
    http://www.glpi-project.org/forum/viewtopic.php?id=46119

    Le 21/01/2015 10:53, Moron, Olivier a écrit :

        I made a test on my GLPI 0.85.1 and now complete names are
        empty when a translation is not existing


    Are you sure of your test ?
    I do another test without any trouble.



    *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:glpi-user-boun...@gna.org] *On Behalf Of
    *Julien Dombre
    *Sent:* Wednesday, January 21, 2015 9:47 AM
    *To:* glpi-user@gna.org <mailto:glpi-user@gna.org>
    *Subject:* Re: [Glpi-user] Fix proposal for:
    http://www.glpi-project.org/forum/viewtopic.php?id=46119

    I try to fix it writing this function more simplier.
    Fix proposal :
    https://forge.indepnet.net/projects/glpi/repository/revisions/23296

    Regards


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

        You’re welcome,

        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:glpi-user-boun...@gna.org] *On Behalf
        Of *Julien Dombre
        *Sent:* Wednesday, January 21, 2015 9:33 AM
        *To:* Liste de diffusion des utilsateurs de GLPI
        *Subject:* Re: [Glpi-user] Fix proposal for:
        http://www.glpi-project.org/forum/viewtopic.php?id=46119

        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:glpi-user-boun...@gna.org] *On
            Behalf Of *Julien Dombre
            *Sent:* Wednesday, January 21, 2015 9:10 AM
            *To:* glpi-user@gna.org <mailto:glpi-user@gna.org>
            *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:glpi-user-boun...@gna.org]
                *On Behalf Of *Julien Dombre
                *Sent:* Wednesday, January 21, 2015 7:59 AM
                *To:* glpi-user@gna.org <mailto:glpi-user@gna.org>
                *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

                    Glpi-user@gna.org  <mailto:Glpi-user@gna.org>

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








                _______________________________________________

                Glpi-user mailing list

                Glpi-user@gna.org  <mailto:Glpi-user@gna.org>

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









                _______________________________________________

                Glpi-user mailing list

                Glpi-user@gna.org  <mailto:Glpi-user@gna.org>

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







            _______________________________________________

            Glpi-user mailing list

            Glpi-user@gna.org  <mailto:Glpi-user@gna.org>

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






        _______________________________________________

        Glpi-user mailing list

        Glpi-user@gna.org  <mailto:Glpi-user@gna.org>

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





    _______________________________________________

    Glpi-user mailing list

    Glpi-user@gna.org  <mailto:Glpi-user@gna.org>

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




    _______________________________________________

    Glpi-user mailing list

    Glpi-user@gna.org  <mailto:Glpi-user@gna.org>

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



_______________________________________________
Glpi-user mailing list
Glpi-user@gna.org
https://mail.gna.org/listinfo/glpi-user

_______________________________________________
Glpi-user mailing list
Glpi-user@gna.org
https://mail.gna.org/listinfo/glpi-user

Reply via email to