The processes

When all the verifications have been made, the processes are then executed.
Very often, these processes call functions that exist in the same file, or functions in a library in the inc/ directory. Sometimes the action will be to simply execute the file’s own main function.

Example of assigning moderation rights to an article

// Modifier le reglage des forums publics de l'article x
// Modify the moderation rights for the public form on article x
function action_regler_moderation_dist()
{
    include_spip('inc/autoriser');

    $securiser_action = charger_fonction('securiser_action', 'inc');
    $arg = $securiser_action();

    if (!preg_match(",^\W*(\d+)$,", $arg, $r)) {
        spip_log("action_regler_moderation_dist $arg pas compris");
        return;
    }

    $id_article = $r[1];
    if (!autoriser('modererforum', 'article', $id_article))
        return;

    // traitements - processes
    $statut = _request('change_accepter_forum');
    sql_updateq("spip_articles", array("accepter_forum" => $statut), "id_article=". $id_article);
    if ($statut == 'abo') {
        ecrire_meta('accepter_visiteurs', 'oui');
    }
    include_spip('inc/invalideur');
    suivre_invalideur("id='id_forum/a$id_article'");
}

The processes executed modify the spip_articles table in the database to assign a new management status for forum management. When a forum is requested on subscription, which means you must be logged in to post, we must absolutely be sure that the site actually accepts visitor registrations, which is checked by calling ecrire_meta('accepter_visiteurs', 'oui');.

And finally, a call to invalidate the cached files is executed by calling the suivre_invalideur() function. All of the cache will be recreated (note that from SPIP 2.0 onwards, which was not the case previously, only the relevant section of the cache was invalidated).

Author Mark Baber Published : Updated : 02/06/10

Translations : English, français