/** * 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 = UserAccount::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 UserAccount, given the clauses above $this->DataSource = UserAccount::QueryArray($objCondition, $objClauses); }
protected function btnPrintLabels_Click() { //if ($this->blnPrintLabels) { $this->strBarCodeArray = array(); $this->strTablesBufferArray = array(); $this->intCurrentBarCodeLabel = 0; // Set start value for PDF generation progress bar $_SESSION["intGeneratingStatus"] = 0; set_time_limit(0); $blnError = false; // Array[0] - DataGrid Object name; array[1] - Id; array[2] - used for Bar Code Label Generation $arrDataGridObjectNameId = $this->ctlSearchMenu->GetDataGridObjectNameId(); $this->intObjectIdArray = $this->ctlSearchMenu->{$arrDataGridObjectNameId}[0]->GetSelected($arrDataGridObjectNameId[1]); $objCheckedArray = array(); if (count($this->intObjectIdArray)) { // Switch statement for all four entity types switch ($this->lstLabelTypeControl->SelectedValue) { case 1: // Load an array of Assets by AssetId $objCheckedArray = Asset::QueryArray(QQ::In(QQN::Asset()->AssetId, $this->intObjectIdArray)); break; case 2: // Load an array of Inventories by InventoryModelId $objCheckedArray = InventoryModel::QueryArray(QQ::In(QQN::InventoryModel()->InventoryModelId, $this->intObjectIdArray)); break; case 3: // Load an array of Locations by LocationId $objCheckedArray = Location::QueryArray(QQ::In(QQN::Location()->LocationId, $this->intObjectIdArray)); break; case 4: $objCheckedArray = UserAccount::QueryArray(QQ::In(QQN::UserAccount()->UserAccountId, $this->intObjectIdArray)); break; default: $this->btnPrintLabels->Warning = "Please select Label Type.<br/>"; $this->intObjectIdArray = array(); $blnError = true; break; } $objArrayById = array(); // Create array of objects where the key is Id foreach ($objCheckedArray as $objChecked) { $objArrayById[$objChecked->{$arrDataGridObjectNameId}[1]] = $objChecked; } // Fill the BarCodeArray in the order items sorted in the datagrid foreach ($this->intObjectIdArray as $intObjectId) { $this->strBarCodeArray[] = $objArrayById[$intObjectId]->{$arrDataGridObjectNameId}[2]; } } else { $blnError = true; } if (!$blnError) { $this->btnPrintLabels->Warning = ""; $this->lstLabelStock->SelectedValue = 0; $this->lstLabelOffset->RemoveAllItems(); $this->lstLabelOffset->AddItem(new QListItem('None', 0, 1)); $this->lstLabelStock->Enabled = true; $this->lstLabelOffset->Enabled = true; $this->dlgPrintLabels->ShowDialogBox(); } else { // If we have no checked items $this->btnPrintLabels->Warning .= "You must check at least one item."; } // Enable Print Labels button $this->btnPrintLabels->Enabled = true; //$this->blnPrintLabels = false; /*} else { $this->btnPrintLabels->Warning = "Please wait... loading."; $this->blnPrintLabels = true; QApplication::ExecuteJavaScript("document.getElementById('".$this->btnPrintLabels->ControlId."').click(); document.getElementById('warning_loading').innerHTML = '';"); }*/ QApplication::ExecuteJavaScript("document.getElementById('warning_loading').innerHTML = '';"); }
$strQuery = "INSERT INTO `_version` (`version`) VALUES ('0.4.0')"; $objDatabase->NonQuery($strQuery); // Change `textarea` custom field type name to `text area` $strQuery = "UPDATE `custom_field_qtype` SET `name` = 'text area' WHERE `custom_field_qtype_id` = 3"; $objDatabase->NonQuery($strQuery); // Update terminology in Asset module shortcuts $strQuery = "UPDATE `shortcut` SET `short_description`='Models' WHERE `shortcut_id`='2'"; $objDatabase->NonQuery($strQuery); $strQuery = "UPDATE `shortcut` SET `short_description`='Import Models' WHERE `shortcut_id`='3'"; $objDatabase->NonQuery($strQuery); $strQuery = "UPDATE `shortcut` SET `short_description`='Create Model' WHERE `shortcut_id`='1'"; $objDatabase->NonQuery($strQuery); // Change password_hash length to varchar(60) $strQuery = "ALTER TABLE `user_account` CHANGE `password_hash` `password_hash` VARCHAR( 60 ) NOT NULL"; $objDatabase->NonQuery($strQuery); // Update existing SHA1 hashes to PHPass hashes require '../includes/php/PasswordHash.php'; $objHasher = new PasswordHash(8, PORTABLE_PASSWORDS); $objUserAccountArray = UserAccount::QueryArray(QQ::All()); foreach ($objUserAccountArray as $objUserAccount) { $strNewHash = $objHasher->HashPassword($objUserAccount->PasswordHash); $strQuery = sprintf("UPDATE `user_account` SET `password_hash` = '%s' WHERE `user_account_id` = %s", $strNewHash, $objUserAccount->UserAccountId); $objDatabase->NonQuery($strQuery); } $objDatabase->TransactionCommit(); echo 'Update successful!'; } catch (Exception $objExc) { // Something went wrong $objDatabase->TransactionRollback(); echo 'Update failed!'; }
public function dtgUserAccount_Bind() { $objClauses = array(); if ($objClause = $this->dtgUserAccount->OrderByClause) { array_push($objClauses, $objClause); } $objClause = QQ::Expand(QQN::UserAccount()->CreatedByObject); array_push($objClauses, $objClause); $objClause = QQ::Expand(QQN::UserAccount()->Role); array_push($objClauses, $objClause); $this->strUsername = $this->txtUsername->Text; if ($this->strUsername) { $this->dtgUserAccount->TotalItemCount = UserAccount::QueryCount(QQ::Like(QQN::UserAccount()->Username, '%' . $this->strUsername . '%'), $objClauses); if ($this->dtgUserAccount->TotalItemCount > 0) { $this->dtgUserAccount->ShowHeader = true; // Add the LimitClause information, as well if ($objClause = $this->dtgUserAccount->LimitClause) { array_push($objClauses, $objClause); } $this->dtgUserAccount->DataSource = UserAccount::QueryArray(QQ::Like(QQN::UserAccount()->Username, '%' . $this->strUsername . '%'), $objClauses); } else { $this->dtgUserAccount->ShowHeader = false; } } else { // Get Total Count b/c of Pagination $this->dtgUserAccount->TotalItemCount = UserAccount::CountAll(); if ($this->dtgUserAccount->TotalItemCount == 0) { $this->dtgUserAccount->ShowHeader = false; } else { if ($objClause = $this->dtgUserAccount->LimitClause) { array_push($objClauses, $objClause); } $this->dtgUserAccount->DataSource = UserAccount::LoadAll($objClauses); $this->dtgUserAccount->ShowHeader = true; } } }
/** * Load an array of UserAccount objects, * by RoleId Index(es) * @param integer $intRoleId * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query * @return UserAccount[] */ public static function LoadArrayByRoleId($intRoleId, $objOptionalClauses = null) { // Call UserAccount::QueryArray to perform the LoadArrayByRoleId query try { return UserAccount::QueryArray(QQ::Equal(QQN::UserAccount()->RoleId, $intRoleId), $objOptionalClauses); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
public static function LoadByPasswordResetCode($strPasswordResetCode) { // Reset code must be 32 characters if (strlen($strPasswordResetCode) != 32) { return null; } // Load all users with unexpired reset codes $arrUserAccount = UserAccount::QueryArray(QQ::AndCondition(QQ::Equal(QQN::UserAccount()->ActiveFlag, 1), QQ::IsNotNull(QQN::UserAccount()->PasswordResetCode), QQ::GreaterThan(QQN::UserAccount()->PasswordResetExpiry, QDateTime::Now()))); // Check submitted reset code against any valid codes foreach ($arrUserAccount as $objUserAccount) { if (QApplication::CheckPassword($strPasswordResetCode, $objUserAccount->PasswordResetCode)) { // Match found return $objUserAccount; } } return null; }