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)  

storagemanagementpage.class.php
Go to the documentation of this file.
1 <?php
23 {
29  public $node = 'storage';
37  public function __construct($name = '')
38  {
39  $this->name = 'Storage Management';
40  parent::__construct($this->name);
41  $this->menu = array(
42  'list' => self::$foglang['AllSN'],
43  'addStorageNode' => self::$foglang['AddSN'],
44  'storageGroup' => self::$foglang['AllSG'],
45  'addStorageGroup' => self::$foglang['AddSG'],
46  );
47  global $node;
48  global $sub;
49  global $id;
50  switch ($sub) {
51  case 'edit':
52  case 'delete':
53  case 'deleteStorageNode':
54  if ($id) {
55  if (!$this->obj->isValid() && false === strpos($sub, 'add')) {
56  unset($this->obj);
58  sprintf(
59  _('%s ID %s is not valid'),
60  _('Storage Node'),
61  $id
62  )
63  );
64  self::redirect(sprintf('?node=%s', $this->node));
65  }
66  $this->subMenu = array(
67  sprintf(
68  '?node=%s&sub=%s&id=%s#node-general',
69  $this->node,
70  $sub,
71  $id
72  ) => self::$foglang['General'],
73  sprintf(
74  '?node=%s&sub=%s&id=%s',
75  $this->node,
76  'deleteStorageNode',
77  $id
78  ) => self::$foglang['Delete']
79  );
80  $this->notes = array(
81  sprintf(
82  '%s %s',
83  self::$foglang['Storage'],
84  self::$foglang['Node']
85  ) => $this->obj->get('name'),
86  self::$foglang['ImagePath'] => $this->obj->get('path'),
87  self::$foglang['FTPPath'] => $this->obj->get('ftppath'),
88  );
89  }
90  break;
91  case 'editStorageGroup':
92  case 'deleteStorageGroup':
93  if ($id) {
94  if (!$this->obj->isValid() && false === strpos($sub, 'add')) {
95  unset($this->obj);
97  sprintf(
98  _('%s ID %s is not valid'),
99  $this->childClass,
100  $id
101  )
102  );
104  sprintf(
105  '?node=%s',
106  $this->node
107  )
108  );
109  }
110  $this->subMenu = array(
111  sprintf(
112  '?node=%s&sub=%s&id=%s#group-general',
113  $this->node,
114  $sub,
115  $id
116  ) => self::$foglang['General'],
117  sprintf(
118  '?node=%s&sub=%s&id=%s',
119  $this->node,
120  'deleteStorageGroup',
121  $id
122  ) => self::$foglang['Delete']
123  );
124  $this->notes = array(
125  sprintf(
126  '%s %s',
127  self::$foglang['Storage'],
128  self::$foglang['Group']
129  ) => $this->obj->get('name')
130  );
131  }
132  break;
133  }
134  }
140  public function search()
141  {
142  $this->index();
143  }
149  public function edit()
150  {
151  $this->editStorageNode();
152  }
158  public function editPost()
159  {
160  $this->editStorageNodePost();
161  }
167  public function delete()
168  {
169  $this->deleteStorageNode();
170  }
176  public function deletePost()
177  {
178  $this->deleteStorageNodePost();
179  }
185  public function index()
186  {
187  unset(
188  $this->data,
189  $this->form,
190  $this->headerData,
191  $this->templates,
192  $this->attributes
193  );
194  $this->title = self::$foglang['AllSN'];
195  Route::listem('storagenode');
196  $StorageNodes = json_decode(
198  );
199  $StorageNodes = $StorageNodes->storagenodes;
200  foreach ((array)$StorageNodes as &$StorageNode) {
201  $StorageGroup = $StorageNode->storagegroup;
202  $this->data[] = array(
203  'name' => $StorageNode->name,
204  'id' => $StorageNode->id,
205  'isMasterText' => (
206  $StorageNode->isMaster ?
207  _('Yes') :
208  _('No')
209  ),
210  'isEnabledText' => (
211  $StorageNode->isEnabled ?
212  _('Yes') :
213  _('No')
214  ),
215  'storage_group' => $StorageGroup->name,
216  'max_clients' => $StorageNode->maxClients,
217  );
218  unset($StorageGroup, $StorageNode);
219  }
220  $this->headerData = array(
221  '<input type="checkbox" name="toggle-checkbox" class='
222  . '"toggle-checkboxAction" id="toggler"/>'
223  . '<label for="toggler"></label>',
224  self::$foglang['SN'],
225  self::$foglang['SG'],
226  self::$foglang['Enabled'],
227  self::$foglang['MasterNode'],
228  _('Max Clients'),
229  );
230  $this->templates = array(
231  '<input type="checkbox" name="node[]" value='
232  . '"${id}" class="toggle-action" id="node-${id}"/>'
233  . '<label for="node-${id}"></label>',
234  sprintf(
235  '<a href="?node=%s&sub=edit&%s=${id}" title="%s">${name}</a>',
236  $this->node,
237  $this->id,
238  self::$foglang['Edit']
239  ),
240  '${storage_group}',
241  '${isEnabledText}',
242  '${isMasterText}',
243  '${max_clients}',
244  );
245  $this->attributes = array(
246  array(
247  'class' => 'filter-false',
248  'width' => 22
249  ),
250  array(),
251  array(
252  ),
253  array(),
254  array(
255  ),
256  array(),
257  );
258  self::$HookManager
259  ->processEvent(
260  'STORAGE_NODE_DATA',
261  array(
262  'headerData' => &$this->headerData,
263  'data' => &$this->data,
264  'templates' => &$this->templates,
265  'attributes' => &$this->attributes
266  )
267  );
268  echo '<div class="col-xs-9">';
269  $this->indexDivDisplay(true, 'node');
270  echo '</div>';
271  unset(
272  $this->data,
273  $this->form,
274  $this->headerData,
275  $this->templates,
276  $this->attributes
277  );
278  }
284  public function addStorageNode()
285  {
286  $this->title = self::$foglang['AddSN'];
287  unset($this->headerData);
288  $this->attributes = array(
289  array('class' => 'col-xs-4'),
290  array('class' => 'col-xs-8 form-group'),
291  );
292  $this->templates = array(
293  '${field}',
294  '${input}',
295  );
296  $name = filter_input(INPUT_POST, 'name');
297  $desc = filter_input(INPUT_POST, 'description');
298  $ip = filter_input(INPUT_POST, 'ip');
299  $webroot = filter_input(INPUT_POST, 'webroot') ?: '/fog';
300  $maxClients = (int)filter_input(INPUT_POST, 'maxClients');
301  $ismaster = isset($_POST['isMaster']) ? ' checked' : '';
302  $bandwidth = filter_input(INPUT_POST, 'bandwidth');
303  $storagegroupID = (int)filter_input(INPUT_POST, 'storagegroupID');
304  if (!$storagegroupID) {
305  $storagegroupID = @min(
306  self::getSubObjectIDs('StorageGroup')
307  );
308  }
309  $path = filter_input(INPUT_POST, 'path') ?: '/images/';
310  $ftppath = filter_input(INPUT_POST, 'ftppath') ?: '/images/';
311  $snapinpath = filter_input(INPUT_POST, 'snapinpath') ?: '/opt/fog/snapins/';
312  $sslpath = filter_input(INPUT_POST, 'sslpath') ?: '/opt/fog/snapins/ssl/';
313  $bitrate = filter_input(INPUT_POST, 'bitrate');
314  $helloInterval = filter_input(INPUT_POST, 'helloInterval');
315  $interface = filter_input(INPUT_POST, 'interface') ?: 'eth0';
316  $user = filter_input(INPUT_POST, 'user');
317  $pass = filter_input(INPUT_POST, 'pass');
318  $fields = array(
319  '<label for="name">'
320  . self::$foglang['SNName']
321  . '</label>' => '<div class="input-group">'
322  . '<input type="text" name="name" id="name" value="'
323  . $name
324  . '" autocomplete="off" class="form-control" required/>'
325  . '</div>',
326  '<label for="desc">'
327  . self::$foglang['SNDesc']
328  . '</label>' => '<div class="input-group">'
329  . '<textarea name="description" id="desc" autocomplete="off" '
330  . 'class="form-control">'
331  . $desc
332  . '</textarea>'
333  . '</div>',
334  '<label for="ip">'
335  . self::$foglang['IPAdr']
336  . '</label>' => '<div class="input-group">'
337  . '<input type="text" name="ip" id="ip" value="'
338  . $ip
339  . '" autocomplete="off" class="form-control" required/>'
340  . '</div>',
341  '<label for="webroot">'
342  . _('Web root')
343  . '</label>' => '<div class="input-group">'
344  . '<input type="text" name="webroot" id="webroot" value="'
345  . $webroot
346  . '" class="form-control" autocomplete="off"/>'
347  . '</div>',
348  '<label for="maxClients">'
349  . self::$foglang['MaxClients']
350  . '</div>' => '<div class="input-group">'
351  . '<input type="number" name="maxClients" id="maxClients" value="'
352  . $maxClients
353  . '" class="form-control" autocomplete="off" required/>'
354  . '</div>',
355  '<label for="ismaster">'
356  . self::$foglang['IsMasterNode']
357  . '</label>' => '<div class="col-xs-1">'
358  . '<input type="checkbox" name="isMaster" '
359  . 'id="ismaster"'
360  . $ismaster
361  . '/>'
362  . '</div>'
363  . '<div class="col-xs-1">'
364  . '<i class="icon fa fa-question hand" title="'
365  . self::$foglang['CautionPhrase']
366  . '" data-toggle="tooltip" data-placement="right"></i>'
367  . '</div>',
368  '<label for="bandwidth">'
369  . self::$foglang['BandwidthReplication']
370  . ' (Kbps)'
371  . '</label>' => '<div class="input-group">'
372  . '<i class="input-group-addon icon fa fa-question hand" title="'
373  . self::$foglang['BandwidthRepHelp']
374  . '" data-toggle="tooltip" data-placement="left"></i>'
375  . '<input type="number" name="bandwidth" id="bandwidth" '
376  . 'value="'
377  . $bandwidth
378  . '" autocomplete="off" class="form-control"/>'
379  . '</div>',
380  '<label for="storagegroupID">'
381  . self::$foglang['SG']
382  . '</label>' => self::getClass('StorageGroupManager')->buildSelectBox(
383  $storagegroupID,
384  'storagegroupID'
385  ),
386  '<label for="path">'
387  . self::$foglang['ImagePath']
388  . '</label>' => '<div class="input-group">'
389  . '<input type="text" name="path" id="path" value="'
390  . $path
391  . '" autocomplete="off" class="form-control"/>'
392  . '</div>',
393  '<label for="ftppath">'
394  . self::$foglang['FTPPath']
395  . '</label>' => '<div class="input-group">'
396  . '<input type="text" name="ftppath" id="ftppath" value="'
397  . $ftppath
398  . '" autocomplete="off" class="form-control"/>'
399  . '</div>',
400  '<label for="snapinpath">'
401  . self::$foglang['SnapinPath']
402  . '</label>' => '<div class="input-group">'
403  . '<input type="text" name="snapinpath" id="snapinpath" value="'
404  . $snapinpath
405  . '" autocomplete="off" class="form-control"/>'
406  . '</div>',
407  '<label for="sslpath">'
408  . self::$foglang['SSLPath']
409  . '</label>' => '<div class="input-group">'
410  . '<input type="text" name="sslpath" id="sslpath" value="'
411  . $sslpath
412  . '" autocomplete="off" class="form-control"/>'
413  . '</div>',
414  '<label for="bitrate">'
415  . _('Bitrate')
416  . '</label>' => '<div class="input-group">'
417  . '<input type="text" name="bitrate" id="bitrate" value="'
418  . $bitrate
419  . '" autocomplete="off" class="form-control"/>'
420  . '</div>',
421  '<label for="helloInterval">'
422  . _('Rexmit Hello Interval')
423  . '</label>' => '<div class="input-group">'
424  . '<input type="text" name="helloInterval" id="helloInterval" value="'
425  . $helloInterval
426  . '" autocomplete="off" class="form-control"/>'
427  . '</div>',
428  '<label for="interface">'
429  . self::$foglang['Interface']
430  . '</label>' => '<div class="input-group">'
431  . '<input type="text" name="interface" id="interface" value="'
432  . $interface
433  . '" autocomplete="off" class="form-control"/>'
434  . '</div>',
435  '<label for="isen">'
436  . self::$foglang['IsEnabled']
437  . '</label>' => '<input type="checkbox" name="isEnabled" id="isen" '
438  . 'checked/>',
439  '<label for="isgren">'
440  . self::$foglang['IsGraphEnabled']
441  . '<br/>'
442  . '('
443  . self::$foglang['OnDash']
444  . ')'
445  . '</label>' => '<input type="checkbox" name="isGraphEnabled" '
446  . 'id="isgren" checked/>',
447  '<label for="user">'
448  . self::$foglang['ManUser']
449  . '</label>' => '<div class="input-group">'
450  . '<input type="text" name="user" id="user" value="'
451  . $user
452  . '" autocomplete="off" class="form-control" required/>'
453  . '</div>',
454  '<label for="pass">'
455  . self::$foglang['ManPass']
456  . '</label>' => '<div class="input-group">'
457  . '<input type="password" name="pass" id="pass" value="'
458  . $pass
459  . '" autocomplete="off" class="form-control" required/>'
460  . '</div>',
461  '<label for="add">'
462  . _('Create Storage Node')
463  . '</label>' => '<button name="add" id="add" type="submit" '
464  . 'class="btn btn-info btn-block">'
465  . _('Add')
466  . '</button>'
467  );
468  array_walk($fields, $this->fieldsToData);
469  self::$HookManager
470  ->processEvent(
471  'STORAGE_NODE_ADD',
472  array(
473  'headerData' => &$this->headerData,
474  'data' => &$this->data,
475  'templates' => &$this->templates,
476  'attributes' => &$this->attributes
477  )
478  );
479  echo '<div class="col-xs-9">';
480  echo '<div class="panel panel-info">';
481  echo '<div class="panel-heading text-center">';
482  echo '<h4 class="title">';
483  echo _('New Storage Node');
484  echo '</h4>';
485  echo '</div>';
486  echo '<div class="panel-body">';
487  echo '<form class="form-horizontal" method="post" action="'
488  . $this->formAction
489  . '">';
490  echo '<input type="text" name="fakeusernameremembered" class="fakes"/>';
491  echo '<input type="text" name="fakepasswordremembered" class="fakes"/>';
492  $this->render(12);
493  echo '</form>';
494  echo '</div>';
495  echo '</div>';
496  echo '</div>';
497  }
503  public function addStorageNodePost()
504  {
505  // Setup and filter our vars.
506  $name = filter_input(INPUT_POST, 'name');
507  $ip = filter_input(INPUT_POST, 'ip');
508  $maxClients = filter_input(INPUT_POST, 'maxClients');
509  $interface = filter_input(INPUT_POST, 'interface');
510  $user = filter_input(INPUT_POST, 'user');
511  $pass = filter_input(INPUT_POST, 'pass');
512  $bandwidth = filter_input(INPUT_POST, 'bandwidth');
513  $desc = filter_input(INPUT_POST, 'description');
514  $webroot = filter_input(INPUT_POST, 'webroot');
515  $isen = (int)isset($_POST['isEnabled']);
516  $isgren = (int)isset($_POST['isGraphEnabled']);
517  $isMaster = (int)isset($_POST['isMaster']);
518  $storagegroupID = filter_input(INPUT_POST, 'storagegroupID');
519  $path = filter_input(INPUT_POST, 'path');
520  $ftppath = filter_input(INPUT_POST, 'ftppath');
521  $snapinpath = filter_input(INPUT_POST, 'snapinpath');
522  $sslpath = filter_input(INPUT_POST, 'sslpath');
523  $bitrate = filter_input(INPUT_POST, 'bitrate');
524  $helloInterval = filter_input(INPUT_POST, 'helloInterval');
525  self::$HookManager->processEvent('STORAGE_NODE_ADD_POST');
526  try {
527  if (empty($name)) {
528  throw new Exception(self::$foglang['StorageNameRequired']);
529  }
530  if (self::getClass('StorageNodeManager')->exists($name)) {
531  throw new Exception(self::$foglang['StorageNameExists']);
532  }
533  if (empty($ip)) {
534  throw new Exception(self::$foglang['StorageIPRequired']);
535  }
536  if (empty($maxClients)) {
537  throw new Exception(self::$foglang['StorageClientsRequired']);
538  }
539  if (empty($interface)) {
540  throw new Exception(self::$foglang['StorageIntRequired']);
541  }
542  if (empty($user)) {
543  throw new Exception(self::$foglang['StorageUserRequired']);
544  }
545  if (empty($pass)) {
546  throw new Exception(self::$foglang['StoragePassRequired']);
547  }
548  if (is_numeric($bandwidth)) {
549  if ($bandwidth < 0) {
550  throw new Exception(
551  _('Bandwidth should be numeric and greater than 0')
552  );
553  }
554  } else {
555  $bandwidth = '';
556  }
557  $StorageNode = self::getClass('StorageNode')
558  ->set('name', $name)
559  ->set('description', $desc)
560  ->set('ip', $ip)
561  ->set('webroot', $webroot)
562  ->set('maxClients', $maxClients)
563  ->set('isMaster', $isMaster)
564  ->set('storagegroupID', $storagegroupID)
565  ->set('path', $path)
566  ->set('ftppath', $ftppath)
567  ->set('snapinpath', $snapinpath)
568  ->set('sslpath', $sslpath)
569  ->set('bitrate', $bitrate)
570  ->set('helloInterval', $helloInterval)
571  ->set('interface', $interface)
572  ->set('isGraphEnabled', $isgren)
573  ->set('isEnabled', $isen)
574  ->set('user', $user)
575  ->set('pass', $pass)
576  ->set('bandwidth', $bandwidth);
577  if (!$StorageNode->save()) {
578  throw new Exception(_('Add storage node failed!'));
579  }
580  if ($StorageNode->get('isMaster')) {
581  $masternodes = self::getSubObjectIDs(
582  'StorageNode',
583  array(
584  'isMaster' => 1,
585  'storagegroupID' => $StorageNode->get('storagegroupID')
586  )
587  );
588  self::getClass('StorageNodeManager')
589  ->update(
590  array(
591  'id' => array_diff(
592  (array) $StorageNode->get('id'),
593  (array) $masternodes
594  )
595  ),
596  '',
597  array('isMaster' => 0)
598  );
599  }
600  $hook = 'STORAGE_NODE_ADD_SCCESS';
601  $msg = json_encode(
602  array(
603  'msg' => _('Storage Node added!'),
604  'title' => _('Storage Node Create Success')
605  )
606  );
607  } catch (Exception $e) {
608  $hook = 'STORAGE_NODE_ADD_FAIL';
609  $msg = json_encode(
610  array(
611  'error' => $e->getMessage(),
612  'title' => _('Storage Node Create Fail')
613  )
614  );
615  }
616  self::$HookManager
617  ->processEvent(
618  $hook,
619  array('StorageNode' => &$StorageNode)
620  );
621  unset($StorageNode);
622  echo $msg;
623  exit;
624  }
630  public function editStorageNode()
631  {
632  unset(
633  $this->data,
634  $this->form,
635  $this->headerData,
636  $this->templates,
637  $this->attributes
638  );
639  $name = filter_input(INPUT_POST, 'name') ?:
640  $this->obj->get('name');
641  $desc = filter_input(INPUT_POST, 'description') ?:
642  $this->obj->get('description');
643  $ip = filter_input(INPUT_POST, 'ip') ?:
644  $this->obj->get('ip');
645  $webroot = filter_input(INPUT_POST, 'webroot') ?:
646  $this->obj->get('webroot');
647  $maxClients = (int)filter_input(INPUT_POST, 'maxClients') ?:
648  $this->obj->get('maxClients');
649  $bandwidth = filter_input(INPUT_POST, 'bandwidth') ?:
650  $this->obj->get('bandwidth');
651  $storagegroupID = (int)filter_input(INPUT_POST, 'storagegroupID') ?:
652  $this->obj->get('storagegroupID');
653  $path = filter_input(INPUT_POST, 'path') ?:
654  $this->obj->get('path');
655  $ftppath = filter_input(INPUT_POST, 'ftppath') ?:
656  $this->obj->get('ftppath');
657  $snapinpath = filter_input(INPUT_POST, 'snapinpath') ?:
658  $this->obj->get('snapinpath');
659  $sslpath = filter_input(INPUT_POST, 'sslpath') ?:
660  $this->obj->get('sslpath');
661  $bitrate = filter_input(INPUT_POST, 'bitrate') ?:
662  $this->obj->get('bitrate');
663  $helloInterval = filter_input(INPUT_POST, 'helloInterval') ?:
664  $this->obj->get('helloInterval');
665  $interface = filter_input(INPUT_POST, 'interface') ?:
666  $this->obj->get('interface');
667  $user = filter_input(INPUT_POST, 'user') ?:
668  $this->obj->get('user');
669  $pass = filter_input(INPUT_POST, 'pass') ?:
670  $this->obj->get('pass');
671  $isgren = isset($_POST['isGraphEnabled']) ?:
672  $this->obj->get('isGraphEnabled');
673  $isen = isset($_POST['isEnabled']) ?:
674  $this->obj->get('isEnabled');
675  $ismaster = isset($_POST['isMaster']) ?:
676  $this->obj->get('isMaster');
677  if ($isgren) {
678  $isgren = ' checked';
679  }
680  if ($isen) {
681  $isen = ' checked';
682  }
683  if ($ismaster) {
684  $ismaster = ' checked';
685  }
686  $this->title = _('Storage Node General');
687  $this->attributes = array(
688  array('class' => 'col-xs-4'),
689  array('class' => 'col-xs-8 form-group'),
690  );
691  $this->templates = array(
692  '${field}',
693  '${input}',
694  );
695  $fields = array(
696  '<label for="name">'
697  . self::$foglang['SNName']
698  . '</label>' => '<div class="input-group">'
699  . '<input type="text" name="name" id="name" value="'
700  . $name
701  . '" autocomplete="off" class="form-control" required/>'
702  . '</div>',
703  '<label for="desc">'
704  . self::$foglang['SNDesc']
705  . '</label>' => '<div class="input-group">'
706  . '<textarea name="description" id="desc" autocomplete="off" '
707  . 'class="form-control">'
708  . $desc
709  . '</textarea>'
710  . '</div>',
711  '<label for="ip">'
712  . self::$foglang['IPAdr']
713  . '</label>' => '<div class="input-group">'
714  . '<input type="text" name="ip" id="ip" value="'
715  . $ip
716  . '" autocomplete="off" class="form-control" required/>'
717  . '</div>',
718  '<label for="webroot">'
719  . _('Web root')
720  . '</label>' => '<div class="input-group">'
721  . '<input type="text" name="webroot" id="webroot" value="'
722  . $webroot
723  . '" class="form-control" autocomplete="off"/>'
724  . '</div>',
725  '<label for="maxClients">'
726  . self::$foglang['MaxClients']
727  . '</div>' => '<div class="input-group">'
728  . '<input type="number" name="maxClients" id="maxClients" value="'
729  . $maxClients
730  . '" class="form-control" autocomplete="off" required/>'
731  . '</div>',
732  '<label for="ismaster">'
733  . self::$foglang['IsMasterNode']
734  . '</label>' => '<div class="col-xs-1">'
735  . '<input type="checkbox" name="isMaster" '
736  . 'id="ismaster"'
737  . $ismaster
738  . '/>'
739  . '</div>'
740  . '<div class="col-xs-1">'
741  . '<i class="icon fa fa-question hand" title="'
742  . self::$foglang['CautionPhrase']
743  . '" data-toggle="tooltip" data-placement="right"></i>'
744  . '</div>',
745  '<label for="bandwidth">'
746  . self::$foglang['BandwidthReplication']
747  . ' (Kbps)'
748  . '</label>' => '<div class="input-group">'
749  . '<i class="input-group-addon icon fa fa-question hand" title="'
750  . self::$foglang['BandwidthRepHelp']
751  . '" data-toggle="tooltip" data-placement="left"></i>'
752  . '<input type="number" name="bandwidth" id="bandwidth" '
753  . 'value="'
754  . $bandwidth
755  . '" autocomplete="off" class="form-control"/>'
756  . '</div>',
757  '<label for="storagegroupID">'
758  . self::$foglang['SG']
759  . '</label>' => self::getClass('StorageGroupManager')->buildSelectBox(
760  $storagegroupID,
761  'storagegroupID'
762  ),
763  '<label for="path">'
764  . self::$foglang['ImagePath']
765  . '</label>' => '<div class="input-group">'
766  . '<input type="text" name="path" id="path" value="'
767  . $path
768  . '" autocomplete="off" class="form-control"/>'
769  . '</div>',
770  '<label for="ftppath">'
771  . self::$foglang['FTPPath']
772  . '</label>' => '<div class="input-group">'
773  . '<input type="text" name="ftppath" id="ftppath" value="'
774  . $ftppath
775  . '" autocomplete="off" class="form-control"/>'
776  . '</div>',
777  '<label for="snapinpath">'
778  . self::$foglang['SnapinPath']
779  . '</label>' => '<div class="input-group">'
780  . '<input type="text" name="snapinpath" id="snapinpath" value="'
781  . $snapinpath
782  . '" autocomplete="off" class="form-control"/>'
783  . '</div>',
784  '<label for="sslpath">'
785  . self::$foglang['SSLPath']
786  . '</label>' => '<div class="input-group">'
787  . '<input type="text" name="sslpath" id="sslpath" value="'
788  . $sslpath
789  . '" autocomplete="off" class="form-control"/>'
790  . '</div>',
791  '<label for="bitrate">'
792  . _('Bitrate')
793  . '</label>' => '<div class="input-group">'
794  . '<input type="text" name="bitrate" id="bitrate" value="'
795  . $bitrate
796  . '" autocomplete="off" class="form-control"/>'
797  . '</div>',
798  '<label for="helloInterval">'
799  . _('Remit Hello Interval')
800  . '</label>' => '<div class="input-group">'
801  . '<input type="text" name="helloInterval" id="helloInterval" value="'
802  . $helloInterval
803  . '" autocomplete="off" class="form-control"/>'
804  . '</div>',
805  '<label for="interface">'
806  . self::$foglang['Interface']
807  . '</label>' => '<div class="input-group">'
808  . '<input type="text" name="interface" id="interface" value="'
809  . $interface
810  . '" autocomplete="off" class="form-control"/>'
811  . '</div>',
812  '<label for="isen">'
813  . self::$foglang['IsEnabled']
814  . '</label>' => '<input type="checkbox" name="isEnabled" id="isen" '
815  . $isen
816  . '/>',
817  '<label for="isgren">'
818  . self::$foglang['IsGraphEnabled']
819  . '<br/>'
820  . '('
821  . self::$foglang['OnDash']
822  . ')'
823  . '</label>' => '<input type="checkbox" name="isGraphEnabled" '
824  . 'id="isgren"'
825  . $isgren
826  . '/>',
827  '<label for="user">'
828  . self::$foglang['ManUser']
829  . '</label>' => '<div class="input-group">'
830  . '<input type="text" name="user" id="user" value="'
831  . $user
832  . '" autocomplete="off" class="form-control" required/>'
833  . '</div>',
834  '<label for="pass">'
835  . self::$foglang['ManPass']
836  . '</label>' => '<div class="input-group">'
837  . '<input type="password" name="pass" id="pass" value="'
838  . $pass
839  . '" autocomplete="off" class="form-control" required/>'
840  . '</div>',
841  '<label for="update">'
842  . _('Make Changes?')
843  . '</label>' => '<button name="update" id="update" type="submit" '
844  . 'class="btn btn-info btn-block">'
845  . _('Update')
846  . '</button>'
847  );
848  array_walk($fields, $this->fieldsToData);
849  self::$HookManager
850  ->processEvent(
851  'STORAGE_NODE_EDIT',
852  array(
853  'headerData' => &$this->headerData,
854  'data' => &$this->data,
855  'templates' => &$this->templates,
856  'attributes' => &$this->attributes
857  )
858  );
859  echo '<div class="col-xs-9 tab-content">';
860  echo '<div class="tab-pane fade in active" id="node-general">';
861  echo '<div class="panel panel-info">';
862  echo '<div class="panel-heading text-center">';
863  echo '<h4 class="title">';
864  echo $this->title;
865  echo '</h4>';
866  echo '</div>';
867  echo '<div class="panel-body">';
868  echo '<form class="form-horizontal" method="post" action="'
869  . $this->formAction
870  . '">';
871  echo '<input type="text" name="fakeusernameremembered" class="fakes"/>';
872  echo '<input type="text" name="fakepasswordremembered" class="fakes"/>';
873  $this->render(12);
874  echo '</form>';
875  echo '</div>';
876  echo '</div>';
877  echo '</div>';
878  echo '</div>';
879  }
885  public function editStorageNodePost()
886  {
887  // Setup and filter our vars.
888  $name = filter_input(INPUT_POST, 'name');
889  $ip = filter_input(INPUT_POST, 'ip');
890  $maxClients = filter_input(INPUT_POST, 'maxClients');
891  $interface = filter_input(INPUT_POST, 'interface');
892  $user = filter_input(INPUT_POST, 'user');
893  $pass = filter_input(INPUT_POST, 'pass');
894  $bandwidth = filter_input(INPUT_POST, 'bandwidth');
895  $desc = filter_input(INPUT_POST, 'description');
896  $webroot = filter_input(INPUT_POST, 'webroot');
897  $isen = (int)isset($_POST['isEnabled']);
898  $isgren = (int)isset($_POST['isGraphEnabled']);
899  $isMaster = (int)isset($_POST['isMaster']);
900  $storagegroupID = filter_input(INPUT_POST, 'storagegroupID');
901  $path = filter_input(INPUT_POST, 'path');
902  $ftppath = filter_input(INPUT_POST, 'ftppath');
903  $snapinpath = filter_input(INPUT_POST, 'snapinpath');
904  $sslpath = filter_input(INPUT_POST, 'sslpath');
905  $bitrate = filter_input(INPUT_POST, 'bitrate');
906  $helloInterval = filter_input(INPUT_POST, 'helloInterval');
907  self::$HookManager
908  ->processEvent(
909  'STORAGE_NODE_EDIT_POST',
910  array('StorageNode' => &$this->obj)
911  );
912  try {
913  if (!$name) {
914  throw new Exception(self::$foglang['StorageNameRequired']);
915  }
916  $exists = self::getClass('StorageNodeManager')
917  ->exists($name, $this->obj->get('id'));
918  if ($this->obj->get('name') != $name
919  && $exists
920  ) {
921  throw new Exception(self::$foglang['StorageNameExists']);
922  }
923  if (!$ip) {
924  throw new Exception(self::$foglang['StorageIPRequired']);
925  }
926  if ($maxClients < 0) {
927  throw new Exception(self::$foglang['StorageClientRequired']);
928  }
929  if (!$interface) {
930  throw new Exception(self::$foglang['StorageIntRequired']);
931  }
932  if (!$user) {
933  throw new Exception(self::$foglang['StorageUserRequired']);
934  }
935  if (!$pass) {
936  throw new Exception(self::$foglang['StoragePassRequired']);
937  }
938  if (is_numeric($bandwidth)) {
939  if ($bandwidth < 0) {
940  throw new Exception(
941  _('Bandwidth should be numeric and greater than 0')
942  );
943  }
944  } else {
945  $bandwidth = '';
946  }
947  $this->obj
948  ->set('name', $name)
949  ->set('description', $desc)
950  ->set('ip', $ip)
951  ->set('webroot', $webroot)
952  ->set('maxClients', $maxClients)
953  ->set('isMaster', $isMaster)
954  ->set('storagegroupID', $storagegroupID)
955  ->set('path', $path)
956  ->set('ftppath', $ftppath)
957  ->set('snapinpath', $snapinpath)
958  ->set('sslpath', $sslpath)
959  ->set('bitrate', $bitrate)
960  ->set('helloInterval', $helloInterval)
961  ->set('interface', $interface)
962  ->set('isGraphEnabled', $isgren)
963  ->set('isEnabled', $isen)
964  ->set('user', $user)
965  ->set('pass', $pass)
966  ->set('bandwidth', $bandwidth);
967  if (!$this->obj->save()) {
968  throw new Exception(_('Storage Node update failed!'));
969  }
970  if ($this->obj->get('isMaster')) {
971  $masternodes = self::getSubObjectIDs(
972  'StorageNode',
973  array(
974  'isMaster' => 1,
975  'storagegroupID' => $this->obj->get('storagegroupID')
976  )
977  );
978  self::getClass('StorageNodeManager')
979  ->update(
980  array(
981  'id' => array_diff(
982  (array) $this->obj->get('id'),
983  (array) $masternodes
984  )
985  ),
986  '',
987  array('isMaster' => 0)
988  );
989  }
990  $hook = 'STORAGE_NODE_EDIT_SUCCESS';
991  $msg = json_encode(
992  array(
993  'msg' => _('Storage Node updated!'),
994  'title' => _('Storage Node Update Success')
995  )
996  );
997  } catch (Exception $e) {
998  $hook = 'STORAGE_NODE_EDIT_FAIL';
999  $msg = json_encode(
1000  array(
1001  'error' => $e->getMessage(),
1002  'title' => _('Storage Node Update Fail')
1003  )
1004  );
1005  }
1006  self::$HookManager
1007  ->processEvent(
1008  $hook,
1009  array('StorageNode' => &$this->obj)
1010  );
1011  echo $msg;
1012  exit;
1013  }
1019  public function deleteStorageNode()
1020  {
1021  $this->title = sprintf(
1022  '%s: %s',
1023  self::$foglang['Remove'],
1024  $this->obj->get('name')
1025  );
1026  unset($this->headerData);
1027  $this->attributes = array(
1028  array('class' => 'col-xs-4'),
1029  array('class' => 'col-xs-8 form-group'),
1030  );
1031  $this->templates = array(
1032  '${field}',
1033  '${input}',
1034  );
1035  $fields = array(
1036  '<label for="delete">'
1037  . $this->title
1038  . '</label>' => '<input type="hidden" name="remitems[]" '
1039  . 'value="'
1040  . $this->obj->get('id')
1041  . '"/>'
1042  . '<button type="submit" name="delete" id="delete" '
1043  . 'class="btn btn-danger btn-block">'
1044  . _('Delete')
1045  . '</button>'
1046  );
1047  array_walk($fields, $this->fieldsToData);
1048  self::$HookManager
1049  ->processEvent(
1050  'STORAGE_NODE_DELETE',
1051  array(
1052  'headerData' => &$this->headerData,
1053  'data' => &$this->data,
1054  'templates' => &$this->templates,
1055  'attributes' => &$this->attributes
1056  )
1057  );
1058  echo '<div class="col-xs-9">';
1059  echo '<div class="panel panel-info">';
1060  echo '<div class="panel-heading text-center">';
1061  echo '<h4 class="title">';
1062  echo $this->title;
1063  echo '</h4>';
1064  echo '</div>';
1065  echo '<div class="panel-body">';
1066  echo '<form class="form-horizontal" method="post" action="'
1067  . $this->formAction
1068  . '">';
1069  $this->render(12);
1070  echo '</form>';
1071  echo '</div>';
1072  echo '</div>';
1073  echo '</div>';
1074  }
1080  public function deleteStorageNodePost()
1081  {
1082  if (self::getSetting('FOG_REAUTH_ON_DELETE')) {
1083  $user = filter_input(INPUT_POST, 'fogguiuser');
1084  $pass = filter_input(INPUT_POST, 'fogguipass');
1085  $validate = self::getClass('User')
1086  ->passwordValidate(
1087  $user,
1088  $pass,
1089  true
1090  );
1091  if ($validate) {
1092  echo json_encode(
1093  array(
1094  'error' => self::$foglang['InvalidLogin']
1095  )
1096  );
1097  exit;
1098  }
1099  }
1100  self::$HookManager
1101  ->processEvent(
1102  'STORAGE_NODE_DELETE_POST',
1103  array(
1104  'StorageNode' => &$this->obj
1105  )
1106  );
1107  try {
1108  if (!$this->obj->destroy()) {
1109  throw new Exception(self::$foglang['FailDelSN']);
1110  }
1111  $hook = 'STORAGE_NODE_DELETE_SUCCESS';
1112  $msg = sprintf(
1113  '%s: %s',
1114  self::$foglang['SNDelSuccess'],
1115  $this->obj->get('name')
1116  );
1117  $url = sprintf(
1118  '?node=%s',
1119  $this->node
1120  );
1121  } catch (Exception $e) {
1122  $hook = 'STORAGE_NODE_DELETE_FAIL';
1123  $msg = $e->getMessage();
1125  }
1126  self::$HookManager
1127  ->processEvent(
1128  $hook,
1129  array(
1130  'StorageNode' => &$this->obj
1131  )
1132  );
1135  }
1141  public function storageGroup()
1142  {
1143  unset(
1144  $this->data,
1145  $this->form,
1146  $this->headerData,
1147  $this->templates,
1148  $this->attributes
1149  );
1150  $this->title = self::$foglang['AllSG'];
1151  Route::listem('storagegroup');
1152  $StorageGroups = json_decode(
1153  Route::getData()
1154  );
1155  $StorageGroups = $StorageGroups->storagegroups;
1156  foreach ((array)$StorageGroups as &$StorageGroup) {
1157  $this->data[] = array(
1158  'name' => $StorageGroup->name,
1159  'id' => $StorageGroup->id,
1160  'max_clients' => $StorageGroup->totalsupportedclients,
1161  );
1162  unset($StorageGroup);
1163  }
1164  $this->headerData = array(
1165  '<input type="checkbox" name="toggle-checkbox" class='
1166  . '"toggle-checkboxAction" id="toggler2"/>'
1167  . '<label for="toggler2"></label>',
1168  self::$foglang['SG'],
1169  _('Max'),
1170  );
1171  $this->templates = array(
1172  '<input type="checkbox" name="storage[]" value='
1173  . '"${id}" class="toggle-action" id="group-${id}"/>'
1174  . '<label for="group-${id}"></label>',
1175  sprintf(
1176  '<a href="?node=%s&sub=editStorageGroup&%s=${id}" title='
1177  . '"%s">${name}</a>',
1178  $this->node,
1179  $this->id,
1180  self::$foglang['Edit']
1181  ),
1182  '${max_clients}',
1183  );
1184  $this->attributes = array(
1185  array(
1186  'class' => 'filter-false',
1187  'width' => 22
1188  ),
1189  array(),
1190  array(
1191  'width' => 20
1192  ),
1193  );
1194  self::$HookManager
1195  ->processEvent(
1196  'STORAGE_GROUP_DATA',
1197  array(
1198  'headerData' => &$this->headerData,
1199  'data' => &$this->data,
1200  'templates' => &$this->templates,
1201  'attributes' => &$this->attributes
1202  )
1203  );
1204  echo '<div class="col-xs-9">';
1205  $this->indexDivDisplay(true, 'group');
1206  echo '</div>';
1207  unset(
1208  $this->data,
1209  $this->form,
1210  $this->headerData,
1211  $this->templates,
1212  $this->attributes
1213  );
1214  }
1220  public function addStorageGroup()
1221  {
1222  $this->title = self::$foglang['AddSG'];
1223  unset($this->headerData);
1224  $this->attributes = array(
1225  array('class' => 'col-xs-4'),
1226  array('class' => 'col-xs-8 form-group'),
1227  );
1228  $this->templates = array(
1229  '${field}',
1230  '${input}',
1231  );
1232  $name = filter_input(INPUT_POST, 'name');
1233  $desc = filter_input(INPUT_POST, 'description');
1234  $fields = array(
1235  '<label for="name">'
1236  . self::$foglang['SGName']
1237  . '</label>' => '<div class="input-group">'
1238  . '<input type="text" name="name" id="name" value="'
1239  . $name
1240  . '" class="form-control" required/>'
1241  . '</div>',
1242  '<label for="description">'
1243  . self::$foglang['SGDesc']
1244  . '</label>' => '<div class="input-group">'
1245  . '<textarea name="description" id="description" class="form-control">'
1246  . $desc
1247  . '</textarea>'
1248  . '</div>',
1249  '<label for="add">'
1250  . _('Create Storage Group')
1251  . '</label>' => '<button name="add" id="add" type="submit" '
1252  . 'class="btn btn-info btn-block">'
1253  . _('Add')
1254  . '</button>'
1255  );
1256  array_walk($fields, $this->fieldsToData);
1257  self::$HookManager
1258  ->processEvent(
1259  'STORAGE_GROUP_ADD',
1260  array(
1261  'headerData' => &$this->headerData,
1262  'data' => &$this->data,
1263  'templates' => &$this->templates,
1264  'attributes' => &$this->attributes
1265  )
1266  );
1267  echo '<div class="col-xs-9">';
1268  echo '<div class="panel panel-info">';
1269  echo '<div class="panel-heading text-center">';
1270  echo '<h4 class="title">';
1271  echo _('New Storage Group');
1272  echo '</h4>';
1273  echo '</div>';
1274  echo '<div class="panel-body">';
1275  echo '<form class="form-horizontal" method="post" action="'
1276  . $this->formAction
1277  . '">';
1278  $this->render(12);
1279  echo '</form>';
1280  echo '</div>';
1281  echo '</div>';
1282  echo '</div>';
1283  }
1289  public function addStorageGroupPost()
1290  {
1291  self::$HookManager->processEvent('STORAGE_GROUP_ADD_POST');
1292  $name = filter_input(INPUT_POST, 'name');
1293  $desc = filter_input(INPUT_POST, 'description');
1294  try {
1295  if (empty($name)) {
1296  throw new Exception(self::$foglang['SGNameReq']);
1297  }
1298  if (self::getClass('StorageGroupManager')->exists($name)) {
1299  throw new Exception(self::$foglang['SGExist']);
1300  }
1301  $StorageGroup = self::getClass('StorageGroup')
1302  ->set('name', $name)
1303  ->set('description', $desc);
1304  if (!$StorageGroup->save()) {
1305  throw new Exception(self::$foglang['DBupfailed']);
1306  }
1307  $hook = 'STORAGE_GROUP_ADD_POST_SUCCESS';
1308  $msg = json_encode(
1309  array(
1310  'msg' => self::$foglang['SGCreated'],
1311  'title' => _('Storage Group Create Success')
1312  )
1313  );
1314  } catch (Exception $e) {
1315  $hook = 'STORAGE_GROUP_ADD_POST_FAIL';
1316  $msg = json_encode(
1317  array(
1318  'error' => $e->getMessage(),
1319  'title' => _('Storage Group Create Fail')
1320  )
1321  );
1322  }
1323  self::$HookManager
1324  ->processEvent(
1325  $hook,
1326  array('StorageGroup' => &$StorageGroup)
1327  );
1328  unset($StorageGroup);
1329  echo $msg;
1330  exit;
1331  }
1337  public function editStorageGroup()
1338  {
1339  unset(
1340  $this->data,
1341  $this->form,
1342  $this->headerData,
1343  $this->templates,
1344  $this->attributes
1345  );
1346  $this->title = _('Storage Group General');
1347  $this->attributes = array(
1348  array('class' => 'col-xs-4'),
1349  array('class' => 'col-xs-8 form-group'),
1350  );
1351  $this->templates = array(
1352  '${field}',
1353  '${input}',
1354  );
1355  $name = filter_input(INPUT_POST, 'name') ?:
1356  $this->obj->get('name');
1357  $desc = filter_input(INPUT_POST, 'description') ?:
1358  $this->obj->get('description');
1359  $fields = array(
1360  '<label for="name">'
1361  . self::$foglang['SGName']
1362  . '</label>' => '<div class="input-group">'
1363  . '<input type="text" name="name" id="name" value="'
1364  . $name
1365  . '" class="form-control" autocomplete="off" required/>'
1366  . '</div>',
1367  '<label for="description">'
1368  . self::$foglang['SGDesc']
1369  . '</label>' => '<div class="input-group">'
1370  . '<textarea name="description" id="description" class="form-control">'
1371  . $desc
1372  . '</textarea>'
1373  . '</div>',
1374  '<label for="update">'
1375  . _('Make Changes?')
1376  . '</label>' => '<button type="submit" name="update" id="update" '
1377  . 'class="btn btn-info btn-block">'
1378  . self::$foglang['Update']
1379  . '</button>'
1380  );
1381  array_walk($fields, $this->fieldsToData);
1382  self::$HookManager
1383  ->processEvent(
1384  'STORAGE_GROUP_EDIT',
1385  array(
1386  'headerData' => &$this->headerData,
1387  'data' => &$this->data,
1388  'templates' => &$this->templates,
1389  'attributes' => &$this->attributes
1390  )
1391  );
1392  echo '<div class="col-xs-9 tab-content">';
1393  echo '<div class="tab-pane fade in active" id="group-general">';
1394  echo '<div class="panel panel-info">';
1395  echo '<div class="panel-heading text-center">';
1396  echo '<h4 class="title">';
1397  echo $this->title;
1398  echo '</h4>';
1399  echo '</div>';
1400  echo '<div class="panel-body">';
1401  echo '<form class="form-horizontal" method="post" action="'
1402  . $this->formAction
1403  . '">';
1404  $this->render(12);
1405  echo '</form>';
1406  echo '</div>';
1407  echo '</div>';
1408  echo '</div>';
1409  echo '</div>';
1410  }
1416  public function editStorageGroupPost()
1417  {
1418  self::$HookManager
1419  ->processEvent(
1420  'STORAGE_GROUP_EDIT_POST',
1421  array(
1422  'StorageGroup' => &$this->obj
1423  )
1424  );
1425  $name = filter_input(INPUT_POST, 'name');
1426  $desc = filter_input(INPUT_POST, 'description');
1427  try {
1428  $exists = self::getClass('StorageGroupManager')->exists(
1429  $name,
1430  $this->obj->get('id')
1431  );
1432  if (!$name) {
1433  throw new Exception(self::$foglang['SGName']);
1434  }
1435  if ($this->obj->get('name') != $name
1436  && $exists
1437  ) {
1438  throw new Exception(self::$foglang['SGExist']);
1439  }
1440  $this->obj
1441  ->set('name', $name)
1442  ->set('description', $desc);
1443  if (!$this->obj->save()) {
1444  throw new Exception(_('Storage Group update failed!'));
1445  }
1446  $hook = 'STORAGE_GROUP_EDIT_POST_SUCCESS';
1447  $msg = json_encode(
1448  array(
1449  'msg' => _('Storage Group updated!'),
1450  'title' => _('Storage Group Update Success')
1451  )
1452  );
1453  } catch (Exception $e) {
1454  $hook = 'STORAGE_GROUP_EDIT_POST_FAIL';
1455  $msg = array(
1456  'error' => $e->getMessage(),
1457  'title' => _('Storage Group Update Fail')
1458  );
1459  }
1460  self::$HookManager
1461  ->processEvent(
1462  $hook,
1463  array('StorageGroup' => &$this->obj)
1464  );
1465  echo $msg;
1466  exit;
1467  }
1473  public function deleteStorageGroup()
1474  {
1475  $this->title = sprintf(
1476  '%s: %s',
1477  self::$foglang['Remove'],
1478  $this->obj->get('name')
1479  );
1480  unset($this->headerData);
1481  $this->attributes = array(
1482  array('class' => 'col-xs-4'),
1483  array('class' => 'col-xs-8 form-group'),
1484  );
1485  $this->templates = array(
1486  '${field}',
1487  '${input}',
1488  );
1489  $fields = array(
1490  '<label for="delete">'
1491  . $this->title
1492  . '</label>' => '<input type="hidden" name="remitems[]" '
1493  . 'value="'
1494  . $this->obj->get('id')
1495  . '"/>'
1496  . '<button type="submit" name="delete" id="delete" '
1497  . 'class="btn btn-danger btn-block">'
1498  . _('Delete')
1499  . '</button>'
1500  );
1501  array_walk($fields, $this->fieldsToData);
1502  self::$HookManager
1503  ->processEvent(
1504  'STORAGE_GROUP_DELETE',
1505  array(
1506  'headerData' => &$this->headerData,
1507  'data' => &$this->data,
1508  'templates' => &$this->templates,
1509  'attributes' => &$this->attributes
1510  )
1511  );
1512  echo '<div class="col-xs-9">';
1513  echo '<div class="panel panel-info">';
1514  echo '<div class="panel-heading text-center">';
1515  echo '<h4 class="title">';
1516  echo $this->title;
1517  echo '</h4>';
1518  echo '</div>';
1519  echo '<div class="panel-body">';
1520  echo '<form class="form-horizontal" method="post" action="'
1521  . $this->formAction
1522  . '">';
1523  echo '<div id="deleteDiv"></div>';
1524  $this->render(12);
1525  echo '</form>';
1526  echo '</div>';
1527  echo '</div>';
1528  echo '</div>';
1529  }
1535  public function deleteStorageGroupPost()
1536  {
1537  if (self::getSetting('FOG_REAUTH_ON_DELETE')) {
1538  $user = filter_input(INPUT_POST, 'fogguiuser');
1539  $pass = filter_input(INPUT_POST, 'fogguipass');
1540  $validate = self::getClass('User')
1541  ->passwordValidate(
1542  $user,
1543  $pass,
1544  true
1545  );
1546  if ($validate) {
1547  echo json_encode(
1548  array(
1549  'error' => self::$foglang['InvalidLogin']
1550  )
1551  );
1552  exit;
1553  }
1554  }
1555  self::$HookManager
1556  ->processEvent(
1557  'STORAGE_GROUP_DELETE_POST',
1558  array('StorageGroup' => &$this->obj)
1559  );
1560  try {
1561  if (self::getClass('StorageGroupManager')->count() == 1) {
1562  throw new Exception(self::$foglang['OneSG']);
1563  }
1564  if (!$this->obj->destroy()) {
1565  throw new Exception(self::$foglang['FailDelSG']);
1566  }
1567  $hook = 'STORAGE_GROUP_DELETE_POST_SUCCESS';
1568  $msg = sprintf(
1569  '%s: %s',
1570  self::$foglang['SGDelSuccess'],
1571  $this->obj->get('name')
1572  );
1573  $url = sprintf(
1574  '?node=%s&sub=storageGroup',
1575  $this->node
1576  );
1577  } catch (Exception $e) {
1578  $hook = 'STORAGE_GROUP_DELETE_POST_FAIL';
1579  $msg = $e->getMessaage();
1581  }
1582  self::$HookManager
1583  ->processEvent(
1584  $hook,
1585  array('StorageGroup'=>&$this->obj)
1586  );
1589  }
1590 }
StorageManagementPage\deleteStorageGroupPost
deleteStorageGroupPost()
Definition: storagemanagementpage.class.php:1535
StorageManagementPage\$node
$node
Definition: storagemanagementpage.class.php:29
StorageManagementPage\editPost
editPost()
Definition: storagemanagementpage.class.php:158
StorageManagementPage\addStorageNode
addStorageNode()
Definition: storagemanagementpage.class.php:284
StorageManagementPage
Definition: storagemanagementpage.class.php:23
FOGPage\render
render($colsize=9)
Definition: fogpage.class.php:605
exit
exit
Definition: download.php:102
FOGPage\$formAction
$formAction
Definition: fogpage.class.php:141
FOGBase\getClass
static getClass($class, $data='', $props=false)
Definition: fogbase.class.php:439
StorageManagementPage\index
index()
Definition: storagemanagementpage.class.php:185
FOGPage\$title
$title
Definition: fogpage.class.php:49
StorageManagementPage\addStorageGroupPost
addStorageGroupPost()
Definition: storagemanagementpage.class.php:1289
StorageManagementPage\deleteStorageNodePost
deleteStorageNodePost()
Definition: storagemanagementpage.class.php:1080
StorageManagementPage\editStorageNodePost
editStorageNodePost()
Definition: storagemanagementpage.class.php:885
StorageManagementPage\deleteStorageGroup
deleteStorageGroup()
Definition: storagemanagementpage.class.php:1473
StorageManagementPage\deletePost
deletePost()
Definition: storagemanagementpage.class.php:176
StorageManagementPage\edit
edit()
Definition: storagemanagementpage.class.php:149
StorageManagementPage\editStorageNode
editStorageNode()
Definition: storagemanagementpage.class.php:630
$exists
$exists
Definition: check_node_exists.php:26
StorageManagementPage\addStorageGroup
addStorageGroup()
Definition: storagemanagementpage.class.php:1220
$user
$user
Definition: advanced.php:38
FOGPage\$name
$name
Definition: fogpage.class.php:31
StorageManagementPage\storageGroup
storageGroup()
Definition: storagemanagementpage.class.php:1141
FOGPage\indexDivDisplay
indexDivDisplay( $delNeeded=false, $storage=false, $actionbox=false)
Definition: fogpage.class.php:4222
StorageManagementPage\editStorageGroupPost
editStorageGroupPost()
Definition: storagemanagementpage.class.php:1416
StorageManagementPage\editStorageGroup
editStorageGroup()
Definition: storagemanagementpage.class.php:1337
StorageManagementPage\deleteStorageNode
deleteStorageNode()
Definition: storagemanagementpage.class.php:1019
StorageManagementPage\addStorageNodePost
addStorageNodePost()
Definition: storagemanagementpage.class.php:503
FOGBase\redirect
static redirect($url='')
Definition: fogbase.class.php:831
FOGPage
Definition: fogpage.class.php:25
$path
if(!is_string($_GET['path'])) $path
Definition: getfiles.php:31
Route\getData
static getData()
Definition: route.class.php:1173
FOGPage\$id
$id
Definition: fogpage.class.php:43
Route\listem
static listem( $class, $sortby='name', $bypass=false, $find=array(), $item='')
Definition: route.class.php:429
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
$foglang
$foglang['Display']
Definition: text.php:22
$msg
if($Host->isValid()) $msg
Definition: hostnameloop.php:42
StorageManagementPage\__construct
__construct($name='')
Definition: storagemanagementpage.class.php:37
$url
$url
Definition: kernelvers.php:27
FOGBase\setMessage
static setMessage($txt, $data=array())
Definition: fogbase.class.php:784
$pass
$pass
Definition: hostinfo.php:161
$ip
if(!(isset($_POST['ip']) &&is_string($_POST['ip']))) if(!(isset($_POST['file']) &&is_string($_POST['file']))) if(!(isset($_POST['lines']) &&is_numeric($_POST['lines']))) if(!(isset($_POST['reverse']) &&is_numeric($_POST['reverse']))) $ip
Definition: logtoview.php:149
StorageManagementPage\search
search()
Definition: storagemanagementpage.class.php:140
FOGBase\$interface
static $interface
Definition: fogbase.class.php:259