Started the creation of the session handler / auth class. Made some minor modifications elsewhere.

git-svn-id: svn://10.0.0.236/trunk@177808 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mike.morgan%oregonstate.edu
2005-08-16 01:52:38 +00:00
parent 86755463ec
commit c920ad508c
8 changed files with 186 additions and 144 deletions

View File

@@ -1,16 +0,0 @@
<?php
/**
* Developers index.
* @package amo
* @subpackage docs
*/
// Assign content template.
$tpl->assign(
array(
'content' =>'developers/index.tpl',
'title' =>'Developer Login')
);
// Set custom wrapper for this page.
$wrapper = 'inc/wrappers/nonav.tpl';
?>

View File

@@ -20,7 +20,6 @@ require_once('Auth.php'); // PEAR::Auth
require_once(LIB.'/smarty/libs/Smarty.class.php'); // Smarty
require_once(LIB.'/amo.class.php');
require_once(LIB.'/addon.class.php');
require_once(LIB.'/auth.class.php');
require_once(LIB.'/error.php');
require_once(LIB.'/rdf.class.php');
require_once(LIB.'/rss.class.php');

View File

@@ -3,9 +3,9 @@
* Addon super class. The class to end all classes.
* @package amo
* @subpackage lib
* @todo properly separate accessors and mutators.
*/
class AddOn extends AMO_Object
{
class AddOn extends AMO_Object {
// AddOn metadata.
var $ID;
var $GUID;
@@ -63,8 +63,7 @@ class AddOn extends AMO_Object
*
* @param int $ID AddOn ID
*/
function AddOn($ID=null)
{
function AddOn($ID=null) {
// Our DB and Smarty objects are global to save cycles.
global $db, $tpl;
@@ -79,8 +78,10 @@ class AddOn extends AMO_Object
}
}
function getAddOn()
{
/**
* Get all commonly used AddOn information.
*/
function getAddOn() {
$this->getAddonCats();
$this->getComments();
$this->getCurrentVersion();
@@ -88,8 +89,10 @@ class AddOn extends AMO_Object
$this->getUserInfo();
}
function getMainPreview()
{
/**
* Get the "highlight" for the current AddOn.
*/
function getMainPreview() {
// Gather previews information.
$this->db->query("
SELECT
@@ -116,8 +119,10 @@ class AddOn extends AMO_Object
}
function getPreviews()
{
/**
* Get all preview information attached to the current AddOn.
*/
function getPreviews() {
// Gather preview information
$this->db->query("
SELECT
@@ -144,9 +149,10 @@ class AddOn extends AMO_Object
}
}
function getHistory()
{
// Gather history of an addon
/**
* Get all previous versions of the current AddOn.
*/
function getHistory() {
$this->db->query("
SELECT
TV.vID,
@@ -173,9 +179,10 @@ class AddOn extends AMO_Object
$this->History = $this->db->record;
}
function getCurrentVersion()
{
// Gather version information for most current version.
/**
* Get information about the most recent verison of the current AddOn.
*/
function getCurrentVersion() {
$this->db->query("
SELECT
version.vID,
@@ -205,8 +212,12 @@ class AddOn extends AMO_Object
}
}
function getUserInfo()
{
/**
* Retrieve user information.
*
* @todo have this function set a User object instead
*/
function getUserInfo() {
// Gather addons metadata, user info.
$this->db->query("
SELECT
@@ -229,8 +240,13 @@ class AddOn extends AMO_Object
}
}
function getComments($limit=5)
{
/**
* Get comments attached to this Addon.
*
* @param int $limit number of rows to limit by.
* @todo add left/right limit clauses i.e. LIMIT 10,20 to work with pagination
*/
function getComments($limit=5) {
// Gather 10 latest comments.
$this->db->query("
SELECT
@@ -256,8 +272,10 @@ class AddOn extends AMO_Object
$this->setVar('Comments',$this->db->record);
}
function getAddonCats()
{
/**
* Retrieve all categories attached to the current AddOn.
*/
function getAddonCats() {
// Gather addon categories.
$this->db->query("
SELECT DISTINCT

View File

@@ -1,15 +1,21 @@
<?php
/**
* AMO master class. This class contains global application logic.
* @todo properly separate accessors and mutators.
* @todo don't store data in this superclass -- strip vars except for tpl/db.
*/
class AMO_Object
{
var $cats;
var $apps;
var $platforms;
var $db;
var $tpl;
function AMO_Object()
{
/**
* AMO_Object constructor.
*/
function AMO_Object() {
// Our DB and Smarty objects are global to save cycles.
global $db, $tpl;
@@ -51,6 +57,9 @@ class AMO_Object
}
}
/**
* Get all category names.
*/
function getCats()
{
// Gather categories.
@@ -71,6 +80,9 @@ class AMO_Object
} while ($this->db->next(SQL_ASSOC));
}
/**
* Get all operating system names (platforms). Used to populate forms.
*/
function getPlatforms()
{
// Gather platforms..
@@ -90,6 +102,9 @@ class AMO_Object
}
/**
* Get all application names. Used to populate forms.
*/
function getApps()
{
// Gather aapplications.

View File

@@ -1,101 +0,0 @@
<?php
/**
* Authentication and Session handling class.
* This class circumvents basic PHP Sessions and uses MySQL to store all session data.
* The reason this was done was to preserve sessions across different LVS nodes by utilizing the application latyer.
*
* @package amo
* @subpackage lib
*/
class Session
{
var $id;
var $data;
var $db;
/**
* Constructor.
*
* @param int $id
*/
function Session($id=null)
{
global $db;
$this->db =& $db;
if (!is_null($id)) {
$this->resume($id);
}
}
/**
* Write (or overwrite) a value to the session data array.
*
* @param string $key
* @param mixed $val
* @param bool $overwrite
*
* @return bool
*/
function write($key,$val,$overwrite=false)
{
if (!isset($this->data[$key]) || ($this->data[$key] == $val && $overwrite)) {
$this->data[$key] = $val;
return true;
} else {
return false;
}
}
/**
* Retrieve a value from the session data array.
*
* @param string $key
*
* @return mixed|bool
*/
function read($key)
{
if (isset($this->data[$key])) {
return $this->data[$key];
} else {
return false;
}
}
/**
* Start a session.
*
* @return bool
*/
function create()
{
// Insert a session entry in the database.
if (true) {
return true;
} else {
return false;
}
// Set a cookie containing the session ID.
}
/**
* Resume a session. This gathers session data and restores it.
*
* @param $id
*
* @return bool
*/
function resume($id)
{
// Retrieve session data from database based on id.
if (true) {
return true;
} else {
return false;
}
}
}
?>

View File

@@ -0,0 +1,126 @@
<?php
/**
* Session handling class.
* This class circumvents basic PHP Sessions and uses MySQL to store all session data.
* This was done was to preserve sessions across different LVS nodes by utilizing the application latyer.
*
* @package amo
* @subpackage lib
*/
class Session {
var $id;
var $data;
var $db;
/**
* Constructor.
*
* @param int $id
*/
function Session($id=null) {
global $db;
$this->db =& $db;
if (!is_null($id)) {
$this->resume($id);
}
}
/**
* Write (or overwrite) a value to the session data array.
*
* @param string $key
* @param mixed $val
* @param bool $overwrite
*
* @return bool
*/
function write($key,$val,$overwrite=false) {
if (!isset($this->data[$key]) || ($this->data[$key] == $val && $overwrite)) {
$this->data[$key] = $val;
return true;
} else {
return false;
}
}
/**
* Retrieve a value from the session data array.
*
* @param string $key
*
* @return mixed|bool
*/
function read($key) {
if (isset($this->data[$key])) {
return $this->data[$key];
} else {
return false;
}
}
/**
* Start a session.
*
* @return bool
*/
function create() {
// Insert a session entry in the database.
if (true) {
return true;
} else {
return false;
}
// Set a cookie containing the session ID.
}
/**
* Resume a session. This gathers session data and restores it.
*
* @param $id
*
* @return bool
*/
function resume($id) {
// Retrieve session data from database based on id.
if (true) {
return true;
} else {
return false;
}
}
/**
* Authenticate a user account against a database.
*
* @param string $username
* @param string $password
*
* @return bool
*/
function authencticate($username,$password) {
if (true) {
return true;
} else {
return false;
}
}
/**
* Check to see if the user's session is valid.
*
* @param string $cookieName
*
* @return bool
*/
function isValidSession($cookieName='mozilla-addons') {
if (true) {
return true;
} else {
return false;
}
}
}
?>

View File

@@ -35,7 +35,7 @@ Requires: {$addon->AppName} {$addon->MinAppVer} - {$addon->MaxAppVer} <img src="
<ul id="opinions">
{section name=comments loop=$addon->Comments max=10}
<li>
<div class="opinions-vote">{$addon->Comments[comments].CommentVote}<span class="opinions-caption">out of 10</span></div>
<div class="opinions-vote">{$addon->Comments[comments].CommentVote} <span class="opinions-caption">out of 10</span></div>
<h4 class="opinions-title">{$addon->Comments[comments].CommentTitle}</h4>
<p class="opinions-info">by {$addon->Comments[comments].CommentName}, {$addon->Comments[comments].CommentDate|date_format}</p>
<p class="opinions-text">{$addon->Comments[comments].CommentNote}</p>

View File

@@ -26,8 +26,9 @@
<div id="key-title">
<h1><a href="{$config.webpath}/" title="Return to home page" accesskey="1">Mozilla Update: Beta</a></h1>
<ul>
<li><a href="{$config.webpath}/login.php" title="Log in to MyUpdate">Login</a></li>
<li><a href="{$config.webpath}/register.php" title="Register your MyUpdate account">Register</a></li>
<li><a href="{$config.webpath}/faq.php" title="Frequently Asked Questions">FAQ</a></li>
<li><a href="{$config.webpath}/developers/" title="Tools for Addons Developers">Developers</a></li>
<li><a href="{$config.webpath}/search.php" title="Find an Addon">Search</a></li>
</ul>
</div>