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)  

printer.class.php
Go to the documentation of this file.
1 <?php
22 class Printer extends FOGController
23 {
29  protected $databaseTable = 'printers';
35  protected $databaseFields = array(
36  'id' => 'pID',
37  'name' => 'pAlias',
38  'description' => 'pDesc',
39  'port' => 'pPort',
40  'file' => 'pDefFile',
41  'model' => 'pModel',
42  'config' => 'pConfig',
43  'configFile' => 'pConfigFile',
44  'ip' => 'pIP',
45  'pAnon2' => 'pAnon2',
46  'pAnon3' => 'pAnon3',
47  'pAnon4' => 'pAnon4',
48  'pAnon5' => 'pAnon5',
49  );
55  protected $databaseFieldsRequired = array(
56  'name',
57  );
63  protected $additionalFields = array(
64  'hosts',
65  'hostsnotinme',
66  );
74  public function destroy($key = 'id')
75  {
76  self::getClass('PrinterAssociationManager')
77  ->destroy(array('printerID'=>$this->get('id')));
78  return parent::destroy($key);
79  }
85  public function save()
86  {
87  parent::save();
88  return $this
89  ->assocSetter('Printer', 'host')
90  ->load();
91  }
99  public function addHost($addArray)
100  {
101  return $this->addRemItem(
102  'hosts',
103  (array)$addArray,
104  'merge'
105  );
106  }
114  public function removeHost($removeArray)
115  {
116  return $this->addRemItem(
117  'hosts',
118  (array)$removeArray,
119  'diff'
120  );
121  }
127  protected function loadHosts()
128  {
129  $this->set(
130  'hosts',
131  (array)self::getSubObjectIDs(
132  'PrinterAssociation',
133  array('printerID'=>$this->get('id')),
134  'hostID'
135  )
136  );
137  }
143  protected function loadHostsnotinme()
144  {
145  $hosts = array_diff(
146  self::getSubObjectIDs('Host'),
147  $this->get('hosts')
148  );
149  $this->set('hostsnotinme', (array)$hosts);
150  }
159  public function updateDefault($hostid, $onoff)
160  {
161  $AllHostsPrinter = self::getSubObjectIDs(
162  'PrinterAssociation',
163  array('printerID'=>$this->get('id'))
164  );
165  self::getClass('PrinterAssociationManager')
166  ->update(
167  array(
168  'id' => $AllHostsPrinter,
169  'isDefault' => 0
170  )
171  );
172  self::getClass('PrinterAssociationManager')
173  ->update(
174  array(
175  'hostID' => $onoff,
176  'printerID' => $this->get('id')
177  ),
178  '',
179  array('isDefault' => 1)
180  );
181  return $this;
182  }
188  public function isValid()
189  {
190  $validTypes = array(
191  'iprint',
192  'network',
193  'local',
194  'cups',
195  );
196  $curtype = $this->get('config');
197  $curtype = trim($this->get('config'));
198  $curtype = strtolower($curtype);
199  if (!in_array($curtype, $validTypes)) {
200  return false;
201  }
202  return parent::isValid();
203  }
209  public static function buildPrinterTypeSelector()
210  {
211  $printerTypes = array(
212  'Local' => _('TCP/IP Port Printer'),
213  'iPrint' => _('iPrint Printer'),
214  'Network' => _('Network Printer'),
215  'Cups' => _('CUPS Printer'),
216  );
217  ob_start();
218  foreach ((array)$printerTypes as $short => &$long) {
219  printf(
220  '<option value="%s"%s>%s</option>',
221  $short,
222  (
223  filter_input(INPUT_POST, 'printertype') === $short ?
224  ' selected' :
225  ''
226  ),
227  $long
228  );
229  unset($short, $long);
230  }
231  $optionPrinter = '<select class="form-control" name="printertype" '
232  . 'id="printertype">'
233  . '<option value="">- '
234  . self::$foglang['PleaseSelect']
235  . ' -</option>'
236  . ob_get_clean()
237  . '</select>';
238  self::$HookManager->processEvent(
239  'PRINTER_TYPE_SELECTOR',
240  array(
241  'optionPrinter' => &$optionPrinter
242  )
243  );
244  return $optionPrinter;
245  }
246 }
Printer\loadHosts
loadHosts()
Definition: printer.class.php:127
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
Printer\$databaseFieldsRequired
$databaseFieldsRequired
Definition: printer.class.php:55
Printer\destroy
destroy($key='id')
Definition: printer.class.php:74
Printer\addHost
addHost($addArray)
Definition: printer.class.php:99
Printer\$databaseTable
$databaseTable
Definition: printer.class.php:29
Printer\removeHost
removeHost($removeArray)
Definition: printer.class.php:114
Printer\$additionalFields
$additionalFields
Definition: printer.class.php:63
FOGController
Definition: fogcontroller.class.php:29
Printer\buildPrinterTypeSelector
static buildPrinterTypeSelector()
Definition: printer.class.php:209
Printer\save
save()
Definition: printer.class.php:85
Printer\updateDefault
updateDefault($hostid, $onoff)
Definition: printer.class.php:159
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
Printer\loadHostsnotinme
loadHostsnotinme()
Definition: printer.class.php:143
$foglang
$foglang['Display']
Definition: text.php:22
Printer
Definition: printer.class.php:23
Printer\isValid
isValid()
Definition: printer.class.php:188
Printer\$databaseFields
$databaseFields
Definition: printer.class.php:35