public function __construct(NarroProject $objProject, NarroLanguage $objLanguage, $objParentObject, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->objProject = $objProject; $this->objLanguage = $objLanguage; $this->lstProject = new QListBox($this); $this->lstProject->DisplayStyle = QDisplayStyle::Block; $this->lstProject->Instructions = t('Please choose the project from which you will import matching approved translations'); $this->lstProject->PreferedRenderMethod = 'RenderWithName'; $this->blnAutoRenderChildren = true; foreach (NarroProject::QueryArray(QQ::Equal(QQN::NarroProject()->Active, 1), array(QQ::OrderBy(QQN::NarroProject()->ProjectName))) as $objProject) { $this->lstProject->AddItem($objProject->ProjectName, $objProject->ProjectId); } }
/** * 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 = NarroProject::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 NarroProject, given the clauses above $this->DataSource = NarroProject::QueryArray($objConditions, $objClauses); }
public function __construct($objUser, $objParentObject, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->strTemplate = __NARRO_INCLUDES__ . '/narro/panel/NarroUserRolePanel.tpl.php'; $this->objUser = $objUser; // Setup DataGrid Columns $this->colLanguage = new QDataGridColumn(t('Language'), '<?= $_CONTROL->ParentControl->dtgUserRole_LanguageColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Language->LanguageName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Language->LanguageName, false))); $this->colLanguage->HtmlEntities = false; $this->colProject = new QDataGridColumn(t('Project'), '<?= $_CONTROL->ParentControl->dtgUserRole_ProjectColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Project->ProjectName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Project->ProjectName, false))); $this->colProject->HtmlEntities = false; $this->colRole = new QDataGridColumn(t('Roles'), '<?= $_CONTROL->ParentControl->dtgUserRole_RoleColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Role->RoleName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Role->RoleName, false))); $this->colRole->HtmlEntities = false; $this->colActions = new QDataGridColumn(t('Actions'), '<?= $_CONTROL->ParentControl->dtgUserRole_ActionsColumn_Render($_ITEM) ?>'); $this->colActions->HtmlEntities = false; // Setup DataGrid $this->dtgUserRole = new NarroDataGrid($this); $this->dtgUserRole->Title = sprintf(t('<b>%s</b>\'s roles'), NarroLink::UserProfile($this->objUser->UserId, $this->objUser->RealName)); $this->dtgUserRole->ShowHeader = true; $this->dtgUserRole->Paginator = new QPaginator($this->dtgUserRole); $this->dtgUserRole->PaginatorAlternate = new QPaginator($this->dtgUserRole); $this->dtgUserRole->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page'); // Specify Whether or Not to Refresh using Ajax $this->dtgUserRole->UseAjax = QApplication::$UseAjax; // Specify the local databind method this datagrid will use $this->dtgUserRole->SetDataBinder('dtgUserRole_Bind', $this); $this->dtgUserRole->AddColumn($this->colLanguage); $this->dtgUserRole->AddColumn($this->colProject); $this->dtgUserRole->AddColumn($this->colRole); $this->lstLanguage = new QListBox($this); $this->lstLanguage->AddItem('Any'); foreach (NarroLanguage::LoadAllActive(array(QQ::OrderBy(QQN::NarroLanguage()->LanguageName))) as $objNarroLanguage) { if (QApplication::HasPermission('Can manage user roles', null, $objNarroLanguage->LanguageId)) { $this->blnCanManageSomeRoles = true; } $this->lstLanguage->AddItem($objNarroLanguage->LanguageName, $objNarroLanguage->LanguageId); } $this->lstLanguage->SelectedValue = QApplication::GetLanguageId(); $this->lstProject = new QListBox($this); $this->lstProject->AddItem('Any'); foreach (NarroProject::QueryArray(QQ::Equal(QQN::NarroProject()->Active, 1), array(QQ::OrderBy(QQN::NarroProject()->ProjectName))) as $objNarroProject) { if (QApplication::HasPermission('Can manage user roles', $objNarroProject->ProjectId)) { $this->blnCanManageSomeRoles = true; } $this->lstProject->AddItem($objNarroProject->ProjectName, $objNarroProject->ProjectId); } if (!$this->blnCanManageSomeRoles && QApplication::HasPermission('Can manage user roles')) { $this->blnCanManageSomeRoles = true; } if ($this->blnCanManageSomeRoles) { $this->dtgUserRole->AddColumn($this->colActions); } $this->lstRole = new QListBox($this); foreach (NarroRole::LoadAll(array(QQ::OrderBy(QQN::NarroRole()->RoleName))) as $objNarroRole) { if ($objNarroRole->RoleName == 'Administrator' && !QApplication::HasPermission('Administrator')) { continue; } $this->lstRole->AddItem($objNarroRole->RoleName, $objNarroRole->RoleId); } $this->btnAddRole = new QButton($this); $this->btnAddRole->Text = t('Add'); $this->btnAddRole->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnAddRole_Click')); }
public function dtgProjectList_Bind() { if ($this->txtSearch->Text != '') { $arrConditions[] = QQ::Like(QQN::NarroProject()->ProjectName, sprintf('%%%s%%', $this->txtSearch->Text)); } else { $arrConditions[] = QQ::All(); } if (QApplication::HasPermissionForThisLang('Can manage project')) { $arrConditions[] = QQ::All(); } else { $arrConditions[] = QQ::AndCondition(QQ::Equal(QQN::NarroProject()->NarroProjectProgressAsProject->Active, 1), QQ::Equal(QQN::NarroProject()->Active, 1)); } // Setup the $objClauses Array $objClauses = array(QQ::Expand(QQN::NarroProject()->NarroProjectProgressAsProject, QQ::Equal(QQN::NarroProject()->NarroProjectProgressAsProject->LanguageId, QApplication::GetLanguageId()))); // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below $this->dtgProjectList->TotalItemCount = NarroProject::QueryCount(QQ::AndCondition($arrConditions), $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->dtgProjectList->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgProjectList->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be the array of all NarroProjectProgress objects, given the clauses above $this->dtgProjectList->DataSource = NarroProject::QueryArray(QQ::AndCondition($arrConditions), $objClauses); }
/** * Load an array of NarroProject objects, * by Active Index(es) * @param integer $intActive * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query * @return NarroProject[] */ public static function LoadArrayByActive($intActive, $objOptionalClauses = null) { // Call NarroProject::QueryArray to perform the LoadArrayByActive query try { return NarroProject::QueryArray(QQ::Equal(QQN::NarroProject()->Active, $intActive), $objOptionalClauses); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }