A problem with the function has_capability

A problem with the function has_capability

د Marty Borisov لخوا -
د ځوابونو شمیر: 1

Hello,

I'm having a problem with the function has_capability(). So, I have a file called access.php which I defined roles for the different users for my block simplehtml in. 
I increased the version with 1 in the file version.php and made an update as administrator.  I can seen that capability is OK for different users checking in Users->Permissions->Define roles.

I added the function has_capability() in my block's class:

if( has_capability('blocks/simplehtml:viewpages', $context) ) {
$this->content->text = $this->content->text;
} else {
$this->content->text = '';
}


But when I try to enter to any course, an error appears:
Fatal error: Class 'block_base' not found in C:\xampp\htdocs\moodle\blocks\simplehtml\block_simplehtml.php on line 15
(I see it when I enter localhost/moodle/blocks/simplehtml/block_simplehtml.php) 

My class inherits block_base. I saw that block_base is defined in the file moodleblock.class.php, so I added the line on the top of my file block_simplehtml.php: require_once('../moodleblock.class.php'); It's quite strange because before that (added the function and file above) everything worked fine without that line.
But when I try to enter to the course, there is nothing on the screen - just a white page.


Could you please anyone tell me where I'm making a mistake? 

 

د درجې بندۍ اوسط:  -