Exemplo n.º 1
0
        $batch->about = $_POST['about'];
        $batch->pending = $_POST['pending'];
        $batch->enabled = $_POST['enabled'];
        $batch->fromyear = $_POST['fromyear'];
        $batch->schoolid = $_POST['schoolid'];
        $batch->update();
        $log = new Log($session->user_id, $clientip, "WEB", "UPDATED BATCH: " . $_POST['id']);
        $log->create();
    } else {
        if ($_POST['oper'] == 'del') {
            $log = new Log($session->user_id, $clientip, "WEB", "DELETED BATCH: " . $_POST['id']);
            $log->create();
            $batch = Batch::get_by_id($_POST['id']);
            SectionUser::delete_all_by_schoolid($batch->schoolid);
            Section::delete_all_by_schoolid($batch->schoolid);
            BatchUser::delete_all_by_batchid($batch->id);
            $folder_path = "../../public/schools/" . $batch->schoolid . "/yearbooks/" . $batch->id;
            rrmdir($folder_path);
            $batch->delete();
        }
    }
}
function rrmdir($dir)
{
    foreach (glob($dir . '/*') as $file) {
        if (is_dir($file)) {
            rrmdir($file);
        } else {
            unlink($file);
        }
    }