user-avatar
Today is Tuesday
April 30, 2024

Tag: module

February 15, 2011

How to make Users as Invite only in Drupal

by viggy — Categories: Uncategorized — Tags: , , , , , Leave a comment

If you are creating a specific site, you wouldnt want anyone Tom and Harry to be able to register in the site. Also you would not want the burden of adding users completely on the admin. The best solution for that is to allow existing users to Invite other users. This will ensure that any time you always have users who are linked to each other.
To enable this feature, you need to enable Invite module, http://drupal.org/project/invite. The settings are very basic. After enabling the invite module, you will have a Invite tab under User management. Change the settings as you want. Also after this, make sure that you go to User settings and change the Public registrations: to “New user registration by invitation only.” This should enable already existing users to see a link “Invite a friend” on their main menu.
Now I need to find out how to restrict the number of invites per user.

July 21, 2009

Perl-error “.pm did not return a true value at”

by viggy — Categories: perl — Tags: , , Leave a comment

This is one of the errors that I got when I started using perl modules.
It was because I had not put “1;” at the end of my perl module. So I did not get the error after I put “1;” at the end of the perl module.

why is the “1;” necessary at the end of perl modules?

Typically, a module contains a bunch of subroutine definitions.  A
module may also contain code which is not part of a subroutine. This
code is executed at the time the module is loaded, so it can be used
to initialize the module. For example, the module might open
adatatbase connection or initialize some time at the time it is
loaded.


Such code might be successful, or it might fail. Perl allows the
module to indicate the result by returning a true or false value back
to its caller. If the value is false, Perl aborts the compilation
with an error message.

Unfortunately, the default return value is *false*, so a module which
just defines a bunch of subroutines, and which has no initialization
code, accidentally returns a false value back to the caller, and Perl
aborts. So we insert "1;" at the end to suppress this misbehavior.

http://dev.perl.org/rfc/269.pod
http://dev.perl.org/rfc/269.html

discusses this in some more detail.

For documentation, see perldiag:

%s did not return a true value
(F) A required (or used) file must return a true value
to indicate that it compiled correctly and ran its
initialization code correctly. It's traditional to
end such a file with a "1;", though any true value
would do. See the require entry in the perlfunc man-
page.

and the relevant part of 'perlfunc':

The file must return true as the last statement
to indicate successful execution of any initialization code, so
it's customary to end such a file with "1;" unless you're sure
it'll return true otherwise. But it's better just to put the
"1;", in case you add more statements.

Courtsey: http://lists.netisland.net/archives/phlpm/phlpm-2001/msg00426.html