Skip to content

Commit

Permalink
added phones list
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBlueHat committed Feb 12, 2012
1 parent f67c717 commit 730bcb8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
24 changes: 13 additions & 11 deletions public/authenticated.php
Expand Up @@ -21,23 +21,25 @@ function on_get($params)
{
$sag = $params['sag'];

try {
// get list of existing registered phones and display them
$phones = $sag->get($_SESSION['flattr_username'])->body->phones;
} catch(SagCouchException $e) {
// if it 404's, create it so we'll have it later
if($e->getCode() == "404") {
$doc = array('_id' => $_SESSION['flattr_username'],
'phones' => $phones = array());
$sag->put($doc);
}
}

$vars = array(
'profile' => $params['client']->getParsed('/user'),
'things' => $params['client']->getParsed('/user/things'),
'title' => 'signed in!',
'phones' => $phones
);

try {
// get list of existing registered phones and display them
print_r($sag->get($_SESSION['flattr_username']));
} catch(SagCouchException $e) {
// The requested post doesn't exist - oh no!
if($e->getCode() == "404") {
$e = new Exception("That post doesn't exist.");
}
throw $e;
}
// if it 404's, create it so we'll have it later
return template(basename(__FILE__),$vars);
}

Expand Down
14 changes: 14 additions & 0 deletions templates/authenticated.php
Expand Up @@ -12,4 +12,18 @@
<?php } ?>
</div>

<div>
<h3>Phones:</h3>
<?php if (count($p['phones']) == 0): ?>
<p>You've not connected a phone number to your Flattr account yet. Want to now?</p>
<?php else: ?>
<p>You've connected these phone numbers:</p>
<ul>
<?php foreach($p['phones'] as $phone): ?>
<li><?= h($phone); ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>

<a href="/logout.php">logout</a>

0 comments on commit 730bcb8

Please sign in to comment.