Jump to:

23376 Posts in 18282 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Trying to fix code to go back php versions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 237 Views
  • an_Eskimo
    Avatar
    Community Member
    10 Posts

    Trying to fix code to go back php versions Link to this post

    can anyone please help here, when I run this code, the editors for this are not able to see the sitetree. All that comes up is "There has been an error".

    The error that comes up is: "[Error] Uncaught Exception: Object->__call(): the method 'organisation' does not exist on 'Page'"

    This is coming from the line marked with stars:

    public function canEdit($member = null) {
          $return = false;

          // If parent::canEdit() returns true, then the user is an admin so they're allowed to edit. We don't need to do
          // any further checking.
          // If parent::canEdit() returns false, then we want to continue checking whether the Member is part of the group
          // of editors that this ResourcePage is associated with
          $return = parent::canEdit($member);
          if(!$return) {
             // Get the Member object ($member could be instanceof Member, or ID, or null)
             if(is_numeric($member)) $member = Member::get()->byID($member);
             else $member = Member::currentUser();
    if($member && $member->isInDB()) {

    // Check whether this Member is in the organisation editing group
    *** if($this->Parent && $this->Parent->Organisation() && $this->Parent->Organisation()->Group()) {
    if($member->inGroup($this->Parent->Organisation()->Group(), true)) {
    $return = true;
    }
    }
    }
          }

          return $return;
       }

    any assistance in this matter would be greatly appreciated!

  • an_Eskimo
    Avatar
    Community Member
    10 Posts

    Re: Trying to fix code to go back php versions Link to this post

    For those who are interested, I solved this quite simply (After three, yes, three hours of fighting with it).

    All I did was add a try catch around the if statement causing the issue and it has fixed it.

    237 Views
Page: 1
Go to Top

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

Comments on this website? Please give feedback.