<?php // charset=utf-8
/**
 * Action pagemod followed by sendemail for DokuWiki plugin bureaucracy
 */

class syntax_plugin_bureaucracy_action_pagemodandmail extends syntax_plugin_bureaucracy_action {

    /**
     * Simply extract the relevant arguments and call the relevant actions
     */
    function run($data, $thanks, $argv) {
        global $ID;
        global $conf;
        require_once(DOKU_PLUGIN . 'bureaucracy/actions/action.php');
        require_once(DOKU_PLUGIN . 'bureaucracy/actions/pagemod.php');
        require_once(DOKU_PLUGIN . 'bureaucracy/actions/mail.php');

        $pagemodargs = array_slice($argv,0,2);
        $emailargs = array_slice($argv,2);

        $class = 'syntax_plugin_bureaucracy_action_pagemod';
        $pagemodder = new $class();
        $pagemodsuccess = $pagemodder->run($data, $thanks, $pagemodargs);

        $class = 'syntax_plugin_bureaucracy_action_mail';
        $emailer = new $class();
        $emailsuccess = $emailer->run($data, $thanks, $emailargs);

        $rmsg = '';
        if (!$pagemodsuccess) {$rmsg .= "Pagemod failed";}
        if (!$emailsuccess) {$rmsg .= "Emailing failed";}
        if ($rmsg=='') {return $thanks;}
        else {return $rmsg.join(',',$errors);}
    }
}