Page MenuHomeCode

No OneTemporary

diff --git a/controllers/home.php b/controllers/home.php
index 5160686..0fac199 100644
--- a/controllers/home.php
+++ b/controllers/home.php
@@ -1,68 +1,75 @@
<?php
/*
* Zed
* (c) 2010, Dereckson, some rights reserved
* Released under BSD license
*
* Homepage
*/
//
// Gets and manage messages
//
require_once('includes/objects/message.php');
//Deletes a message if user have clicked the X
if ($_GET['action'] == 'msg_delete') {
//Deletes message $_GET['id']
$id = $_GET['id'];
$messageToDelete = new Message($id);
if ($messageToDelete->to != $CurrentPerso->id) {
//Not one of user message
$smarty->assign('WAP', lang_get('NotYourMessage'));
} elseif ($messageToDelete->flag == 2) {
//Already deleted
$smarty->assign('WAP', lang_get('MessageAlreadyDeleted'));
} else {
$messageToDelete->delete();
$smarty->assign('NOTIFY', lang_get('MessageDeleted'));
}
}
//Gets messages
-$messages = Message::get_messages($CurrentPerso->id);
-$smarty->assign('MESSAGES', $messages);
+$newMessagesCount = 0;
+$messages = Message::get_messages($CurrentPerso->id, true, $newMessagesCount);
+if ($newMessagesCount > 0) {
+ $smarty->assign('NOTIFY', sprintf(lang_get("NewMessages"), $newMessagesCount, s($newMessagesCount)));
+}
//Gets scene
require_once("includes/geo/scene.php");
$scene = new GeoScene($CurrentPerso->location);
$smarty->assign('SCENE', $scene);
//
// HTML output
//
//Serves header
//TODO: Dojo loading here is currently a kludge, as dojo is required by
//hypership .tpl scene. We should create an optionnal .meta xml file format
//to set this kind of options
if (!defined('DIJIT')) define('DIJIT', true);
$smarty->assign('PAGE_TITLE', lang_get('Welcome'));
include('header.php');
//Serves content
if (!$scene->lastError)
$scene->render();
+
$smarty->display('home.tpl');
-if ($messages)
+
+if ($messages) {
+ $smarty->assign('MESSAGES', $messages);
$smarty->display('messages.tpl');
+}
//Serves footer
$smarty->assign("screen", "Home console");
include('footer.php');
?>
\ No newline at end of file
diff --git a/includes/objects/message.php b/includes/objects/message.php
index 242e0bc..ed53d31 100644
--- a/includes/objects/message.php
+++ b/includes/objects/message.php
@@ -1,135 +1,139 @@
<?php
/*
* Message class
*
* 0.1 2010-01-28 01:47 Autogenerated by Pluton Scaffolding
*
* @package Zed
* @copyright Copyright (c) 2010, Dereckson
* @license Released under BSD license
* @version 0.1
*
*/
class Message {
public $id;
public $date;
public $from;
public $to;
public $text;
public $flag;
/*
* Initializes a new instance
* @param int $id the primary key
*/
function __construct ($id = null) {
if ($id) {
$this->id = $id;
$this->load_from_database();
} else {
$this->date = time();
$this->flag = 0; //unread
}
}
/*
* Loads the object Message (ie fill the properties) from the $_POST array
*/
function load_from_form () {
if (array_key_exists('date', $_POST)) $this->date = $_POST['date'];
if (array_key_exists('from', $_POST)) $this->from = $_POST['from'];
if (array_key_exists('to', $_POST)) $this->to = $_POST['to'];
if (array_key_exists('text', $_POST)) $this->text = $_POST['text'];
if (array_key_exists('flag', $_POST)) $this->flag = $_POST['flag'];
}
/*
* Loads the object Message (ie fill the properties) from the database
*/
function load_from_database () {
global $db;
$sql = "SELECT * FROM messages WHERE message_id = '" . $this->id . "'";
if ( !($result = $db->sql_query($sql)) ) message_die(SQL_ERROR, "Unable to query messages", '', __LINE__, __FILE__, $sql);
if (!$row = $db->sql_fetchrow($result)) {
$this->lastError = "Message unkwown: " . $this->id;
return false;
}
$this->date = $row['message_date'];
$this->from = $row['message_from'];
$this->to = $row['message_to'];
$this->text = $row['message_text'];
$this->flag = $row['message_flag'];
return true;
}
/*
* Saves to database
*/
function save_to_database () {
global $db;
$id = $this->id ? "'" . $db->sql_escape($this->id) . "'" : 'NULL';
$date = $db->sql_escape($this->date);
$from = $db->sql_escape($this->from);
$to = $db->sql_escape($this->to);
$text = $db->sql_escape($this->text);
$flag = $db->sql_escape($this->flag);
//Updates or inserts
$sql = "REPLACE INTO messages (`message_id`, `message_date`, `message_from`, `message_to`, `message_text`, `message_flag`) VALUES ($id, '$date', '$from', '$to', '$text', '$flag')";
if (!$db->sql_query($sql)) {
message_die(SQL_ERROR, "Unable to save", '', __LINE__, __FILE__, $sql);
}
if (!$id) {
//Gets new record id value
$this->id = $db->sql_nextid();
}
}
/*
* Sends the message
*/
function send () {
$this->save_to_database();
//TODO: triggers new message notifier
}
/*
* Deletes a message
*/
function delete () {
//A message is deleted if its flag value is 2
if ($this->flag != 2) {
$this->flag = 2;
$this->save_to_database();
}
}
/*
* Gets messages from the specified perso
*/
- static function get_messages ($perso_id, $mark_as_read = true) {
+ static function get_messages ($perso_id, $mark_as_read = true, &$countNewMessages = 0) {
global $db;
$sql = "SELECT message_id FROM " . TABLE_MESSAGES . " WHERE message_to = " . $db->sql_escape($perso_id) . " AND message_flag < 2 ORDER BY message_id DESC";
if (!$result = $db->sql_query($sql)) {
message_die(SQL_ERROR, "Unable to get messages", '', __LINE__, __FILE__, $sql);
}
while ($row = $db->sql_fetchrow($result)) {
$message = new Message($row[0]);
$messages[] = $message;
$ids[] = $message->id;
+ if ($message->flag == 0) {
+ //New message
+ $countNewMessages++;
+ }
}
if ($mark_as_read && count($ids)) {
$ids = join($ids, ', ');
$sql = "UPDATE " . TABLE_MESSAGES . " SET message_flag = '1' WHERE message_id IN ($ids)";
$db->sql_query($sql);
}
return $messages;
}
}
?>
diff --git a/lang/en/core.conf b/lang/en/core.conf
index 8d49251..2a42f30 100644
--- a/lang/en/core.conf
+++ b/lang/en/core.conf
@@ -1,178 +1,181 @@
#Zed language config file
#Language: English
#Code: en
#Author: Dereckson
###
### Site configuration
###
SiteTitle = Zed
Product = "<strong>Zed 0.1</strong>, alpha technical preview"
###
### General stuff
###
_t = ":"
Save = Save
###
### Login
###
Login = Login
Password = Password
OK = OK
LoginNotFound = Login not found.
IncorrectPassword = Incorrect password.
JaMata = Ja mata!
WelcomeBack = Welcome back.
OpenID = OpenID
Logout = Logout
###
### Errors
###
UnauthorizedAccess = "Unauthorized access"
SQLError = "SQL Error"
line = line
Error = Error
BackToHome = "Back to homepage"
GeneralError = General error
PageNotFound = "Page not found"
#Keep those two lines in English, to help to identify error screens in any lang
FatalErrorScreen = Fatal error screen
FatalErrorInterrupt = Fatal error breaking screen
###
### Homepage
###
Welcome = Welcome
WelcomeText = "<p>Welcome to the Zed alpha technical preview. Zed, it's a mix between a gallery, a place to meet new and existing friends, with some RPG inspiration.<br />
The concept is to have each information stored at physical places in a virtual world, like the 80s cyberspace vision. Another goal is to build a community sharing values like cooperation, freedom, ethic.</p>"
###
### Homepage - messages
###
+#NOTIFY if new messages
+NewMessages = "You've got %d new message%s"
+
#messages.tpl, Reply
Reply = Reply
#messages.tpl, the X link title
DeleteThisMessage = Delete this message
#home.php, messages error
MessageDeleted = Message deleted.
NotYourMessage = This message is not one of yours.
MessageAlreadyDeleted = Message already deleted.
###
### Account create
###
CreateAccountTitle = Create an account
CreateAccountIntro = "<p>Welcome to Zed.<br />To get an account, you need an invite code. To get an invite code, ask who tell you about Zed.</p>"
YourLogin = The login you want
InviteCode = Your invite code
YourEmail = Your e-mail
EnterInviteCodePromptMessage = "Your invite code is something like ABC123."
EnterUsernamePromptMessage = "Enter your username, in lowercase (11 characters max.).<br />It's your usual username, not your character name."
EnterEmailPromptMessage = "Enter your e-mail. It will used (1) as password recovery method (2) to send you notification of new messages or events you've configured.<br />We don't like spam, so we take all the measures to protect your mail."
IncorrectInviteCode = "Your invite code's format isn't valid. It's something like ABC123."
InviteCodeAlreadyClaimed = "This invite code were valid. But it have already been claimed."
CreateAccountImageTitle = "Zed is for human being. But it's also for people defining themselves like other beings than humans."
CreateAccountImageAlt = "A strange-looking white picture. An half circle from top right to bottom right, then the brush come back in spirale to create a big white spot. Some brushes effects add fringes at start and end. Grayscale spots have been added in main circle."
MissingUsername = "You need to provide a login."
LoginUnavailable = "This login is already taken."
MissingPassword = "You need to provide a password."
InviteHaveBeenClaimed = "Your invite %s have just been claimed."
AccountCreated = "Your account is created. Welcome to Zed."
###
### Perso create/select
###
NewCharacterCreated = New character created
CreateCharacter = Create a character
EditCharacter = Edit %s information
FullName = Full name
Nickname = Nickname
Sex = Sex
Male = Male
Female = Female
Neutral = Neutral
Hermaphrodit = Hermaphrodit
Race = Race
NoSexSpecified = "Pick a sex, or '<em>Neutral</em>' if you don't want to tell it."
NoNicknameSpecified = "You must pick a nickname, it's like your login to identify your character."
NoFullnameSpecified = "All beings must have a name."
NoRaceSpecified = "You've to specify a race: '<em>humanoid</em>' for human and co.<br />If you don't want to specify a race, use the generic '<em>being</em>'."
NicknameUnavailable = "This nickname is already used.<br />Choose a more original one."
PickPerso = Pick your perso
SwapPerso = "Swap perso (%s's logout)"
NewLocationNotify = "You're slowly awaking in a place you don't recognize."
###
### Places
###
CurrentLocation = "Current location"
UnknownBody = "Unknown asteroid"
UnknownPlace = "Unknown place"
WherePlace = "%s @ %s"
SpaceAround = "Space around %s"
hypership = hypership
asteroid = asteroid
moon = moon
planet = planet
star = star
orbital = orbital
place = place
ship = ship
###
### Stories
###
InvalidStoryGUID = "In story mode, you can't use previous/back URL."
ExpiredStorySession = "Story choices URL are temporary.<br />You can't bookmark them or use in another session."
###
### Requests
###
Request = Request
Title = Title
###
### MOTD
###
PushMessage = Push a message to the header
TextToAdd = Text to add
TextToAddWarning = Warning: once published, it can't be (easily) removed.
Rendering = How it will be printed?
RenderingWhere = "At the top right header corner:"
DummyPlaceholder = Here your message.
Push = Push
Published = Published :)
\ No newline at end of file
diff --git a/lang/fr/core.conf b/lang/fr/core.conf
index 44f8793..1f61bf0 100644
--- a/lang/fr/core.conf
+++ b/lang/fr/core.conf
@@ -1,193 +1,196 @@
#Zed language config file
#Language: English
#Code: fr
#Author: Dereckson
###
### Site configuration
###
SiteTitle = Zed
Product = "<strong>Zed 0.1</strong>, alpha technical preview"
###
### General stuff
###
_t = " :"
Save = Enregistrer
###
### Login
###
Login = Login
Password = Password
OK = OK
LoginNotFound = Login introuvable.
IncorrectPassword = Mot de passe incorrect.
JaMata = Ja mata!
WelcomeBack = Welcome back.
OpenID = OpenID
Logout = Déconnexion
###
### Erreurs
###
UnauthorizedAccess = "Accès non autorisé"
SQLError = "Erreur SQL"
line = ligne
Error = Erreur
BackToHome = "Retourner à la page d'accueil"
GeneralError = "Erreur générale"
PageNotFound = "Cette page n'existe pas."
#Veuillez laisser en anglais, pour identifier plus clairement les erreurs.
FatalErrorScreen = Fatal error screen
FatalErrorInterrupt = Fatal error breaking screen
###
### Homepage
###
Welcome = Bienvenue
WelcomeText = "<p>Bienvenue sur la version alpha de Zed, un hybride un peu étrange entre une galerie, un endroit où rencontrer ses amis ou s'en faire de nouveaux, avec une légère inspiration RPG, dans un environnement galactique inspiré des romans de la Culture de Iain M. Banks.</p>
<p>Le concept est d'expérimenter ce qui se passe lorsque chaque information est dans un espace précis, un peu comme la vision cyberpunk des années 80 du cyberespace. Un autre but est de créer une communauté partagant des valeurs de respect, de coopération, de liberté et d'éthique.</p>"
###
### Homepage - Messages
###
+#NOTIFY if new messages
+NewMessages = "Vous avez reçu %d message%s"
+
#messages.tpl, Reply
Reply = Répondre
#messages.tpl, the X link title
DeleteThisMessage = Effacer ce message
#home.php, messages error
MessageDeleted = Message effacé.
NotYourMessage = Hey, ce message appartient à autrui !
MessageAlreadyDeleted = Message déjà effacé
###
### Errors
###
UnauthorizedAccess = "Accès non autorisé"
SQLError = "Erreur dans la requête SQL"
line = ligne
Error = Erreur
BackToHome = "Retour à la page d'accueil"
FatalErrorScreen = Fatal error screen
FatalErrorInterrupt = Fatal error screen (interruption)
GeneralError = "Erreur"
PageNotFound = "Cette page n'existe pas."
###
### Account create
###
CreateAccountTitle = Créer un compte
CreateAccountIntro = "<p>Bienvenue sur Zed.<br />Zed est un site privé uniquement accessible suite à l'invitation d'un membre.</p>"
YourLogin = Le login de votre choix
InviteCode = "Votre code d'invitation"
YourEmail = Votre adresse e-mail
EnterInviteCodePromptMessage = "Votre code d'invitation ressemble à ABC123."
EnterUsernamePromptMessage = "Votre login sera en minuscule et d'au plus onze caractères.<br />Il sera uniquement utilisé pour vous identifier, votre login NE sera PAS le nom de votre perso."
EnterEmailPromptMessage = "Votre adresse sera utilisée pour vous permettre de modifier votre mot de passe en cas d'oubli. Vous pourrez également configurer des notifications en cas de nouveau message & co, mais par défaut c'est désactivé."
IncorrectInviteCode = "Format invalide du code d'invitation,<br />recherchez quelque chose ressemblant à ABC123."
InviteCodeAlreadyClaimed = "Ce code d'invitation était certes valide mais a déjà été utilisé par autrui."
CreateAccountImageTitle = "Zed est un site pour les êtres humains. Mais aussi pour tous ceux qui se définissent autrement que comme humain."
CreateAccountImageAlt = "Une étrange créature blanche. Un demi cercle allant d'en haut à droite vers le bas à droite ; la brosse poursuit ensuite en spirale pour créer une grosse tâche blanche. Les effets de la brosse ajoutent au début et à la fin des franges. Des tâches grises ont été rajoutées au centre."
MissingUsername = "Vous avez oublié de spécifier le login."
LoginUnavailable = "Ce login est déjà utilisé."
MissingPassword = "Vous avez oublié de spécifier le mot de passe."
InviteHaveBeenClaimed = "Votre invitation %s a été acceptée."
AccountCreated = "Votre compte a été créé. Bienvenue sur Zed."
###
### Perso create/select
###
NewCharacterCreated = Nouveau perso créé.
CreateCharacter = Nouveau perso
EditCharacter = Éditer les infos de %s
FullName = Prénom et nom
Nickname = Pseudonyme
Sex = Sexe
Male = Masculin
Female = Féminin
Neutral = Neutre
Hermaphrodit = Hermaphrodite
Race = Race
NoSexSpecified = "Quel est votre sexe ? Si vous ne souhaitez pas le dévoiler, vous pouvez toujours utiliser '<em>Neutral</em>'."
NoNicknameSpecified = "Vous devez choisir un pseudo. C'est comme un login, pour votre perso."
NoFullnameSpecified = "Tous les êtres doivent avoir un nom."
NoRaceSpecified = "Spécifiez une race: '<em>humanoid</em>' pour les humains et humanoïdes.<br />Si vous ne souhaitez pas spécifier de race, vous pouvez utiliser '<em>being</em>'."
NicknameUnavailable = "Ce pseudo est déjà utilisé.<br />Veuillez en choisir un plus original."
PickPerso = "Sélectionnez votre perso"
SwapPerso = "Changer de perso (déco %s)"
NewLocationNotify = "Vous vous réveillez lentement dans un endroit inconnu"
###
### Places
###
CurrentLocation = "Localisateur"
UnknownBody = "Astéroïde inconnu"
UnknownPlace = "Endroit inconnu"
WherePlace = "%2$s, %1$s."
SpaceAround = "%s et l'espace aux alentours"
hypership = hypership
asteroid = astéroïde
moon = lune
planet = planète
star = étoile
orbital = orbitale
place = endroit
ship = vaisseau
###
### Stories
###
InvalidStoryGUID = "En mode récit, il n'est pas possible <br />d'utiliser les boutons précédents et suivants."
ExpiredStorySession = "Les URL de choix sont temporaires.<br />Il n'est pas possible de les bookmark pour y revenir."
###
### Requests
###
Request = Requête
Title = Titre
###
### MOTD
###
PushMessage = Publier un message tout en haut
TextToAdd = Texte à ajouter
TextToAddWarning = "Une fois publié, ne peut être facilement enlevé."
Rendering = Aperçu
RenderingWhere = "Coin supérieur droit de la page :"
DummyPlaceholder = Lorem ipsum dolor.
Push = Publier
Published = Publié :)
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 23, 09:47 (1 d, 6 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21132
Default Alt Text
(18 KB)

Event Timeline