public function update_after_restore($restoreid, $courseid, \base_logger $logger, $name)
 {
     global $DB;
     if (!$this->roleid) {
         // If using 'same as activity' option, no need to change it.
         return false;
     }
     $rec = \restore_dbops::get_backup_ids_record($restoreid, 'role', $this->roleid);
     if (!$rec || !$rec->newitemid) {
         // If we are on the same course (e.g. duplicate) then we can just
         // use the existing one.
         if ($DB->record_exists('roles', array('id' => $this->roleid, 'courseid' => $courseid))) {
             return false;
         }
         // Otherwise it's a warning.
         $this->roleid = -1;
         $logger->process('Restored item (' . $name . ') has availability condition on grouping that was not restored', \backup::LOG_WARNING);
     } else {
         $this->roleid = (int) $rec->newitemid;
     }
     return true;
 }
Example #2
0
 public function __construct($level, $datecol = false, $levelcol = false, $messagecol = null, $logtable = null, $columns = null)
 {
     // TODO check $datecol exists
     // TODO check $levelcol exists
     // TODO check $logtable exists
     // TODO check $messagecol exists
     // TODO check all $columns exist
     $this->datecol = $datecol;
     $this->levelcol = $levelcol;
     $this->messagecol = $messagecol;
     $this->logtable = $logtable;
     $this->columns = $columns;
     parent::__construct($level, (bool) $datecol, (bool) $levelcol);
 }
Example #3
0
 static function end($shutdown = false)
 {
     if (self::$path) {
         self::$finish = true;
         $content = ob_get_contents();
         ob_end_clean();
         $name = array_pop(self::$path);
         if (defined('SHOP_DEVELOPER')) {
             error_log("\n\n" . str_pad(@date(DATE_RFC822) . ' ', 60, '-') . "\n" . $content, 3, ROOT_DIR . '/data/trace.' . $name . '.log');
         }
         if ($shutdown) {
             echo json_encode(array('rsp' => 'fail', 'res' => $content, 'data' => null));
         }
         return $content;
     }
 }
Example #4
0
 public function __construct($level, $showdate = false, $showlevel = false, $fullpath = null)
 {
     if (empty($fullpath)) {
         throw new base_logger_exception('missing_fullpath_parameter', $fullpath);
     }
     if (!is_writable(dirname($fullpath))) {
         throw new base_logger_exception('file_not_writable', $fullpath);
     }
     // Open the OS file for writing (append)
     $this->fullpath = $fullpath;
     if ($level > backup::LOG_NONE) {
         // Only create the file if we are going to log something
         if (!($this->fhandle = fopen($this->fullpath, 'a'))) {
             throw new base_logger_exception('error_opening_file', $fullpath);
         }
     }
     parent::__construct($level, $showdate, $showlevel);
 }
Example #5
0
 public function async_result_handler($params)
 {
     base_logger::begin(__FUNCTION__);
     $result = new base_rpc_result($_POST);
     $row = app::get('base')->model('rpcpoll')->getlist('callback,callback_params', array('id' => $params['id'], 'type' => 'request'), 0, 1);
     if ($row) {
         list($class, $method) = explode(':', $row[0]['callback']);
         if ($class && $method) {
             $result->set_callback_params(unserialize($row[0]['callback_params']));
             kernel::single($class)->{$method}($result);
         }
     }
     $return = array('rst' => 'ok', 'id' => $params['id'], 'error' => null);
     app::get('base')->model('rpcpoll')->delete(array('id' => $params['id'], 'type' => 'request'));
     if (!$return) {
         $return = array('id' => $request->id, 'error' => 'bad request-id:' . $request->id);
     }
     base_logger::end();
     header('Content-type: text/plain');
     echo json_encode($return);
 }
Example #6
0
 public function get_levelstr($level)
 {
     return parent::get_levelstr($level);
 }