CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 CodeCharge goes Joomla

Print topic Send  topic

Author Message
Pixelmessage

Posts: 5
Posted: 09/29/2008, 1:04 PM


I've tried to translate my post in the german-ccs-forum on www.devdata.de
(http://www.devdata.de/cc/ccsforthema.php?MsgID=5813&) into english, because here are some questions concerning the connection between ccs and joomla. As I'm not a native english-speaker, I hope my tranlation is good enough to declare my way of solving this problem.

I've made several projects with CodeChargeStudio and Joomla and searched often for a solution, because it isn't comfortable to login twice. As there is no solution in CCS and Joomla forums yet, I tried to solve the problem myself. I started from an old thread in the RexDesign-forum
(http://www.rexdesign.com/ccs/kb.php?category_id=61&language_id=7&event_id=86).

Here is the solution for the newest versions of CCS 4 and Joomla 1.5.6 that should work. To embed a CCS-Project in Joomla you must call it in an iframe.

Starting point is to translate the session-variables from Joomla to CCS. Three steps are necessary:

1. Prepare security-settings in CCS - I modified it to fit to the new version of joomla)
2. add a few script-lines at the end of common.php
3. Make a small adaption in the wrapper-component of Joomla, which is responsible for the embedding of the iframe

Step 1:

I assume a ready-to-use installation of Joomla 1.5.6 an a new ccs-project. Both can be in different folders on the server as the CCS-project is only referenced in the iframe of Joomla. In the settings of the CCS-project you define the Joomla-db as project-db as the Joomla-usertable (normally 'jos_users') is taken as usertable of ccs for authentification. There are according fields in the user-table of Joomla (you can download screenshots here: http://www.pixmess.at/CCS_goes_Joomla.zip) :

UserTable = jos_users
UserID-Feld = id
Login-Field = username
Passwort-Field = password (is not in use for this approach)
Usergroup = gid

The gid-field in jos_users is important, as now there is an unique identifier for every usergroup in joomla. Set the usergroups in the ccs-settings accordingly to the joomla-usergroups:

25 = Super Administrator
24 = Administrator
23 = Manager
21 = Publisher
20 = Editor
19 = Author
18 = Registered

Now set the CCS Sessionvariable in Advanced Security Settings - but match it to Joomla (jos...):

User ID Variable = josUserID
User Login Variable = josUserLogin
Group ID Variable = josGroupID


Now step 2:
CCS has to recognize which usergroup ist logged in to Joomla. Therefore the necessary values from session-table of joomla must be read and translated to to the CCS Sessionvariables. The followings lines will do this. I add them at the end of common.php, so all CCS-pages are secured.


######################################################## Begin


global $Login;

$conn = new clsDBjoomla(); // CCS-db-connection which is the joomla-db

$sessioncookie = CCGetFromGet("sessioncookie", ""); // Get sessionvariable of Joomla-Session over the URL which passes the Joomla-Wrapper to the iframe

//Get the values out of the jos-session-table:

$session_user_id = CCDLookUp("userid","jos_session","session_id='$sessioncookie'", $conn);
$session_username = CCDLookUp("username","jos_session","session_id=' $sessioncookie'", $conn);
$session_usertype = CCDLookUp("usertype","jos_session","session_id='$sessioncookie'", $conn);
$session_usergid = CCDLookUp("gid","jos_session","session_id='$sessioncookie'", $conn);

// If there es no user logged in to Joomla, CCS-Sessionvariable are destroyed if there are some left:

if($session_usertype == "") {

CCSetSession("josGroupID", "");
CCSetSession("josUserID", "");
CCSetSession("josUserLogin", "");
}

// otherwise the current user is logged in and the Joomla-values are assigned to the CCS-sessionvariables:

else {

CCSetSession("josUserID", $session_user_id);
CCSetSession("josUserLogin", $session_username);
CCSetSession("josGroupID", $session_usergid);




//that's it!

################################################################## End



Step 3:
There is only the last step left to pass the specific session-variable of Joomla to the iframe to send it to the script above.

The new concept of "Template Overrides" in Joomla 1.5.x makes it easy and there is no hack in the Joomla-core necessary. I assume knowledge about this concept, otherwise there is lot of information on the joomla-websites. You make a file in your joomla-templatey directory which should be:

your_joomla_template/html/com_wrapper/wrapper/default.php to override the core-wrapper-component.

At the beginning of the source-code - right after the default "no direct access"- lines copy this:

#################

$session =& JFactory::getSession();
$sid = $session->getId();

###################

This passes the current joomla-sessionvariable to the variable $id through joomlaspecific functions. $id must now be added to the url, which calls the iframe in Joomla-framework - to be found a litte bit below:


src="<?php echo $this->wrapper->url; ?>"

is modified to:

src="<?php echo $this->wrapper->url."?sessioncookie=$sid"; ?>"



Passing a sessionvariable to the iframe doesn't work in the Joomla-Framework - I don't know why. I get the error "Notice: Undefined index: sessioncookie in ..... " - sessioncookie as sessionvariable is not recognized by the iframe. url works!

It's done! Now embed pages from your CCS-project in Joomla with the wrapper-component, set security-settings for each ccs-page, define a "access-denied"-page und you will see: access to the CCS-pages is allowed or restricted matching to the access authorisation which has the current joomla-user. As soon as I have a little bit more time I will post an example here.

I hope, this solution is useful for all, who work with CodeChargeStudio and Joomla. If there are more simple solutions, please let me know.

best regards
Peter

View profile  Send private message
Waspman

Posts: 948
Posted: 09/29/2008, 1:30 PM

Peter...YOU ARE A STAR!!!!!


I'm just had an enquiry to embed an CCS asset management system into Joomla and this is perfect.


Thank you...


Tony
_________________
http://www.waspmedia.co.uk
View profile  Send private message
Jan K. van Dalen
Posted: 09/30/2008, 7:13 AM

This is great ..... thank you.

"Pixelmessage" <Pixelmessage@forum.codecharge> wrote in message
news:2548e134b90557c@news.codecharge.com...
>
> I've tried to translate my post in the german-ccs-forum on www.devdata.de
> (http://www.devdata.de/cc/ccsforthema.php?MsgID=5813&) into english,
> because
> here are some questions concerning the connection between ccs and joomla.
> As I'm
> not a native english-speaker, I hope my tranlation is good enough to
> declare my
> way of solving this problem.
>
> I've made several projects with CodeChargeStudio and Joomla and searched
> often
> for a solution, because it isn't comfortable to login twice. As there is
> no
> solution in CCS and Joomla forums yet, I tried to solve the problem
> myself. I
> started from an old thread in the RexDesign-forum
> (http://www.rexdesign.com/ccs/kb.php?category_id=61&language_id=7&event_id=86).
>
> Here is the solution for the newest versions of CCS 4 and Joomla 1.5.6
> that
> should work. To embed a CCS-Project in Joomla you must call it in an
> iframe.
>
> Starting point is to translate the session-variables from Joomla to CCS.
> Three
> steps are necessary:
>
> 1. Prepare security-settings in CCS - I modified it to fit to the new
> version
> of joomla)
> 2. add a few script-lines at the end of common.php
> 3. Make a small adaption in the wrapper-component of Joomla, which is
> responsible for the embedding of the iframe
>
> Step 1:
>
> I assume a ready-to-use installation of Joomla 1.5.6 an a new ccs-project.
> Both
> can be in different folders on the server as the CCS-project is only
> referenced
> in the iframe of Joomla. In the settings of the CCS-project you define the
> Joomla-db as project-db as the Joomla-usertable (normally 'jos_users') is
> taken
> as usertable of ccs for authentification. There are according fields in
> the
> user-table of Joomla (you can download screenshots here:
> http://www.pixmess.at/CCS_goes_Joomla.zip) :
>
> UserTable = jos_users
> UserID-Feld = id
> Login-Field = username
> Passwort-Field = password (is not in use for this approach)
> Usergroup = gid
>
> The gid-field in jos_users is important, as now there is an unique
> identifier
> for every usergroup in joomla. Set the usergroups in the ccs-settings
> accordingly to the joomla-usergroups:
>
> 25 = Super Administrator
> 24 = Administrator
> 23 = Manager
> 21 = Publisher
> 20 = Editor
> 19 = Author
> 18 = Registered
>
> Now set the CCS Sessionvariable in Advanced Security Settings - but match
> it to
> Joomla (jos...):
>
> User ID Variable = josUserID
> User Login Variable = josUserLogin
> Group ID Variable = josGroupID
>
>
> Now step 2:
> CCS has to recognize which usergroup ist logged in to Joomla. Therefore
> the
> necessary values from session-table of joomla must be read and translated
> to to
> the CCS Sessionvariables. The followings lines will do this. I add them at
> the
> end of common.php, so all CCS-pages are secured.
>
>
> ######################################################## Begin
>
>
> global $Login;
>
> $conn = new clsDBjoomla(); // CCS-db-connection which is the joomla-db
>
> $sessioncookie = CCGetFromGet("sessioncookie", ""); // Get
> sessionvariable of
> Joomla-Session over the URL which passes the Joomla-Wrapper to the iframe
>
> //Get the values out of the jos-session-table:
>
> $session_user_id =
> CCDLookUp("userid","jos_session","session_id='$sessioncookie'", $conn);
> $session_username = CCDLookUp("username","jos_session","session_id='
> $sessioncookie'", $conn);
> $session_usertype =
> CCDLookUp("usertype","jos_session","session_id='$sessioncookie'", $conn);
> $session_usergid =
> CCDLookUp("gid","jos_session","session_id='$sessioncookie'",
> $conn);
>
> // If there es no user logged in to Joomla, CCS-Sessionvariable are
> destroyed
> if there are some left:
>
> if($session_usertype == "") {
>
> CCSetSession("josGroupID", "");
> CCSetSession("josUserID", "");
> CCSetSession("josUserLogin", "");
> }
>
> // otherwise the current user is logged in and the Joomla-values are
> assigned
> to the CCS-sessionvariables:
>
> else {
>
> CCSetSession("josUserID", $session_user_id);
> CCSetSession("josUserLogin", $session_username);
> CCSetSession("josGroupID", $session_usergid);
>
>
>
>
> //that's it!
>
> ################################################################## End
>
>
>
> Step 3:
> There is only the last step left to pass the specific session-variable of
> Joomla to the iframe to send it to the script above.
>
> The new concept of "Template Overrides" in Joomla 1.5.x makes it easy and
> there
> is no hack in the Joomla-core necessary. I assume knowledge about this
> concept,
> otherwise there is lot of information on the joomla-websites. You make a
> file in
> your joomla-templatey directory which should be:
>
> your_joomla_template/html/com_wrapper/wrapper/default.php to override the
> core-wrapper-component.
>
> At the beginning of the source-code - right after the default "no direct
> access"- lines copy this:
>
> #################
>
> $session =& JFactory::getSession();
> $sid = $session->getId();
>
> ###################
>
> This passes the current joomla-sessionvariable to the variable $id through
> joomlaspecific functions. $id must now be added to the url, which calls
> the
> iframe in Joomla-framework - to be found a litte bit below:
>
>
> src="<?php echo $this->wrapper->url; ?>"
>
> is modified to:
>
> src="<?php echo $this->wrapper->url."?sessioncookie=$sid"; ?>"
>
>
>
> Passing a sessionvariable to the iframe doesn't work in the
> Joomla-Framework -
> I don't know why. I get the error "Notice: Undefined index: sessioncookie
> in
> .... " - sessioncookie as sessionvariable is not recognized by the iframe.
> url
> works!
>
> It's done! Now embed pages from your CCS-project in Joomla with the
> wrapper-component, set security-settings for each ccs-page, define a
> "access-denied"-page und you will see: access to the CCS-pages is allowed
> or
> restricted matching to the access authorisation which has the current
> joomla-user. As soon as I have a little bit more time I will post an
> example
> here.
>
> I hope, this solution is useful for all, who work with CodeChargeStudio
> and
> Joomla. If there are more simple solutions, please let me know.
>
> best regards
> Peter
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
Waspman

Posts: 948
Posted: 10/02/2008, 11:27 AM

I'm working with Joomla 1.0 so here's my lazy way to get the userID

Found this...Added a bit of code to wrapper.php...makes the userID catchable - atleast in IE:-)

~~~
function showWrap( $option ) {
global $database, $Itemid, $mainframe, $my; // Modified 18-01-2006 to put UserID in session variable

// Added this next line
$_SESSION['uid'] = $my->id;

$menu = new mosMenu( $database );

etc...

I can now catch the userID and do what I like with it, brill!


T
_________________
http://www.waspmedia.co.uk
View profile  Send private message
ColinA

Posts: 9
Posted: 10/06/2008, 6:00 PM

Great work well done. I used german\english translator software recommended by Support which was good but your English translation is better (actually your english is better than many native speakers).

I have found it easy to connect to the Joomla database and use jos_users for authentication but have not yet tried to use the wrapper.
_________________
Col
View profile  Send private message
Pixelmessage

Posts: 5
Posted: 10/07/2008, 12:55 AM

Glad, I could help!

Peter
View profile  Send private message
optron


Posts: 114
Posted: 02/10/2009, 11:02 PM

I wonder if anybody has got this procedure to work, as it doesn't work for me.
I would be really nice to see real example that we could test.

Arthur

_________________
==============================
don't forget to check: www.youngliving.us
use: 739947 to register
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.