public static function unblock_contacts($userids, $userid = 0) {
        global $CFG, $USER;

        // Check if messaging is enabled.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        if (empty($userid)) {
            $userid = $USER->id;
        }

        // Validate context.
        $context = context_system::instance();
        self::validate_context($context);

        $params = array('userids' => $userids, 'userid' => $userid);
        $params = self::validate_parameters(self::unblock_contacts_parameters(), $params);

        $capability = 'moodle/site:manageallmessaging';
        if (($USER->id != $params['userid']) && !has_capability($capability, $context)) {
            throw new required_capability_exception($context, $capability, 'nopermissions', '');
        }

        foreach ($params['userids'] as $id) {
            message_unblock_contact($id, $params['userid']);
        }

        return null;
    }
public static function unblock_contacts($userids, $userid = 0) {
        global $CFG, $USER;

        // Check if messaging is enabled.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        if (empty($userid)) {
            $userid = $USER->id;
        }

        // Validate context.
        $context = context_system::instance();
        self::validate_context($context);

        $params = array('userids' => $userids, 'userid' => $userid);
        $params = self::validate_parameters(self::unblock_contacts_parameters(), $params);

        $capability = 'moodle/site:manageallmessaging';
        if (($USER->id != $params['userid']) && !has_capability($capability, $context)) {
            throw new required_capability_exception($context, $capability, 'nopermissions', '');
        }

        foreach ($params['userids'] as $id) {
            message_unblock_contact($id, $params['userid']);
        }

        return null;
    }
public static function unblock_contacts ( $ userids , $ userid = 0 ) { global $ CFG , $ USER ; // Check if messaging is enabled. if ( empty ( $ CFG -> messaging ) ) { throw new moodle_exception ( 'disabled' , 'message' ) ; } if ( empty ( $ userid ) ) { $ userid = $ USER -> id ; } // Validate context. $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; $ params = array ( 'userids' => $ userids , 'userid' => $ userid ) ; $ params = self :: validate_parameters ( self :: unblock_contacts_parameters ( ) , $ params ) ; $ capability = 'moodle/site:manageallmessaging' ; if ( ( $ USER -> id != $ params [ 'userid' ] ) && ! has_capability ( $ capability , $ context ) ) { throw new required_capability_exception ( $ context , $ capability , 'nopermissions' , '' ) ; } foreach ( $ params [ 'userids' ] as $ id ) { message_unblock_contact ( $ id , $ params [ 'userid' ] ) ; } return null ; }
Unblock contacts.

@param array $userids array of user IDs.
@param int $userid The id of the user we are unblocking the contacts for
@return null
@since Moodle 2.5
Unblock contacts .