markscarts Posted September 15, 2012 Share Posted September 15, 2012 In the php file, for example, modules/plugins/example/admin/index.inc.php I need to access some store config settings. For instance, in CC4 I could simply use $config['masterEmail'] to represent the store's email setting. I am wondering how I might access that data in CC5? Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted September 16, 2012 Share Posted September 16, 2012 Have you looked in the various default plugins to see how CC handled it in the various pluginname.class,php files? Maybe that would give you some ideas. Quote Link to comment Share on other sites More sharing options...
bsmither Posted September 16, 2012 Share Posted September 16, 2012 All the store's settings are found at: $GLOBALS['config']->get(config_name, element) where config_name is the major group, kind of like a namespace ('config' for the store's settings, and others like 'gift_certs', 'Contact_Form', 'Free-Shipping', and whatever $variable for the name of the module in play that the module handler is handling, etc) and element, which is optional, is the key into the first dimension of the array. If element is not present, the whole namespace is retrieved. As best I can tell, this is limited to one dimension. The config class does not have the magic getter and setter functions. So this will not work: $GLOBALS['config']->namespace['keyname'], although I know that one of the classes does have these magic functions (Language, I think). There are the companion ->set(), ->merge(), ->has(), and isEmpty(). Once the configuration values have been retrieved from a config xml file, or entered/edited on a form, they are saved to the CC_config database table. The metadata about the module is saved in the CC_modules table. If there is a database record for the 'namespace', ->get() will fetch it if it's not already loaded into memory. ->set() will put the array to the database when PHP is shutting down. The settings are stored in base64 encoded, json format. The config class is instantiated early in CubeCart's awakening cycle, so it should be available from wherever you are. But, during shut-down, there is no guarantee it will still be available at any particular point in time. If that's the case and you get errors of calls to methods of undefined objects, you will need to use: Config::getInstance()->set(args). To see all the Config stuff that is available to the skin, open controller.index.inc.php for editing at the bottom, just before offline();, add: if( $GLOBALS['session']->has('super_user', 'admin_data') ) Smarty_Internal_Debug::display_debug($GLOBALS['smarty']); An admin designated as 'Super User' must be logged in to the admin side, then viewing the store front. In this case, there will be a popup containing all the stuff the skins can use. Quote Link to comment Share on other sites More sharing options...
markscarts Posted September 16, 2012 Author Share Posted September 16, 2012 @Dirty Butter, yes I am busy perusing the stock CubeCart files, I haven't found an instance where the store email address is retrieved yet. @bsmithers, thank you I was hoping you might shed some light. Also, thanks for the tip on showing smarty globals. Presently, I am looking to retrieve a config value for store email for use in a php file as mentioned previously, and it won't be used in the template. You've given me some help with the discussion already, maybe I can figure out how to do this. Quote Link to comment Share on other sites More sharing options...
bsmither Posted September 16, 2012 Share Posted September 16, 2012 If this is the email address found on the Advanced tab of the Store Settings, it is: $GLOBALS['config']->get('config', 'email_name') $GLOBALS['config']->get('config', 'email_address') The Mailer class is one such class that uses this. Each administrator has their own email address as well and is available when signed in. So, if a module is doing some admin work and the result of that work needs to be sent to that admin or to someone else from that admin, use: $GLOBALS['session']->get('email', 'admin_data') Quote Link to comment Share on other sites More sharing options...
markscarts Posted September 16, 2012 Author Share Posted September 16, 2012 Exactly right, mailer class is where I should have been looking. Module makes a db update and emails results. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted September 16, 2012 Share Posted September 16, 2012 Glad Bsmither could help - didn't notice who was asking when I stuck my 2 cents in - or I would have realized you had already checked the default plugins for clues. I'll rename this thread as Resolved when you're ready. For some reason the owner of the thread can't do that here, the way you can on the 3rd party forum. Quote Link to comment Share on other sites More sharing options...
markscarts Posted September 17, 2012 Author Share Posted September 17, 2012 Thanks Dirty Butter, you can mark it resolved. I am way behind on CC5 and finding my way around a bit, I had not been very active in this forum since the days of CC3. Brian has been and is a blessing to the community, very knowledgeable and very helpful, I appreciate you guys and your service to the community has been awesome. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.