public function getAttributes() { $ret = parent::getAttributes(); if ($this->isLogged()) { $user = new Pap_Common_User(); $user->setId($this->getPapUserId()); $user->load(); for ($i=1; $i<=25; $i++) { $ret['data'.$i] = $user->get('data'.$i); } $ret[Pap_Db_Table_Users::PARENTUSERID] = $user->getParentUserId(); } return $ret; }
/** * @return Pap_Common_User or null */ public function getParent(Pap_Common_User $child) { $parentUserId = $child->getParentUserId(); if (!isset($this->parentUserCache[$parentUserId])) { if (is_array($this->affiliatesInDownline)) { $this->affiliatesInDownline[] = $child->getId(); if (in_array($parentUserId, $this->affiliatesInDownline) || $child->getId() == $parentUserId) { $child->setParentUserId(''); $child->save(); $this->parentUserCache[$parentUserId] = null; return null; } } $this->parentUserCache[$parentUserId] = $child->getParentUser(); } return $this->parentUserCache[$parentUserId]; }
private function getParentWhoReachedCondition($userId, array $reachedConditionUserIds) { $user = new Pap_Common_User(); $user->setId($userId); $user->load(); if (is_null($user->getParentUserId()) || $user->getParentUserId() == '') { return null; } if (in_array($user->getParentUserId(), $reachedConditionUserIds)) { return $user->getParentUserId(); } return $this->getParentWhoReachedCondition($user->getParentUserId(), $reachedConditionUserIds); }