Ja sekojošajā padomā nav norādīts citādi, dažādu servisu uzstādīšana ir aprakstīta Ubuntu 16.04 serverim, bet dažādu lietotņu uzstādīšana Ubuntu 16.04 un/vai Lubuntu 16.04 darbstacijai. Ja lietojat citu Ubuntu versiju vai Linux distributīvu, iestatījumi, iestatījumu failu saturs, to atrašanās vietas un nosaukumi var atšķirties!
Sapratu.

XWiki registration

If any user is allowed to register in XWiki, it can be (and is) abused by spambots. This recipe shows, how to avoid it with customized XWiki.Registration class.
  1. Open XWiki.Registration class in edit mode, e.g. http://localhost:8080/xwiki/bin/edit/XWiki/Registration
  2. Uncomment sample code for sample code, which asks for favorite color (and accepts green as valid answer): 
...
  ## Uncomment this code to see an example of how you can easily add a field to the registration page
  ## NOTE: In order to save the favorite color in the "doAfterRegistration" hook, this page must be
  ## saved by an administrator and can not self sandboxing.
  #set($sandbox = false)
  #set($field =
    {'name' : 'favorite_color',
      'label' : 'What is your favorite color',
      'params' : {
        'type' : 'text',
        'size' : '60'
      },
      'validate' : {
        'mandatory' : {
          'failureMessage' : $services.localization.render('core.validation.required.message')
        },
        'regex' : {
          'pattern' : '/^green$/',
          'failureMessage' : 'You are not cool enough to register here.'
        },
        'fieldOkayMessage' : 'You are awesome.'
      },
      'doAfterRegistration' : '#saveFavoriteColor()'
    })
  #set($discard = $fields.add($field))
  ## Save the user's favorite color on their user page.
  #macro(saveFavoriteColor)
    #set($xwikiname = $request.get('xwikiname'))
    #set($userDoc = $xwiki.getDocument("$userSpace$xwikiname"))
    $userDoc.setContent("$userDoc.getContent() ${xwikiname}'s favorite color is $request.get('favorite_color')!")
    ## The user (who is not yet logged in) can't save documents so saveWithProgrammingRights
    ## will save the document as long as the user who last saved this registration page has programming rights.
    $userDoc.saveWithProgrammingRights("Saved favorite color from registration form.")
  #end
...
  1. If necessary, customize this code according to your needs and preferences.
  2. If multi lingual messages are needed, look at Writing Internationalized XWiki Applications for more info.
     
Tagi: XWiki English
Izveidojis Valdis Vītoliņš 2013-11-09 15:24
Pēdējais mainījis Valdis Vītoliņš 2018-12-04 12:36
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License