Skip to content

Commit

Permalink
moving tablePrefix to ManagementAppModel
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Feb 4, 2010
1 parent 64c23a3 commit 62505b4
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 121 deletions.
22 changes: 21 additions & 1 deletion infinitas/management/controllers/users_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function login(){
* @access public
*/
function logout(){

$this->redirect($this->Auth->logout());
}

function register(){
Expand All @@ -56,6 +56,14 @@ function register(){
}


function admin_login(){

}

function admin_logout(){
$this->redirect($this->Auth->logout());
}

function admin_index(){
$this->User->recursive = 0;
$users = $this->paginate(null, $this->Filter->filter);
Expand Down Expand Up @@ -109,5 +117,17 @@ function admin_edit($id = null) {
$groups = $this->User->Group->find('list');
$this->set(compact('groups'));
}

function admin_initDB() {
$group =& $this->User->Group;
//Allow admins to everything
$group->id = 1;
$this->Acl->allow($group, 'controllers');

//allow managers to posts and widgets
$group->id = 2;
//$this->Acl->deny($group, 'controllers');
}

}
?>
45 changes: 23 additions & 22 deletions infinitas/management/management_app_model.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<?php
/**
* Comment Template.
*
* @todo Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/

class ManagementAppModel extends AppModel {
}

<?php
/**
* Comment Template.
*
* @todo Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/

class ManagementAppModel extends AppModel {
var $tablePrefix = 'core_';
}

?>
130 changes: 64 additions & 66 deletions infinitas/management/models/backup.php
Original file line number Diff line number Diff line change
@@ -1,67 +1,65 @@
<?php
/**
* Comment Template.
*
* @todo Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/

class Backup extends CoreAppModel {
var $name = 'Backup';

var $tablePrefix = 'core_';

var $last_id = 0;
/**
* Constructor
*
* @access protected
*/
function getLastBackup($model = null, $plugin = null) {
$lastBackup = $this->find(
'first',
array(
'fields' => array(
'Backup.last_id'
),
'conditions' => array(
'Backup.plugin' => $plugin,
'Backup.model' => $model
),
'order' => array(
'Backup.id' => 'DESC'
)
)
);

if (!empty($lastBackup)) {
$this->last_id = $lastBackup['Backup']['last_id'];
}

return $this->last_id;
}

function getRecordsForBackup($Model) {
return $Model->find(
'all',
array(
'conditions' => array($Model->name . '.id > ' => $this->last_id
),
'contain' => false
)
);
}
}

<?php
/**
* Comment Template.
*
* @todo Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/

class Backup extends CoreAppModel {
var $name = 'Backup';

var $last_id = 0;
/**
* Constructor
*
* @access protected
*/
function getLastBackup($model = null, $plugin = null) {
$lastBackup = $this->find(
'first',
array(
'fields' => array(
'Backup.last_id'
),
'conditions' => array(
'Backup.plugin' => $plugin,
'Backup.model' => $model
),
'order' => array(
'Backup.id' => 'DESC'
)
)
);

if (!empty($lastBackup)) {
$this->last_id = $lastBackup['Backup']['last_id'];
}

return $this->last_id;
}

function getRecordsForBackup($Model) {
return $Model->find(
'all',
array(
'conditions' => array($Model->name . '.id > ' => $this->last_id
),
'contain' => false
)
);
}
}

?>
1 change: 0 additions & 1 deletion infinitas/management/models/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
class Comment extends ManagementAppModel {
var $name = 'Comment';
var $tablePrefix = 'core_';

function __construct($id = false, $table = null, $ds = null) {
parent::__construct($id, $table, $ds);
Expand Down
2 changes: 0 additions & 2 deletions infinitas/management/models/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
class Config extends ManagementAppModel {
var $name = 'Config';

var $tablePrefix = 'core_';

var $order = array(
'Config.core' => 'DESC',
'Config.key' => 'ASC'
Expand Down
7 changes: 5 additions & 2 deletions infinitas/management/models/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
*
*/
class Group extends ManagementAppModel{
var $tablePrefix = 'core_';
var $name = 'Group';
var $actsAs = array('Tree', 'Acl' => array('requester'));

var $actsAs = array('Tree');
function parentNode() {
return null;
}
}
?>
1 change: 0 additions & 1 deletion infinitas/management/models/log.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
class Log extends ManagementAppModel {
var $tablePrefix = 'core_';
var $name = 'Log';

var $order = array(
Expand Down
2 changes: 0 additions & 2 deletions infinitas/management/models/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
class Menu extends ManagementAppModel{
var $name = 'Menu';

var $tablePrefix = 'core_';

var $hasMany = array(
'MenuItem' => array(
'className' => 'Management.MenuItem',
Expand Down
2 changes: 0 additions & 2 deletions infinitas/management/models/menu_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
class MenuItem extends ManagementAppModel{
var $name = 'MenuItem';

var $tablePrefix = 'core_';

var $actsAs = array('Tree');

var $belongsTo = array(
Expand Down
4 changes: 1 addition & 3 deletions infinitas/management/models/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
class Module extends ManagementAppModel{
var $name = 'Module';

var $tablePrefix = 'core_';

var $actsAs = array(
'Libs.Ordered' => array(
'foreign_key' => 'position_id'
Expand All @@ -34,7 +32,7 @@ class Module extends ManagementAppModel{
var $hasAndBelongsToMany = array(
'Route' => array(
'className' => 'Management.Route',
'joinTable' => 'core_modules_routes',
'joinTable' => 'modules_routes',
'foreignKey' => 'module_id',
'associationForeignKey' => 'route_id',
'unique' => true
Expand Down
2 changes: 0 additions & 2 deletions infinitas/management/models/module_position.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
class ModulePosition extends ManagementAppModel{
var $name = 'ModulePosition';

var $tablePrefix = 'core_';
}
?>
2 changes: 0 additions & 2 deletions infinitas/management/models/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
class Route extends ManagementAppModel {
var $name = 'Route';

var $tablePrefix = 'core_';

var $actsAs = array(
'Libs.Ordered'
);
Expand Down
2 changes: 0 additions & 2 deletions infinitas/management/models/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
class Theme extends ManagementAppModel {
var $name = 'Theme';

var $tablePrefix = 'core_';

var $hasMay = array(
'Management.Route'
);
Expand Down

0 comments on commit 62505b4

Please sign in to comment.