Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
soap_api.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset.inc';
19 
31 class SOAP_Api extends Asset
32 {
33 
34  public static $string_non_optional = Array (
35  'type' => 'string',
36  'min' => 1,
37  'max' => 1,
38  'nillable' => FALSE,
39  'mixed' => FALSE,
40  );
41  public static $string_optional = Array (
42  'type' => 'string',
43  'min' => 0,
44  'max' => 1,
45  'nillable' => FALSE,
46  'mixed' => FALSE,
47  );
48  public static $string_optional_unbounded= Array (
49  'type' => 'string',
50  'min' => 0,
51  'max' => 'unbounded',
52  'nillable' => FALSE,
53  'mixed' => FALSE,
54  );
55  public static $boolean_non_optional = Array (
56  'type' => 'boolean',
57  'min' => 1,
58  'max' => 1,
59  'nillable' => FALSE,
60  'mixed' => FALSE,
61  );
62  public static $boolean_optional = Array (
63  'type' => 'boolean',
64  'min' => 0,
65  'max' => 1,
66  'nillable' => FALSE,
67  'mixed' => FALSE,
68  );
69  public static $int_non_optional = Array (
70  'type' => 'int',
71  'min' => 1,
72  'max' => 1,
73  'nillable' => FALSE,
74  'mixed' => FALSE,
75  );
76  public static $int_optional = Array (
77  'type' => 'int',
78  'min' => 0,
79  'max' => 1,
80  'nillable' => FALSE,
81  'mixed' => FALSE,
82  );
83  private $simple_types = NULL;
84 
91  function __construct($assetid=0)
92  {
93  $this->_ser_attrs = TRUE;
94  parent::__construct($assetid);
95 
96  }//end constructor
97 
98 
109  protected function _preCreateCheck(Array &$link)
110  {
111  if (!parent::_preCreateCheck($link)) return FALSE;
112 
113  // if the short name hasn't been set then short and long names are the same to begin with
114  $name = trim($this->attr('name'));
115  if (trim($this->attr('short_name')) == '') {
116  $this->setAttrValue('short_name', $name);
117  }//end if
118 
119  return TRUE;
120 
121  }//end _preCreateCheck()
122 
123 
134  protected function _getName($short_name=FALSE, $contextid=NULL)
135  {
136  // No context specified, using the current context
137  if ($contextid === NULL) {
138  $contextid = $GLOBALS['SQ_SYSTEM']->getContextId();
139  }//end if
140 
141  // Obtain the attribute value for Name from the specified Context
142  $attr = ($short_name) ? 'short_name' : 'name';
143  $values = $GLOBALS['SQ_SYSTEM']->am->getAttributeValuesByName($attr, $this->type(), Array($this->id), $contextid);
144  if (empty($values) === TRUE) {
145  return parent::_getName($short_name, $contextid);
146  } else {
147  return $values[$this->id];
148  }
149 
150  }//end _getName()
151 
152 
160  public function getFunctionList()
161  {
162  return Array();
163 
164  }//end getFunctionList()
165 
166 
178  public static function getArgType($type, $min=0, $max=1, $nillable=FALSE, $mixed=FALSE)
179  {
180  $arg_type = Array (
181  'type' => $type,
182  'min' => $min,
183  'max' => $max,
184  'nillable' => $nillable,
185  'mixed' => $mixed,
186  );
187  return $arg_type;
188 
189  }//end getArgType()
190 
191 
200  public static function getComplexElements($complex_elements=Array())
201  {
202  $complex_elements_available = Array();
203  if (empty($func_list)) {
204  // So sick, this is dodgy, it wouldnt hurt performance though.
205  $func_list = $complex_elements;
206  }//end if
207  foreach ($func_list as $func_name => $switch) {
208  if (isset($complex_elements[$func_name])) {
209  if ($switch) {
210  $complex_elements_available = array_merge($complex_elements_available, $complex_elements[$func_name]);
211  }//end if
212  }//end if
213  }//end foreach
214 
215  return $complex_elements_available;
216 
217  }//end getComplexElements()
218 
219 
226  public static function processSimpleRestrictedTypes($simple_types=Array())
227  {
228  $simple_types_available = Array();
229  if (empty($func_list)) {
230  // So sick, this is dodgy, it wouldnt hurt performance though.
231  $func_list = $simple_types;
232  }//end if
233  foreach ($func_list as $func_name => $switch) {
234  if (isset($simple_types[$func_name])) {
235  if ($switch) {
236  $simple_types_available = array_merge($simple_types_available, $simple_types[$func_name]);
237  }//end if
238  }//end if
239  }//end foreach
240  return $simple_types_available;
241 
242  }//end getSimpleRestrictedTypes()
243 
244 
253  public static function getSimpleRestrictedTypes($simple_types=Array())
254  {
255  return Array();
256 
257  }//end getSimpleRestrictedTypes()
258 
265  public static function getComplexTypes($func_list=Array())
266  {
267  return Array();
268 
269  }//end getComplexTypes()
270 
271 
281  public static function getBooleanIndex($array, $index, $default_val)
282  {
283  $val = array_get_index($array, $index, $default_val);
284  if (empty($val)) {
285  $val = FALSE;
286  } else if ($val == 1) {
287  $val = TRUE;
288  }//end else
289 
290  return $val;
291 
292  }//end getBooleanIndex()
293 
294 
304  public static function getNullIndex($array, $index, $default_val)
305  {
306  $val = array_get_index($array, $index, $default_val);
307  if (empty($val)) {
308  $val = NULL;
309  }//end if
310  return $val;
311 
312  }//end getNullIndex()
313 
314 
324  public function array_get_index_restricted_value($array, $index, $default_val)
325  {
326  $val = array_get_index($array, $index, $default_val);
327  if (empty($this->simple_types)) {
328  $this->simple_types = $this->getSimpleRestrictedTypes();
329  }//end if
330 
331  if (!empty($this->simple_types) && isset($this->simple_types[$index])) {
332  if (!in_array($val, $this->simple_types[$index]['enumeration'])) {
333  throw new SoapFault('Server', 'The input value is not a valid value for '.$index.'. Valid values include: '.implode(', ', $this->simple_types[$index]['enumeration']));
334  }//end if
335  }//end if
336  return $val;
337 
338  }//end array_get_index_restricted_value()
339 
340 
347  public function updateLookupsforAsset($assetid)
348  {
349  require_once SQ_SYSTEM_ROOT.'/core/hipo/jobs/hipo_job_update_lookups.inc';
350  $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
351 
352  $vars = Array('assetids' => Array($assetid));
353  $hh->freestyleHipo('hipo_job_update_lookups', $vars);
354 
355  }//end updateLookupsforAsset()
356 
357 }//end class
358 ?>