forked from masood09/ProjectManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f715aa9
Showing
201 changed files
with
28,411 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
###Windows### | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
|
||
###Linux### | ||
|
||
!.gitignore | ||
*~ | ||
|
||
# KDE | ||
.directory | ||
|
||
|
||
###OSX### | ||
|
||
.DS_Store | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear on external disk | ||
.Spotlight-V100 | ||
.Trashes | ||
|
||
|
||
###Project### | ||
|
||
/app/config/config.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<IfModule mod_rewrite.c> | ||
RewriteEngine On | ||
RewriteRule ^$ public/ [L] | ||
RewriteRule (.*) public/$1 [L] | ||
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Order deny,allow | ||
Deny from all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<config> | ||
<core> | ||
<name><![CDATA[GS Microsystems]]></name> | ||
<version><![CDATA[0.1.0]]></version> | ||
<baseUrl><![CDATA[http://localhost/Project/]]></baseUrl> | ||
</core> | ||
<database> | ||
<host><![CDATA[]]></host> | ||
<username><![CDATA[]]></username> | ||
<password><![CDATA[]]></password> | ||
<dbname><![CDATA[]]></dbname> | ||
</database> | ||
<metadata> | ||
<adapter><![CDATA[Apc]]></adapter> | ||
</metadata> | ||
<email> | ||
<host><![CDATA[localhost]]></host> | ||
<username><![CDATA[]]></username> | ||
<password><![CDATA[]]></password> | ||
<port><![CDATA[25]]></port> | ||
<ssl><![CDATA[fasle]]></ssl> | ||
<from><![CDATA[[email protected]]]></from> | ||
</email> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
class AdminController extends ControllerBase | ||
{ | ||
public function indexAction() | ||
{ | ||
Phalcon\Tag::appendTitle('Administration'); | ||
$this->view->setVar('developers', User::getAllDevelopers()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<?php | ||
|
||
class ControllerBase extends \Phalcon\Mvc\Controller | ||
{ | ||
protected $session_id = null; | ||
protected $currentUser = null; | ||
|
||
/** | ||
* @var Phalcon\Acl\Adapter\Memory | ||
*/ | ||
protected $_acl; | ||
|
||
protected function _getAcl() | ||
{ | ||
if (!$this->_acl) { | ||
|
||
$acl = new Phalcon\Acl\Adapter\Memory(); | ||
|
||
$acl->setDefaultAction(Phalcon\Acl::DENY); | ||
|
||
// Register roles | ||
$roles = array( | ||
'admin' => new Phalcon\Acl\Role('admin'), | ||
'developer' => new Phalcon\Acl\Role('developer'), | ||
'guest' => new Phalcon\Acl\Role('guest') | ||
); | ||
|
||
foreach ($roles as $role) { | ||
$acl->addRole($role); | ||
} | ||
|
||
// Private area resources | ||
$adminResources = array( | ||
'index' => array('index'), | ||
'project' => array('index', 'create', 'createpost', 'saveusers', 'savepost'), | ||
'task' => array('savepost', 'view', 'subscribe', 'unsubscribe', 'addcomment', 'index'), | ||
'admin' => array('index'), | ||
'user' => array('saveuser', 'myaccount'), | ||
); | ||
|
||
// Private developer resources | ||
$developerResources = array( | ||
'index' => array('index'), | ||
'project' => array('index', 'create', 'createpost', 'saveusers', 'savepost'), | ||
'task' => array('savepost', 'view', 'subscribe', 'unsubscribe', 'addcomment', 'index'), | ||
'user' => array('logout', 'myaccount'), | ||
); | ||
|
||
foreach ($adminResources as $resource => $actions){ | ||
$acl->addResource(new Phalcon\Acl\Resource($resource), $actions); | ||
} | ||
|
||
foreach ($developerResources as $resource => $actions){ | ||
$acl->addResource(new Phalcon\Acl\Resource($resource), $actions); | ||
} | ||
|
||
// Public area resources | ||
$publicResources = array( | ||
'user' => array('login', 'loginpost', 'test'), | ||
); | ||
|
||
foreach ($publicResources as $resource => $actions) { | ||
$acl->addResource(new Phalcon\Acl\Resource($resource), $actions); | ||
} | ||
|
||
// Grant access to public areas to both users and guests | ||
foreach ($roles as $role) { | ||
foreach($publicResources as $resource => $actions){ | ||
$acl->allow($role->getName(), $resource, '*'); | ||
} | ||
} | ||
|
||
// Grant acess to admin area to role Admin | ||
foreach ($adminResources as $resource => $actions) { | ||
foreach($actions as $action){ | ||
$acl->allow('admin', $resource, $action); | ||
} | ||
} | ||
|
||
// Grant acess to developer area to role Developer | ||
foreach ($developerResources as $resource => $actions) { | ||
foreach($actions as $action){ | ||
$acl->allow('developer', $resource, $action); | ||
} | ||
} | ||
|
||
$this->_acl = $acl; | ||
} | ||
|
||
return $this->_acl; | ||
} | ||
|
||
protected function initialize() | ||
{ | ||
$role = null; | ||
$session_id = $this->session->get('session_id'); | ||
$role = SessionHelper::getUserRole($session_id); | ||
|
||
if (is_null($role)) { | ||
$role = 'guest'; | ||
} | ||
else { | ||
$role = $role->code; | ||
} | ||
|
||
if (!$session_id) { | ||
$this->session_id = null; | ||
$this->currentUser = null; | ||
$this->view->setVar('currentUser', $this->currentUser); | ||
} | ||
else { | ||
$this->session_id = $session_id; | ||
$this->currentUser = SessionHelper::getUser($session_id); | ||
$this->view->setVar('currentUser', $this->currentUser); | ||
} | ||
|
||
Phalcon\Tag::prependTitle('Project Manager | '); | ||
|
||
$controller = $this->dispatcher->getControllerName(); | ||
$action = $this->dispatcher->getActionName(); | ||
|
||
$acl = $this->_getAcl(); | ||
|
||
$allowed = $acl->isAllowed($role, $controller, $action); | ||
|
||
if ($allowed != Phalcon\Acl::ALLOW) { | ||
if ($role == 'guest') { | ||
$this->flashSession->error('Please login before you proceed.'); | ||
$this->response->redirect('user/login'); | ||
$this->view->disable(); | ||
return; | ||
} | ||
else { | ||
$this->flashSession->error('You do not have permission to access this area.'); | ||
$this->response->redirect('project/index'); | ||
$this->view->disable(); | ||
return; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
class IndexController extends ControllerBase | ||
{ | ||
public function indexAction() | ||
{ | ||
echo $this->session_id; die; | ||
} | ||
} |
Oops, something went wrong.