Subversion Repositories eFlore/Applications.cel

Rev

Rev 416 | Rev 754 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
416 aurelien 1
<?php
2
// in utf8
3
// out utf8
4
 
5
// List des stations par utilisateur et par commune
6
 
7
Class InventoryUserList extends DBAccessor {
8
 
9
 
10
    var $config;
11
 
12
    function InventoryUserList($config) {
13
 
14
        $this->config=$config;
15
    }
16
 
17
 
18
    function getElement($uid){
19
 
20
           // Controle detournement utilisateur
21
            session_start();
22
           $this->controleUtilisateur($uid[0]);
23
 
24
            // uid[0] : utilisateur obligatoire
25
            $DB=$this->connectDB($this->config,'database_cel');
26
 
27
            $value=array();
28
 
29
            $query='SELECT DISTINCT identifiant FROM cel_inventory' ;
30
 
31
            if(isset($uid[1]) && $uid[1] != null && $uid[1] != '*') {
32
                $query .= ' WHERE identifiant LIKE "'.$DB->escapeSimple($uid[1]).'%"';
33
            }
34
 
35
            $res =& $DB->query($query);
36
 
37
                if (DB::isError($res)) {
38
                    die($res->getMessage());
39
                }
40
 
41
                $i = 0;
42
                while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
43
                    $value[$i] =$row['identifiant'];
44
                    $i++;
45
                }
46
 
47
                usort($value,'trierUtilisateurs');
48
 
423 aurelien 49
                $output = json_encode($value);
416 aurelien 50
                print($output);
51
 
52
                return true;
53
    }
54
}
55
 
56
function trierUtilisateurs($val1, $val2) {
57
 
58
        if(strstr($val1,'@')) {
59
 
60
            if(strstr($val2,'@')) {
61
                return strcmp($val1,$val2);
62
            }
63
            else
64
            {
65
                return -1 ;
66
            }
67
        }
68
        else
69
        {
70
            if(strstr($val2,'@')) {
71
                return 1 ;
72
            }
73
            else
74
            {
75
                return strcmp($val1,$val2) ;
76
            }
77
        }
78
 
79
    }
80
 
81
 
82
/* +--Fin du code ---------------------------------------------------------------------------------------+
83
* $Log$
84
* Revision 1.3  2008-01-30 08:57:28  ddelon
85
* fin mise en place mygwt
86
*
87
* Revision 1.2  2007-05-22 12:54:09  ddelon
88
* Securisation acces utilisateur
89
*
90
*
91
*
92
*/
93
 
94
 
95
?>