From 36ee5561035af335bc3c900ded7aa89066421226 Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Tue, 24 Jun 2008 02:53:16 -0400 Subject: Move code out of index.php Move database queries to functions and html to templates. Signed-off-by: Loui Chang --- web/html/index.php | 182 +++-------------------------------------------------- 1 file changed, 10 insertions(+), 172 deletions(-) (limited to 'web/html') diff --git a/web/html/index.php b/web/html/index.php index 7a95abf..ce5e009 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -5,66 +5,13 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR # Add to handle the i18n of My Packages include("pkgfuncs_po.inc"); include("aur.inc"); +include('stats.inc'); set_lang(); check_sid(); html_header( __("Home") ); - -# Newest packages -$q = "SELECT * FROM Packages WHERE DummyPkg != 1 ORDER BY GREATEST(SubmittedTS,ModifiedTS) DESC LIMIT 0 , 10"; -$newest_packages = db_query($q, $dbh); - -# AUR statistics -$q = "SELECT count(*) FROM Packages,PackageLocations WHERE Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'unsupported'"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$unsupported_count = $row[0]; - -$q = "SELECT count(*) FROM Packages,PackageLocations WHERE Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'community'"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$community_count = $row[0]; - -$q = "SELECT count(*) from Users"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$user_count = $row[0]; - -$q = "SELECT count(*) from Users,AccountTypes WHERE Users.AccountTypeID = AccountTypes.ID AND AccountTypes.AccountType = 'Trusted User'"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$tu_count = $row[0]; - -$targstamp = intval(strtotime("-7 days")); -$q = "SELECT count(*) from Packages WHERE (Packages.SubmittedTS >= $targstamp OR Packages.ModifiedTS >= $targstamp)"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$update_count = $row[0]; - -$user = username_from_sid($_COOKIE["AURSID"]); - -if (!empty($user)) { - $q = "SELECT count(*) FROM Packages,PackageLocations,Users WHERE Packages.MaintainerUID = Users.ID AND Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'unsupported' AND Users.Username='".mysql_real_escape_string($user)."'"; - $result = db_query($q, $dbh); - $row = mysql_fetch_row($result); - $maintainer_unsupported_count = $row[0]; - - $q = "SELECT count(*) FROM Packages,Users WHERE Packages.OutOfDate = 1 AND Packages.MaintainerUID = Users.ID AND Users.Username='".mysql_real_escape_string($user)."'"; - $result = db_query($q, $dbh); - $row = mysql_fetch_row($result); - $flagged_outdated = $row[0]; - - # If the user is a TU calculate the number of the packages - $atype = account_from_sid($_COOKIE["AURSID"]); - - if ($atype == 'Trusted User') { - $q = "SELECT count(*) FROM Packages,PackageLocations,Users WHERE Packages.MaintainerUID = Users.ID AND Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'community' AND Users.Username='".mysql_real_escape_string($user)."'"; - $result = db_query($q, $dbh); - $row = mysql_fetch_row($result); - $maintainer_community_count = $row[0]; - } -} +$dbh = db_connect(); ?> @@ -106,127 +53,19 @@ print __( 'Contributed PKGBUILDs must conform to the %hArch Packaging Sta - - - - - - - - - - - - - - - - -
- -
-"> - - + - + '; +} -if ($mod_int != 0): - $modstring = gmdate("r", $mod_int); -elseif ($sub_int != 0): - $modstring = ' ' . gmdate("r", $sub_int); -else: - $modstring = '(unknown)'; -endif; +general_stats_table($dbh); ?> - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - -
- - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
@@ -236,4 +75,3 @@ endif; -- cgit v1.2.3-54-g00ecf From 5528501497af781ff9d05e3110aa5e1b78fb71bf Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Mon, 30 Jun 2008 00:12:59 +0800 Subject: Redirect on package submission On a successful package submit there will be a redirect to the package details page of the packages, no more successful message Also got rid of the $warning stuff, what the hell was that for? Signed-off-by: Callan Barrett Signed-off-by: Loui Chang --- web/html/pkgsubmit.php | 50 +++++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 33 deletions(-) (limited to 'web/html') diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 4d15ebe..0d245b8 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -1,28 +1,15 @@ - -
-
- -
-
- - + +
+
+ +
+
+

- - -

-
- - -
-
- - Date: Wed, 9 Jul 2008 14:56:15 -0400 Subject: Change some of the index page notices. Signed-off-by: Loui Chang --- web/html/css/fonts.css | 6 +++++- web/html/index.php | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'web/html') diff --git a/web/html/css/fonts.css b/web/html/css/fonts.css index dc65070..baa7560 100644 --- a/web/html/css/fonts.css +++ b/web/html/css/fonts.css @@ -99,5 +99,9 @@ a:hover { h1, h2, h3, h4 { font-size: 16pt; } -span.important { color: #f00; } + +.important { + font-weight: bold; + color: #f00; +} diff --git a/web/html/index.php b/web/html/index.php index ce5e009..f5e10ee 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -46,8 +46,8 @@ print __( 'Contributed PKGBUILDs must conform to the %hArch Packaging Sta

-
- +
+

@@ -69,7 +69,12 @@ general_stats_table($dbh); -
+ +
'; +echo __('Unsupported PKGBUILDs are user produced content. Any use of files is at your own risk.'); +?>
+
-- cgit v1.2.3-54-g00ecf From b81e3c2f6814e73973b4d42e66b1d0e58c2943d2 Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Wed, 23 Jul 2008 10:07:53 -0400 Subject: Tweak index.php and update translations. Signed-off-by: Loui Chang --- web/html/index.php | 31 ++++++++++++++++--------------- web/lang/ca/index_po.inc | 3 +-- web/lang/de/index_po.inc | 2 +- web/lang/es/index_po.inc | 2 +- web/lang/fr/index_po.inc | 2 +- web/lang/it/index_po.inc | 4 +--- web/lang/pl/index_po.inc | 5 ++--- web/lang/pt/index_po.inc | 5 +---- web/lang/ru/index_po.inc | 3 +-- 9 files changed, 25 insertions(+), 32 deletions(-) (limited to 'web/html') diff --git a/web/html/index.php b/web/html/index.php index f5e10ee..c7847f2 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -20,37 +20,36 @@ $dbh = db_connect(); AUR
- - - - +

' - , '' - , '' - , '' +echo __( + 'Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information.', + '', + '', + '', + '' ); ?> -
+
must conform to the %hArch Packaging Standards%h otherwise they will be deleted!' - , '' - , '' +echo __( + 'Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!', + '', '', + '', + '' ); ?>

- +

-
@@ -70,6 +69,7 @@ general_stats_table($dbh);
+
'; echo __('Unsupported PKGBUILDs are user produced content. Any use of files is at your own risk.'); @@ -80,3 +80,4 @@ echo __('Unsupported PKGBUILDs are user produced content. Any use of files is at must conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Els PKGBUILDs enviats han de seguir els %hEstàndards d'empaquetament d'Arch%h sinó seran esborrats!"; +$_t["ca"]["Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Els PKGBUILDs enviats %hhan%h de seguir els %hEstàndards d'empaquetament d'Arch%h sinó seran esborrats!"; $_t["ca"]["Login"] = "Entra"; @@ -55,4 +55,3 @@ $_t["ca"]["Logged-in as: %h%s%h"] = "Identificat com: %h%s%h"; $_t["ca"]["Incorrect password for username, %s."] = "Contrasenya incorrecta per a l'usuari, %s."; -?> diff --git a/web/lang/de/index_po.inc b/web/lang/de/index_po.inc index 1b55775..377a669 100644 --- a/web/lang/de/index_po.inc +++ b/web/lang/de/index_po.inc @@ -39,7 +39,7 @@ $_t["de"]["Error trying to generate session id."] = "Fehler beim Erstellen der S $_t["de"]["Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information."] = "Willkommen beim AUR! Für weitergehende Informationen lies bitte das %hAUR Benutzerhandbuch%h und die %hAUR TU Richtlinien%h."; -$_t["de"]["Contributed PKGBUILDs must conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Deine PKGBUILDs müssen dem %hArch Paket Standard%h entsprechen. Andernfalls werden sie gelöscht!"; +$_t["de"]["Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Deine PKGBUILDs %hmüssen%h dem %hArch Paket Standard%h entsprechen. Andernfalls werden sie gelöscht!"; $_t["de"]["Login"] = "Anmelden"; diff --git a/web/lang/es/index_po.inc b/web/lang/es/index_po.inc index 77e5ee9..821c09d 100644 --- a/web/lang/es/index_po.inc +++ b/web/lang/es/index_po.inc @@ -39,7 +39,7 @@ $_t["es"]["Error trying to generate session id."] = "Error al intentar crear un $_t["es"]["Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information."] = "¡Bienvenido al AUR! Por favor lea la %hGuía AUR del Usuario%h y la %hGuía TU del AUR%h para más información."; -$_t["es"]["Contributed PKGBUILDs must conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "¡Los PKGBUILDS enviados deben cumplir las %hNormas de empaquetado de Arch%h sino serán eliminados!"; +$_t["es"]["Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "¡Los PKGBUILDS enviados %hdeben%h cumplir las %hNormas de empaquetado de Arch%h sino serán eliminados!"; $_t["es"]["Login"] = "Entrar"; diff --git a/web/lang/fr/index_po.inc b/web/lang/fr/index_po.inc index 7c67bf4..3e522a2 100644 --- a/web/lang/fr/index_po.inc +++ b/web/lang/fr/index_po.inc @@ -40,7 +40,7 @@ $_t["fr"]["Error trying to generate session id."] = "Erreur en essayant de gén $_t["fr"]["Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information."] = "Bienvenue sur AUR ! Lisez, s'il vous plaît, le %hGuide Utilisateur AUR%h et le %hGuide des Utilisateurs de Confiance%h pour plus d'informations."; -$_t["fr"]["Contributed PKGBUILDs must conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Les PKGBUILDs proposés doivent se conformer aux %hStandards de l'empaquetage Arch%h sans quoi ils seront supprimés!"; +$_t["fr"]["Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Les PKGBUILDs proposés %hdoivent%h se conformer aux %hStandards de l'empaquetage Arch%h sans quoi ils seront supprimés!"; $_t["fr"]["Login"] = "Se connecter"; diff --git a/web/lang/it/index_po.inc b/web/lang/it/index_po.inc index 6619d94..1770470 100644 --- a/web/lang/it/index_po.inc +++ b/web/lang/it/index_po.inc @@ -45,8 +45,6 @@ $_t["it"]["Email discussion about the AUR takes place on the %sTUR Users List%s. $_t["it"]["Recent Updates"] = "Aggiornamenti recenti"; -$_t["it"]["Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information. Contributed PKGBUILDs must conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Benvenuto in AUR! Per ottenere maggiori informazioni, leggi le %hAUR User Guidelines%h e %hAUR TU Guidelines%h. I PKGBUILD inviati devono essere conformi agli %hArch Packaging Standards%h altrimenti saranno cancellati!"; - $_t["it"]["Community"] = "Community"; $_t["it"]["Package Counts"] = "Conteggio dei pacchetti"; @@ -55,7 +53,7 @@ $_t["it"]["Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR $_t["it"]["Unsupported"] = "Unsupported"; -$_t["it"]["Contributed PKGBUILDs must conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "I PKGBUILD inviati devono essere conformi agli %hArch Packaging Standards%h altrimenti saranno cancellati!"; +$_t["it"]["Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "I PKGBUILD inviati %hdevono%h essere conformi agli %hArch Packaging Standards%h altrimenti saranno cancellati!"; $_t["it"]["Statistics"] = "Statistiche"; diff --git a/web/lang/pl/index_po.inc b/web/lang/pl/index_po.inc index a93c690..889a841 100644 --- a/web/lang/pl/index_po.inc +++ b/web/lang/pl/index_po.inc @@ -24,7 +24,7 @@ $_t["pl"]["You must supply an email address."] = "Musisz podać adres e-mail."; $_t["pl"]["Incorrect password for email address, %s."] = "Nieprawidłowe hasło dla adresu %s."; $_t["pl"]["Incorrect password for username, %s."] = "Nieprawidłowe hasło dla użytkownika %s."; $_t["pl"]["Logged in as: %h%s%h"] = "Zalogowany jako: %h%s%h"; -$_t["pl"]["Logged-in as: %h%s%h"] = "Zalogowany jako: %h%s%h"; + $_t["pl"]["Error looking up username, %s."] = "Błąd podczas wyszukiwania użytkownika %s."; $_t["pl"]["Welcome to the AUR! If you're a newcomer, you may want to read the %hGuidelines%h."] = "Witamy w AUR! Jeżeli jesteś tu po raz pierwszy, być może zechcesz przeczytać %hInstrukcję%h."; $_t["pl"]["If you have feedback about the AUR, please leave it in %hFlyspray%h."] = "Jeżeli masz uwagi lub pomysły odnośnie AUR, %hFlyspray%h jest odpowiednim miejscem do ich pozostawienia."; @@ -52,7 +52,7 @@ $_t["pl"]["Packages in [community]"] = "Pakietów w [community]"; $_t["pl"]["Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information."] = "Witamy w AUR! Aby uzyskać więcej informacji, przeczytaj %hInstrukcję Użytkownika%h oraz %hInstrukcję Zaufanego Użytkownika%h."; -$_t["pl"]["Contributed PKGBUILDs must conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Pliki PKGBUILD muszą być zgodne ze %hStandardami Pakietów Archa%h, inaczej będą usuwane!"; +$_t["pl"]["Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Pliki PKGBUILD %hmuszą%h być zgodne ze %hStandardami Pakietów Archa%h, inaczej będą usuwane!"; $_t["pl"]["Registered Users"] = "Zarejestrowanych użytkowników"; @@ -72,4 +72,3 @@ $_t["pl"]["Home"] = "Start"; $_t["pl"]["DISCLAIMER"] = "ZRZECZENIE"; -?> \ No newline at end of file diff --git a/web/lang/pt/index_po.inc b/web/lang/pt/index_po.inc index 7fe4283..66de424 100644 --- a/web/lang/pt/index_po.inc +++ b/web/lang/pt/index_po.inc @@ -53,8 +53,6 @@ $_t["pt"]["Email discussion about the AUR takes place on the %sTUR Users List%s. $_t["pt"]["Recent Updates"] = "Atualizações Recentes"; -$_t["pt"]["Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information. Contributed PKGBUILDs must conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Bem-vindo ao AUR! Por favor leia as %hregras de usuário do AUR%h e as %hregras de TU do AUR%h para maiores informações.PKGBUILDs contribuídos devem seguir os %hpadrões Arch de Empacotamento%h caso contrário, eles serão excluídos!"; - $_t["pt"]["Community"] = "Comunidade"; $_t["pt"]["Package Counts"] = "Contagem de Pacotes"; @@ -63,7 +61,7 @@ $_t["pt"]["Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR $_t["pt"]["Unsupported"] = "Sem Suporte"; -$_t["pt"]["Contributed PKGBUILDs must conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "PKGBUILDs contribuídos devem seguir os %hpadrões Arch de Empacotamento%h caso contrário, eles serão excluídos!"; +$_t["pt"]["Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "PKGBUILDs contribuídos %hdevem%h seguir os %hpadrões Arch de Empacotamento%h caso contrário, eles serão excluídos!"; $_t["pt"]["Statistics"] = "Estatísticas"; @@ -93,4 +91,3 @@ $_t["pt"]["My Statistics"] = "Minhas Estatísticas"; $_t["pt"]["Flagged as safe by me"] = "Pacotes que marquei como seguros"; -?> \ No newline at end of file diff --git a/web/lang/ru/index_po.inc b/web/lang/ru/index_po.inc index 45b2d40..1a464a0 100644 --- a/web/lang/ru/index_po.inc +++ b/web/lang/ru/index_po.inc @@ -39,7 +39,7 @@ $_t["ru"]["Error trying to generate session id."] = "Ошибка генерац $_t["ru"]["Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information."] = "Добро пожаловать в AUR! Пожалуйста прочитайте %hAUR User Guidelines%h и %hAUR TU Guidelines%h, чтобы получить больше информации."; -$_t["ru"]["Contributed PKGBUILDs must conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Присланые PKGBUILD должны соответствовать %hArch Packaging Standards%h или будут удалены!"; +$_t["ru"]["Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!"] = "Присланые PKGBUILD %hдолжны%h соответствовать %hArch Packaging Standards%h или будут удалены!"; $_t["ru"]["Login"] = "Войти"; @@ -69,4 +69,3 @@ $_t["ru"]["My Statistics"] = "Моя статистика"; $_t["ru"]["Home"] = "Заглавная страница"; -?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf From bbebc08104032da5ca3a218d58b2cadc5501f16c Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Tue, 19 Aug 2008 15:46:03 -0400 Subject: Remove obsolete test scripts. Signed-off-by: Loui Chang --- web/html/testpo.php | 45 --------------------------------------------- web/lang/ca/test_po.inc | 16 ---------------- web/lang/de/test_po.inc | 16 ---------------- web/lang/en/test_po.inc | 22 ---------------------- web/lang/es/test_po.inc | 16 ---------------- web/lang/fr/test_po.inc | 17 ----------------- web/lang/it/test_po.inc | 16 ---------------- web/lang/pl/test_po.inc | 13 ------------- web/lang/pt/test_po.inc | 22 ---------------------- web/lang/ru/test_po.inc | 16 ---------------- web/lang/test_po.inc | 32 -------------------------------- 11 files changed, 231 deletions(-) delete mode 100644 web/html/testpo.php delete mode 100644 web/lang/ca/test_po.inc delete mode 100644 web/lang/de/test_po.inc delete mode 100644 web/lang/en/test_po.inc delete mode 100644 web/lang/es/test_po.inc delete mode 100644 web/lang/fr/test_po.inc delete mode 100644 web/lang/it/test_po.inc delete mode 100644 web/lang/pl/test_po.inc delete mode 100644 web/lang/pt/test_po.inc delete mode 100644 web/lang/ru/test_po.inc delete mode 100644 web/lang/test_po.inc (limited to 'web/html') diff --git a/web/html/testpo.php b/web/html/testpo.php deleted file mode 100644 index a8a6337..0000000 --- a/web/html/testpo.php +++ /dev/null @@ -1,45 +0,0 @@ -\n"; - -print "

\n"; -print __("Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h.", - array("","English","", - "","Espaol","", - "","Deutsch","", - "","Franais","")); -print "

\n"; - -print "

\n"; -print __("My current language tag is: '%s'.", array($LANG)); -print "

\n"; - -print "
    \n"; -print __("Hello, world!")."
    \n"; -print __("Hello, again!")."
    \n"; -print "
\n"; -print "\n"; - -?> diff --git a/web/lang/ca/test_po.inc b/web/lang/ca/test_po.inc deleted file mode 100644 index 3f5ddad..0000000 --- a/web/lang/ca/test_po.inc +++ /dev/null @@ -1,16 +0,0 @@ - - -include_once("translator.inc"); -global $_t; - -$_t["ca"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Seleccioneu el vostre idioma ací: %h%s%h, %h%s%h, %h%s%h, %h%s%h"; - -$_t["ca"]["Hello, world!"] = "Hola, món!"; - -$_t["ca"]["Hello, again!"] = "Hola, altre cop!"; - -$_t["ca"]["My current language tag is: '%s'."] = "La meua etiqueta actual d'idioma és: '%s'."; - -?> \ No newline at end of file diff --git a/web/lang/de/test_po.inc b/web/lang/de/test_po.inc deleted file mode 100644 index a957522..0000000 --- a/web/lang/de/test_po.inc +++ /dev/null @@ -1,16 +0,0 @@ -, Matthias Gorissen , Lukas Kropatschek, Niclas Pfeifer - -include_once("translator.inc"); -global $_t; - -$_t["de"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Wähle hier deine Sprache aus: %h%s%h, %h%s%h, %h%s%h, %h%s%h."; - -$_t["de"]["Hello, world!"] = "Hallo, Welt!"; - -$_t["de"]["Hello, again!"] = "Nochmals Hallo!"; - -$_t["de"]["My current language tag is: '%s'."] = "Meine momentan gewählte Sprache ist: '%s'"; - -?> \ No newline at end of file diff --git a/web/lang/en/test_po.inc b/web/lang/en/test_po.inc deleted file mode 100644 index 28c0e10..0000000 --- a/web/lang/en/test_po.inc +++ /dev/null @@ -1,22 +0,0 @@ - \ No newline at end of file diff --git a/web/lang/es/test_po.inc b/web/lang/es/test_po.inc deleted file mode 100644 index 83bc7dc..0000000 --- a/web/lang/es/test_po.inc +++ /dev/null @@ -1,16 +0,0 @@ - - -include_once("translator.inc"); -global $_t; - -$_t["es"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Seleccione su idioma aquí: %h%s%h, %h%s%h, %h%s%h, %h%s%h."; - -$_t["es"]["Hello, world!"] = "¡Hola, mundo!"; - -$_t["es"]["Hello, again!"] = "¡Hola, otra vez!"; - -$_t["es"]["My current language tag is: '%s'."] = "Mi identificador actual del idioma es: '%s'."; - -?> \ No newline at end of file diff --git a/web/lang/fr/test_po.inc b/web/lang/fr/test_po.inc deleted file mode 100644 index f53af14..0000000 --- a/web/lang/fr/test_po.inc +++ /dev/null @@ -1,17 +0,0 @@ - -# Translator: Cilyan Olowen - -include_once("translator.inc"); -global $_t; - -$_t["fr"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Choisissez votre langue ici: %h%s%h, %h%s%h, %h%s%h, %h%s%h."; - -$_t["fr"]["Hello, world!"] = "Salut tout le monde !"; - -$_t["fr"]["Hello, again!"] = "Salut encore !"; - -$_t["fr"]["My current language tag is: '%s'."] = "Mon choix actuel de langue est: '%s'."; - -?> diff --git a/web/lang/it/test_po.inc b/web/lang/it/test_po.inc deleted file mode 100644 index 55c0a4c..0000000 --- a/web/lang/it/test_po.inc +++ /dev/null @@ -1,16 +0,0 @@ - and Pierluigi Picciau - -include_once("translator.inc"); -global $_t; - -$_t["it"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Scegli la tua lingua: %h%s%h, %h%s%h, %h%s%h, %h%s%h."; - -$_t["it"]["Hello, world!"] = "Ciao, mondo!"; - -$_t["it"]["Hello, again!"] = "Ciao, di nuovo!"; - -$_t["it"]["My current language tag is: '%s'."] = "Il tag della mia lingua corrente è: '%s'."; - -?> \ No newline at end of file diff --git a/web/lang/pl/test_po.inc b/web/lang/pl/test_po.inc deleted file mode 100644 index 847a0ab..0000000 --- a/web/lang/pl/test_po.inc +++ /dev/null @@ -1,13 +0,0 @@ - - -include_once("translator.inc"); -global $_t; - -$_t["pl"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Wybierz swój język: %h%s%h, %h%s%h, %h%s%h, %h%s%h."; -$_t["pl"]["Hello, world!"] = "Witaj, świecie!"; -$_t["pl"]["Hello, again!"] = "Witaj, ponownie!"; -$_t["pl"]["My current language tag is: '%s'."] = "Etykieta mojego obecnego języka to: '%s'."; - -?> \ No newline at end of file diff --git a/web/lang/pt/test_po.inc b/web/lang/pt/test_po.inc deleted file mode 100644 index 040e736..0000000 --- a/web/lang/pt/test_po.inc +++ /dev/null @@ -1,22 +0,0 @@ - \ No newline at end of file diff --git a/web/lang/ru/test_po.inc b/web/lang/ru/test_po.inc deleted file mode 100644 index 381abe3..0000000 --- a/web/lang/ru/test_po.inc +++ /dev/null @@ -1,16 +0,0 @@ - - -include_once("translator.inc"); -global $_t; - -$_t["ru"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Выберите ваш язык здесь: %h%s%h, %h%s%h, %h%s%h, %h%s%h."; - -$_t["ru"]["Hello, world!"] = "Всем привет!"; - -$_t["ru"]["Hello, again!"] = "Привет еще раз!"; - -$_t["ru"]["My current language tag is: '%s'."] = "Мой текущий язык: '%s'."; - -?> \ No newline at end of file diff --git a/web/lang/test_po.inc b/web/lang/test_po.inc deleted file mode 100644 index a2c5c5c..0000000 --- a/web/lang/test_po.inc +++ /dev/null @@ -1,32 +0,0 @@ - \ No newline at end of file -- cgit v1.2.3-54-g00ecf From b69e2cce56bee61ea445417e29e55d27a15637d5 Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Tue, 19 Aug 2008 18:08:12 -0400 Subject: Move top page template-example to web/template. Make note in web/README.txt Signed-off-by: Loui Chang --- web/README.txt | 3 +++ web/html/template.php | 20 -------------------- web/lang/ca/template_po.inc | 10 ---------- web/lang/de/template_po.inc | 10 ---------- web/lang/en/template_po.inc | 16 ---------------- web/lang/es/template_po.inc | 10 ---------- web/lang/fr/template_po.inc | 11 ----------- web/lang/it/template_po.inc | 10 ---------- web/lang/pl/template_po.inc | 10 ---------- web/lang/pt/template_po.inc | 16 ---------------- web/lang/ru/template_po.inc | 10 ---------- web/lang/template_po.inc | 32 -------------------------------- web/template/template.phps | 21 +++++++++++++++++++++ 13 files changed, 24 insertions(+), 155 deletions(-) delete mode 100644 web/html/template.php delete mode 100644 web/lang/ca/template_po.inc delete mode 100644 web/lang/de/template_po.inc delete mode 100644 web/lang/en/template_po.inc delete mode 100644 web/lang/es/template_po.inc delete mode 100644 web/lang/fr/template_po.inc delete mode 100644 web/lang/it/template_po.inc delete mode 100644 web/lang/pl/template_po.inc delete mode 100644 web/lang/pt/template_po.inc delete mode 100644 web/lang/ru/template_po.inc delete mode 100644 web/lang/template_po.inc create mode 100644 web/template/template.phps (limited to 'web/html') diff --git a/web/README.txt b/web/README.txt index 69bec04..249f605 100644 --- a/web/README.txt +++ b/web/README.txt @@ -92,6 +92,9 @@ Directory Layout: ./template - Where most of the html markup resides and minimal amount of PHP scripting. + There is also a template to model the site's top pages in + template.phps + Scripts: -------- diff --git a/web/html/template.php b/web/html/template.php deleted file mode 100644 index 11e05e0..0000000 --- a/web/html/template.php +++ /dev/null @@ -1,20 +0,0 @@ -\n"; - - -html_footer(AUR_VERSION); - -?> diff --git a/web/lang/ca/template_po.inc b/web/lang/ca/template_po.inc deleted file mode 100644 index 5ea5ee6..0000000 --- a/web/lang/ca/template_po.inc +++ /dev/null @@ -1,10 +0,0 @@ - - -include_once("translator.inc"); -global $_t; - -$_t["ca"]["Hi, this is worth reading!"] = "Hola, val la pena llegir açò!"; - -?> \ No newline at end of file diff --git a/web/lang/de/template_po.inc b/web/lang/de/template_po.inc deleted file mode 100644 index 024d767..0000000 --- a/web/lang/de/template_po.inc +++ /dev/null @@ -1,10 +0,0 @@ -, Matthias Gorissen , Lukas Kropatschek, Niclas Pfeifer - -include_once("translator.inc"); -global $_t; - -$_t["de"]["Hi, this is worth reading!"] = "Hallo - es lohnt sich, dies zu lesen!"; - -?> \ No newline at end of file diff --git a/web/lang/en/template_po.inc b/web/lang/en/template_po.inc deleted file mode 100644 index db437be..0000000 --- a/web/lang/en/template_po.inc +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/web/lang/es/template_po.inc b/web/lang/es/template_po.inc deleted file mode 100644 index 21e45fc..0000000 --- a/web/lang/es/template_po.inc +++ /dev/null @@ -1,10 +0,0 @@ - - -include_once("translator.inc"); -global $_t; - -$_t["es"]["Hi, this is worth reading!"] = "Hola, ¡vale la pena llegar hasta aquí!"; - -?> \ No newline at end of file diff --git a/web/lang/fr/template_po.inc b/web/lang/fr/template_po.inc deleted file mode 100644 index 2084c16..0000000 --- a/web/lang/fr/template_po.inc +++ /dev/null @@ -1,11 +0,0 @@ - -# Translator: Cilyan Olowen - -include_once("translator.inc"); -global $_t; - -$_t["fr"]["Hi, this is worth reading!"] = "Salut, ceci vaut la peine d'être lu !"; - -?> diff --git a/web/lang/it/template_po.inc b/web/lang/it/template_po.inc deleted file mode 100644 index defe7ac..0000000 --- a/web/lang/it/template_po.inc +++ /dev/null @@ -1,10 +0,0 @@ - and Pierluigi Picciau - -include_once("translator.inc"); -global $_t; - -$_t["it"]["Hi, this is worth reading!"] = "Ciao, questo vale la pena di leggerlo!"; - -?> \ No newline at end of file diff --git a/web/lang/pl/template_po.inc b/web/lang/pl/template_po.inc deleted file mode 100644 index c4e5686..0000000 --- a/web/lang/pl/template_po.inc +++ /dev/null @@ -1,10 +0,0 @@ - - -include_once("translator.inc"); -global $_t; - -$_t["pl"]["Hi, this is worth reading!"] = "Witaj, warto to przeczytać!"; - -?> \ No newline at end of file diff --git a/web/lang/pt/template_po.inc b/web/lang/pt/template_po.inc deleted file mode 100644 index ed4a1d0..0000000 --- a/web/lang/pt/template_po.inc +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/web/lang/ru/template_po.inc b/web/lang/ru/template_po.inc deleted file mode 100644 index 86c3e9b..0000000 --- a/web/lang/ru/template_po.inc +++ /dev/null @@ -1,10 +0,0 @@ - - -include_once("translator.inc"); -global $_t; - -$_t["ru"]["Hi, this is worth reading!"] = "Привет, это стоит почитать!"; - -?> \ No newline at end of file diff --git a/web/lang/template_po.inc b/web/lang/template_po.inc deleted file mode 100644 index 8d65fc0..0000000 --- a/web/lang/template_po.inc +++ /dev/null @@ -1,32 +0,0 @@ - \ No newline at end of file diff --git a/web/template/template.phps b/web/template/template.phps new file mode 100644 index 0000000..7a86686 --- /dev/null +++ b/web/template/template.phps @@ -0,0 +1,21 @@ +\n"; + + +html_footer(AUR_VERSION); + -- cgit v1.2.3-54-g00ecf From 73f807a5a86c3ebd2f2de84b721c78271bd0cace Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Tue, 19 Aug 2008 18:10:29 -0400 Subject: Remove obsolete Trusted User guidelines. Guidelines are now maintained in the Arch wiki. Signed-off-by: Loui Chang --- web/html/guidelines.html | 273 ----------------------------------------------- 1 file changed, 273 deletions(-) delete mode 100644 web/html/guidelines.html (limited to 'web/html') diff --git a/web/html/guidelines.html b/web/html/guidelines.html deleted file mode 100644 index c2acd77..0000000 --- a/web/html/guidelines.html +++ /dev/null @@ -1,273 +0,0 @@ - -AUR Guidelines - - - - - - - -

AUR Guidelines

- -
Jun 08, 2005
-
1.1.0
- -
- Ben Mazer - -
-
- The Trusted Users - -
- -

Summary

-

- Basic guidelines for the Arch User Repository. -

- -

Table Of Contents

- - -

Purpose

-

- The AUR -is a community of Arch users, where packages outside of the core Arch -distribution are maintained. The AUR Community Repo is a supplement to -the EXTRA and CURRENT repositories; less popular packages will be -maintained as a service to the general Arch-using population. Packages -in the AUR will depend on EXTRA and CURRENT.

The AUR was -created to lift the burden on the developers. They should be allowed to -focus on adding new features, rather than doing the mundane job of -package maintenance. Therefore, all packages start inside the AUR, and -as developers consider them crucial to the distribution, they will be -adopted into EXTRA/CURRENT. The AUR was also created to allow easy -participation. Arch is completely volunteer-based, and needs help from -its users. Lastly, the AUR helps to further the Arch philosophy of -KISS. The Arch Core (EXTRA/CURRENT/UNSTABLE) is a complete -distribution, but it does not attempt to provide every single package. -The AUR helps by maintaining less popular packages; but the AUR also -follows KISS, and only popular packages from UNSUPPORTED will make it -into the official AUR repository.

-

The User

-

Users of the -AUR can do many things, the main function being to download and use -packages. One can access the AUR by adding this to their pacman.conf -file:

- [community]
Server = ftp://ftp.archlinux.org/community/os/i686/


-But a user can also help with package maintenance, by: submitting -packages (and then maintaining them while they remain in UNSUPPORTED), -filing bug reports, reporting out-of-date packages, helping with other -user-submitted PKGBUILDs, and voting for packages that should be -maintained by the TUs. Once a user account has been created, all -functions can be performed inside the web interface.

Submitting Packages

-

-Inside the web interface, a user can submit a tarball (tar.gz) of a -directory containing build files for a package. The directory inside -the tarball should contain a PKGBUILD, any .install files, patches, etc -(no binaries). Examples of what a directory looks like can be seen inside /var/abs.

- When submitting a package, observe the following rules: -

    -
  • Check -EXTRA, CURRENT, UNSTABLE, UNSUPPORTED, and AUR for the package. If it -is inside any of those repositories in any form, do not submit the -package (if the package is broken in some way, file a bug report).
  • -
  • Verify -carefully that what you are uploading is correct. Follow the -TU/Developer Package Building Guidelines exactly. Broken packages make -the AUR messy, and prevent the TUs from doing their other duties.
  • -
  • If -you are unsure about the package (or the build/submission process) in -any way, submit the PKGBUILD to the AUR Mailing List for public review -before adding it to the AUR.
  • -
  • Make sure the package -is useful. Will anyone else want to use this package? Is it extremely -specialized? If more than a few people would find this package useful, -it is appropriate for submission.
  • -
  • Gain some experience before submitting packages. Build a few packages to learn the process and then submit.
  • -
  • Do -not abandon packages. While in UNSUPPORTED, it is the user's job to -maintain the package. If you do not want to maintain the package for -some reason, post a message to the AUR Mailing List.
  • -
- - -

The TU

-

-The TU -or Trusted User- is a member of the community charged with -keeping the AUR in working order. He maintains popular packages, and -votes in administrative matters. A TU is elected from active community -members by current TUs in a democratic process. TUs are the only -members who have a final say in the direction of the AUR.

-

Adding a TU

-

-TUs are only added as needed, and applications will only be accepted at -certain times. Check the AUR website for details on whether -applications are being accepted.

-TUs are elected democratically. If you would like to become a TU, a -sponsor (another TU) is needed. You must solicit requests for a sponsor -privately before posting on the mailing list. After this is received, a -request must be made on the AUR Mailing List by the sponsor. Ideally, a -TU should have a specific subset of packages he wishes to maintain.

-Four other votes must be received from other TUs or developers for an -applicant to be accepted. Once these have been received, the user will -be given the proper passwords, and a TU will upgrade the user's status -on the web interface.

-Once an application has been published on the mailing list, it is open -for voting for 3 weeks. If the applicant does not receive enough votes -within that time period, he must wait 3 months to submit another -application, with vote tallies being reset.
- -

-

Sanctioning/Removing a TU

-

-There is a basic sanctioning system for TUs. If a TU breaks a rule, -either official or through "community standards" when he was already -aware of this rule, one can request a sanction. If two other votes from -TUs are received, a sanction will be added. After two sanctions, the TU -will automatically come up for a removal vote.

If a TU is not working out, for any reason, one can -request him to be expelled. Someone requesting a removal of a TU must -state a valid reason, and why immediate removal is necessary. Almost -always, previous sanctions will be needed. With four additional votes, -that TU will be immediately removed and his packages will have to be -adopted by a different TU.

-

Other Duties

-

-All other duties (changing rules, adding new regulations, new features, -etc) should be discussed openly on the AUR Mailing List and voted on. -Various pieces of documentation and code can have specified -"maintainers" that can perform basic updates (typo/bug fixes) without a -vote, but any changes should be reported on the mailing list. Any major -changes should receive a simple majority vote.

-

Guidelines for Package Maintenance

-

-

-

Accessing the Repo

-

- Follow these instructions for uploading/modifying packages once you have become a TU: -

    -
  1. Install the "aurtools" package.
  2. -
  3. Email Jason () for a CVS account.
  4. -
  5. Run the following commands to checkout the AUR CVS:
    - - export CVSROOT=":pserver:<userid>@cvs.archlinux.org:/home/cvs-community"
    - cvs login
    - cvs co community
  6. -
  7. To add a PKGBUILD and other build files:
    - - cvs add <directory>
    - cd <directory>
    - cvs add PKGBUILD
    - .
    - .
    - cvs commit
  8. -
  9. To upload a binary package: - tupkg --user <userid> --password <password> <packagefile.pkg.tar.gz>
  10. -
  11. After uploading a package and committing the build files, tag the files with this command: - cvs tag -cFR CURRENT <newpackagebuilddir>
  12. -
  13. Package -changes should be available within 10 minutes. Verify everything was -uploaded properly, then select the newly added or updated package in -the web interface and set yourself as the maintainer.
  14. -
- -

Adopting Packages

-

-A TU may adopt any package at any time. But because the TU's time is -limited, he should try to only adopt popular packages. The voting -mechanism in the AUR allows a TU to quickly gage which packages users -want.

-If a package receives 25 votes, it may be adopted by a TU. A maintainer -should adopt it via the web interface. That maintainer is then -responsible for bug fixes and new version updates. Packages must be -properly cleaned and fixed after adoption.

- -

Disowning packages

-

-If a TU can't or doesn't want to maintain a package any longer, a -notice should be posted to the AUR Mailing List, so another TU can -maintain it. A package can still be disowned even if no other TU wants -to maintain it, but the TUs should try not to drop many packages (they -shouldn't take on more than they have time for). If a package has -become obsolete or isn't used any longer, it can be removed completely -as well.

-If a package has been removed completely, it can be uploaded once again -(fresh) to UNSUPPORTED, where a regular user can maintain the package -instead of the TU.

-

Packaging Etiquette

-

- Adhere to the following rules when building/maintaining packages: -
-

    -
  • Follow all rules in the Arch Packaging Guidelines.
  • -
  • Always run Namcap on all packages and PKGBUILDs.
  • -
  • All -important messages should be echoed inside the .install file. For -example, if a package needs extra setup to work, directions should be -echoed.
  • -
  • Any optional dependencies that aren't -needed to run the package or have it generally function shouldn't be -included, but a warning message inside the .install file should echo -something like: "To enable SMB support, download the Samba package."
  • - -
  • Always look at current packages for ideas on how various problems should be handled. Most problems have already been solved.
  • -
  • Dependencies -are the most common packaging error. Namcap can help detect them, but -it is not always correct. Verify dependencies by looking at source -documentation and the program website.
  • -
  • All packages should be buildable as a user, under fakeroot.
  • -
  • New user creation should only be done when absolutely necessary.
  • -
  • Always -fill out all applicable fields in the PKGBUILD (never forget a URL, -md5sum, etc). The LICENSE variable is not currently used, but will be -very shortly.
  • -
  • All custom variables should begin with an underscore (_).
  • -
  • A PKGBUILD should never modify any files outside of the build directory.
  • -
- -

Frequently Asked Questions

-

- Q: What is the difference between the AUR, COMMUNITY, and TUR? Why don't packages I upload to the AUR show up in pacman?

-A: The TUR, or Trusted User Repository, was the old system used to -manage user submissions. It had a number of flaws, so was discontinued. -The TUR website is still up, but is dead and will be removed shortly. -AUR is the official replacement for the TUR. It is a web system that -allows users to submit their own PKGBUILDs for both the TUs and the -general community to see. COMMUNITY is a new Arch repository, run by -the TUs, that is available via pacman.

-User submitted PKGBUILDs are available from the AUR, but because they -have not been reviewed, packages are not available. If a PKGBUILD is -reviewed, and receives many votes, it may "graduate" into the COMMUNITY -repo. There it will easily be retrievable from pacman.

-If you are a new user, it is safe to use the COMMUNITY repo, as -packages have been verified. Any PKGBUILDs in the UNSUPPORTED section -of the AUR have not been tested, and could be dangerous or broken. Use -at your own risk.

- -- cgit v1.2.3-54-g00ecf From 99881b31db85bcb87bec22258d856521e5bef7ed Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Sat, 13 Sep 2008 15:35:32 -0400 Subject: Fix whitespace and indenting in pkgsubmit. Signed-off-by: Loui Chang --- web/html/pkgsubmit.php | 229 ++++++++++++++++++++++++------------------------- 1 file changed, 112 insertions(+), 117 deletions(-) (limited to 'web/html') diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 0d245b8..78d6e50 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -12,12 +12,12 @@ set_lang(); # this sets up the visitor's language check_sid(); # see if they're still logged in if ($_COOKIE["AURSID"]): - + # Track upload errors $error = ""; if ($_REQUEST["pkgsubmit"]) { - + # Before processing, make sure we even have a file if ($_FILES['pfile']['size'] == 0){ $error = __("Error - No file uploaded"); @@ -35,30 +35,30 @@ if ($_COOKIE["AURSID"]): $error = __("Could not change directory to %s.", array($tempdir)); } else { - if ($_FILES['pfile']['name'] == "PKGBUILD") { - move_uploaded_file($_FILES['pfile']['tmp_name'], $tempdir . "/PKGBUILD"); - } else { - $tar = new Archive_Tar($_FILES['pfile']['tmp_name']); - $extract = $tar->extract(); - - if (!$extract) { - $error = __("Unknown file format for uploaded file."); - } - } + if ($_FILES['pfile']['name'] == "PKGBUILD") { + move_uploaded_file($_FILES['pfile']['tmp_name'], $tempdir . "/PKGBUILD"); + } else { + $tar = new Archive_Tar($_FILES['pfile']['tmp_name']); + $extract = $tar->extract(); + + if (!$extract) { + $error = __("Unknown file format for uploaded file."); + } + } } } } # Find the PKGBUILD if (!$error) { - $pkgbuild = File_Find::search('PKGBUILD', $tempdir); - - if (count($pkgbuild)) { - $pkgbuild = $pkgbuild[0]; - $pkg_dir = dirname($pkgbuild); - } else { - $error = __("Error trying to unpack upload - PKGBUILD does not exist."); - } + $pkgbuild = File_Find::search('PKGBUILD', $tempdir); + + if (count($pkgbuild)) { + $pkgbuild = $pkgbuild[0]; + $pkg_dir = dirname($pkgbuild); + } else { + $error = __("Error trying to unpack upload - PKGBUILD does not exist."); + } } # if no error, get list of directory contents and process PKGBUILD @@ -108,7 +108,7 @@ if ($_COOKIE["AURSID"]): fclose($fp); # Now process the lines and put any var=val lines into the - # 'pkgbuild' array. Also check to make sure it has the build() + # 'pkgbuild' array. Also check to make sure it has the build() # function. # $seen_build_function = 0; @@ -123,13 +123,13 @@ if ($_COOKIE["AURSID"]): $lparts[1]{strlen($lparts[1])-1} == '"') { $pkgbuild[$lparts[0]] = substr($lparts[1], 1, -1); } - elseif + elseif ($lparts[1]{0} == "'" && $lparts[1]{strlen($lparts[1])-1} == "'") { $pkgbuild[$lparts[0]] = substr($lparts[1], 1, -1); } else { $pkgbuild[$lparts[0]] = $lparts[1]; - } + } } else { $pkgbuild[$lparts[0]] = str_replace(array("(",")","\"","'"), "", $lparts[1]); @@ -150,20 +150,20 @@ if ($_COOKIE["AURSID"]): if (!$seen_build_function) { $error = __("Missing build function in PKGBUILD."); } - + $req_vars = array("md5sums", "source", "url", "pkgdesc", "license", "pkgrel", "pkgver", "arch", "pkgname"); foreach ($req_vars as $var) { - if (!array_key_exists($var, $pkgbuild)) { - $error = __("Missing " . $var . " variable in PKGBUILD."); - } - } + if (!array_key_exists($var, $pkgbuild)) { + $error = __("Missing " . $var . " variable in PKGBUILD."); + } + } } # TODO This is where other additional error checking can be - # performed. Examples: #md5sums == #sources?, md5sums of any + # performed. Examples: #md5sums == #sources?, md5sums of any # included files match?, install scriptlet file exists? # - + # Check for http:// or other protocol in url # if (!$error) { @@ -172,7 +172,7 @@ if ($_COOKIE["AURSID"]): $error = __("Package URL is missing a protocol (ie. http:// ,ftp://)"); } } - + # Now, run through the pkgbuild array and do any $pkgname/$pkgver # substituions. # @@ -195,9 +195,9 @@ if ($_COOKIE["AURSID"]): $pkg_name = str_replace("'", "", $pkgbuild['pkgname']); $pkg_name = escapeshellarg($pkg_name); $pkg_name = str_replace("'", "", $pkg_name); - + $presult = preg_match("/^[a-z0-9][a-z0-9\.+_-]*$/", $pkg_name); - + if (!$presult) { $error = __("Invalid name: only lowercase letters are allowed."); } @@ -213,18 +213,14 @@ if ($_COOKIE["AURSID"]): } if (!@mkdir(INCOMING_DIR . $pkg_name)) { - $error = __( "Could not create directory %s." - , INCOMING_DIR . $pkg_name - ); + $error = __( "Could not create directory %s.", + INCOMING_DIR . $pkg_name); } - rename($pkg_dir, INCOMING_DIR . $pkg_name . "/" . $pkg_name); + rename($pkg_dir, INCOMING_DIR . $pkg_name . "/" . $pkg_name); } else { - $error = __( "You are not allowed to overwrite the %h%s%h package." - , "" - , $pkg_name - , "" - ); + $error = __( "You are not allowed to overwrite the %h%s%h package.", + "", $pkg_name, ""); } } @@ -235,16 +231,16 @@ if ($_COOKIE["AURSID"]): array(INCOMING_DIR . $pkg_name)); } } - + if (!$error) { - $tar = new Archive_Tar($pkg_name . '.tar.gz'); - $create = $tar->create(array($pkg_name)); - + $tar = new Archive_Tar($pkg_name . '.tar.gz'); + $create = $tar->create(array($pkg_name)); + if (!$create) { $error = __("Could not re-tar"); } } - + # Whether it failed or not we can clean this out if (file_exists($tempdir)) { rm_rf($tempdir); @@ -252,13 +248,13 @@ if ($_COOKIE["AURSID"]): # Update the backend database if (!$error) { - + $dbh = db_connect(); - + # This is an overwrite of an existing package, the database ID - # needs to be preserved so that any votes are retained. However, + # needs to be preserved so that any votes are retained. However, # PackageDepends and PackageSources can be purged. - + $q = "SELECT * FROM Packages WHERE Name = '" . mysql_real_escape_string($new_pkgbuild['pkgname']) . "'"; $result = db_query($q, $dbh); $pdata = mysql_fetch_assoc($result); @@ -273,53 +269,52 @@ if ($_COOKIE["AURSID"]): # If the package was a dummy, undummy it if ($pdata['DummyPkg']) { - $q = sprintf( "UPDATE Packages SET DummyPkg = 0, SubmitterUID = %d, MaintainerUID = %d, SubmittedTS = UNIX_TIMESTAMP() WHERE ID = %d" - , uid_from_sid($_COOKIE["AURSID"]) - , uid_from_sid($_COOKIE["AURSID"]) - , $pdata["ID"] - ); + $q = sprintf( "UPDATE Packages SET DummyPkg = 0, SubmitterUID = %d, MaintainerUID = %d, SubmittedTS = UNIX_TIMESTAMP() WHERE ID = %d", + uid_from_sid($_COOKIE["AURSID"]), + uid_from_sid($_COOKIE["AURSID"]), + $pdata["ID"]); - db_query($q, $dbh); + db_query($q, $dbh); } - + # If a new category was chosen, change it to that if ($_POST['category'] > 1) { - $q = sprintf( "UPDATE Packages SET CategoryID = %d WHERE ID = %d" - , mysql_real_escape_string($_REQUEST['category']) - , $pdata["ID"] - ); - - db_query($q, $dbh); - } - + $q = sprintf( "UPDATE Packages SET CategoryID = %d WHERE ID = %d", + mysql_real_escape_string($_REQUEST['category']), + $pdata["ID"]); + + db_query($q, $dbh); + } + # Update package data - $q = sprintf( "UPDATE Packages SET ModifiedTS = UNIX_TIMESTAMP(), Name = '%s', Version = '%s-%s', License = '%s', Description = '%s', URL = '%s', LocationID = 2, FSPath = '%s', URLPath = '%s', OutOfDate = 0 WHERE ID = %d" - , mysql_real_escape_string($new_pkgbuild['pkgname']) - , mysql_real_escape_string($new_pkgbuild['pkgver']) - , mysql_real_escape_string($new_pkgbuild['pkgrel']) - , mysql_real_escape_string($new_pkgbuild['license']) - , mysql_real_escape_string($new_pkgbuild['pkgdesc']) - , mysql_real_escape_string($new_pkgbuild['url']) - , mysql_real_escape_string(INCOMING_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz") - , mysql_real_escape_string(URL_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz") - , $pdata["ID"] - ); - + $q = sprintf("UPDATE Packages SET ModifiedTS = UNIX_TIMESTAMP(), Name = '%s', Version = '%s-%s', License = '%s', Description = '%s', URL = '%s', LocationID = 2, FSPath = '%s', URLPath = '%s', OutOfDate = 0 WHERE ID = %d", + mysql_real_escape_string($new_pkgbuild['pkgname']), + mysql_real_escape_string($new_pkgbuild['pkgver']), + mysql_real_escape_string($new_pkgbuild['pkgrel']), + mysql_real_escape_string($new_pkgbuild['license']), + mysql_real_escape_string($new_pkgbuild['pkgdesc']), + mysql_real_escape_string($new_pkgbuild['url']), + mysql_real_escape_string(INCOMING_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz"), + mysql_real_escape_string(URL_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz"), + $pdata["ID"]); + db_query($q, $dbh); # Update package depends $depends = explode(" ", $new_pkgbuild['depends']); - foreach ($depends as $dep) { + foreach ($depends as $dep) { $q = "INSERT INTO PackageDepends (PackageID, DepPkgID, DepCondition) VALUES ("; $deppkgname = preg_replace("/[<>]?=.*/", "", $dep); - $depcondition = str_replace($deppkgname, "", $dep); - - if ($deppkgname == "#") { break; } - + $depcondition = str_replace($deppkgname, "", $dep); + + if ($deppkgname == "#") { + break; + } + $deppkgid = create_dummy($deppkgname, $_COOKIE['AURSID']); - $q .= $pdata["ID"] . ", " . $deppkgid . ", '" . mysql_real_escape_string($depcondition) . "')"; + $q .= $pdata["ID"] . ", " . $deppkgid . ", '" . mysql_real_escape_string($depcondition) . "')"; - db_query($q, $dbh); + db_query($q, $dbh); } # Insert sources @@ -328,26 +323,25 @@ if ($_COOKIE["AURSID"]): $q = "INSERT INTO PackageSources (PackageID, Source) VALUES ("; $q .= $pdata["ID"] . ", '" . mysql_real_escape_string($src) . "')"; db_query($q, $dbh); - } + } header('Location: packages.php?ID=' . $pdata['ID']); - + } else { - + # This is a brand new package - $q = sprintf( "INSERT INTO Packages (Name, License, Version, CategoryID, Description, URL, LocationID, SubmittedTS, SubmitterUID, MaintainerUID, FSPath, URLPath) VALUES ('%s', '%s', '%s-%s', %d, '%s', '%s', 2, UNIX_TIMESTAMP(), %d, %d, '%s', '%s')" - , mysql_real_escape_string($new_pkgbuild['pkgname']) - , mysql_real_escape_string($new_pkgbuild['license']) - , mysql_real_escape_string($new_pkgbuild['pkgver']) - , mysql_real_escape_string($new_pkgbuild['pkgrel']) - , mysql_real_escape_string($_REQUEST['category']) - , mysql_real_escape_string($new_pkgbuild['pkgdesc']) - , mysql_real_escape_string($new_pkgbuild['url']) - , uid_from_sid($_COOKIE["AURSID"]) - , uid_from_sid($_COOKIE["AURSID"]) - , mysql_real_escape_string(INCOMING_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz") - , mysql_real_escape_string(URL_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz") - ); + $q = sprintf("INSERT INTO Packages (Name, License, Version, CategoryID, Description, URL, LocationID, SubmittedTS, SubmitterUID, MaintainerUID, FSPath, URLPath) VALUES ('%s', '%s', '%s-%s', %d, '%s', '%s', 2, UNIX_TIMESTAMP(), %d, %d, '%s', '%s')", + mysql_real_escape_string($new_pkgbuild['pkgname']), + mysql_real_escape_string($new_pkgbuild['license']), + mysql_real_escape_string($new_pkgbuild['pkgver']), + mysql_real_escape_string($new_pkgbuild['pkgrel']), + mysql_real_escape_string($_REQUEST['category']), + mysql_real_escape_string($new_pkgbuild['pkgdesc']), + mysql_real_escape_string($new_pkgbuild['url']), + uid_from_sid($_COOKIE["AURSID"]), + uid_from_sid($_COOKIE["AURSID"]), + mysql_real_escape_string(INCOMING_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz"), + mysql_real_escape_string(URL_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz")); $result = db_query($q, $dbh); $packageID = mysql_insert_id($dbh); @@ -358,12 +352,14 @@ if ($_COOKIE["AURSID"]): $q = "INSERT INTO PackageDepends (PackageID, DepPkgID, DepCondition) VALUES ("; $deppkgname = preg_replace("/[<>]?=.*/", "", $dep); $depcondition = str_replace($deppkgname, "", $dep); - - if ($deppkgname == "#") { break; } - - $deppkgid = create_dummy($deppkgname, $_COOKIE['AURSID']); - $q .= $packageID . ", " . $deppkgid . ", '" . mysql_real_escape_string($depcondition) . "')"; - + + if ($deppkgname == "#") { + break; + } + + $deppkgid = create_dummy($deppkgname, $_COOKIE['AURSID']); + $q .= $packageID . ", " . $deppkgid . ", '" . mysql_real_escape_string($depcondition) . "')"; + db_query($q, $dbh); } @@ -373,10 +369,10 @@ if ($_COOKIE["AURSID"]): $q = "INSERT INTO PackageSources (PackageID, Source) VALUES ("; $q .= $packageID . ", '" . mysql_real_escape_string($src) . "')"; db_query($q, $dbh); - } + } header('Location: packages.php?ID=' . $packageID); - + } } @@ -390,10 +386,10 @@ html_header("Submit"); ?>
-
- -
-
+
+ +
+
@@ -463,15 +459,14 @@ else: ?>
- + -
+
-- cgit v1.2.3-54-g00ecf From 34c8a9cf80fa857f8024eacd65292cd015673165 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Mon, 6 Oct 2008 06:09:06 +0800 Subject: Major rearrangement of tu.php, strings setup for translation All the strings are set up to be translated now, HTML of tu.php has been moved to templates and the worst of it rewritten (there's no longer a massive function in it) Signed-off-by: Callan Barrett Signed-off-by: Loui Chang --- web/html/tu.php | 438 +++++++------------------------------------- web/template/tu_details.php | 62 +++++++ web/template/tu_list.php | 68 +++++++ 3 files changed, 200 insertions(+), 368 deletions(-) create mode 100644 web/template/tu_details.php create mode 100644 web/template/tu_list.php (limited to 'web/html') diff --git a/web/html/tu.php b/web/html/tu.php index 524e14d..e2e44b7 100644 --- a/web/html/tu.php +++ b/web/html/tu.php @@ -8,44 +8,30 @@ set_lang(); check_sid(); html_header(); -# get login privileges -# +# Default votes per page +$pp = 5; + +$atype = ""; if (isset($_COOKIE["AURSID"])) { - # Only logged in users can do stuff - # $atype = account_from_sid($_COOKIE["AURSID"]); -} else { - $atype = ""; } if ($atype == "Trusted User" OR $atype == "Developer") { - # Show the TU interface - # - - # Temp value for results per page $pp = 5; - if (isset($_REQUEST['id'])) { - # Show application details - # depending on action and time frame will show either - # sponsor button, comments and vote buttons - # - - if (intval($_REQUEST['id'])) { + if (isset($_GET['id'])) { + if (is_numeric($_GET['id'])) { $q = "SELECT * FROM TU_VoteInfo "; - $q.= "WHERE ID = " . $_REQUEST['id']; + $q.= "WHERE ID = " . $_GET['id']; $dbh = db_connect(); $results = db_query($q, $dbh); $row = mysql_fetch_assoc($results); if (empty($row)) { - print "Could not retrieve proposal details.\n"; + print __("Could not retrieve proposal details."); } else { - # Print out application details, thanks again AUR - # - $isrunning = $row['End'] > time() ? 1 : 0; $qvoted = "SELECT * FROM TU_Votes WHERE "; @@ -53,30 +39,27 @@ if ($atype == "Trusted User" OR $atype == "Developer") { $qvoted.= "UserID = " . uid_from_sid($_COOKIE["AURSID"]); $hasvoted = mysql_num_rows(db_query($qvoted, $dbh)); - # Can this person vote? - # - $canvote = 1; // we assume they can - $errorvote = ""; // error message to give + $canvote = 1; + $errorvote = ""; if ($isrunning == 0) { $canvote = 0; - $errorvote = "Voting is closed for this proposal."; + $errorvote = __("Voting is closed for this proposal."); } else if ($row['User'] == username_from_sid($_COOKIE["AURSID"])) { $canvote = 0; - $errorvote = "You cannot vote in an proposal regarding you."; + $errorvote = __("You cannot vote in an proposal about you."); } else if ($hasvoted != 0) { $canvote = 0; - $errorvote = "You've already voted in this proposal."; + $errorvote = __("You've already voted in this proposal."); } - # have to put this here so results are correct immediately after voting if ($canvote == 1) { if (isset($_POST['doVote'])) { if (isset($_POST['voteYes'])) { - $myvote = "Yes"; + $myvote = __("Yes"); } else if (isset($_POST['voteNo'])) { - $myvote = "No"; + $myvote = __("No"); } else if (isset($_POST['voteAbstain'])) { - $myvote = "Abstain"; + $myvote = __("Abstain"); } $qvote = "UPDATE TU_VoteInfo SET " . $myvote . " = " . ($row[$myvote] + 1) . " WHERE ID = " . $row['ID']; @@ -87,7 +70,7 @@ if ($atype == "Trusted User" OR $atype == "Developer") { # Can't vote anymore # $canvote = 0; - $errorvote = "You've already voted for this proposal."; + $errorvote = __("You've already voted for this proposal."); # Update if they voted $hasvoted = mysql_num_rows(db_query($qvoted, $dbh)); @@ -95,357 +78,76 @@ if ($atype == "Trusted User" OR $atype == "Developer") { $row = mysql_fetch_assoc($results); } } - - # I think I understand why MVC is good for this stuff.. - echo "
\n"; - echo "
Proposal Details
\n"; - echo "
\n"; - - if ($isrunning == 1) { - print "
This vote is still running.
"; - print "
"; - } - - print "User: "; - - if (!empty($row['User'])) { - print "" . $row['User'] . ""; - } else { - print "N/A"; - } - - print "
\n"; - - print "Submitted: " . gmdate("r", $row['Submitted']) . " by "; - print "" . username_from_id($row['SubmitterID']) . "
\n"; - - if ($isrunning == 0) { - print "Ended: "; - } else { - print "Ends: "; - } - print "" . gmdate("r", $row['End']) . "
\n"; - - print "
\n"; - - $row['Agenda'] = htmlentities($row['Agenda']); - # str_replace seems better than
 because it still maintains word wrapping
-				print str_replace("\n", "
\n", $row['Agenda']); - - print "
\n"; - print "
\n"; - - print "
\n"; - print "\n"; - print "\n"; - print "\n"; - print "
\n"; - print "\n"; - - print "\n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print "\n"; - - $c = "data1"; - - print "\n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print "\n"; - - print "
"; - print "Yes"; - print ""; - print "No"; - print ""; - print "Abstain"; - print ""; - print "Total"; - print ""; - print "Voted?"; - print "
"; - print $row['Yes']; - print ""; - print $row['No']; - print ""; - print $row['Abstain']; - print ""; - print ($row['Yes'] + $row['No'] + $row['Abstain']); - print ""; - - if ($hasvoted == 0) { - print "No"; - } else { - print "Yes"; - } - - print "
\n"; - print "
\n"; - - echo "
\n"; - - # Actions, vote buttons - # - print "
\n"; - print "
\n"; - print "
Vote Actions
\n"; - print "
\n"; - - if ($canvote == 1) { - print "
\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "
\n"; - } else { - print "
$errorvote
"; - } - - print "
\n"; - print "
Back
\n"; - + include("tu_details.php"); } - } else { - print "Vote ID not valid.\n"; + print __("Vote ID not valid."); } } else { - # page listing applications being discussed, voted on and all those finished - # - - # I guess there should be a function since I use this a few times - function gen_results($offset, $limit, $sort, $by, $type="normal") { - - $dbh = db_connect(); - - if (!empty($offset) AND is_numeric($offset)) { - if ($offset >= 1) { - $off = $offset; - } else { - $off = 0; - } - } else { - $off = 0; - } - - $q = "SELECT * FROM TU_VoteInfo"; - - if ($type == "new") { - $q.= " WHERE End > " . time(); - $application = "Current Votes"; - } else { - $application = "All Votes"; - } - - $order = ($by == 'down') ? 'DESC' : 'ASC'; - - # not much to sort, I'm unsure how to sort by username - # when we only store the userid, someone come up with a nifty - # way to do this - # - switch ($sort) { - case 'sub': - $q.= " ORDER BY Submitted $order"; - break; - default: - $q.= " ORDER BY Submitted $order"; - break; - } - - if ($limit != 0) { - $q.= " LIMIT " . $off . ", ". $limit; - } - - $result = db_query($q, $dbh); - - if ($by == "down") { - $by_next = "up"; - } else { - $by_next = "down"; - } - - print "
\n"; - print "\n"; - print "\n"; - print " \n"; - print "\n"; - print "\n"; - print "
\n"; - print " $application\n"; - print "
\n"; - print "\n"; - - print "\n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; -# I'm not sure if abstains are necessary inthis view, it's just extra clutter -# print " \n"; - print " \n"; - print "\n"; - - if (mysql_num_rows($result) == 0) { - print "\n"; - } else { - for ($i = 0; $row = mysql_fetch_assoc($result); $i++) { - # Thankyou AUR - - # alright, I'm going to just have a "new" table and the - # "old" table can just have every vote, works just as well - # and probably saves on doing some crap - # - - (($i % 2) == 0) ? $c = "data1" : $c = "data2"; - print "\n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - # print " \n"; - print "\n"; - } - } + $dbh = db_connect(); - print "
"; - print "Proposal"; - print ""; - print "Start"; - print ""; - print "End"; - print ""; - print "User"; - print ""; - print "Yes"; - print ""; - print "No"; - print ""; -# print "Abstain"; -# print ""; - print "Voted?"; - print "
No results found.
"; - - $prev_Len = 100; - - if (strlen($row["Agenda"]) >= $prev_Len) { - $row["Agenda"] = htmlentities(substr($row["Agenda"], 0, $prev_Len)) . "... -"; - } else { - $row["Agenda"] = htmlentities($row["Agenda"]) . " -"; - } - - print $row["Agenda"]; - print " [More]"; - print ""; - # why does the AUR use gmdate with formatting that includes the offset - # to GMT?! - print gmdate("j M y", $row["Submitted"]); - print ""; - print gmdate("j M y", $row["End"]); - print ""; - - if (!empty($row['User'])) { - print ""; - print $row['User'] . ""; - } else { - print "N/A"; - } - - print ""; - print $row['Yes']; - print ""; - print $row['No']; - print ""; - # See above - # print $row['Abstain']; - # print ""; - - $qvoted = "SELECT * FROM TU_Votes WHERE "; - $qvoted.= "VoteID = " . $row['ID'] . " AND "; - $qvoted.= "UserID = " . uid_from_sid($_COOKIE["AURSID"]); - $hasvoted = mysql_num_rows(db_query($qvoted, $dbh)); - - if ($hasvoted == 0) { - print "No"; - } else { - print "Yes"; - } - - print "
\n"; - print "
\n"; + $offset = $_GET['off']; + $limit = $pp; + $by = $_GET['by']; - if ($type == "old" AND $limit != 0) { - $qnext = "SELECT ID FROM TU_VoteInfo"; - $nextresult = db_query($qnext, $dbh); + if (!empty($offset) AND is_numeric($offset)) { + if ($offset >= 1) { + $off = $offset; + } else { + $off = 0; + } + } else { + $off = 0; + } - print "\n"; + $order = ($by == 'down') ? 'DESC' : 'ASC'; + $lim = ($limit > 0) ? " LIMIT " . $off . ", " . $limit : ""; + $by_next = ($by == "down") ? "up" : "down"; - if (mysql_num_rows($result)) { - $sort = htmlentities($sort, ENT_QUOTES); - $by = htmlentities($by, ENT_QUOTES); + $prev_Len = 100; - print "\n"; - print "\n"; + $q = "SELECT * FROM TU_VoteInfo WHERE End > " . time() . " ORDER BY Submitted " . $order; + $result = db_query($q, $dbh); - print "\n"; - print "\n"; - } - print "
\n"; - if ($off != 0) { - $back = (($off - $limit) <= 0) ? 0 : $off - $limit; - print "Back"; - } - print "\n"; - if (($off + $limit) < mysql_num_rows($nextresult)) { - $forw = $off + $limit; - print "Next"; - } - print "
\n"; - } + $type = __("Current Votes"); + include("tu_list.php"); +?> - print "
\n"; - } +
+ +

- # stop notices, ythanku Xilon - if (empty($_REQUEST['sort'])) { $_REQUEST['sort'] = ""; } - if (empty($_REQUEST['by'])) { $_REQUEST['by'] = ""; } - if (empty($_REQUEST['off'])) { $_REQUEST['off'] = ""; } +Add
"; - gen_results($_REQUEST['off'], $pp, $_REQUEST['sort'], $_REQUEST['by'], "old"); + $type = __("All Votes"); + include("tu_list.php"); + $qnext = "SELECT ID FROM TU_VoteInfo"; + $nextresult = db_query($qnext, $dbh); +?> + + + + + + + +
+ + + + + + + +
+ diff --git a/web/template/tu_details.php b/web/template/tu_details.php new file mode 100644 index 0000000..b1d69f6 --- /dev/null +++ b/web/template/tu_details.php @@ -0,0 +1,62 @@ +
+
+
+ +
+
+ +User: + +&SeB=m'> + +N/A + +
+" . gmdate("r", $row['Submitted']) . "", "" . username_from_id($row['SubmitterID']) . "") ?>
+

+\n", htmlentities($row['Agenda'])) ?>

+
+ + + +
+ + + + + + + + + + + + + + + +
+ + + + + +
+
+
+
+
+
+
+ +
' method='post'> + + + + +
+ +
+ +
+
diff --git a/web/template/tu_list.php b/web/template/tu_list.php new file mode 100644 index 0000000..bec2985 --- /dev/null +++ b/web/template/tu_list.php @@ -0,0 +1,68 @@ +
+ + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ = $prev_Len) { + $row["Agenda"] = htmlentities(substr($row["Agenda"], 0, $prev_Len)) . "... - "; + } else { + $row["Agenda"] = htmlentities($row["Agenda"]) . " - "; + } + ?> + '>[] + + " . $row['User'] . ""; + } else { + print "N/A"; + } + ?> + + + + + + + + + +
+
+
-- cgit v1.2.3-54-g00ecf From 2d49849e2cebc9014c9c1d8f009b7397c3fd8269 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Wed, 8 Oct 2008 04:00:00 +0800 Subject: Setup translation files for tu.php Signed-off-by: Callan Barrett --- web/html/tu.php | 2 +- web/lang/tu_po.inc | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 web/lang/tu_po.inc (limited to 'web/html') diff --git a/web/html/tu.php b/web/html/tu.php index e2e44b7..67ac3f2 100644 --- a/web/html/tu.php +++ b/web/html/tu.php @@ -2,7 +2,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); -include("pkgfuncs_po.inc"); +include("tu_po.inc"); include("aur.inc"); set_lang(); check_sid(); diff --git a/web/lang/tu_po.inc b/web/lang/tu_po.inc new file mode 100644 index 0000000..00f603a --- /dev/null +++ b/web/lang/tu_po.inc @@ -0,0 +1,4 @@ + Date: Wed, 8 Oct 2008 04:42:47 +0800 Subject: Add comment and submitted to notification emails for comments Signed-off-by: Callan Barrett Signed-off-by: Loui Chang --- web/html/pkgedit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/html') diff --git a/web/html/pkgedit.php b/web/html/pkgedit.php index 610113a..974f14b 100644 --- a/web/html/pkgedit.php +++ b/web/html/pkgedit.php @@ -91,7 +91,7 @@ if ($_REQUEST["add_Comment"]) { #TODO: native language emails for users, based on their prefs # Simply making these strings translatable won't work, users would be # getting emails in the language that the user who posted the comment was in - $body = "A comment has been added to ".$row['Name'].", you may view it at:\nhttp://aur.archlinux.org/packages.php?ID=".$_REQUEST["ID"]."\n\n\n---\nYou received this e-mail because you chose to recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the UnNotify button."; + $body = "A comment has been added to ".$row['Name']." by " . username_from_sid($_COOKIE["AURSID"]) . ", you may view it at:\nhttp://aur.archlinux.org/packages.php?ID=".$_REQUEST["ID"]."\n\n\"" . $_POST['comment'] . "\"\n\n---\nYou received this e-mail because you chose to receive notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the UnNotify button."; $body = wordwrap($body, 70); $bcc = implode(', ', $bcc); $headers = "Bcc: $bcc\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n"; -- cgit v1.2.3-54-g00ecf From 2ce36384da97946bc6fe324a8c32a99c9b2d7873 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Wed, 8 Oct 2008 04:19:07 +0800 Subject: Setup translation for addvote.php Signed-off-by: Callan Barrett Signed-off-by: Loui Chang --- web/html/addvote.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'web/html') diff --git a/web/html/addvote.php b/web/html/addvote.php index 8e4df79..449bbb0 100644 --- a/web/html/addvote.php +++ b/web/html/addvote.php @@ -2,7 +2,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); -include("pkgfuncs_po.inc"); +include("tu_po.inc"); include("aur.inc"); set_lang(); check_sid(); @@ -25,23 +25,23 @@ if ($atype == "Trusted User" OR $atype == "Developer") { $check = mysql_num_rows(db_query($qcheck, $dbh)); if ($check == 0) { - $error.= "
Username does not exist.
"; + $error.= "
" . __("Username does not exist.") . "
"; } else { $qcheck = "SELECT * FROM TU_VoteInfo WHERE User = '" . mysql_real_escape_string($_POST['user']) . "'"; $qcheck.= " AND End > UNIX_TIMESTAMP()"; $check = mysql_num_rows(db_query($qcheck, $dbh)); if ($check != 0) { - $error.= "
" . htmlentities($_POST['user']) . " already has proposal running for them.
"; + $error.= "
" . __("%s already has proposal running for them.", htmlentities($_POST['user'])) . "
"; } } } if (!empty($_POST['length'])) { if (!is_numeric($_POST['length'])) { - $error.= "
Length must be a number.
"; + $error.= "
" . __("Length must be a number.") . "
"; } else if ($_POST['length'] < 1) { - $error.= "
Length must be at least 1.
"; + $error.= "
" . __("Length must be at least 1.") . "
"; } else { $len = (60*60*24)*$_POST['length']; } @@ -50,7 +50,7 @@ if ($atype == "Trusted User" OR $atype == "Developer") { } if (empty($_POST['agenda'])) { - $error.= "
Proposal cannot be empty.
"; + $error.= "
" . __("Proposal cannot be empty.") . "
"; } } @@ -62,21 +62,21 @@ if ($atype == "Trusted User" OR $atype == "Developer") { $q.= ", " . uid_from_sid($_COOKIE["AURSID"]) . ")"; db_query($q, $dbh); - print "

New proposal submitted.

\n"; + print "

" . __("New proposal submitted.") . "

\n"; } else { ?> -

Submit a proposal to vote on.

+

"; } ?>
-Applicant/TU: + '> -(empty if not applicable) +
-Length in days: + '> -(defaults to 7 if empty) +
-Proposal:
+

@@ -84,9 +84,9 @@ if ($atype == "Trusted User" OR $atype == "Developer") {
Back"; + print "" . __("Back") . ""; } else { - print "You are not allowed to access this area.\n"; + print __("You are not allowed to access this area."); } html_footer(AUR_VERSION); -- cgit v1.2.3-54-g00ecf From 8f5882e68deec6a8780653ae537aea7aa02283c3 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Sun, 5 Oct 2008 01:46:31 +0800 Subject: Convert package flagging to a function Signed-off-by: Callan Barrett Signed-off-by: Loui Chang --- web/html/packages.php | 101 +++----------------------------------------------- web/lib/pkgfuncs.inc | 74 +++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 96 deletions(-) (limited to 'web/html') diff --git a/web/html/packages.php b/web/html/packages.php index 4cfe9c4..317583f 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -37,106 +37,17 @@ if (isset($_COOKIE["AURSID"])) { # grab the list of Package IDs to be operated on # isset($_POST["IDs"]) ? $ids = $_POST["IDs"] : $ids = array(); -#isset($_REQUEST["All_IDs"]) ? -# $all_ids = explode(":", $_REQUEST["All_IDs"]) : -# $all_ids = array(); - # determine what button the visitor clicked # if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { - if (!$atype) { - print __("You must be logged in before you can flag packages."); - print "
\n"; - - } else { - - if (!empty($ids)) { - $dbh = db_connect(); - - # Flag the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $flag = $pid; - } else { - $flag .= ", ".$pid; - } - } - $q = "UPDATE Packages SET OutOfDate = 1 "; - $q.= "WHERE ID IN (" . $flag . ")"; - db_query($q, $dbh); - - print "

\n"; - print __("The selected packages have been flagged out-of-date."); - print "

\n"; - - # notification by tardo. - $f_name = username_from_sid($_COOKIE['AURSID']); - $f_email = email_from_sid($_COOKIE['AURSID']); - $f_uid = uid_from_sid($_COOKIE['AURSID']); - $q = "SELECT Packages.Name, Users.Email, Packages.ID "; - $q.= "FROM Packages, Users "; - $q.= "WHERE Packages.ID IN (" . $flag .") "; - $q.= "AND Users.ID = Packages.MaintainerUID "; - $q.= "AND Users.ID != " . $f_uid; - $result = db_query($q, $dbh); - if (mysql_num_rows($result)) { - while ($row = mysql_fetch_assoc($result)) { - # construct email - $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . ". You may view your package at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=" . $row['ID']; - $body = wordwrap($body, 70); - $headers = "To: ".$row['Email']."\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n"; - @mail(' ', "AUR Out-of-date Notification for ".$row['Name'], $body, $headers); - } - } - - } else { - print "

\n"; - print __("You did not select any packages to flag."); - print "

\n"; - } - } - + print "

"; + print pkg_flag($atype, $ids, True); + print "

"; } elseif ($_POST['action'] == "do_UnFlag" || isset($_POST['do_UnFlag'])) { - if (!$atype) { - print __("You must be logged in before you can unflag packages."); - print "
\n"; - - } else { - - if (!empty($ids)) { - $dbh = db_connect(); - - # Un-Flag the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $unflag = $pid; - } else { - $unflag .= ", ".$pid; - } - } - $q = "UPDATE Packages SET OutOfDate = 0 "; - $q.= "WHERE ID IN (" . $unflag . ")"; - db_query($q, $dbh); - - print "

\n"; - print __("The selected packages have been unflagged."); - print "

\n"; - } else { - print "

\n"; - print __("You did not select any packages to unflag."); - print "

\n"; - } - - - } - + print "

"; + print pkg_flag($atype, $ids, False); + print "

"; } elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) { if (!$atype) { print __("You must be logged in before you can disown packages."); diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 5ba56da..a508a0b 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -985,4 +985,76 @@ function pkg_search_page($SID="") { return; } -?> +function pkg_flag ($atype, $ids, $action = True) { + if (!$atype) { + if ($action) { + return __("You must be logged in before you can flag packages."); + } else { + return __("You must be logged in before you can unflag packages."); + } + } + + if (empty($ids)) { + if ($action) { + return __("You did not select any packages to flag."); + } else { + return __("You did not select any packages to unflag."); + } + } + + foreach ($ids as $pid => $v) { + if (!is_numeric($pid)) { + if ($action) { + return __("You did not select any packages to flag."); + } else { + return __("You did not select any packages to unflag."); + } + } + } + + $dbh = db_connect(); + + $first = 1; + foreach ($ids as $pid => $v) { + if ($first) { + $first = 0; + $flag = $pid; + } else { + $flag .= ", " . $pid; + } + } + + $ood = $action ? 1 : 0; + $q = "UPDATE Packages SET OutOfDate = " . $ood; + $q.= " WHERE ID IN (" . $flag . ")"; + + db_query($q, $dbh); + + if ($action) { + # Notify of flagging by email + $f_name = username_from_sid($_COOKIE['AURSID']); + $f_email = email_from_sid($_COOKIE['AURSID']); + $f_uid = uid_from_sid($_COOKIE['AURSID']); + $q = "SELECT Packages.Name, Users.Email, Packages.ID "; + $q.= "FROM Packages, Users "; + $q.= "WHERE Packages.ID IN (" . $flag .") "; + $q.= "AND Users.ID = Packages.MaintainerUID "; + $q.= "AND Users.ID != " . $f_uid; + $result = db_query($q, $dbh); + if (mysql_num_rows($result)) { + while ($row = mysql_fetch_assoc($result)) { + # construct email + $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . ". You may view your package at:\nhttp://aur.archlinux.org/packages.php?ID=" . $row['ID']; + $body = wordwrap($body, 70); + $headers = "To: ".$row['Email']."\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n"; + @mail(' ', "AUR Out-of-date Notification for ".$row['Name'], $body, $headers); + } + } + } + + if ($action) { + return __("The selected packages have been flagged out-of-date."); + } else { + return __("The selected packages have been unflagged."); + } +} -- cgit v1.2.3-54-g00ecf From a447281d4f5ce2071ebc81b375c70ae44231b046 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Sat, 4 Oct 2008 03:42:34 +0800 Subject: Convert package deletion to a function Signed-off-by: Callan Barrett Signed-off-by: Loui Chang --- web/html/packages.php | 90 +++------------------------------------------------ web/lib/pkgfuncs.inc | 73 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 86 deletions(-) (limited to 'web/html') diff --git a/web/html/packages.php b/web/html/packages.php index 317583f..bc3ed18 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -22,7 +22,7 @@ if (isset($_GET['ID'])) { $title = __("Packages"); } -html_header($title); # print out the HTML header +html_header($title); # get login privileges # @@ -95,91 +95,9 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { } elseif ($_POST['action'] == "do_Delete" || isset($_POST['do_Delete'])) { - if (!$atype) { - print __("You must be logged in before you can disown packages."); - print "
\n"; - } else { - # Delete the packages in $ids array (but only if they are Unsupported) - # - if (!empty($ids)) { - $dbh = db_connect(); - - # Delete the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $delete = $pid; - } else { - $delete .= ", ".$pid; - } - } - - $field = "MaintainerUID"; - - # Only grab Unsupported packages that "we" own or are not owned at all - # - $ids_to_delete = array(); - $q = "SELECT Packages.ID FROM Packages, PackageLocations "; - $q.= "WHERE Packages.ID IN (" . $delete . ") "; - $q.= "AND Packages.LocationID = PackageLocations.ID "; - $q.= "AND PackageLocations.Location = 'unsupported' "; - # If they're a TU or dev, can always delete, otherwise check ownership - # - if ($atype == "Trusted User" || $atype == "Developer") { - $result = db_query($q, $dbh); - } - if ($result != Null && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_assoc($result)) { - $ids_to_delete[] = $row['ID']; - } - } - if (!empty($ids_to_delete)) { - # These are the packages that are safe to delete - # - foreach ($ids_to_delete as $id) { - # delete from PackageVotes - $q = "DELETE FROM PackageVotes WHERE PackageID = " . $id; - $result = db_query($q, $dbh); - - # delete from PackageDepends - $q = "DELETE FROM PackageDepends WHERE PackageID = " . $id; - $result = db_query($q, $dbh); - - # delete from PackageSources - $q = "DELETE FROM PackageSources WHERE PackageID = " . $id; - $result = db_query($q, $dbh); - - # delete from PackageComments - $q = "DELETE FROM PackageComments WHERE PackageID = " . $id; - $result = db_query($q, $dbh); - - # delete from Packages - $q = "DELETE FROM Packages WHERE ID = " . $id; - $result = db_query($q, $dbh); - - # delete from CommentNotify - $q = "DELETE FROM CommentNotify WHERE PkgID = " . $id; - $result = db_query($q, $dbh); - - # Print the success message - print "

\n"; - print __("The selected packages have been deleted."); - print "

\n"; - } - } else { - print "

\n"; - print __("None of the selected packages could be deleted."); - print "

\n"; - } # end if (!empty($ids_to_delete)) - } else { - print "

\n"; - print __("You did not select any packages to delete."); - print "

\n"; - } # end if (!empty($ids)) - } # end if (!atype) - + print "

"; + print pkg_delete($atype, $ids, False); + print "

"; } elseif ($_POST['action'] == "do_Adopt" || isset($_POST['do_Adopt'])) { if (!$atype) { print __("You must be logged in before you can adopt packages."); diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index a508a0b..c952b85 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -1058,3 +1058,76 @@ function pkg_flag ($atype, $ids, $action = True) { return __("The selected packages have been unflagged."); } } + +function pkg_delete ($atype, $ids) { + if (!$atype) { + return __("You must be logged in before you can disown packages."); + } + + if (empty($ids)) { + return __("You did not select any packages to delete."); + } + + # Delete the packages in $ids array (but only if they are Unsupported) + # + $dbh = db_connect(); + + # Delete the packages in $ids array + # + $first = 1; + foreach ($ids as $pid => $v) { + if ($first) { + $first = 0; + $delete = $pid; + } else { + $delete .= ", ".$pid; + } + } + + $field = "MaintainerUID"; + + # Only grab Unsupported packages that "we" own or are not owned at all + $ids_to_delete = array(); + $q = "SELECT Packages.ID FROM Packages, PackageLocations "; + $q.= "WHERE Packages.ID IN (" . $delete . ") "; + $q.= "AND Packages.LocationID = PackageLocations.ID "; + $q.= "AND PackageLocations.Location = 'unsupported' "; + + # If they're a TU or dev, can delete + if ($atype == "Trusted User" || $atype == "Developer") { + $result = db_query($q, $dbh); + } + + if ($result != Null && mysql_num_rows($result) > 0) { + while ($row = mysql_fetch_assoc($result)) { + $ids_to_delete[] = $row['ID']; + } + } + + if (empty($ids_to_delete)) { + return __("None of the selected packages could be deleted."); + } + + # These are the packages that are safe to delete + foreach ($ids_to_delete as $id) { + $q = "DELETE FROM PackageVotes WHERE PackageID = " . $id; + $result = db_query($q, $dbh); + + $q = "DELETE FROM PackageDepends WHERE PackageID = " . $id; + $result = db_query($q, $dbh); + + $q = "DELETE FROM PackageSources WHERE PackageID = " . $id; + $result = db_query($q, $dbh); + + $q = "DELETE FROM PackageComments WHERE PackageID = " . $id; + $result = db_query($q, $dbh); + + $q = "DELETE FROM Packages WHERE ID = " . $id; + $result = db_query($q, $dbh); + + $q = "DELETE FROM CommentNotify WHERE PkgID = " . $id; + $result = db_query($q, $dbh); + } + + return __("The selected packages have been deleted."); +} -- cgit v1.2.3-54-g00ecf From 5d4303d0b6afacb2b3a8731bdb9fdbd6c40f5c0e Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Sun, 5 Oct 2008 02:13:35 +0800 Subject: Convert package adoption/disowning to a function Signed-off-by: Callan Barrett Signed-off-by: Loui Chang --- web/html/packages.php | 100 +++----------------------------------------------- web/lib/pkgfuncs.inc | 58 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 94 deletions(-) (limited to 'web/html') diff --git a/web/html/packages.php b/web/html/packages.php index bc3ed18..5935ebd 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -49,105 +49,17 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { print pkg_flag($atype, $ids, False); print "

"; } elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) { - if (!$atype) { - print __("You must be logged in before you can disown packages."); - print "
\n"; - - } else { - # Disown the packages in $ids array - # - if (!empty($ids)) { - $dbh = db_connect(); - - # Disown the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $disown = $pid; - } else { - $disown .= ", ".$pid; - } - } - - $field = "MaintainerUID"; - $q = "UPDATE Packages "; - $q.= "SET ".$field." = 0 "; - $q.= "WHERE ID IN (" . $disown . ") "; - # If a user is a TU or dev they can disown any package - if ($atype == "User") { - $q.= "AND ".$field." = ".uid_from_sid($_COOKIE["AURSID"]); - } - db_query($q, $dbh); - - print "

\n"; - print __("The selected packages have been disowned."); - print "

\n"; - } else { - print "

\n"; - print __("You did not select any packages to disown."); - print "

\n"; - } - - - } - - + print "

"; + print pkg_adopt($atype, $ids, False); + print "

"; } elseif ($_POST['action'] == "do_Delete" || isset($_POST['do_Delete'])) { print "

"; print pkg_delete($atype, $ids, False); print "

"; } elseif ($_POST['action'] == "do_Adopt" || isset($_POST['do_Adopt'])) { - if (!$atype) { - print __("You must be logged in before you can adopt packages."); - print "
\n"; - - } else { - # Adopt the packages in $ids array - # - if (!empty($ids)) { - $dbh = db_connect(); - - # Adopt the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $adopt = $pid; - } else { - $adopt .= ", ".$pid; - } - } - - $field = "MaintainerUID"; - # NOTE: Only "orphaned" packages can be adopted at a particular - # user class (TU/Dev or User). - # - $q = "UPDATE Packages "; - $q.= "SET ".$field." = ".uid_from_sid($_COOKIE["AURSID"])." "; - $q.= "WHERE ID IN (" . $adopt . ") "; - if ($atype == "User") - { - # Regular users may only adopt orphan packages from unsupported - # FIXME: We assume that LocationID for unsupported is "2" - $q.= "AND ".$field." = 0"; - $q.= " AND LocationID = 2"; - } - db_query($q, $dbh); - - print "

\n"; - print __("The selected packages have been adopted."); - print "

\n"; - } else { - print "

\n"; - print __("You did not select any packages to adopt."); - print "

\n"; - } - } - - + print "

"; + print pkg_adopt($atype, $ids, True); + print "

"; } elseif ($_POST['action'] == "do_Vote" || isset($_POST['do_Vote'])) { if (!$atype) { print __("You must be logged in before you can vote for packages."); diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index c952b85..415f3e7 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -1131,3 +1131,61 @@ function pkg_delete ($atype, $ids) { return __("The selected packages have been deleted."); } + +function pkg_adopt ($atype, $ids, $action = True) { + if (!$atype) { + if ($action) { + return __("You must be logged in before you can adopt packages."); + } else { + return __("You must be logged in before you can disown packages."); + } + } + + if (empty($ids)) { + if ($action) { + return __("You did not select any packages to adopt."); + } else { + return __("You did not select any packages to disown."); + } + } + + $dbh = db_connect(); + + $first = 1; + foreach ($ids as $pid => $v) { + if ($first) { + $first = 0; + $pkg = $pid; + } else { + $pkg .= ", ".$pid; + } + } + + $field = "MaintainerUID"; + $q = "UPDATE Packages "; + + if ($action) { + $user = uid_from_sid($_COOKIE["AURSID"]); + } else { + $user = 0; + } + + $q.= "SET $field = $user "; + $q.= "WHERE ID IN ($pkg) "; + + if ($action && $atype == "User") { + # Regular users may only adopt orphan packages from unsupported + $q.= "AND $field = 0 "; + $q.= "AND LocationID = 2 "; + } else if ($atype == "User") { + $q.= "AND $field = " . uid_from_sid($_COOKIE["AURSID"]); + } + + db_query($q, $dbh); + + if ($action) { + return __("The selected packages have been adopted."); + } else { + return __("The selected packages have been disowned."); + } +} -- cgit v1.2.3-54-g00ecf From 132fd7cfc791a76f084140b2901018a046160b84 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Sun, 5 Oct 2008 02:54:13 +0800 Subject: Convert package voting to a function Signed-off-by: Callan Barrett Signed-off-by: Loui Chang --- web/html/packages.php | 112 +++----------------------------------------------- web/lib/pkgfuncs.inc | 77 ++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 106 deletions(-) (limited to 'web/html') diff --git a/web/html/packages.php b/web/html/packages.php index 5935ebd..91b0e6e 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -61,113 +61,13 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { print pkg_adopt($atype, $ids, True); print "

"; } elseif ($_POST['action'] == "do_Vote" || isset($_POST['do_Vote'])) { - if (!$atype) { - print __("You must be logged in before you can vote for packages."); - print "
\n"; - - } else { - # vote on the packages in $ids array. - # - if (!empty($ids)) { - $dbh = db_connect(); - $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]); - $uid = uid_from_sid($_COOKIE["AURSID"]); - # $vote_ids will contain the string of Package.IDs that - # the visitor hasn't voted for already - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if (!isset($my_votes[$pid])) { - # cast a vote for this package - # - if ($first) { - $first = 0; - $vote_ids = $pid; - $vote_clauses = "(".$uid.", ".$pid.")"; - } else { - $vote_ids .= ", ".$pid; - $vote_clauses .= ", (".$uid.", ".$pid.")"; - } - } - } - # only vote for packages the user hasn't already voted for - # - $q = "UPDATE Packages SET NumVotes = NumVotes + 1 "; - $q.= "WHERE ID IN (".$vote_ids.")"; - db_query($q, $dbh); - - $q = "INSERT INTO PackageVotes (UsersID, PackageID) VALUES "; - $q.= $vote_clauses; - db_query($q, $dbh); - - # Update the LastVoted field for this user - # - $q = "UPDATE Users SET LastVoted = UNIX_TIMESTAMP() "; - $q.= "WHERE ID = ".$uid; - db_query($q, $dbh); - - print "

\n"; - print __("Your votes have been cast for the selected packages."); - print "

\n"; - - } else { - print "

\n"; - print __("You did not select any packages to vote for."); - print "

\n"; - } - } - - + print "

"; + print pkg_vote($atype, $ids, True); + print "

"; } elseif ($_POST['action'] == "do_UnVote" || isset($_POST['do_UnVote'])) { - if (!$atype) { - print __("You must be logged in before you can un-vote for packages."); - print "
\n"; - - } else { - # un-vote on the packages in $ids array. - # - if (!empty($ids)) { - $dbh = db_connect(); - $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]); - $uid = uid_from_sid($_COOKIE["AURSID"]); - # $unvote_ids will contain the string of Package.IDs that - # the visitor has voted for and wants to unvote. - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if (isset($my_votes[$pid])) { - # cast a un-vote for this package - # - if ($first) { - $first = 0; - $unvote_ids = $pid; - } else { - $unvote_ids .= ", ".$pid; - } - } - } - # only un-vote for packages the user has already voted for - # - $q = "UPDATE Packages SET NumVotes = NumVotes - 1 "; - $q.= "WHERE ID IN (".$unvote_ids.")"; - db_query($q, $dbh); - - $q = "DELETE FROM PackageVotes WHERE UsersID = ".$uid." "; - $q.= "AND PackageID IN (".$unvote_ids.")"; - db_query($q, $dbh); - - print "

\n"; - print __("Your votes have been removed from the selected packages."); - print "

\n"; - - } else { - print "

\n"; - print __("You did not select any packages to un-vote for."); - print "

\n"; - } - } - - + print "

"; + print pkg_vote($atype, $ids, False); + print "

"; } elseif (isset($_GET["ID"])) { if (!intval($_GET["ID"])) { diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 415f3e7..7fe3f31 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -1189,3 +1189,80 @@ function pkg_adopt ($atype, $ids, $action = True) { return __("The selected packages have been disowned."); } } + +function pkg_vote ($atype, $ids, $action = True) { + if (!$atype) { + if ($action) { + return __("You must be logged in before you can vote for packages."); + } else { + return __("You must be logged in before you can un-vote for packages."); + } + } + + if (empty($ids)) { + if ($action) { + return __("You did not select any packages to vote for."); + } else { + return __("Your votes have been removed from the selected packages."); + } + } + + $dbh = db_connect(); + $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]); + $uid = uid_from_sid($_COOKIE["AURSID"]); + + $first = 1; + foreach ($ids as $pid => $v) { + if ($action) { + $check = !isset($my_votes[$pid]); + } else { + $check = isset($my_votes[$pid]); + } + + if ($check) { + if ($first) { + $first = 0; + $vote_ids = $pid; + if ($action) { + $vote_clauses = "($uid, $pid)"; + } + } else { + $vote_ids .= ", $pid"; + if ($action) { + $vote_clauses .= ", ($uid, $pid)"; + } + } + } + } + + # only vote for packages the user hasn't already voted for + # + $op = $action ? "+" : "-"; + $q = "UPDATE Packages SET NumVotes = NumVotes $op 1 "; + $q.= "WHERE ID IN ($vote_ids)"; + + db_query($q, $dbh); + + if ($action) { + $q = "INSERT INTO PackageVotes (UsersID, PackageID) VALUES "; + $q.= $vote_clauses; + } else { + $q = "DELETE FROM PackageVotes WHERE UsersID = $uid "; + $q.= "AND PackageID IN ($vote_ids)"; + } + + db_query($q, $dbh); + + if ($action) { + $q = "UPDATE Users SET LastVoted = UNIX_TIMESTAMP() "; + $q.= "WHERE ID = $uid"; + + db_query($q, $dbh); + } + + if ($action) { + return __("Your votes have been cast for the selected packages."); + } else { + return __("Your votes have been removed from the selected packages."); + } +} -- cgit v1.2.3-54-g00ecf