hi krobi.
It is not so easy to explain how to use a library
gticket2 is almost the same as gticket.
- include_once it
- add hidden into your form
- add check() into your transaction
form side with XoopsForm:
$form = new XoopsThemeForm( ... );
$GLOBALS['xoopsGTicket']->addTicketXoopsFormElement( $form , __LINE__ , 1800 , '(your area name)' ) ;
form side with plain HTML:
$xoopsGTicket->getTicketHtml( __LINE__ , 1800 , '(your area name)' )
transaction side:
if ( ! $xoopsGTicket->check( true , '(your area name)' ) ) {
redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
}
If an error occurs in cheking the ticket, "repost form" is displayed automatically.
If you don't want to display "repost form", call check() like this.
if ( ! $xoopsGTicket->check( true , '(your area name)' , false ) ) {
redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
}
thank you very much for explaining.
its a great help.
your gticket works with every xoops version or do a xoops user need a specific xoops version? or does i have to look at anything when i use the gticket? (like xoops version compatibility or so on)
Quote:
krobi wrote:
your gticket works with every xoops version or do a xoops user need a specific xoops version? or does i have to look at anything when i use the gticket? (like xoops version compatibility or so on)
As gticket2 is just a ticket/token class, you -developper- can use it in your module with any version of XOOPS.
And I shall support any XOOPS from xoops.org, xoopscube.jp etc.
hi krobi.
Quote:
i'am wondering what this "'(your area name)'" exaclty do and mean.
"area" means purpose of the ticket.
eg)
Even if you buy the ticket for japan-brasil in the heat, you cannot watch the final germany-brasil
Quote:
i have tried it with and without the "'(your area name)'" and it works always.
"gticket" checks loosely like this.
deep referer ok && area ok -> ok
deep referer ok && area ng -> ok
deep referer ng && area ok -> ok
deep referer ng && area ng -> ng
Because "deep referer" and "area" have almost the same effect.
If you issue a ticket with the area of "myblocksadmin" and you check the area is "mytplsadmin", "area" will be NG.
But if you send right referer, the total result of the check will be OK.
Quote:
and i have a second question, how can a add a gticket2 to a xoops_confirm?
I don't think it is necessary to add gticket2 into xoops_confirm.
In the latest version of xoops, "xoops_confirm" has a ticket from XOOPS core.
The advantages of using gticket2 in your module:
(1) independence of core versions (XOOPS 2.0/2.2, XOOPS Cube, Oreteki, MOX etc)
(2) auto repost form
If your module have textarea for long text, (2) will be the big advantage
hey gijoe,
i have successfully added your ticket to a xoops_confirm.
its good when you have a confirm message, for deleting entries for example, here is what i have done:
you have to add a function to you gtickets.php
Quote:
// get only the form value back for example its good for using it in a xoops_confirm -> Done by PD Coding Team
function getTicketHTMLValue ( $salt = '' , $timeout = 1800 , $area = '' )
{
return $this->issue( $salt , $timeout , $area ) ;
}
then you can make a xoops_confirm message like this:
Quote:
xoops_confirm(array('XOOPS_G_TICKET' => $xoopsGTicket->getTicketHTMLValue(__LINE__ , 1800 , '(your area name)')), 'index.php', _AM_PDD_FILE_REALLYDELETEDTHIS . "message", _DELETE, false);
hi krobi.
You can find existet codes in myblocksadmin.php etc.
xoops_confirm( array( 'op' => 'delete_ok' ) + $GLOBALS['xoopsGTicket']->getTicketArray( __LINE__ , 1800 , 'myblocksadmin' ) , (action) , (message) ) ;
Operator '+' is useful for array in this situation.