Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F209464
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Subscribers
None
View Options
diff --git a/img/index.html b/img/index.html
new file mode 100644
index 0000000..f5b9b2e
--- /dev/null
+++ b/img/index.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd"
+ >
+<html lang="en">
+<head>
+ <title>Restricted directory</title>
+ <link rel="Stylesheet" href="../css/zed/theme.css" type="text/css" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+</head>
+<body>
+ <div style="width: 960px; margin: auto; margin-top: 3em;">
+ <h1 style="font-size: 3em;">Zed</h1>
+ <h2>img directory</h2>
+ <p>As you can guess from the URL, this directory contains <em>image files <em>.</p>
+ </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/img/login/invite.png b/img/login/invite.png
new file mode 100644
index 0000000..18d3dbd
Binary files /dev/null and b/img/login/invite.png differ
diff --git a/includes/objects/invite.php b/includes/objects/invite.php
new file mode 100644
index 0000000..935a4b3
--- /dev/null
+++ b/includes/objects/invite.php
@@ -0,0 +1,169 @@
+<?php
+
+/*
+ * User invite class
+ *
+ * 0.1 2010-06-29 02:13 Created by hand
+ *
+ * @package Zed
+ * @copyright Copyright (c) 2010, Dereckson
+ * @license Released under BSD license
+ * @version 0.1
+ *
+ */
+class Invite {
+
+ public $code;
+ public $date;
+ public $from_user_id;
+ public $from_perso_id;
+
+ /*
+ * @var int the user_id who have been claimed the invite
+ * Will be NULL as long as the invite haven't been claimed
+ */
+ public $to_user_id = NULL;
+
+ /*
+ * Initializes a new instance
+ * @param int $code the primary key
+ */
+ function __construct ($code = NULL) {
+ if ($code) {
+ $this->code = $code;
+ $this->load_from_database();
+ } else {
+ //New invite code
+ $this->generate_code();
+ $this->date = time();
+ }
+ }
+
+ //Generates a unique invite code
+ function generate_code () {
+ global $db;
+
+ do {
+ $this->code = genereString("AAA111");
+ $sql = "SELECT COUNT(*) FROM " . TABLE_USERS_INVITES . " WHERE invite_code = '$this->code' LOCK IN SHARE MODE;";
+ if (!$result = $db->sql_query($sql)) {
+ message_die(SQL_ERROR, "Can't access invite users table", '', __LINE__, __FILE__, $sql);
+ }
+ $row = $db->sql_fetchrow($result);
+ } while ($row[0]);
+ }
+
+ /*
+ * Loads the object Invite (ie fill the properties) from the database
+ */
+ function load_from_database () {
+ global $db;
+ $code = $db->sql_escape($this->code);
+ $sql = "SELECT * FROM " . TABLE_USERS_INVITES . " WHERE invite_code = '" . $code . "'";
+ if ( !($result = $db->sql_query($sql)) ) message_die(SQL_ERROR, "Unable to query invite codes", '', __LINE__, __FILE__, $sql);
+ if (!$row = $db->sql_fetchrow($result)) {
+ $this->lastError = "Invite code unkwown: " . $this->code;
+ return false;
+ }
+ $this->code = $row['invite_code'];
+ $this->date = $row['invite_date'];
+ $this->from_user_id = $row['invite_from_user_id'];
+ $this->from_perso_id = $row['invite_from_perso_id'];
+ $this->to_user_id = $row['invite_to_user_id'];
+
+ return true;
+ }
+
+ /*
+ * Determines wheter the current invite code have been claimed by an user.
+ * @return true if the code have been claimed ; otherwise, false.
+ */
+ function is_claimed () {
+ return (bool)$this->to_user_id;
+ }
+
+ /*
+ * Saves to database
+ */
+ function save_to_database () {
+ global $db;
+
+ $code = $db->sql_escape($this->code);
+ $date = $db->sql_escape($this->date);
+ $from_user_id = $db->sql_escape($this->from_user_id);
+ $from_perso_id = $db->sql_escape($this->from_perso_id);
+ $to_user_id = $this->to_user_id ? "'" . $db->sql_escape($this->to_user_id) . "'" : 'NULL';
+
+ //Updates or inserts
+ $sql = "REPLACE INTO " . TABLE_USERS_INVITES . " (`invite_code`, `invite_date`, `invite_from_user_id`, `invite_from_perso_id`, `invite_to_user_id`) VALUES ('$code', '$date', '$from_perso_id', '$from_user_id', $to_user_id)";
+ if (!$db->sql_query($sql)) {
+ message_die(SQL_ERROR, "Unable to save invite code", '', __LINE__, __FILE__, $sql);
+ }
+ }
+
+ /*
+ * Deletes the invite
+ */
+ function delete () {
+ global $db;
+ $code = $db->sql_escape($this->code);
+ $sql = "DELETE FROM " . TABLE_USERS_INVITES . " WHERE invite_code = '$code'";
+ if (!$db->sql_query($sql)) {
+ message_die(SQL_ERROR, "Unable to save delete code", '', __LINE__, __FILE__, $sql);
+ }
+ }
+
+ /*
+ * Creates an invite code
+ * @param int $user_id user id
+ * @param int $perso_id perso id
+ * @return string the invite code
+ */
+ static function create ($user_id, $perso_id) {
+ $invite = new Invite();
+ $invite->from_perso_id = $perso_id;
+ $invite->from_user_id = $user_id;
+ $invite->save_to_database();
+ return $invite->code;
+ }
+
+ /*
+ * Gets invites generated by the specified perso ID
+ *
+ * @param int $perso_id the perso whom to get the invites
+ * @return Array an array of string, each line being an invite code
+ */
+ static function get_invites_from ($perso_id) {
+ global $db;
+ $sql = "SELECT invite_code FROM " . TABLE_USERS_INVITES
+ . " WHERE invite_from_perso_id = $perso_id AND invite_to_user_id IS NULL ORDER BY invite_date ASC";
+ if (!$result = $db->sql_query($sql)) {
+ message_die(SQL_ERROR, "Can't access invite users table", '', __LINE__, __FILE__, $sql);
+ }
+ while ($row = $db->sql_fetchrow($result)) {
+ $codes[] = $row['invite_code'];
+ }
+ return $codes;
+ }
+
+ static function who_invited ($perso_id) {
+ global $db;
+ $perso = Perso::get($perso_id);
+
+ if ($user_id = $perso->user_id) {
+ $sql = "SELECT invite_from_perso_id FROM " . TABLE_USERS_INVITES . " WHERE invite_to_user_id = '$user_id'";
+ if (!$result = $db->sql_query($sql)) {
+ message_die(SQL_ERROR, "Can't access invite users table", '', __LINE__, __FILE__, $sql);
+ }
+ if ($row = $db->sql_fetchrow($result)) {
+ return $row[0];
+ }
+ }
+
+ return null;
+ }
+
+}
+
+?>
+
diff --git a/skins/zed/account_create.tpl b/skins/zed/account_create.tpl
new file mode 100644
index 0000000..fc70d99
--- /dev/null
+++ b/skins/zed/account_create.tpl
@@ -0,0 +1,51 @@
+{include file="perso_header.tpl"}
+
+<div class="grid_16">
+ <img src="{#StaticContentURL#}/img/login/invite.png" title="{#CreateAccountImageTitle#}" alt="{#CreateAccountImageAlt#}" align="right" />
+ <h2>{#CreateAccountTitle#}</h2>
+ <p><em>{#CreateAccountIntro#}</em></p>
+ <!-- Edit Perso form -->
+ <form dojoType="dijit.form.Form" id="AccountForm" method="post" execute="document.getElementById('AccountForm').submit()">
+ <input type="hidden" name="form" value="account.create" />
+ <div class="row">
+ <label class="firstLabel" for="username">{#YourLogin#}</label>
+ <input type="text" id="username" name="username" maxlength="11"
+ value="{$username}" dojoType="dijit.form.ValidationTextBox"
+ required="true" trim="true" lowercase="true" class="medium"
+ promptMessage="{#EnterUsernamePromptMessage#}"
+ />
+ </div>
+ <div class="row">
+ <label class="firstLabel" for="invite_code">{#InviteCode#}</label>
+ <input type="text" id="invite_code" name="invite_code" maxlength="6"
+ value="{$invite_code}" class="small"
+ dojoType="dijit.form.ValidationTextBox" uppercase="true"
+ regExp="{literal}[a-zA-Z]{3}[0-9]{3}{/literal}"
+ promptMessage="{#EnterInviteCodePromptMessage#}"
+ invalidMessage="{#IncorrectInviteCode#}"
+ />
+ </div>
+ <div class="row">
+ <label class="firstLabel" for="email">{#YourEmail#}</label>
+ <input type="text" id="email" name="email" maxlength="63"
+ value="{$email}" class="long" required="true" trim="true"
+ regExpGen="dojox.validate.regexp.emailAddress"
+ dojoType="dijit.form.ValidationTextBox"
+ promptMessage="{#EnterEmailPromptMessage#}"
+ />
+ </div>
+ <div class="row" dojoType="dojox.form.PasswordValidator" name="passwd">
+ <label class="firstLabel">{#Password#}</label>
+ <input type="password" pwType="new" />
+ <br />
+ <label class="firstLabel">{#Password#}</label>
+ <input type="password" pwType="verify" />
+ </div>
+ <div class="row">
+ <button dojoType="dijit.form.Button" type="submit" value="Save"
+ iconClass="dijitEditorIcon dijitEditorIconSave"
+ />{#Save#}</button>
+ </div>
+ </form>
+</div>
+{include file="perso_footer.tpl"}
\ No newline at end of file
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Nov 4, 00:29 (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
20986
Default Alt Text
(9 KB)
Attached To
rZED Zed
Event Timeline
Log In to Comment