Gestion simplissime des Todo

crabs_todo-2.0 ©2008-2011 - Christophe Cazajus (crabs-mettre_le_signe_at-crabs-world.com)

~~ / hr_todo_list.php
Makefile todo.css todo.js onglet.js liste.js detail.js modif.js index.php logout.php todo.php hr_todo_create.php hr_todo_list.php hr_todo_info.php hr_todo_change.php hr_todo_del.php hr_projet_liste.php hr_pseudo_liste.php
    1 <?php
    2 //
    3 // =============================================================================
    4 //  crabs_todo-2.0 : Gestion simplissime des Todo
    5 //  Copyright (C) 2008-2011 : Christophe Cazajus (crabs-mettre_le_signe_at-crabs-world.com)
    6 //
    7 //  Ce source fait partie d'un projet logiciel libre. Vous pouvez le distribuer
    8 //  et/ou le modifier en respectant les termes de la GNU General Public License
    9 //  version 2 ou (suite a votre propre choix) une version ulterieure.
   10 //
   11 //  Ce programme est distribue dans l'espoir qu'il puisse etre utile, mais
   12 //  sans aucune garantie, meme si il est associe a un produit qui vous en
   13 //  propose une. Conformez-vous a la GNU General Public License pour avoir
   14 //  plus de precisions.
   15 //
   16 //  L'auteur ne peut etre tenu responsable de l'utilisation faite des
   17 //  composantes associees a ce projet (en partie ou dans leur totalite).
   18 //
   19 //  Une copie du fichier de la GNU GPL est fournie dans le repertoire DOC
   20 //  de ce projet sous le nom gnu_gpl.txt
   21 //
   22 // =============================================================================
   23 //
   24 // HTTP REQUEST...
   25 //  lignes separees par <#>
   26 //  colonnes separees par <!>
   27 //  champs 0 : id du todo
   28 //  champs 1 : etat du todo (state => fs)
   29 //  champs 2 : traitement du todo (work => fw)
   30 //  champs 3 : priorite du todo (priority => fp )
   31 //  champs 4 : projet
   32 //  champs 5 : tache
   33 //  champs 6 : createur
   34 //  champs 7 : prive/public
   35 //  champs 8 : date
   36 //  champs 9 : pour le
   37 
   38 $ROOT = '' ;
   39 include( "{$ROOT}LIB/param.php" ) ;
   40 include( "{$ROOT}LIB/util.php" ) ;
   41 include( "{$ROOT}LIB/mysql.php" ) ;
   42 
   43 if ( !array_key_exists( 'PHPSESSID', $_REQUEST ) )
   44     { header( 'Location: '.$ROOT_URL ) ; exit ; }
   45 session_set_cookie_params(0,relative2absolute('.', true)) ;
   46 session_start() ;
   47 $pseudo = $_SESSION['user']['pseudo'] ;
   48 
   49 
   50 $projet =  toMySQL( fromGET( 'projet', '0' ) ) ;
   51 $createur =  toMySQL( fromGET( 'pseudo', '0' ) ) ;
   52 
   53 // on enleve les 2 premieres lettres pour obtenir la valeur
   54 $filtres = array( 'fw'=>'w', 'fp'=>'p', 'fr'=>'r' ) ;
   55 foreach( $filtres as $get => $var )
   56     $$var = toMySQL( substr( fromGET( $get, 0 ), 2 ) ) ;
   57 
   58 // cette clause est un calcul => 'having'
   59 $having = array( 'fs'=>'s' ) ;
   60 foreach( $having as $get => $var )
   61     $$var = toMySQL( substr( fromGET( $get, 0 ), 2 ) ) ;
   62 
   63 switch ( $createur )
   64     {
   65     case '0':
   66         $where = "( ( pseudo='$pseudo' ) OR ( pseudo<>'$pseudo' AND r=1 ) )" ;
   67     break ;
   68     case $pseudo :
   69         $where = "pseudo='$pseudo'" ;
   70     break ;
   71     default :
   72         $where = "pseudo='$createur' AND r=1" ;
   73     }
   74 
   75 if ( $projet != '0' ) $where .= " AND projet='{$projet}'" ;
   76 
   77 foreach( $filtres as $var )
   78     if ( $$var != 0 ) $where .= " AND {$var}='{$$var}'" ;
   79 
   80 $and = 'HAVING' ;
   81 foreach( $having as $var )
   82     if ( $$var != 0 ) { $where .= " {$and} {$var}='{$$var}'" ; $and='AND' ; }
   83 
   84 $order_by = "s DESC, w DESC, p DESC, id DESC" ;
   85 
   86 $sql = <<<SQL
   87     SELECT id, ${DB_PRFX}state( w, p, ouverture, pour_le ) AS s,
   88         w, p, projet, tache, pseudo, r,
   89         DATE_FORMAT( ouverture, '%d/%m/%Y') as ouverture_fr,
   90         IFNULL( DATE_FORMAT( pour_le, '%d/%m/%Y'), '---' ) as pour_le_fr
   91     FROM ${DB_PRFX}todo
   92     WHERE $where
   93     ORDER BY $order_by
   94 
   95 SQL;
   96 
   97 $todo = array() ;
   98 $c = new MYSQL( true, false ) ;
   99 $res = $c->query( $sql ) ;
  100 $todo[] = 'OK' ;
  101 while ( $r = mysql_fetch_assoc( $res ) )
  102     {
  103     $attr = array() ;
  104     foreach( $r as $var => $val ) $attr[$var] = toJS( fromMySQL( $val ) ) ;
  105     $todo[] =  implode( '<!>', $attr ) ;
  106     }
  107 echo implode( '<#>', $todo ) ;
  108 ?>
Makefile todo.css todo.js onglet.js liste.js detail.js modif.js index.php logout.php todo.php hr_todo_create.php hr_todo_list.php hr_todo_info.php hr_todo_change.php hr_todo_del.php hr_projet_liste.php hr_pseudo_liste.php
~~ / hr_todo_list.php

Haut de page

Contacter crabs

Date de génération : 22/09/2011 21:49