當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserListFactory::getIterator方法代碼示例

本文整理匯總了PHP中UserListFactory::getIterator方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserListFactory::getIterator方法的具體用法?PHP UserListFactory::getIterator怎麽用?PHP UserListFactory::getIterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserListFactory的用法示例。


在下文中一共展示了UserListFactory::getIterator方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Validate

 function Validate()
 {
     if ($this->getUser() == $this->getParent()) {
         $this->Validator->isTrue('parent', FALSE, TTi18n::gettext('User is the same as parent'));
     }
     //Make sure both user and parent belong to the same company
     $ulf = new UserListFactory();
     $ulf->getById($this->getUser());
     $user = $ulf->getIterator()->current();
     unset($ulf);
     $ulf = new UserListFactory();
     $ulf->getById($this->getParent());
     $parent = $ulf->getIterator()->current();
     unset($ulf);
     if ($this->getUser() == 0 and $this->getParent() == 0) {
         $parent_company_id = 0;
         $user_company_id = 0;
     } elseif ($this->getUser() == 0) {
         $parent_company_id = $parent->getCompany();
         $user_company_id = $parent->getCompany();
     } elseif ($this->getParent() == 0) {
         $parent_company_id = $user->getCompany();
         $user_company_id = $user->getCompany();
     } else {
         $parent_company_id = $parent->getCompany();
         $user_company_id = $user->getCompany();
     }
     if ($user_company_id > 0 and $parent_company_id > 0) {
         Debug::Text(' User Company: ' . $user_company_id . ' Parent Company: ' . $parent_company_id, __FILE__, __LINE__, __METHOD__, 10);
         if ($user_company_id != $parent_company_id) {
             $this->Validator->isTrue('parent', FALSE, TTi18n::gettext('User or parent has incorrect company'));
         }
         $this->getFastTreeObject()->setTree($this->getHierarchyControl());
         $children_arr = $this->getFastTreeObject()->getAllChildren($this->getUser(), 'RECURSE');
         if (is_array($children_arr)) {
             $children_ids = array_keys($children_arr);
             if (isset($children_ids) and is_array($children_ids) and in_array($this->getParent(), $children_ids) == TRUE) {
                 Debug::Text(' Objects cant be re-parented to their own children...', __FILE__, __LINE__, __METHOD__, 10);
                 $this->Validator->isTrue('parent', FALSE, TTi18n::gettext('Unable to change parent to a child of itself'));
             }
         }
         /*
         			//Make sure we're not re-parenting to a child.
         			$uhlf = new UserHierarchyListFactory();
         			$hierarchy = $uhlf->getByCompanyIdArray( $parent_company_id );
         
         			Debug::Text(' User ID: '. $this->getUser() .' Parent ID: '. $this->getParent(), __FILE__, __LINE__, __METHOD__,10);
         			if ( is_array( $hierarchy ) ) {
         				if ( in_array( $this->getParent(), array_keys( $hierarchy[$this->getUser()] ) ) ) {
         					Debug::Text(' Trying to re-parent to a child! ', __FILE__, __LINE__, __METHOD__,10);
         
         					$this->Validator->isTrue(	'parent',
         												FALSE,
         												TTi18n::gettext('Unable to change parent to a child of itself')
         												);
         
         				} else {
         					Debug::Text(' NOT Trying to re-parent to a child! ', __FILE__, __LINE__, __METHOD__,10);
         				}
         			} else {
         				Debug::Text(' NOT Trying to re-parent to a child! 22', __FILE__, __LINE__, __METHOD__,10);
         			}
         */
     }
     return TRUE;
 }
開發者ID:J-P-Hanafin,項目名稱:TimeTrex-1,代碼行數:66,代碼來源:HierarchyFactory.class.php


注:本文中的UserListFactory::getIterator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。