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

User/Nav/Session Cleanup #1377

merged 24 commits into from
Nov 22, 2016

Conversation

DawoudIO
Copy link
Contributor

@DawoudIO DawoudIO commented Nov 16, 2016

closes #1112 #1315 #1378
started #947

  • updated user object boolean types
  • removed unused use columns
  • added user object to session
  • add user object name.
  • moved admin menu to right nav
  • moved cvs export to right nav
  • moved properties to right nav

- updated user object boolean types
- removed unused columns
- added user object to session
- add user object name.
@DawoudIO
Copy link
Contributor Author

image

image

@DawoudIO DawoudIO closed this Nov 16, 2016
@DawoudIO DawoudIO reopened this Nov 16, 2016
@crossan007
Copy link
Contributor

Why is the "logoff / Poweroff" icon highlighted? Is that how you get to this side menu?

@@ -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

@@ -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

/* @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_var_in_uri, url_parm_name, security_grp
FROM menuconfig_mcf
WHERE parent = '$menu' AND active=1 " . $security_matrix . "
$query = "SELECT name, ismenu, content, uri, statustext, session_var, session_var_in_text,
Copy link
Contributor

Choose a reason for hiding this comment

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

can we ORM this?

Copy link
Contributor Author

@DawoudIO DawoudIO Nov 18, 2016

Choose a reason for hiding this comment

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

MVP :) but Yes we can

Header_modals();
Header_body_scripts();

$loggedInUserPhoto = $sRootPath . "/api/persons/" . $_SESSION['iUserID'] . "/photo";
Copy link
Contributor

Choose a reason for hiding this comment

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

would it make sense to have a getUserPhoto(); function for cleaner re-use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this will help with page load time as there is another thread doing the lookup

$_SESSION['bFinance'] = $currentUser->isFinanceEnabled();
$_SESSION['bNotes'] = $currentUser->isNotesEnabled();
$_SESSION['bEditSelf'] = $currentUser->isEditSelfEnabled();
$_SESSION['bCanvasser'] = $currentUser->isCanvasserEnabled();
Copy link
Contributor

Choose a reason for hiding this comment

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

eventually I see us moving away from session variables specific to the permission.....but that's probably not for a while.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like this cleanup for now.

@@ -134,28 +132,28 @@

if ($undupCount == 0) {
$sPasswordHashSha256 = hash ("sha256", $sDefault_Pass.$iPersonID);
$sSQL = "INSERT INTO user_usr (usr_per_ID, usr_Password, usr_NeedPasswordChange, usr_LastLogin, usr_AddRecords, usr_EditRecords, usr_DeleteRecords, usr_MenuOptions, usr_ManageGroups, usr_Finance, usr_Notes, usr_Communication, usr_Admin, usr_Style, usr_SearchLimit, usr_defaultFY, usr_UserName, usr_EditSelf, usr_Canvasser) VALUES (" . $iPersonID . ",'" . $sPasswordHashSha256 . "',1,'" . date("Y-m-d H:i:s") . "', " . $AddRecords . ", " . $EditRecords . ", " . $DeleteRecords . ", " . $MenuOptions . ", " . $ManageGroups . ", " . $Finance . ", " . $Notes . ", " . $Communication . ", " . $Admin . ", '" . $Style . "', 10," . $defaultFY . ",\"" . $sUserName . "\"," . $EditSelf . "," . $Canvasser . ")";
$sSQL = "INSERT INTO user_usr (usr_per_ID, usr_Password, usr_NeedPasswordChange, usr_LastLogin, usr_AddRecords, usr_EditRecords, usr_DeleteRecords, usr_MenuOptions, usr_ManageGroups, usr_Finance, usr_Notes, usr_Admin, usr_Style, usr_SearchLimit, usr_defaultFY, usr_UserName, usr_EditSelf, usr_Canvasser) VALUES (" . $iPersonID . ",'" . $sPasswordHashSha256 . "',1,'" . date("Y-m-d H:i:s") . "', " . $AddRecords . ", " . $EditRecords . ", " . $DeleteRecords . ", " . $MenuOptions . ", " . $ManageGroups . ", " . $Finance . ", " . $Notes . ", " . $Admin . ", '" . $Style . "', 10," . $defaultFY . ",\"" . $sUserName . "\"," . $EditSelf . "," . $Canvasser . ")";
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we can ORM this now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I'll be working on user ORM in another branch

if ($undupCount == 0) {
$sSQL = "UPDATE user_usr SET usr_AddRecords = " . $AddRecords . ", usr_EditRecords = " . $EditRecords . ", usr_DeleteRecords = " . $DeleteRecords . ", usr_MenuOptions = " . $MenuOptions . ", usr_ManageGroups = " . $ManageGroups . ", usr_Finance = " . $Finance . ", usr_Notes = " . $Notes . ", usr_Communication = " . $Communication . ", usr_Admin = " . $Admin . ", usr_Style = \"" . $Style . "\", usr_UserName = \"" . $sUserName . "\", usr_EditSelf = \"" . $EditSelf . "\", usr_Canvasser = " . $Canvasser . " WHERE usr_per_ID = " . $iPersonID;
$sSQL = "UPDATE user_usr SET usr_AddRecords = " . $AddRecords . ", usr_EditRecords = " . $EditRecords . ", usr_DeleteRecords = " . $DeleteRecords . ", usr_MenuOptions = " . $MenuOptions . ", usr_ManageGroups = " . $ManageGroups . ", usr_Finance = " . $Finance . ", usr_Notes = " . $Notes . ", usr_Admin = " . $Admin . ", usr_Style = \"" . $Style . "\", usr_UserName = \"" . $sUserName . "\", usr_EditSelf = \"" . $EditSelf . "\", usr_Canvasser = " . $Canvasser . " WHERE usr_per_ID = " . $iPersonID;
Copy link
Contributor

Choose a reason for hiding this comment

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

ORM?

@@ -1242,30 +1238,27 @@ INSERT INTO `userconfig_ucfg` (`ucfg_per_id`, `ucfg_id`, `ucfg_name`, `ucfg_valu
CREATE TABLE `user_usr` (
`usr_per_ID` mediumint(9) unsigned NOT NULL default '0',
`usr_Password` varchar(500) NOT NULL default '',
`usr_NeedPasswordChange` tinyint(3) unsigned NOT NULL default '1',
`usr_NeedPasswordChange` tinyint(1) unsigned NOT NULL default '1',
Copy link
Contributor

Choose a reason for hiding this comment

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

You got it - 1 here - but 3 in schema.xml ;-)

`usr_SearchLimit` tinyint(4) default '10',
`usr_Style` varchar(50) default 'Style.css',
`usr_showPledges` tinyint(1) NOT NULL default '0',
`usr_showPayments` tinyint(1) NOT NULL default '0',
`usr_showSince` date NOT NULL default '0000-00-00',
`usr_defaultFY` mediumint(9) NOT NULL default '10',
`usr_currentDeposit` mediumint(9) NOT NULL default '0',
`usr_UserName` varchar(32) default NULL,
`usr_EditSelf` tinyint(3) unsigned NOT NULL default '0',
`usr_UserName` varchar(50) default NULL,
Copy link
Contributor

Choose a reason for hiding this comment

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

It's 50 here, but only 32 in the schema.xml model definition

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 find

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


ALTER TABLE `user_usr`
CHANGE COLUMN `usr_NeedPasswordChange` `usr_NeedPasswordChange` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '' ,
CHANGE COLUMN `usr_UserName` `usr_UserName` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL COMMENT '',
Copy link
Contributor

Choose a reason for hiding this comment

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

It's 50 here, but only 32 in the schema.xml model definition

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

$.ajax({
url: window.CRM.root + "/api/timerjobs/run",
type: "POST"
});
$(".date-picker").datepicker({format:'yyyy-mm-dd', language: window.CRM.lang});
});

function showGlobalMessage(message, callOutClass) {
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm......Interesting idea.


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

@DawoudIO
Copy link
Contributor Author

DawoudIO commented Nov 19, 2016

need to move the following links to the Right Nav also

@crossan007 crossan007 merged commit de9ab63 into develop Nov 22, 2016
@crossan007 crossan007 deleted the right-nav-v1 branch November 22, 2016 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants