code/extensions/EditLockControllerExtension.php
public function updateForm($form, $record)
    {
        if (!$record) {
            return;
        }
        // if the current user can't edit the record anyway, we don't need to do anything
        if ($record && !$record->canEdit()) {
            return $form;
        }
        
        // check if all classes should be locked by default or a certain list
        $lockedClasses = Config::inst()->get('EditLockControllerExtension', 'lockedClasses');
        if (!empty($lockedClasses)) {
            if (!in_array($record->ClassName, $lockedClasses)) {
                return $form;
            }
        }

        // check if this record is being edited by another user
        $beingEdited = RecordBeingEdited::get()->filter(array(
            'RecordID' => $record->ID,
            'RecordClass' => $record->ClassName,
            'EditorID:not' => Member::currentUserID()
        ))->first();

        if ($beingEdited) {
            if ($this->owner->getRequest()->getVar('editanyway') == '1') {
                $beingEdited->isEditingAnyway();
                return Controller::curr()->redirectBack();
            }
            // if the RecordBeingEdited record has not been updated in the last 15 seconds (via ping)
            // the person editing it must have left the edit form, so delete the RecordBeingEdited
            if (strtotime($beingEdited->LastEdited) < (time() - 15)) {
                $beingEdited->delete();
            // otherwise, there must be someone currently editing this record, so make the form readonly
            // unless they have permission to, and have chosen to edit anyway
            } else {
                if (!$beingEdited->isEditingAnyway()) {
                    $readonlyFields = $form->Fields()->makeReadonly();
                    $form->setFields($readonlyFields);
                    $form->addExtraClass('edit-locked');
                    $form->setAttribute('data-lockedmessage', $beingEdited->getLockedMessage());
                    return;
                }
            }
        }

        $form->setAttribute('data-recordclass', $record->ClassName);
        $form->setAttribute('data-recordid', $record->ID);
        $form->setAttribute('data-lockurl', $this->owner->link('lock'));
        return $form;
    }
public function updateForm($form, $record)
    {
        if (!$record) {
            return;
        }
        // if the current user can't edit the record anyway, we don't need to do anything
        if ($record && !$record->canEdit()) {
            return $form;
        }
        
        // check if all classes should be locked by default or a certain list
        $lockedClasses = Config::inst()->get('EditLockControllerExtension', 'lockedClasses');
        if (!empty($lockedClasses)) {
            if (!in_array($record->ClassName, $lockedClasses)) {
                return $form;
            }
        }

        // check if this record is being edited by another user
        $beingEdited = RecordBeingEdited::get()->filter(array(
            'RecordID' => $record->ID,
            'RecordClass' => $record->ClassName,
            'EditorID:not' => Member::currentUserID()
        ))->first();

        if ($beingEdited) {
            if ($this->owner->getRequest()->getVar('editanyway') == '1') {
                $beingEdited->isEditingAnyway();
                return Controller::curr()->redirectBack();
            }
            // if the RecordBeingEdited record has not been updated in the last 15 seconds (via ping)
            // the person editing it must have left the edit form, so delete the RecordBeingEdited
            if (strtotime($beingEdited->LastEdited) < (time() - 15)) {
                $beingEdited->delete();
            // otherwise, there must be someone currently editing this record, so make the form readonly
            // unless they have permission to, and have chosen to edit anyway
            } else {
                if (!$beingEdited->isEditingAnyway()) {
                    $readonlyFields = $form->Fields()->makeReadonly();
                    $form->setFields($readonlyFields);
                    $form->addExtraClass('edit-locked');
                    $form->setAttribute('data-lockedmessage', $beingEdited->getLockedMessage());
                    return;
                }
            }
        }

        $form->setAttribute('data-recordclass', $record->ClassName);
        $form->setAttribute('data-recordid', $record->ID);
        $form->setAttribute('data-lockurl', $this->owner->link('lock'));
        return $form;
    }
Updtes the edit form based on whether it is being edited or not