- if ($this->isPluginEnabled('lk') && $this->lock_spec) {
- // Override for managers.
- if ($this->canManageTeam()) return false;
-
- require_once(LIBRARY_DIR.'/tdcron/class.tdcron.php');
- require_once(LIBRARY_DIR.'/tdcron/class.tdcron.entry.php');
-
- // Calculate the last occurrence of a lock.
- $last = tdCron::getLastOccurrence($this->lock_spec, time());
- $lockdate = new DateAndTime(DB_DATEFORMAT, strftime('%Y-%m-%d', $last));
- if ($date->before($lockdate)) {
- return true;
- }
- }
+ if (!$this->isPluginEnabled('lk'))
+ return false; // Locking feature is disabled.
+
+ if (!$this->lock_spec)
+ return false; // There is no lock specification.
+
+ if (!$this->behalf_id && $this->can('override_own_date_lock'))
+ return false; // User is working as self and can override own date lock.
+
+ if ($this->behalf_id && $this->can('override_date_lock'))
+ return false; // User is working on behalf of someone else and can override date lock.
+
+ require_once(LIBRARY_DIR.'/tdcron/class.tdcron.php');
+ require_once(LIBRARY_DIR.'/tdcron/class.tdcron.entry.php');
+
+ // Calculate the last occurrence of a lock.
+ $last = tdCron::getLastOccurrence($this->lock_spec, time());
+ $lockdate = new DateAndTime(DB_DATEFORMAT, strftime('%Y-%m-%d', $last));
+ if ($date->before($lockdate))
+ return true;
+