示例#1
0
	/**
	 * @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];
    }
示例#2
0
	private function spilloverChosenAffiliate(Pap_Common_User $child, Pap_Common_User $originalParentUser) {
		$user = $this->userTree->getChosenUser(Gpf_Settings::get(Pap_Settings::MATRIX_AFFILIATE));
		if ($user === null) {
			$child->setParentUserId(self::NONE_PARENT_USER_ID);
			return;
		}
		$this->initLimit($this->matrixWidth);
		$parent = $this->getParent(array($user));
		if ($parent === null) {
			$parent = $this->getParentSpillover($user);
			if ($parent === null) {
				$child->setParentUserId($user->getId());
				return;
			}
		}
		$child->setParentUserId($parent->getId());
	}
 private function setParentUserId(Pap_Common_User $user, $parentUserId) {
     $user->setParentUserId($parentUserId);
 }