wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
class.UserRDBBase.php
Go to the documentation of this file.
1 <?php
2 /**
3  * This file was generated by wCMFGenerator 2.6.1.0033 from cookbook1.xmi on 23.02.09 21:34.
4  * Manual modifications should be placed inside the protected regions.
5  */
6 require_once(BASE."wcmf/lib/security/class.User.php");
7 
8 /**
9  * @class UserRDB
10  * UserRDB description:
11  *
12  * @author <ingo@wemove.com>
13  * @version 1.0
14  */
15 class UserRDBBase extends User
16 {
17  function UserRDBBase($oid=null, $type=null)
18  {
19  if ($type == null)
20  parent::User($oid, 'UserRDB');
21  else
22  parent::User($oid, $type);
23  }
24  /**
25  * @see PersistentObject::getObjectDisplayName()
26  */
28  {
29  return Message::get("UserRDB");
30  }
31  /**
32  * @see PersistentObject::getObjectDescription()
33  */
35  {
36  return Message::get("");
37  }
38  /**
39  * @see PersistentObject::getValueDisplayName()
40  */
41  function getValueDisplayName($name, $type=null)
42  {
43  $displayName = $name;
44  if ($name == 'id') $displayName = Message::get("id");
45  if ($name == 'login') $displayName = Message::get("login");
46  if ($name == 'password') $displayName = Message::get("password");
47  if ($name == 'name') $displayName = Message::get("name");
48  if ($name == 'firstname') $displayName = Message::get("firstname");
49  if ($name == 'config') $displayName = Message::get("config");
50  return Message::get($displayName);
51  }
52  /**
53  * @see PersistentObject::getValueDescription()
54  */
55  function getValueDescription($name, $type=null)
56  {
57  $description = $name;
58  if ($name == 'id') $description = Message::get("");
59  if ($name == 'login') $description = Message::get("");
60  if ($name == 'password') $description = Message::get("");
61  if ($name == 'name') $description = Message::get("");
62  if ($name == 'firstname') $description = Message::get("");
63  if ($name == 'config') $description = Message::get("");
64  return Message::get($description);
65  }
66  /**
67  * See if the node is an association object, that implements a many to many relation
68  */
69  function isManyToManyObject()
70  {
71  return false;
72  }
73  /**
74  * Getter/Setter
75  */
76  function getId($unconverted=false)
77  {
78  if ($unconverted)
79  return $this->getUnconvertedValue('id', DATATYPE_IGNORE);
80  else
81  return $this->getValue('id', DATATYPE_IGNORE);
82  }
83  function setId($id)
84  {
85  return $this->setValue('id', $id, DATATYPE_IGNORE);
86  }
87  function getLogin($unconverted=false)
88  {
89  if ($unconverted)
90  return $this->getUnconvertedValue('login', DATATYPE_ATTRIBUTE);
91  else
92  return $this->getValue('login', DATATYPE_ATTRIBUTE);
93  }
94  function setLogin($login)
95  {
96  return $this->setValue('login', $login, DATATYPE_ATTRIBUTE);
97  }
98  function getPassword($unconverted=false)
99  {
100  if ($unconverted)
101  return $this->getUnconvertedValue('password', DATATYPE_ATTRIBUTE);
102  else
103  return $this->getValue('password', DATATYPE_ATTRIBUTE);
104  }
105  function setPassword($password)
106  {
107  return $this->setValue('password', $password, DATATYPE_ATTRIBUTE);
108  }
109  function getName($unconverted=false)
110  {
111  if ($unconverted)
112  return $this->getUnconvertedValue('name', DATATYPE_ATTRIBUTE);
113  else
114  return $this->getValue('name', DATATYPE_ATTRIBUTE);
115  }
116  function setName($name)
117  {
118  return $this->setValue('name', $name, DATATYPE_ATTRIBUTE);
119  }
120  function getFirstname($unconverted=false)
121  {
122  if ($unconverted)
123  return $this->getUnconvertedValue('firstname', DATATYPE_ATTRIBUTE);
124  else
125  return $this->getValue('firstname', DATATYPE_ATTRIBUTE);
126  }
127  function setFirstname($firstname)
128  {
129  return $this->setValue('firstname', $firstname, DATATYPE_ATTRIBUTE);
130  }
131  function getConfig($unconverted=false)
132  {
133  if ($unconverted)
134  return $this->getUnconvertedValue('config', DATATYPE_ATTRIBUTE);
135  else
136  return $this->getValue('config', DATATYPE_ATTRIBUTE);
137  }
138  function setConfig($config)
139  {
140  return $this->setValue('config', $config, DATATYPE_ATTRIBUTE);
141  }
142  /**
143  * @deprecated use getLocktableChildren() instead
144  */
145  function getLocktableList()
146  {
147  Log::warn("use of deprecated method getLocktableList. use getLocktableChildren() instead.\n".WCMFException::getStackTrace(), __CLASS__);
148  return $this->getLocktableChildren();
149  }
151  {
152  return $this->getChildrenEx(null, 'Locktable', array('fk_user_id' => $this->getDBID()), null);
153  }
154  /**
155  * @deprecated use getNMUserRoleChildren() instead
156  */
157  function getNMUserRoleList()
158  {
159  Log::warn("use of deprecated method getNMUserRoleList. use getNMUserRoleChildren() instead.\n".WCMFException::getStackTrace(), __CLASS__);
160  return $this->getNMUserRoleChildren();
161  }
163  {
164  return $this->getChildrenEx(null, 'NMUserRole', array('fk_user_id' => $this->getDBID()), null);
165  }
166  /**
167  * @deprecated use getRoleRDBChildren() instead
168  */
169  function getRoleRDBList()
170  {
171  Log::warn("use of deprecated method getRoleRDBList. use getRoleRDBChildren() instead.\n".WCMFException::getStackTrace(), __CLASS__);
172  return $this->getRoleRDBChildren();
173  }
175  {
176  // the foreign key column does not exist
177  return $this->getChildrenEx(null, 'RoleRDB', null, null);
178  }
179 
180  /**
181  * Node class overrides
182  */
183 
184  /**
185  * @see Node::loadChildren()
186  * Override this to also load the children of many-to-many relations
187  */
188  function loadChildren($type, $buildDepth=BUILDDEPTH_SINGLE, $forceUpdate=false)
189  {
190  // handle NMUserRole as many-to-many type
191  if ($type == 'RoleRDB')
192  {
193  // for every NMUserRole we have to load the RoleRDB
194  $this->loadChildren('NMUserRole');
195  $children = parent::getChildrenEx(null, 'NMUserRole', array('fk_user_id' => $this->getDBID()), null);
196  $persistenceFacade = &PersistenceFacade::getInstance();
197  $grandChildren = array();
198  for($i=0; $i<sizeof($children); $i++)
199  {
200  if (PersistenceFacade::isValidOID($children[$i]->getRoleRDBOID()))
201  {
202  $grandChild = &$persistenceFacade->load($children[$i]->getRoleRDBOID(), BUILDDEPTH_SINGLE);
203  if ($grandChild != null)
204  {
205  // establish connetcion
206  $grandChild->addChild($children[$i]);
207  $grandChild->setState(STATE_CLEAN);
208  $children[$i]->setState(STATE_CLEAN);
209  }
210  }
211  }
212  return;
213  }
214  // do default
215  parent::loadChildren($type, $buildDepth, $forceUpdate);
216  }
217  /**
218  * @see Node::getChildrenEx()
219  * Override this to also get the children of many-to-many relations
220  */
221  function getChildrenEx($oid, $type, $values, $properties)
222  {
223  // handle NMUserRole as many-to-many type
224  if ($type == 'RoleRDB' || PersistenceFacade::getOIDParameter($oid, 'type') == 'RoleRDB')
225  {
226  // for every NMUserRole we have to get the RoleRDB parents
227  $children = parent::getChildrenEx(null, 'NMUserRole', array('fk_user_id' => $this->getDBID()), null);
228  $grandChildren = array();
229  $persistenceFacade = &PersistenceFacade::getInstance();
230  for($i=0; $i<sizeof($children); $i++)
231  {
232  // load the parents
233  $grandChildrenParents = array();
234  foreach ($children[$i]->getProperty('parentoids') as $parentoid)
235  {
236  if (PersistenceFacade::getOIDParameter($parentoid, 'type') == 'RoleRDB')
237  {
238  $tmpParents = $children[$i]->getParentsEx($parentoid, null, null, null);
239  if (sizeof($tmpParents) > 0)
240  $curChildParent = &$tmpParents[0];
241  else
242  $curChildParent = &$persistenceFacade->load($parentoid, BUILDDEPTH_SINGLE);
243  if ($curChildParent != null)
244  $grandChildrenParents[sizeof($grandChildrenParents)] = &$curChildParent;
245  }
246  }
247  for($j=0; $j<sizeof($grandChildrenParents); $j++)
248  $grandChildren[sizeof($grandChildren)] = &$grandChildrenParents[$j];
249  }
250  return Node::filter($grandChildren, $oid, $type, $values, $properties);
251  }
252  // do default
253  return parent::getChildrenEx($oid, $type, $values, $properties);
254  }
255  /**
256  * @see Node::addChild()
257  * Override this to insert association objects if necessary
258  */
259  function addChild(&$child, $addtype=ADDCHILD_BACK)
260  {
261  if ($child != null && $child->getType() == 'RoleRDB')
262  {
263  // for every RoleRDB we have to insert a NMUserRole
264  $persistenceFacade = &PersistenceFacade::getInstance();
265  // check if the relation already exists
266  $relOID = $persistenceFacade->getFirstOID('NMUserRole', array('fk_user_id' => $this->getDBID(), 'fk_role_id' => $child->getDBID()));
267  if ($relOID == null)
268  {
269  // add the child only if it is not added already
270  $associationNode = &$persistenceFacade->create('NMUserRole', BUILDTYPE_SINGLE);
271  $associationNode->setUserRDB($this);
272  $associationNode->setRoleRDB($child);
273  $child->addChild($associationNode);
274  }
275  else
276  $associationNode = &$persistenceFacade->load($relOID, BUILDTYPE_SINGLE);
277  // set child parameter to associationNode and prodeed with default behaviour
278  $child = &$associationNode;
279  }
280  // do default
281  parent::addChild($child, $addtype);
282  }
283  /**
284  * @see Node::deleteChild()
285  * Override this to delete association objects if necessary
286  */
287  function deleteChild($childOID, $reallyDelete=false)
288  {
289  if (PersistenceFacade::isValidOID($childOID) && PersistenceFacade::getOIDParameter($childOID, 'type') == 'RoleRDB')
290  {
291  // for every RoleRDB we have to delete the NMUserRole
292  // set childOID parameter to the NMUserRole's object id and prodeed with default behaviour
293  $ids = PersistenceFacade::getOIDParameter($childOID, 'id');
294  array_unshift($ids, $this->getDBID());
295  $childOID = PersistenceFacade::composeOID(array('type' => 'NMUserRole', 'id' => $ids));
296  }
297  // do default
298  parent::deleteChild($childOID, $reallyDelete);
299  }
300 }
301 ?>
getLogin($unconverted=false)
getPassword($unconverted=false)
getValueDescription($name, $type=null)
getId($unconverted=false)
get($message, $parameters=null, $domain='', $lang='')
warn($message, $category)
Definition: class.Log.php:59
const DATATYPE_ATTRIBUTE
Abstract base class for user classes that represent a system user.
Definition: class.User.php:31
getName($unconverted=false)
getValue($name, $type=null)
setPassword($password)
loadChildren($type, $buildDepth=BUILDDEPTH_SINGLE, $forceUpdate=false)
const STATE_CLEAN
deleteChild($childOID, $reallyDelete=false)
getConfig($unconverted=false)
filter(&$nodeList, $oid, $type, $values, $properties, $useRegExp=true)
Definition: class.Node.php:401
getFirstname($unconverted=false)
const DATATYPE_IGNORE
setFirstname($firstname)
const ADDCHILD_BACK
Definition: class.Node.php:31
getOIDParameter($oid, $param, $validate=true)
setValue($name, $value, $type=null, $forceSet=false)
addChild(&$child, $addtype=ADDCHILD_BACK)
UserRDBBase($oid=null, $type=null)
const BUILDDEPTH_SINGLE
getUnconvertedValue($name, $type=null)
getChildrenEx($oid, $type, $values, $properties)
getValueDisplayName($name, $type=null)