[Solved] Coping with loss of $gCms
Posted: Mon Jan 03, 2011 5:47 pm
EDIT: Solution is that there's no issue here in the first place! The smarty variable {$gCms} has been retired in 1.9, but the PHP variable $gCms (available in modules and UDTs) has not.
--
I'm currently using CMSMS 1.8.2 and am planning my upgrade to 1.9.2. I notice from the release notes that $gCms will no longer be accessible. My site currently relies on $gCms in 4 ways, all from within (pretty complex) UDTs. For each, what is the correct replacement code to achieve the same end?
1) Getting a page URL from the page alias
I used to use...
Without using $gCms, how can I get a page URL from its alias?
2) Testing whether the logged on user is a member of a particular group
I used to use...
Without using $gCms, how can I determine (in a UDT) if the currently logged on user is a member of a particular group?
3) Retrieving smarty variables
I used to use...
Without using $gCms, how can I get a smarty template variable? Or, if easier, how can I retrieve a particular custom field from the currently logged on user's FEU account details? (At the moment, I'm relying on the fact the all the custom properties from the user's account are copied into a smarty template variable.)
4) Screening FEU passwords against a default
Finally, without using $gCms, how can I check a user's password against a default? (We use this to force the user to change their password away from the default that we give to new accounts.)
Answers to any or all of the above would be much appreciated. (And if your solution works in 1.8.2, please mention it because it means I can change the offending code before doing the migration rather than trying to do it all at once.)
Many thanks,
Andrew
--
I'm currently using CMSMS 1.8.2 and am planning my upgrade to 1.9.2. I notice from the release notes that $gCms will no longer be accessible. My site currently relies on $gCms in 4 ways, all from within (pretty complex) UDTs. For each, what is the correct replacement code to achieve the same end?
1) Getting a page URL from the page alias
I used to use...
Code: Select all
global $gCms;
$manager = &$gCms->GetHierarchyManager();
$page_url = $manager->sureGetNodeByAlias('page-alias')->GetContent()->GetUrl();
2) Testing whether the logged on user is a member of a particular group
I used to use...
Code: Select all
global $gCms;
$modFEU = $gCms->modules['FrontEndUsers']['object'];
$is_in_group1 = $modFEU->MemberOfGroup($modFEU->LoggedInId(),$modFEU->GetGroupID('group1'));
3) Retrieving smarty variables
I used to use...
Code: Select all
global $gCms;
$smarty = &$gCms->GetSmarty();
$our_ref = $smarty->get_template_vars('ccuser')->property('our_ref');
4) Screening FEU passwords against a default
Code: Select all
global $gCms;
$modFEU = $gCms->modules['FrontEndUsers']['object'];
$is_using_default_password = $modFEU->CheckPassword($modFEU->LoggedInName(), 'default_password');
Answers to any or all of the above would be much appreciated. (And if your solution works in 1.8.2, please mention it because it means I can change the offending code before doing the migration rather than trying to do it all at once.)
Many thanks,
Andrew