First pass at implementing a new lock tracking mechnism. Not complete, but the basics seem to work
git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@1038 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -25,6 +25,11 @@ class Unit extends AppModel {
|
||||
|
||||
var $hasMany = array(
|
||||
'Lease',
|
||||
'LocksUnit'
|
||||
);
|
||||
|
||||
var $hasAndBelongsToMany = array(
|
||||
'Lock'
|
||||
);
|
||||
|
||||
//var $default_log_level = array('log' => 30, 'show' => 15);
|
||||
@@ -209,6 +214,40 @@ class Unit extends AppModel {
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: lockUnit
|
||||
* - Put lock on unit
|
||||
*/
|
||||
function lockUnit($id, $lock_ids) {
|
||||
$this->prEnter(compact('id', 'lock_ids'));
|
||||
$this->id = $id;
|
||||
|
||||
// Remove any exising locks for this unit
|
||||
$this->LocksUnit->deleteAll
|
||||
(array('unit_id' => $id), false);
|
||||
|
||||
// We'll proceed forward as much as possible, even
|
||||
// if we encounter an error. For now, we'll assume
|
||||
// the operation will succeed.
|
||||
$ret = true;
|
||||
|
||||
// Go through each lock, and put them on the unit
|
||||
foreach ($lock_ids AS $lock_id) {
|
||||
$pair['unit_id'] = $id;
|
||||
$pair['lock_id'] = $lock_id;
|
||||
|
||||
// Save the relationship between lock and unit
|
||||
$LU = new LocksUnit();
|
||||
if (!$LU->save($pair, false))
|
||||
$ret = false;
|
||||
}
|
||||
|
||||
return $this->prReturn($ret);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user