Difference: TWikiFuncDotPm (6 vs. 7)

Revision 72008-01-22 - Main.TWikiContributor

Line: 5 to 5
  Official list of stable TWiki functions for Plugin developers
Changed:
<
<
This module defines official functions that Plugins
>
>
This module defines official functions that Plugins
 can use to interact with the TWiki engine and content.

Refer to EmptyPlugin and lib/TWiki/Plugins/EmptyPlugin.pm for a template Plugin and documentation on how to write a Plugin.

Line: 20 to 20
  The version of the TWiki::Func module is defined by the VERSION number of the TWiki::Plugins module, currently 1.2. This can be shown
Changed:
<
<
by the %PLUGINVERSION% variable. The 'Since' field in the function documentation refers to the VERSION number and the date that the function was addded.

Note: Beware! These methods should only ever be called from the context of a TWiki Plugin. They require a Plugins SESSION context to be established before they are called, and will not work if simply called from another TWiki module. For example,

use TWiki;
print TWiki::Func::getSkin(),"\n";
will fail with Can't call method "getSkin" on an undefined value at TWiki/Func.pm line 83.

If you want to call the methods outside the context of a plugin, you can create a Plugins SESSION object. For example, the script:

use TWiki:
$TWiki::Plugins::SESSION = new TWiki();
print TWiki::Func::getSkin(),"\n";
will work happily.
>
>
by the %PLUGINVERSION% TWiki variable, and accessed in code using $TWiki::Plugins::VERSION. The 'Since' field in the function documentation refers to $TWiki::Plugins::VERSION.

Notes on use of $TWiki::Plugins::VERSION (from 1.2 forwards):

  • If the major version (e.g. 1.) is the same then any plugin coded to use any earlier revision of the 1. API will still work. No function has been removed from the interface, nor has any API published in that version changed in such a way as to require plugins to be recoded.
  • If the minor version (e.g. 1.1) is incremented there may be changes in the API that may help improve the coding of some plugins - for example, new interfaces giving access to previously hidden core functions. In addition, deprecation of functions in the interface trigger a minor version increment. Note that deprecated functions are not removed, they are merely frozen, and plugin authors are recommended to stop using them.
  • Any additional digits in the version number relate to minor changes, such as the addition of parameters to the existing functions, or addition of utility functions that are unlikely to require significant changes to existing plugins.
  • TWiki::Plugins::VERSION also applies to the plugin handlers. The handlers are documented in the EmptyPlugin, and that module indicates what version of TWiki::Plugins::VERSION it relates to.
A full history of the changes to this API can be found at the end of this topic.
 
Line: 73 to 76
 
  • $web - Web name, e.g. 'Main'
  • $topic - Topic name, e.g. 'WebNotify'
  • $script - Script name, e.g. 'view'
Changed:
<
<
  • ... - an arbitrary number of name,value parameter pairs that will be url-encoded and added to the url. The special parameter name '#' is reserved for specifying an anchor. e.g. getScriptUrl('x','y','view','#'=>'XXX',a=>1,b=>2) will give .../view/x/y?a=1&b=2#XXX
>
>
  • ... - an arbitrary number of name=>value parameter pairs that will be url-encoded and added to the url. The special parameter name '#' is reserved for specifying an anchor. e.g. getScriptUrl('x','y','view','#'=>'XXX',a=>1,b=>2) will give .../view/x/y?a=1&b=2#XXX
  Return: $url URL, e.g. "http://example.com:80/cgi-bin/view.pl/Main/WebNotify"
Line: 90 to 93
 Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)
Changed:
<
<

getOopsUrl( $web, $topic, $template, $param1, $param2, $param3, $param4 ) -> $url

Compose fully qualified 'oops' dialog URL

  • $web - Web name, e.g. 'Main'. The current web is taken if empty
  • $topic - Topic name, e.g. 'WebNotify'
  • $template - Oops template name, e.g. 'oopsmistake'. The 'oops' is optional; 'mistake' will translate to 'oopsmistake'.
  • $param1 ... $param4 - Parameter values for %PARAM1% ... %PARAMn% variables in template, optional
Return: $url URL, e.g. "http://example.com:80/cgi-bin/oops.pl/ Main/WebNotify?template=oopslocked&param1=joe"
>
>

getPubUrlPath( ) -> $path

 
Changed:
<
<
This might be used like this:
   my $url = TWiki::Func::getOopsUrl($web, $topic, 'oopsmistake', 'I made a boo-boo');
   TWiki::Func::redirectCgiQuery( undef, $url );
   return 0;
>
>
Get pub URL path
 
Changed:
<
<
Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)
>
>
Return: $path URL path of pub directory, e.g. "/pub"
 
Changed:
<
<
Since TWiki::Plugins::VERSION 1.1, the recommended approach is to throw an oops exception.
   use Error qw( :try );
>
>
Since: TWiki::Plugins::VERSION 1.000 (14 Jul 2001)
 
Deleted:
<
<
throw TWiki::OopsException($web, $topic, undef, 0, [ 'I made a boo-boo' ]); and let TWiki handle the cleanup.
 
Added:
>
>

getExternalResource( $url ) -> $response

 
Changed:
<
<

getPubUrlPath( ) -> $path

>
>
Get whatever is at the other end of a URL (using an HTTP GET request). Will only work for encrypted protocols such as https if the LWP CPAN module is installed.

Note that the $url may have an optional user and password, as specified by the relevant RFC. Any proxy set in configure is honoured.

The $response is an object that is known to implement the following subset of the methods of LWP::Response. It may in fact be an LWP::Response object, but it may also not be if LWP is not available, so callers may only assume the following subset of methods is available:

code()
message()
header($field)
content()
is_error()
is_redirect()

Note that if LWP is not available, this function:

  1. can only really be trusted for HTTP/1.0 urls. If HTTP/1.1 or another protocol is required, you are strongly recommended to require LWP.
  2. Will not parse multipart content

In the event of the server returning an error, then is_error() will return true, code() will return a valid HTTP status code as specified in RFC 2616 and RFC 2518, and message() will return the message that was received from the server. In the event of a client-side error (e.g. an unparseable URL) then is_error() will return true and message() will return an explanatory message. code() will return 400 (BAD REQUEST).

 
Changed:
<
<
Get pub URL path
>
>
Note: Callers can easily check the availability of other HTTP::Response methods as follows:
 
Changed:
<
<
Return: $path URL path of pub directory, e.g. "/pub"
>
>
my $response = TWiki::Func::getExternalResource($url);
if (!$response->is_error() && $response->isa('HTTP::Response')) {
    ... other methods of HTTP::Response may be called
} else {
    ... only the methods listed above may be called
}
 
Changed:
<
<
Since: TWiki::Plugins::VERSION 1.000 (14 Jul 2001)
>
>
Since: TWiki::Plugins::VERSION 1.2
 

getCgiQuery( ) -> $query

Line: 135 to 159
 Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)
Added:
>
>

getSessionKeys() -> @keys

Get a list of all the names of session variables. The list is unsorted.

Session keys are stored and retrieved using setSessionValue and getSessionValue.

Since: TWiki::Plugins::VERSION 1.2

 

getSessionValue( $key ) -> $value

Get a session value from the client session module

Line: 175 to 208
 identifier - the view script has 'view', the edit script has 'edit' etc. So you can easily tell what 'type' of script your Plugin is being called within. The core context identifiers are listed
Changed:
<
<
in the TWikiTemplates topic. Please be careful not to
>
>
in the TWikiTemplates topic. Please be careful not to
 overwrite any of these identifiers!

Context identifiers can be used to communicate between Plugins, and between

Line: 210 to 243
 Since: TWiki::Plugins::VERSION 1.1
Added:
>
>

pushTopicContext($web, $topic)

  • $web - new web
  • $topic - new topic
Change the TWiki context so it behaves as if it was processing $web.$topic from now on. All the preferences will be reset to those of the new topic. Note that if the new topic is not readable by the logged in user due to access control considerations, there will not be an exception. It is the duty of the caller to check access permissions before changing the topic.

It is the duty of the caller to restore the original context by calling popTopicContext.

Note that this call does not re-initialise plugins, so if you have used global variables to remember the web and topic in initPlugin, then those values will be unchanged.

Since: TWiki::Plugins::VERSION 1.2

popTopicContext()

Returns the TWiki context to the state it was in before the pushTopicContext was called.

Since: TWiki::Plugins::VERSION 1.2

 

Preferences

Line: 281 to 341
 preferences set in the plugin topic will be ignored.
Added:
>
>

setPreferencesValue($name, $val)

Set the preferences value so that future calls to getPreferencesValue will return this value, and %$name% will expand to the preference when used in future variable expansions.

The preference only persists for the rest of this request. Finalised preferences cannot be redefined using this function.

Returns 1 if the preference was defined, and 0 otherwise.

 

getWikiToolName( ) -> $name

Get toolname as defined in TWiki.cfg

Line: 319 to 389
 Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)
Changed:
<
<

getWikiName( ) -> $wikiName

>
>

getCanonicalUserID( $user ) -> $cUID

Return the cUID of the specified user. A cUID is a unique identifier which is assigned by TWiki for each user. BEWARE: While the default TWikiUserMapping uses a cUID that looks like a user's LoginName, some characters are modified to make them compatible with rcs. Additionally, other usermappings will use other conventions - the JoomlauserMapping for example, has cUIDs like 'JoomlaeUserMapping_1234'.

If $user is undefined Get the cUID of logged in user, and will generally be 'BaseUserMapping_666'

  • $user can be a cUID, login, wikiname or web.wikiname

Return: $cUID an internal unique and transportable escaped identifier for registered users (they can be autogenerated for an authenticated but unregistered user)

 
Changed:
<
<
Get Wiki name of logged in user
>
>
Since: TWiki::Plugins::VERSION 1.2

getWikiName( $user ) -> $wikiName

return the WikiName of the specified user if $user is undefined Get Wiki name of logged in user

  • $user can be a cUID, login, wikiname or web.wikiname
  Return: $wikiName Wiki Name, e.g. 'JohnDoe'

Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)

Changed:
<
<

getWikiUserName( ) -> $wikiName

>
>

getWikiUserName( $user ) -> $wikiName

return the userWeb.WikiName of the specified user if $user is undefined Get Wiki name of logged in user

 
Changed:
<
<
Get Wiki name of logged in user with web prefix
>
>
  • $user can be a cUID, login, wikiname or web.wikiname
  Return: $wikiName Wiki Name, e.g. "Main.JohnDoe"
Line: 338 to 434
 

wikiToUserName( $wikiName ) -> $loginName

Changed:
<
<
Translate a Wiki name to a login name based on Main.TWikiUsers topic
>
>
Translate a Wiki name (or login name or cUID, if it can) to a login name.
 
  • $wikiName - Wiki name, e.g. 'Main.JohnDoe' or 'JohnDoe'
Changed:
<
<
Return: $loginName Login name of user, e.g. 'jdoe'
>
>
Return: $loginName Login name of user, e.g. 'jdoe', or undef if not matched.

Note that it is possible for several login names to map to the same wikiname. This function will only return the first login name that maps to the wikiname.

returns undef if the WikiName is not found.

  Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)

userToWikiName( $loginName, $dontAddWeb ) -> $wikiName

Changed:
<
<
Translate a login name to a Wiki name based on Main.TWikiUsers topic
>
>
Translate a login name to a Wiki name
 
  • $loginName - Login name, e.g. 'jdoe'
  • $dontAddWeb - Do not add web prefix if "1"
Return: $wikiName Wiki name of user, e.g. 'Main.JohnDoe' or 'JohnDoe'
Added:
>
>
userToWikiName will always return a name, if the user does not exist in the mapping, the $loginName parameter is returned. (backward compatibility)
 Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)
Added:
>
>

emailToWikiNames( $email, $dontAddWeb ) -> @wikiNames

  • $email - email address to look up
  • $dontAddWeb - Do not add web prefix if "1"
Find the wikinames of all users who have the given email address as their registered address. Since several users could register with the same email address, this returns a list of wikinames rather than a single wikiname.

Since: TWiki::Plugins::VERSION 1.2

wikiNameToEmails( $wikiname ) -> @emails

  • $wikiname - wikiname of user to look up
Returns the registered email addresses of the named user. If $wikiname is undef, returns the registered email addresses for the logged-in user.

Since: TWiki::Plugins::VERSION 1.2

 

isGuest( ) -> $boolean

Test if logged in user is a guest (TWikiGuest )

Line: 363 to 485
 Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)
Changed:
<
<

permissionsSet( $web ) -> $boolean

>
>

isAnAdmin( $login ) -> $boolean

 
Changed:
<
<
Test if any access restrictions are set for this web, ignoring settings on individual pages
  • $web - Web name, required, e.g. 'Sandbox'
>
>
Find out if the user is an admin or not. If the user is not given, the currently logged-in user is assumed.
  • $login can be either a login, or a CUID
 
Changed:
<
<
Since: TWiki::Plugins::VERSION 1.000 (27 Feb 2001)
>
>
Since: TWiki::Plugins::VERSION 1.2

isGroupMember( $group, $login ) -> $boolean

Find out if $login is in the named group. e.g.

if( TWiki::Func::isGroupMember( "HesperionXXGroup", "jordi" )) {
    ...
}
If $user is undef, it defaults to the currently logged-in user.

  • $login can be a login name, or a cUID, or WikiName

Since: TWiki::Plugins::VERSION 1.2

eachUser() -> $iterator

Get an iterator over the list of all the registered users not including groups. The iterator will return each wiki name in turn (e.g. 'FredBloggs').

Use it as follows:

    my $iterator = TWiki::Func::eachUser();
    while ($it->hasNext()) {
        my $user = $it->next();
        # $user is a wikiname
    }

WARNING on large sites, this could be a long list!

Since: TWiki::Plugins::VERSION 1.2

eachMembership($wikiname) -> $iterator

Get an iterator over the names of all groups that the user is a member of. If $wikiname is undef, defaults to the currently logged-in user.

Since: TWiki::Plugins::VERSION 1.2

eachGroup() -> $iterator

Get an iterator over all groups.

Use it as follows:

    my $iterator = TWiki::Func::eachGroup();
    while ($it->hasNext()) {
        my $group = $it->next();
        # $group is a group name e.g. TWikiAdminGroup
    }

WARNING on large sites, this could be a long list!

Since: TWiki::Plugins::VERSION 1.2

isGroup( $group ) -> $boolean

Checks if $group is the name of a group known to TWiki.

eachGroupMember($group) -> $iterator

Get an iterator over all the members of the named group. Returns undef if $group is not a valid group.

Use it as follows:

    my $iterator = TWiki::Func::eachGroupMember('RadioheadGroup');
    while ($it->hasNext()) {
        my $user = $it->next();
        # $user is a wiki name e.g. 'TomYorke', 'PhilSelway'
    }

WARNING on large sites, this could be a long list!

Since: TWiki::Plugins::VERSION 1.2

 

checkAccessPermission( $type, $wikiName, $text, $topic, $web, $meta ) -> $boolean

Check access permission for a topic based on the

Changed:
<
<
TWiki.TWikiAccessControl rules
>
>
TWiki.TWikiAccessControl rules
 
  • $type - Access type, required, e.g. 'VIEW', 'CHANGE'.
  • $wikiName - WikiName of remote user, required, e.g. "PeterThoeny". If $wikiName is '', 0 or undef then access is always permitted.
Line: 492 to 695
 Since: TWiki::Plugins::VERSION 1.1
Added:
>
>

eachChangeSince($web, $time) -> $iterator

Get an iterator over the list of all the changes in the given web between $time and now. $time is a time in seconds since 1st Jan 1970, and is not guaranteed to return any changes that occurred before (now - {Store}{RememberChangesFor}). {Store}{RememberChangesFor}) is a setting in configure. Changes are returned in most-recent-first order.

Use it as follows:

    my $iterator = TWiki::Func::eachChangeSince(
        $web, time() - 7 * 24 * 60 * 60); # the last 7 days
    while ($it->hasNext()) {
        my $change = $it->next();
        # $change is a perl hash that contains the following fields:
        # topic => topic name
        # user => wikiname - wikiname of user who made the change
        # time => time of the change
        # revision => revision number *after* the change
        # more => more info about the change (e.g. 'minor')
    }
 

getTopicList( $web ) -> @topics

Get list of all topics in a web

Line: 506 to 734
 Test if topic exists
  • $web - Web name, optional, e.g. 'Main'.
  • $topic - Topic name, required, e.g. 'TokyoOffice', or "Main.TokyoOffice"
Added:
>
>
 $web and $topic are parsed as described in the documentation for normalizeWebTopicName.
Added:
>
>
Specifically, the Main is used if $web is not specified and $topic has no web specifier. To get an expected behaviour it is recommened to specify the current web for $web; don't leave it empty.
  Since: TWiki::Plugins::VERSION 1.000 (14 Jul 2001)
Line: 526 to 757
 
  • $web Web name, e.g. "Main", or empty
  • $topic Topic name, e.g. "MyTopic", or "Main.MyTopic"
Changed:
<
<
  • $lock 1 to lease the topic, 0 to clear the lease=
>
>
  • $lock 1 to lease the topic, 0 to clear an existing lease
  Takes out a "lease" on the topic. The lease doesn't prevent anyone from editing and changing the topic, but it does redirect them
Line: 643 to 874
  NOTE: if you are trying to get revision info for a topic, use $meta->getRevisionInfo instead if you can - it is significantly
Changed:
<
<
more efficient, and returns a user object that contains other user information.

NOTE: prior versions of TWiki may under some circumstances have returned the login name of the user rather than the wiki name; the code documentation was totally unclear, and we have been unable to establish the intent. However the wikiname is obviously more useful, so that is what is returned.

>
>
more efficient.
  Since: TWiki::Plugins::VERSION 1.000 (29 Jul 2001)
Line: 692 to 917
 
  • $ignorePermissions - Set to "1" if checkAccessPermission() is already performed and OK; an oops URL is returned if user has no permission
Return: $text Topic text with embedded meta data; an oops URL for calling redirectCgiQuery() is returned in case of an error
Changed:
<
<
This method is more efficient than readTopic, but returns meta-data embedded in the text. Plugins authors must be very careful to avoid damaging meta-data. You are recommended to use readTopic instead, which is a lot safer..
>
>
This method is more efficient than readTopic, but returns meta-data embedded in the text. Plugins authors must be very careful to avoid damaging meta-data. You are recommended to use readTopic instead, which is a lot safer.
  Since: TWiki::Plugins::VERSION 1.010 (31 Dec 2002)
Line: 815 to 1040
 

readTemplate( $name, $skin ) -> $text

Changed:
<
<
Read a template or skin. Embedded template directives get expanded
>
>
Read a template or skin. Embedded template directives get expanded
 
  • $name - Template name, e.g. 'view'
  • $skin - Comma-separated list of skin names, optional, e.g. 'print'
Return: $text Template text
Line: 855 to 1080
 

writeHeader( $query, $contentLength )

Prints a basic content-type HTML header for text/html to standard out

Changed:
<
<
  • $query - CGI query object. If not given, the default CGI query will be used. In most cases you should not pass this parameter.
  • $contentLength - Length of content
>
>
  • $query - CGI query object. If not given, the default CGI query will be used (optional, in most cases you should not pass this parameter)
  • $contentLength - Length of content (optional, in most cases you should not pass this parameter)
 Return: none

Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)

Line: 879 to 1104
 same TWiki installation. If $passthru is set to a true value, then TWiki will save the current URL parameters, and then try to restore them on the other side of the redirect. Parameters are stored on the server in a cache
Changed:
<
<
file (see {PassthroughDir} in =configure).
>
>
file.
  Note that if $passthru is set, then any parameters in $url will be lost when the old parameters are restored. if you want to change any parameter
Line: 916 to 1141
 
Changed:
<
<

expandCommonVariables( $text, $topic, $web ) -> $text

>
>

expandCommonVariables( $text, $topic, $web, $meta ) -> $text

  Expand all common %VARIABLES%
  • $text - Text with variables to expand, e.g. 'Current user is %WIKIUSER%'
  • $topic - Current topic name, e.g. 'WebNotify'
  • $web - Web name, optional, e.g. 'Main'. The current web is taken if missing
Added:
>
>
  • $meta - topic meta-data to use while expanding (Since TWiki::Plugins::VERSION 1.2)
 Return: $text Expanded text, e.g. 'Current user is TWikiGuest'

Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)

Line: 931 to 1157
 

renderText( $text, $web ) -> $text

Changed:
<
<
Render text from TWiki markup into XHTML as defined in TWiki.TextFormattingRules
>
>
Render text from TWiki markup into XHTML as defined in TWiki.TextFormattingRules
 
  • $text - Text to render, e.g. '*bold* text and =fixed font='
  • $web - Web name, optional, e.g. 'Main'. The current web is taken if missing
Return: $text XHTML text, e.g. '<b>bold</b> and <code>fixed font</code>'
Line: 1111 to 1337
 (ie, with the name of the function instead of the alias) will not work.

Added:
>
>

decodeFormatTokens($str) -> $unencodedString

TWiki has an informal standard set of tokens used in format parameters that are used to block evaluation of paramater strings. For example, if you were to write

%MYTAG{format="%WURBLE%"}%

then %WURBLE would be expanded before %MYTAG is evaluated. To avoid this TWiki uses escapes in the format string. For example:

%MYTAG{format="$percntWURBLE$percnt"}%

This lets you enter arbitrary strings into parameters without worrying that TWiki will expand them before your plugin gets a chance to deal with them properly. Once you have processed your tag, you will want to expand these tokens to their proper value. That's what this function does.

Escape: Expands To:
$n or $n() New line. Use $n() if followed by alphanumeric character, e.g. write Foo$n()Bar instead of Foo$nBar
$nop or $nop() Is a "no operation".
$quot Double quote (")
$percnt Percent sign (%)
$dollar Dollar sign ($)

Note thath $quot, $percnt and $dollar all work *even if they are followed by alphanumeric characters*. You have been warned!

Since: TWiki::Plugins::VERSION 1.2

 

Searching

Line: 1250 to 1507
  Note that hierarchical web names (SubWeb ) are only available if hierarchical webs are enabled in configure.
Changed:
<
<
The symbols %USERSWEB%, %SYSTEMWEB%, %DOCWEB%, %MAINWEB% and %TWIKIWEB% can be used in the input to represent the web names set in $cfg{UsersWebName} and $cfg{SystemWebName}. For example:
>
>
The symbols %USERSWEB%, %SYSTEMWEB% and %DOCWEB% can be used in the input to represent the web names set in $cfg{UsersWebName} and $cfg{SystemWebName}. For example:
 
Input Return
<-- -->
Sorted ascending
( '%USERSWEB%', 'Topic' ) ( 'Main', 'Topic' )
( '%SYSTEMWEB%', 'Topic' ) ( 'TWiki', 'Topic' )
( '', '%DOCWEB%.Topic' ) ( 'TWiki', 'Topic' )
Added:
>
>

StaticMethod *sanitizeAttachmentName ($fname) -> ($fileName,$origName)

Given a file namer, sanitise it according to the rules for transforming attachment names. Returns the sanitised name together with the basename before sanitisation.

Sanitation includes filtering illegal characters and mapping client file names to legal server names.

Since: TWiki::Plugins::VERSION 1.2

spaceOutWikiWord( $word, $sep ) -> $text

Spaces out a wiki word by inserting a string (default: one space) between each word component. With parameter $sep any string may be used as separator between the word components; if $sep is undefined it defaults to a space.

Since: TWiki::Plugins::VERSION 1.2

 

writeWarning( $text )

Log Warning that may require admin intervention to data/warning.txt

Line: 1287 to 1565
 Since: TWiki::Plugins::VERSION 1.020 (26 Feb 2004)
Added:
>
>

isTrue( $value, $default ) -> $boolean

Returns 1 if $value is true, and 0 otherwise. "true" means set to something with a Perl true value, with the special cases that "off", "false" and "no" (case insensitive) are forced to false. Leading and trailing spaces in $value are ignored.

If the value is undef, then $default is returned. If $default is not specified it is taken as 0.

Since: $TWiki::Plugins::VERSION 1.2

 

isValidWikiWord ( $text ) -> $boolean

Check for a valid WikiWord or WikiName

Line: 1365 to 1656
 Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)
Added:
>
>

getOopsUrl( $web, $topic, $template, $param1, $param2, $param3, $param4 ) -> $url

Compose fully qualified 'oops' dialog URL

  • $web - Web name, e.g. 'Main'. The current web is taken if empty
  • $topic - Topic name, e.g. 'WebNotify'
  • $template - Oops template name, e.g. 'oopsmistake'. The 'oops' is optional; 'mistake' will translate to 'oopsmistake'.
  • $param1 ... $param4 - Parameter values for %PARAM1% ... %PARAMn% variables in template, optional
Return: $url URL, e.g. "http://example.com:80/cgi-bin/oops.pl/ Main/WebNotify?template=oopslocked&param1=joe"

DEPRECATED since 1.1, the recommended approach is to throw an oops exception.

   use Error qw( :try );

   throw TWiki::OopsException(
      'toestuckerror',
      web => $web,
      topic => $topic,
      params => [ 'I got my toe stuck' ]);
(this example will use the oopstoestuckerror template.)

If this is not possible (e.g. in a REST handler that does not trap the exception) then you can use getScriptUrl instead:

   my $url = TWiki::Func::getScriptUrl($web, $topic, 'oops',
            template => 'oopstoestuckerror',
            param1 => 'I got my toe stuck');
   TWiki::Func::redirectCgiQuery( undef, $url );
   return 0;

Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)

permissionsSet( $web ) -> $boolean

Test if any access restrictions are set for this web, ignoring settings on individual pages

  • $web - Web name, required, e.g. 'Sandbox'

Since: TWiki::Plugins::VERSION 1.000 (27 Feb 2001)

DEPRECATED since 1.2 - use getPreferencesValue instead to determine what permissions are set on the web, for example:

foreach my $type qw( ALLOW DENY ) {
    foreach my $action qw( CHANGE VIEW ) {
        my $pref = $type . 'WEB' . $action;
        my $val = getPreferencesValue( $pref, $web ) || '';
        if( $val =~ /\S/ ) {
            print "$pref is set to $val on $web\n";
        }
    }
}
 

getPublicWebList( ) -> @webs

DEPRECATED since 1.1 - use getListOfWebs instead.

 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.TWikiFuncDotPm