You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2007-06-20 09:40:15

mcjo
Member
Registered: 2007-06-20
Posts: 1

Ajout de fonctionnalité sur la visualisation des tickets

Le but est d'ajouter un niveau de visualisation des postes, ainsi un utilisateur aurait la possibilité de voir les tickets des utilisateurs de son groupe, sans qu'on est besoin d'attribuer un ticket à un groupe, ni via une règle ni manuellement.

J'ai donc fait quelques modifications sur la version du SVN récupérée lundi.
J'espère ne rien avoir oublier.
Dans les pramétrage des profils, il devrait apparaître en plus : "Voir les tickets des utilisateurs de mes groupes"

modifier la classe user.class.php, dans la classe User ajouter :

        function getGroupFromDB() {
                global $DB;
                $sql = "SELECT * FROM glpi_users_groups WHERE FK_users=".$this->fields["ID"]."";

                $this->fields["groups"] = array();

                $resultat = $DB->query($sql);
                while ($data=$DB->fetch_array($resultat)){
                        $this->fields["groups"][] = $data["FK_groups"];
                }
        }

fichier inc/profiles.class.php :
Classe Profile
fonction cleanProfile()

remplacer

$helpdesk=array("ID","name","interface","faq","reservation_helpdesk","create_ticket","comment_ticket","observe_ticket","password_update","helpdesk_hardware","helpdesk_hardware_type","show_group_ticket","show_group_hardware");

par

$helpdesk=array("ID","name","interface","faq","reservation_helpdesk","create_ticket","comment_ticket","observe_ticket","password_update","helpdesk_hardware","helpdesk_hardware_type","show_group_ticket","show_group_hardware", "show_usersgroup_ticket");

puis
fonction showHelpdeskForm($ID)

après

echo "<tr class='tab_bg_2'>";
                echo "<td>".$LANG["profiles"][9].":</td><td>";
                dropdownYesNo("observe_ticket",$this->fields["observe_ticket"]);
                echo "</td>";
                echo "<td>".$LANG["profiles"][26].":</td><td>";
                dropdownYesNo("show_group_ticket",$this->fields["show_group_ticket"]);
                echo "</td>";
                echo "</tr>";

ajouter

echo "<tr class='tab_bg_2'>";
                echo "<td>&nbsp;</td><td>&nbsp;";
                echo "</td>";
                echo "<td>".$LANG["profiles"][32].":</td><td>";
                dropdownYesNo("show_usersgroup_ticket",$this->fields["show_usersgroup_ticket"]);
                echo "</td>";
                echo "</tr>";

fonction showCentralForm($ID)
après

echo "<tr class='tab_bg_2'>";
                echo "<td>".$LANG["profiles"][20].":</td><td>";
                dropdownYesNo("show_planning",$this->fields["show_planning"]);
                echo "</td>";
                echo "<td>".$LANG["profiles"][21].":</td><td>";
                dropdownYesNo("show_all_planning",$this->fields["show_all_planning"]);
                echo "</td>";

                echo "<td>".$LANG["profiles"][26]."</td><td>";
                dropdownYesNo("show_group_ticket",$this->fields["show_group_ticket"]);
                echo "</td></tr>";

ajouter

echo "<tr class='tab_bg_2'>";
                echo "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>";
                echo "<td>".$LANG["profiles"][32].":</td><td>";
                dropdownYesNo("show_usersgroup_ticket",$this->fields["show_usersgroup_ticket"]);
                echo "</td>";
                echo "</tr>";

fichier locales/fr_FR.php:

$LANG["profiles"][32]="Voir les tickets des utilisateurs de mes groupes";

le faire aussi pour les autres langues.


fichier inc/tracking.function.php

fonction showTrackingList

else if ($group==-1&&$author!=0&&haveRight("show_group_ticket",1)){
if (count($_SESSION["glpigroups"])){
                        $where.=" AND ( ";
                        $i=0;
                        foreach ($_SESSION["glpigroups"] as $gp){
                                if ($i>0) $where.=" OR ";
                                $where.=" glpi_tracking.FK_group = '$gp' ";
                                $i++;
                        }

par

else if
($group==-1&&$author!=0&&(haveRight("show_group_ticket",1)||haveRight("show_usersgroup_ticket",1))){
if (count($_SESSION["glpigroups"])){
                        $where.=" AND ( ";
                        $i=0;
                        foreach ($_SESSION["glpigroups"] as $gp){
                                if (haveRight("show_group_ticket",1)) {
                                if ($i>0) $where.=" OR ";
                                $where.=" glpi_tracking.FK_group = '$gp' ";
                                }
                                if (haveRight("show_usersgroup_ticket",1)) {
                                if ($i>0) $where.=" OR ";
                                $where.=" OR glpi_tracking.author IN (SELECT FK_users from glpi_users_groups
                                         where glpi_users_groups.FK_groups = '$gp')";
                                }
                                $i++;
                        }

fonction showJobDetails:

if
(!haveRight("show_ticket","1")&&$data["author"]!=$_SESSION["glpiID"]&&$data["assign"]!=$_SESSION["glpiID"]&&(!haveRight("show_group_ticket",1)||!in_array($data["FK_group"],$_SESSION["glpigroups"])))
{
        return false;
}

par

if (!haveRight("show_ticket","1")
                        &&$job->fields["author"]!=$_SESSION["glpiID"]
                        &&$job->fields["assign"]!=$_SESSION["glpiID"]
                        &&!($_SESSION["glpiactiveprofile"]["show_group_ticket"]&&in_array($job->fields["FK_group"],$_SESSION["glpigroups"]))
){
                                $author=new User();
                                $author->getFromDB($job->fields["author"]);
                                $author->getGroupFromDB();
                                $trouver = false;
                                for ($i=0; $i<count($_SESSION["glpigroups"]) && !$trouver; $i++) {
                                        $trouver = in_array($_SESSION["glpigroups"][$i],
$author->fields["groups"]);
                                }
                                if (!$trouver) Return false;
                }

function showJobShort :

if ($_SESSION["glpiactiveprofile"]["interface"]=="central"){
                        if
(!haveRight("show_ticket","1")&&$data["author"]!=$_SESSION["glpiID"]&&$data["assign"]!=$_SESSION["glpiID"]&&(!haveRight("show_group_ticket",1)||!in_array($data["FK_group"],$_SESSION["glpigroups"])))
                                $nineth_column.="&nbsp;";
                        else
                                $nineth_column.="<a
href=\"".$CFG_GLPI["root_doc"]."/front/tracking.form.php?ID=".$data["ID"]."\"><strong>".$LANG["joblist"][13]."</strong></a>&nbsp;(".$job->numberOfFollowups().")";
                }

par

if ($_SESSION["glpiactiveprofile"]["interface"]=="central"){
                        if
(!haveRight("show_ticket","1")&&$data["author"]!=$_SESSION["glpiID"]&&$data["assign"]!=$_SESSION["glpiID"]&&(!haveRight("show_group_ticket",1)||!in_array($data["FK_group"],$_SESSION["glpigroups"])))
                        {
                                $author=new User();
                                $author->getFromDB($data["author"]);
                                $author->getGroupFromDB();
                                $trouver = false;
                                for ($i=0; $i<count($_SESSION["glpigroups"]) && !$trouver; $i++) {
                                        $trouver = in_array($_SESSION["glpigroups"][$i],
$author->fields["groups"]);
                                }
                                if (!$trouver) {

                                $nineth_column.="&nbsp;";
                                } else
                                $nineth_column.="<a
href=\"".$CFG_GLPI["root_doc"]."/front/tracking.form.php?ID=".$data["ID"]."\"><strong>".$LANG["joblist"][13]."</strong></a>&nbsp;(".$job->numberOfFollowups().")";
                        }
                        else
                                $nineth_column.="<a
href=\"".$CFG_GLPI["root_doc"]."/front/tracking.form.php?ID=".$data["ID"]."\"><strong>".$LANG["joblist"][13]."</strong></a>&nbsp;(".$job->numberOfFollowups().")";
                }

Last edited by mcjo (2007-06-20 09:41:03)

Offline

Board footer

Powered by FluxBB