public function btnEdit_Click($strFormId, $strControlId, $strParameter) { $strParameterArray = explode(',', $strParameter); $objModule = Module::Load($strParameterArray[0]); $objEditPanel = new ModuleEditPanel($this, $this->strCloseEditPanelMethod, $objModule); $strMethodName = $this->strSetEditPanelMethod; $this->objForm->{$strMethodName}($objEditPanel); }
protected function SetupModule() { // Lookup Object PK information from Query String (if applicable) // Set mode to Edit or New depending on what's found $intModuleId = QApplication::QueryString('intModuleId'); if ($intModuleId) { $this->objModule = Module::Load($intModuleId); if (!$this->objModule) { throw new Exception('Could not find a Module object with PK arguments: ' . $intModuleId); } $this->strTitleVerb = QApplication::Translate('Edit'); $this->blnEditMode = true; } else { $this->objModule = new Module(); $this->strTitleVerb = QApplication::Translate('Create'); $this->blnEditMode = false; } }
public function __construct($objParentObject, $intEntityQtypeId, $arrControls, $intModuleId, $strPnlName, $blnEditMode, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } //Setup Panel Grid $this->Template = 'FieldLevelAuthPanel.tpl.php'; $this->Display = false; $this->intEntityQtypeId = $intEntityQtypeId; $this->objModule = Module::Load($intModuleId); $this->arrControls = $arrControls; $this->strPnlName = $strPnlName; $this->blnEditMode = $blnEditMode; //First, setup the checkbox of the entity. This checkboxs select/deselect all the checkbox of the entity $this->chkEntity_Create(); // Setup 2 Built In checkbox. One for View Access (chkBuiltInView) and one for the Edit Access(chkBuiltInEdit) $this->chkBuiltIn_Create(); // Setup 2 Checkbox for each CustomField associated to the entity $this->chkCustom_Create(); }
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) */ include 'includes.inc.php'; if (empty($user)) { header("Location:" . CLIENT_BASE_URL . "login.php"); } if (empty($user->default_module)) { if ($user->user_level == "Admin") { $homeLink = HOME_LINK_ADMIN; } else { $homeLink = HOME_LINK_OTHERS; } } else { $defaultModule = new Module(); $defaultModule->Load("id = ?", array($user->default_module)); $homeLink = CLIENT_BASE_URL . "?g=" . $defaultModule->mod_group . "&&n=" . $defaultModule->name . "&m=" . $defaultModule->mod_group . "_" . str_replace(" ", "_", $defaultModule->menu); } //Check Module Permissions $modulePermissions = BaseService::getInstance()->loadModulePermissions($_REQUEST['g'], $_REQUEST['n'], $user->user_level); if (!in_array($user->user_level, $modulePermissions['user'])) { if (!empty($user->user_roles)) { $userRoles = json_decode($user->user_roles, true); } else { $userRoles = array(); } $commonRoles = array_intersect($modulePermissions['user_roles'], $userRoles); if (empty($commonRoles)) { echo "You are not allowed to access this page"; exit; }
public function loadModulePermissions($group, $name, $userLevel) { $module = new Module(); $module->Load("update_path = ?", array($group . ">" . $name)); $arr = array(); $arr['user'] = json_decode($module->user_levels, true); $permission = new Permission(); $modulePerms = $permission->Find("module_id = ? and user_level = ?", array($module->id, $userLevel)); $perms = array(); foreach ($modulePerms as $p) { $perms[$p->permission] = $p->value; } $arr['perm'] = $perms; return $arr; }
public function loadModulePermissions($group, $name, $userLevel) { $module = new Module(); $module->Load("update_path = ?", array($group . ">" . $name)); LogManager::getInstance()->info(" Current Mod :" . json_encode($module)); $arr = array(); $arr['user'] = json_decode($module->user_levels, true); $arr['user_roles'] = !empty($module->user_roles) ? json_decode($module->user_roles, true) : array(); $permission = new Permission(); $modulePerms = $permission->Find("module_id = ? and user_level = ?", array($module->id, $userLevel)); $perms = array(); foreach ($modulePerms as $p) { $perms[$p->permission] = $p->value; } $arr['perm'] = $perms; return $arr; }
/** * Override method to perform a property "Get" * This will get the value of $strName * * @param string $strName Name of the property to get * @return mixed */ public function __get($strName) { switch ($strName) { /////////////////// // Member Variables /////////////////// case 'RoleModuleId': /** * Gets the value for intRoleModuleId (Read-Only PK) * @return integer */ return $this->intRoleModuleId; case 'RoleId': /** * Gets the value for intRoleId (Not Null) * @return integer */ return $this->intRoleId; case 'ModuleId': /** * Gets the value for intModuleId (Not Null) * @return integer */ return $this->intModuleId; case 'AccessFlag': /** * Gets the value for blnAccessFlag (Not Null) * @return boolean */ return $this->blnAccessFlag; case 'CreatedBy': /** * Gets the value for intCreatedBy * @return integer */ return $this->intCreatedBy; case 'CreationDate': /** * Gets the value for dttCreationDate * @return QDateTime */ return $this->dttCreationDate; case 'ModifiedBy': /** * Gets the value for intModifiedBy * @return integer */ return $this->intModifiedBy; case 'ModifiedDate': /** * Gets the value for strModifiedDate (Read-Only Timestamp) * @return string */ return $this->strModifiedDate; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'Role': /** * Gets the value for the Role object referenced by intRoleId (Not Null) * @return Role */ try { if (!$this->objRole && !is_null($this->intRoleId)) { $this->objRole = Role::Load($this->intRoleId); } return $this->objRole; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Module': /** * Gets the value for the Module object referenced by intModuleId (Not Null) * @return Module */ try { if (!$this->objModule && !is_null($this->intModuleId)) { $this->objModule = Module::Load($this->intModuleId); } return $this->objModule; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'CreatedByObject': /** * Gets the value for the UserAccount object referenced by intCreatedBy * @return UserAccount */ try { if (!$this->objCreatedByObject && !is_null($this->intCreatedBy)) { $this->objCreatedByObject = UserAccount::Load($this->intCreatedBy); } return $this->objCreatedByObject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'ModifiedByObject': /** * Gets the value for the UserAccount object referenced by intModifiedBy * @return UserAccount */ try { if (!$this->objModifiedByObject && !is_null($this->intModifiedBy)) { $this->objModifiedByObject = UserAccount::Load($this->intModifiedBy); } return $this->objModifiedByObject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// case '_RoleModuleAuthorization': /** * Gets the value for the private _objRoleModuleAuthorization (Read-Only) * if set due to an expansion on the role_module_authorization.role_module_id reverse relationship * @return RoleModuleAuthorization */ return $this->_objRoleModuleAuthorization; case '_RoleModuleAuthorizationArray': /** * Gets the value for the private _objRoleModuleAuthorizationArray (Read-Only) * if set due to an ExpandAsArray on the role_module_authorization.role_module_id reverse relationship * @return RoleModuleAuthorization[] */ return (array) $this->_objRoleModuleAuthorizationArray; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
protected function lstEdit_Change($strFormId, $strControlId, $strParameter) { $objControl = $this->GetControl($strControlId); // $strParameter is the ModuleId $objModule = Module::Load($strParameter); $objDeleteControl = $this->arrControls[$objModule->ShortDescription]['delete']; if ($objControl->SelectedValue == 3) { if ($objDeleteControl->ItemCount < 3) { $objDeleteControl->AddItem('None', 3); } $objDeleteControl->SelectedValue = 3; $objDeleteControl->Enabled = false; //If we set Edit Access to "None", we must uncheck and disable all Edit Column switch ($objModule->ModuleId) { case 2: if (isset($this->pnlAssets)) { $this->pnlAssets->DisableEditColumn(); $this->pnlAssets->UnCheckEditColumn(); } if (isset($this->pnlAssetModel)) { $this->pnlAssetModel->DisableEditColumn(); $this->pnlAssetModel->UnCheckEditColumn(); } break; case 3: if (isset($this->pnlInventory)) { $this->pnlInventory->DisableEditColumn(); $this->pnlInventory->UnCheckEditColumn(); } break; case 4: if (isset($this->pnlCompany)) { $this->pnlCompany->DisableEditColumn(); $this->pnlCompany->UnCheckEditColumn(); } if (isset($this->pnlContact)) { $this->pnlContact->DisableEditColumn(); $this->pnlContact->UnCheckEditColumn(); } if (isset($this->pnlAddress)) { $this->pnlAddress->DisableEditColumn(); $this->pnlAddress->UnCheckEditColumn(); } break; case 5: if (isset($this->pnlShipping)) { $this->pnlShipping->DisableEditColumn(); $this->pnlShipping->UnCheckEditColumn(); } break; case 6: if (isset($this->pnlReceiving)) { $this->pnlReceiving->DisableEditColumn(); $this->pnlReceiving->UnCheckEditColumn(); } break; } } elseif ($objControl->SelectedValue == 2) { if ($objDeleteControl->ItemCount == 3) { //$objDeleteControl->RemoveItem(2); } $objDeleteControl->Enabled = true; switch ($objModule->ModuleId) { case 2: if (isset($this->pnlAssets)) { $this->pnlAssets->EnableEditColumn(); } if (isset($this->pnlAssetModel)) { $this->pnlAssetModel->EnableEditColumn(); } break; case 3: if (isset($this->pnlInventory)) { $this->pnlInventory->EnableEditColumn(); } break; case 4: if (isset($this->pnlCompany)) { $this->pnlCompany->EnableEditColumn(); } if (isset($this->pnlContact)) { $this->pnlContact->EnableEditColumn(); } if (isset($this->pnlAddress)) { $this->pnlAddress->EnableEditColumn(); } break; case 5: if (isset($this->pnlShipping)) { $this->pnlShipping->EnableEditColumn(); } break; case 6: if (isset($this->pnlReceiving)) { $this->pnlReceiving->EnableEditColumn(); } break; } } elseif ($objControl->SelectedValue == 1) { if ($objDeleteControl->ItemCount == 3) { //$objDeleteControl->RemoveItem(2); } $objDeleteControl->Enabled = true; switch ($objModule->ModuleId) { case 2: if (isset($this->pnlAssets)) { $this->pnlAssets->EnableEditColumn(); } if (isset($this->pnlAssetModel)) { $this->pnlAssetModel->EnableEditColumn(); } break; case 3: if (isset($this->pnlInventory)) { $this->pnlInventory->EnableEditColumn(); } break; case 4: if (isset($this->pnlCompany)) { $this->pnlCompany->EnableEditColumn(); } if (isset($this->pnlContact)) { $this->pnlContact->EnableEditColumn(); } if (isset($this->pnlAddress)) { $this->pnlAddress->EnableEditColumn(); } break; case 5: if (isset($this->pnlShipping)) { $this->pnlShipping->EnableEditColumn(); } break; case 6: if (isset($this->pnlReceiving)) { $this->pnlReceiving->EnableEditColumn(); } break; } } }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this ModuleMetaControl * @param integer $intModuleId primary key value * @param QMetaControlCreateType $intCreateType rules governing Module object creation - defaults to CreateOrEdit * @return ModuleMetaControl */ public static function Create($objParentObject, $intModuleId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intModuleId)) { $objModule = Module::Load($intModuleId); // Module was found -- return it! if ($objModule) { return new ModuleMetaControl($objParentObject, $objModule); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a Module object with PK arguments: ' . $intModuleId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new ModuleMetaControl($objParentObject, new Module()); }
/** * Override method to perform a property "Get" * This will get the value of $strName * * @param string $strName Name of the property to get * @return mixed */ public function __get($strName) { switch ($strName) { /////////////////// // Member Variables /////////////////// case 'ShortcutId': // Gets the value for intShortcutId (Read-Only PK) // @return integer return $this->intShortcutId; case 'ModuleId': // Gets the value for intModuleId (Not Null) // @return integer return $this->intModuleId; case 'AuthorizationId': // Gets the value for intAuthorizationId // @return integer return $this->intAuthorizationId; case 'TransactionTypeId': // Gets the value for intTransactionTypeId // @return integer return $this->intTransactionTypeId; case 'ShortDescription': // Gets the value for strShortDescription (Not Null) // @return string return $this->strShortDescription; case 'Link': // Gets the value for strLink (Not Null) // @return string return $this->strLink; case 'ImagePath': // Gets the value for strImagePath // @return string return $this->strImagePath; case 'EntityQtypeId': // Gets the value for intEntityQtypeId (Not Null) // @return integer return $this->intEntityQtypeId; case 'CreateFlag': // Gets the value for blnCreateFlag (Not Null) // @return boolean return $this->blnCreateFlag; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'Module': // Gets the value for the Module object referenced by intModuleId (Not Null) // @return Module try { if (!$this->objModule && !is_null($this->intModuleId)) { $this->objModule = Module::Load($this->intModuleId); } return $this->objModule; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Authorization': // Gets the value for the Authorization object referenced by intAuthorizationId // @return Authorization try { if (!$this->objAuthorization && !is_null($this->intAuthorizationId)) { $this->objAuthorization = Authorization::Load($this->intAuthorizationId); } return $this->objAuthorization; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'TransactionType': // Gets the value for the TransactionType object referenced by intTransactionTypeId // @return TransactionType try { if (!$this->objTransactionType && !is_null($this->intTransactionTypeId)) { $this->objTransactionType = TransactionType::Load($this->intTransactionTypeId); } return $this->objTransactionType; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// case '__Restored': return $this->__blnRestored; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
/** * Reload this Module from the database. * @return void */ public function Reload() { // Make sure we are actually Restored from the database if (!$this->__blnRestored) { throw new QCallerException('Cannot call Reload() on a new, unsaved Module object.'); } // Reload the Object $objReloaded = Module::Load($this->intModuleId); // Update $this's local variables to match $this->strShortDescription = $objReloaded->strShortDescription; }