Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
soap_server_edit_fns.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/page/page_edit_fns.inc';
19 
32 {
33 
34 
39  function __construct()
40  {
41  parent::__construct();
42 
43  }//end constructor
44 
45 
56  function paintAPIList(&$asset, &$o, $prefix)
57  {
58  require_once SQ_LIB_PATH.'/html_form/html_form.inc';
59 
60  $write_access = $asset->writeAccess('attributes');
61  $am = $GLOBALS['SQ_SYSTEM']->am;
62  $list_api = $am->getChildren($asset->id, 'soap_api', FALSE);
63 
64  $known_api = $asset->attr('list_api');
65 
66  if (empty($list_api)) {
67  echo 'No APIs installed';
68  } else {
69  // Define the list with an enable/disable field
70  $o->openField('');
71  ?>
72  <table class="sq-backend-table">
73  <tr>
74  <td class="sq-backend-table-header" width="66%"><?php echo translate('api_name'); ?></td>
75  <td class="sq-backend-table-header" width="33%"><?php echo translate('enable'); ?></td>
76  </tr>
77  <?php
78  foreach ($list_api as $api_id => $api_value) {
79 
80  // Find the current value
81  $current_value = FALSE;
82 
83  if (isset($known_api[$api_id])) $current_value = TRUE;
84 
85  ?>
86  <tr>
87  <td class="sq-backend-table-cell">
88  <?php
89  echo get_asset_tag_line($api_id);
90  ?>
91  </td>
92  <td class="sq-backend-table-cell">
93  <?php
94  if ($write_access) {
95  check_box($prefix.'_enable['.$api_id.']', $api_value[0]['type_code'], $current_value);
96  } else {
97  ?>&nbsp;
98  <img src="<?php echo sq_web_path('lib'); ?>/web/images/<?php echo ($current_value) ? 'tick' : 'cross'; ?>.gif" width="15" height="15" />
99  <?php
100  }
101  ?>
102  </td>
103  </tr>
104  <?php
105 
106  // Unload our temp asset here
107  $am->forgetAsset($api_asset);
108  unset($api_asset);
109  }//end foreach
110  ?>
111  </table>
112  <?php
113 
114  $o->closeField();
115  if ($write_access) {
116  $o->openField('');
117  $o->closeField();
118  $o->openField('Regenerate WSDL');
119  check_box($prefix.'_regenerate_wsdl', '1', 1);
120  $o->note('Select to regenerate the WSDL file to reflect your new changes');
121  $o->closeField();
122  }//end if
123  }//end else
124 
125  return TRUE;
126 
127  }//end paintAPIList()
128 
129 
140  function processAPIList(&$asset, &$o, $prefix)
141  {
142  $write_access = $asset->writeAccess('attributes');
143  $prefix = $asset->getPrefix();
144 
145  $regen_wsdl = FALSE;
146  if ($write_access) {
147  if (isset($_POST[$prefix.'_regenerate_wsdl'])) {
148  $regen_wsdl = TRUE;
149  }//end if
150  if (isset($_POST[$prefix.'_enable']) && !empty($_POST[$prefix.'_enable'])) {
151  $save_api_list = Array();
152  foreach ($_POST[$prefix.'_enable'] as $assetid => $enabled) {
153  if (empty($assetid)) continue;
154 
155  // Save the entry
156  $save_api_list[$assetid] = $enabled;
157  }//end foreach
158 
159  if (!empty($save_api_list)) {
160  $regen_wsdl = TRUE;
161  $GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
162  $asset->setAttrValue('list_api', $save_api_list);
163  $asset->saveAttributes();
164  $GLOBALS['SQ_SYSTEM']->restoreRunLevel();
165  }//end foreach
166  } else {
167  // If it is not set then there is nothing enabled.
168  $empty_api_list = Array();
169  $regen_wsdl = TRUE;
170  $asset->setAttrValue('list_api', $empty_api_list);
171  $asset->saveAttributes();
172  }//end else
173  }//end if write access
174 
175  if ($regen_wsdl) {
176  $asset->generateWSDL();
177  }//end if
178 
179  }//end processAPIList()
180 
181 
182 }//end class
183 ?>