Skip to content

Commit

Permalink
Continued development of simplification.
Browse files Browse the repository at this point in the history
Updated bootstrap 2.3
  • Loading branch information
Jason Schoeman committed Feb 11, 2013
1 parent c0c72a3 commit cbfd3d3
Show file tree
Hide file tree
Showing 16 changed files with 496 additions and 9,910 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ nbproject
write/upload/*
write/logs/*.log
write/logs/*.html
write/private/*.txt
single-site.config.php
multi-host.config.php
other/tests/unittests/diag/coverage/*
Expand Down
2 changes: 0 additions & 2 deletions includes/PHPDS.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,6 @@ public function run()
// We require templating system for final output
// Run template as required.
$this->PHPDS_core()->startController();
// Lets log access to menu item if so required.
$this->PHPDS_db()->logMenuAccess();
// Write collected logs to database.
$this->PHPDS_db()->logThis();
} catch (Exception $e) {
Expand Down
17 changes: 1 addition & 16 deletions includes/PHPDS_db.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,27 +437,12 @@ public function countRows($table_name, $column = false)
return $this->invokeQuery('DB_countRowsQuery', $column, $table_name);
}

/**
* Method logs menu access per user.
*
*/
public function logMenuAccess()
{
$configuration = $this->configuration;
// Check if we need to log.
// Log menu access...
if ($configuration['access_logging'] == true && ! empty($configuration['m']))
$this->invokeQuery('DB_logMenuAccessQuery', $configuration['m'], $configuration['user_id'], $configuration['time']);
}

/**
* This method logs error and success entries to the database.
*
* @param integer $log_type
* @param string $log_description
* @author Jason Schoeman <[email protected]>
*
* @version 1.0.1 Changed mysql_escape_string() to mysql_real_escape_string() [see http://www.php.net/manual/en/function.mysql-escape-string.php ]
* @version 1.0.1 Changed mysql_escape_string() to mysql_real_escape_string() [see http://www.php.net/manual/en/function.mysql-escape-string.php ]
*/
public function logThis()
{
Expand Down
2 changes: 1 addition & 1 deletion includes/PHPDS_user.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function currentUserID()
public function isSameGroup($user_id)
{
$edit = $this->db->invokeQuery('USER_isSameGroupQuery', $user_id);
return (!empty($edit['user_id']));
return (! empty($edit['user_id']));
}

/**
Expand Down
20 changes: 0 additions & 20 deletions includes/models/PHPDS_db.query.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,6 @@ public function invoke($parameters = null)
}
}

/**
* DB - Log Menu Access.
* @author Jason Schoeman, Contact: titan [at] phpdevshell [dot] org.
*
*/
class DB_logMenuAccessQuery extends PHPDS_query
{
/**
* Initiate query invoke command.
* @param array
* @return array
*/
protected $sql = "
INSERT INTO
_db_core_menu_access_logs (log_id, menu_id, user_id, timestamp)
VALUES
(NULL, '%s', '%u', '%s')
";
}

/**
* DB - General Logs.
* @author Jason Schoeman, Contact: titan [at] phpdevshell [dot] org.
Expand Down
114 changes: 9 additions & 105 deletions includes/models/PHPDS_user.query.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,6 @@ public function checkParameters(&$parameters = null)
}
}

/**
* USER - Get extra users roles.
* @author Jason Schoeman, Contact: titan [at] phpdevshell [dot] org.
*
*/
class USER_getExtraRolesQuery extends PHPDS_query
{
protected $sql = "
SELECT
user_role_id
FROM
_db_core_user_extra_roles
WHERE
user_id = %u
";
}

/**
* USER - Get users roles.
* @author Jason Schoeman, Contact: titan [at] phpdevshell [dot] org.
Expand All @@ -145,10 +128,7 @@ class USER_getRolesQuery extends PHPDS_query
*
* Parameters are ($user_id, $return_array) - $user_id can be 0 for current user
*
* @version 1.0.2
*
* @date 20110215 (greg) (v1.0.1) added checks to avoid error if $select_user_roles_db is not an array
* @date 20110315 (jason) (v1.0.2) improved functionality and stability.
* @version 2.0
*
* @param array
* @return array
Expand All @@ -158,65 +138,22 @@ public function invoke($parameters = null)
list($user_id, $return_array) = $parameters;
$configuration = $this->configuration;
$db = $this->db;
$user = $this->user;

// First try to assign default user id.
if (empty($user_id))
(! empty($configuration['user_id'])) ? $user_id = $configuration['user_id'] : $user_id = 0;
$user_id = (! empty($configuration['user_id'])) ? $configuration['user_id'] : 0;

// Check if user is a guest.
if (! empty($user_id)) {
// Check roles cache.
if ($db->cacheEmpty("roles_{$user_id}")) {
// Check if we have a saved array.
if (empty($user->mergeRoles)) {
// Pull user roles.
if ($user_id == $configuration['user_id']) {
$role_main = $configuration['user_role'];
} else {
$role_main = parent::invoke($user_id);
}

// Get all extra roles for user..
$role_array = $db->invokeQuery('USER_getExtraRolesQuery', $user_id);

// Set.
$role_string = '';

// Check if anything is selected.
if (is_array($role_array)) {
// Loop Roles and return string.
foreach ($role_array as $role_arr) {
$role_string .= "{$role_arr['user_role_id']},";
}
}
// Merger primary and extra roles.
$user->mergeRoles = rtrim("$role_main," . $role_string, ',');
}
// Write to cache.
$db->cacheWrite("roles_{$user_id}", $this->user->mergeRoles);
} else {
// Read from cache.
$user->mergeRoles = $db->cacheRead("roles_{$user_id}");
}

// Nothing there? Fallback to nothing.
if (empty($user->mergeRoles))
$user->mergeRoles = 0;

// What should we return, array or , string.
if ($return_array == false) {
// Ok return string.
return $user->mergeRoles;
} else {
// Ok return array.
return explode(',', $user->mergeRoles);
}

if ($user_id == $configuration['user_id']) {
return $configuration['user_role'];
} else {
$role = parent::invoke($user_id);
return ($return_array) ? array($role) : $role;
}
} else {
$settings = $db->essentialSettings;
$guest_role = $settings['guest_role'];
if (empty($guest_role)) throw new PHPDS_Exception('Unable to get the GUEST ROLE from the essential settings.');
if (empty($guest_role)) throw new PHPDS_Exception('Unable to get the GUEST ROLE from essential settings.');
return $return_array ? array($guest_role) : $guest_role;
}
}
Expand All @@ -238,39 +175,6 @@ class USER_getExtraGroupsQuery extends PHPDS_query
";
}

/**
* USER - Find group children.
* @author Jason Schoeman, Contact: titan [at] phpdevshell [dot] org.
*
* @date 20110504 (jason) (v1.0.0)
*
*/
class USER_findGroupChildren extends PHPDS_query
{
/**
* Initiate query invoke command.
* @param array
* @return string
*/
public function invoke($parameters = null)
{
list($group_id) = $parameters;
$user = $this->user;
$group_string = '';
// Check what children belongs to parent.
if (! empty($user->parentGroups[$group_id])) {
foreach ($user->parentGroups[$group_id] as $group) {
// Seek grand children.
if (! empty($user->parentGroups[$group]))
$group_string .= $user->findGroupChildren($group);
$group_string .= "{$group},";
}
}
// Return found results.
return $group_string;
}
}

/**
* USER - Get users groups.
* @author Jason Schoeman, Contact: titan [at] phpdevshell [dot] org.
Expand Down
56 changes: 28 additions & 28 deletions service/PHPDevShell-db-sample.sql
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
REPLACE INTO `pds_core_users` VALUES ('2', 'Test User 2', 'test2', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '3', '5', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('3', 'Test User 3', 'test3', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '3', '5', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('4', 'Test User 4', 'test4', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '3', '5', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('5', 'Test User 5', 'test5', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '3', '5', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('6', 'Test User 6', 'test6', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '2', '5', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('7', 'Test User 7', 'test7', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '2', '2', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('8', 'Test User 8', 'test8', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '2', '2', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('9', 'Test User 9', 'test9', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '2', '2', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('10', 'Test User 10', 'test2', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '5', '9', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('11', 'Test User 11', 'test2', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '5', '9', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('12', 'Test User 12', 'test2', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '5', '9', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES ('13', 'Test User 13', 'test2', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '5', '9', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 2', 'test2', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '3', '5', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 3', 'test3', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '3', '5', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 4', 'test4', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '3', '5', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 5', 'test5', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '3', '5', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 6', 'test6', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '2', '5', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 7', 'test7', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '2', '2', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 8', 'test8', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '2', '2', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 9', 'test9', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '2', '2', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 10', 'test2', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '5', '9', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 11', 'test2', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '5', '9', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 12', 'test2', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '5', '9', '12569537329', 'en', 'UTC', 'US');
REPLACE INTO `pds_core_users` VALUES (DEFAULT, 'Test User 13', 'test2', '63a9f0ea7bb98050796b649e85481845', '[email protected]', '5', '9', '12569537329', 'en', 'UTC', 'US');

INSERT INTO `pds_core_user_groups` VALUES ('20', 'Test Group 1', null, '0', '');
INSERT INTO `pds_core_user_groups` VALUES ('21', 'Test Group 2', null, '0', '');
INSERT INTO `pds_core_user_groups` VALUES ('22', 'Test Group 3', null, '0', '');
INSERT INTO `pds_core_user_groups` VALUES ('23', 'Test Group 4', null, '0', '');
INSERT INTO `pds_core_user_groups` VALUES ('24', 'Test Group 5', null, '0', '');
INSERT INTO `pds_core_user_groups` VALUES ('25', 'Test Group 6', null, '0', '');
INSERT INTO `pds_core_user_groups` VALUES ('26', 'Test Group 7', null, '0', '');
INSERT INTO `pds_core_user_groups` VALUES ('27', 'Test Group 8', null, '0', '');
INSERT INTO `pds_core_user_groups` VALUES (DEFAULT, 'Test Group 1', '', '');
INSERT INTO `pds_core_user_groups` VALUES (DEFAULT, 'Test Group 2', '', '');
INSERT INTO `pds_core_user_groups` VALUES (DEFAULT, 'Test Group 3', '', '');
INSERT INTO `pds_core_user_groups` VALUES (DEFAULT, 'Test Group 4', '', '');
INSERT INTO `pds_core_user_groups` VALUES (DEFAULT, 'Test Group 5', '', '');
INSERT INTO `pds_core_user_groups` VALUES (DEFAULT, 'Test Group 6', '', '');
INSERT INTO `pds_core_user_groups` VALUES (DEFAULT, 'Test Group 7', '', '');
INSERT INTO `pds_core_user_groups` VALUES (DEFAULT, 'Test Group 8', '', '');

INSERT INTO `pds_core_user_roles` VALUES ('20', 'Test Role 1', '');
INSERT INTO `pds_core_user_roles` VALUES ('21', 'Test Role 2', '');
INSERT INTO `pds_core_user_roles` VALUES ('22', 'Test Role 3', '');
INSERT INTO `pds_core_user_roles` VALUES ('23', 'Test Role 4', '');
INSERT INTO `pds_core_user_roles` VALUES ('24', 'Test Role 5', '');
INSERT INTO `pds_core_user_roles` VALUES ('25', 'Test Role 6', '');
INSERT INTO `pds_core_user_roles` VALUES ('26', 'Test Role 7', '');
INSERT INTO `pds_core_user_roles` VALUES ('27', 'Test Role 8', '');
INSERT INTO `pds_core_user_roles` VALUES (DEFAULT, 'Test Role 1', '');
INSERT INTO `pds_core_user_roles` VALUES (DEFAULT, 'Test Role 2', '');
INSERT INTO `pds_core_user_roles` VALUES (DEFAULT, 'Test Role 3', '');
INSERT INTO `pds_core_user_roles` VALUES (DEFAULT, 'Test Role 4', '');
INSERT INTO `pds_core_user_roles` VALUES (DEFAULT, 'Test Role 5', '');
INSERT INTO `pds_core_user_roles` VALUES (DEFAULT, 'Test Role 6', '');
INSERT INTO `pds_core_user_roles` VALUES (DEFAULT, 'Test Role 7', '');
INSERT INTO `pds_core_user_roles` VALUES (DEFAULT, 'Test Role 8', '');
52 changes: 0 additions & 52 deletions service/PHPDevShell-db4000-complete.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ CREATE TABLE `pds_core_logs` (
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- Create menu access logs table.;
CREATE TABLE `pds_core_menu_access_logs` (
`log_id` int(20) NOT NULL AUTO_INCREMENT,
`menu_id` varchar(64) NOT NULL,
`user_id` int(10) DEFAULT NULL,
`timestamp` int(10) DEFAULT NULL,
PRIMARY KEY (`log_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- Create table for default menu items.;
CREATE TABLE `pds_core_menu_items` (
`menu_id` varchar(64) NOT NULL,
Expand Down Expand Up @@ -260,27 +251,6 @@ INSERT INTO `pds_core_plugin_classes` (class_name, alias, plugin_folder, enable,
INSERT INTO `pds_core_plugin_classes` (class_name, alias, plugin_folder, enable, rank) VALUES ('crud', 'PHPDS_crud', 'CRUD', '1', '1');
INSERT INTO `pds_core_plugin_classes` (class_name, alias, plugin_folder, enable, rank) VALUES ('botBlock', 'PHPDS_botBlock', 'BotBlock', '1', '1');

-- Create table for registrations that is in queue.;
CREATE TABLE `pds_core_registration_queue` (
`user_id` int(20) unsigned NOT NULL DEFAULT '0',
`registration_type` int(1) DEFAULT NULL,
`token_id` int(20) DEFAULT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create table for registration tokens.;
CREATE TABLE `pds_core_registration_tokens` (
`token_id` int(10) NOT NULL AUTO_INCREMENT,
`token_name` varchar(255) DEFAULT NULL,
`user_role_id` int(10) DEFAULT NULL,
`user_group_id` int(10) DEFAULT NULL,
`token_key` varchar(42) DEFAULT NULL,
`registration_option` int(1) DEFAULT NULL,
`available_tokens` int(25) DEFAULT NULL,
PRIMARY KEY (`token_id`),
KEY `index` (`token_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create session table.;
CREATE TABLE `pds_core_session` (
`cookie_id` int(20) unsigned NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -441,28 +411,6 @@ INSERT INTO `pds_core_templates` VALUES ('1757887940', 'empty');
INSERT INTO `pds_core_templates` VALUES ('3566024413', 'emptyCloud');
INSERT INTO `pds_core_templates` VALUES ('3814588639', 'default');

-- Create file upload storing registry and logs.;
CREATE TABLE `pds_core_upload_logs` (
`file_id` int(20) unsigned NOT NULL AUTO_INCREMENT,
`sub_id` int(20) DEFAULT NULL,
`menu_id` varchar(64) NOT NULL,
`alias` varchar(255) DEFAULT NULL,
`original_filename` varchar(255) DEFAULT NULL,
`new_filename` varchar(255) DEFAULT NULL,
`relative_path` text,
`thumbnail` text,
`resized` text,
`extention` varchar(5) DEFAULT NULL,
`mime_type` varchar(255) DEFAULT NULL,
`file_desc` varchar(255) DEFAULT NULL,
`group_id` int(20) DEFAULT NULL,
`user_id` int(20) DEFAULT NULL,
`date_stored` int(10) unsigned DEFAULT NULL,
`file_size` int(14) DEFAULT NULL,
`file_explained` text,
PRIMARY KEY (`file_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- Create important user table to store all users.;
CREATE TABLE `pds_core_users` (
`user_id` int(20) unsigned NOT NULL AUTO_INCREMENT,
Expand Down
Loading

0 comments on commit cbfd3d3

Please sign in to comment.