[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Report v0.1



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 18 May 2002 05:49 pm, Adam \"Tauvix\" Debus wrote:
> Hello Everyone,
>

Hello

<snip>

>     Now, at this time it does nothing with the Permissions Bit except
> create it. It doesn't check for it, or anything else. But it does show up
> in the "Users" configuration.

Technically you dont have to do any checking on the permissions bit.  The 
VoodooMagic function in NorthStar.pm handles the dispatching of the user call 
(shnet, shreport, shdevice, etc..) to the right subroutine and does all the 
checking for the permissions (basically just make sure that the current user 
can execute the called function).

>
>     Here's the part where I am having problems. When I click my link, which
> calls a function I've exported back, it tells me this:
>
>         You do not have permission to execute this function
>
>     I have debugging mode on, so here is the stack trace:

Ok.. this is happening because the package declaration in the module is not 
correct.  The fixed version is attached but I will summarize the changes 
here:

1.  The 'package NorthStar::Report' should be 
    'package NorthStar::Modules::Report'

2.  The export of the shreport call in user_hooks should
    be have a reference to NorthStar::Modules::Report::ShowReport
    because of the change above.

3.  The call to API_PermissionsRegisterPerm should have 'Report' as
    the last argument instead of 'CORE' because this is not a core 
    module.  Also the third argument should be 'shreport' since 
    this is the user call that was exported in user_hooks

4.  The module should not have to modify any of the core files (NorthStar.pm, 
    API.pm) for including the module.  Instead you should a line like the
    following to NorthStar.conf in the Global section:

	UseModules	Report AnotherModule TestModule

    The function ModulesInit in API.pm (called way up the stack during 
    initialzation reads this and dynamically loads the modules (each 
    module name should be seperated by a space.

    This is not documented anywhere yet.. I appologize for any
    confusion it might have caused.

5.  You shouldn't have to have the 'use Exporter' and associated lines
    since your not exporting any functions that are going to be called
    by the core modules.

6.  Be sure to go and specifically set the user to be able to execute the 
    'Reports' permission before you try to run it.  Since the call to 
    API_PermissionsRegisterPerm has the second argument as '0' that means
    that the particular bit does not default to being executable, therefore
    each user has to be specifically set to allow it.  This may be a problem
    if your using the admin user because up until a couple days ago the 
    permissions settings for the admin user only allowed the core functions.
  
    The fix is to manually go into the database and do a:

    UPDATE users SET permmask = 
'11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'
    WHERE id = '0';

    In case my mailer screws up that last line that is 128 1's.

I have fixed the errors and attached the file.  Be sure to add the UseModules 
directive described in #4 above to actually load the module.

The Report.pm file needs to be put under lib/NorthStar/Modules/

Have fun, sorry for the delay in replying.. one of those weekends ;-)

- -- 
+---------------------------------+----------------------------+
| Hitesh Patel                    |  Lead Developer            |
| hitesh@presys.com               |  NorthStar                 |
+---------------------------------+----------------------------+
| NorthStar: http://www.brownkid.net/NorthStar/                |
| PGP Key:   http://www.brownkid.net/pgpkey.asc                |
+--------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE86W6dCws8KqPtd2URAktdAJ9lwLINh5XZjgOrLK8YF7G7+hVm7QCfSaaT
+zUZCX1OW8Ym4Rrz62CTBWc=
=QQGO
-----END PGP SIGNATURE-----
#
# Copyright (C) 2002, Adam Debus <adam@reachone.com>
# All rights reserved.
#
# This file is an extention of the NorthStar system,
# and is covered under the terms of the Apache Software
# License version 1.1
#
# A copy of this license is included in the LICENSE file.
#

package NorthStar::Modules::Report;
use NorthStar::API qw(:ALL);

sub init {

	Debug("REPORT: initializing module");

	my(%modinfo) = (
		export_hooks => [],
		user_hooks => {
			'shreport'=> \&NorthStar::Modules::Report::ShowReport,
		},
		import_hooks => {},
	);

	API_PermissionsRegisterPerm(127, 0, 'shreport', 'Reports', 'Report');

	my($script) = ConfigGetValue('Global','ScriptURL');
	API_MenuAddSection('Reports');
	API_MenuAddItem('Reports','Run Reports',"$script?r=shreport",undef);

	return(%modinfo);
}

sub ShowReport {

	API_OutputPage('view_report.html');

}

return 1;