summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common.php26
-rw-r--r--lib/settingsaction.php25
2 files changed, 51 insertions, 0 deletions
diff --git a/lib/common.php b/lib/common.php
index f30096796..b4c2f9b6e 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -22,6 +22,7 @@ if (!defined('LACONICA')) { exit(1) }
define('AVATAR_PROFILE_SIZE', 96);
define('AVATAR_STREAM_SIZE', 48);
define('AVATAR_MINI_SIZE', 24);
+define('MAX_AVATAR_SIZE', 256 * 1024);
# global configuration object
@@ -30,6 +31,9 @@ define('AVATAR_MINI_SIZE', 24);
$config =
array('site' =>
array('name' => 'Just another µB'),
+ 'avatar' =>
+ array('directory' => INSTALLDIR . 'files',
+ 'path' => '/files'),
'dsn' =>
array('phptype' => 'mysql',
'username' => 'stoica',
@@ -228,6 +232,28 @@ function common_render_content($text) {
return htmlspecialchars($text);
}
+// where should the avatar go for this user?
+
+function common_avatar_filename($user, $extension, $size=NULL) {
+ global $config;
+
+ if ($size) {
+ return $user->id . '-' . $size . $extension;
+ } else {
+ return $user->id . '-original' . $extension;
+ }
+}
+
+function common_avatar_path($filename) {
+ global $config;
+ return $config['avatar']['directory'] . '/' . $filename;
+}
+
+function common_avatar_url($filename) {
+ global $config;
+ return $config['avatar']['path'] . '/' . $filename;
+}
+
// XXX: set up gettext
function _t($str) { $str }
diff --git a/lib/settingsaction.php b/lib/settingsaction.php
index db07bdef9..1795969f9 100644
--- a/lib/settingsaction.php
+++ b/lib/settingsaction.php
@@ -23,8 +23,33 @@ class SettingsAction extends Action {
function handle($args) {
parent::handle($args);
+ if (!common_logged_in()) {
+ common_user_error(_t('Not logged in.'));
+ return;
+ }
+ if ($this->arg('METHOD') == 'POST') {
+ $this->handle_post();
+ } else {
+ $this->show_form();
+ }
}
+ # override!
+ function handle_post() {
+ return false;
+ }
+
+ function show_form($msg=NULL, $success=false) {
+ return false;
+ }
+
+ function show_message($msg, $success) {
+ if ($msg) {
+ common_element('div', ($success) ? 'success' : 'error',
+ $msg);
+ }
+ }
+
function settings_menu() {
common_element_start('ul', 'headmenu');
common_menu_item(common_local_url('editprofile'),