示例#1
0
	public function computeParentFor(Pap_Common_User $child) {
		$originalParent = $this->userTree->getParent($child);
		if ($originalParent === null) {
			$child->setParentUserId(self::NONE_PARENT_USER_ID);
			return;
		}
		$this->initMatrixSize($originalParent);		
		$parent = $this->getParent(array($originalParent));
		if ($parent === null) {
			$this->spillover($child, $originalParent);
			return;
		}
		$child->setParentUserId($parent->getId());
	}
示例#2
0
 private function getTransaction(Pap_Contexts_Tracking $context) {
     $userTree = new Pap_Common_UserTree();
     $tier = 1;
     $currentUser = $context->getUserObject();
     $currentTransaction = $context->getTransaction($tier);
     
     while ($currentUser != null && $tier < 100) {
         if ($currentTransaction != null) {
             $transactionId = $currentTransaction->getTransactionId();
             if ($transactionId != null && $transactionId != '') {
                 return $currentTransaction;
             }
         }
         $tier++;
         $currentUser = $userTree->getParent($currentUser);
         $currentTransaction = $context->getTransaction($tier);
     }
     return $context->getTransaction();
 }
 protected function checkForCycle(Pap_Affiliates_User $potentialParent, $userId) {
     $tree = new Pap_Common_UserTree();
     $tree->startCheckingLoops();
     $affiliate = $potentialParent;
     while ($affiliate != null){
         if ($userId == $affiliate->getId()) {
             return false;
         }
         $affiliate = $tree->getParent($affiliate);
     }
     return true;
 }