ACL Extension  0.3
 All Data Structures Namespaces Files Functions Variables
Util.php
Go to the documentation of this file.
1 <?php
2 
9 class Util {
10 
17  public static function getDataBaseType($obj){
18  $class = get_class($obj);
19 
20  switch($class){
21  case Strategy::getClass('Aro'):
22  case Strategy::getClass('AroNode'):
23  case 'RGroup':
24  return 'aro';
25  case Strategy::getClass('Aco'):
26  case Strategy::getClass('AcoNode'):
27  case 'AGroup':
28  return 'aco';
29  default:
30  throw new InvalidArgumentException('Unexpected Object');
31  }
32  }
33 
40  public static function getNodeNameOfObject(AclObject $obj){
41  $class = get_class($obj);
42 
43  switch($class){
44  case Strategy::getClass('Aro'):
45  case 'RGroup':
46  return Strategy::getClass('AroNode');
47  case Strategy::getClass('Aco'):
48  case 'CGroup':
49  return Strategy::getClass('AcoNode');
50  default:
51  throw new InvalidArgumentException('Unexpected Object');
52  }
53  }
54 
60  public static function generateInStatement($options){
61  $ret = ' IN ( ';
62 
63  foreach($options as $key =>$option){
64  if($key > 0)
65  $ret.= ' , ';
66 
67  $ret.= ctype_digit($option) ? $option : ' "'.$option.'" ';
68  }
69  $ret.= ' ) ';
70 
71  return $ret;
72  }
73 
80  public static function getIdsOfObjects($objects){
81  $ret = array();
82  foreach($objects as $obj){
83  $ret[] = $obj->id;
84  }
85  return $ret;
86  }
87 }
88 
89 ?>