Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User/Nav/Session Cleanup #1377

Merged
merged 24 commits into from
Nov 22, 2016
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
813331d
user object & session updates
DawoudIO Nov 16, 2016
be6544f
moving headers to header file... not funcations
DawoudIO Nov 16, 2016
c338bba
removed commented code
DawoudIO Nov 16, 2016
867db65
removed commented code
DawoudIO Nov 16, 2016
2fcaa53
delete user
DawoudIO Nov 16, 2016
e76e9fb
user orm
DawoudIO Nov 16, 2016
d7c66ee
global message is now done via JS
DawoudIO Nov 16, 2016
4f8c17c
moved settings / tasks to right nav menu
DawoudIO Nov 16, 2016
4717846
Admin Nav is now hardcode via icons in the Right Nav
DawoudIO Nov 16, 2016
a51dffd
check for null before deleteing the user
DawoudIO Nov 16, 2016
43c8b85
changed users settings icon
DawoudIO Nov 16, 2016
97ec153
updated font - awesome to 4.7.0
DawoudIO Nov 16, 2016
b021b69
Merge branch 'develop' into right-nav-v1
DawoudIO Nov 18, 2016
cfd0a3b
code review feedback
DawoudIO Nov 19, 2016
b4471e9
Side Nav bar now has admin and non admin settings.
DawoudIO Nov 19, 2016
c94e37a
Edit Group Types moved to side nav
DawoudIO Nov 19, 2016
ea4dc57
cleaner nav footer for crm settings
DawoudIO Nov 19, 2016
f080f09
Merge branch 'develop' into right-nav-v1
DawoudIO Nov 20, 2016
1696182
Merge branch 'develop' into right-nav-v1
DawoudIO Nov 21, 2016
46034d1
more cleanup
DawoudIO Nov 21, 2016
dd47764
added missing script
DawoudIO Nov 21, 2016
73d74ae
fixed menus AUTO_INCREMENT
DawoudIO Nov 21, 2016
f1d0ed8
updated nav menus to match install menus
DawoudIO Nov 21, 2016
d9064b4
Merge branch 'develop' into right-nav-v1
crossan007 Nov 22, 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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"admin-lte": "2.3.7",
"ionicons": "2.0.1",
"font-awesome": "4.6.3",
"font-awesome": "4.7.0",
"fullcalendar": "3.0.1"
},
"scripts": {
Expand Down
25 changes: 11 additions & 14 deletions propel/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -608,21 +608,18 @@
<table name="user_usr" idMethod="native" phpName="User">
<column name="usr_per_ID" phpName="PersonId" type="SMALLINT" size="9" sqlType="mediumint(9) unsigned" primaryKey="true" required="true" defaultValue="0"/>
<column name="usr_Password" phpName="Password" type="VARCHAR" size="500" required="true" defaultValue=""/>
<column name="usr_NeedPasswordChange" phpName="NeedPasswordChange" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="1"/>
<column name="usr_NeedPasswordChange" phpName="NeedPasswordChange" type="BOOLEAN" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="1"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean size 3? What kind of parallel universe is this?! :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

<column name="usr_LastLogin" phpName="LastLogin" type="TIMESTAMP" required="true" defaultValue="0000-00-00 00:00:00"/>
<column name="usr_LoginCount" phpName="LoginCount" type="SMALLINT" size="5" sqlType="smallint(5) unsigned" required="true" defaultValue="0"/>
<column name="usr_FailedLogins" phpName="FailedLogins" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_AddRecords" phpName="AddRecords" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_EditRecords" phpName="EditRecords" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_DeleteRecords" phpName="DeleteRecords" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_MenuOptions" phpName="MenuOptions" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_ManageGroups" phpName="ManageGroups" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_Finance" phpName="Finance" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_Communication" phpName="Communication" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_Notes" phpName="Notes" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_Admin" phpName="Admin" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_Workspacewidth" phpName="WorkspaceWidth" type="SMALLINT"/>
<column name="usr_BaseFontSize" phpName="BaseFontsize" type="TINYINT"/>
<column name="usr_AddRecords" phpName="AddRecords" type="BOOLEAN" size="1" sqlType="tinyint(1) unsigned" required="true" defaultValue="0"/>
<column name="usr_EditRecords" phpName="EditRecords" type="BOOLEAN" size="1" sqlType="tinyint(1) unsigned" required="true" defaultValue="0"/>
<column name="usr_DeleteRecords" phpName="DeleteRecords" type="BOOLEAN" size="1" sqlType="tinyint(1) unsigned" required="true" defaultValue="0"/>
<column name="usr_MenuOptions" phpName="MenuOptions" type="BOOLEAN" size="1" sqlType="tinyint(1) unsigned" required="true" defaultValue="0"/>
<column name="usr_ManageGroups" phpName="ManageGroups" type="BOOLEAN" size="1" sqlType="tinyint(1) unsigned" required="true" defaultValue="0"/>
<column name="usr_Finance" phpName="Finance" type="BOOLEAN" size="1" sqlType="tinyint(1) unsigned" required="true" defaultValue="0"/>
<column name="usr_Notes" phpName="Notes" type="BOOLEAN" size="1" sqlType="tinyint(1) unsigned" required="true" defaultValue="0"/>
<column name="usr_Admin" phpName="Admin" type="BOOLEAN" size="1" sqlType="tinyint(1) unsigned" required="true" defaultValue="0"/>
<column name="usr_SearchLimit" phpName="SearchLimit" type="TINYINT" defaultValue="10"/>
<column name="usr_Style" phpName="Style" type="VARCHAR" size="50" defaultValue="Style.css"/>
<column name="usr_showPledges" phpName="ShowPledges" type="BOOLEAN" size="1" required="true" defaultValue="false"/>
Expand All @@ -631,7 +628,7 @@
<column name="usr_defaultFY" phpName="DefaultFY" type="SMALLINT" size="9" required="true" defaultValue="10"/>
<column name="usr_currentDeposit" phpName="CurrentDeposit" type="SMALLINT" size="9" required="true" defaultValue="0"/>
<column name="usr_UserName" phpName="UserName" type="VARCHAR" size="32"/>
<column name="usr_EditSelf" phpName="EditSelf" type="TINYINT" size="3" sqlType="tinyint(3) unsigned" required="true" defaultValue="0"/>
<column name="usr_EditSelf" phpName="EditSelf" type="BOOLEAN" size="1" sqlType="tinyint(1) unsigned" required="true" defaultValue="0"/>
<column name="usr_CalStart" phpName="CalStart" type="DATE"/>
<column name="usr_CalEnd" phpName="CalEnd" type="DATE"/>
<column name="usr_CalNoSchool1" phpName="CalNoSchool1" type="DATE"/>
Expand All @@ -643,7 +640,7 @@
<column name="usr_CalNoSchool7" phpName="CalNoSchool7" type="DATE"/>
<column name="usr_CalNoSchool8" phpName="CalNoSchool8" type="DATE"/>
<column name="usr_SearchFamily" phpName="Searchfamily" type="TINYINT" size="3"/>
<column name="usr_Canvasser" phpName="Canvasser" type="TINYINT" size="3" required="true" defaultValue="0"/>
<column name="usr_Canvasser" phpName="Canvasser" type="BOOLEAN" size="1" required="true" defaultValue="0"/>
<index name="usr_per_ID">
<index-column name="usr_per_ID"/>
</index>
Expand Down
48 changes: 48 additions & 0 deletions src/ChurchCRM/model/ChurchCRM/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,53 @@
*/
class User extends BaseUser
{
public function getName()
{
return $this->getPerson()->getFullName();
}

public function isAddRecordsEnabled()
{
return ($this->isAdmin() ? true : $this->isAddRecords());
}

public function isEditRecordsEnabled()
{
return ($this->isAdmin() ? true : $this->isEditRecords());
}

public function isDeleteRecordsEnabled()
{
return ($this->isAdmin() ? true : $this->isDeleteRecords());
}

public function isMenuOptionsEnabled()
{
return ($this->isAdmin() ? true : $this->isMenuOptions());
}

public function isManageGroupsEnabled()
{
return ($this->isAdmin() ? true : $this->isManageGroups());
}

public function isFinanceEnabled()
{
return ($this->isAdmin() ? true : $this->isFinance());
}

public function isNotesEnabled()
{
return ($this->isAdmin() ? true : $this->isNotes());
}

public function isEditSelfEnabled()
{
return ($this->isAdmin() ? true : $this->isEditSelf());
}

public function isCanvasserEnabled()
{
return ($this->isAdmin() ? true : $this->isCanvasser());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd write all those as

return $this->isAdmin() || $this->isEditSelf();

rather than using the ternary ?: operator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}
7 changes: 5 additions & 2 deletions src/DepositSlipEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@
}

$_SESSION['iCurrentDeposit'] = $iDepositSlipID; // Probably redundant
$sSQL = "UPDATE user_usr SET usr_currentDeposit = '$iDepositSlipID' WHERE usr_per_id = \"" . $_SESSION['iUserID'] . "\"";
$rsUpdate = RunQuery($sSQL);

/* @var $currentUser \ChurchCRM\User */
$currentUser = $_SESSION['user'];
$currentUser->setCurrentDeposit($iDepositSlipID);
$currentUser->save();

require "Include/Header.php";
?>
Expand Down
7 changes: 1 addition & 6 deletions src/DonatedItemEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@
}
}

// Set Current Deposit setting for user
//if ($iCurrentFundraiser) {
// $sSQL = "UPDATE user_usr SET usr_CurrentFundraiser = '$iCurrentFundraiser' WHERE usr_per_id = \"".$_SESSION['iUserID']."\"";
// $rsUpdate = RunQuery($sSQL);
//}
//Get People for the drop-down
$sPeopleSQL = "SELECT per_ID, per_FirstName, per_LastName, fam_Address1, fam_City, fam_State FROM person_per JOIN family_fam on per_fam_id=fam_id ORDER BY per_LastName, per_FirstName";

Expand Down Expand Up @@ -310,7 +305,7 @@
</td>
</tr>
</table> <!-- Table for the whole form -->

</table>
</form>
<div>
Expand Down
48 changes: 24 additions & 24 deletions src/EmailSend.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ function ClearEmailLog()
") ENGINE=MyISAM";
RunQuery($sSQL);

$sSQL = "INSERT INTO email_job_log_$iUserID ".
"SET ejl_text='".mysql_real_escape_string($sMessage)."', ".
$sSQL = "INSERT INTO email_job_log_$iUserID ".
"SET ejl_text='".mysql_real_escape_string($sMessage)."', ".
" ejl_time='$tSec', ".
" ejl_usec='$tUsec'";

Expand All @@ -85,8 +85,8 @@ function AddToEmailLog($sMessage, $iUserID)
$tSec = $tSystem['sec'];
$tUsec = str_pad($tSystem['usec'], 6, '0');

$sSQL = "INSERT INTO email_job_log_$iUserID ".
"SET ejl_text='".mysql_real_escape_string($sMessage)."', ".
$sSQL = "INSERT INTO email_job_log_$iUserID ".
"SET ejl_text='".mysql_real_escape_string($sMessage)."', ".
" ejl_time='$tSec', ".
" ejl_usec='$tUsec'";

Expand Down Expand Up @@ -123,8 +123,8 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)
$sSQL = 'SELECT * FROM email_message_pending_emp';
extract(mysql_fetch_array(RunQuery($sSQL)));

// Keep track of how long this script has been running. To avoid server
// and browser timeouts break out of loop every $sLoopTimeout seconds and
// Keep track of how long this script has been running. To avoid server
// and browser timeouts break out of loop every $sLoopTimeout seconds and
// redirect back to EmailSend.php with meta refresh until finished.
$tStartTime = time();

Expand All @@ -139,7 +139,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)

$mail->From = $sFromEmailAddress; // From email address (User Settings)
$mail->FromName = $sFromName; // From name (User Settings)

if ($hasAttach)
$mail->AddAttachment ("tmp_attach/".$attachName);

Expand All @@ -159,7 +159,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)
$sSMTPPort = 25; // Default port number
} else {
$sSMTPPort = substr($sSMTPHost, $delimeter+1);
$sSMTPHost = substr($sSMTPHost, 0, $delimeter);
$sSMTPHost = substr($sSMTPHost, 0, $delimeter);
}

if (is_int($sSMTPPort))
Expand All @@ -174,12 +174,12 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)

$bContinue = TRUE;
$sLoopTimeout = 30; // Break out of loop if this time is exceeded
$iMaxAttempts = 3; // Error out if an email address fails 3 times
while ($bContinue)
$iMaxAttempts = 3; // Error out if an email address fails 3 times
while ($bContinue)
{ // Three ways to get out of this loop
// 1. We're finished sending email
// 2. Time exceeds $sLoopTimeout
// 3. Something strange happens
// 3. Something strange happens
// (maybe user tries to send from multiple sessions
// causing counts and timestamps to 'misbehave' )

Expand Down Expand Up @@ -293,7 +293,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)

if (!$bTableExists) {
// Create a new empty log, this might be cruft
ClearEmailLog();
ClearEmailLog();
}

if (array_key_exists ('resume', $_POST) && $_POST['resume'] == 'true') {
Expand Down Expand Up @@ -396,7 +396,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)
extract(mysql_fetch_array(RunQuery($sSQL_EMP)));

if ($emp_to_send==0 && $countrecipients==0) {
// If both are zero the email job has not started yet.
// If both are zero the email job has not started yet.
// Begin by loading the list of recipients into MySQL.
ClearEmailLog(); // Initialize Log
$_SESSION['sEmailState'] = 'start';
Expand All @@ -407,22 +407,22 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)

$sMsg = 'Error, cannot start. email_array is not an array';
echo "<br>$sMsg<br>";
AddToEmailLog($sMsg, $iUserID);
AddToEmailLog($sMsg, $iUserID);
$_SESSION['sEmailState'] = 'error';
}

if ( !count($email_array) ) {

$sMsg = 'Error, cannot start. email_array is empty';
echo "<br>$sMsg<br>";
AddToEmailLog($sMsg, $iUserID);
$_SESSION['sEmailState'] = 'error';
AddToEmailLog($sMsg, $iUserID);
$_SESSION['sEmailState'] = 'error';
}

if ($_SESSION['sEmailState'] == 'start') {

foreach($email_array as $email_address) {

$iEmailNum++;
// Load MySQL with the list of addresses to be sent
$sSQL = 'INSERT INTO email_recipient_pending_erp '.
Expand Down Expand Up @@ -461,7 +461,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)
}

} else {

// Should only get here if we are about to finish by sending the final email
if ($_SESSION['sEmailState'] != 'finish') {
$sMsg = 'Error on line '.__LINE__.' of file '.__FILE__;
Expand All @@ -487,7 +487,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)
}

// Set a Meta Refresh in the header so this page automatically reloads
if ($bMetaRefresh) {
if ($bMetaRefresh) {
$sMetaRefresh = '<meta http-equiv="refresh" content="2;URL=EmailSend.php">'."\n";
}

Expand Down Expand Up @@ -531,7 +531,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)
$sMessage = $emp_message;
$attachName = $emp_attach_name;
$hasAttach = $emp_attach;


// There must be more than one recipient
if ($countrecipients) {
Expand All @@ -554,7 +554,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)
$sSubject = "Email job started at $tTimeStamp";

$sMessage = "Email job issued by ";
$sMessage .= $_SESSION['UserFirstName'].' '.$_SESSION['UserLastName'];
$sMessage .= $_SESSION['user']->getName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

$sMessage .= " using:\n";
$sMessage .= "From Name = $sFromName\n";
$sMessage .= "From Address = $sFromEmailAddress\n";
Expand Down Expand Up @@ -605,7 +605,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)
$sSubject = "Email job finished at $tTimeStamp";

$sMessage = "Email job issued by ";
$sMessage .= $_SESSION['UserFirstName'].' '.$_SESSION['UserLastName'];
$sMessage .= $_SESSION['user']->getName();
$sMessage .= " using:\n";
$sMessage .= "From Name = $sFromName\n";
$sMessage .= "From Address = $sFromEmailAddress\n";
Expand All @@ -616,7 +616,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)

if (strlen($emp_attach_name)>0) // delete the attached file if there is one
unlink ("tmp_attach/".$emp_attach_name);

// $sMessage .= "Email sent to $emp_num_sent email addresses.\n"; // $emp_num_sent not a field in email_message_pending_emp
$sMessage .= "Email job finished at $tTimeStamp\n\n";
$sMessage .= "Email job log:\n\n";
Expand Down Expand Up @@ -681,7 +681,7 @@ function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)
$sSubject = "Email job terminated due to error at $tTimeStamp";

$sMessage = "Email job issued by ";
$sMessage .= $_SESSION['UserFirstName'].' '.$_SESSION['UserLastName'];
$sMessage .= $_SESSION['user']->getName();
$sMessage .= " using:\n";
$sMessage .= "From Name = $sFromName\n";
$sMessage .= "From Address = $sFromEmailAddress\n";
Expand Down
8 changes: 5 additions & 3 deletions src/FindFundRaiser.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@
// Save record limit if changed
if (isset($_GET["Number"]))
{
$_SESSION['SearchLimit'] = FilterInput($_GET["Number"],'int');
$uSQL = "UPDATE user_usr SET usr_SearchLimit = " . $_SESSION['SearchLimit'] . " WHERE usr_per_ID = " . $_SESSION['iUserID'];
$rsUser = RunQuery($uSQL);
/* @var $currentUser \ChurchCRM\User */
$currentUser = $_SESSION['user'];
$currentUser->setSearchLimit(FilterInput($_GET["Number"],'int'));
$currentUser->save();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

$_SESSION['SearchLimit'] = $currentUser->getSearchLimit();
}

// Select the proper sort SQL
Expand Down
2 changes: 0 additions & 2 deletions src/FundRaiserEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@
// Set Current Deposit setting for user
if ($iFundRaiserID > 0) {
$_SESSION['iCurrentFundraiser'] = $iFundRaiserID; // Probably redundant
// $sSQL = "UPDATE user_usr SET usr_currentDeposit = '$iFundRaiserID' WHERE usr_per_id = \"".$_SESSION['iUserID']."\"";
// $rsUpdate = RunQuery($sSQL);
}

require "Include/Header.php";
Expand Down
Loading