protected function Form_Create() { parent::Form_Create(); $this->pnlTab = new QTabs($this); $pnlDummy = new QPanel($this->pnlTab); $pnlDummy = new QPanel($this->pnlTab); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders = array(NarroLink::ProjectList(t('Projects')), NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_ALL, '', 0, 0, 10, 0, 0, t('Translate')), NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Review'))); /** * Do not show the langauge tab if only two languages are active (source and target * Unless the user is an administrator and might want to set another one active */ if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) { $this->pnlLanguageTab = new QTabs($this->pnlTab); $pnlDummy = new QPanel($this->pnlLanguageTab); $arrLangHeaders[] = t('List'); if (QApplication::HasPermissionForThisLang('Can add language')) { $this->pnlLanguageEdit = new NarroLanguageEditPanel($this->pnlLanguageTab, NarroLanguage::Load(QApplication::QueryString('lid'))); $arrLangHeaders[] = QApplication::QueryString('lid') ? t('Edit') : t('Add'); } $this->pnlLanguageTab->Headers = $arrLangHeaders; $this->pnlLanguageTab->Selected = 1; $arrHeaders[] = t('Languages'); $this->pnlTab->Selected = count($arrHeaders) - 1; } $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserList('', t('Users')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles')); if (QApplication::HasPermissionForThisLang('Administrator')) { $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Log('', t('Application Log')); } $this->pnlTab->Headers = $arrHeaders; }
protected function Form_Create() { parent::Form_Create(); if (QApplication::GetUserId() == NarroUser::ANONYMOUS_USER_ID) { QApplication::Redirect(NarroLink::ProjectList()); exit; } if (QApplication::GetUserId() != QApplication::QueryString('u') && QApplication::HasPermissionForThisLang('Can manage users', null)) { $this->objUser = NarroUser::Load(QApplication::QueryString('u')); } if (!$this->objUser instanceof NarroUser) { $this->objUser = QApplication::$User; } $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), NarroLink::UserList('', t('Users')), $this->objUser->RealName); $this->pnlTab = new QTabs($this); new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserProfile($this->objUser->UserId, t('Profile')); if (QApplication::GetUserId() == $this->objUser->UserId || QApplication::HasPermissionForThisLang('Can manage users', null)) { new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserPreferences($this->objUser->UserId, t('Preferences')); } new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserRole($this->objUser->UserId, t('Roles')); if (QApplication::GetUserId() == $this->objUser->UserId || QApplication::HasPermissionForThisLang('Can manage users', null)) { $this->pnlUser = new NarroUserEditPanel($this->objUser, $this->pnlTab); $arrHeaders[] = NarroLink::UserEdit($this->objUser->UserId, t('Edit')); $this->pnlTab->Selected = count($arrHeaders) - 1; } $this->pnlTab->Headers = $arrHeaders; }
protected function Form_Create() { parent::Form_Create(); if (!QApplication::HasPermissionForThisLang('Can export project', $this->objProject->ProjectId)) { QApplication::Redirect(NarroLink::ProjectList()); } $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Project($this->objProject->ProjectId, t('Overview')); if ($this->objProject instanceof NarroProject && QApplication::HasPermissionForThisLang('Can edit project', $this->objProject->ProjectId)) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectEdit($this->objProject->ProjectId, t('Edit')); } $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Translate($this->objProject->ProjectId, '', 0, '', 0, 0, 10, 0, 0, t('Translate')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Review($this->objProject->ProjectId, '', NarroReviewPanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Review')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectFileList($this->objProject->ProjectId, '', '', t('Files')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectLanguages($this->objProject->ProjectId, t('Languages')); if (QApplication::HasPermissionForThisLang('Can import project', $this->objProject->ProjectId)) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectImport($this->objProject->ProjectId, t('Import')); } if (QApplication::HasPermissionForThisLang('Can export project', $this->objProject->ProjectId)) { $this->pnlSelectedTab = new NarroProjectExportPanel($this->objProject, $this->pnlMainTab); $arrHeaders[] = t('Export'); $this->pnlMainTab->Selected = count($arrHeaders) - 1; } $this->pnlMainTab->Headers = $arrHeaders; }
protected function Form_Create() { parent::Form_Create(); $this->pnlTab = new QTabs($this); /** * Create the project list panel and set the filter from the url. * The filter is used to show only projects of a given status based on their progress * (finished, empty, in progress). */ $this->pnlProjectList = new NarroProjectListPanel($this->pnlTab); $this->pnlTop = new NarroTopPanel(date(sprintf('Y-m-%d 00:00:00', date('d') - date('N') + 1)), $this); $pnlDummy = new QPanel($this->pnlTab); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders = array(t('Projects'), NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate')), NarroLink::Review(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Review'))); /** * Do not show the langauge tab if only two languages are active (source and target * Unless the user is an administrator and might want to set another one active */ if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) { $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::LanguageList(t('Languages')); } $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserList('', t('Users')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles')); if (QApplication::HasPermissionForThisLang('Administrator')) { $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Log('', t('Application Log')); } $this->pnlTab->Headers = $arrHeaders; }
protected function Form_Create() { parent::Form_Create(); $this->pnlTab = new QTabs($this); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::ProjectList(t('Projects')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Review(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Translate')); if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) { $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::LanguageList(t('Languages')); } $this->pnlUserList = new NarroUserListPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserList('', t('Users')); $this->pnlTab->Selected = count($arrHeaders) - 1; $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles')); if (QApplication::HasPermissionForThisLang('Administrator')) { $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Log('', t('Application Log')); } $this->pnlTab->Headers = $arrHeaders; }
public function dtgRoleUserList_UsernameColumn_Render(NarroUserRole $objNarroUserRole) { if (QApplication::HasPermission('Can manage roles')) { return NarroLink::UserRole($objNarroUserRole->UserId, $objNarroUserRole->User->Username); } else { return NarroLink::UserProfile($objNarroUserRole->UserId, $objNarroUserRole->User->Username); } }
protected function SetupNarroProject($intProjectId) { // Lookup Object PK information from Query String (if applicable) if ($intProjectId) { $this->objProject = NarroProject::Load($intProjectId); $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), $this->objProject->ProjectName); } else { $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), t('Add project')); } }
protected function SetupNarroProject($intProjectId) { $this->objProject = NarroProject::Load($intProjectId); if (!$this->objProject) { QApplication::Redirect(NarroLink::ProjectList()); return false; } else { $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), $this->objProject->ProjectName); return true; } }
protected function Form_Create() { parent::Form_Create(); if (QApplication::QueryString('p') == 0) { $this->pnlMainTab = new QTabs($this); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectList(t('Projects')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Translate')); $this->pnlReview = new NarroTranslatePanel($this->pnlMainTab); $arrHeaders[] = t('Review'); $this->pnlMainTab->Selected = count($arrHeaders) - 1; if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::LanguageList(t('Languages')); } $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::UserList('', t('Users')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles')); if (QApplication::HasPermissionForThisLang('Administrator')) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Log('', t('Application Log')); } $this->pnlMainTab->Headers = $arrHeaders; } else { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Project($this->objProject->ProjectId, t('Overview')); if ($this->objProject instanceof NarroProject && QApplication::HasPermissionForThisLang('Can edit project', $this->objProject->ProjectId)) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectEdit($this->objProject->ProjectId, t('Edit')); } $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Translate($this->objProject->ProjectId, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate')); $this->pnlReview = new NarroTranslatePanel($this->pnlMainTab); $arrHeaders[] = t('Review'); $this->pnlMainTab->Selected = count($arrHeaders) - 1; $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectFileList($this->objProject->ProjectId, '', '', t('Files')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectLanguages($this->objProject->ProjectId, t('Languages')); if (QApplication::HasPermissionForThisLang('Can import project', $this->objProject->ProjectId)) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectImport($this->objProject->ProjectId, t('Import')); } if (QApplication::HasPermissionForThisLang('Can export project', $this->objProject->ProjectId)) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectExport($this->objProject->ProjectId, t('Export')); } $this->pnlMainTab->Headers = $arrHeaders; } }
protected function btnChangePassword_Click($strFormId, $strControlId, $strParameter) { require_once __NARRO_INCLUDES__ . '/PasswordHash.class.php'; $objHasher = new PasswordHash(8, FALSE); QApplication::$User->Password = $objHasher->HashPassword($this->txtPassword->Text); try { QApplication::$User->Save(); } catch (Exception $objEx) { $this->lblMessage->ForeColor = 'red'; $this->lblMessage->Text = t('Failed to change the password.'); } $this->lblMessage->ForeColor = 'green'; $this->lblMessage->Text = sprintf(t('Password changed succesfully. Click <a href="%s">here</a> to go to the project list.'), NarroLink::ProjectList()); }
protected function Form_Create() { parent::Form_Create(); $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), NarroLink::UserList('', t('Users')), t('Register')); $this->pnlTab = new QTabs($this); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserLogin(t('Login')); $this->pnlUserRegister = new NarroUserRegisterPanel($this->pnlTab); $arrHeaders[] = t('Register'); $this->pnlTab->Selected = count($arrHeaders) - 1; $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserRecoverPassword(t('Lost and found')); $this->pnlTab->Headers = $arrHeaders; }
protected function Form_Create() { parent::Form_Create(); $this->pnlTab = new QTabPanel($this); $this->pnlTab->UseAjax = false; $this->pnlRoleTab = new QTabPanel($this->pnlTab); $this->pnlRoleEdit = new NarroRoleEditPanel($this->pnlRoleTab, NarroRole::Load(QApplication::QueryString('rid'))); $this->pnlRoleTab->addTab(new QPanel($this->pnlRoleTab), t('List'), NarroLink::RoleList()); $this->pnlRoleTab->addTab($this->pnlRoleEdit, QApplication::QueryString('lid') ? t('Edit') : t('Add')); $this->pnlTab->addTab(new QPanel($this->pnlTab), t('Projects'), NarroLink::ProjectList()); $this->pnlTab->addTab(new QPanel($this->pnlTab), t('Translate'), NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_ALL, '', 0, 0, 10, 0, 0)); $this->pnlTab->addTab(new QPanel($this->pnlTab), t('Languages'), NarroLink::LanguageList()); $this->pnlTab->addTab(new QPanel($this->pnlTab), t('Users'), NarroLink::UserList()); $this->pnlTab->addTab($this->pnlRoleTab, t('Roles')); $this->pnlTab->SelectedTab = 4; $this->pnlRoleTab->SelectedTab = 1; $this->pnlTab = new QTabs($this); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::ProjectList(t('Projects')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Review(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Translate')); if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) { $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::LanguageList(t('Languages')); } $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserList('', t('Users')); $this->pnlRoleTab = new QTabs($this->pnlTab); new QPanel($this->pnlRoleTab); $arrRoleHeaders[] = NarroLink::RoleList(0, '', t('List')); if (QApplication::HasPermissionForThisLang('Can add role')) { $pnlDummy = new NarroRoleEditPanel($this->pnlRoleTab, NarroRole::Load(QApplication::QueryString('rid'))); $arrRoleHeaders[] = NarroLink::RoleEdit(null, t('Add')); $this->pnlRoleTab->Selected = count($arrRoleHeaders) - 1; } $this->pnlRoleTab->Headers = $arrRoleHeaders; $arrHeaders[] = t('Roles'); $this->pnlTab->Selected = count($arrHeaders) - 1; if (QApplication::HasPermissionForThisLang('Administrator')) { $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Log('', t('Application Log')); } $this->pnlTab->Headers = $arrHeaders; }
public function btnRegister_Click($strFormId, $strControlId, $strParameter) { if (!trim($this->txtUsername->Text) || !trim($this->txtPassword->Text)) { $this->lblMessage->ForeColor = 'red'; $this->lblMessage->Text = t("It's just three fields, don't leave one empty please."); return false; } try { $objUser = NarroUser::RegisterUser($this->txtUsername->Text, $this->txtEmail->Text, $this->txtPassword->Text, $this->txtRealname->Text); } catch (Exception $objEx) { $this->lblMessage->ForeColor = 'red'; $this->lblMessage->Text = t("Seems like the username or email is already in use.") . $objEx->getMessage(); return false; } if (!$objUser instanceof NarroUser) { QApplication::Redirect(sprintf('login.php?l=%s', QApplication::$TargetLanguage->LanguageCode)); } QApplication::$Session->User = $objUser; QApplication::Redirect(NarroLink::UserPreferences($objUser->UserId)); }
<?php $pnlEditor = $_FORM->GetControl('i' . $_ITEM->ContextInfoId); if (!$pnlEditor) { $pnlEditor = new NarroContextInfoEditor($_CONTROL, 'i' . $_ITEM->ContextInfoId, $_ITEM); $pnlEditor->Translation->AddAction(new QFocusEvent(), new QJavaScriptAction(sprintf("if (jQuery(window).scrollTop() + 200 > jQuery(document).height() - jQuery(window).height() && jQuery('#endReached').attr('checked') == false) qc.pA('%s', '%s', 'QClickEvent', '%s', '%s')", $_CONTROL->Form->FormId, $_CONTROL->ParentControl->btnMore->ControlId, $pnlEditor->Translation->ControlId, $_CONTROL->ParentControl->objWaitIcon->ControlId))); $_CONTROL->ParentControl->blnNewEditorCreated = true; } else { $_CONTROL->ParentControl->blnNewEditorCreated = false; } $intCurrentItem = $_CONTROL->CurrentItemIndex + 1 + $_CONTROL->ParentControl->intStart; $pnlEditor->Index = sprintf('<a href="%s" id="#i%d" tabindex="-1">%s</a>', NarroLink::Translate($_CONTROL->ParentControl->lstProject->SelectedValue, $_CONTROL->ParentControl->txtFile->Text, $_CONTROL->ParentControl->lstFilter->SelectedValue, $_CONTROL->ParentControl->txtSearch->Text, $_CONTROL->ParentControl->lstSort->SelectedValue, $_CONTROL->ParentControl->lstSortDir->SelectedValue, 10, $intCurrentItem - 1, $_ITEM->ContextInfoId), $_ITEM->ContextInfoId, $_CONTROL->ParentControl->intTotalItemCount ? ($_CONTROL->ParentControl->dtrText->PageNumber - 1) * $_CONTROL->ParentControl->dtrText->ItemsPerPage + $_CONTROL->CurrentItemIndex + 1 . '/' . $_CONTROL->ParentControl->intTotalItemCount : $intCurrentItem); if ($_CONTROL->ParentControl->intTotalItemCount == $_CONTROL->CurrentItemIndex + 1) { $pnlEditor->SaveButton->DisplayStyle = QDisplayStyle::Inline; } if ($pnlEditor->Translation->Warning != '') { $pnlEditor->CssClass = 'narro_context_info_editor ui-state-focus'; } else { $pnlEditor->CssClass = 'narro_context_info_editor'; } if ($_CONTROL->CurrentItemIndex % 2 == 0) { $pnlEditor->CssClass .= ' odd'; } else { $pnlEditor->CssClass .= ' even'; } $pnlEditor->RenderWithError();
public function colText_Render(NarroTextComment $objComment) { return str_replace('?l=' . QApplication::$TargetLanguage->LanguageCode, '?l=' . $objComment->Language->LanguageCode, NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_ALL, "'" . $objComment->Text->TextValue . "'", 0, 0, 10, 0, 0, NarroString::HtmlEntities($objComment->Text->TextValue))); }
public function colComment_Render(NarroTextComment $objComment) { return sprintf('%s<br /><small>-- <a href="%s" tabindex="-1">%s</a> in %s, %s ago</small>', $objComment->CommentText, NarroLink::UserProfile($objComment->UserId), $objComment->User->RealName, $objComment->Language->LanguageName, (new QDateTimeSpan(time() - strtotime($objComment->Created)))->SimpleDisplay()); }
public function btnViewUsers_Click($strFormId, $strControlId, $strParameter) { QApplication::Redirect(NarroLink::RoleList($strParameter, 'user')); }
public function colText_Render(NarroContextInfo $objContextInfo) { return str_replace('?l=' . QApplication::$TargetLanguage->LanguageCode, '?l=' . $objContextInfo->Language->LanguageCode, NarroLink::Translate($objContextInfo->Context->ProjectId, '', NarroTranslatePanel::SHOW_ALL, "'" . $objContextInfo->ValidSuggestion->Text->TextValue . "'", 0, 0, 10, 0, 0, NarroString::HtmlEntities($objContextInfo->ValidSuggestion->Text->TextValue))); }
<?php /** * Narro is an application that allows online software translation and maintenance. * Copyright (C) 2008-2011 Alexandru Szasz <*****@*****.**> * http://code.google.com/p/narro/ * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public * 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 */ $this->objDefaultWaitIcon->Render(); if (QApplication::GetUserId() == NarroUser::ANONYMOUS_USER_ID) { echo sprintf(t('Translating in %s'), $_CONTROL->lstLanguage->ItemCount > 1 ? $_CONTROL->lstLanguage->Render(false) : $_CONTROL->lstLanguage->GetItem(0)->Name) . sprintf(', <a href="%s">' . t('sign in') . '</a>', 'login.php?l=' . QApplication::$TargetLanguage->LanguageCode); } else { echo sprintf(t('Translating in %s as %s'), $_CONTROL->lstLanguage->ItemCount > 1 ? $_CONTROL->lstLanguage->Render(false) : $_CONTROL->lstLanguage->GetItem(0)->Name, sprintf(' <a title="%s" href="%s"><b>%s</b></a> ', t('Profile'), NarroLink::UserProfile(QApplication::$User->UserId), QApplication::$User->RealName ? QApplication::$User->RealName : QApplication::$User->RealName) . sprintf('<a title="%s" href="%s" style="vertical-align:middle"><img src="%s/settings.png" /></a>', t('Preferences'), NarroLink::UserPreferences(QApplication::GetUserId()), __NARRO_IMAGE_ASSETS__) . ' ' . $_CONTROL->btnLogout->Render(false)); }
<span style="font-size:80%%;color:gray;">' . t('%s wrote on %s:') . '</span> <br /> <span style="margin-left:5px;padding:3px;">%s</span>', NarroLink::UserProfile($objTextComment->UserId, '<b>' . $objTextComment->User->RealName . '</b>'), $objTextComment->Created, nl2br($objTextComment->CommentText)); foreach ($arrContext as $objContext) { $arrProjects[$objContext->ProjectId] = $objContext->Project->ProjectName; $strContextLink = __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . '/' . '#textcomments'; } asort($arrProjects); if (count($arrProjects)) { $strDescription .= sprintf(' <br /> <small> ' . t('This is a debate on the text "%s", used in the following projects:') . ' <br />', NarroString::HtmlEntities($objTextComment->Text->TextValue)); foreach ($arrProjects as $intProjectId => $strProjectName) { $strProjectLink = __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . '/' . NarroLink::ProjectTextList($intProjectId, NarroTranslatePanel::SHOW_ALL, $objTextComment->Text->TextValue); $arrProjectLinks[] = sprintf(t('<a href="%s">%s</a>'), $strProjectLink, $strProjectName); } $strDescription .= join(', ', $arrProjectLinks) . '</small>'; } } else { continue; } $objItem = new QRssItem(strlen($objTextComment->CommentText) > 124 ? substr($objTextComment->CommentText, 0, 124) . '...' : $objTextComment->CommentText, $strContextLink); $objItem->Description = $strDescription; $objItem->PubDate = new QDateTime($objTextComment->Created); $objItem->Author = $objTextComment->User->RealName; /** * Damn Google Reader doesn't care about PubDate, so we need this */ $objItem->Guid = NarroString::HtmlEntities($strContextLink);
public function dtgUserRole_RoleColumn_Render(NarroUserRole $objUserRole) { return NarroLink::RoleList($objUserRole->RoleId, 'user', $objUserRole->Role->RoleName); }
public function btnDelete_Click($strFormId, $strControlId, $strParameter) { if (!QApplication::HasPermission('Can delete project', $this->objProject->ProjectId)) { QApplication::Redirect(NarroLink::ProjectList()); } $objDatabase = QApplication::$Database[1]; try { $strQuery = sprintf("DELETE FROM narro_context_info USING narro_context_info LEFT JOIN narro_context ON narro_context_info.context_id=narro_context.context_id WHERE narro_context_info.language_id=%d AND narro_context.project_id=%d", QApplication::GetLanguageId(), $this->objProject->ProjectId); $objDatabase->NonQuery($strQuery); $strQuery = sprintf("DELETE FROM `narro_context` WHERE project_id = %d", $this->objProject->ProjectId); $objDatabase->NonQuery($strQuery); $strQuery = sprintf("DELETE FROM `narro_file` WHERE project_id = %d", $this->objProject->ProjectId); $objDatabase->NonQuery($strQuery); $strQuery = sprintf("DELETE FROM `narro_user_role` WHERE project_id = %d", $this->objProject->ProjectId); $objDatabase->NonQuery($strQuery); $intProjectId = $this->objProject->ProjectId; $this->objProject->Delete(); NarroUtils::RecursiveDelete(__IMPORT_PATH__ . '/' . $intProjectId); NarroUtils::RecursiveDelete(sprintf('%s/project-%d-hg', __NARRO_DATA__ . '/mozilla-build', $intProjectId)); NarroUtils::RecursiveDelete(sprintf('%s/project-%d-obj', __NARRO_DATA__ . '/mozilla-build', $intProjectId)); } catch (Exception $objEx) { $this->lblMessage->Text = $objEx->getMessage(); return false; } QApplication::Redirect(NarroLink::ProjectList()); }
public function btnBrowserIdLogin_Click($strFormId, $strControlId, $strAssertion) { // open connection $ch = curl_init(); // set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, 'https://browserid.org/verify'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 2); curl_setopt($ch, CURLOPT_POSTFIELDS, sprintf('assertion=%s&audience=%s', $strAssertion, __HTTP_URL__)); // execute post $result = json_decode(curl_exec($ch)); // close connection curl_close($ch); if ($result && property_exists($result, 'status') && $result->status == 'okay') { $objUser = NarroUser::LoadByUsername($result->email); if (!$objUser instanceof NarroUser) { try { $objUser = NarroUser::RegisterUser($result->email, $result->email, '', $result->email); } catch (Exception $objEx) { $this->lblMessage->ForeColor = 'red'; $this->lblMessage->Text = sprintf(t('Failed to create an associated user for the email address "%s": %s'), $result->email, $objEx->getMessage()); return false; } $objUser->Reload(); QApplication::$Session->User = $objUser; QApplication::Redirect(NarroLink::UserPreferences($objUser->UserId)); exit; } elseif ($objUser->Password != $objHasher->HashPassword('')) { $this->lblMessage->ForeColor = 'red'; $this->lblMessage->Text = t('This user has a password set, please login with that instead'); return false; } QApplication::$Session->RegenerateId(); QApplication::$Session->User = $objUser; QApplication::$User = $objUser; if ($this->txtPreviousUrl) { $strUrl = preg_replace('/([\\?\\&]l\\=)[a-z0-9\\-\\_]+/', '\\1' . QApplication::$User->GetPreferenceValueByName('Language'), $this->txtPreviousUrl); if ($strUrl) { QApplication::Redirect($strUrl); } else { QApplication::Redirect($this->txtPreviousUrl); } } else { QApplication::Redirect(NarroLink::ProjectList(null, null, QApplication::$User->GetPreferenceValueByName('Language'))); } exit; } else { $this->lblMessage->Text = t('BrowserID login failed'); $this->lblMessage->ForeColor = 'red'; } }
protected function Form_Create() { parent::Form_Create(); if (!QApplication::HasPermissionForThisLang('Administrator')) { QApplication::Redirect(NarroLink::ProjectList()); } $this->pnlTab = new QTabs($this); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::ProjectList(t('Projects')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::Review(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Review')); if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) { $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::LanguageList(t('Languages')); } $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::UserList('', t('Users')); $pnlDummy = new QPanel($this->pnlTab); $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles')); if (QApplication::HasPermissionForThisLang('Administrator')) { $this->pnlLog = new QPanel($this->pnlTab); $this->pnlLog->AutoRenderChildren = true; $btnClearLog = new QButton($this->pnlLog); $btnClearLog->Text = t('Clear the log'); $btnClearLog->AddAction(new QClickEvent(), new QConfirmAction(t('Are you sure you want to delete all the logged messages?'))); $btnClearLog->AddAction(new QClickEvent(), new QAjaxAction('btnClearLog_Click')); $this->dtgLog = new NarroLogDataGrid($this->pnlLog); // Datagrid Paginator $this->dtgLog->Paginator = new QPaginator($this->dtgLog); $this->dtgLog->PaginatorAlternate = new QPaginator($this->dtgLog); $this->dtgLog->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page'); $this->dtgLog->SortColumnIndex = 0; $this->dtgLog->SortDirection = 1; $colDate = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Date); $colDate->OrderByClause = QQ::OrderBy(QQN::NarroLog()->LogId); $colDate->ReverseOrderByClause = QQ::OrderBy(QQN::NarroLog()->LogId, 0); if (QApplication::HasPermission('Administrator')) { $colLanguage = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Language->LanguageName); $colLanguage->Filter = null; $colLanguage->FilterAddListItem(t('-Not set-'), QQ::IsNull(QQN::NarroLog()->LanguageId)); foreach (NarroLanguage::LoadAll(QQ::OrderBy(QQN::NarroLanguage()->LanguageName)) as $objLanguage) { $colLanguage->FilterAddListItem($objLanguage->LanguageName, QQ::Equal(QQN::NarroLog()->LanguageId, $objLanguage->LanguageId)); } } else { $this->dtgLog->AdditionalConditions = QQ::Equal(QQN::NarroLog()->LanguageId, QApplication::GetLanguageId()); } $colProject = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Project->ProjectName); $colProject->Filter = null; $colProject->FilterAddListItem(t('-Not set-'), QQ::IsNull(QQN::NarroLog()->ProjectId)); foreach (NarroProject::LoadAll(QQ::OrderBy(QQN::NarroProject()->ProjectName)) as $objProject) { $colProject->FilterAddListItem($objProject->ProjectName, QQ::Equal(QQN::NarroLog()->ProjectId, $objProject->ProjectId)); } $colUser = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->User->Username); $colUser->Html = '<?=(($_ITEM->UserId)?NarroLink::UserProfile($_ITEM->UserId, $_ITEM->User->Username):"")?>'; $colUser->HtmlEntities = false; $colPriority = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Priority); $colPriority->Name = 'P'; $colPriority->Width = 16; $colPriority->FilterBoxSize = 1; $colPriority->HtmlEntities = false; $colMessage = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Message); $colMessage->HtmlEntities = false; $colMessage->Html = '<?=$_FORM->dtgLog_colMessage_Render($_ITEM)?>'; $arrHeaders[] = NarroLink::Log('', t('Application Log')); $this->pnlTab->Selected = count($arrHeaders) - 1; } $this->pnlTab->Headers = $arrHeaders; }
public function dtgUser_ActionsColumn_Render(NarroUser $objUser) { return NarroLink::UserRole($objUser->UserId, t('Roles')); }
public function btnSearch_Click() { QApplication::Redirect(NarroLink::ProjectFileList($this->objProject->ProjectId, $this->objParentFile instanceof NarroFile ? $this->objParentFile->FilePath : '', $this->txtSearch->Text)); }
public function btnDelete_Click($strFormId, $strControlId, $strParameter) { if (QApplication::HasPermissionForThisLang('Can delete language', null)) { $this->objNarroLanguage->Delete(); } QApplication::Redirect(NarroLink::LanguageList()); }
public function btnAdd_Click($strFormId, $strControlId, $strParameter) { QApplication::Redirect(NarroLink::ProjectEdit(0)); }
protected function IsSuggestionUsed($objSuggestion) { if (NarroContextInfo::QueryCount(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->File->Active, true), QQ::Equal(QQN::NarroContextInfo()->Context->Active, true), QQ::Equal(QQN::NarroContextInfo()->ValidSuggestionId, $objSuggestion->SuggestionId)))) { $strLink = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_APPROVED, "'" . $objSuggestion->Text->TextValue . "'", 0, 1, 30, 0, 0, ''); $this->lblText->Warning = sprintf(t('This translation was already approved somewhere.<br />If you still want to delete it, click <a href="%s" target="_blank">here</a> to edit all the texts that use it or %s'), $strLink, ''); return true; } /** elseif ($intVoteCount = NarroSuggestionVote::QueryCount(QQ::AndCondition(QQ::Equal(QQN::NarroSuggestionVote()->SuggestionId, $strSuggestionId), QQ::NotEqual(QQN::NarroSuggestionVote()->UserId, QApplication::GetUserId())))) { $this->lblMessage->ForeColor = 'red'; $this->lblMessage->Text = sprintf(t('You cannot alter this suggestion because it has %d vote(s).'), $intVoteCount); $this->MarkAsModified(); return true; } */ return false; }
public function btnDelete_Click($strFormId, $strControlId, $strParameter) { if (QApplication::HasPermission('Can manage users')) { $this->objNarroUser->Delete(); QApplication::Redirect(NarroLink::UserList('')); } }