Skip to content

Commit

Permalink
Merge branch 'RELEASE-3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
xcompass committed Jan 2, 2013
2 parents 303e53c + ddd442d commit 0752c48
Show file tree
Hide file tree
Showing 260 changed files with 13,549 additions and 18,097 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ app/tmp/
app/config/bootstrap.local.php
app/config/guard.php
app/config/database.php
app/config/config.local.php

dist
build/api/
Expand All @@ -13,3 +14,4 @@ build/pdepend/
cache.properties
lint.cache
tags
.project
7 changes: 6 additions & 1 deletion .htaccess
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<IfModule mod_rewrite.c>
RewriteEngine on
#Options +FollowSymlinks
#RewriteCond %{REQUEST_URI} !/maintenance.html$
#RewriteCond %{REMOTE_HOST} !^128\.189\.126\.182
#RewriteRule $ /maintenance.html [R=302,L]

RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
</IfModule>
90 changes: 41 additions & 49 deletions app/app_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

uses('sanitize');
App::import('Lib', 'toolkit');
App::import('Model', 'User');
App::import('Lib', 'breadcrumb');

/**
* AppController the base controller
Expand All @@ -23,12 +23,13 @@ class AppController extends Controller
{
public $startpage = 'pages';
public $uses = array('User', 'SysParameter', 'OauthToken');
public $components = array('Session', 'Output', 'sysContainer',
public $components = array('Session', 'Output',
'userPersonalize', 'framework', 'Guard.Guard', 'Acl',
'AccessControl', 'Email');
public $helpers = array('Session', 'Html', 'Js');
'AccessControl', 'TemplateEmail');
public $helpers = array('Session', 'Html', 'Js', 'Vocabulary');
public $access = array ();
public $actionList = array ();
public $breadcrumb;

/**
* if this request has session transfer data
Expand All @@ -41,7 +42,6 @@ class AppController extends Controller
public $sessionTransferData = array();


/* protected __construct() {{{ */
/**
* __construct constructor function
*
Expand All @@ -52,9 +52,7 @@ public function __construct()
{
parent::__construct();
}
/* }}} */

/* public beforeFilter() {{{ */
/**
* beforeFilter function called before filter
*
Expand All @@ -74,18 +72,23 @@ public function beforeFilter()
// store user in the singleton for global access
User::store($this->Auth->user());

$this->breadcrumb = Breadcrumb::create();

if ($this->Auth->isAuthorized()) {
// check if the user has permission to access the controller/action
User::hasPermission('controllers/'.ucwords($this->params['controller']).'/'.$this->params['action']);
$permission = array_filter(array('controllers', ucwords($this->params['plugin']), ucwords($this->params['controller']), $this->params['action']));
if (!User::hasPermission(join('/', $permission))) {
$this->Session->setFlash('Error: You do not have permission to access the page.');
$this->redirect('/home');
return;
}

$this->_checkDatabaseVersion();
}

parent::beforeFilter();
}
/* }}} */

/* public checkDatabaseVersion() {{{ */
/**
* checkDatabaseVersion
*
Expand All @@ -98,16 +101,13 @@ public function _checkDatabaseVersion()

if (User::hasPermission('controllers/upgrade') &&
Configure::read('DATABASE_VERSION') > $dbv) {
$flashMessage = "<span class='notice'>Your database version is older than the current version. ";
$flashMessage .= "Please do the <a href=" . $this->webroot ."upgrade" .">upgrade</a>.</span>";
$flashMessage = "Your database version is older than the current version. ";
$flashMessage .= "Please do the <a href=" . $this->webroot ."upgrade" .">upgrade</a>.";
$this->Session->setFlash($flashMessage);
}
}
/* }}} */

/* }}} */

/* public extractModel($model,$array,$field) {{{ */
/**
* extractModel extract the model
*
Expand All @@ -118,7 +118,7 @@ public function _checkDatabaseVersion()
* @access public
* @return void
*/
public function extractModel($model,$array,$field)
public function _extractModel($model,$array,$field)
{
$return = array();
foreach ($array as $row) {
Expand All @@ -127,43 +127,35 @@ public function extractModel($model,$array,$field)

return $return;
}
/* }}} */

/* protected _sendEmail($content,$subject,$from,$to, $templateName = 'default', $cc = array(),$bcc= array()) {{{ */
/**
* _sendEmail send email wrapper
*
* @param mixed $content email body
* @param mixed $subject email subject
* @param mixed $from sender address
* @param mixed $to receiver address
* @param mixed $toAddress receiver address
* @param bool $templateName email template name
* @param bool $cc cc field
* @param bool $ccAddress cc field
* @param bool $bcc bcc field
*
* @access protected
* @return void
*/
protected function _sendEmail($content,$subject,$from,$to, $templateName = 'default', $cc = array(),$bcc= array())
protected function _sendEmail($content, $subject, $from, $toAddress, $templateName = 'default', $ccAddress = array(), $bcc= array())
{
$smtp['port'] = $this->sysContainer->getParamByParamCode('email.port');
$smtp['host'] = $this->sysContainer->getParamByParamCode('email.host');
$smtp['username'] = $this->sysContainer->getParamByParamCode('email.username');
$smtp['password'] = $this->sysContainer->getParamByParamCode('email.password');

$this->SysParameter->reload();
$smtp['port'] = $this->SysParameter->get('email.port');
$smtp['host'] = $this->SysParameter->get('email.host');
$smtp['username'] = $this->SysParameter->get('email.username');
$smtp['password'] = $this->SysParameter->get('email.password');
$smtp['timeout'] = 30;
$this->Email->reset();

$this->Email->smtpOptions = array(
'port'=>$smtp['port']['parameter_value'],
'timeout'=>'30',
'host' => $smtp['host']['parameter_value'],
'username'=>$smtp['username']['parameter_value'],
'password'=>$smtp['password']['parameter_value'],
);

$this->Email->smtpOptions = $smtp;
$this->Email->delivery = 'smtp';
$this->Email->to = $to;
$this->Email->cc = $cc;
$this->Email->to = $toAddress;
$this->Email->cc = $ccAddress;
$this->Email->bcc = $bcc;
$this->Email->subject = $subject;
$this->Email->from = $from;
Expand All @@ -172,28 +164,29 @@ protected function _sendEmail($content,$subject,$from,$to, $templateName = 'defa

return $this->Email->send($content);
}
/* }}} */

/**
* beforeLogin callback, called every time in auth compoment
*
* @access public
* @return void
*/
public function beforeLogin()
public function _beforeLogin()
{
// if we have a session transfered to us
if ($this->hasSessionTransferData()) {
if ($this->authenticateWithSessionTransferData()) {
if (method_exists($this, 'afterLogin')) {
$this->afterLogin();
if ($this->_hasSessionTransferData()) {
if ($this->_authenticateWithSessionTransferData()) {
if (method_exists($this, '_afterLogin')) {
$this->_afterLogin();
}
return true;
} else {
$this->Session->setFlash($this->Auth->loginError, $this->Auth->flashElement, array(), 'auth');
return false;
}
}
$this->set('loginHeader', $this->SysParameter->get('display.login.header'));
$this->set('loginFooter', $this->SysParameter->get('display.login.footer'));
}

/**
Expand All @@ -202,13 +195,13 @@ public function beforeLogin()
* @access public
* @return void
*/
public function afterLogin()
public function _afterLogin()
{
if ($this->Auth->isAuthorized()) {
User::getInstance($this->Auth->user());
// after login stuff
$this->AccessControl->getPermissions();
$this->User->loadRoles(User::get('id'));
$this->AccessControl->loadPermissions();
//TODO logging!
}

Expand All @@ -226,7 +219,7 @@ public function afterLogin()
* @access public
* @return void
*/
function afterLogout()
function _afterLogout()
{
$this->Session->destroy();
}
Expand All @@ -237,7 +230,7 @@ function afterLogout()
* @access public
* @return boolean
*/
function hasSessionTransferData()
function _hasSessionTransferData()
{
$params = $this->params['url'];
if (isset($params['username']) && isset($params['timestamp']) && isset($params['token']) && isset($params['signature'])) {
Expand All @@ -256,19 +249,18 @@ function hasSessionTransferData()
* @access public
* @return boolean
*/
function authenticateWithSessionTransferData()
function _authenticateWithSessionTransferData()
{
$message = $this->sessionTransferData['username'].$this->sessionTransferData['timestamp'].$this->sessionTransferData['token'];
$secret = $this->OauthToken->getTokenSecret($this->sessionTransferData['token']);
$signature = base64_encode(hash_hmac('sha1', $message, $secret, true));
if ($signature == $this->sessionTransferData['signature']) {
$user = $this->User->findByUsername($this->sessionTransferData['username']);
$this->Session->write($this->Auth->sessionKey, $user['User']);
$loggedIn = true;
return true;
}

Debugger::log('Invalid signature! Expect '.$signature.', Got '.$this->sessionTransferData['signature']);
$this->log('Invalid signature! Expect '.$signature.', Got '.$this->sessionTransferData['signature']);
return false;
}
}
15 changes: 0 additions & 15 deletions app/app_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,6 @@ class AppModel extends Model
{
protected $errorMessage = array();

/**
* __construct constructor function
*
* @param bool $id the id
* @param bool $table table
* @param bool $ds ds
*
* @access protected
* @return void
*/
function __construct($id = false, $table = null, $ds = null)
{
parent::__construct($id, $table, $ds);
}

/**
* save override save function
*
Expand Down
32 changes: 28 additions & 4 deletions app/config/core.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* This is core configuration file.
* This is core configuration file. It should be set up as production
* configuration. To customize it for development, please use config.local.php.
*
* Use it to configure core behavior of Cake.
*
Expand Down Expand Up @@ -33,7 +34,7 @@
* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/
Configure::write('debug', 2);
Configure::write('debug', 0);

/**
* CakePHP Log Level:
Expand Down Expand Up @@ -301,7 +302,18 @@
* ));
*
*/
Cache::config('default', array('engine' => 'File'));
Cache::config('default', array('engine' => 'File'));

// additional cache for configuration/sys parameters
Cache::config('configuration', array(
'engine' => 'File', //[required]
'duration'=> '+1 week', //[optional]
'probability'=> 100, //[optional]
'path' => CACHE, //[optional] use system tmp directory - remember to use absolute path
'prefix' => 'configuration_', //[optional] prefix every cache file with this string
'lock' => false, //[optional] use file locking
'serialize' => true, //[optional]
));


/**
Expand Down Expand Up @@ -330,4 +342,16 @@
$CWL['applicationID'] = '';
$CWL['applicationPassword'] = '';

define('IPEER_VERSION', '3.0.0 Beta');
define('IPEER_VERSION', '3.0.0');


/**
* Load the local configuration. It can override the ones
* in this file. Use it for your own customization,
* e.g.
* Configure::write('debug', 2);
* To turn on the debug
*/
if (file_exists(dirname(__FILE__).'/config.local.php')) {
include('config.local.php');
}
7 changes: 4 additions & 3 deletions app/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
'action' => 'login'));
Router::connect('/logout', array('plugin' => 'guard', 'controller' => 'guard',
'action' => 'logout'));
Router::connect('/loginout/loginByCWL', array('plugin' => 'guard', 'controller' => 'guard',
'action' => 'logout'));
// Connect url to groups api
Router::connect('/:controller/courses/:course_id/groups/:group_id',
array('action' => 'groups', 'group_id' => null),
Expand Down Expand Up @@ -96,8 +98,7 @@
// the /* directive would just redirect every page to the index page
// of install, including the install/install2/, etc. steps of install
Router::connect('/install/:action/*', array('controller' => 'install'));
Router::connect('/upgrade', array('controller' => 'upgrade', 'action' => 'index'));
Router::connect('/upgrade/:action', array('controller' => 'upgrade', 'action' => 'index'));
Router::connect('/*', array('controller' => 'install'));
}


?>
Loading

0 comments on commit 0752c48

Please sign in to comment.