function tripal_expire_collections
3.x tripal.collections.api.inc | tripal_expire_collections() |
Deletes all collections that have surpassed their lifespan
Related topics
1 string reference to 'tripal_expire_collections'
- tripal_cron in tripal/
tripal.module - Implements hook_cron().
File
- tripal/
api/ tripal.collections.api.inc, line 111 - Provides the API for working with Data collections. This includes creation, experiation, and retreival.
Code
function tripal_expire_collections() {
$max_days = variable_get('tripal_data_collections_lifespan', 30);
$ctime = time();
$query = db_select('tripal_collection', 'tc');
$query->fields('tc', array('collection_id'));
$query->where("((($ctime - create_date) / 60) / 60) / 24 >= $max_days");
$results = $query->execute();
while ($collection_id = $results->fetchField()) {
$collection = new TripalEntityCollection();
$collection->load($collection_id);
$collections[] = $collection;
$collection->delete();
}
return $collections;
}