Skip to content

Instantly share code, notes, and snippets.

View maxparm's full-sized avatar

Maxime Parmentier maxparm

View GitHub Profile
<?php
class View_Helper_BaseUrl extends Zend_View_Helper_Abstract
{
public function baseUrl()
{
return 'http://localhost/myapplication';
}
}
?>
@maxparm
maxparm / gist:1015654
Created June 8, 2011 22:57
signed_request
{
"algorithm":"HMAC-SHA256",
"expires":1297328400,
"issued_at":1297322606,
"oauth_token":"OAUTH_TOKEN",
"app_data":"any_string_here",
"page":{
"id":119132324783475,
"liked":true,
"admin":true
@maxparm
maxparm / UserController.php
Created June 15, 2011 19:03
User Registration
<?php
namespace app\controllers;
use app\models\Users;
class UserController extends \lithium\action\Controller {
public function signup() {
$user = Users::create();
if(($this->request->data) && $user->save($this->request->data)) {
@maxparm
maxparm / Users.php
Created June 15, 2011 18:37
Users model
<?php
namespace app\models;
class Users extends \lithium\data\Model {
protected $_schema = array(
'_id' => array('type' => 'id'),
'username' => array('type' => 'string', 'null' => false),
'password' => array('type' => 'string', 'null' => false),
'name' => array('type' => 'string', 'null' => false),
@maxparm
maxparm / User.php
Created June 15, 2011 23:17
User Helper
<?php
namespace app\extensions\helper;
use lithium\security\Auth;
class User extends \lithium\template\helper {
public function connected() {
return Auth::check('member', $this->_context->_config['request']);
}
}
@maxparm
maxparm / Users.php
Created June 15, 2011 20:11
Users Models 2
<?php
namespace app\models;
use lithium\util\Validator;
class Users extends \lithium\data\Model {
protected $_schema = array(
'_id' => array('type' => 'id'),
'username' => array('type' => 'string', 'null' => false),
'password' => array('type' => 'string', 'null' => false),
public function index() {
$users = Users::all();
return compact('users');
}
@maxparm
maxparm / session.php
Created June 15, 2011 22:39
Session bootstrap file
<?php
use lithium\storage\Session;
use lithium\security\Auth;
Session::config(array(
'cookie' => array('adapter' => 'Cookie'),
'default' => array('adapter' => 'Php')
));
Auth::config(array(
@maxparm
maxparm / UserController.php
Created June 15, 2011 22:44
LITHIUM - User Login
<?php
namespace app\controllers;
use app\models\Users;
use lithium\security\Auth;
use lithium\storage\Session;
class UserController extends \lithium\action\Controller {
// Action index & signup ...
@maxparm
maxparm / ExampleController.php
Created June 15, 2011 23:12
LITHIUM - Example test authentification
<?php
namespace app\controllers;
use app\models\Users;
use lithium\security\Auth;
use lithium\storage\Session;
class ExampleController extends \lithium\action\Controller {
public function test() {