Logo Search packages:      
Sourcecode: nagvis version File versions  Download package

WuiMapCfg::checkMapLocked ( ignoreLock = 0,
printErr = 1 
)

Gets lockfile informations

Parameters:
Boolean $ignoreLock
Boolean $printErr
Returns:
Array/Boolean Is Successful?
Author:
Lars Michelsen <lars@vertical-visions.de>

Definition at line 257 of file WuiMapCfg.php.

References readMapLock(), and writeMapLock().

                                                       {
          if (DEBUG&&DEBUGLEVEL&1) debug('Start method GlobalMapCfg::checkMapLocked('.$ignoreLock.','.$printErr.')');
        // read lockfile
        $lockdata = $this->readMapLock();
        if(is_array($lockdata)) {
            // check if the lock is older than 5 Minutes and don't ignore lock
            if($lockdata['time'] > time() - $this->MAINCFG->getValue('wui','maplocktime') * 60) {
                if($ignoreLock == 0) {
                    // the lock should be ignored
                        if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::checkMapLocked(): FALSE');
                    return FALSE;
                } else {
                    // there is a lock and it should be recognized
                    // check if this is the lock of the current user (Happens e.g. by pressing F5)
                    if($this->MAINCFG->getRuntimeValue('user') == $lockdata['user'] && $_SERVER['REMOTE_ADDR'] == $lockdata['ip']) {
                        // refresh the lock (write a new lock)
                        $this->writeMapLock();
                        // it's locked by the current user, so it's not locked for him
                        return FALSE;
                    }
                    if($printErr == 1) {
                        $LANG = new GlobalLanguage($this->MAINCFG,'wui:global');
                        
                        // message the user that there is a lock by another user, the user can decide wether he want's to override it or not
                        print '<script>if(!confirm(\''.$LANG->getMessageText('mapLocked','MAP~'.$this->name.',TIME~'.date('d.m.Y H:i',$lockdata['time']).',USER~'.$lockdata['user'].',IP~'.$lockdata['ip']).'\',\'\')) { history.back(); }</script>';
                        }
                        if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::checkMapLocked(): TRUE');
                        return TRUE;
                }
            } else {
                // delete lockfile & continue
                // try to delete map lock, if nothing to delete its OK
                $this->deleteMapLock();
                  if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::checkMapLocked(): FALSE');
                return FALSE;
            }
        } else {
            // no valid informations in lock or no lock there
            // try to delete map lock, if nothing to delete its OK
            $this->deleteMapLock();
            if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMapCfg::checkMapLocked(): FALSE');
            return FALSE;
        }
    }


Generated by  Doxygen 1.6.0   Back to index