Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
search_folder_edit_fns.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/asset_edit/asset_edit_fns.inc';
18 
31 {
32 
33 
38  function __construct()
39  {
40  parent::__construct();
41 
42  $this->static_screens = Array(
43  'details' => Array(
44  'name' => 'Details',
45  'force_unlock' => FALSE,
46  'lock_type' => 'menu',
47  ),
48  'permissions' => Array(
49  'name' => 'Permissions',
50  'force_unlock' => TRUE,
51  'lock_type' => 'permissions',
52  ),
53  'linking' => Array(
54  'name' => 'Linking',
55  'force_unlock' => TRUE,
56  'lock_type' => 'links',
57  ),
58  'history' => Array(
59  'name' => 'History',
60  'force_unlock' => TRUE,
61  'lock_type' => 'none',
62  ),
63  );
64 
65  }//end constructor
66 
67 
78  function paintRoot(&$asset, &$o, $prefix)
79  {
80  $write_access = $asset->writeAccess('attributes');
81 
82  $settings = $asset->attr('settings');
83  $current = (isset($settings['root'])) ? $settings['root'] : Array();
84 
85  if ($write_access) {
86  multiple_asset_finder($prefix.'_roots', $current);
87  } else {
88  ?><ul style="margin: 1px 15px"><?php
89  foreach ($current as $assetid) {
90  if (!empty($assetid)) {
91  ?><li><?php echo get_asset_tag_line($assetid) ?></li><?php
92  } else {
93  echo translate('sch_folder_no_search_root');
94  }
95  }
96  ?></ul><?php
97  }
98 
99  return $write_access;
100 
101  }//end paintRoot()
102 
103 
114  function processRoot(&$asset, &$o, $prefix)
115  {
116  // need to have write access to make any changes
117  if (!$asset->writeAccess('attributes')) return FALSE;
118 
119  $settings = $asset->attr('settings');
120  $settings['root'] = Array();
121 
122  if (is_array($_POST[$prefix.'_roots'])) {
123  foreach ($_POST[$prefix.'_roots'] as $root_node) {
124  if (!empty($root_node['assetid'])) {
125  $settings['root'][] = $root_node['assetid'];
126  }
127  }
128  }
129 
130  return $asset->setAttrValue('settings', $settings);
131 
132  }//end processRoot()
133 
134 
145  function paintPhrase(&$asset, &$o, $prefix)
146  {
147  $write_access = $asset->writeAccess('attributes');
148 
149  $settings = $asset->attr('settings');
150  $current = (isset($settings['phrase'])) ? $settings['phrase'] : '';
151 
152  if ($write_access) {
153  text_box($prefix.'_phrase', $current, 50);
154  } else {
155  if (empty($current)) {
156  echo translate('sch_folder_no_search_phrase');
157  } else {
158  echo $current;
159  }
160  }
161 
162  return $write_access;
163 
164  }//end paintPhrase()
165 
166 
177  function processPhrase(&$asset, &$o, $prefix)
178  {
179  // need to have write access to make any changes
180  if (!$asset->writeAccess('attributes')) return FALSE;
181 
182  $settings = $asset->attr('settings');
183 
184  if (isset($_POST[$prefix.'_phrase'])) {
185  $settings['phrase'] = trim($_POST[$prefix.'_phrase']);
186  } else {
187  $settings['phrase'] = '';
188  }
189 
190  return $asset->setAttrValue('settings', $settings);
191 
192  }//end processPhrase()
193 
194 
205  function paintLogic(&$asset, &$o, $prefix)
206  {
207  $write_access = $asset->writeAccess('attributes');
208 
209  $settings = $asset->attr('settings');
210  $current = (isset($settings['logic'])) ? $settings['logic'] : 'and';
211 
212  if ($write_access) {
213  combo_box($prefix.'_logic', Array('and' => translate('sch_folder_logic_and'), 'or' => translate('sch_folder_logic_or')), FALSE, $current);
214  } else {
215  echo translate('sch_folder_logic_'.$current);
216  }
217 
218  return $write_access;
219 
220  }//end paintLogic()
221 
222 
233  function processLogic(&$asset, &$o, $prefix)
234  {
235  // need to have write access to make any changes
236  if (!$asset->writeAccess('attributes')) return FALSE;
237 
238  $settings = $asset->attr('settings');
239 
240  if (isset($_POST[$prefix.'_logic'])) {
241  $settings['logic'] = trim($_POST[$prefix.'_logic']);
242  } else {
243  $settings['logic'] = '';
244  }
245 
246  return $asset->setAttrValue('settings', $settings);
247 
248  }//end processLogic()
249 
250 
261  function paintStatus(&$asset, &$o, $prefix)
262  {
263  require_once SQ_INCLUDE_PATH.'/general_occasional.inc';
264  $write_access = $asset->writeAccess('attributes');
265 
266  $settings = $asset->attr('settings');
267  $current = (isset($settings['statuses'])) ? $settings['statuses'] : Array();
268 
269  if ($write_access) {
270  require_once SQ_LIB_PATH.'/html_form/html_form.inc';
271  $statuses = get_constant_values('SQ_STATUS');
272 
273  $options = Array();
274  foreach ($statuses as $constant => $value) {
275  $options[$value] = get_status_description($value);
276  }
277 
278  combo_box($prefix.'_statuses', $options, TRUE, $current);
279  } else {
280  if (empty($current)) {
281  echo translate('no_status_selected');
282  } else {
283  ?><ul style="margin: 1px 15px"><?php
284  foreach ($current as $status) {
285  echo '<li>';
286  echo get_asset_status_icon($status);
287  echo get_status_description($status);
288  echo '</li>';
289  }
290  ?></ul><?php
291  }
292  }
293 
294  return $write_access;
295 
296  }//end paintStatus()
297 
298 
309  function processStatus(&$asset, &$o, $prefix)
310  {
311  // need to have write access to make any changes
312  if (!$asset->writeAccess('attributes')) return FALSE;
313 
314  $settings = $asset->attr('settings');
315 
316  if (isset($_POST[$prefix.'_statuses'])) {
317  $settings['statuses'] = Array();
318  foreach ($_POST[$prefix.'_statuses'] as $status) {
319  $settings['statuses'][] = $status;
320  }
321  $settings['statuses'] = array_unique($settings['statuses']);
322  } else {
323  $settings['statuses'] = Array();
324  }
325 
326  return $asset->setAttrValue('settings', $settings);
327 
328  }//end processStatus()
329 
330 
341  function paintAssetTypes(&$asset, &$o, $prefix)
342  {
343  $settings = $asset->attr('settings');
344  $types = array_get_index($settings, 'types', Array());
345  if ($asset->writeAccess('attributes')) {
346  // print the form fields
347  $display_values = Array('type_code' => Array(), 'inherit' => Array());
348  foreach ($types as $type => $inherit) {
349  $display_values['type_code'][] = $type;
350  $display_values['inherit'][] = $inherit;
351  }
352  asset_type_chooser($prefix.'_types', TRUE, $display_values, NULL, FALSE, TRUE);
353  return TRUE;
354  } else {
355  // print the read-only version
356  if (empty($types)) {
357  echo '<p class="sq-backend-warning">'.translate('sch_no_asset_types_selected').'</p>';
358  } else {
359  $type_names = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo(array_keys($types), 'name');
360  ?>
361  <table class="sq-backend-table">
362  <tr>
363  <th><?php echo translate('type'); ?></th>
364  <th><?php echo translate('inherit_question'); ?></th>
365  </tr>
366  <?php
367  $inherit_image_path = sq_web_path('lib').'/web/images/';
368  foreach ($types as $type => $inherit) {
369  $inherit_image = $inherit_image_path.($inherit ? 'tick' : 'cross').'.gif';
370  $inherit_alt = $inherit ? translate('yes') : translate('no');
371  ?>
372  <tr>
373  <td><?php echo get_asset_type_icon($type).$type_names[$type]; ?></td>
374  <td><img src="<?php echo $inherit_image; ?>" alt="<?php echo $inherit_alt; ?>" /></td>
375  </tr>
376  <?php
377  }
378  ?>
379  </table>
380  <?php
381  }
382  return FALSE;
383  }
384 
385  }//end paintAssetTypes()
386 
387 
398  function processAssetTypes(&$asset, &$o, $prefix)
399  {
400  $settings = $asset->attr('settings');
401 
402  $submitted_types = Array();
403  foreach ($_POST[$prefix.'_types']['type_code'] as $i => $type_code) {
404  if (!empty($type_code)) {
405  $submitted_types[$type_code] = $_POST[$prefix.'_types']['inherit'][$i];
406  }
407  }
408 
409  $settings['types'] = $submitted_types;
410  return $asset->setAttrValue('settings', $settings);
411 
412  }//end processAssetTypes()
413 
414 
415 }//end class
416 
417 ?>