[Solved] Coping with loss of $gCms

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
arr28
Forum Members
Forum Members
Posts: 17
Joined: Thu Sep 10, 2009 7:46 am

[Solved] Coping with loss of $gCms

Post by arr28 »

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

Code: Select all

global $gCms;
$manager = &$gCms->GetHierarchyManager();
$page_url = $manager->sureGetNodeByAlias('page-alias')->GetContent()->GetUrl();
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...

Code: Select all

global $gCms;
$modFEU = $gCms->modules['FrontEndUsers']['object'];
$is_in_group1 = $modFEU->MemberOfGroup($modFEU->LoggedInId(),$modFEU->GetGroupID('group1'));
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...

Code: Select all

global $gCms;
$smarty = &$gCms->GetSmarty();
$our_ref = $smarty->get_template_vars('ccuser')->property('our_ref');
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

Code: Select all

global $gCms;
$modFEU = $gCms->modules['FrontEndUsers']['object'];
$is_using_default_password = $modFEU->CheckPassword($modFEU->LoggedInName(), 'default_password');
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
Last edited by arr28 on Mon Jan 03, 2011 6:44 pm, edited 1 time in total.
Sonya

Re: Coping with loss of $gCms (upgrading from 1.8.2 to 1.9.2

Post by Sonya »

arr28 wrote: 1) Getting a page URL from the page alias

Code: Select all

global $gCms;
$manager = &$gCms->GetHierarchyManager();
$page_url = $manager->sureGetNodeByAlias('page-alias')->GetContent()->GetUrl();
Quick test of this UDT on 1.9.2 "Tevairoa" and it works. Where have you got the information that $gCms is "lost"? I cannot imagine it's true as a lot of modules rely on this variable.
Last edited by Sonya on Mon Jan 03, 2011 6:33 pm, edited 1 time in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Coping with loss of $gCms (upgrading from 1.8.2 to 1.9.2

Post by Wishbone »

According to the 1.9 announcement, the {$gCms} smarty variable has been removed. It's still available to modules. I would think it would still be available to UDTs.
Sonya

Re: Coping with loss of $gCms (upgrading from 1.8.2 to 1.9.2

Post by Sonya »

Wishbone wrote:According to the 1.9 announcement, the {$gCms} smarty variable has been removed. It's still available to modules. I would think it would still be available to UDTs.
Oh, I see. It is only about Smarty variable, it does not have any impact on PHP variable. Same name, but something completely different :)
arr28
Forum Members
Forum Members
Posts: 17
Joined: Thu Sep 10, 2009 7:46 am

Re: Coping with loss of $gCms (upgrading from 1.8.2 to 1.9.2

Post by arr28 »

Oh, I see. It is only about Smarty variable, it does not have any impact on PHP variable. Same name, but something completely different.
Many thanks for your help. I hadn't noticed the subtlety. Will press on with the upgrade and see how things go.
Locked

Return to “[locked] Installation, Setup and Upgrade”