CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Custom Component -- Access Denied
Pages: [1]

Author Topic: Custom Component -- Access Denied  (Read 847 times)

Luciano S.

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 2
  • iXiam Team Leader
  • CiviCRM version: 4.2+ / 4.3+ / 4.4+
  • CMS version: Drupal
  • MySQL version: 5.1+ / 5.5+
  • PHP version: 5.3+ / 5.4+
Custom Component -- Access Denied
February 08, 2011, 08:04:32 am
Hi, I'm trying to create a custom component. I started with the very basic, following this tutorial:
http://wiki.civicrm.org/confluence/display/CRMDOC33/Creating+custom+components

Test is my component, the steps I followed

1. Create folder: civicrm/CRM/Test
2. Create file: civicrm/CRM/Test/Info.php

Code: [Select]
require_once 'CRM/Core/Component/Info.php';

class CRM_Test_Info extends CRM_Core_Component_Info
{

    // docs inherited from interface
    protected $keyword = 'test';

    // docs inherited from interface
    public function getInfo()
    {
        return array( 'name'                 => 'Test',
                      'translatedName'       => ts('Test'),
                      'title'                => 'CiviCRM Test',
                      'search'               => 1,
                      'showActivitiesInCore' => 1
                      );
    }


    // docs inherited from interface
    public function getPermissions()
    {
        return array( 'access CiviCRM' );
    }

    // docs inherited from interface
    public function getUserDashboardElement()
    {
        return array(  );
    }

    // docs inherited from interface
    public function registerTab()
    {
        return array(  );
    }

    // docs inherited from interface
    public function registerAdvancedSearchPane()
    {
        return array( );
    }

    // docs inherited from interface   
    public function getActivityTypes()
    {
        return null;
    }
   
    // add shortcut to Create New
    public function creatNewShortcut( &$shortCuts ) {
       
        }
    }
   
}

3. Run "insert into civicrm_component (name, namespace) values ('Test', 'CRM_Test');"
4. Create folder: civicrm/CRM/Test/xml/Menu
5. create file: civicrm/CRM/Test/xml/Menu/Test.xml

Code: [Select]
<menu>
  <item>
     <path>civicrm/test</path>
     <title>Test</title>
     <page_callback>CRM_Test_Page_Form</page_callback>
     <access_arguments>access CiviCRM</access_arguments>
     <page_type>1</page_type>
     <weight>500</weight>
     <component>Test</component>
  </item>
</menu>

6. Rebuild the menu: http://localhost/drupal_url/civicrm/menu/rebuild&reset=1
7. Create folder civicrm/CRM/Test/Page
8. Create file: civicrm/CRM/Test/Page/Form.php

Code: [Select]
require_once 'CRM/Core/Page.php';

class CRM_Test_Page_Form extends CRM_Core_Page
{
 
    function preProcess( )
    {
        echo "I'm a Test Component";
    }

                                                         
    function run( ) {
        $this->preProcess( );
        return parent::run( );
    }

}


9. Create folder: civicrm/templates/CRM/Test/Page/Form.tpl  (in blank, not really needed I think...)

10. Go to http://localhost/drupal_url/civicrm/test

And there I get:

Access denied
You are not authorized to access this page.



I changed access_arguments, permits, functions, names.. etc.. but always I get the same error.

Any clue what am I doing wrong??

Thanks!
Luciano

Luciano S.

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 2
  • iXiam Team Leader
  • CiviCRM version: 4.2+ / 4.3+ / 4.4+
  • CMS version: Drupal
  • MySQL version: 5.1+ / 5.5+
  • PHP version: 5.3+ / 5.4+
Re: Custom Component -- Access Denied
February 08, 2011, 09:01:18 am
I think I solved it..

I didn't enable the component in "Enable CiviCRM Components" area (would be nice to add that to the Wiki as the last step, cause could be trivial but very easy to forget as well :) )

cheers!

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Custom Component -- Access Denied
February 08, 2011, 09:06:30 am
Quote from: sluc23 on February 08, 2011, 09:01:18 am
I didn't enable the component in "Enable CiviCRM Components" area (would be nice to add that to the Wiki as the last step, cause could be trivial but very easy to forget as well :) )

Glad you got it fixed. It would be helpful if you could go ahead and add that to the wiki. It is a community-developed resource. :)

Thank you.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Luciano S.

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 2
  • iXiam Team Leader
  • CiviCRM version: 4.2+ / 4.3+ / 4.4+
  • CMS version: Drupal
  • MySQL version: 5.1+ / 5.5+
  • PHP version: 5.3+ / 5.4+
Re: Custom Component -- Access Denied
February 08, 2011, 09:13:50 am
Hi hershel,

since it's my very first custom module, I'm going little step by little step to understand how it works.

For sure once I finish I will update the wiki and post and example if it is useful for other members

Tx!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Custom Component -- Access Denied
February 08, 2011, 01:20:44 pm
Hi,

Have a look at our book too on the section about extending civi, the hook chapter gives info too.

Good luck

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Custom Component -- Access Denied

This forum was archived on 2017-11-26.