Added ability to delete a lock
git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@1040 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -57,6 +57,41 @@ class Lock extends AppModel {
|
||||
return $this->prReturn($this->save($data, false));
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: destroy
|
||||
* - destroys a lock
|
||||
*/
|
||||
|
||||
function destroy($id) {
|
||||
$this->prEnter(compact('id'));
|
||||
|
||||
// Can't delete a lock that's in use... check.
|
||||
$this->id = $id;
|
||||
$lock = $this->find
|
||||
('first', array
|
||||
('contain' => array('Unit'),
|
||||
));
|
||||
|
||||
// If it's in use, bail with error
|
||||
$this->pr(1, $lock);
|
||||
if (isset($lock['Unit']) && count($lock['Unit']) > 0)
|
||||
return $this->prReturn(false);
|
||||
|
||||
// Otherwise, attempt to delete the lock from the database
|
||||
return $this->prReturn($this->delete());
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: lockList
|
||||
* - list of all locks in the system
|
||||
*/
|
||||
|
||||
function lockList() {
|
||||
return $this->find('list',
|
||||
array('order' =>
|
||||
|
||||
Reference in New Issue
Block a user