Active::Check PHP Method

Check() public method

public Check ( )
    public function Check()
    {
        $cur_users = array();
        foreach ($this->actives as $active => $data) {
            if (is_array($data) && isset($data['username']) && $data['username'] != $this->username && $data['path'] == $this->path) {
                $cur_users[] = $data['username'];
            }
        }
        if (count($cur_users) != 0) {
            echo formatJSEND("error", "Warning: File " . substr($this->path, strrpos($this->path, "/") + 1) . " Currently Opened By: " . implode(", ", $cur_users));
        } else {
            echo formatJSEND("success");
        }
    }

Usage Example

Example #1
0
//////////////////////////////////////////////////////////////////
// Rename
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'rename') {
    $Active->username = $_SESSION['user'];
    $Active->path = $_GET['old_path'];
    $Active->new_path = $_GET['new_path'];
    $Active->Rename();
}
//////////////////////////////////////////////////////////////////
// Check if file is active
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'check') {
    $Active->username = $_SESSION['user'];
    $Active->path = $_GET['path'];
    $Active->Check();
}
//////////////////////////////////////////////////////////////////
// Remove active record
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'remove') {
    $Active->username = $_SESSION['user'];
    $Active->path = $_GET['path'];
    $Active->Remove();
}
//////////////////////////////////////////////////////////////////
// Remove all active record
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'removeall') {
    $Active->username = $_SESSION['user'];
    $Active->RemoveAll();