예제 #1
0
파일: account.php 프로젝트: Jobava/narro
 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;
 }
예제 #2
0
 public function dtgUser_RealNameColumn_Render(NarroUser $objUser)
 {
     if ($objUser->UserId == NarroUser::ANONYMOUS_USER_ID) {
         return t('Anonymous');
     } else {
         return NarroLink::UserProfile($objUser->UserId, $objUser->RealName);
     }
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
 public function dtgTranslation_colAuthor_Render(NarroSuggestion $objSuggestion)
 {
     $objDateSpan = new QDateTimeSpan(time() - strtotime($objSuggestion->Created));
     $strModifiedWhen = $objDateSpan->SimpleDisplay();
     if (strtotime($objSuggestion->Modified) > 0 && $strModifiedWhen && $objSuggestion->User->RealName) {
         $strAuthorInfo = sprintf($objSuggestion->IsImported ? t('imported by <a href="%s" tabindex="-1">%s</a>, %s ago') : t('<a href="%s" tabindex="-1">%s</a>, %s ago'), NarroLink::UserProfile($objSuggestion->User->UserId), $objSuggestion->User->RealName, $strModifiedWhen);
     } elseif (strtotime($objSuggestion->Modified) > 0 && $strModifiedWhen && !$objSuggestion->User->RealName) {
         $strAuthorInfo = sprintf(t('%s ago'), $strModifiedWhen);
     } elseif ($objSuggestion->User) {
         $strAuthorInfo = sprintf($objSuggestion->IsImported ? t('imported by <a href="%s" tabindex="-1">%s</a>') : '<a href="%s" tabindex="-1">%s</a>', NarroLink::UserProfile($objSuggestion->User->UserId), $objSuggestion->User->RealName);
     } else {
         $strAuthorInfo = t('Unknown');
     }
     if ($objSuggestion->SuggestionId == $this->objContextInfo->ValidSuggestionId && $this->objContextInfo->ValidatorUserId != NarroUser::ANONYMOUS_USER_ID) {
         $objDateSpan = new QDateTimeSpan(time() - strtotime($this->objContextInfo->Modified));
         $strModifiedWhen = $objDateSpan->SimpleDisplay();
         $strAuthorInfo .= ', ' . sprintf(sprintf(t('approved by <a href="%s" tabindex="-1">%s</a>'), NarroLink::UserProfile($this->objContextInfo->ValidatorUser->UserId), $this->objContextInfo->ValidatorUser->RealName . ' %s'), $objDateSpan->SimpleDisplay() ? sprintf(t('%s ago'), $objDateSpan->SimpleDisplay()) : '');
     }
     return sprintf('<small>-- %s, %s</small>', $strAuthorInfo, sprintf(t('%d votes'), $objSuggestion->Votes));
 }
예제 #5
0
 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());
 }
예제 #6
0
 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'));
 }
예제 #7
0
파일: rss.php 프로젝트: Jobava/narro
 $objDbResult = $objDatabase->Query($strSqlQuery);
 if ($objDbResult) {
     $arrTextComment = NarroTextComment::InstantiateDbResult($objDbResult);
     foreach ($arrTextComment as $objTextComment) {
         if (isset($objProject) && $objProject instanceof NarroProject) {
             $arrContext = NarroContext::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContext()->ProjectId, $objProject->ProjectId), QQ::Equal(QQN::NarroContext()->TextId, $objTextComment->TextId), QQ::Equal(QQN::NarroContext()->Active, 1)));
         } else {
             $arrContext = NarroContext::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContext()->TextId, $objTextComment->TextId), QQ::Equal(QQN::NarroContext()->Active, 1)));
         }
         if (count($arrContext)) {
             $arrProjectLinks = array();
             $arrProjects = array();
             $strDescription = sprintf('
                     <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);
                 }
예제 #8
0
<?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));
}