public function __construct($objParentObject, $strControlId = null) { // First, call the parent to do most of the basic setup try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->objParentObject = $objParentObject; $objExpansionMap[RoleModule::ExpandModule] = true; $this->objRoleModuleArray = RoleModule::LoadArrayByRoleIdAccessFlag(QApplication::$objUserAccount->RoleId, true, null, null, $objExpansionMap); $this->lblSignOut_Create(); $this->lblLogo_Create(); $this->objDefaultWaitIcon_Create(); }
protected function SetupRoleModule() { // Lookup Object PK information from Query String (if applicable) // Set mode to Edit or New depending on what's found $intRoleModuleId = QApplication::QueryString('intRoleModuleId'); if ($intRoleModuleId) { $this->objRoleModule = RoleModule::Load($intRoleModuleId); if (!$this->objRoleModule) { throw new Exception('Could not find a RoleModule object with PK arguments: ' . $intRoleModuleId); } $this->strTitleVerb = QApplication::Translate('Edit'); $this->blnEditMode = true; } else { $this->objRoleModule = new RoleModule(); $this->strTitleVerb = QApplication::Translate('Create'); $this->blnEditMode = false; } }
protected function lstRoleModule_Create() { $this->lstRoleModule = new QListBox($this); $this->lstRoleModule->Name = QApplication::Translate('Role Module'); $this->lstRoleModule->AddItem(QApplication::Translate('- Select One -'), null); $objRoleModuleArray = RoleModule::LoadAll(); if ($objRoleModuleArray) { foreach ($objRoleModuleArray as $objRoleModule) { $objListItem = new QListItem($objRoleModule->__toString(), $objRoleModule->RoleModuleId); if ($this->objRoleModuleAuthorization->RoleModule && $this->objRoleModuleAuthorization->RoleModule->RoleModuleId == $objRoleModule->RoleModuleId) { $objListItem->Selected = true; } $this->lstRoleModule->AddItem($objListItem); } } }
protected function Form_Create() { // check rigths for the Inventory to Ship $this->blnShowInventory = true; $objRoleModule = RoleModule::LoadByRoleIdModuleId(QApplication::$objUserAccount->RoleId, 3); if ($objRoleModule->AccessFlag) { $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId($objRoleModule->RoleModuleId, 2); if ($objRoleModuleAuthorization->AuthorizationLevelId == 3) { $this->blnShowInventory = false; } } else { $this->blnShowInventory = false; } // Call SetupShipment to either Load/Edit Existing or Create New $this->SetupShipment(); $this->objCompanyArray = Company::LoadAll(QQ::Clause(QQ::OrderBy(QQN::Company()->ShortDescription))); // Create the Header Menu $this->ctlHeaderMenu_Create(); // Create the Shortcut Menu $this->ctlShortcutMenu_Create(); // Packing List Link $this->lblPackingListLink_Create(); // Shipping Labels $this->lblShipmentNumber_Create(); $this->lblHeaderShipment_Create(); $this->lblShipDate_Create(); $this->lblFromCompany_Create(); $this->lblFromContact_Create(); $this->lblFromAddress_Create(); $this->lstToCompany_Create(); $this->lblNewToCompany_Create(); $this->lstToContact_Create(); $this->lblNewToContact_Create(); $this->lstToAddress_Create(); $this->lblNewToAddress_Create(); $this->lblFromAddressFull_Create(); $this->lblToCompany_Create(); $this->lblToContact_Create(); $this->lblToAddress_Create(); $this->lblToAddressFull_Create(); $this->lblCourier_Create(); $this->pnlNote_Create(); $this->lblTrackingNumber_Create(); // Shipping Inputs $this->dlgExchange_Create(); $this->dlgDueDate_Create(); $this->calShipDate_Create(); $this->lstFromCompany_Create(); $this->lblNewFromCompany_Create(); $this->lstFromContact_Create(); $this->lblNewFromContact_Create(); $this->lstFromAddress_Create(); $this->lblNewFromAddress_Create(); if (QApplication::$TracmorSettings->CustomShipmentNumbers) { $this->txtShipmentNumber_Create(); } $this->lstCourier_Create(); $this->txtNote_Create(); $this->txtNewAssetCode_Create(); if ($this->blnShowInventory) { $this->txtNewInventoryModelCode_Create(); $this->btnLookup_Create(); $this->ctlInventorySearchTool_Create(); $this->lstSourceLocation_Create(); $this->txtQuantity_Create(); $this->btnAddInventory_Create(); } $this->txtTrackingNumber_Create(); //$this->lblAdvanced_Create(); $this->txtReceiptAssetCode_Create(); $this->chkAutoGenerateAssetCode_Create(); $this->dtpScheduleReceiptDueDate_Create(); $this->rblAssetType_Create(); $this->chkScheduleReceipt_Create(); $this->btnAddAsset_Create(); $this->ctlAssetSearchTool_Create(); $this->btnSaveExchange_Create(); $this->btnCancelExchange_Create(); $this->btnSaveDueDate_Create(); $this->btnCancelDueDate_Create(); $this->pnlAttachments_Create(); // Create all custom asset fields $this->customFields_Create(); //Set display logic of Built-In Fields $this->UpdateBuiltInFields(); $this->UpdateAddressAccess(); $this->UpdateCompanyAccess(); $this->UpdateContactAccess(); // New entities Dialog $this->dlgNew_Create(); if (!$this->objShipment->ShippedFlag) { // Shipping Buttons $this->btnDelete_Create(); } $this->btnSave_Create(); $this->btnCancel_Create(); $this->btnEdit_Create(); $this->atcAttach_Create(); // Complete Shipment Buttons $this->btnCompleteShipment_Create(); $this->btnCancelShipment_Create(); $this->btnCancelCompleteShipment_Create(); // Shipping Datagrids $this->dtgAssetTransact_Create(); $this->dtgInventoryTransact_Create(); // Load the objAssetTransactionArray and objInventoryTransactionArray for the first time if ($this->blnEditMode) { $objClauses = array(); if ($objClause = $this->dtgAssetTransact->OrderByClause) { array_push($objClauses, $objClause); } /*if ($objClause = $this->dtgAssetTransact->LimitClause) array_push($objClauses, $objClause);*/ if ($objClause = QQ::Expand(QQN::AssetTransaction()->Asset->AssetModel)) { array_push($objClauses, $objClause); } if ($objClause = QQ::Expand(QQN::AssetTransaction()->SourceLocation)) { } array_push($objClauses, $objClause); $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objShipment->TransactionId, $objClauses); $objClauses = null; $objClauses = array(); if ($objClause = $this->dtgInventoryTransact->OrderByClause) { array_push($objClauses, $objClause); } /*if ($objClause = $this->dtgInventoryTransact->LimitClause) array_push($objClauses, $objClause);*/ if ($objClause = QQ::Expand(QQN::InventoryTransaction()->InventoryLocation->InventoryModel)) { } array_push($objClauses, $objClause); $this->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->objShipment->TransactionId, $objClauses); // If shipped, display labels. Otherwise, we don't need to call DisplayLabels because only labels are on the QPanel. $this->DisplayLabels(); } elseif (!$this->blnEditMode) { $this->DisplayInputs(); } // Check if there is an Asset or InventoryModel ID in the query string to automatically add them - they would be coming from AssetEdit or InventoryEdit if (!$this->blnEditMode) { $intAssetId = QApplication::QueryString('intAssetId'); // If an Asset was passed in the query string, load the txt in the Asset Tag text box and click the add button if ($intAssetId) { $objAsset = Asset::Load($intAssetId); if ($objAsset) { $this->txtNewAssetCode->Text = $objAsset->AssetCode; $this->btnAddAsset_Click($this, null, null); } } $intInventoryModelId = QApplication::QueryString('intInventoryModelId'); // If an InventoryModel was passed in the query string, load the text in the InventoryModel text box and set the focus to the quantity box if ($intInventoryModelId) { $objInventoryModel = InventoryModel::Load($intInventoryModelId); if ($objInventoryModel) { $this->txtNewInventoryModelCode->Text = $objInventoryModel->InventoryModelCode; $this->btnLookup_Click($this, null, null); QApplication::ExecuteJavaScript(sprintf("document.getElementById('%s').focus()", $this->lstSourceLocation->ControlId)); } } } }
/** * Counts all associated RoleModules * @return int */ public function CountRoleModules() { if (is_null($this->intRoleId)) { return 0; } return RoleModule::CountByRoleId($this->intRoleId); }
protected function dtgRoleModule_Bind() { // Because we want to enable pagination AND sorting, we need to setup the $objClauses array to send to LoadAll() // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below $this->dtgRoleModule->TotalItemCount = RoleModule::CountAll(); // Setup the $objClauses Array $objClauses = array(); // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->dtgRoleModule->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgRoleModule->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be the array of all RoleModule objects, given the clauses above $this->dtgRoleModule->DataSource = RoleModule::LoadAll($objClauses); }
/** * Authorizes any control to determine if the user has access * If not, it sets the objControl->Visible to false * * @param object $objEntity - any entity with a created_by column (asset, location, etc.) * @param object $objControl - the control which is being evaluated - any QControl where visible is a property * @param integer $intAuthorizationId - the authorization required to see this control (view(1), edit(2), or delete(3)) */ public static function AuthorizeControl($objEntity, $objControl, $intAuthorizationId, $intModuleId = null) { if ($intModuleId == null) { $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId(QApplication::$objRoleModule->RoleModuleId, $intAuthorizationId); } else { $objRoleModule = RoleModule::LoadByRoleIdModuleId(QApplication::$objRoleModule->RoleId, $intModuleId); $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId($objRoleModule->RoleModuleId, $intAuthorizationId); } // Added if $objEntity == null for the ship button shortcut on the asset page. if ($objRoleModuleAuthorization->AuthorizationLevelId == 1 || $objRoleModuleAuthorization->AuthorizationLevelId == 2 && $objEntity == null || $objRoleModuleAuthorization->AuthorizationLevelId == 2 && $objEntity->CreatedBy == QApplication::$objUserAccount->UserAccountId) { $objControl->Visible = true; } else { $objControl->Visible = false; } }
protected function btnLogin_Click($strFormId, $strControlId, $strParameter) { if ($_SERVER['REMOTE_ADDR'] != "127.0.0.1" && substr($_SERVER['REMOTE_ADDR'], 0, 8) != "192.168.") { $ip_array = json_decode(file_get_contents("http://192.168.1.168:8888/eBayBO/service.php?action=getClientIp")); //file_put_contents("/tmp/xx.log", print_r($ip_array, true)); if (!in_array($_SERVER['REMOTE_ADDR'], $ip_array)) { $blnError = true; $this->txtUsername->Warning = QApplication::Translate('Invalid username or password.'); return 0; } } $blnError = false; $strUsername = $this->txtUsername->Text; $strPassword = $this->txtPassword->Text; $objUserAccount = UserAccount::LoadByUsername($strUsername); $errorMessage = QApplication::Translate('Invalid username or password.'); // Check if that username exists if (!$objUserAccount) { $blnError = true; $this->txtUsername->Warning = $errorMessage; } elseif (!$objUserAccount->ActiveFlag) { $blnError = true; $this->txtUsername->Warning = $errorMessage; } elseif (sha1($strPassword) != $objUserAccount->PasswordHash) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } else { QApplication::Login($objUserAccount); // If the user has access to the assets module, send them there. Otherwise, send them to the home module. $objRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 2); if ($objRoleModule->AccessFlag) { QApplication::Redirect('./inventory/'); } else { Qapplication::Redirect('./home/'); } } }
/** * Main utility method to aid with data binding. It is used by the default BindAllRows() databinder but * could and should be used by any custom databind methods that would be used for instances of this * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). * * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query * @return void */ public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null) { // Setup input parameters to default values if none passed in if (!$objCondition) { $objCondition = QQ::All(); } $objClauses = $objOptionalClauses ? $objOptionalClauses : array(); // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = RoleModule::QueryCount($objCondition, $objClauses); } // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from RoleModule, given the clauses above $this->DataSource = RoleModule::QueryArray($objCondition, $objClauses); }
protected function btnLogin_Click($strFormId, $strControlId, $strParameter) { $blnError = false; $strUsername = $this->txtUsername->Text; $strPassword = $this->txtPassword->Text; $objUserAccount = UserAccount::LoadByUsername($strUsername); $errorMessage = 'Invalid username or password.'; $objHasher = new PasswordHash(8, PORTABLE_PASSWORDS); // Check if that username exists if (!$objUserAccount) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } elseif (!$objUserAccount->ActiveFlag) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } elseif (!$objHasher->CheckPassword(sha1($strPassword), $objUserAccount->PasswordHash)) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } else { QApplication::Login($objUserAccount); $objAssetRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 2); $objInventoryRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 3); $objContactsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 4); $objShippingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 5); $objReceivingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 6); $objReportsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 7); if (array_key_exists('strReferer', $_GET)) { QApplication::Redirect($_GET['strReferer']); } else { if ($objAssetRoleModule->AccessFlag) { // If the user has access to the assets module, send them there, otherwise... QApplication::Redirect('./assets/'); } else { if ($objInventoryRoleModule->AccessFlag) { Qapplication::Redirect('./inventory/'); } else { if ($objContactsRoleModule->AccessFlag) { Qapplication::Redirect('./contacts/'); } else { if ($objShippingRoleModule->AccessFlag) { Qapplication::Redirect('./shipping/'); } else { if ($objReceivingRoleModule->AccessFlag) { Qapplication::Redirect('./receiving/'); } else { if ($objReportsRoleModule->AccessFlag) { Qapplication::Redirect('./reports/'); } } } } } } } } }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objRoleModule) { $objObject->objRoleModule = RoleModule::GetSoapObjectFromObject($objObject->objRoleModule, false); } else { if (!$blnBindRelatedObjects) { $objObject->intRoleModuleId = null; } } if ($objObject->objAuthorization) { $objObject->objAuthorization = Authorization::GetSoapObjectFromObject($objObject->objAuthorization, false); } else { if (!$blnBindRelatedObjects) { $objObject->intAuthorizationId = null; } } if ($objObject->objAuthorizationLevel) { $objObject->objAuthorizationLevel = AuthorizationLevel::GetSoapObjectFromObject($objObject->objAuthorizationLevel, false); } else { if (!$blnBindRelatedObjects) { $objObject->intAuthorizationLevelId = null; } } if ($objObject->objCreatedByObject) { $objObject->objCreatedByObject = UserAccount::GetSoapObjectFromObject($objObject->objCreatedByObject, false); } else { if (!$blnBindRelatedObjects) { $objObject->intCreatedBy = null; } } if ($objObject->dttCreationDate) { $objObject->dttCreationDate = $objObject->dttCreationDate->__toString(QDateTime::FormatSoap); } if ($objObject->objModifiedByObject) { $objObject->objModifiedByObject = UserAccount::GetSoapObjectFromObject($objObject->objModifiedByObject, false); } else { if (!$blnBindRelatedObjects) { $objObject->intModifiedBy = null; } } return $objObject; }
/** * 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 RoleModuleMetaControl * @param integer $intRoleModuleId primary key value * @param QMetaControlCreateType $intCreateType rules governing RoleModule object creation - defaults to CreateOrEdit * @return RoleModuleMetaControl */ public static function Create($objParentObject, $intRoleModuleId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intRoleModuleId)) { $objRoleModule = RoleModule::Load($intRoleModuleId); // RoleModule was found -- return it! if ($objRoleModule) { return new RoleModuleMetaControl($objParentObject, $objRoleModule); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a RoleModule object with PK arguments: ' . $intRoleModuleId); } } // 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 RoleModuleMetaControl($objParentObject, new RoleModule()); }
/** * Internally called method to assist with early binding of objects * on load methods. Can only early-bind references that this class owns in the database. * @param string $strParentAlias the alias of the parent (if any) * @param string $strAlias the alias of this object * @param array $objExpansionMap map of referenced columns to be immediately expanded via early-binding * @param QueryExpansion an already instantiated QueryExpansion object (used as a utility object to assist with object expansion) */ public static function ExpandQuery($strParentAlias, $strAlias, $objExpansionMap, QQueryExpansion $objQueryExpansion) { if ($strAlias) { $objQueryExpansion->AddFromItem(sprintf('LEFT JOIN `role_module_authorization` AS `%s__%s` ON `%s`.`%s` = `%s__%s`.`role_module_authorization_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`role_module_authorization_id` AS `%s__%s__role_module_authorization_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`role_module_id` AS `%s__%s__role_module_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`authorization_id` AS `%s__%s__authorization_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`authorization_level_id` AS `%s__%s__authorization_level_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`created_by` AS `%s__%s__created_by`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`creation_date` AS `%s__%s__creation_date`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`modified_by` AS `%s__%s__modified_by`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`modified_date` AS `%s__%s__modified_date`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $strParentAlias = $strParentAlias . '__' . $strAlias; } if (is_array($objExpansionMap)) { foreach ($objExpansionMap as $strKey => $objValue) { switch ($strKey) { case 'role_module_id': try { RoleModule::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'authorization_id': try { Authorization::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'authorization_level_id': try { AuthorizationLevel::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'created_by': try { UserAccount::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'modified_by': try { UserAccount::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } default: throw new QCallerException(sprintf('Unknown Object to Expand in %s: %s', $strParentAlias, $strKey)); } } } }
/** * Counts all associated RoleModulesAsCreatedBy * @return int */ public function CountRoleModulesAsCreatedBy() { if (is_null($this->intUserAccountId)) { return 0; } return RoleModule::CountByCreatedBy($this->intUserAccountId); }
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(); //} }
public function dtgRoleModule_Bind() { // Get Total Count b/c of Pagination $this->dtgRoleModule->TotalItemCount = RoleModule::CountAll(); $objClauses = array(); if ($objClause = $this->dtgRoleModule->OrderByClause) { array_push($objClauses, $objClause); } if ($objClause = $this->dtgRoleModule->LimitClause) { array_push($objClauses, $objClause); } $this->dtgRoleModule->DataSource = RoleModule::LoadAll($objClauses); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, RoleModule::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * Load an array of RoleModule objects, based on the RoleId and Access Flag * @param int intRoleId * @param bit blnAccessFlag * @param string $strOrderBy * @param string $strLimit * @param array $objExpansionMap map of referenced columns to be immediately expanded via early-binding * @return RoleModule[] */ public static function LoadArrayByRoleIdAccessFlag($intRoleId, $blnAccessFlag, $strOrderBy = null, $strLimit = null, $objExpansionMap = null) { // Call to ArrayQueryHelper to Get Database Object and Get SQL Clauses RoleModule::ArrayQueryHelper($strOrderBy, $strLimit, $strLimitPrefix, $strLimitSuffix, $strExpandSelect, $strExpandFrom, $objExpansionMap, $objDatabase); // Properly Escape All Input Parameters using Database->SqlVariable() $intRoleId = $objDatabase->SqlVariable($intRoleId); $blnAccessFlag = $objDatabase->SqlVariable($blnAccessFlag); // Setup the SQL Query $strQuery = sprintf(' SELECT %s `role_module`.* %s FROM `role_module` AS `role_module` %s WHERE `role_module`.`role_id` = %s AND `role_module`.`access_flag` = %s %s %s', $strLimitPrefix, $strExpandSelect, $strExpandFrom, $intRoleId, $blnAccessFlag, $strOrderBy, $strLimitSuffix); // Perform the Query and Instantiate the Result $objDbResult = $objDatabase->Query($strQuery); return RoleModule::InstantiateDbResult($objDbResult); }
/** * Refresh this MetaControl with Data from the local RoleModuleAuthorization object. * @param boolean $blnReload reload RoleModuleAuthorization from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objRoleModuleAuthorization->Reload(); } if ($this->lblRoleModuleAuthorizationId) { if ($this->blnEditMode) { $this->lblRoleModuleAuthorizationId->Text = $this->objRoleModuleAuthorization->RoleModuleAuthorizationId; } } if ($this->lstRoleModule) { $this->lstRoleModule->RemoveAllItems(); $this->lstRoleModule->AddItem(QApplication::Translate('- Select One -'), null); $objRoleModuleArray = RoleModule::LoadAll(); if ($objRoleModuleArray) { foreach ($objRoleModuleArray as $objRoleModule) { $objListItem = new QListItem($objRoleModule->__toString(), $objRoleModule->RoleModuleId); if ($this->objRoleModuleAuthorization->RoleModule && $this->objRoleModuleAuthorization->RoleModule->RoleModuleId == $objRoleModule->RoleModuleId) { $objListItem->Selected = true; } $this->lstRoleModule->AddItem($objListItem); } } } if ($this->lblRoleModuleId) { $this->lblRoleModuleId->Text = $this->objRoleModuleAuthorization->RoleModule ? $this->objRoleModuleAuthorization->RoleModule->__toString() : null; } if ($this->lstAuthorization) { $this->lstAuthorization->RemoveAllItems(); $this->lstAuthorization->AddItem(QApplication::Translate('- Select One -'), null); $objAuthorizationArray = Authorization::LoadAll(); if ($objAuthorizationArray) { foreach ($objAuthorizationArray as $objAuthorization) { $objListItem = new QListItem($objAuthorization->__toString(), $objAuthorization->AuthorizationId); if ($this->objRoleModuleAuthorization->Authorization && $this->objRoleModuleAuthorization->Authorization->AuthorizationId == $objAuthorization->AuthorizationId) { $objListItem->Selected = true; } $this->lstAuthorization->AddItem($objListItem); } } } if ($this->lblAuthorizationId) { $this->lblAuthorizationId->Text = $this->objRoleModuleAuthorization->Authorization ? $this->objRoleModuleAuthorization->Authorization->__toString() : null; } if ($this->lstAuthorizationLevel) { $this->lstAuthorizationLevel->RemoveAllItems(); $this->lstAuthorizationLevel->AddItem(QApplication::Translate('- Select One -'), null); $objAuthorizationLevelArray = AuthorizationLevel::LoadAll(); if ($objAuthorizationLevelArray) { foreach ($objAuthorizationLevelArray as $objAuthorizationLevel) { $objListItem = new QListItem($objAuthorizationLevel->__toString(), $objAuthorizationLevel->AuthorizationLevelId); if ($this->objRoleModuleAuthorization->AuthorizationLevel && $this->objRoleModuleAuthorization->AuthorizationLevel->AuthorizationLevelId == $objAuthorizationLevel->AuthorizationLevelId) { $objListItem->Selected = true; } $this->lstAuthorizationLevel->AddItem($objListItem); } } } if ($this->lblAuthorizationLevelId) { $this->lblAuthorizationLevelId->Text = $this->objRoleModuleAuthorization->AuthorizationLevel ? $this->objRoleModuleAuthorization->AuthorizationLevel->__toString() : null; } if ($this->lstCreatedByObject) { $this->lstCreatedByObject->RemoveAllItems(); $this->lstCreatedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objCreatedByObjectArray = UserAccount::LoadAll(); if ($objCreatedByObjectArray) { foreach ($objCreatedByObjectArray as $objCreatedByObject) { $objListItem = new QListItem($objCreatedByObject->__toString(), $objCreatedByObject->UserAccountId); if ($this->objRoleModuleAuthorization->CreatedByObject && $this->objRoleModuleAuthorization->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstCreatedByObject->AddItem($objListItem); } } } if ($this->lblCreatedBy) { $this->lblCreatedBy->Text = $this->objRoleModuleAuthorization->CreatedByObject ? $this->objRoleModuleAuthorization->CreatedByObject->__toString() : null; } if ($this->calCreationDate) { $this->calCreationDate->DateTime = $this->objRoleModuleAuthorization->CreationDate; } if ($this->lblCreationDate) { $this->lblCreationDate->Text = sprintf($this->objRoleModuleAuthorization->CreationDate) ? $this->objRoleModuleAuthorization->__toString($this->strCreationDateDateTimeFormat) : null; } if ($this->lstModifiedByObject) { $this->lstModifiedByObject->RemoveAllItems(); $this->lstModifiedByObject->AddItem(QApplication::Translate('- Select One -'), null); $objModifiedByObjectArray = UserAccount::LoadAll(); if ($objModifiedByObjectArray) { foreach ($objModifiedByObjectArray as $objModifiedByObject) { $objListItem = new QListItem($objModifiedByObject->__toString(), $objModifiedByObject->UserAccountId); if ($this->objRoleModuleAuthorization->ModifiedByObject && $this->objRoleModuleAuthorization->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) { $objListItem->Selected = true; } $this->lstModifiedByObject->AddItem($objListItem); } } } if ($this->lblModifiedBy) { $this->lblModifiedBy->Text = $this->objRoleModuleAuthorization->ModifiedByObject ? $this->objRoleModuleAuthorization->ModifiedByObject->__toString() : null; } if ($this->lblModifiedDate) { if ($this->blnEditMode) { $this->lblModifiedDate->Text = $this->objRoleModuleAuthorization->ModifiedDate; } } }
protected function btnLogin_Click($strFormId, $strControlId, $strParameter) { $blnError = false; $strUsername = $this->txtUsername->Text; $strPassword = $this->txtPassword->Text; $objUserAccount = UserAccount::LoadByUsername($strUsername); $errorMessage = 'Invalid username or password.'; // Check if that username exists if (!$objUserAccount) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } elseif (!$objUserAccount->ActiveFlag) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } elseif (!QApplication::CheckPassword(sha1($strPassword), $objUserAccount->PasswordHash)) { $blnError = true; $this->txtPassword->Warning = $errorMessage; } else { QApplication::Login($objUserAccount); $objAssetRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 2); $objInventoryRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 3); $objContactsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 4); $objShippingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 5); $objReceivingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 6); $objReportsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 7); $strRedirect = ''; $intModule = null; if (array_key_exists('strReferer', $_GET)) { $strRedirect = $_GET['strReferer']; } else { if ($objAssetRoleModule->AccessFlag) { // If the user has access to the assets module, send them there, otherwise... $strRedirect = __SUBDIRECTORY__ . '/assets/'; $intModule = 2; } else { if ($objInventoryRoleModule->AccessFlag) { $strRedirect = __SUBDIRECTORY__ . '/inventory/'; $intModule = 3; } else { if ($objContactsRoleModule->AccessFlag) { $strRedirect = __SUBDIRECTORY__ . '/contacts/'; $intModule = 4; } else { if ($objShippingRoleModule->AccessFlag) { $strRedirect = __SUBDIRECTORY__ . '/shipping/'; $intModule = 5; } else { if ($objReceivingRoleModule->AccessFlag) { $strRedirect = __SUBDIRECTORY__ . '/receiving/'; $intModule = 6; } else { if ($objReportsRoleModule->AccessFlag) { $strRedirect = __SUBDIRECTORY__ . '/reports/'; $intModule = 7; } } } } } } } QApplication::Redirect($strRedirect); } }
/** * Deletes all associated RoleModules * @return void */ public function DeleteAllRoleModules() { if (is_null($this->intRoleId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateRoleModule on this unsaved Role.'); } // Get the Database Object for this Class $objDatabase = Role::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (RoleModule::LoadArrayByRoleId($this->intRoleId) as $objRoleModule) { $objRoleModule->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `role_module` WHERE `role_id` = ' . $objDatabase->SqlVariable($this->intRoleId) . ' '); }
/** * @return \yii\db\ActiveQuery */ public function getRoleModules() { return $this->hasMany(RoleModule::className(), ['hak_akses' => 'id']); }
protected function Form_Create() { // check rigths for the Inventory to Ship $this->blnShowInventory = true; $objRoleModule = RoleModule::LoadByRoleIdModuleId(QApplication::$objUserAccount->RoleId, 3); if ($objRoleModule->AccessFlag) { $objRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId($objRoleModule->RoleModuleId, 2); if ($objRoleModuleAuthorization->AuthorizationLevelId == 3) { $this->blnShowInventory = false; } } else { $this->blnShowInventory = false; } // Call Setup Receipt to either load existing or create new receipt $this->SetupReceipt(); // Create the Header Menu $this->ctlHeaderMenu_Create(); // Create the Shortcut Menu $this->ctlShortcutMenu_Create(); // Create the labels $this->lblHeaderReceipt_Create(); $this->lblFromCompany_Create(); $this->lblFromContact_Create(); $this->lblToContact_Create(); $this->lblToAddress_Create(); $this->lblReceiptNumber_Create(); $this->pnlNote_Create(); $this->lblDueDate_Create(); $this->lblReceiptDate_Create(); // Create the inputs $this->lstFromCompany_Create(); $this->lblNewFromCompany_Create(); $this->lstFromContact_Create(); $this->lblNewFromContact_Create(); $this->lstToContact_Create(); $this->lblNewToContact_Create(); $this->lstToAddress_Create(); $this->lblNewToAddress_Create(); $this->txtNote_Create(); // Create all custom asset fields - this must be here for tab ordering $this->customFields_Create(); if ($this->blnShowInventory) { $this->txtNewInventoryModelCode_Create(); $this->ctlInventorySearchTool_Create(); $this->txtQuantity_Create(); $this->btnAddInventory_Create(); } $this->txtNewAssetCode_Create(); $this->rblAssetType_Create(); $this->lstAssetModel_Create(); $this->chkAutoGenerateAssetCode_Create(); $this->calDueDate_Create(); $this->calDateReceived_Create(); if (QApplication::$TracmorSettings->CustomReceiptNumbers) { $this->txtReceiptNumber_Create(); } // Create the buttons $this->btnSave_Create(); $this->btnEdit_Create(); $this->btnCancel_Create(); $this->btnDelete_Create(); $this->atcAttach_Create(); $this->pnlAttachments_Create(); $this->btnAddAsset_Create(); $this->ctlAssetSearchTool_Create(); //Set display logic of Built-In Fields $this->UpdateBuiltInFields(); // Set display logic of certain Entities $this->UpdateAddressAccess(); $this->UpdateCompanyAccess(); $this->UpdateContactAccess(); // Check prerequisites for scheduling receipts $this->CheckPrerequisites(); // Create the datagrids $this->dtgAssetTransact_Create(); $this->dtgInventoryTransact_Create(); // New entities Dialog $this->dlgNew_Create(); // Load the objAssetTransactionArray and objInventoryTransactionArray for the first time if ($this->blnEditMode) { $objClauses = array(); if ($objClause = $this->dtgAssetTransact->OrderByClause) { array_push($objClauses, $objClause); } /*if ($objClause = $this->dtgAssetTransact->LimitClause) array_push($objClauses, $objClause);*/ if ($objClause = QQ::Expand(QQN::AssetTransaction()->Asset->AssetModel)) { array_push($objClauses, $objClause); } $this->objAssetTransactionArray = AssetTransaction::LoadArrayByTransactionId($this->objReceipt->TransactionId, $objClauses); $objClauses = null; $objClauses = array(); if ($objClause = $this->dtgInventoryTransact->OrderByClause) { array_push($objClauses, $objClause); } /*if ($objClause = $this->dtgInventoryTransact->LimitClause) array_push($objClauses, $objClause);*/ if ($objClause = QQ::Expand(QQN::InventoryTransaction()->InventoryLocation->InventoryModel)) { } array_push($objClauses, $objClause); $this->objInventoryTransactionArray = InventoryTransaction::LoadArrayByTransactionId($this->objReceipt->TransactionId, $objClauses); $this->DisplayLabels(); } elseif (!$this->blnEditMode) { $this->DisplayInputs(); } // Check if there is an Asset or InventoryModel ID in the query string to automatically add them - they would be coming from AssetEdit or InventoryEdit if (!$this->blnEditMode) { $intAssetId = QApplication::QueryString('intAssetId'); // If an Asset was passed in the query string, load the txt in the Asset Code text box and click the add button if ($intAssetId) { $objAsset = Asset::Load($intAssetId); if ($objAsset) { $this->txtNewAssetCode->Text = $objAsset->AssetCode; $this->btnAddAsset_Click($this, null, null); } } $intInventoryModelId = QApplication::QueryString('intInventoryModelId'); // If an InventoryModel was passed in the query string, load the text in the InventoryModel text box and set the focus to the quantity box if ($intInventoryModelId) { $objInventoryModel = InventoryModel::Load($intInventoryModelId); if ($objInventoryModel) { $this->txtNewInventoryModelCode->Text = $objInventoryModel->InventoryModelCode; $this->txtQuantity->Focus(); } } } }
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; } }*/ }