Pending
in package
Hold an uploaded cartridge zip across the Settings import select step.
The file stays on disk; only a token and path live in $_SESSION. Any stash or load also deletes every ccimp* file in temp older than TTL, including other users' abandoned uploads.
Table of Contents
Constants
- FILE_PREFIX : mixed = 'ccimp'
- SESSION_KEY : mixed = 'tsugi_cc_import_pending'
- TTL_SECONDS : mixed = 3600
Methods
- clear() : mixed
- Unlink the stashed zip and drop the session row.
- isStashPath() : bool
- Uploaded cartridges live in the system temp dir with a ccimp prefix.
- load() : array{token: string, path: string, name: string, context_id: int, user_id: int, created: int}|null
- Pending zip for this course and user, or null if none / expired / mismatched.
- matches() : mixed
- True when $token matches the pending row for this course and user.
- stash() : string
- Remember a moved upload for this instructor and course. Replaces any prior pending zip.
- sweep() : mixed
- Unlink every stashed cartridge whose mtime is older than TTL.
- raw() : array{token: string, path: string, name: string, context_id: int, user_id: int, created: int}|null
- sessionKey() : string
Constants
FILE_PREFIX
public
mixed
FILE_PREFIX
= 'ccimp'
SESSION_KEY
public
mixed
SESSION_KEY
= 'tsugi_cc_import_pending'
TTL_SECONDS
public
mixed
TTL_SECONDS
= 3600
Methods
clear()
Unlink the stashed zip and drop the session row.
public
static clear([string|null $sessionKey = null ]) : mixed
Parameters
- $sessionKey : string|null = null
isStashPath()
Uploaded cartridges live in the system temp dir with a ccimp prefix.
public
static isStashPath(string $path) : bool
Parameters
- $path : string
Return values
boolload()
Pending zip for this course and user, or null if none / expired / mismatched.
public
static load(mixed $context_id, mixed $user_id[, string|null $sessionKey = null ]) : array{token: string, path: string, name: string, context_id: int, user_id: int, created: int}|null
Parameters
- $context_id : mixed
- $user_id : mixed
- $sessionKey : string|null = null
Return values
array{token: string, path: string, name: string, context_id: int, user_id: int, created: int}|nullmatches()
True when $token matches the pending row for this course and user.
public
static matches(mixed $context_id, mixed $user_id, mixed $token[, string|null $sessionKey = null ]) : mixed
Parameters
- $context_id : mixed
- $user_id : mixed
- $token : mixed
- $sessionKey : string|null = null
stash()
Remember a moved upload for this instructor and course. Replaces any prior pending zip.
public
static stash(string $path, string $name, mixed $context_id, mixed $user_id[, string|null $sessionKey = null ]) : string
$sessionKey isolates course-copy from an in-progress import upload. Both still use the ccimp temp prefix so sweep can delete either.
Parameters
- $path : string
-
Absolute path already moved off PHP's upload tmp
- $name : string
-
Original filename
- $context_id : mixed
- $user_id : mixed
- $sessionKey : string|null = null
Return values
string —Token posted back on confirm
sweep()
Unlink every stashed cartridge whose mtime is older than TTL.
public
static sweep() : mixed
Runs on stash/load so the next import request cleans leftovers from every user, not only the current session.
raw()
private
static raw(string $sessionKey) : array{token: string, path: string, name: string, context_id: int, user_id: int, created: int}|null
Parameters
- $sessionKey : string
Return values
array{token: string, path: string, name: string, context_id: int, user_id: int, created: int}|nullsessionKey()
private
static sessionKey(string|null $sessionKey) : string
Parameters
- $sessionKey : string|null