Exemple #1
0
 public static function LoadByUserId($intUserId, $objOptionalClauses = null)
 {
     $objUser = NarroUser::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroUser()->UserId, $intUserId)), QQ::ExpandAsArray(QQN::NarroUser()->NarroUserRoleAsUser));
     if (!$objUser instanceof NarroUser) {
         return false;
     }
     foreach ($objUser->_NarroUserRoleAsUserArray as $objRole) {
         /* @var $objRole NarroUserRole */
         $arrRolePermission = NarroRolePermission::LoadArrayByRoleId($objRole->RoleId, QQ::Expand(QQN::NarroRolePermission()->Permission));
         foreach ($arrRolePermission as $objRolePermission) {
             $objUser->arrPermissions[$objRolePermission->Permission->PermissionName . '-' . $objRole->LanguageId . '-' . $objRole->ProjectId] = $objRolePermission;
         }
     }
     if (isset($objUser->Preferences['Language'])) {
         $objLanguage = NarroLanguage::LoadByLanguageCode($objUser->Preferences['Language']);
         if ($objLanguage instanceof NarroLanguage) {
             $objUser->Language = $objLanguage;
         } elseif (QApplication::$TargetLanguage instanceof NarroLanguage) {
             $objUser->Language = QApplication::$TargetLanguage;
         }
     } elseif (QApplication::$TargetLanguage instanceof NarroLanguage) {
         $objUser->Language = QApplication::$TargetLanguage;
     }
     return $objUser;
 }
Exemple #2
0
 /**
  * Gets all associated NarroRolePermissionsAsRole as an array of NarroRolePermission objects
  * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  * @return NarroRolePermission[]
  */
 public function GetNarroRolePermissionAsRoleArray($objOptionalClauses = null)
 {
     if (is_null($this->intRoleId)) {
         return array();
     }
     try {
         return NarroRolePermission::LoadArrayByRoleId($this->intRoleId, $objOptionalClauses);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }