Integrates new phone table in profile and other pages
[platal.git] / bin / cron / checkdb.php
index b8bab65..fcb56b5 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -64,9 +64,8 @@ if ( PEAR::isError($opts) ) {
     $opts = $opts[0];
     foreach ( $opts as $opt) {
         switch ($opt[0]) {
-            case "v":
-                $opt_verbose=true;
-            echo "Mode verbeux\n";
+          case "v":
+            $opt_verbose=true;
             break;
         }
     }
@@ -74,24 +73,16 @@ if ( PEAR::isError($opts) ) {
 
 /* Validite des flags de transmission */
 check("SELECT  u.user_id, nom, prenom, promo,
-               profile_mobile_pub, emails_alias_pub, profile_web_pub, profile_freetext_pub, profile_medals_pub
+               emails_alias_pub, profile_freetext_pub, profile_medals_pub
          FROM  auth_user_md5 AS u
    INNER JOIN  auth_user_quick AS q USING(user_id)
-        WHERE  (profile_mobile_pub != 'private' AND profile_mobile_pub != 'ax' AND profile_mobile_pub != 'public')
-           OR  (emails_alias_pub != 'private' AND emails_alias_pub != 'public')
-           OR  (profile_web_pub != 'private' AND profile_web_pub != 'public')
+        WHERE  (emails_alias_pub != 'private' AND emails_alias_pub != 'public')
            OR  (profile_freetext_pub != 'private' AND profile_freetext_pub != 'public')
            OR  (profile_medals_pub != 'private' AND profile_medals_pub != 'public')",
     "Utilisateur n'ayant pas de flag de publicite pour leurs donnees de profil");
 check("select uid from adresses where pub != 'private' and pub !='ax' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour une adresse");
-check("select uid from tels where tel_pub != 'private' and tel_pub !='ax' and tel_pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour un numero de telephone");
-
-/* validite de adresses */
-check("select uid, count(adrid) from adresses group by uid having count(adrid) > 7", "Utilisateurs ayant trop d'adresses");
-
-/* Validite des tables de langues, competences, mentoring*/
-check("select uid, count(lid) from langues_ins group by uid having count(lid) > 10","Utilisateurs ayant trop de langues");
-check("select uid, count(cid) from competences_ins group by uid having count(cid) > 20","Utilisateurs ayant trop de competences");
+check("select uid from telephone where pub != 'private' and pub != 'ax' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour un numero de telephone");
+check("select uid from profile_networking where pub != 'private' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicité pour une adresse de networking");
 
 /* validite de aliases */
 check("SELECT a.*
@@ -183,5 +174,32 @@ check("SELECT  matricule,nom,prenom,matricule_ax,COUNT(matricule_ax) AS c
         WHERE  matricule_ax != '0'
         GROUP BY  matricule_ax
         having  c > 1", "à chaque personne de l'annuaire de l'AX (identification_ax) doit correspondre AU PLUS UNE personne de notre annuaire (auth_user_md5) -> si ce n'est pas le cas il faut regarder en manuel ce qui ne va pas !");
+        
+/* each alumni has one and only one display name by default and one and only one name when we talk to him directly */
+check("SELECT u.`user_id`, u.`nom`, u.`prenom`, COUNT(n.`display`) AS c
+        FROM `auth_user_md5` AS u
+        LEFT JOIN `profile_names_display` AS n ON(u.`user_id` = n.`user_id` AND FIND_IN_SET(n.`reason`, 'default'))
+        GROUP BY u.`user_id`
+        HAVING c != 1", "chaque personne doit avoir un et un seul nom par défaut");
+check("SELECT u.`user_id`, u.`nom`, u.`prenom`, COUNT(n.`display`) AS c
+        FROM `auth_user_md5` AS u
+        LEFT JOIN `profile_names_display` AS n ON(u.`user_id` = n.`user_id` AND FIND_IN_SET(n.`reason`, 'yourself'))
+        GROUP BY u.`user_id`
+        HAVING c != 1", "chaque personne doit avoir un et un seul nom quand on lui parle");
+
+/* no alumni is allowed to have empty names */
+check("SELECT u.`user_id`, u.`nom`, u.`prenom`
+        FROM `auth_user_md5` AS u
+        INNER JOIN `profile_names_search` AS n USING(`user_id`)
+        WHERE n.`search_name` = ''", "liste des personnes qui ont un de leur nom de recherche vide");
+        
+/* verifie qu'il n'y a pas d'utilisateurs ayant un compte Google Apps désactivé et une redirection encore active vers Google Apps */
+check("SELECT  a.alias, g.g_status, u.mail_storage
+         FROM  auth_user_md5 AS u
+   INNER JOIN  aliases AS a ON (a.id = u.user_id AND a.type = 'a_vie')
+   INNER JOIN  gapps_accounts AS g ON (g.l_userid = u.user_id)
+        WHERE  FIND_IN_SET('googleapps', u.mail_storage) > 0 AND g.g_status != 'active'",
+      "utilisateurs ayant une redirection vers Google Apps alors que leur compte GApps n'est pas actif");
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>