Beispiel #1
0
 protected function UpdateAuthorizations()
 {
     if ($this->objModuleArray) {
         foreach ($this->objModuleArray as $objModule) {
             if ($this->blnEditMode) {
                 $objRoleModule = RoleModule::LoadByRoleIdModuleId($this->objRole->RoleId, $objModule->ModuleId);
             } else {
                 $objRoleModule = new RoleModule();
                 $objRoleModule->ModuleId = $objModule->ModuleId;
                 $objRoleModule->RoleId = $this->objRole->RoleId;
             }
             $objRoleModule->AccessFlag = $this->arrControls[$objModule->ShortDescription]['access']->SelectedValue;
             $objRoleModule->Save();
             if ($this->objAuthorizationArray) {
                 foreach ($this->objAuthorizationArray as $objAuthorization) {
                     if ($this->blnEditMode) {
                         $objRoleModuleAuthorization = $this->objRoleModuleAuthorizationArray[$objRoleModule->RoleModuleId . '-' . $objAuthorization->AuthorizationId];
                     } else {
                         $objRoleModuleAuthorization = new RoleModuleAuthorization();
                         $objRoleModuleAuthorization->RoleModuleId = $objRoleModule->RoleModuleId;
                         $objRoleModuleAuthorization->AuthorizationId = $objAuthorization->AuthorizationId;
                     }
                     $objRoleModuleAuthorization->AuthorizationLevelId = $this->arrControls[$objModule->ShortDescription][$objAuthorization->ShortDescription]->SelectedValue;
                     $objRoleModuleAuthorization->Save();
                 }
             }
         }
     }
     // Home module not implemented yet.  When it is,  uncomment the code below
     //if (!$this->blnEditMode) {
     //	$objRoleModule = new RoleModule();
     //	$objRoleModule->ModuleId = 1;
     //	$objRoleModule->RoleId = $this->objRole->RoleId;
     //	$objRoleModule->AccessFlag = true;
     //	$objRoleModule->Save();
     //}
 }
Beispiel #2
0
 protected function UpdateAuthorizations()
 {
     if ($this->objModuleArray) {
         foreach ($this->objModuleArray as $objModule) {
             if ($this->blnEditMode) {
                 $objRoleModule = RoleModule::LoadByRoleIdModuleId($this->objRole->RoleId, $objModule->ModuleId);
             } else {
                 $objRoleModule = new RoleModule();
                 $objRoleModule->ModuleId = $objModule->ModuleId;
                 $objRoleModule->RoleId = $this->objRole->RoleId;
             }
             $objRoleModule->AccessFlag = $this->arrControls[$objModule->ShortDescription]['access']->SelectedValue;
             $objRoleModule->Save();
             if ($this->objAuthorizationArray) {
                 foreach ($this->objAuthorizationArray as $objAuthorization) {
                     if ($this->blnEditMode) {
                         $objRoleModuleAuthorization = $this->objRoleModuleAuthorizationArray[$objRoleModule->RoleModuleId . '-' . $objAuthorization->AuthorizationId];
                     } else {
                         $objRoleModuleAuthorization = new RoleModuleAuthorization();
                         $objRoleModuleAuthorization->RoleModuleId = $objRoleModule->RoleModuleId;
                         $objRoleModuleAuthorization->AuthorizationId = $objAuthorization->AuthorizationId;
                     }
                     $objRoleModuleAuthorization->AuthorizationLevelId = $this->arrControls[$objModule->ShortDescription][$objAuthorization->ShortDescription]->SelectedValue;
                     $objRoleModuleAuthorization->Save();
                 }
             }
         }
     }
     // If creating a new Role, manually give access to the Home module
     //if (!$this->blnEditMode) {
     //	$objRoleModule = new RoleModule();
     //	$objRoleModule->ModuleId = 1;
     //	$objRoleModule->RoleId = $this->objRole->RoleId;
     //	$objRoleModule->AccessFlag = true;
     //	$objRoleModule->Save();
     /*
     // Give view, edit, and delete access for ALL for the home module
     if ($this->objAuthorizationArray) {
     foreach ($this->objAuthorizationArray as $objAuthorization) {
     $objRoleModuleAuthorization = new RoleModuleAuthorization();
     $objRoleModuleAuthorization->RoleModuleId = $objRoleModule->RoleModuleId;
     $objRoleModuleAuthorization->AuthorizationId = $objAuthorization->AuthorizationId;
     $objRoleModuleAuthorization->AuthorizationLevelId = 3;
     $objRoleModuleAuthorization->Save();
     }
     }
     */
     //}
     /*
     			// Delete all RoleModules - this will cascade to all RoleModuleAuthorizations also
     			if ($this->blnEditMode) {
     			// Set the Role Module Access
     			$objRoleModuleArray = RoleModule::LoadArrayByRoleId($this->objRole->RoleId);
     			if ($objRoleModuleArray) {
     			foreach ($objRoleModuleArray as $objRoleModule) {
     			$objRoleModule->Delete();
     			$objRoleModule = null;
     			}
     			}
     			}
     
     			if ($this->objModuleArray) {
     
     			foreach ($this->objModuleArray as $objModule) {
     				
     			$objRoleModule = new RoleModule();
     			$objRoleModule->ModuleId = $objModule->ModuleId;
     			$objRoleModule->RoleId = $this->objRole->RoleId;
     			$objRoleModule->AccessFlag = $this->arrControls[$objModule->ShortDescription]['access']->SelectedValue;
     			$objRoleModule->Save();
     				
     			if ($this->objAuthorizationArray) {
     			foreach ($this->objAuthorizationArray as $objAuthorization) {
     			$objRoleModuleAuthorization = new RoleModuleAuthorization();
     			$objRoleModuleAuthorization->RoleModuleId = $objRoleModule->RoleModuleId;
     			$objRoleModuleAuthorization->AuthorizationId = $objAuthorization->AuthorizationId;
     			$objRoleModuleAuthorization->AuthorizationLevelId = $this->arrControls[$objModule->ShortDescription][$objAuthorization->ShortDescription]->SelectedValue;
     			$objRoleModuleAuthorization->Save();
     			$objRoleModuleAuthorization = null;
     			}
     			}
     			$objRoleModule = null;
     			}
     			}*/
 }