fogproject  1.5.9
About: FOG is a Linux-based network computer cloning solution for Windows, Mac OSX and various Linux distributions that ties together a few open-source tools with a PHP-based web interface. FOG doesn’t use any boot disks, or CDs; everything is done via TFTP and PXE.
  Fossies Dox: fogproject-1.5.9.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

location.class.php
Go to the documentation of this file.
1 <?php
24 class Location extends FOGController
25 {
31  protected $databaseTable = 'location';
37  protected $databaseFields = array(
38  'id' => 'lID',
39  'name' => 'lName',
40  'description' => 'lDesc',
41  'createdBy' => 'lCreatedBy',
42  'createdTime' => 'lCreatedTime',
43  'storagegroupID' => 'lStorageGroupID',
44  'storagenodeID' => 'lStorageNodeID',
45  'tftp' => 'lTftpEnabled',
46  );
52  protected $databaseFieldsRequired = array(
53  'name',
54  'storagegroupID',
55  );
61  protected $additionalFields = array(
62  'hosts',
63  'hostsnotinme',
64  'storagenode',
65  'storagegroup'
66  );
73  'StorageGroup' => array(
74  'id',
75  'storagegroupID',
76  'storagegroup'
77  ),
78  'StorageNode' => array(
79  'id',
80  'storagenodeID',
81  'storagenode'
82  )
83  );
91  public function destroy($key = 'id')
92  {
93  self::getClass('LocationAssociationManager')
94  ->destroy(
95  array(
96  'locationID' => $this->get('id')
97  )
98  );
99  return parent::destroy($key);
100  }
106  public function save()
107  {
108  parent::save();
109  return $this
110  ->assocSetter('Location', 'host')
111  ->load();
112  }
120  public function addHost($addArray)
121  {
122  return $this->addRemItem(
123  'hosts',
124  (array)$addArray,
125  'merge'
126  );
127  }
135  public function removeHost($removeArray)
136  {
137  return $this->addRemItem(
138  'hosts',
139  (array)$removeArray,
140  'diff'
141  );
142  }
148  public function getStorageGroup()
149  {
150  return $this->get('storagegroup');
151  }
157  public function getStorageNode()
158  {
159  if ($this->get('storagenodeID')) {
160  return $this->get('storagenode');
161  }
162  return $this->getStorageGroup()->getOptimalStorageNode();
163  }
169  protected function loadHosts()
170  {
171  $hostIDs = self::getSubObjectIDs(
172  'LocationAssociation',
173  array('locationID' => $this->get('id')),
174  'hostID'
175  );
176  $hostIDs = self::getSubObjectIDs(
177  'Host',
178  array('id' => $hostIDs)
179  );
180  $this->set(
181  'hosts',
182  (array)$hostIDs
183  );
184  }
190  protected function loadHostsnotinme()
191  {
192  $hosts = array_diff(
193  self::getSubObjectIDs('Host'),
194  $this->get('hosts')
195  );
196  $this->set('hostsnotinme', (array)$hosts);
197  }
198 }
Location\addHost
addHost($addArray)
Definition: location.class.php:120
FOGController\addRemItem
addRemItem($key, $array, $array_type)
Definition: fogcontroller.class.php:823
FOGBase\getClass
static getClass($class, $data='', $props=false)
Definition: fogbase.class.php:439
Location\$additionalFields
$additionalFields
Definition: location.class.php:61
Location\save
save()
Definition: location.class.php:106
Location\getStorageNode
getStorageNode()
Definition: location.class.php:157
Location
Definition: location.class.php:25
Location\$databaseFieldClassRelationships
$databaseFieldClassRelationships
Definition: location.class.php:72
FOGController
Definition: fogcontroller.class.php:29
Location\getStorageGroup
getStorageGroup()
Definition: location.class.php:148
Location\loadHostsnotinme
loadHostsnotinme()
Definition: location.class.php:190
Location\$databaseFields
$databaseFields
Definition: location.class.php:37
Location\removeHost
removeHost($removeArray)
Definition: location.class.php:135
Location\destroy
destroy($key='id')
Definition: location.class.php:91
FOGBase\getSubObjectIDs
static getSubObjectIDs( $object='Host', $findWhere=array(), $getField='id', $not=false, $operator='AND', $orderBy='name', $groupBy=false, $filter='array_unique')
Definition: fogbase.class.php:2006
Location\$databaseFieldsRequired
$databaseFieldsRequired
Definition: location.class.php:52
Location\loadHosts
loadHosts()
Definition: location.class.php:169
Location\$databaseTable
$databaseTable
Definition: location.class.php:31