Re: [xwiki-users] passing POST query string

2011-05-18 Thread China Sunrise
Thank you both for the quick response! Will shift to getParameterValues()
and give it a try.



On Wed, May 18, 2011 at 9:33 PM, Sergiu Dumitriu  wrote:

> On 05/19/2011 01:35 AM, Caleb James DeLisle wrote:
> > The query string is literally the string which follows the ? in the url.
> When you are posting you
> > are not using the query string but instead you are encoding the data in
> the body of the post which
> > is why it can hold more data.
> >
> > Instead of using getQueryString() then looking for the pieces of that you
> can use
> > getParameter('name') and it will return the value given with that name
> and you won't even have to
> > URL decode it.
>
> getParameter returns a single value for a parameter.
> getParameterValues('name') returns all the values sent for a parameter.
> This is useful, for example, for  elements with multi-select
> enabled.
> getParameterMap returns a map of all the parameters and their values.
>
> If you want to manually process the POST body, you should use
> getInputStream (byte reading) or getReader (character reading, using the
> system's default encoding). But it's really better to use getParameter,
> which will look both in the POST body and the GET query string.
>
> More information about the request object here:
>
> http://download.oracle.com/javaee/5/api/javax/servlet/http/HttpServletRequest.html
>
> If you want to handle file uploads, then you should look at the
> FileUpload plugin:
>
> https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/plugin/fileupload/FileUploadPluginApi.java
>
> >
> > On 05/18/2011 05:50 PM, China Sunrise wrote:
> >> Hi,
> >> My xwiki 3.0 implementation is using PHP in many pages, and some pages
> are
> >> based on simple HTML forms with a "submit" button. In the PHP part, I
> >> process $request->getQueryString() to check the form fields that were
> sent.
> >> It works very well when the form used the GET method, but doesn't work
> at
> >> all when the form used the POST method. Doing some research, it looks
> like
> >> the getQueryString() method should handle both scenarios but it doesn't,
> so
> >> I wonder if there is anything else blocking the POST data at a lower
> level.
> >>
> >> I also did the same test not inside PHP and run into the same issue, so
> it
> >> does not look to be PHP-related.
> >>
> >> Unfortunately this is becoming critical as GET data size is limited and
> I
> >> start running into this limit on some forms, so have to move to POST.
>
> --
> Sergiu Dumitriu
> http://purl.org/net/sergiu/
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] passing POST query string

2011-05-18 Thread China Sunrise
Hi,
My xwiki 3.0 implementation is using PHP in many pages, and some pages are
based on simple HTML forms with a "submit" button. In the PHP part, I
process $request->getQueryString() to check the form fields that were sent.
It works very well when the form used the GET method, but doesn't work at
all when the form used the POST method. Doing some research, it looks like
the getQueryString() method should handle both scenarios but it doesn't, so
I wonder if there is anything else blocking the POST data at a lower level.

I also did the same test not inside PHP and run into the same issue, so it
does not look to be PHP-related.

Unfortunately this is becoming critical as GET data size is limited and I
start running into this limit on some forms, so have to move to POST.

Thanks
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] stopping a page for non-editors

2011-04-07 Thread China Sunrise
Hi,
Thanks for all the responses. Here are some results after testing the
suggestions:
* When I simply remove the #stop directive, I no longer get exceptions, but
also I don't get the page to block. Without the #stop, the velocity part
simply ends and it continues to the PHP part with no interruption and so the
page is shown normally. This solution is therefore not going to work in this
case.
* Nesting a PHP script inside a velocity script is not accepted, so this
solution will also not work here.
* I could use the native page access control, but it's somewhat of an
overhead as the pages in question are in different spaces and I would need
to go page by page to set the proper permissions. I realize that this may be
the more "correct" approach but it still appears to be easier for me to do
it at the code level - sort of 'do once and never worry about anything
else later'.

Anyway, following Raluca's advice I've opened a minor JIRA XE-887 about the
#stop excepetion issue, and what I ended up doing for now is the following,
which simply redirects to an error page. For my current needs this is good
enough, and eventually when the #stop directive will be supported again I'll
shift back to it.

{{velocity}}
#set($user=$xwiki.getUser())
#if(!$user.isUserInGroup("XWiki.XWikiEditorsGroup"))
  {{warning}}You don't have permission to view this document{{/warning}}
  $response.sendRedirect($xwiki.getURL("MyMain.NoAccess"))
#end
{{/velocity}}

Thanks again for all the help!



On Thu, Apr 7, 2011 at 1:59 PM, Eduard Moraru wrote:

> Hi China :),
>
> On 04/05/2011 05:38 PM, China Sunrise wrote:
> > Hi,
> > I'm relatively new to xwiki. I have a few pages where dynamic tables had
> to
> > be shown, and I'm using PHP quite heavily there. In a couple of pages,
> the
> > content is supposed to be shown only if the user is in a specific group
> > called 'XWikiEditorsGroup'. I didn't want to rely on xwiki's native
> > single-page permissions as they looked a little cumbersome for what I
> > needed, and preferred to control access via the page code itself. Up to
> > xwiki 2.7, the following velocity section, which was the first section in
> > the page, did the trick:
> >
> > {{velocity}}
> > #set($user=$xwiki.getUser())
> > #if(!$user.isUserInGroup("XWiki.XWikiEditorsGroup"))
> >{{warning}}You don't have permission to view this document{{/warning}}
> >#stop
> > #end
> > {{/velocity}}
> I don`t know how the PHP macro(?) works, but why don`t you do something
> like:
>
> {{velocity}}
> #set($user=$xwiki.getUser())
> #if(!$user.isUserInGroup("XWiki.XWikiEditorsGroup"))
>   {{warning}}You don't have permission to view this document{{/warning}}
> #else
>   {{php}}
> do some php here.
>   {{/php}}
> #end
> {{/velocity}}
>
>
> If you can nest the php macro into the velocity one, you are good to go
> and the code does not use velocity-dependent tricks.
>
> P.S.: On the other hand, I do recommend using XWiki's rights system. If
> you want to assign rights to multiple pages at once, do it at space
> level. You could also create a 'protected' space where you put all your
> protected pages that should be visible only to group X (so that you
> manage rights from a single -- space level -- point to avoid page level
> management).
>
> Hope this helps,
> Eduard
> > However, after upgrading to xwiki 3.0, this code no longer works. From
> what
> > I see, the issue appears to be related to velocity 1.7 and its different
> > syntax for the #stop directive. I can't seem to find the right syntax
> > though. As an alternative approach, I've also tried to relocate this
> access
> > control logic into the PHP code that follows the above velocity section.
> To
> > do that, I need to find a way to get the true/false value of
> > "$user.isUserInGroup("XWiki.XWikiEditorsGroup")" in PHP, but so far
> haven't
> > found a way to do that either and not sure how to pass the $user object
> and
> > its isUserInGroup() method to the PHP part. I've even looked into doing
> this
> > in groovy but no luck there either.
> >
> > Any advice will be appreciated...
> >
> > Thanks
>  > ___
> > users mailing list
> > users@xwiki.org
> > http://lists.xwiki.org/mailman/listinfo/users
> >
>
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] stopping a page for non-editors

2011-04-05 Thread China Sunrise
Hi,
I'm relatively new to xwiki. I have a few pages where dynamic tables had to
be shown, and I'm using PHP quite heavily there. In a couple of pages, the
content is supposed to be shown only if the user is in a specific group
called 'XWikiEditorsGroup'. I didn't want to rely on xwiki's native
single-page permissions as they looked a little cumbersome for what I
needed, and preferred to control access via the page code itself. Up to
xwiki 2.7, the following velocity section, which was the first section in
the page, did the trick:

{{velocity}}
#set($user=$xwiki.getUser())
#if(!$user.isUserInGroup("XWiki.XWikiEditorsGroup"))
  {{warning}}You don't have permission to view this document{{/warning}}
  #stop
#end
{{/velocity}}

However, after upgrading to xwiki 3.0, this code no longer works. From what
I see, the issue appears to be related to velocity 1.7 and its different
syntax for the #stop directive. I can't seem to find the right syntax
though. As an alternative approach, I've also tried to relocate this access
control logic into the PHP code that follows the above velocity section. To
do that, I need to find a way to get the true/false value of
"$user.isUserInGroup("XWiki.XWikiEditorsGroup")" in PHP, but so far haven't
found a way to do that either and not sure how to pass the $user object and
its isUserInGroup() method to the PHP part. I've even looked into doing this
in groovy but no luck there either.

Any advice will be appreciated...

Thanks
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users