-
Notifications
You must be signed in to change notification settings - Fork 443
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
User/Nav/Session Cleanup #1377
Changes from 13 commits
813331d
be6544f
c338bba
867db65
2fcaa53
e76e9fb
d7c66ee
4f8c17c
4717846
a51dffd
43c8b85
97ec153
b021b69
cfd0a3b
b4471e9
c94e37a
ea4dc57
f080f09
1696182
46034d1
dd47764
73d74ae
f1d0ed8
d9064b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd write all those as
rather than using the ternary ?: operator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'"; | ||
|
||
|
@@ -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'"; | ||
|
||
|
@@ -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(); | ||
|
||
|
@@ -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); | ||
|
||
|
@@ -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)) | ||
|
@@ -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' ) | ||
|
||
|
@@ -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') { | ||
|
@@ -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'; | ||
|
@@ -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 '. | ||
|
@@ -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__; | ||
|
@@ -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"; | ||
} | ||
|
||
|
@@ -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) { | ||
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"; | ||
|
@@ -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"; | ||
|
@@ -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"; | ||
|
@@ -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"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
$_SESSION['SearchLimit'] = $currentUser->getSearchLimit(); | ||
} | ||
|
||
// Select the proper sort SQL | ||
|
There was a problem hiding this comment.
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?! :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed