<?php

/* cron script to perform all the periodic search tasks
*
* delete.php
*   updates the index by pruning deleted documents
*
* update.php
*   updates document info in the index if the document has been modified since indexing
*
* add.php
*   adds documents created since the last index run
*/

// (Shirai147): グローバルサーチのインデックスの更新（search/cron.php）をコマンドラインでも実行可能とする改良 (2009/06/05)
// (Shirai147): ここから追加
    /**
    * includes and requires
    */
    if (!isset($_SERVER['REMOTE_ADDR'])) {
        if (isset($_SERVER['argv'][0])) {
            chdir(dirname($_SERVER['argv'][0]));
        }
        require_once('../config.php');
        if (!defined('FULLME')) define('FULLME', 'cron');
/// emulate normal session
        $SESSION = new object();
        $USER = get_admin();      /// Temporarily, to provide environment for this script

/// ignore admins timezone, language and locale - use site deafult instead!
        $USER->timezone = $CFG->timezone;
        $USER->lang = '';
        $USER->theme = '';
        course_setup(SITEID);
    }
// (Shirai147): ここまで追加
    if (!defined('MOODLE_INTERNAL')) {
        die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
    }

    require_once("$CFG->dirroot/search/lib.php");

    if (empty($CFG->enableglobalsearch)) {
        mtrace('Global searching is not enabled. Nothing performed by search.');
    }
    else{
       include("{$CFG->dirroot}/search/cron_php5.php");
    }
?>