public function dtgPermission_PermissionColumn_Render(NarroPermission $objPermission)
 {
     if (QApplication::HasPermission('Can manage roles')) {
         $strControlId = 'chkPermission' . $objPermission->PermissionId;
         $chkPermission = new QCheckBox($this->dtgPermission);
         $chkPermission->Text = t($objPermission->PermissionName);
         $chkPermission->ActionParameter = $objPermission->PermissionId;
         $chkPermission->Checked = NarroRolePermission::QueryCount(QQ::AndCondition(QQ::Equal(QQN::NarroRolePermission()->RoleId, $this->objRole->RoleId), QQ::Equal(QQN::NarroRolePermission()->PermissionId, $objPermission->PermissionId)));
         if (QApplication::$UseAjax) {
             $chkPermission->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'chkPermission_Click'));
         } else {
             $chkPermission->AddAction(new QClickEvent(), new QServerControlAction($this, 'chkPermission_Click'));
         }
         return $chkPermission->Render(false);
     } else {
         return t($objPermission->PermissionName);
     }
 }
Esempio n. 2
0
 public function chkSelected_Render(Person $objPerson)
 {
     // In order to keep track whether or not a Person's Checkbox has been rendered,
     // we will use explicitly defined control ids.
     $strControlId = 'chkSelected' . $objPerson->Id;
     // Let's see if the Checkbox exists already
     $chkSelected = $this->GetControl($strControlId);
     if (!$chkSelected) {
         // Define the Checkbox -- it's parent is the Datagrid (b/c the datagrid is the one calling
         // this method which is responsible for rendering the checkbox.  Also, we must
         // explicitly specify the control ID
         $chkSelected = new QCheckBox($this->dtgPersons, $strControlId);
         $chkSelected->Text = 'Select';
         // We'll use Control Parameters to help us identify the Person ID being copied
         $chkSelected->ActionParameter = $objPerson->Id;
         // Let's assign a server action on click
         $chkSelected->AddAction(new QClickEvent(), new QServerAction('chkSelected_Click'));
     }
     // Render the checkbox.  We want to *return* the contents of the rendered Checkbox,
     // not display it.  (The datagrid is responsible for the rendering of this column).
     // Therefore, we must specify "false" for the optional blnDisplayOutput parameter.
     return $chkSelected->Render(false);
 }
 protected function chkCustom_Create()
 {
     $intRoleId = QApplication::QueryString('intRoleId');
     $objCustomFieldArray = CustomField::LoadObjCustomFieldArray($this->intEntityQtypeId, false, null);
     foreach ($objCustomFieldArray as $objCustomField) {
         //For each Custom Field, we setup one checkbox for View Access and one for Edit Access
         $chkCustomView = new QCheckBox($this);
         $chkCustomView->AddAction(new QClickEvent(), new QAjaxAction('chkCustom_Click'));
         $chkCustomEdit = new QCheckBox($this);
         //When we click in a View Checkbox, we need to control the Edit Checkbox Control too in the chkCustom_Click method.
         $chkCustomView->ActionParameter = $chkCustomEdit->ControlId;
         //In order to manipulate the RoleEntityQtypeCustomFieldAuthorization table, we need to obtain the EntityQtypeCustomFieldId field.
         $objEntityQtypeCustomField = EntityQtypeCustomField::LoadByEntityQtypeIdCustomFieldId($this->intEntityQtypeId, $objCustomField->CustomFieldId);
         if ($objEntityQtypeCustomField) {
             $objCustomAuthView = RoleEntityQtypeCustomFieldAuthorization::LoadByRoleIdEntityQtypeCustomFieldIdAuthorizationId($intRoleId, $objEntityQtypeCustomField->EntityQtypeCustomFieldId, 1);
             //If Creation Mode, the View Privilege of the Custom Fields is checked by default
             if (!$this->blnEditMode) {
                 $chkCustomView->Checked = 1;
             } elseif (isset($objCustomAuthView)) {
                 $chkCustomView->Checked = $objCustomAuthView->AuthorizedFlag;
             }
             $objCustomAuthEdit = RoleEntityQtypeCustomFieldAuthorization::LoadByRoleIdEntityQtypeCustomFieldIdAuthorizationId($intRoleId, $objEntityQtypeCustomField->EntityQtypeCustomFieldId, 2);
             //If Creation Mode, the Edit Privilege of the Custom Fields is checked by default
             if (!$this->blnEditMode) {
                 $chkCustomEdit->Checked = 1;
             } elseif (isset($objCustomAuthEdit)) {
                 $chkCustomEdit->Checked = $objCustomAuthEdit->AuthorizedFlag;
             }
             //if view access is not authorized, edit access won't be authorized
             if (!$chkCustomView->Checked) {
                 $chkCustomEdit->Enabled = false;
                 $chkCustomEdit->Checked = false;
             }
         }
         //In order to manipulate all the custom checkbox of the entity, we save them in an associated array.
         $this->arrCustomChecks[] = array('name' => $objCustomField->ShortDescription . ':', 'view' => $chkCustomView, 'edit' => $chkCustomEdit, 'id' => $objCustomField->CustomFieldId);
     }
 }
 public function dtgLanguage_ActiveColumn_Render(NarroLanguage $objLanguage)
 {
     if ($objLanguage->LanguageId == QApplication::$SourceLanguage->LanguageId || $objLanguage->LanguageId == QApplication::GetLanguageId()) {
         return '';
     }
     $objCheckBox = $this->Form->GetControl('activelang' . $objLanguage->LanguageId);
     if (!$objCheckBox instanceof QCheckBox) {
         $objCheckBox = new QCheckBox($this->dtgLanguage, 'activelang' . $objLanguage->LanguageId);
         $objCheckBox->ActionParameter = $objLanguage->LanguageId;
         if (QApplication::$UseAjax) {
             $objCheckBox->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'chkActive_Click'));
         } else {
             $objCheckBox->AddAction(new QClickEvent(), new QServerControlAction($this, 'chkActive_Click'));
         }
     }
     $objCheckBox->Checked = $objLanguage->Active;
     return $objCheckBox->Render(false);
 }
Esempio n. 5
0
 public function chkSelected_Render(Person $objPerson, QCheckBox $chkSelected)
 {
     // Let's assign a server action on click
     $chkSelected->AddAction(new QClickEvent(), new QServerAction('chkSelected_Click'));
 }
 public function dtgFile_colSettings_Render(NarroFileProgress $objProgress)
 {
     if ($objProgress->File->TypeId == NarroFileType::Folder) {
         return '';
     }
     $strControlId = 'chkExport' . $objProgress->FileId;
     $chkExport = $this->dtgFile->GetChildControl($strControlId);
     if (!$chkExport) {
         $chkExport = new QCheckBox($this->dtgFile, $strControlId);
         $chkExport->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'chkExport_Click'));
         $chkExport->Name = t('Export with project');
         $chkExport->ToolTip = t('If ticked, this file will be exported when doing a project export. Useful for excluding some files from the project export.');
     }
     $chkExport->ActionParameter = $objProgress->File->FileId;
     $chkExport->Checked = NarroFileProgress::CountByFileIdLanguageIdExport($objProgress->File->FileId, QApplication::GetLanguageId(), 1);
     $chkExport->Display = QApplication::HasPermission('Can export project', $this->objProject->ProjectId, QApplication::GetLanguageId());
     return $chkExport->RenderWithName(false);
 }