summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-09-15 21:18:59 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2013-09-15 21:18:59 +0200
commitad82a56f79fa46fae0742d0647008025e32c3d2b (patch)
tree8b407c82b7e44761cfba105be1f10d17efcfaef7 /lib
parent4480b0b16409c9c2f3fcca34afbd5bd5d2d2a6e2 (diff)
parent339c98e5e69103806f03d1eac660f69d1583c5c2 (diff)
downloadnextcloud-server-ad82a56f79fa46fae0742d0647008025e32c3d2b.tar.gz
nextcloud-server-ad82a56f79fa46fae0742d0647008025e32c3d2b.zip
Merge branch 'master' into appframework-master
Diffstat (limited to 'lib')
-rw-r--r--lib/avatar.php89
-rw-r--r--lib/base.php8
-rw-r--r--lib/installer.php1
-rw-r--r--lib/l10n/km.php8
-rw-r--r--lib/l10n/lt_LT.php49
-rw-r--r--lib/notsquareexception.php12
-rw-r--r--lib/templatelayout.php1
7 files changed, 163 insertions, 5 deletions
diff --git a/lib/avatar.php b/lib/avatar.php
new file mode 100644
index 00000000000..f20980c364b
--- /dev/null
+++ b/lib/avatar.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+/**
+ * This class gets and sets users avatars.
+ */
+
+class OC_Avatar {
+
+ private $view;
+
+ /**
+ * @brief constructor
+ * @param $user string user to do avatar-management with
+ */
+ public function __construct ($user) {
+ $this->view = new \OC\Files\View('/'.$user);
+ }
+
+ /**
+ * @brief get the users avatar
+ * @param $size integer size in px of the avatar, defaults to 64
+ * @return boolean|\OC_Image containing the avatar or false if there's no image
+ */
+ public function get ($size = 64) {
+ if ($this->view->file_exists('avatar.jpg')) {
+ $ext = 'jpg';
+ } elseif ($this->view->file_exists('avatar.png')) {
+ $ext = 'png';
+ } else {
+ return false;
+ }
+
+ $avatar = new OC_Image();
+ $avatar->loadFromData($this->view->file_get_contents('avatar.'.$ext));
+ $avatar->resize($size);
+ return $avatar;
+ }
+
+ /**
+ * @brief sets the users avatar
+ * @param $data mixed imagedata or path to set a new avatar
+ * @throws Exception if the provided file is not a jpg or png image
+ * @throws Exception if the provided image is not valid
+ * @throws \OC\NotSquareException if the image is not square
+ * @return void
+ */
+ public function set ($data) {
+ if (\OC_App::isEnabled('files_encryption')) {
+ $l = \OC_L10N::get('lib');
+ throw new \Exception($l->t("Custom profile pictures don't work with encryption yet"));
+ }
+
+ $img = new OC_Image($data);
+ $type = substr($img->mimeType(), -3);
+ if ($type === 'peg') { $type = 'jpg'; }
+ if ($type !== 'jpg' && $type !== 'png') {
+ $l = \OC_L10N::get('lib');
+ throw new \Exception($l->t("Unknown filetype"));
+ }
+
+ if (!$img->valid()) {
+ $l = \OC_L10N::get('lib');
+ throw new \Exception($l->t("Invalid image"));
+ }
+
+ if (!($img->height() === $img->width())) {
+ throw new \OC\NotSquareException();
+ }
+
+ $this->view->unlink('avatar.jpg');
+ $this->view->unlink('avatar.png');
+ $this->view->file_put_contents('avatar.'.$type, $data);
+ }
+
+ /**
+ * @brief remove the users avatar
+ * @return void
+ */
+ public function remove () {
+ $this->view->unlink('avatar.jpg');
+ $this->view->unlink('avatar.png');
+ }
+}
diff --git a/lib/base.php b/lib/base.php
index 76779f66d16..05d151439a4 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -271,6 +271,14 @@ class OC {
OC_Util::addScript('router');
OC_Util::addScript("oc-requesttoken");
+ // avatars
+ if (\OC_Config::getValue('enable_avatars', true) === true) {
+ \OC_Util::addScript('placeholder');
+ \OC_Util::addScript('3rdparty', 'md5/md5.min');
+ \OC_Util::addScript('jquery.avatar');
+ \OC_Util::addScript('avatar');
+ }
+
OC_Util::addStyle("styles");
OC_Util::addStyle("apps");
OC_Util::addStyle("fixes");
diff --git a/lib/installer.php b/lib/installer.php
index 607e6da7265..e082c7eeee9 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -428,6 +428,7 @@ class OC_Installer{
'OC_API::',
'OC_App::',
'OC_AppConfig::',
+ 'OC_Avatar',
'OC_BackgroundJob::',
'OC_Config::',
'OC_DB::',
diff --git a/lib/l10n/km.php b/lib/l10n/km.php
new file mode 100644
index 00000000000..e7b09649a24
--- /dev/null
+++ b/lib/l10n/km.php
@@ -0,0 +1,8 @@
+<?php
+$TRANSLATIONS = array(
+"_%n minute ago_::_%n minutes ago_" => array(""),
+"_%n hour ago_::_%n hours ago_" => array(""),
+"_%n day go_::_%n days ago_" => array(""),
+"_%n month ago_::_%n months ago_" => array("")
+);
+$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/lt_LT.php b/lib/l10n/lt_LT.php
index 242b0a23106..1fd9b9ea634 100644
--- a/lib/l10n/lt_LT.php
+++ b/lib/l10n/lt_LT.php
@@ -1,30 +1,69 @@
<?php
$TRANSLATIONS = array(
+"App \"%s\" can't be installed because it is not compatible with this version of ownCloud." => "Programa „%s“ negali būti įdiegta, nes yra nesuderinama su šia ownCloud versija.",
+"No app name specified" => "Nenurodytas programos pavadinimas",
"Help" => "Pagalba",
"Personal" => "Asmeniniai",
"Settings" => "Nustatymai",
"Users" => "Vartotojai",
"Admin" => "Administravimas",
+"Failed to upgrade \"%s\"." => "Nepavyko pakelti „%s“ versijos.",
"web services under your control" => "jūsų valdomos web paslaugos",
+"cannot open \"%s\"" => "nepavyksta atverti „%s“",
"ZIP download is turned off." => "ZIP atsisiuntimo galimybė yra išjungta.",
"Files need to be downloaded one by one." => "Failai turi būti parsiunčiami vienas po kito.",
"Back to Files" => "Atgal į Failus",
"Selected files too large to generate zip file." => "Pasirinkti failai per dideli archyvavimui į ZIP.",
+"Download the files in smaller chunks, seperately or kindly ask your administrator." => "Atsisiųskite failus mažesnėmis dalimis atskirai, arba mandagiai prašykite savo administratoriaus.",
+"No source specified when installing app" => "Nenurodytas šaltinis diegiant programą",
+"No href specified when installing app from http" => "Nenurodytas href diegiant programą iš http",
+"No path specified when installing app from local file" => "Nenurodytas kelias diegiant programą iš vietinio failo",
+"Archives of type %s are not supported" => "%s tipo archyvai nepalaikomi",
+"Failed to open archive when installing app" => "Nepavyko atverti archyvo diegiant programą",
+"App does not provide an info.xml file" => "Programa nepateikia info.xml failo",
+"App can't be installed because of not allowed code in the App" => "Programa negali būti įdiegta, nes turi neleistiną kodą",
+"App can't be installed because it is not compatible with this version of ownCloud" => "Programa negali būti įdiegta, nes yra nesuderinama su šia ownCloud versija",
+"App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps" => "Programa negali būti įdiegta, nes turi <shipped>true</shipped> žymę, kuri yra neleistina ne kartu platinamoms programoms",
+"App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "Programa negali būti įdiegta, nes versija pateikta info.xml/version nesutampa su versija deklaruota programų saugykloje",
+"App directory already exists" => "Programos aplankas jau egzistuoja",
+"Can't create app folder. Please fix permissions. %s" => "Nepavyksta sukurti aplanko. Prašome pataisyti leidimus. %s",
"Application is not enabled" => "Programa neįjungta",
"Authentication error" => "Autentikacijos klaida",
"Token expired. Please reload page." => "Sesija baigėsi. Prašome perkrauti puslapį.",
"Files" => "Failai",
"Text" => "Žinučių",
"Images" => "Paveikslėliai",
+"%s enter the database username." => "%s įrašykite duombazės naudotojo vardą.",
+"%s enter the database name." => "%s įrašykite duombazės pavadinimą.",
+"%s you may not use dots in the database name" => "%s negalite naudoti taškų duombazės pavadinime",
+"MS SQL username and/or password not valid: %s" => "MS SQL naudotojo vardas ir/arba slaptažodis netinka: %s",
+"You need to enter either an existing account or the administrator." => "Turite prisijungti su egzistuojančia paskyra arba su administratoriumi.",
+"MySQL username and/or password not valid" => "Neteisingas MySQL naudotojo vardas ir/arba slaptažodis",
+"DB Error: \"%s\"" => "DB klaida: \"%s\"",
+"Offending command was: \"%s\"" => "Vykdyta komanda buvo: \"%s\"",
+"MySQL user '%s'@'localhost' exists already." => "MySQL naudotojas '%s'@'localhost' jau egzistuoja.",
+"Drop this user from MySQL" => "Pašalinti šį naudotoją iš MySQL",
+"MySQL user '%s'@'%%' already exists" => "MySQL naudotojas '%s'@'%%' jau egzistuoja",
+"Drop this user from MySQL." => "Pašalinti šį naudotoją iš MySQL.",
+"Oracle connection could not be established" => "Nepavyko sukurti Oracle ryšio",
+"Oracle username and/or password not valid" => "Neteisingas Oracle naudotojo vardas ir/arba slaptažodis",
+"Offending command was: \"%s\", name: %s, password: %s" => "Vykdyta komanda buvo: \"%s\", name: %s, password: %s",
+"PostgreSQL username and/or password not valid" => "Neteisingas PostgreSQL naudotojo vardas ir/arba slaptažodis",
+"Set an admin username." => "Nustatyti administratoriaus naudotojo vardą.",
+"Set an admin password." => "Nustatyti administratoriaus slaptažodį.",
+"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Jūsų serveris nėra tvarkingai nustatytas leisti failų sinchronizaciją, nes WebDAV sąsaja panašu, kad yra sugadinta.",
+"Please double check the <a href='%s'>installation guides</a>." => "Prašome pažiūrėkite dar kartą <a href='%s'>diegimo instrukcijas</a>.",
"seconds ago" => "prieš sekundę",
-"_%n minute ago_::_%n minutes ago_" => array("",""," prieš %n minučių"),
-"_%n hour ago_::_%n hours ago_" => array("","","prieš %n valandų"),
+"_%n minute ago_::_%n minutes ago_" => array("prieš %n min.","Prieš % minutes","Prieš %n minučių"),
+"_%n hour ago_::_%n hours ago_" => array("Prieš %n valandą","Prieš %n valandas","Prieš %n valandų"),
"today" => "šiandien",
"yesterday" => "vakar",
-"_%n day go_::_%n days ago_" => array("","",""),
+"_%n day go_::_%n days ago_" => array("Prieš %n dieną","Prieš %n dienas","Prieš %n dienų"),
"last month" => "praeitą mėnesį",
-"_%n month ago_::_%n months ago_" => array("","","prieš %n mėnesių"),
+"_%n month ago_::_%n months ago_" => array("Prieš %n mėnesį","Prieš %n mėnesius","Prieš %n mėnesių"),
"last year" => "praeitais metais",
-"years ago" => "prieš metus"
+"years ago" => "prieš metus",
+"Caused by:" => "Iššaukė:",
+"Could not find category \"%s\"" => "Nepavyko rasti kategorijos „%s“"
);
$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);";
diff --git a/lib/notsquareexception.php b/lib/notsquareexception.php
new file mode 100644
index 00000000000..03dba8fb25f
--- /dev/null
+++ b/lib/notsquareexception.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC;
+
+class NotSquareException extends \Exception {
+}
diff --git a/lib/templatelayout.php b/lib/templatelayout.php
index 0b868a39e49..625f3424a04 100644
--- a/lib/templatelayout.php
+++ b/lib/templatelayout.php
@@ -46,6 +46,7 @@ class OC_TemplateLayout extends OC_Template {
$user_displayname = OC_User::getDisplayName();
$this->assign( 'user_displayname', $user_displayname );
$this->assign( 'user_uid', OC_User::getUser() );
+ $this->assign('enableAvatars', \OC_Config::getValue('enable_avatars', true));
} else if ($renderas == 'guest' || $renderas == 'error') {
parent::__construct('core', 'layout.guest');
} else {