public static function list_user_plans($userid) {
        global $DB, $USER;
        static::require_enabled();
        $select = 'userid = :userid';
        $params = array('userid' => $userid);
        $context = context_user::instance($userid);

        // Check that we can read something here.
        if (!plan::can_read_user($userid) && !plan::can_read_user_draft($userid)) {
            throw new required_capability_exception($context, 'moodle/competency:planview', 'nopermissions', '');
        }

        // The user cannot view the drafts.
        if (!plan::can_read_user_draft($userid)) {
            list($insql, $inparams) = $DB->get_in_or_equal(plan::get_draft_statuses(), SQL_PARAMS_NAMED, 'param', false);
            $select .= " AND status $insql";
            $params += $inparams;
        }
        // The user cannot view the non-drafts.
        if (!plan::can_read_user($userid)) {
            list($insql, $inparams) = $DB->get_in_or_equal(array(plan::STATUS_ACTIVE, plan::STATUS_COMPLETE),
                SQL_PARAMS_NAMED, 'param', false);
            $select .= " AND status $insql";
            $params += $inparams;
        }

        return plan::get_records_select($select, $params, 'name ASC');
    }
public static function list_user_plans($userid) {
        global $DB, $USER;
        static::require_enabled();
        $select = 'userid = :userid';
        $params = array('userid' => $userid);
        $context = context_user::instance($userid);

        // Check that we can read something here.
        if (!plan::can_read_user($userid) && !plan::can_read_user_draft($userid)) {
            throw new required_capability_exception($context, 'moodle/competency:planview', 'nopermissions', '');
        }

        // The user cannot view the drafts.
        if (!plan::can_read_user_draft($userid)) {
            list($insql, $inparams) = $DB->get_in_or_equal(plan::get_draft_statuses(), SQL_PARAMS_NAMED, 'param', false);
            $select .= " AND status $insql";
            $params += $inparams;
        }
        // The user cannot view the non-drafts.
        if (!plan::can_read_user($userid)) {
            list($insql, $inparams) = $DB->get_in_or_equal(array(plan::STATUS_ACTIVE, plan::STATUS_COMPLETE),
                SQL_PARAMS_NAMED, 'param', false);
            $select .= " AND status $insql";
            $params += $inparams;
        }

        return plan::get_records_select($select, $params, 'name ASC');
    }
public static function list_user_plans ( $ userid ) { global $ DB , $ USER ; static :: require_enabled ( ) ; $ select = 'userid = :userid' ; $ params = array ( 'userid' => $ userid ) ; $ context = context_user :: instance ( $ userid ) ; // Check that we can read something here. if ( ! plan :: can_read_user ( $ userid ) && ! plan :: can_read_user_draft ( $ userid ) ) { throw new required_capability_exception ( $ context , 'moodle/competency:planview' , 'nopermissions' , '' ) ; } // The user cannot view the drafts. if ( ! plan :: can_read_user_draft ( $ userid ) ) { list ( $ insql , $ inparams ) = $ DB -> get_in_or_equal ( plan :: get_draft_statuses ( ) , SQL_PARAMS_NAMED , 'param' , false ) ; $ select .= " AND status $insql" ; $ params += $ inparams ; } // The user cannot view the non-drafts. if ( ! plan :: can_read_user ( $ userid ) ) { list ( $ insql , $ inparams ) = $ DB -> get_in_or_equal ( array ( plan :: STATUS_ACTIVE , plan :: STATUS_COMPLETE ) , SQL_PARAMS_NAMED , 'param' , false ) ; $ select .= " AND status $insql" ; $ params += $ inparams ; } return plan :: get_records_select ( $ select , $ params , 'name ASC' ) ; }
Lists user plans.

@param int $userid
@return \core_competency\plan[]
Lists user plans .