Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
cmis_bridge_edit_fns.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/asset_edit/asset_edit_fns.inc';
18 
29 {
30 
35  function __construct()
36  {
37  parent::__construct();
38  $this->static_screens['details']['force_unlock'] = FALSE;
39 
40  }//end constructor
41 
42 
51  function paintWsdlUrl(&$asset, &$o, $prefix)
52  {
53  $write_access = $asset->writeAccess('attributes');
54  $wsdl = $asset->attr('wsdl');
55 
56  ?>
57  <table class="sq-backend-table">
58  <tr>
59  <td class="sq-backend-table-header">
60  <?php echo 'Service Name'; ?>
61  </td>
62  <td class="sq-backend-table-header">
63  <?php echo 'WSDL URL'; ?>
64  </td>
65  <td class="sq-backend-table-header">
66  <?php echo 'Connection Status'; ?>
67  </td>
68  </tr>
69  <?php
70 
71  foreach ($wsdl as $service => $url) {
72  ?>
73  <tr>
74  <td class="sq-backend-table-cell">
75  <?php echo $service; ?>
76  </td>
77  <td class="sq-backend-table-cell">
78  <?php
79  if ($write_access){
80  text_box($prefix.'[wsdl_urls]['.$service.']', $url, '100');
81  } else {
82  echo $url;
83  }
84  ?>
85  </td>
86  <td class="sq-backend-table-cell">
87  <?php
88  $conn = $asset->connect($service, TRUE);
89  if ($conn === FALSE) {
90  echo '<span style="color: red"><b>'.translate('cmis_not_connected').'</b></span>';
91  } else {
92  echo '<span style="color: green"><b>'.translate('cmis_connected').'</b></span>';
93  }
94  ?>
95  </td>
96  </tr>
97  <?php
98  }//end foreach data
99  ?>
100  </table>
101  <?php
102  return TRUE;
103 
104  }//end paintWsdlUrl()
105 
106 
115  function processWsdlUrl(&$asset, &$o, $prefix)
116  {
117  if (!$asset->writeAccess('attributes')) return FALSE;
118 
119  if (isset($_POST[$prefix]['wsdl_urls'])) {
120  $wsdl = $_POST[$prefix]['wsdl_urls'];
121  foreach ($wsdl as $service => $url){
122  $wsdl[$service] = trim($url);
123  }
124 
125  $asset->setAttrValue('wsdl', $wsdl);
126  $asset->saveAttributes();
127  }
128 
129  return TRUE;
130 
131  }//end processWsdlUrl()
132 
133 
144  function paintSynchCheck(&$asset, &$o, $prefix)
145  {
146  $wa = $asset->writeAccess('attributes');
147  if ($wa) check_box($prefix.'_synch');
148  return TRUE;
149 
150  }//end paintSynchCheck()
151 
152 
163  function processSynchCheck(&$asset, &$o, $prefix)
164  {
165  if (isset($_POST[$prefix.'_synch'])) {
166  $vars['bridge_id'] = $asset->id;
167  $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
168  $hh->queueHipo('hipo_job_sync_cmis_bridge', $vars, '', SQ_PACKAGES_PATH.'/sharepoint/hipo_jobs/');
169  }
170 
171  return TRUE;
172  }//end processSynchCheck()
173 
174 
185  function paintMetadataOptions(&$asset, &$o, $prefix)
186  {
187  $wa = $asset->writeAccess('attributes');
188  $current_metadata_fields = $asset->attr('metadata_fields');
189  $metadata_fields = $asset->getAvailableDocumentFields();
190  if (empty($metadata_fields)) return FALSE; //should never be empty unless !$this->isConnected()
191 
192  ?>
193  <table class="sq-backend-table">
194  <tr>
195  <th><?php echo "Field"; ?></th>
196  <th><?php echo "Field Type"; ?></th>
197  <th><?php echo "Metadata Field ID" ?></th>
198  </tr>
199  <?php
200  foreach ($metadata_fields as $property => $info) {
201  ?>
202  <tr>
203  <td>
204  <?php
205  echo $info['display_name'];
206  ?>
207  </td>
208  <td>
209  <?php
210  echo $info['type'];
211  ?>
212  </td>
213  <td>
214  <?php
215  $field_id = isset($current_metadata_fields[$property]['field']) ? $current_metadata_fields[$property]['field'] : '';
216  if ($wa) {
217  $type_codes = Array('metadata_field' => 'D');
218  if ($property == 'cmis:objectId') $type_codes = Array('metadata_field_text' => 'I');
219  if ($property == 'cmis:lastModificationDate') $type_codes = Array('metadata_field_date' => 'I');
220  asset_finder($prefix.'_'.$property, $field_id, $type_codes);
221  } else {
222  if ($field_id) echo get_asset_tag_line($field_id);
223  }
224  ?>
225  </td>
226  </tr>
227  <?php
228  }//end foreach
229  ?>
230  </table>
231  <?php
232  return TRUE;
233 
234  }//end paintMetadataOptions()
235 
236 
247  function processMetadataOptions(&$asset, &$o, $prefix)
248  {
249  if (!$asset->writeAccess('attributes')) return FALSE;
250  $mm = $GLOBALS['SQ_SYSTEM']->getMetadataManager();
251  $applied_schemas = $mm->getSchemas($asset->id, TRUE, TRUE);
252  $fields = $mm->getMetadataFields($applied_schemas);
253 
254  $current_metadata_fields = $asset->attr('metadata_fields');
255  $metadata_fields = $asset->getAvailableDocumentFields();
256  if (empty($metadata_fields)) return FALSE; //should never be empty unless !$this->isConnected()
257 
258  foreach ($metadata_fields as $property => $info){
259  $current_field_id = isset($current_metadata_fields[$property]['field']) ? $current_metadata_fields[$property]['field'] : '';
260  $field_id = (isset($_POST[$prefix.'_'.$property]['assetid'])) ? $_POST[$prefix.'_'.$property]['assetid'] : $current_field_id;
261  if (!empty($field_id)){
262  if (!array_key_exists($field_id, $fields)){
263  trigger_localised_error('SHAR0001', E_USER_WARNING, $field_id);
264  //revert to original value
265  $metadata_fields[$property]['field'] = $current_field_id;
266  continue;
267  }
268  if ($property == 'cmis:objectId'){
269  $type_info = $GLOBALS['SQ_SYSTEM']->am->getAssetTypeInfo($field_id, Array('metadata_field_text'));
270  if (empty($type_info)) {
271  trigger_localised_error('SHAR0004', E_USER_WARNING, $info['display_name'], 'Metadata Text Field');
272  //revert to original value
273  $field_id = $current_field_id;
274  }
275  } else if ($property == 'cmis:lastModificationDate'){
276  $type_info = $GLOBALS['SQ_SYSTEM']->am->getAssetTypeInfo($field_id, Array('metadata_field_date'));
277  if (empty($type_info)) {
278  trigger_localised_error('SHAR0004', E_USER_WARNING, $info['display_name'], 'Metadata Date Field');
279  //revert to original value
280  $field_id = $current_field_id;
281  }
282  }
283  }
284 
285  $metadata_fields[$property]['field'] = $field_id;
286  }
287 
288  $asset->setAttrValue('metadata_fields', $metadata_fields);
289  $asset->saveAttributes();
290 
291  return TRUE;
292 
293  }//end processMetadataOptions()
294 
295 
304  function isConnected(&$asset)
305  {
306  foreach ($asset->attr('wsdl') as $service_name => $url){
307  $connected = $asset->connect($service_name, TRUE);
308  if (!$connected) break;
309  }
310  if (empty($connected)) return FALSE;
311 
312  $repositoryId = $asset->getRepositoryId();
313  if (empty($repositoryId)) return FALSE;
314 
315  return TRUE;
316 
317  }//end isConnected()
318 
319 
320 
321 }//end class
322 ?>