We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 25b6d34e authored by tobyink's avatar tobyink

First stab at journal entries

parent 76b1e2e0
......@@ -70,7 +70,9 @@ if (isset($_POST['install'])) {
webid_uri VARCHAR(255),
avatar_uri VARCHAR(255),
active INTEGER DEFAULT 1,
location_uri VARCHAR(255) REFERENCES Places(location_uri))");
location_uri VARCHAR(255) REFERENCES Places(location_uri),
laconica_profile VARCHAR(255),
journal_rss VARCHAR(255))");
$res = $mdb2->query("CREATE TABLE Groups (
groupname VARCHAR(64) PRIMARY KEY,
......
......@@ -33,7 +33,7 @@ require_once($install_path . '/data/Server.php');
class User {
public $name, $email, $fullname, $bio, $location, $homepage, $error, $userlevel;
public $id, $acctid, $avatar_uri, $location_uri, $webid_uri;
public $id, $acctid, $avatar_uri, $location_uri, $webid_uri, $laconica_profile, $journal_rss;
public $password;
/**
......@@ -70,6 +70,8 @@ class User {
$this->id = $row["webid_uri"];
$this->webid_uri = $row["webid_uri"];
$this->avatar_uri = $row["avatar_uri"];
$this->laconica_profile = $row["laconica_profile"];
$this->journal_rss = $row["journal_rss"];
$this->acctid = $this->getURL() . '#acct';
if (! preg_match('/\:/', $this->id))
......@@ -98,6 +100,8 @@ class User {
. "webid_uri=%s, "
. "location_uri=%s, "
. "avatar_uri=%s, "
. "laconica_profile=%s, "
. "journal_rss=%s, "
. "modified=%d "
. "WHERE username=%s"
, $mdb2->quote($this->email, 'text')
......@@ -110,6 +114,8 @@ class User {
, $mdb2->quote($this->id, 'text')
, (empty($this->location_uri) ? 'NULL' : $mdb2->quote($this->location_uri, 'text'))
, $mdb2->quote($this->avatar_uri, 'text')
, $mdb2->quote($this->laconica_profile, 'text')
, $mdb2->quote($this->journal_rss, 'text')
, time()
, $mdb2->quote($this->name, 'text'));
......
......@@ -175,4 +175,19 @@ function webidLookup ()
"status=1,resizable=1,scrollbars=1,width=600,height=500");
}
function laconicaClick ()
{
if ($('#laconica_profile')[0].value == 'http://identi.ca/example')
$('#laconica_profile')[0].value = '';
}
function laconicaUpdate ()
{
if ($('#laconica_profile')[0].value.match(/^http:\/\/.+\/.+/))
{
$('#journal_rss')[0].value = $('#laconica_profile')[0].value + '/rss';
}
}
UpdateLocationLabel();
$('#laconica_profile')[0].value = 'http://identi.ca/example';
......@@ -48,6 +48,16 @@
</td>
<td><a href="#dfn_id" rel="glossary">What's this?</a></td>
</tr>
<tr>
<th align="right" valign="top"><label for="laconica_profile">Laconica/identi.ca Profile:</label></th>
<td><input onchange="laconicaChange();" onclick="laconicaClick();" name="laconica_profile" id="laconica_profile" value="{$laconica_profile|escape:'html':'UTF-8'}" /></td>
<td><a href="#dfn_laconica_profile" rel="glossary">What's this?</a></td>
</tr>
<tr>
<th align="right" valign="top"><label for="journal_rss">Avatar URL:</label></th>
<td><input name="journal_rss" id="journal_rss" value="{$journal_rss|escape:'html':'UTF-8'}" /></td>
<td><a href="#dfn_journal_rss" rel="glossary">What's this?</a></td>
</tr>
<tr>
<th align="right" valign="top"><label for="password_1">Password:</label></th>
<td><input name="password_1" id="password_1" type="password" value="" /></td>
......@@ -66,7 +76,6 @@
</table>
</form>
<script type="text/javascript" src="{$base_url}/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="{$base_url}/js/edit_profile.js"></script>
<h3>Help</h3>
......
......@@ -69,6 +69,26 @@ if ($_POST['submit'])
$errors[] = "Avatar must be a URI. Valid URIs cannot contain whitespace.";
}
if (!empty($_POST['laconica_profile']))
{
# Need better URI validation, but this will do for now. I think
# PEAR has a suitable module to help out here.
if ( !preg_match('/^[a-z0-9\+\.\-]+\:/i', $_POST['laconica_profile']) )
$errors[] = "Laconica profile must be a URI.";
if ( preg_match('/\s/', $_POST['laconica_profile']) )
$errors[] = "Laconica profile must be a URI. Valid URIs cannot contain whitespace.";
}
if (!empty($_POST['journal_rss']))
{
# Need better URI validation, but this will do for now. I think
# PEAR has a suitable module to help out here.
if ( !preg_match('/^[a-z0-9\+\.\-]+\:/i', $_POST['journal_rss']) )
$errors[] = "Journal RSS must be a URI.";
if ( preg_match('/\s/', $_POST['journal_rss']) )
$errors[] = "Journal RSS must be a URI. Valid URIs cannot contain whitespace.";
}
if (!empty($_POST['password_1']))
{
if ($_POST['password_1'] != $_POST['password_2'])
......@@ -94,13 +114,15 @@ if ($_POST['submit'])
$user->location = $_POST['location'];
$user->location_uri = $_POST['location_uri'];
$user->avatar_uri = $_POST['avatar_uri'];
$user->laconica_profile = $_POST['laconica_profile'];
$user->journal_rss = $_POST['journal_rss'];
if (!empty( $_POST['password_1'] ))
$user->password = md5($_POST['password_1']);
$user->save();
header("Location: " . $base_url . "/user/" . $user->name);
header("Location: " . $user->getURL());
exit;
}
......@@ -134,6 +156,8 @@ if(isset($user->name))
$smarty->assign('location', $_POST['location']);
$smarty->assign('location_uri', $_POST['location_uri']);
$smarty->assign('avatar_uri', $_POST['avatar_uri']);
$smarty->assign('laconica_profile', $_POST['laconica_profile']);
$smarty->assign('journal_rss', $_POST['journal_rss']);
}
else
{
......@@ -144,6 +168,8 @@ if(isset($user->name))
$smarty->assign('location', ($user->location));
$smarty->assign('location_uri', ($user->location_uri));
$smarty->assign('avatar_uri', ($user->avatar_uri));
$smarty->assign('laconica_profile', ($user->laconica_profile));
$smarty->assign('journal_rss', ($user->journal_rss));
}
# And display the page.
......
<?php
require_once '../database.php';
$mdb2->query('ALTER TABLE Users ADD COLUMN laconica_profile VARCHAR(255);');
$mdb2->query('ALTER TABLE Users ADD COLUMN journal_rss VARCHAR(255);');
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment