Skip to content

Commit

Permalink
Merge pull request #153 from CON-In-A-Box/ARIC_cleanup_concom
Browse files Browse the repository at this point in the history
Aric - Cleanup ConCom
  • Loading branch information
tskeeley authored May 9, 2018
2 parents f98dced + ba15072 commit d9ddf9b
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 123 deletions.
22 changes: 6 additions & 16 deletions functions/session.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
require_module 'standard';
.*/

if (!in_array('concom', $DISABLEDMODULES)) {
if (is_dir($MODULESDIR.DIRECTORY_SEPARATOR.'concom')) {
$check = $MODULESDIR.DIRECTORY_SEPARATOR.'concom';
$check .= DIRECTORY_SEPARATOR.'functions/concom.inc';
if (is_file($check)) {
require_once($check);
}
}
}


function buildSessionData($accountId)
{
Expand Down Expand Up @@ -71,8 +61,8 @@ function buildSessionData($accountId)
}

// Current ConCom Positions and ConCom Years Served
if (class_exists('CONCOM') && method_exists('CONCOM', 'getConComPosition')) {
$_SESSION['customFields']['currConComPos'] = CONCOM::getConComPosition($accountId);
if (class_exists('\\concom\\POSITION') && method_exists('\\concom\\POSITION', 'getConComPosition')) {
$_SESSION['customFields']['currConComPos'] = concom\POSITION::getConComPosition($accountId);
}

// Current Hotel Lottery Status
Expand Down Expand Up @@ -215,8 +205,8 @@ function loadAccount($accountId)
}

// Current ConCom Positions and ConCom Years Served
if (class_exists('CONCOM') && method_exists('CONCOM', 'getConComPosition')) {
$_SESSION['customFields']['currConComPos'] = CONCOM::getConComPosition($accountId);
if (class_exists('\\concom\\POSITION') && method_exists('\\concom\\POSITION', 'getConComPosition')) {
$_SESSION['customFields']['currConComPos'] = concom\POSITION::getConComPosition($accountId);
}

// Current Hotel Lottery Status
Expand All @@ -227,8 +217,8 @@ function loadAccount($accountId)
$_SESSION['customFields']['hotelRoomCheckOut'] = &$_SESSION['customFields'][search_definedFields('Check Out')];

// If the logged in user is in the volunteers, note it
if (class_exists('VOLUNTEERS') && method_exists('VOLUNTEERS', 'inVolunteers')) {
$_SESSION['IS_VOLUNTEERS'] = VOLUNTEERS::inVolunteers($accountId);
if (class_exists('\\concom\\VOLUNTEERS') && method_exists('\\concom\\VOLUNTEERS', 'inVolunteers')) {
$_SESSION['IS_VOLUNTEERS'] = concom\VOLUNTEERS::inVolunteers($accountId);
}

// If the logged in user is a System Admin (defined in the config file), note it
Expand Down
14 changes: 2 additions & 12 deletions functions/users.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
require_module 'standard';
.*/

if (!in_array('concom', $DISABLEDMODULES)) {
if (is_dir($MODULESDIR.DIRECTORY_SEPARATOR.'concom')) {
$check = $MODULESDIR.DIRECTORY_SEPARATOR.'concom';
$check .= DIRECTORY_SEPARATOR.'functions/concom.inc';
if (is_file($check)) {
require_once($check);
}
}
}


function _parse_user($result, $additional_fields)
{
Expand All @@ -30,8 +20,8 @@ function _parse_user($result, $additional_fields)
} else {
$user['Last Name'] = $result['Last Name'];
}
if (class_exists('CONCOM') && method_exists('CONCOM', 'getConComPosition')) {
$user['ConCom'] = CONCOM::getConComPosition($user['Id']);
if (class_exists('\\concom\\POSITION') && method_exists('\\concom\\POSITION', 'getConComPosition')) {
$user['ConCom'] = concom\POSITION::getConComPosition($user['Id']);
}
if (!empty($result['Email 1'])) {
$user['Email'] = $result['Email 1'];
Expand Down
58 changes: 58 additions & 0 deletions modules/concom/functions/POSITION.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace concom;

class POSITION
{


public static function getConComPosition($account, $event = null)
{
if ($event == null) {
$event = current_eventID();
}
$sql = <<<SQL
SELECT
*,
(
SELECT
Name
FROM
Departments
WHERE
DepartmentID = c.DepartmentID
) as Department,
(
SELECT
Name
FROM
ConComPositions
WHERE
PositionID = c.PositionID
) as Position
FROM
ConComList as c
WHERE
AccountID = $account
AND EventID = $event;
SQL;
$result = \DB::run($sql);
$value = $result->fetch();
$retvalue = null;
while ($value !== false) {
if ($retvalue == null) {
$retvalue = array();
}
$retvalue[] = ['position' => $value['Position'],
'department' => $value['Department'],
'departmentId' => $value['DepartmentID'],
'note' => $value['Note']];
$value = $result->fetch();
}
return $retvalue;

}


/* end POSITION */
}
26 changes: 26 additions & 0 deletions modules/concom/functions/REGISTRATION.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace concom;

class REGISTRATION
{


public static function inRegistration($lookup)
{
$sql = "SELECT count(ListRecordID) as count From ConComList";
$sql .= " WHERE AccountID = $lookup";
$sql .= " AND DepartmentID = (SELECT DepartmentID FROM Departments WHERE Name = 'Registration');";
$result = \DB::run($sql);
$value = $result->fetch();
if ($value !== false && $value['count']) {
return true;
} else {
return false;
}

}


/* end REGISTRATION */
}
26 changes: 26 additions & 0 deletions modules/concom/functions/VOLUNTEERS.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace concom;

class VOLUNTEERS
{


public static function inVolunteers($lookup)
{
$sql = "SELECT count(ListRecordID) as count From ConComList";
$sql .= " WHERE AccountID = $lookup";
$sql .= " AND DepartmentID = (SELECT DepartmentID FROM Departments WHERE Name = 'Volunteers');";
$result = \DB::run($sql);
$value = $result->fetch();
if ($value !== false && $value['count']) {
return true;
} else {
return false;
}

}


/* end VOLUNTEERS */
}
96 changes: 3 additions & 93 deletions modules/concom/functions/concom.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,99 +3,9 @@
require_once($FUNCTIONDIR.'/divisional.inc');
require_once($FUNCTIONDIR."/database.inc");
require_once($FUNCTIONDIR.'/users.inc');

class VOLUNTEERS {

public static function inVolunteers($lookup)
{
$sql = "SELECT count(ListRecordID) as count From ConComList";
$sql .= " WHERE AccountID = $lookup";
$sql .=" AND DepartmentID = (SELECT DepartmentID FROM Departments WHERE Name = 'Volunteers');";
$result = DB::run($sql);
$value = $result->fetch();
if ($value !== false && $value['count']) {
return true;
}
else {
return false;
}
}

}


class CONCOM {

public static function getConComPosition($account, $event = null)
{
if ($event == null) {
$event = current_eventID();
}
$sql = <<<SQL
SELECT
*,
(
SELECT
Name
FROM
Departments
WHERE
DepartmentID = c.DepartmentID
) as Department,
(
SELECT
Name
FROM
ConComPositions
WHERE
PositionID = c.PositionID
) as Position
FROM
ConComList as c
WHERE
AccountID = $account
AND EventID = $event;
SQL;
$result = DB::run($sql);
$value = $result->fetch();
$retvalue = null;
while ($value !== false) {
if ($retvalue == null) {
$retvalue = array();
}
$retvalue[] = ['position' => $value['Position'],
'department' => $value['Department'],
'departmentId' => $value['DepartmentID'],
'note' => $value['Note']];
$value = $result->fetch();
}
return $retvalue;
}

}

class REGISTRATION
{


public static function inRegistration($lookup)
{
$sql = "SELECT count(ListRecordID) as count From ConComList";
$sql .= " WHERE AccountID = $lookup";
$sql .= " AND DepartmentID = (SELECT DepartmentID FROM Departments WHERE Name = 'Registration');";
$result = DB::run($sql);
$value = $result->fetch();
if ($value !== false && $value['count']) {
return true;
} else {
return false;
}

}


/* end REGISTRATION */
}
require_once(__DIR__.'/VOLUNTEERS.inc');
require_once(__DIR__.'/POSITION.inc');
require_once(__DIR__.'/REGISTRATION.inc');


function getDivision($dep)
Expand Down
5 changes: 5 additions & 0 deletions modules/concom/init.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

require_once(__DIR__.'/functions/VOLUNTEERS.inc');
require_once(__DIR__.'/functions/POSITION.inc');
require_once(__DIR__.'/functions/REGISTRATION.inc');
4 changes: 2 additions & 2 deletions modules/registration/pages/menubar.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
require_module 'standard';
.*/

if (class_exists('REGISTRATION') && method_exists('REGISTRATION', 'inRegistration')) {
$in_registration = REGISTRATION::inRegistration($_SESSION['accountId']);
if (class_exists('\\concom\\REGISTRATION') && method_exists('\\concom\\REGISTRATION', 'inRegistration')) {
$in_registration = concom\REGISTRATION::inRegistration($_SESSION['accountId']);
} else {
$in_registration = false;
}
Expand Down

0 comments on commit d9ddf9b

Please sign in to comment.