Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b727a57
Merge pull request #9 from thewizster/develop
thewizster Jul 14, 2016
c9ab480
Merge pull request #10 from keoflex/develop
thewizster Jul 26, 2016
7921fa4
Merge pull request #13 from webextant/develop
thewizster Jul 26, 2016
284d6d0
remove dreamweaver _notes folders, remove echo text, add gitignore to…
thewizster Jul 26, 2016
bcb83c9
Merge pull request #11 from thewizster/develop
thewizster Jul 26, 2016
39a0a73
empty district level approver list validates and works.
thewizster Aug 4, 2016
91b301e
Merge branch 'hotfix/formbuildvalidation'
thewizster Aug 4, 2016
556a8f2
Merge branch 'hotfix/formbuildvalidation' into develop
thewizster Aug 4, 2016
3aa4285
Merge pull request #12 from thewizster/develop
thewizster Aug 4, 2016
4a81052
Fixes #11
thewizster Aug 4, 2016
b49e073
Fixes #11
thewizster Aug 4, 2016
f548ad3
Fixes #10
thewizster Aug 4, 2016
b30ccae
bump to v2.0.1
thewizster Aug 4, 2016
5e00f98
Merge branch 'release/v2.0.1'
thewizster Aug 4, 2016
7e3a29f
Merge tag 'v2.0.1' into develop
thewizster Aug 4, 2016
f28c469
Merge pull request #14 from thewizster/develop
thewizster Aug 4, 2016
9ba3952
See changelog.md 6Aug2016 for details.
thewizster Aug 6, 2016
c5508d0
Merge branch 'develop' of https://github.com/webextant/workorders int…
thewizster Aug 6, 2016
d8771b0
correct spelling error
thewizster Aug 11, 2016
9eea584
stub out code for collaborator feature
thewizster Aug 11, 2016
aef3dc3
add simple pubsub for easy eventing
thewizster Aug 11, 2016
66bda01
Structure for working with collaborators
thewizster Aug 16, 2016
c8e1675
Wires up select element and allows event subscribe
thewizster Aug 16, 2016
0125939
refactor html for clarity
thewizster Aug 16, 2016
e02432f
Add collaborator selection
thewizster Aug 16, 2016
e9f744e
Pulls collaborators from DB, refactor some code
thewizster Aug 16, 2016
5755c57
Update DB to support collaborator users
thewizster Aug 16, 2016
b3d0ee5
Remove references to form_manager field
thewizster Aug 19, 2016
bc1ed35
Split WO approve page into page_content dbquery.
thewizster Aug 19, 2016
52d0e1e
Add notes about user_perms
thewizster Aug 22, 2016
f526f5c
Add collaborator functioning.
thewizster Aug 22, 2016
860e016
Used to add a single comment to a workorder.
thewizster Aug 22, 2016
a4438ba
Finish collab feature
thewizster Sep 6, 2016
9ff01d0
Sends update email to creator
thewizster Sep 6, 2016
705e02c
Only allow access to current approver
thewizster Sep 6, 2016
9bb96f1
bug fix for handling group names with illegal char
thewizster Sep 6, 2016
f5a4c98
Move appconfig.php to config dir
thewizster Sep 7, 2016
c55f600
fix syntax bug in SQL
thewizster Sep 7, 2016
d301f3a
Update readme bump version
thewizster Sep 7, 2016
efc0880
FormsDataController new required params
thewizster Sep 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_notes/
.vscode/
30 changes: 30 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
# CHANGE LOG
**7 September 2016

* Fix: Issue handling illegal characters in group names
* Fix: Better handling of authorization when attempting to edit a workorder.
* Fix: Corrent some spelling errors.
* Improvement: Current approver can add collaborator to a workorder. * db changes see _update.
* Improvement: Sends update email to workorder creator when something changes.
* Improvement: Move workorder approve/edit into page_content and dbquery routing structure.
* Improvement: Refactor php/html in several places for greater clarity.
* Improvement: Add simple pubsub javascript library for easy frontend ui eventing.
* Improvement: Move appconfig.php to /config/appconfig.php * just makes sense.
* Improvement: Bump minor version

**6 August 2016**

* Fix: Pay engineering debt. forms_db_controller.php better follows data adapter pattern used in other classes.
* Fix: classes/login.php now including user fname and lname in query.
* Fix: XDebug with PHP on Windows showing multiple undefined variables. Fixed by initializing vars to null in multiple pages.
* Fix: Form preview on workorder forms list page now working. Added header_forms_admin.php to include JS code.
* Fix: Remove old db conn info in appconfig.php Not needed any longer.
* Fix: UserDataAdapter AdminUpdate function protected against SQL injection.
* Fix: Update .gitignore to ignore Visual Studio Code IDE config files in .vscode folder.
* Improvement: Supports using environment variables for db connection. See config/db.php for details.

**4 August 2016**

* Fix: #7 district level approver list can now be left blank if needed. Final will be handled by last group level approver.
* Fix: #10 Special characters in goup name can now include / char.
* Fix: #11 If forms fields have identical label text they will now render correctly in email and when viewing/editing.

**16 July 2016**

* Fix: Fixed the query section of the update user page. Now you can update user information
Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workorders v2.0.0
# Workorders v2.1.0

A simple way for large groups to organize work using custom forms!

Expand All @@ -14,4 +14,5 @@ A simple way for large groups to organize work using custom forms!
* User permission levels.
* User registration can be limited based on domain.
* Users can view work orders that need their approval.
* Users can view work orders they have submitted.
* Users can view work orders they have submitted.
* Collaboration feature allows including others in the workflow process as needed.
10 changes: 5 additions & 5 deletions src/_page_processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once("config/db.php");
require_once("classes/Login.php");
require_once('./resources/appconfig.php');
require_once('config/appconfig.php');

require_once "./resources/library/appinfo.php";
$appInfoDbAdapter = new AppInfo($dsn, $user_name, $pass_word);
Expand Down Expand Up @@ -87,8 +87,8 @@
*/



if($include_address == ""){
$folder = null; // set default value or error in navbar. XDebug
if(isset($include_address) == false || $include_address == ""){
$include_address = "page_content/index.php";
}
if(isset($_GET['I'])){
Expand Down Expand Up @@ -158,12 +158,12 @@

<div class="container-fluid">
<?php
if($BASE_URL == "http://localhost/workorder"){
if(getenv("WO_ENV_ENABLED") == 1 || $BASE_URL == "http://localhost/workorder"){
?>
<div class="col-lg-12">
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<i class="fa fa-info-circle"></i> <strong>ALERT </strong> Your are on the local server
<i class="fa fa-info-circle"></i> <strong>ALERT </strong> You are on the local server
</div>
</div>
<?php
Expand Down
5 changes: 5 additions & 0 deletions src/_update/db_update_6-14-2016.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
CREATE TABLE IF NOT EXISTS `groups` ( `GRP_id` INT NOT NULL AUTO_INCREMENT , `GRP_name` VARCHAR(50) NOT NULL COMMENT 'Currently GRP_id is not saved in users table GRP_name is' , PRIMARY KEY (`GRP_id`)) ENGINE = MyISAM;
/*
Add a permissions section to user table
NOTE: user_perms field in users table defines what users are allowed to see in the interface
ie
1 = super admin - can see all, do all
2 = admin - can approve workorders (sees needs approval button)
3 = user - can only create new workorders for approval
*/
ALTER TABLE `users` ADD `user_perms` TINYINT NOT NULL DEFAULT '3' COMMENT 'smaller=higher perms' AFTER `form_manager`;
5 changes: 5 additions & 0 deletions src/_update/db_update_8-13-2016_rb.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE `workorders` ADD `collaborators` TEXT COMMENT 'Current collaborators as JSON array of email addresses' AFTER `comments`;

ALTER TABLE `users` ADD `collaborator` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'User is a collaborator when set to non zero value' AFTER `user_perms`;

ALTER TABLE `users` DROP COLUMN `form_manager`;
3 changes: 1 addition & 2 deletions src/classes/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private function dologinWithPostData()

// database query, getting all the info of the selected user (allows login via email address in the
// username field)
$sql = "SELECT user_name, user_email, user_password_hash, user_group, form_manager, user_perms
$sql = "SELECT user_name, user_email, user_password_hash, user_group, user_perms, user_fname, user_lname
FROM users
WHERE user_name = '" . $user_name . "' OR user_email = '" . $user_name . "';";
$result_of_login_check = $this->db_connection->query($sql);
Expand All @@ -88,7 +88,6 @@ private function dologinWithPostData()
$_SESSION['user_lname'] = $result_row->user_lname;
$_SESSION['user_email'] = $result_row->user_email;
$_SESSION['user_group'] = $result_row->user_group;
$_SESSION['form_manager'] = $result_row->form_manager;
$_SESSION['user_perms'] = $result_row->user_perms;
$_SESSION['user_login_status'] = 1;

Expand Down
4 changes: 0 additions & 4 deletions src/classes/_notes/dwsync.xml

This file was deleted.

4 changes: 0 additions & 4 deletions src/resources/appconfig.php → src/config/appconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ abstract class Config {
const BaseUrl = "http://www.example.com/";
const SiteTitleShort = "FLOW";
const SiteTitleLong = "Work Flow";
const DbDsn = "mysql:host=localhost;dbname=formsdb";
const DbUsername = "";
const DbPassword = "";
const WorkorderApproverScript = "workorderview.php";
const WorkorderViewOnlyScript = "workorderview.php";
}

?>
32 changes: 26 additions & 6 deletions src/config/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
/**
* Configuration for: Database Connection
*
* NOTE: There are two ways to configure the DB connection.
* 1) Environment variables
* WO_ENV_ENABLED=1
* WO_DB_NAME=yourDBname
* WO_DB_USERNAME=yourDBusername
* WO_DB_PASSWORD=yourDBpassword
* 2) Modify values in this config file below
* Change DB_NAME, DB_USERNAME_HERE, and DB_PASSWORD_HERE
*
* For more information about constants please @see http://php.net/manual/en/function.define.php
* If you want to know why we use "define" instead of "const" @see http://stackoverflow.com/q/2447791/1114320
*
Expand All @@ -11,13 +20,24 @@
* DB_USER: user for your database. the user needs to have rights for SELECT, UPDATE, DELETE and INSERT.
* DB_PASS: the password of the above user
*/
$database_name = "DB_NAME";
$dsn = 'mysql:host=localhost;dbname='.$database_name;
$user_name = 'DB_USERNAME_HERE'; //DEFUAULT DB_USERNAME_HERE
$pass_word = 'DB_PASSWORD_HERE';
if(getenv("WO_ENV_ENABLED") == 1)
{
// Set these in your local environment
$database_name = getenv("WO_DB_NAME"); // DO NOT MODIFY HERE
$dsn = 'mysql:host=localhost;dbname='.$database_name;
$user_name = getenv('WO_DB_USERNAME'); // DO NOT MODIFY HERE
$pass_word = getenv('WO_DB_PASSWORD'); // DO NOT MODIFY HERE
} else {
// Modify the values below IF you are NOT using environment variables for config.
$database_name = "DB_NAME"; // SET DB NAME HERE
$dsn = 'mysql:host=localhost;dbname='.$database_name;
$user_name = 'DB_USERNAME_HERE'; // SET DB USERNAME HERE
$pass_word = 'DB_PASSWORD_HERE'; // SET DB PASSWORD HERE

if($user_name == 'DB_USERNAME_HERE'){
echo "<h1 style=\"color:red\">Woah!!! Hold on there Sparky, you need to update the util/forms_db_info.php befor running this program!</h1>";
if($user_name == 'DB_USERNAME_HERE'){
echo "<h1 style=\"color:red\">Woah!!! Hold on there Sparky, you need to update the config/db.php before running this program!</h1>";
die();
}
}

define("DB_HOST", "127.0.0.1");
Expand Down
4 changes: 0 additions & 4 deletions src/dbquery/_notes/dwsync.xml

This file was deleted.

6 changes: 3 additions & 3 deletions src/dbquery/qryADMIN/formbuild_qry.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
$formAvailable = 0;
if (isset($_POST["formAvailable"])) { $formAvailable = 1; }
if (isset($_POST["updateform"])){
$fdc = new FormsDataController();
$fdc = new FormsDataController($dsn, $user_name, $pass_word);
$QUERY_PROCESS = $fdc->updateForm($_POST["id"], $_POST["formname"], $_POST["formdesc"], $_POST["xmldata"], $_POST["workflow"], $_POST["notifyOnFinalApproval"], $formAvailable, $_POST["groupWorkflows"]);
} elseif (isset($_POST["deleteform"])) {
$fdc = new FormsDataController();
$fdc = new FormsDataController($dsn, $user_name, $pass_word);
$QUERY_PROCESS = $fdc->deleteForm($_POST["id"]);
} elseif (isset($_POST["addform"])) {
$fdc = new FormsDataController();
$fdc = new FormsDataController($dsn, $user_name, $pass_word);
$QUERY_PROCESS = $fdc->addForm($_POST["formname"], $_POST["formdesc"], $_POST["xmldata"], $_POST["workflow"], $_POST["notifyOnFinalApproval"], $formAvailable, $_POST["groupWorkflows"]);
if (!$QUERY_PROCESS){
echo "<div class='alert alert-danger'>All fields are required. Keep calm and try again...</div>";
Expand Down
4 changes: 0 additions & 4 deletions src/dbquery/qryGROUP/_notes/dwsync.xml

This file was deleted.

4 changes: 0 additions & 4 deletions src/dbquery/qryUSER/_notes/dwsync.xml

This file was deleted.

2 changes: 1 addition & 1 deletion src/dbquery/qryUSER/edit_user_qry.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once "./resources/library/user.php";

$usrDbAdapter = new UserDataAdapter($dsn, $user_name, $pass_word, $currentUserEmail);
$usrDbAdapter = new UserDataAdapter($dsn, $user_name, $pass_word);


$element = "User";
Expand Down
37 changes: 37 additions & 0 deletions src/dbquery/qryWORKORDER/add_collab_qry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/************************************************************************************************
Adds a user as a collaborator to a workorder
Author: Raymond Brady
Date Created: 8/16/2016
************************************************************************************************/
require_once('./resources/library/workorder.php');

$element = "Workorder";
$element_function = "updated";

if (!isset($_SESSION['user_email']) || !isset($_POST['id']) || !isset($_POST['key']) || !isset($_POST['collabcomment']) || !isset($_POST['collabUserSelect'])) {
$QUERY_PROCESS = "ERROR|Required fields are missing.";
return;
}
// Gather data, process POST, and update the workorder with collaborator
$currentUserEmail = filter_var($_SESSION['user_email'], FILTER_SANITIZE_EMAIL);
$id = filter_var(trim($_POST['id']), FILTER_SANITIZE_NUMBER_INT);
$key = filter_var(trim($_POST['key']), FILTER_SANITIZE_STRING);
$commentInput = filter_var(trim($_POST['collabcomment']), FILTER_SANITIZE_STRING);
$comment = "Requesting collaboration for this item.";
if ($commentInput != null ){
$comment = $commentInput;
}

$collabUser = filter_var(trim($_POST['collabUserSelect']), FILTER_SANITIZE_NUMBER_INT);

$workorderDataAdapter = new WorkorderDataAdapter($dsn, $user_name, $pass_word, $currentUserEmail);
$QUERY_PROCESS = $workorderDataAdapter->AddCollaborator($id, $comment, $collabUser);

$wo = $workorderDataAdapter->Select($id);
$woViewModel = new WorkorderViewModel($wo, $key, $currentUserEmail);
// send emails.
$fromEmailAddress = 'noreply@dumasisd.org';
$emailAdapter = new WorkorderEmailAdapter($fromEmailAddress);
$emailAdapter->SendAddCollab($wo, $woViewModel);
?>
24 changes: 24 additions & 0 deletions src/dbquery/qryWORKORDER/add_comment_qry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/************************************************************************************************
Adds a comment to a workorder
Author: Raymond Brady
Date Created: 8/22/2016
************************************************************************************************/
require_once('./resources/library/workorder.php');

$element = "Workorder";
$element_function = "updated";

if (!isset($_SESSION['user_email']) || !isset($_POST['id']) || !isset($_POST['collabcomment'])) {
$QUERY_PROCESS = "ERROR|Required fields are missing.";
return;
}
// Gather data, process POST, and update the workorder with collaborator
$currentUserEmail = filter_var($_SESSION['user_email'], FILTER_SANITIZE_EMAIL);
$id = filter_var(trim($_POST['id']), FILTER_SANITIZE_NUMBER_INT);
$key = filter_var(trim($_POST['key']), FILTER_SANITIZE_STRING);
$comment = filter_var(trim($_POST['collabcomment']), FILTER_SANITIZE_STRING);

$workorderDataAdapter = new WorkorderDataAdapter($dsn, $user_name, $pass_word, $currentUserEmail);
$QUERY_PROCESS = $workorderDataAdapter->AddComment($id, $comment);
?>
36 changes: 36 additions & 0 deletions src/dbquery/qryWORKORDER/end_collab_qry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/************************************************************************************************
Ends ALL user collaboration for a workorder
Author: Raymond Brady
Date Created: 9/6/2016
************************************************************************************************/
require_once('./resources/library/workorder.php');

$element = "Workorder";
$element_function = "updated";

if (!isset($_SESSION['user_email']) || !isset($_POST['id']) || !isset($_POST['key'])) {
$QUERY_PROCESS = "ERROR|Required fields are missing.";
return;
}
// Gather data, process POST, and update the workorder
$currentUserEmail = filter_var($_SESSION['user_email'], FILTER_SANITIZE_EMAIL);
$id = filter_var(trim($_POST['id']), FILTER_SANITIZE_NUMBER_INT);
$key = filter_var(trim($_POST['key']), FILTER_SANITIZE_STRING);
$comment = "Thanks for the assist! I ended collaboration.";
if (isset($_POST['endcollabcomment']) && $_POST['endcollabcomment'] != null ){
$comment = filter_var(trim($_POST['endcollabcomment']), FILTER_SANITIZE_STRING);
}

$workorderDataAdapter = new WorkorderDataAdapter($dsn, $user_name, $pass_word, $currentUserEmail);
// read the record before making the changes. Used for sending collab emails
$wo = $workorderDataAdapter->Select($id);
$woViewModel = new WorkorderViewModel($wo, $key, $currentUserEmail);

$QUERY_PROCESS = $workorderDataAdapter->EndCollaboration($id, $comment);

// send emails.
$fromEmailAddress = 'noreply@dumasisd.org';
$emailAdapter = new WorkorderEmailAdapter($fromEmailAddress);
$emailAdapter->SendEndCollab($wo, $woViewModel);
?>
Loading