Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

17478 Posts in 4473 Topics by 1972 members

Archive

SilverStripe Forums » Archive » how to override Group

Our old forums are still available as a read-only archive.

Page: 1
Go to End
Author Topic: how to override Group 735 Views
  • blaater
    avatar
    Community Member
    22 posts

    how to override Group Link to this post

    Hello,

    Currently I'm customising the security-tab with some extra fields. I've overridden the Member-class and it works fine. Now I try to do the same thing with Group. The code i've used in _config.php is:

    Object::useCustomClass('Group', 'NetwerkHolder');

    Also I've created the NetwerkHolder.php

    class NetwerkHolder extends Group {
       
       static $db = array('ThemaNetwerk' => 'Varchar');

       static $allow_children = array('Netwerk');
       
    function getCMSFields() {
       
          $fields = parent::getCMSFields();
          
          $fields->insertBefore(new TextField('ThemaNetwerk'), "ThemaNetwerk");
                 
          return $fields;
       }
    }

    When I run mysite.com/db/build/?flush=1 I see that the table is created, but when I log into the cms I get a db error:

    FATAL ERROR: DATABASE ERROR: Couldn't run query: SELECT `Group`.*, `NetwerkHolder`.*, `Group`.ID, if(`Group`.ClassName,`Group`.ClassName,'Group') AS RecordClassName FROM `Group` LEFT JOIN `NetwerkHolder` ON `NetwerkHolder`.ID = `Group`.ID WHERE (`ID` IN (1)) ORDER BY ID | Column 'ID' in where clause is ambiguous
    At line 397 in /serverpath/public_html/sapphire/core/model/Database.php

    Does anybody know what is the problem?

    Thanks in advance!

  • Ingo
    avatar
    Administrator
    596 posts

    Re: how to override Group Link to this post

    subclassing group is not fully supported by the sapphre and cms modules.
    for the programmatic errors (like the one you mentioned above),
    you should look through the following files:
    Security.php
    SecurityAdmin.php
    MemberTableField.php
    Member.php
    Group.php
    Permission.php

    A good start is to make sure that manually constructed SQL-queries still work, and that Object::getCustomClass() is consistently used instead of direct usage of "Group".

    Theres also a usability-related set of problems which is not so easy to solve - SecurityAdmin should ask you which "type" of group you want to create, and not assume that all custom classes are equal. in your use case of customizing the cmsfields, this might only apply to a specific group.

    735 Views
Page: 1
Go to Top

Currently Online: steve_nyhof, Terry Apodaca, timwjohn

Welcome to our latest member: fearofbuttons

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.