public function __construct($objParentObject, $intEntityQtypeId = null, $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; $this->intEntityQtypeId = $intEntityQtypeId; $this->chkEntityView = new QCheckBox($this); $this->chkEntityEdit = new QCheckBox($this); $this->chkBuiltInView = new QCheckBox($this); $this->chkBuiltInView->Enabled = false; $this->chkBuiltInView->Checked = true; $intRoleId = QApplication::QueryString('intRoleId'); if ($intRoleId) { $objBuiltInViewAuth = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($intRoleId, $intEntityQtypeId, 1); } if (isset($objBuiltInViewAuth)) { $this->chkBuiltInView->Checked = $objBuiltInViewAuth->AuthorizedFlag; } $this->chkBuiltInEdit = new QCheckBox($this); if ($intRoleId) { $objBuiltInEditAuth = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($intRoleId, $intEntityQtypeId, 2); } if (isset($objBuiltInEditAuth)) { $this->chkBuiltInEdit->Checked = $objBuiltInEditAuth->AuthorizedFlag; } // Load all custom fields and their values into an array arrCustomChecks $objCustomFieldArray = CustomField::LoadObjCustomFieldArray($intEntityQtypeId, false, null); foreach ($objCustomFieldArray as $objCustomField) { $chkCustomView = new QCheckBox($this); $chkCustomEdit = new QCheckBox($this); $objEntityQtypeCustomField = EntityQtypeCustomField::LoadByEntityQtypeIdCustomFieldId($intEntityQtypeId, $objCustomField->CustomFieldId); if ($objEntityQtypeCustomField) { $objCustomAuthView = RoleEntityQtypeCustomFieldAuthorization::LoadByRoleIdEntityQtypeCustomFieldIdAuthorizationId($intRoleId, $objEntityQtypeCustomField->EntityQtypeCustomFieldId, 1); if ($objCustomAuthView) { $chkCustomView->Checked = $objCustomAuthView->AuthorizedFlag; } $objCustomAuthEdit = RoleEntityQtypeCustomFieldAuthorization::LoadByRoleIdEntityQtypeCustomFieldIdAuthorizationId($intRoleId, $objEntityQtypeCustomField->EntityQtypeCustomFieldId, 2); if ($objCustomAuthEdit) { $chkCustomEdit->Checked = $objCustomAuthEdit->AuthorizedFlag; } } $this->arrCustomChecks[] = array('name' => $objCustomField->ShortDescription . ':', 'view' => $chkCustomView, 'edit' => $chkCustomEdit); } }
protected function SetupRoleEntityQtypeBuiltInAuthorization() { // Lookup Object PK information from Query String (if applicable) // Set mode to Edit or New depending on what's found $intRoleEntityBuiltInId = QApplication::QueryString('intRoleEntityBuiltInId'); if ($intRoleEntityBuiltInId) { $this->objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::Load($intRoleEntityBuiltInId); if (!$this->objRoleEntityQtypeBuiltInAuthorization) { throw new Exception('Could not find a RoleEntityQtypeBuiltInAuthorization object with PK arguments: ' . $intRoleEntityBuiltInId); } $this->strTitleVerb = QApplication::Translate('Edit'); $this->blnEditMode = true; } else { $this->objRoleEntityQtypeBuiltInAuthorization = new RoleEntityQtypeBuiltInAuthorization(); $this->strTitleVerb = QApplication::Translate('Create'); $this->blnEditMode = false; } }
public function __construct($objParentObject, $strClosePanelMethod, $arrayModelId) { try { parent::__construct($objParentObject, $strClosePanelMethod); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->arrModelsToEdit = $arrayModelId; //Set Edit Display Logic of Built-In Fields $objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId(QApplication::$objRoleModule->RoleId, 4, 2); if ($objRoleEntityQtypeBuiltInAuthorization && $objRoleEntityQtypeBuiltInAuthorization->AuthorizedFlag) { $this->blnEditBuiltInFields = true; } else { $this->blnEditBuiltInFields = false; } $this->txtLongDescription->Enabled = false; // Create Asset Custom Fields $this->UpdateCustomFields(); // Create Checkboxes $this->chkCategory_Create(); $this->chkManufacturer_Create(); $this->chkLongDescription_Create(); $this->btnApply_Create(); // Load Custom Fields $objCustomFieldArray = CustomField::LoadObjCustomFieldArray(EntityQtype::AssetModel, false); if ($objCustomFieldArray) { $this->arrCustomFields = CustomField::CustomFieldControlsCreate($objCustomFieldArray, false, $this, true, true, false); foreach ($this->arrCustomFields as $field) { $field['input']->Enabled = false; $this->arrCheckboxes[$field['input']->strControlId] = new QCheckBox($this, 'chk' . $field['input']->strControlId); $this->arrCheckboxes[$field['input']->strControlId]->Checked = false; $this->arrCheckboxes[$field['input']->strControlId]->AddAction(new QClickEvent(), new QJavaScriptAction("enableInput(this)")); $this->arrCheckboxes[$field['input']->strControlId]->Enabled = $field['blnEdit']; } } $this->btnSave->CausesValidation = QCausesValidation::SiblingsOnly; $this->Overflow = QOverflow::Auto; // Modify Code Generated Controls // $this->btnSave->RemoveAllActions('onclick'); //$this->btnSave->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnSave_Click')); }
protected function chkBuiltIn_Create() { $this->chkBuiltInView = new QCheckBox($this); //because many built-in fields must be visible to navigate within Tracmor //the View privilege for built-in fields will always be set as enabled for //entities within modules which a user role has module-level access to //The View privilege is checked and unchecked automatically, acording to the module-level-access $this->chkBuiltInView->Enabled = false; $this->chkBuiltInView->Checked = true; $intRoleId = QApplication::QueryString('intRoleId'); $this->chkBuiltInEdit = new QCheckBox($this); // If $intRoleId is set, then it is Edit Mode, so we load the EditPrivilege of BuiltIn Fields if ($intRoleId) { $objBuiltInEditAuth = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($intRoleId, $this->intEntityQtypeId, 2); } //If Creation Mode, the Edit Privilege of the BuiltIn Fields is checked by default if (!$this->blnEditMode) { $this->chkBuiltInEdit->Checked = 1; } elseif (isset($objBuiltInEditAuth)) { $this->chkBuiltInEdit->Checked = $objBuiltInEditAuth->AuthorizedFlag; } }
public function __construct($objParentObject, $strClosePanelMethod, $arrayInventoryId) { try { parent::__construct($objParentObject); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->arrInventoryToEdit = $arrayInventoryId; //Set Edit Display Logic of Built-In Fields $objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId(QApplication::$objRoleModule->RoleId, EntityQtype::Inventory, 2); if ($objRoleEntityQtypeBuiltInAuthorization && $objRoleEntityQtypeBuiltInAuthorization->AuthorizedFlag) { $this->blnEditBuiltInFields = true; } else { $this->blnEditBuiltInFields = false; } $this->txtLongDescription_Create(); $this->lstCategory_Create(); $this->lstManufacturer_Create(); $this->chkCategory_Create(); $this->chkManufacturer_Create(); $this->chkLongDescription_Create(); $this->btnApply_Create(); $this->btnCancel_Create(); // Load Custom Fields $objCustomFieldArray = CustomField::LoadObjCustomFieldArray(2, false); if ($objCustomFieldArray) { $this->arrCustomFields = CustomField::CustomFieldControlsCreate($objCustomFieldArray, false, $this, true, true, false); foreach ($this->arrCustomFields as $field) { $field['input']->Enabled = false; $this->arrCheckboxes[$field['input']->strControlId] = new QCheckBox($this, 'chk' . $field['input']->strControlId); $this->arrCheckboxes[$field['input']->strControlId]->Checked = false; $this->arrCheckboxes[$field['input']->strControlId]->AddAction(new QClickEvent(), new QJavaScriptAction("enableInput(this)")); $this->arrCheckboxes[$field['input']->strControlId]->Enabled = $field['blnEdit']; } } }
/** * Deletes all associated RoleEntityQtypeBuiltInAuthorizations * @return void */ public function DeleteAllRoleEntityQtypeBuiltInAuthorizations() { if (is_null($this->intRoleId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateRoleEntityQtypeBuiltInAuthorization on this unsaved Role.'); } // Get the Database Object for this Class $objDatabase = Role::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (RoleEntityQtypeBuiltInAuthorization::LoadArrayByRoleId($this->intRoleId) as $objRoleEntityQtypeBuiltInAuthorization) { $objRoleEntityQtypeBuiltInAuthorization->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `role_entity_qtype_built_in_authorization` WHERE `role_id` = ' . $objDatabase->SqlVariable($this->intRoleId) . ' '); }
protected function UpdateBuiltInFields() { //Set View Display Logic of Built-In Fields $objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId(QApplication::$objRoleModule->RoleId, EntityQtype::Address, 1); if ($objRoleEntityQtypeBuiltInAuthorization && $objRoleEntityQtypeBuiltInAuthorization->AuthorizedFlag) { $this->blnViewBuiltInFields = true; } else { $this->blnViewBuiltInFields = false; } //Set Edit Display Logic of Built-In Fields $objRoleEntityQtypeBuiltInAuthorization2 = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId(QApplication::$objRoleModule->RoleId, EntityQtype::Address, 2); if ($objRoleEntityQtypeBuiltInAuthorization2 && $objRoleEntityQtypeBuiltInAuthorization2->AuthorizedFlag) { $this->blnEditBuiltInFields = true; } else { $this->blnEditBuiltInFields = false; } }
protected function Form_Create() { if (QApplication::QueryString('intDownloadCsv')) { $this->RenderBegin(false); session_cache_limiter('must-revalidate'); // force a "no cache" effect header("Pragma: hack"); // IE chokes on "no cache", so set to something, anything, else. $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT"; header($ExpStr); header('Content-Type: text/csv'); header('Content-Disposition: csv; filename=skipped_records.csv'); $file = fopen(sprintf("%s/%s_contact_skipped.csv", __TRACMOR_TMP__, $_SESSION['intUserAccountId']), "r"); ob_end_clean(); while ($row = fgets($file, 1000)) { print $row; @ob_flush(); flush(); } QApplication::$JavaScriptArray = array(); QApplication::$JavaScriptArrayHighPriority = array(); $this->RenderEnd(false); exit; } // Create the Header Menu $this->ctlHeaderMenu_Create(); //$this->ctlShortcutMenu_Create(); $this->pnlMain_Create(); $this->pnlStepOne_Create(); $this->Buttons_Create(); $this->intStep = 1; $this->intSkippedRecordCount = 0; $this->blnImportEnd = true; $this->btnRemoveArray = array(); $this->arrItemCustomField = array(); $this->Labels_Create(); $this->objDatabase = Asset::GetDatabase(); // Load Custom Field foreach (CustomField::LoadArrayByActiveFlagEntity(1, EntityQtype::Contact) as $objCustomField) { $this->arrItemCustomField[$objCustomField->CustomFieldId] = $objCustomField; } $this->blnError = true; $intRoleId = QApplication::$objUserAccount->RoleId; $objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($intRoleId, EntityQtype::Contact, 2); // Check the user have edit permissions if ($objRoleEntityQtypeBuiltInAuthorization && $objRoleEntityQtypeBuiltInAuthorization->AuthorizedFlag) { $this->blnError = false; } if (isset($intCustomFieldIdArray) && count($intCustomFieldIdArray)) { //QApplication::$Database[1]->EnableProfiling(); // Load restrict permisions for Custom Fields $objConditions = QQ::AndCondition(QQ::Equal(QQN::RoleEntityQtypeCustomFieldAuthorization()->RoleId, (string) $intRoleId), QQ::In(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomField->CustomFieldId, $intCustomFieldIdArray), QQ::Equal(QQN::RoleEntityQtypeCustomFieldAuthorization()->AuthorizedFlag, false)); $objClauses = array(); array_push($objClauses, QQ::Expand(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomField->EntityQtypeCustomFieldId)); array_push($objClauses, QQ::OrderBy(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomFieldId)); $arrRoleEntityQtypeCustomFieldAuthorization = RoleEntityQtypeCustomFieldAuthorization::QueryArray($objConditions, $objClauses); if ($arrRoleEntityQtypeCustomFieldAuthorization) { foreach ($arrRoleEntityQtypeCustomFieldAuthorization as $objRoleAuth) { if (array_key_exists($objRoleAuth->EntityQtypeCustomField->CustomFieldId, $this->arrAssetCustomField)) { unset($this->arrAssetCustomField[$objRoleAuth->EntityQtypeCustomField->CustomFieldId]); } } } //QApplication::$Database[1]->OutputProfiling(); } $this->intUserArray = array(); // Load Users foreach (UserAccount::LoadAll() as $objUser) { $this->intUserArray[strtolower($objUser->Username)] = $objUser->UserAccountId; } $this->strAcceptibleMimeArray = array('text/plain' => 'txt', 'text/comma-separated-values' => 'csv', 'text/csv' => 'csv', 'text/x-comma-separated-values' => 'csv', 'application/vnd.ms-excel' => 'csv', 'application/csv' => 'csv', 'text/x-csv' => 'csv'); }
/** * Counts all associated RoleEntityQtypeBuiltInAuthorizationsAsCreatedBy * @return int */ public function CountRoleEntityQtypeBuiltInAuthorizationsAsCreatedBy() { if (is_null($this->intUserAccountId)) { return 0; } return RoleEntityQtypeBuiltInAuthorization::CountByCreatedBy($this->intUserAccountId); }
protected function UpdateContactAccess() { //checks if the entity has edit authorization $objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId(QApplication::$objRoleModule->RoleId, EntityQtype::Contact, 2); if ($objRoleEntityQtypeBuiltInAuthorization && $objRoleEntityQtypeBuiltInAuthorization->AuthorizedFlag) { $this->lblNewFromContact->Visible = true; $this->lblNewToContact->Visible = true; } else { $this->lblNewFromContact->Visible = false; $this->lblNewToContact->Visible = false; } }
/** * Counts all associated RoleEntityQtypeBuiltInAuthorizations * @return int */ public function CountRoleEntityQtypeBuiltInAuthorizations() { if (is_null($this->intRoleId)) { return 0; } return RoleEntityQtypeBuiltInAuthorization::CountByRoleId($this->intRoleId); }
protected function dtgRoleEntityQtypeBuiltInAuthorization_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->dtgRoleEntityQtypeBuiltInAuthorization->TotalItemCount = RoleEntityQtypeBuiltInAuthorization::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->dtgRoleEntityQtypeBuiltInAuthorization->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgRoleEntityQtypeBuiltInAuthorization->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be the array of all RoleEntityQtypeBuiltInAuthorization objects, given the clauses above $this->dtgRoleEntityQtypeBuiltInAuthorization->DataSource = RoleEntityQtypeBuiltInAuthorization::LoadAll($objClauses); }
/** * 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 RoleEntityQtypeBuiltInAuthorizationMetaControl * @param integer $intRoleEntityBuiltInId primary key value * @param QMetaControlCreateType $intCreateType rules governing RoleEntityQtypeBuiltInAuthorization object creation - defaults to CreateOrEdit * @return RoleEntityQtypeBuiltInAuthorizationMetaControl */ public static function Create($objParentObject, $intRoleEntityBuiltInId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intRoleEntityBuiltInId)) { $objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::Load($intRoleEntityBuiltInId); // RoleEntityQtypeBuiltInAuthorization was found -- return it! if ($objRoleEntityQtypeBuiltInAuthorization) { return new RoleEntityQtypeBuiltInAuthorizationMetaControl($objParentObject, $objRoleEntityQtypeBuiltInAuthorization); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a RoleEntityQtypeBuiltInAuthorization object with PK arguments: ' . $intRoleEntityBuiltInId); } } // 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 RoleEntityQtypeBuiltInAuthorizationMetaControl($objParentObject, new RoleEntityQtypeBuiltInAuthorization()); }
/** * 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 = RoleEntityQtypeBuiltInAuthorization::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 RoleEntityQtypeBuiltInAuthorization, given the clauses above $this->DataSource = RoleEntityQtypeBuiltInAuthorization::QueryArray($objCondition, $objClauses); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, RoleEntityQtypeBuiltInAuthorization::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
protected function UpdateFieldLevelAuthorizations() { if ($this->objModuleArray) { //First, we get all the panels that we need to manipulate foreach ($this->objModuleArray as $objModule) { switch ($objModule->ModuleId) { case 2: $arrEntity[] = array('objPanel' => $this->pnlAssets, 'intEntity' => EntityQtype::Asset); $arrEntity[] = array('objPanel' => $this->pnlAssetModel, 'intEntity' => EntityQtype::AssetModel); break; case 3: $arrEntity[] = array('objPanel' => $this->pnlInventory, 'intEntity' => EntityQtype::Inventory); break; case 4: $arrEntity[] = array('objPanel' => $this->pnlCompany, 'intEntity' => EntityQtype::Company); $arrEntity[] = array('objPanel' => $this->pnlContact, 'intEntity' => EntityQtype::Contact); $arrEntity[] = array('objPanel' => $this->pnlAddress, 'intEntity' => EntityQtype::Address); break; case 5: $arrEntity[] = array('objPanel' => $this->pnlShipping, 'intEntity' => EntityQtype::Shipment); break; case 6: $arrEntity[] = array('objPanel' => $this->pnlReceiving, 'intEntity' => EntityQtype::Receipt); break; } } //One Panel= One Entity. For each entity, we must save chkBuiltIn for View and Edit and several CustomChecks, for View and Edit foreach ($arrEntity as $entity) { //We look for the BuiltIn View entry, searching by RoleId, EntityId and authorizationId=1 (View) $objRoleEntityQTypeBuiltInAuthView = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($this->objRole->RoleId, $entity['intEntity'], 1); // If the entry doesn't exists, we create it. if (!$objRoleEntityQTypeBuiltInAuthView) { $objRoleEntityQTypeBuiltInAuthView = new RoleEntityQtypeBuiltInAuthorization(); $objRoleEntityQTypeBuiltInAuthView->RoleId = $this->objRole->RoleId; $objRoleEntityQTypeBuiltInAuthView->EntityQtypeId = $entity['intEntity']; $objRoleEntityQTypeBuiltInAuthView->AuthorizationId = 1; } $objRoleEntityQTypeBuiltInAuthView->AuthorizedFlag = $entity['objPanel']->chkBuiltInView->Checked; $objRoleEntityQTypeBuiltInAuthView->Save(); //We look for the BuiltIn Edit entry, searching by RoleId, EntityId and authorizationId=2 (Edit) $objRoleEntityQTypeBuiltInAuthEdit = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($this->objRole->RoleId, $entity['intEntity'], 2); // If the entry doesn't exists, we create it. if (!$objRoleEntityQTypeBuiltInAuthEdit) { $objRoleEntityQTypeBuiltInAuthEdit = new RoleEntityQtypeBuiltInAuthorization(); $objRoleEntityQTypeBuiltInAuthEdit->RoleId = $this->objRole->RoleId; $objRoleEntityQTypeBuiltInAuthEdit->EntityQtypeId = $entity['intEntity']; $objRoleEntityQTypeBuiltInAuthEdit->AuthorizationId = 2; } $objRoleEntityQTypeBuiltInAuthEdit->AuthorizedFlag = $entity['objPanel']->chkBuiltInEdit->Checked; $objRoleEntityQTypeBuiltInAuthEdit->Save(); //We must now save the View and Edit checkboxs values of the Custom checks. if ($entity['objPanel']->arrCustomChecks) { foreach ($entity['objPanel']->arrCustomChecks as $objCustomCheck) { //We look into EntityQtypeCustomFieldId because we need to get EntityQtypeCustomFieldId in order to save into the RoleEntityCustom tables $objEntityQtypeCustomField = EntityQtypeCustomField::LoadByEntityQtypeIdCustomFieldId($entity['intEntity'], $objCustomCheck['id']); //We look for the Custom View entry, searching by RoleId, EntityQtypeCustomFieldId and authorization_id=1(View) $objRoleEntityQtypeCustomFieldView = RoleEntityQtypeCustomFieldAuthorization::LoadByRoleIdEntityQtypeCustomFieldIdAuthorizationId($this->objRole->RoleId, $objEntityQtypeCustomField->EntityQtypeCustomFieldId, 1); // If the entry doesn't exists, we create it. if (!$objRoleEntityQtypeCustomFieldView) { $objRoleEntityQtypeCustomFieldView = new RoleEntityQtypeCustomFieldAuthorization(); $objRoleEntityQtypeCustomFieldView->RoleId = $this->objRole->RoleId; $objRoleEntityQtypeCustomFieldView->EntityQtypeCustomFieldId = $objEntityQtypeCustomField->EntityQtypeCustomFieldId; $objRoleEntityQtypeCustomFieldView->AuthorizationId = 1; } $objRoleEntityQtypeCustomFieldView->AuthorizedFlag = $objCustomCheck['view']->Checked; $objRoleEntityQtypeCustomFieldView->Save(); //We look for the Custom View entry, searching by RoleId, EntityQtypeCustomFieldId and authorization_id=2(Edit) $objRoleEntityQtypeCustomFieldEdit = RoleEntityQtypeCustomFieldAuthorization::LoadByRoleIdEntityQtypeCustomFieldIdAuthorizationId($this->objRole->RoleId, $objEntityQtypeCustomField->EntityQtypeCustomFieldId, 2); // If the entry doesn't exists, we create it. if (!$objRoleEntityQtypeCustomFieldEdit) { $objRoleEntityQtypeCustomFieldEdit = new RoleEntityQtypeCustomFieldAuthorization(); $objRoleEntityQtypeCustomFieldEdit->RoleId = $this->objRole->RoleId; $objRoleEntityQtypeCustomFieldEdit->EntityQtypeCustomFieldId = $objEntityQtypeCustomField->EntityQtypeCustomFieldId; $objRoleEntityQtypeCustomFieldEdit->AuthorizationId = 2; } $objRoleEntityQtypeCustomFieldEdit->AuthorizedFlag = $objCustomCheck['edit']->Checked; $objRoleEntityQtypeCustomFieldEdit->Save(); } } } } }
protected function UpdateAddressAccess() { //checks if the entity 4 (AssetModel) has edit authorization $objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId(QApplication::$objRoleModule->RoleId, EntityQtype::Address, 2); if ($objRoleEntityQtypeBuiltInAuthorization && $objRoleEntityQtypeBuiltInAuthorization->AuthorizedFlag) { $this->lblNewToAddress->Visible = true; } else { $this->lblNewToAddress->Visible = false; } }
public function dtgRoleEntityQtypeBuiltInAuthorization_Bind() { // Get Total Count b/c of Pagination $this->dtgRoleEntityQtypeBuiltInAuthorization->TotalItemCount = RoleEntityQtypeBuiltInAuthorization::CountAll(); $objClauses = array(); if ($objClause = $this->dtgRoleEntityQtypeBuiltInAuthorization->OrderByClause) { array_push($objClauses, $objClause); } if ($objClause = $this->dtgRoleEntityQtypeBuiltInAuthorization->LimitClause) { array_push($objClauses, $objClause); } $this->dtgRoleEntityQtypeBuiltInAuthorization->DataSource = RoleEntityQtypeBuiltInAuthorization::LoadAll($objClauses); }