public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, NarroUserRole::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * Counts all associated NarroUserRolesAsUser * @return int */ public function CountNarroUserRolesAsUser() { if (is_null($this->intUserId)) { return 0; } return NarroUserRole::CountByUserId($this->intUserId); }
* License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ require_once dirname(__FILE__) . '/configuration/prepend.inc.php'; if (QApplication::HasPermission('Administrator')) { foreach (NarroUser::LoadAll() as $objUser) { $arrUserPermissions = array(); foreach (NarroUserPermission::LoadArrayByUserId($objUser->UserId) as $objUserPermission) { $objUserRole = new NarroUserRole(); switch ($objUserPermission->PermissionId) { case 1: case 2: case 4: $objUserRole->RoleId = 2; break; case 3: $objUserRole->RoleId = 3; break; case 5: case 6: case 8: case 9: case 10: case 18:
/** * Default / simple DataBinder for this Meta DataGrid. This can easily be overridden * by calling SetDataBinder() on this DataGrid with another DataBinder of your choice. * * 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). */ public function MetaDataBinder() { $objConditions = $this->Conditions; if (null !== $this->conAdditionalConditions) { $objConditions = QQ::AndCondition($this->conAdditionalConditions, $objConditions); } // Setup the $objClauses Array $objClauses = array(); if (null !== $this->clsAdditionalClauses) { $objClauses = $this->clsAdditionalClauses; } // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = NarroUserRole::QueryCount($objConditions); } // 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 NarroUserRole, given the clauses above $this->DataSource = NarroUserRole::QueryArray($objConditions, $objClauses); }
public function btnDeleteRole_Click($strFormId, $strControlId, $strParameter) { $objUserRole = NarroUserRole::Load($strParameter); if (!QApplication::HasPermission('Can manage user roles', $objUserRole->ProjectId, $objUserRole->LanguageId)) { return false; } $objUserRole->Delete(); $this->dtgUserRole_Bind(); }
public static function RegisterUser($strUsername, $strEmail, $strPassword, $strRealName) { $objMaxUser = NarroUser::LoadAll(QQ::Clause(QQ::LimitInfo(1, 0), QQ::OrderBy(QQN::NarroUser()->UserId, false))); $objUser = new NarroUser(); $objUser->UserId = $objMaxUser[0]->UserId + 1; $objUser->Username = $strUsername; if ($strRealName) { $objUser->RealName = $strRealName; } $objUser->Email = $strEmail; require_once __NARRO_INCLUDES__ . '/PasswordHash.class.php'; $objHasher = new PasswordHash(8, FALSE); $objUser->Password = $objHasher->HashPassword($strPassword); try { $objUser->Save(); } catch (Exception $objEx) { throw $objEx; } /** * set up default roles */ $objUserRole = new NarroUserRole(); if ($objUser->UserId == 1) { $objUserRole->RoleId = 5; } else { $objUserRole->RoleId = 2; } $objUserRole->UserId = $objUser->UserId; $objUserRole->Save(); return NarroUser::LoadByUsernameAndPassword($strUsername, md5($strPassword)); }
/** * 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 NarroUserRoleMetaControl * @param integer $intUserRoleId primary key value * @param QMetaControlCreateType $intCreateType rules governing NarroUserRole object creation - defaults to CreateOrEdit * @return NarroUserRoleMetaControl */ public static function Create($objParentObject, $intUserRoleId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intUserRoleId)) { $objNarroUserRole = NarroUserRole::Load($intUserRoleId); // NarroUserRole was found -- return it! if ($objNarroUserRole) { return new NarroUserRoleMetaControl($objParentObject, $objNarroUserRole); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a NarroUserRole object with PK arguments: ' . $intUserRoleId); } } // 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 NarroUserRoleMetaControl($objParentObject, new NarroUserRole()); }
/** * This Form_Validate event handler allows you to specify any custom Form Validation rules. * It will also Blink() on all invalid controls, as well as Focus() on the top-most invalid control. */ protected function Form_Validate() { // By default, we report the result of validation from the parent $blnToReturn = parent::Form_Validate(); // Custom Validation Rules // TODO: Be sure to set $blnToReturn to false if any custom validation fails! // Check for records that may violate Unique Clauses if (($objNarroUserRole = NarroUserRole::LoadByUserIdRoleIdProjectIdLanguageId($this->lstUser->SelectedValue, $this->lstRole->SelectedValue, $this->lstProject->SelectedValue, $this->lstLanguage->SelectedValue)) && $objNarroUserRole->UserRoleId != $this->mctNarroUserRole->NarroUserRole->UserRoleId) { $blnToReturn = false; $this->lstUser->Warning = QApplication::Translate("Already in Use"); $this->lstRole->Warning = QApplication::Translate("Already in Use"); $this->lstProject->Warning = QApplication::Translate("Already in Use"); $this->lstLanguage->Warning = QApplication::Translate("Already in Use"); } $blnFocused = false; foreach ($this->GetErrorControls() as $objControl) { // Set Focus to the top-most invalid control if (!$blnFocused) { $objControl->Focus(); $blnFocused = true; } // Blink on ALL invalid controls $objControl->Blink(); } return $blnToReturn; }
/** * Counts all associated NarroUserRolesAsLanguage * @return int */ public function CountNarroUserRolesAsLanguage() { if (is_null($this->intLanguageId)) { return 0; } return NarroUserRole::CountByLanguageId($this->intLanguageId); }
public function dtgRoleUserList_Bind() { $this->dtgRoleUserList->TotalItemCount = NarroUserRole::CountByRoleId($this->objRole->RoleId); // Because we want to enable pagination AND sorting, we need to setup the $objClauses array to send to LoadAll() // 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->dtgRoleUserList->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgRoleUserList->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be the array of all NarroUser objects, given the clauses above $this->dtgRoleUserList->DataSource = NarroUserRole::LoadArrayByRoleId($this->objRole->RoleId, $objClauses); QApplication::ExecuteJavaScript('highlight_datagrid();'); }
/** * Counts all associated NarroUserRolesAsProject * @return int */ public function CountNarroUserRolesAsProject() { if (is_null($this->intProjectId)) { return 0; } return NarroUserRole::CountByProjectId($this->intProjectId); }