private function has_add_block_capability($page, $capability) {
        // Check if the capability exists.
        if (!get_capability_info($capability)) {
            // Debug warning that the capability does not exist, but no more than once per page.
            static $warned = array();
            if (!isset($warned[$this->name()])) {
                debugging('The block ' .$this->name() . ' does not define the standard capability ' .
                        $capability , DEBUG_DEVELOPER);
                $warned[$this->name()] = 1;
            }
            // If the capability does not exist, the block can always be added.
            return true;
        } else {
            return has_capability($capability, $page->context);
        }
    }
private function has_add_block_capability($page, $capability) {
        // Check if the capability exists.
        if (!get_capability_info($capability)) {
            // Debug warning that the capability does not exist, but no more than once per page.
            static $warned = array();
            if (!isset($warned[$this->name()])) {
                debugging('The block ' .$this->name() . ' does not define the standard capability ' .
                        $capability , DEBUG_DEVELOPER);
                $warned[$this->name()] = 1;
            }
            // If the capability does not exist, the block can always be added.
            return true;
        } else {
            return has_capability($capability, $page->context);
        }
    }
private function has_add_block_capability ( $ page , $ capability ) { // Check if the capability exists. if ( ! get_capability_info ( $ capability ) ) { // Debug warning that the capability does not exist, but no more than once per page. static $ warned = array ( ) ; if ( ! isset ( $ warned [ $ this -> name ( ) ] ) ) { debugging ( 'The block ' . $ this -> name ( ) . ' does not define the standard capability ' . $ capability , DEBUG_DEVELOPER ) ; $ warned [ $ this -> name ( ) ] = 1 ; } // If the capability does not exist, the block can always be added. return true ; } else { return has_capability ( $ capability , $ page -> context ) ; } }
Returns true if the user can add a block to a page.

@param moodle_page $page
@param string $capability the capability to check
@return boolean true if user can add a block, false otherwise.
Returns true if the user can add a block to a page .