Coding with SPIP 3.0
SPIP3.0 Technical Documentation

> > > > taches_generales_cron

taches_generales_cron

This pipeline is used to declare functions that will be periodically executed by SPIP. It is called in the ecrire/inc/genie.php file by the taches_generales function, accepting a parameter and returning output of a keyed array, using function names as the key and the time between execution runs as the value.

  1. return pipeline('taches_generales_cron', $taches_generales);

Please read the section on the Wizard for further information.

Example

Any plugin whatsoever could declare a cleaning function to be run every week:

  1. function carte_postale_taches_generales_cron($taches){
  2. $taches['nettoyer_cartes_postales'] = 7*24*3600; // every week
  3. return $taches;
  4. }

Download

This function is contained in the genie/nettoyer_cartes_postales.php file. It deletes all the files in a given directory that are older than 30 days, by using the purger_repertoire function:

  1. function genie_nettoyer_cartes_postales_dist($t){
  2. // Purge postcards that are older than 30 days
  3. include_spip('inc/invalideur');
  4. purger_repertoire(_DIR_IMG . 'cartes_postales/', array(
  5. 'atime' => (time() - (30 * 24 * 3600)),
  6. ));
  7. return 1;
  8. }

Download

  • Author :
  • Published :
  • Updated : 12/05/17
  • Translations : English, français