Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 1ab56685ccd027103b868282282f23306052d871 Mon Sep 17 00:00:00 2001
- From: =?UTF-8?q?Patricio=20P=C3=A9rez?= <janitux@boaboa.org>
- Date: Fri, 20 Aug 2010 19:03:22 -0400
- Subject: [PATCH] * Designer profiles
- ---
- server/lib/user.php | 90 ++++++++++++++++++++++++++++--
- server/profile.php | 26 ++++++++-
- server/templates/change_user_details.php | 29 ++++++++-
- server/templates/gallery.php | 54 +++++++++++++++++-
- static/css/style.css | 66 +++++++++++++++++++++-
- 5 files changed, 250 insertions(+), 15 deletions(-)
- mode change 100644 => 100755 server/lib/user.php
- mode change 100644 => 100755 server/templates/change_user_details.php
- mode change 100644 => 100755 server/templates/gallery.php
- mode change 100644 => 100755 static/css/style.css
- diff --git a/server/lib/user.php b/server/lib/user.php
- old mode 100644
- new mode 100755
- index 064b4ea..efa1df3
- --- a/server/lib/user.php
- +++ b/server/lib/user.php
- @@ -68,6 +68,9 @@ class PersonaUser
- var $_privs = 0;
- var $_errors = array();
- var $_no_signup = 0;
- + var $_location = null;
- + var $_homepage = null;
- + var $_public_mail = 0;
- function __construct($username = null, $password = null, $hostname = null, $dbname = null)
- {
- @@ -161,7 +164,7 @@ class PersonaUser
- try
- {
- - $select_stmt = 'select username, display_username, email, privs, description from users where username = :username';
- + $select_stmt = 'select username, display_username, email, privs, description, location, homepage, public_mail from users where username = :username';
- $sth = $this->_dbh->prepare($select_stmt);
- $sth->bindParam(':username', $username);
- $sth->execute();
- @@ -245,6 +248,63 @@ class PersonaUser
- }
- #####
- +# Get the users public email preference. If called without a username, uses the record of the authed user.
- +
- + function get_public_email($username = null)
- + {
- + if(!$username)
- + return $this->_public_mail;
- +
- + $data = $this->get_user_data($username);
- + return $data['public_mail'];
- + }
- +
- +#####
- +# Get the users location. If called without a username, uses the record of the authed user.
- +
- + function get_location($username = null)
- + {
- + if(!$username)
- + return $this->_location;
- +
- + $data = $this->get_user_data($username);
- + return $data['location'];
- + }
- +
- +#####
- +# Get the users homepage. If called without a username, uses the record of the authed user.
- +
- + function get_homepage($username = null)
- + {
- + if(!$username)
- + return $this->_homepage;
- +
- + $data = $this->get_user_data($username);
- + return $data['homepage'];
- + }
- +
- +#####
- +# Get the users picture. If the user doesn't have a picture, default_picture is shown
- +
- + function get_picture($username)
- + {
- + $user_picture = PERSONAS_STORAGE_PREFIX . "/user_pictures/" . $username . ".png";
- + if(!(file_exists($user_picture) && is_file($user_picture)))
- + return STATIC_BASE_URL.PERSONAS_LIVE_PREFIX . "/user_pictures/" . "default_picture.png";
- +
- + return STATIC_BASE_URL.PERSONAS_LIVE_PREFIX . "/user_pictures/" . $username . ".png";
- + }
- +
- +#####
- +# Resizes and moves the user picture
- +
- + function resize_picture($avatar_file, $username = null)
- + {
- + $conv_cmd = "convert " . $avatar_file . " -resize 150x150 " . PERSONAS_STORAGE_PREFIX . "/user_pictures/" . $username . ".png";
- + exec($conv_cmd);
- + }
- +
- +#####
- # Returns the contents of the error array, if anything has been written to it.
- function get_errors()
- @@ -289,7 +349,7 @@ class PersonaUser
- #####
- # Adds a user to the database
- - function create_user($username, $password, $display_username = null, $email = "", $description = "", $news = 0)
- + function create_user($username, $password, $display_username = null, $email = "", $description = "", $news = 0, $location = "", $homepage = "", $public_mail = 0)
- {
- if (!$username)
- throw new Exception("No username", 404);
- @@ -305,7 +365,7 @@ class PersonaUser
- try
- {
- - $insert_stmt = 'insert into users (username, display_username, md5, email, description, news, privs) values (:username, :display_username, :md5, :email, :description, :news, 1)';
- + $insert_stmt = 'insert into users (username, display_username, md5, email, description, news, privs, location, homepage, public_mail) values (:username, :display_username, :md5, :email, :description, :news, 1, :location, :homepage, :public_mail)';
- $sth = $this->_dbh_master->prepare($insert_stmt);
- $sth->bindParam(':username', $username);
- $sth->bindParam(':display_username', $display_username);
- @@ -313,6 +373,9 @@ class PersonaUser
- $sth->bindParam(':email', $email);
- $sth->bindParam(':description', $description);
- $sth->bindParam(':news', $news);
- + $sth->bindParam(':location', $location);
- + $sth->bindParam(':homepage', $homepage);
- + $sth->bindParam(':public_mail', $public_mail);
- $sth->execute();
- }
- catch( PDOException $exception )
- @@ -328,6 +391,9 @@ class PersonaUser
- $this->_display_username = $display_username;
- $this->_description = $description;
- $this->_email = $email;
- + $this->_location = $location;
- + $this->_homepage = $homepage;
- + $this->_public_mail = $public_mail;
- $this->_cookie_value = $username . " " . md5($username . md5($password) . PERSONAS_LOGIN_SALT);
- setcookie('PERSONA_USER', $this->_cookie_value, time() + 60*60*24*365, '/');
- @@ -349,7 +415,7 @@ class PersonaUser
- try
- {
- - $insert_stmt = 'insert into users (username, display_username, md5, email, description, news, privs) values (:username, :display_username, "", "", "", 0, 0)';
- + $insert_stmt = 'insert into users (username, display_username, md5, email, description, news, privs, location, homepage, public_mail) values (:username, :display_username, "", "", "", 0, 0, "", "", 0)';
- $sth = $this->_dbh_master->prepare($insert_stmt);
- $sth->bindParam(':username', $username);
- $sth->bindParam(':display_username', $username);
- @@ -367,7 +433,7 @@ class PersonaUser
- #####
- # Updates a user record
- - function update_user($username, $display_username = null, $email = "", $description = "", $news = 0)
- + function update_user($username, $display_username = null, $email = "", $description = "", $news = 0, $location = "", $homepage = "", $public_mail = 0)
- {
- if (!$username)
- throw new Exception("No username", 404);
- @@ -380,13 +446,16 @@ class PersonaUser
- try
- {
- - $insert_stmt = 'update users set display_username = :display_username, email = :email, description = :description, news = :news where username = :username';
- + $insert_stmt = 'update users set display_username = :display_username, email = :email, description = :description, news = :news, location = :location, homepage = :homepage, public_mail = :public_mail where username = :username';
- $sth = $this->_dbh_master->prepare($insert_stmt);
- $sth->bindParam(':username', $username);
- $sth->bindParam(':display_username', $display_username);
- $sth->bindParam(':email', $email);
- $sth->bindParam(':description', $description);
- $sth->bindParam(':news', $news);
- + $sth->bindParam(':location', $location);
- + $sth->bindParam(':homepage', $homepage);
- + $sth->bindParam(':public_mail', $public_mail);
- $sth->execute();
- }
- catch( PDOException $exception )
- @@ -400,6 +469,9 @@ class PersonaUser
- $this->_email = $email;
- $this->_display_username = $display_username;
- $this->_description = $description;
- + $this->_location = $location;
- + $this->_homepage = $homepage;
- + $this->_public_mail = $public_mail;
- if ($this->_memcache)
- $this->_memcache->delete('user:' . $username);
- @@ -532,6 +604,9 @@ class PersonaUser
- $this->_email = $result['email'];
- $this->_description = $result['description'];
- $this->_news = $result['news'];
- + $this->_location = $result['location'];
- + $this->_homepage = $result['homepage'];
- + $this->_public_mail = $result['public_mail'];
- return 1;
- }
- return 0;
- @@ -579,6 +654,9 @@ class PersonaUser
- $this->_email = $result['email'];
- $this->_description = $result['description'];
- $this->_news = $result['news'];
- + $this->_location = $result['location'];
- + $this->_homepage = $result['homepage'];
- + $this->_public_mail = $result['public_mail'];
- return 1;
- }
- return 0;
- diff --git a/server/profile.php b/server/profile.php
- index 32465dc..7d1791f 100755
- --- a/server/profile.php
- +++ b/server/profile.php
- @@ -24,10 +24,16 @@
- $create['description'] = array_key_exists('create_description', $_POST) ? (ini_get('magic_quotes_gpc') ? stripslashes($_POST['create_description']) : $_POST['create_description']) : null;
- $create['news'] = array_key_exists('news', $_POST);
- $create['display_username'] = trim($create['display_username']);
- + $create['location'] = array_key_exists('create_location', $_POST) ? (ini_get('magic_quotes_gpc') ? stripslashes($_POST['create_location']) : $_POST['create_location']) : null;
- + $create['homepage'] = array_key_exists('create_homepage', $_POST) ? (ini_get('magic_quotes_gpc') ? stripslashes($_POST['create_homepage']) : $_POST['create_homepage']) : null;
- + $create['public_mail'] = array_key_exists('public_mail', $_POST);
- + $create['picture'] = array_key_exists('picture', $_FILES);
- $create['display_username'] = htmlspecialchars($create['display_username']);
- $create['description'] = htmlspecialchars($create['description']);
- $create['email'] = htmlspecialchars($create['email']);
- + $create['location'] = htmlspecialchars($create['location']);
- + $create['homepage'] = htmlspecialchars($create['homepage']);
- if (!preg_match('/^[A-Z0-9\._%+-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}$/i', $create['email']))
- $_errors['create_email'] = _("Invalid email address");
- @@ -38,9 +44,24 @@
- if (strlen($create['description']) > 256)
- $_errors['create_description'] = _("Please limit your description to 256 characters or less");
- - if (count($_errors) == 0 && $user->update_user($user->get_username(), $create['display_username'], $create['email'], $create['description'], $create['news']))
- + if (strlen($create['location']) > 32)
- + $_errors['create_location'] = _("Please limit your location to 32 characters or less");
- +
- + if (strlen($create['homepage']) > 32)
- + $_errors['create_homepage'] = _("Please limit your homepage to 32 characters or less");
- +
- + if ($_FILES['picture']['size'] > 307200)
- + $_errors['create_picture'] = _("Please limit your profile picture file size to 300K");
- +
- + $img_identify_cmd = "identify -format \"%m\" ";
- + $picture_ftype = exec($img_identify_cmd . $_FILES['picture']['tmp_name']);
- + if (!($picture_ftype == 'JPEG' || $picture_ftype == 'PNG'))
- + $_errors['create_picture'] = sprintf(/*L10N: %s is an email address*/_("We do not recognize the format of your profile picture. Please let us know at %s if you think this is in error."), 'persona-devel@mozilla.com');
- +
- + if (count($_errors) == 0 && $user->update_user($user->get_username(), $create['display_username'], $create['email'], $create['description'], $create['news'], $create['location'], $create['homepage'], $create['public_mail']))
- {
- $db->update_display_username($user->get_username(), $create['display_username']);
- + $user->resize_picture($_FILES['picture']['tmp_name'], $user->get_username());
- $updated = 1;
- }
- }
- @@ -50,6 +71,9 @@
- $create['display_username'] = $user->_display_username;
- $create['description'] = $user->_description;
- $create['news'] = $user->_news;
- + $create['location'] = $user->_location;
- + $create['homepage'] = $user->_homepage;
- + $create['public_mail'] = $user->_public_mail;
- }
- $title = _("Change User Details");
- diff --git a/server/templates/change_user_details.php b/server/templates/change_user_details.php
- old mode 100644
- new mode 100755
- index 22ad46b..97dbaa6
- --- a/server/templates/change_user_details.php
- +++ b/server/templates/change_user_details.php
- @@ -1,6 +1,6 @@
- <div id="signup">
- <h4><?= _("Change User Details");?></h3>
- - <form action="profile" method="post">
- + <form action="profile" method="post" enctype="multipart/form-data">
- <input type="hidden" name="update" value="1">
- <p><label for="username"><?=_("Login Name:");?> <?= $user->get_username() ?></label>
- @@ -11,19 +11,40 @@
- <?php if (array_key_exists('create_email', $_errors)) echo '<span class="error-message">' . $_errors['create_email'] . '</span>' ?>
- </p>
- - <p><label for="username"><?= _("Display Username");?>*</label>
- + <p><label for="username"><?= _("Display Username (optional)");?></label>
- <input type="text" name="create_display_username" value="<?= $create['display_username'] ?>" id="" <?php if (array_key_exists('create_display_username', $_errors)) echo 'class="error"' ?>/>
- <?php if (array_key_exists('create_display_username', $_errors)) echo '<span class="error-message">' . $_errors['create_display_username'] . '</span>' ?>
- </p>
- <p>
- - <label for="description"><?=_("User Description");?>*</label>
- + <label for="description"><?=_("Bio (optional)");?></label>
- <textarea name="create_description" id="create_description" <?php if (array_key_exists('create_description', $_errors)) echo 'class="error"' ?> ><?= $create['description'] ?></textarea>
- <?php if (array_key_exists('create_description', $_errors)) echo '<span class="error-message">' . $_errors['create_description'] . '</span>' ?>
- </p>
- + <p>
- + <label for="location"><?= _("Location (optional)");?></label>
- + <input type="text" name="create_location" value="<?= $create['location'] ?>" id="" <?php if (array_key_exists('create_location', $_errors)) echo 'class="error"' ?>/>
- + <?php if (array_key_exists('create_location', $_errors)) echo '<span class="error-message">' . $_errors['create_location'] . '</span' ?>
- + </p>
- +
- + <p>
- + <label for="homepage"><?= _("Homepage (optional)");?></label>
- + <input type="text" name="create_homepage" value="<?= $create['homepage'] ?>" id="" <?php if (array_key_exists('create_homepage', $_errors)) echo 'class="error"' ?>/>
- + <?php if (array_key_exists('create_homepage', $_errors)) echo '<span class="error-message">' . $_errors['create_homepage'] . '</span' ?>
- + </p>
- +
- + <p>
- + <label for="public_mail"><input type="checkbox" name="public_mail" id="public_mail" value="" <?= $create['public_mail'] ? "checked" : "" ?>/> <?=_("Publicly display my email address (optional)");?></label>
- + </p>
- +
- + <p>
- + <label for="picture"><?= _("Picture (optional)");?></label>
- + <span><input type="file" name="picture" value="" id="picture" <?php if (array_key_exists('create_picture', $_errors)) echo 'class="error"' ?>/></span>
- + <?php echo $_errors['create_picture'];?>
- + </p>
- +
- <p class="news"><label for="news"><input type="checkbox" name="news" id="news" value="" <?= $create['news'] ? "checked" : "" ?>/> <?=_("I'd like to receive news and information about Personas");?></label></p>
- - <p>* <i><?=_("denotes an optional field. These entries will be displayed in the personas gallery.");?></i></p>
- <button type="submit" class="button"><span><?=_("change");?></span><span class="arrow"></span></button>
- </form>
- </div>
- diff --git a/server/templates/gallery.php b/server/templates/gallery.php
- old mode 100644
- new mode 100755
- index 27ba53b..b50adb9
- --- a/server/templates/gallery.php
- +++ b/server/templates/gallery.php
- @@ -6,16 +6,64 @@
- <div id="inner-wrapper">
- <?php include 'nav.php'; ?>
- <?php
- - if (!($category == 'Designer' && $header_text = $user->get_description($tab)))
- - {
- $header_text = _("Your browser, your style! Dress it up with easy-to-use themes for your Firefox.");
- - }
- ?>
- <div id="header">
- <h2><?= htmlentities($page_header, ENT_QUOTES, 'UTF-8', false) ?></h2>
- <h3><?= $header_text ?></h3>
- </div>
- <div id="maincontent">
- +<?php
- + if ($category == 'Designer')
- + { ?>
- + <div class="featured">
- + <div class="featured-inner object-lead">
- + <h3><?php printf(/*L10N: %s is the author name*/_("About %s") , $tab); ?></h3>
- + <img class="avatar thumbnail" src="<?= $user->get_picture($tab); ?>" alt="">
- + <div class="user-info">
- + <?php if ($tab == $user->get_unauthed_username()) { ?>
- + <p class="edit-profile"><?printf("<a href=\"%s\">" . _("Edit my info") . "</a>", $locale_conf->url('/profile'));?></p>
- + <?php } ?>
- + <div>
- + <table class="designerinfo" summary="Designer Information">
- + <tbody>
- + <tr>
- + <th><?= _("Name");?></th>
- + <td><?= $display_username;?></td>
- + </tr>
- + <?php if($user->get_public_email($tab)) { ?>
- + <tr>
- + <th><?= _("Email");?></th>
- + <td><?printf("<a href=\"mailto://%s\">" .$user->get_email($tab) . "</a>", $user->get_email($tab));?></td>
- + </tr>
- + <?php } ?>
- + <?php if($user->get_location($tab)) { ?>
- + <tr>
- + <th><?= _("Location");?></th>
- + <td><?= $user->get_location($tab);?></td>
- + </tr>
- + <?php } ?>
- + <?php if($user->get_homepage($tab)) {
- + $homepage = preg_replace('/(https?\:\/\/[^ ]+[A-Za-z0-9\/])/e', '"<a href=\"".external_link(\'\\1\')."\">\\1</a>"', $user->get_homepage($tab)); ?>
- + <tr>
- + <th><?= _("Homepage");?></th>
- + <td><?= $homepage ?></td>
- + </tr>
- + <?php } ?>
- + <?php if($user->get_description($tab)) { ?>
- + <tr>
- + <th><?= _("Bio");?></th>
- + <td><?= $user->get_description($tab);?>
- + </tr>
- + <?php } ?>
- + </tbody>
- + </table>
- + </div>
- + </div>
- + </div>
- + </div>
- +
- +<?php } ?>
- <div id="gallery">
- <?php
- diff --git a/static/css/style.css b/static/css/style.css
- old mode 100644
- new mode 100755
- index fc08eb7..39b4392
- --- a/static/css/style.css
- +++ b/static/css/style.css
- @@ -153,7 +153,7 @@ h4.section {
- clear: both;
- }
- -#inner-wrapper:after, #nav ul:after, .mini-gallery:after{
- +#inner-wrapper:after, #nav ul:after, .mini-gallery:after .featured:after{
- content: '.';
- display: block;
- clear: both;
- @@ -2492,3 +2492,67 @@ div#gsfn_list_widget div#gsfn_content li { text-align:left; margin-bottom:6px; m
- div#gsfn_list_widget div#gsfn_content a.gsfn_link { line-height: 1; }
- div#gsfn_list_widget div#gsfn_content span.time { font-size: 90%; padding-left: 3px; }
- div#gsfn_list_widget div#gsfn_content p.gsfn_summary { margin-top: 2px }
- +
- +.featured {
- + -moz-border-radius: 5px 5px 5px 5px;
- + background-color: #B5D9E5;
- + border: 4px solid #B5D9E5;
- + clear: both;
- + margin-bottom: 2em;
- +}
- +
- +.object-lead {
- + margin: 0;
- + padding: 1em;
- + position: relative;
- +}
- +
- +.object-lead h3 {
- + margin-top: 0;
- +}
- +
- +.object-lead img.avatar {
- + border: 3px solid #C8E8F3;
- + float: left;
- + margin: 0 15px 15px 0;
- + margin-right: 1em;
- +}
- +
- +.object-lead .avatar {
- + clear: right;
- +}
- +
- +.object-lead .edit-profile {
- + font-size: 0.846em;
- + padding: 0.3em 1.18em 0.3em 35px;
- + position: absolute;
- + right: 0;
- + top: 1em;
- +}
- +
- +.object-lead table {
- + margin-top: 1em;
- + width: 100%;
- +}
- +
- +.object-lead table, .object-lead tbody {
- + border-bottom: medium none;
- + border-top: medium none;
- +}
- +
- +.object-lead table tr th {
- + border-bottom: medium none;
- + color: #444444;
- + background: #FFFFFF;
- + font-weight: bold;
- +}
- +
- +.featured-inner {
- + -moz-border-radius: 3px 3px 3px 3px;
- + background-color: #FFFFFF;
- + border: 1px solid #2E5186;
- +}
- +
- +.object-content {
- + margin-left: 220px;
- +}
- --
- 1.7.0.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement