- if ($this->isPluginEnabled('lk')) {
- // Determine lock date. Entries earlier than lock date cannot be created or modified.
- $lockdate = 0;
- if ($this->lock_interval > 0) {
- $lockdate = new DateAndTime();
- $lockdate->decDay($this->lock_interval);
- }
- if($lockdate && $date->before($lockdate))
+ 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, mktime());
+ $lockdate = new DateAndTime(DB_DATEFORMAT, strftime('%Y-%m-%d', $last));
+ if ($date->before($lockdate)) {