-
- function canUnlock()
- {
- // the only scenario where we can automatically unlock is:::
-
- // this user owns the lock.
-
- $curlock = DB_DataObject::factory('Core_locking');
- $curlock->setFrom(array(
- 'on_id' => $_REQUEST['on_id'],
- 'on_table' => $_REQUEST['on_table']
- ));
- $cc = clone($curlock);
- // the user who owns the lock is not logged in.. ?? - their last
- $curlock->find();
- $users = array();
- while ($curlock->fetch()) {
- $u = DB_DataObject::factory('Person');
- $u->get($curlock->person_id);
- if (!$u->isCurrentlyLoggedIn()) {
- $cc = clone($curlock);
- $cc->delete();
- continue;
- }
- $users[] = clone($u);
-
- }
- if (empty($users)) {
- return true;
-
- }
- // situations
-
- //- the user is logged in, and we can clear it..
-
- //- the user is logged in multiple times, on different browser..
-
- //- the user is logged in multiple times on the same browser..
-
-
-
- // one of two error messages..
-
- $this->jerr("Item is Locked by " . $u->name . ' (' . $u->email . "), Try asking them to log out");
-
- return true;
-
-
-
-
-
- }