Handles canceled payment transactions.
[platal.git] / bin / cron / clean.php
index 195cd4c..76af55d 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require('./connect.db.inc.php');
+require './connect.db.inc.php';
 
 function query ($sql) {
     XDB::execute($sql);
     if (XDB::errno() != 0) {
-       echo "error in \"$sql\" :\n", XDB::error(), "\n";
+       echo "error in \"$sql\":\n", XDB::error(), "\n";
     }
 }
 
-// la table des notifs est nettoyée
-$eight_days_ago = date("YmdHis", time() - 8*24*60*60);
-query("DELETE FROM watch_ops WHERE known<$eight_days_ago");
+query('DELETE FROM  register_pending
+             WHERE  TO_DAYS(NOW()) - TO_DAYS(date) >= 365');
+query('DELETE FROM  register_pending
+             WHERE  hash = \'INSCRIT\'');
 
-query("DELETE FROM register_pending WHERE TO_DAYS(NOW()) - TO_DAYS(date) >= 365");
-query("DELETE FROM register_pending WHERE hash = 'INSCRIT'");
-
-// quelques tables sont triées pour que la lecture triée soit plus facile
-query("ALTER TABLE applis_def ORDER BY text");
-query("ALTER TABLE binets_def ORDER BY text");
-query("ALTER TABLE groupesx_def ORDER BY text");
-query("ALTER TABLE secteur ORDER BY text");
-query("ALTER TABLE sections ORDER BY text");
+// Sorts a few tables to optimize sorted read acces.
+query('ALTER TABLE  profile_binet_enum
+          ORDER BY  text');
+query('ALTER TABLE  profile_corps_enum
+          ORDER BY  name');
+query('ALTER TABLE  profile_corps_rank_enum
+          ORDER BY  name');
+query('ALTER TABLE  profile_education_degree_enum
+          ORDER BY  degree');
+query('ALTER TABLE  profile_education_field_enum
+          ORDER BY  field');
+query('ALTER TABLE  profile_job_enum
+          ORDER BY  name');
+query('ALTER TABLE  profile_langskill_enum
+          ORDER BY  language');
+query('ALTER TABLE  profile_medal_enum
+          ORDER BY  text');
+query('ALTER TABLE  profile_networking_enum
+          ORDER BY  name');
+query('ALTER TABLE  profile_section_enum
+          ORDER BY  text');
+query('ALTER TABLE  profile_skill_enum
+          ORDER BY  text_fr');
 
 // Prunes older autocomplete queries.
-query("DELETE FROM search_autocomplete WHERE generated < DATE_SUB(NOW(), INTERVAL 1 DAY)");
+query('DELETE FROM  search_autocomplete
+             WHERE  generated < DATE_SUB(NOW(), INTERVAL 1 DAY)');
+
+// XXX: cleans profile_merge_issues (to be removed once all merge related issues have been fixed)
+query('DELETE FROM  profile_merge_issues
+             WHERE  issues IS NULL OR issues = \'\'');
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>