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)  

tasktype.class.php
Go to the documentation of this file.
1 <?php
22 class TaskType extends FOGController
23 {
29  protected $databaseTable = 'taskTypes';
35  protected $databaseFields = array(
36  'id' => 'ttID',
37  'name' => 'ttName',
38  'description' => 'ttDescription',
39  'icon' => 'ttIcon',
40  'kernel' => 'ttKernel',
41  'kernelArgs' => 'ttKernelArgs',
42  'type' => 'ttType',
43  'isAdvanced' => 'ttIsAdvanced',
44  'access' => 'ttIsAccess',
45  'initrd' => 'ttInitrd'
46  );
52  protected $databaseFieldsRequired = array(
53  'name',
54  'icon',
55  );
63  public function iconlist($selected = '')
64  {
65  $selected = trim($selected);
66  $fh = fopen(
67  '../management/scss/_variables.scss',
68  'rb'
69  );
70  if (!$fh) {
71  return _('Icon File not found');
72  }
73  while (($line = fgets($fh)) !== false) {
74  if (!preg_match('#^\$fa-var-#', $line)) {
75  continue;
76  }
77  $match = preg_split(
78  '#[:\s|:^\s]+#',
79  trim(
80  preg_replace(
81  '#[\$\"\;\\\]|fa-var-#',
82  '',
83  $line
84  )
85  )
86  );
87  $match[0] = trim($match[0]);
88  $match[1] = trim($match[1]);
89  $icons[$match[0]] = sprintf(
90  '&#x%s',
91  $match[1]
92  );
93  unset($match);
94  }
95  fclose($fh);
96  if (!count($icons)) {
97  return _('No icons found');
98  }
99  ksort($icons);
100  ob_start();
101  echo '<select class="form-control fa" id="icon" name="icon">';
102  foreach ((array) $icons as $name => &$unicode) {
103  printf(
104  '<option value="%s"%s> %s</option>',
105  $name,
106  $selected == $name ? ' selected' : '',
107  $name
108  );
109  unset($unicode, $name);
110  }
111  unset($icons);
112 
113  return sprintf(
114  '%s</select>',
115  ob_get_clean()
116  );
117  }
123  public function getIcon()
124  {
125  return (
126  $this instanceof Task ?
127  $this->getTaskType()->get('icon') :
128  $this->get('icon')
129  );
130  }
136  public function isImagingTask()
137  {
138  return (bool) (
139  $this->isDeploy()
140  || $this->isCapture()
141  );
142  }
150  public function isCapture($nums = false)
151  {
152  $id = (
153  $this instanceof Task ?
154  'typeID' :
155  'id'
156  );
157 
158  if ($nums) {
159  return array(2, 16);
160  }
161 
162  return
163  $this->isValid()
164  && (
165  in_array($this->get($id), array(2, 16))
166  || preg_match(
167  '#type=(2|16|up)#i',
168  $this->get('kernelArgs')
169  )
170  )
171  ;
172  }
180  public function isInitNeededTasking($nums = false)
181  {
182  $id = (
183  $this instanceof Task ?
184  'typeID' :
185  'id'
186  );
187 
188  if ($nums) {
189  return array_diff(
190  range(1, 24),
191  array(4, 12, 13, 14)
192  );
193  }
194 
195  return (
196  $this->isValid()
197  && !in_array($this->get($id), array(4, 12, 13, 14))
198  );
199  }
207  public function isSnapinTasking($nums = false)
208  {
209  $id = (
210  $this instanceof Task ?
211  'typeID' :
212  'id'
213  );
214 
215  if ($nums) {
216  return array(12, 13);
217  }
218 
219  return (
220  $this->isValid()
221  && in_array($this->get($id), array(12, 13))
222  );
223  }
229  public function isSnapinTask()
230  {
231  $id = (
232  $this instanceof Task ?
233  'typeID' :
234  'id'
235  );
236 
237  return
238  $this->isValid()
239  && (
240  (
241  $this->isDeploy()
242  && $this->get($id) != 17
243  )
244  || in_array($this->get($id), array(12, 13))
245  )
246  ;
247  }
255  public function isDeploy($nums = false)
256  {
257  $id = (
258  $this instanceof Task ?
259  'typeID' :
260  'id'
261  );
262 
263  if ($nums) {
264  return array(1, 8, 15, 17, 24);
265  }
266 
267  return
268  $this->isValid()
269  && (
270  in_array($this->get($id), array(1, 8, 15, 17, 24))
271  || preg_match(
272  '#type=(1|8|15|17|24|down)#i',
273  $this->get('kernelArgs')
274  )
275  )
276  ;
277  }
285  public function isMulticast($nums = false)
286  {
287  $id = (
288  $this instanceof Task ?
289  'typeID' :
290  'id'
291  );
292 
293  if ($nums) {
294  return array(8);
295  }
296 
297  return
298  $this->isValid()
299  && (
300  $this->get($id) == 8
301  || preg_match(
302  '#(type=8|mc=yes)#i',
303  $this->get('kernelArgs')
304  )
305  )
306  ;
307  }
313  public function isDebug()
314  {
315  $id = (
316  $this instanceof Task ?
317  'typeID' :
318  'id'
319  );
320 
321  return
322  $this->isValid()
323  && (
324  in_array($this->get($id), array(15, 16))
325  || preg_match('#mode=debug#i', $this->get('kernelArgs'))
326  || preg_match('#mode=onlydebug#i', $this->get('kernelArgs'))
327  )
328  ;
329  }
330 }
TaskType\$databaseFields
$databaseFields
Definition: tasktype.class.php:35
TaskType\$databaseTable
$databaseTable
Definition: tasktype.class.php:29
TaskType\isCapture
isCapture($nums=false)
Definition: tasktype.class.php:150
TaskType\getIcon
getIcon()
Definition: tasktype.class.php:123
TaskType
Definition: tasktype.class.php:23
TaskType\isDebug
isDebug()
Definition: tasktype.class.php:313
TaskType\isInitNeededTasking
isInitNeededTasking($nums=false)
Definition: tasktype.class.php:180
TaskType\isImagingTask
isImagingTask()
Definition: tasktype.class.php:136
TaskType\$databaseFieldsRequired
$databaseFieldsRequired
Definition: tasktype.class.php:52
Task
Definition: task.class.php:23
TaskType\iconlist
iconlist($selected='')
Definition: tasktype.class.php:63
FOGController
Definition: fogcontroller.class.php:29
FOGBase\$selected
static $selected
Definition: fogbase.class.php:151
TaskType\isMulticast
isMulticast($nums=false)
Definition: tasktype.class.php:285
TaskType\isDeploy
isDeploy($nums=false)
Definition: tasktype.class.php:255
TaskType\isSnapinTask
isSnapinTask()
Definition: tasktype.class.php:229
FOGController\isValid
isValid()
Definition: fogcontroller.class.php:865
TaskType\isSnapinTasking
isSnapinTasking($nums=false)
Definition: tasktype.class.php:207