public function DisplayInProjectListInProgressColumn(NarroProject $objProject, $strText = '')
 {
     $strExportText = '';
     if ($objProject->ProjectType != NarroProjectType::Mozilla) {
         return array($objProject, '');
     }
     $objCache = new NarroCache(__CLASS__, QApplication::GetLanguageId());
     $objData = $objCache->GetData();
     if (!$objData) {
         $strJson = @file_get_contents($this->strUrl);
         if ($strJson) {
             $objData = json_decode($strJson);
             if ($objData) {
                 $objCache->SaveData($objData);
             }
         }
     }
     if (is_array($objData->items)) {
         foreach ($objData->items as $objItem) {
             if ($objItem->id == sprintf('%s/%s', $objProject->GetPreferenceValueByName('Code name on mozilla l10n dashboard'), QApplication::$TargetLanguage->LanguageCode)) {
                 $strWarning = $objItem->warnings ? sprintf('%d warnings', $objItem->warnings) : '';
                 $strMissing = $objItem->missing ? sprintf('%d missing', $objItem->missing) : '';
                 $strExportText = sprintf('<a title="Visit the Mozilla l10n dashboard" target="_blank" href="https://l10n-stage-sj.mozilla.org/dashboard/compare?run=%d">%s</a>', $objItem->runid, join(', ', array($objItem->result, $strMissing, $strWarning)));
                 break;
             }
         }
     }
     return array($objProject, $strExportText);
 }
Example #2
0
 public function DisplayInProjectListInProgressColumn(NarroProject $objProject, $strText = '')
 {
     $strExportText = '';
     $objCache = new NarroCache(QApplication::GetLanguageId() . '/' . $objProject->ProjectId, __CLASS__);
     $arrData = $objCache->GetData();
     switch ($objProject->ProjectName) {
         case 'Fennec Aurora':
             if ($arrData) {
                 return $arrData;
             }
             // set up basic connection
             $conn_id = ftp_connect('ftp.mozilla.org');
             // login with username and password
             $login_result = ftp_login($conn_id, 'anonymous', '*****@*****.**');
             // get contents of the current directory
             $contents = ftp_nlist($conn_id, "/pub/mobile/nightly/latest-mozilla-aurora-linux-l10n");
             if (is_array($contents)) {
                 foreach ($contents as $strFile) {
                     if (preg_match('/\\/fennec\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.linux\\-i686\\.tar\\.bz2$/', $strFile, $arrMatches)) {
                         $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                         $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">linux i686</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                     }
                 }
             }
             $contents = ftp_nlist($conn_id, "/pub/mobile/nightly/latest-mozilla-aurora-win32-l10n");
             if (is_array($contents)) {
                 foreach ($contents as $strFile) {
                     if (preg_match('/\\/fennec\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.win32\\.zip$/', $strFile, $arrMatches)) {
                         $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                         $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">win32</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                     }
                 }
             }
             $contents = ftp_nlist($conn_id, "/pub/mobile/nightly/latest-mozilla-aurora-macosx-l10n");
             if (is_array($contents)) {
                 foreach ($contents as $strFile) {
                     if (preg_match('/\\/fennec\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.mac\\.dmg$/', $strFile, $arrMatches)) {
                         $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                         $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">mac</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                     }
                 }
             }
             $contents = ftp_nlist($conn_id, "/pub/mobile/nightly/latest-mozilla-aurora-android");
             if (is_array($contents)) {
                 foreach ($contents as $strFile) {
                     if (preg_match('/\\/fennec\\-(.*)\\.multi\\.android\\-arm\\.apk$/', $strFile, $arrMatches)) {
                         $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                         $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">android</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                     }
                 }
             }
             $strLinks = join(', ', $arrLink);
             if ($strLinks != '') {
                 $arrData = array($objProject, sprintf('nightly: %s', $strLinks));
                 $objCache->SaveData($arrData);
                 return $arrData;
             } else {
                 return array($objProject, '');
             }
         case 'Firefox Aurora':
             if ($arrData) {
                 return $arrData;
             }
             // set up basic connection
             $conn_id = ftp_connect('ftp.mozilla.org');
             // login with username and password
             $login_result = ftp_login($conn_id, 'anonymous', '*****@*****.**');
             // get contents of the current directory
             $contents = ftp_nlist($conn_id, "/pub/firefox/nightly/latest-mozilla-aurora-l10n/");
             if (is_array($contents)) {
                 foreach ($contents as $strFile) {
                     if (preg_match('/\\/firefox\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.linux\\-i686\\.tar\\.bz2$/', $strFile, $arrMatches)) {
                         $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                         $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">linux i686</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                     }
                 }
                 foreach ($contents as $strFile) {
                     if (preg_match('/\\/firefox\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.linux\\-x86\\_64\\.tar\\.bz2$/', $strFile, $arrMatches)) {
                         $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                         $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">linux x86_64</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                     }
                 }
                 foreach ($contents as $strFile) {
                     if (preg_match('/\\/firefox\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.win32\\.zip$/', $strFile, $arrMatches)) {
                         $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                         $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">win32</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                     }
                 }
                 foreach ($contents as $strFile) {
                     if (preg_match('/\\/firefox\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.mac\\.dmg$/', $strFile, $arrMatches)) {
                         $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                         $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">mac</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                     }
                 }
             }
             $strLinks = join(', ', $arrLink);
             if ($strLinks != '') {
                 $arrData = array($objProject, sprintf('nightly: %s', $strLinks));
                 $objCache->SaveData($arrData);
                 return $arrData;
             } else {
                 return array($objProject, '');
             }
         case 'Thunderbird Aurora':
             $strCacheId = __CLASS__ . QApplication::GetLanguageId() . 'p' . $objProject->ProjectId;
             if ($arrData) {
                 return $arrData;
             }
             // set up basic connection
             $conn_id = ftp_connect('ftp.mozilla.org');
             // login with username and password
             $login_result = ftp_login($conn_id, 'anonymous', '*****@*****.**');
             // get contents of the current directory
             $contents = ftp_nlist($conn_id, "/pub/thunderbird/nightly/latest-comm-aurora-l10n/");
             foreach ($contents as $strFile) {
                 if (preg_match('/\\/thunderbird\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.linux\\-i686\\.tar\\.bz2$/', $strFile, $arrMatches)) {
                     $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                     $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">linux i686</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                 }
             }
             foreach ($contents as $strFile) {
                 if (preg_match('/\\/thunderbird\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.linux\\-x86\\_64\\.tar\\.bz2$/', $strFile, $arrMatches)) {
                     $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                     $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">linux x86_64</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                 }
             }
             foreach ($contents as $strFile) {
                 if (preg_match('/\\/thunderbird\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.win32\\.zip$/', $strFile, $arrMatches)) {
                     $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                     $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">win32</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                 }
             }
             foreach ($contents as $strFile) {
                 if (preg_match('/\\/thunderbird\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.mac\\.dmg$/', $strFile, $arrMatches)) {
                     $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile));
                     $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">mac</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile);
                 }
             }
             $strLinks = join(', ', $arrLink);
             if ($strLinks != '') {
                 $arrData = array($objProject, sprintf('nightly: %s', $strLinks));
                 $objCache->SaveData($arrData);
                 return $arrData;
             } else {
                 return array($objProject, '');
             }
         default:
             return array($objProject, '');
     }
 }
Example #3
0
 public static function LoadAnonymousUser()
 {
     $objCache = new NarroCache('user', self::ANONYMOUS_USER_ID);
     $objUser = $objCache->GetData();
     if (!$objUser instanceof NarroUser) {
         $objUser = NarroUser::LoadByUserId(self::ANONYMOUS_USER_ID);
         $arrUserRole = NarroUserRole::LoadArrayByUserId(self::ANONYMOUS_USER_ID);
         foreach ($arrUserRole as $objRole) {
             $arrRolePermission = NarroRolePermission::LoadArrayByRoleId($objRole->RoleId);
             foreach ($arrRolePermission as $objRolePermission) {
                 $objUser->arrPermissions[$objRolePermission->Permission->PermissionName . '-' . $objRole->LanguageId . '-' . $objRole->ProjectId] = $objRolePermission;
             }
         }
         $objCache->SaveData($objUser);
     }
     return $objUser;
 }
Example #4
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
 */
require_once dirname(__FILE__) . '/configuration/prepend.inc.php';
NarroCache::Reset();
if ($_SERVER['HTTP_REFERER']) {
    header('Location: ' . $_SERVER['HTTP_REFERER']);
} else {
    echo 'Cache successfully reset.';
}