text:
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die();

/**
 * This class provides a targeted tied together means of interfacing the enrolment
 * tasks together with a course.
 *
 * It is provided as a convenience more than anything else.
 *
 * @copyright 2010 Sam Hemelryk
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
class course_enrolment_manager {

    /**
     * The course context
     * @var stdClass
     */
    protected $context;
    /**
     * The course we are managing enrolments for
     * @var stdClass
     */
    protected $course = null;
    /**
     * Limits the focus of the manager to one enrolment plugin instance
     * @var string
     */
    protected $instancefilter = null;
    /**
     * Limits the focus of the manager to users with specified role
     * @var int
     */
    protected $rolefilter = 0;
    /**
     * Limits the focus of the manager to users who match search string
     * @var string
     */
    protected $searchfilter = '';

    /**
     * The total number of users enrolled in the course
     * Populated by course_enrolment_manager::get_total_users
     * @var int
     */
    protected $totalusers = null;
    /**
     * An array of users currently enrolled in the course
     * Populated by course_enrolment_manager::get_users
     * @var array
     */
    protected $users = array();

    /**
     * An array of users who have roles within this course but who have not
     * been enrolled in the course
     * @var array
     */
    protected $otherusers = array();

    /**
     * The total number of users who hold a role within the course but who
     * arn't enrolled.
     * @var int
     */
    protected $totalotherusers = null;

    /**
     * The current moodle_page object
     * @var moodle_page
     */
    protected $moodlepage = null;

    /**#@+
     * These variables are used to cache the information this class uses
     * please never use these directly instead use their get_ counterparts.
     * @access private
     * @var array
     */
    private $_instancessql = null;
    private $_instances = null;
    private $_inames = null;
    private $_plugins = null;
    private $_allplugins = null;
    private $_roles = null;
    private $_assignableroles = null;
    private $_assignablerolesothers = null;
    private $_groups = null;
    /**#@-*/

    /**
     * Constructs the course enrolment manager
     *
     * @param moodle_page $moodlepage
     * @param stdClass $course
     * @param string $instancefilter
     * @param int $rolefilter If non-zero, filters to users with specified role
     * @param string $searchfilter If non-blank, filters to users with search text
     */
    public function __construct(moodle_page $moodlepage, $course, $instancefilter = null,
            $rolefilter = 0, $searchfilter = '') {
        $this->moodlepage = $moodlepage;
        $this->context = context_course::instance($course->id);
        $this->course = $course;
        $this->instancefilter = $instancefilter;
        $this->rolefilter = $rolefilter;
        $this->searchfilter = $searchfilter;
    }

    /**
     * Returns the current moodle page
     * @return moodle_page
     */
    public function get_moodlepage() {
        return $this->moodlepage;
    }

    /**
     * Returns the total number of enrolled users in the course.
     *
     * If a filter was specificed this will be the total number of users enrolled
     * in this course by means of that instance.
     *
     * @global moodle_database $DB
     * @return int
     */
    public function get_total_users() {
        global $DB;
        if ($this->totalusers === null) {
            list($instancessql, $params, $filter) = $this->get_instance_sql();
            list($filtersql, $moreparams) = $this->get_filter_sql();
            $params += $moreparams;
            $sqltotal = "SELECT COUNT(DISTINCT u.id)
                           FROM {user} u
                           JOIN {user_enrolments} ue ON (ue.userid = u.id  AND ue.enrolid $instancessql)
                           JOIN {enrol} e ON (e.id = ue.enrolid)
                          WHERE $filtersql";
            $this->totalusers = (int)$DB->count_records_sql($sqltotal, $params);
        }
        return $this->totalusers;
    }

    /**
     * Returns the total number of enrolled users in the course.
     *
     * If a filter was specificed this will be the total number of users enrolled
     * in this course by means of that instance.
     *
     * @global moodle_database $DB
     * @return int
     */
    public function get_total_other_users() {
        global $DB;
        if ($this->totalotherusers === null) {
            list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
            $params['courseid'] = $this->course->id;
            $sql = "SELECT COUNT(DISTINCT u.id)
                      FROM {role_assignments} ra
                      JOIN {user} u ON u.id = ra.userid
                      JOIN {context} ctx ON ra.contextid = ctx.id
                 LEFT JOIN (
                           SELECT ue.id, ue.userid
                             FROM {user_enrolments} ue
                        LEFT JOIN {enrol} e ON e.id=ue.enrolid
                            WHERE e.courseid = :courseid
                         ) ue ON ue.userid=u.id
                     WHERE ctx.id $ctxcondition AND
                           ue.id IS NULL";
            $this->totalotherusers = (int)$DB->count_records_sql($sql, $params);
        }
        return $this->totalotherusers;
    }

    /**
     * Gets all of the users enrolled in this course.
     *
     * If a filter was specified this will be the users who were enrolled
     * in this course by means of that instance. If role or search filters were
     * specified then these will also be applied.
     *
     * @global moodle_database $DB
     * @param string $sort
     * @param string $direction ASC or DESC
     * @param int $page First page should be 0
     * @param int $perpage Defaults to 25
     * @return array
     */
    public function get_users($sort, $direction='ASC', $page=0, $perpage=25) {
        global $DB;
        if ($direction !== 'ASC') {
            $direction = 'DESC';
        }
        $key = md5("$sort-$direction-$page-$perpage");
        if (!array_key_exists($key, $this->users)) {
            list($instancessql, $params, $filter) = $this->get_instance_sql();
            list($filtersql, $moreparams) = $this->get_filter_sql();
            $params += $moreparams;
            $extrafields = get_extra_user_fields($this->get_context());
            $extrafields[] = 'lastaccess';
            $ufields = user_picture::fields('u', $extrafields);
            $sql = "SELECT DISTINCT $ufields, ul.timeaccess AS lastseen
                      FROM {user} u
                      JOIN {user_enrolments} ue ON (ue.userid = u.id  AND ue.enrolid $instancessql)
                      JOIN {enrol} e ON (e.id = ue.enrolid)
                 LEFT JOIN {user_lastaccess} ul ON (ul.courseid = e.courseid AND ul.userid = u.id)
                     WHERE $filtersql";
            if ($sort === 'firstname') {
                $sql .= " ORDER BY u.firstname $direction, u.lastname $direction";
            } else if ($sort === 'lastname') {
                $sql .= " ORDER BY u.lastname $direction, u.firstname $direction";
            } else if ($sort === 'email') {
                $sql .= " ORDER BY u.email $direction, u.lastname $direction, u.firstname $direction";
            } else if ($sort === 'lastseen') {
                $sql .= " ORDER BY ul.timeaccess $direction, u.lastname $direction, u.firstname $direction";
            }
            $this->users[$key] = $DB->get_records_sql($sql, $params, $page*$perpage, $perpage);
        }
        return $this->users[$key];
    }

    /**
     * Obtains WHERE clause to filter results by defined search and role filter
     * (instance filter is handled separately in JOIN clause, see
     * get_instance_sql).
     *
     * @return array Two-element array with SQL and params for WHERE clause
     */
    protected function get_filter_sql() {
        global $DB;

        // Search condition.
        $extrafields = get_extra_user_fields($this->get_context());
        list($sql, $params) = users_search_sql($this->searchfilter, 'u', true, $extrafields);

        // Role condition.
        if ($this->rolefilter) {
            // Get context SQL.
            $contextids = $this->context->get_parent_context_ids();
            $contextids[] = $this->context->id;
            list($contextsql, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
            $params += $contextparams;

            // Role check condition.
            $sql .= " AND (SELECT COUNT(1) FROM {role_assignments} ra WHERE ra.userid = u.id " .
                    "AND ra.roleid = :roleid AND ra.contextid $contextsql) > 0";
            $params['roleid'] = $this->rolefilter;
        }

        return array($sql, $params);
    }

    /**
     * Gets and array of other users.
     *
     * Other users are users who have been assigned roles or inherited roles
     * within this course but who have not been enrolled in the course
     *
     * @global moodle_database $DB
     * @param string $sort
     * @param string $direction
     * @param int $page
     * @param int $perpage
     * @return array
     */
    public function get_other_users($sort, $direction='ASC', $page=0, $perpage=25) {
        global $DB;
        if ($direction !== 'ASC') {
            $direction = 'DESC';
        }
        $key = md5("$sort-$direction-$page-$perpage");
        if (!array_key_exists($key, $this->otherusers)) {
            list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
            $params['courseid'] = $this->course->id;
            $params['cid'] = $this->course->id;
            $sql = "SELECT ra.id as raid, ra.contextid, ra.component, ctx.contextlevel, ra.roleid, u.*, ue.lastseen
                    FROM {role_assignments} ra
                    JOIN {user} u ON u.id = ra.userid
                    JOIN {context} ctx ON ra.contextid = ctx.id
               LEFT JOIN (
                       SELECT ue.id, ue.userid, ul.timeaccess AS lastseen
                         FROM {user_enrolments} ue
                    LEFT JOIN {enrol} e ON e.id=ue.enrolid
                    LEFT JOIN {user_lastaccess} ul ON (ul.courseid = e.courseid AND ul.userid = ue.userid)
                        WHERE e.courseid = :courseid
                       ) ue ON ue.userid=u.id
                   WHERE ctx.id $ctxcondition AND
                         ue.id IS NULL
                ORDER BY u.$sort $direction, ctx.depth DESC";
            $this->otherusers[$key] = $DB->get_records_sql($sql, $params, $page*$perpage, $perpage);
        }
        return $this->otherusers[$key];
    }

    /**
     * Helper method used by {@link get_potential_users()} and {@link search_other_users()}.
     *
     * @param string $search the search term, if any.
     * @param bool $searchanywhere Can the search term be anywhere, or must it be at the start.
     * @return array with three elements:
     *     string list of fields to SELECT,
     *     string contents of SQL WHERE clause,
     *     array query params. Note that the SQL snippets use named parameters.
     */
    protected function get_basic_search_conditions($search, $searchanywhere) {
        global $DB, $CFG;

        // Add some additional sensible conditions
        $tests = array("u.id <> :guestid", 'u.deleted = 0', 'u.confirmed = 1');
        $params = array('guestid' => $CFG->siteguest);
        if (!empty($search)) {
            $conditions = get_extra_user_fields($this->get_context());
            $conditions[] = 'u.firstname';
            $conditions[] = 'u.lastname';
            $conditions[] = $DB->sql_fullname('u.firstname', 'u.lastname');
            if ($searchanywhere) {
                $searchparam = '%' . $search . '%';
            } else {
                $searchparam = $search . '%';
            }
            $i = 0;
            foreach ($conditions as $key => $condition) {
                $conditions[$key] = $DB->sql_like($condition, ":con{$i}00", false);
                $params["con{$i}00"] = $searchparam;
                $i++;
            }
            $tests[] = '(' . implode(' OR ', $conditions) . ')';
        }
        $wherecondition = implode(' AND ', $tests);

        $extrafields = get_extra_user_fields($this->get_context(), array('username', 'lastaccess'));
        $extrafields[] = 'username';
        $extrafields[] = 'lastaccess';
        $ufields = user_picture::fields('u', $extrafields);

        return array($ufields, $params, $wherecondition);
    }

    /**
     * Helper method used by {@link get_potential_users()} and {@link search_other_users()}.
     *
     * @param string $search the search string, if any.
     * @param string $fields the first bit of the SQL when returning some users.
     * @param string $countfields fhe first bit of the SQL when counting the users.
     * @param string $sql the bulk of the SQL statement.
     * @param array $params query parameters.
     * @param int $page which page number of the results to show.
     * @param int $perpage number of users per page.
     * @param int $addedenrollment number of users added to enrollment.
     * @return array with two elememts:
     *      int total number of users matching the search.
     *      array of user objects returned by the query.
     */
    protected function execute_search_queries($search, $fields, $countfields, $sql, array $params, $page, $perpage, $addedenrollment=0) {
        global $DB, $CFG;

        list($sort, $sortparams) = users_order_by_sql('u', $search, $this->get_context());
        $order = ' ORDER BY ' . $sort;

        $totalusers = $DB->count_records_sql($countfields . $sql, $params);
        $availableusers = $DB->get_records_sql($fields . $sql . $order,
                array_merge($params, $sortparams), ($page*$perpage) - $addedenrollment, $perpage);

        return array('totalusers' => $totalusers, 'users' => $availableusers);
    }

    /**
     * Gets an array of the users that can be enrolled in this course.
     *
     * @global moodle_database $DB
     * @param int $enrolid
     * @param string $search
     * @param bool $searchanywhere
     * @param int $page Defaults to 0
     * @param int $perpage Defaults to 25
     * @param int $addedenrollment Defaults to 0
     * @return array Array(totalusers => int, users => array)
     */
    public function get_potential_users($enrolid, $search='', $searchanywhere=false, $page=0, $perpage=25, $addedenrollment=0) {
        global $DB;

        list($ufields, $params, $wherecondition) = $this->get_basic_search_conditions($search, $searchanywhere);

        $fields      = 'SELECT '.$ufields;
        $countfields = 'SELECT COUNT(1)';
        $sql = " FROM {user} u
            LEFT JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid = :enrolid)
                WHERE $wherecondition
                      AND ue.id IS NULL";
        $params['enrolid'] = $enrolid;

        return $this->execute_search_queries($search, $fields, $countfields, $sql, $params, $page, $perpage, $addedenrollment);
    }

    /**
     * Searches other users and returns paginated results
     *
     * @global moodle_database $DB
     * @param string $search
     * @param bool $searchanywhere
     * @param int $page Starting at 0
     * @param int $perpage
     * @return array
     */
    public function search_other_users($search='', $searchanywhere=false, $page=0, $perpage=25) {
        global $DB, $CFG;

        list($ufields, $params, $wherecondition) = $this->get_basic_search_conditions($search, $searchanywhere);

        $fields      = 'SELECT ' . $ufields;
        $countfields = 'SELECT COUNT(u.id)';
        $sql   = " FROM {user} u
              LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid = :contextid)
                  WHERE $wherecondition
                    AND ra.id IS NULL";
        $params['contextid'] = $this->context->id;

        return $this->execute_search_queries($search, $fields, $countfields, $sql, $params, $page, $perpage);
    }

    /**
     * Gets an array containing some SQL to user for when selecting, params for
     * that SQL, and the filter that was used in constructing the sql.
     *
     * @global moodle_database $DB
     * @return string
     */
    protected function get_instance_sql() {
        global $DB;
        if ($this->_instancessql === null) {
            $instances = $this->get_enrolment_instances();
            $filter = $this->get_enrolment_filter();
            if ($filter && array_key_exists($filter, $instances)) {
                $sql = " = :ifilter";
                $params = array('ifilter'=>$filter);
            } else {
                $filter = 0;
                if ($instances) {
                    list($sql, $params) = $DB->get_in_or_equal(array_keys($this->get_enrolment_instances()), SQL_PARAMS_NAMED);
                } else {
                    // no enabled instances, oops, we should probably say something
                    $sql = "= :never";
                    $params = array('never'=>-1);
                }
            }
            $this->instancefilter = $filter;
            $this->_instancessql = array($sql, $params, $filter);
        }
        return $this->_instancessql;
    }

    /**
     * Returns all of the enrolment instances for this course.
     *
     * NOTE: since 2.4 it includes instances of disabled plugins too.
     *
     * @return array
     */
    public function get_enrolment_instances() {
        if ($this->_instances === null) {
            $this->_instances = enrol_get_instances($this->course->id, false);
        }
        return $this->_instances;
    }

    /**
     * Returns the names for all of the enrolment instances for this course.
     *
     * NOTE: since 2.4 it includes instances of disabled plugins too.
     *
     * @return array
     */
    public function get_enrolment_instance_names() {
        if ($this->_inames === null) {
            $instances = $this->get_enrolment_instances();
            $plugins = $this->get_enrolment_plugins(false);
            foreach ($instances as $key=>$instance) {
                if (!isset($plugins[$instance->enrol])) {
                    // weird, some broken stuff in plugin
                    unset($instances[$key]);
                    continue;
                }
                $this->_inames[$key] = $plugins[$instance->enrol]->get_instance_name($instance);
            }
        }
        return $this->_inames;
    }

    /**
     * Gets all of the enrolment plugins that are active for this course.
     *
     * @param bool $onlyenabled return only enabled enrol plugins
     * @return array
     */
    public function get_enrolment_plugins($onlyenabled = true) {
        if ($this->_plugins === null) {
            $this->_plugins = enrol_get_plugins(true);
        }

        if ($onlyenabled) {
            return $this->_plugins;
        }

        if ($this->_allplugins === null) {
            // Make sure we have the same objects in _allplugins and _plugins.
            $this->_allplugins = $this->_plugins;
            foreach (enrol_get_plugins(false) as $name=>$plugin) {
                if (!isset($this->_allplugins[$name])) {
                    $this->_allplugins[$name] = $plugin;
                }
            }
        }

        return $this->_allplugins;
    }

    /**
     * Gets all of the roles this course can contain.
     *
     * @return array
     */
    public function get_all_roles() {
        if ($this->_roles === null) {
            $this->_roles = role_fix_names(get_all_roles($this->context), $this->context);
        }
        return $this->_roles;
    }

    /**
     * Gets all of the assignable roles for this course.
     *
     * @return array
     */
    public function get_assignable_roles($otherusers = false) {
        if ($this->_assignableroles === null) {
            $this->_assignableroles = get_assignable_roles($this->context, ROLENAME_ALIAS, false); // verifies unassign access control too
        }

        if ($otherusers) {
            if (!is_array($this->_assignablerolesothers)) {
                $this->_assignablerolesothers = array();
                list($courseviewroles, $ignored) = get_roles_with_cap_in_context($this->context, 'moodle/course:view');
                foreach ($this->_assignableroles as $roleid=>$role) {
                    if (isset($courseviewroles[$roleid])) {
                        $this->_assignablerolesothers[$roleid] = $role;
                    }
                }
            }
            return $this->_assignablerolesothers;
        } else {
            return $this->_assignableroles;
        }
    }

    /**
     * Gets all of the groups for this course.
     *
     * @return array
     */
    public function get_all_groups() {
        if ($this->_groups === null) {
            $this->_groups = groups_get_all_groups($this->course->id);
            foreach ($this->_groups as $gid=>$group) {
                $this->_groups[$gid]->name = format_string($group->name);
            }
        }
        return $this->_groups;
    }

    /**
     * Unenrols a user from the course given the users ue entry
     *
     * @global moodle_database $DB
     * @param stdClass $ue
     * @return bool
     */
    public function unenrol_user($ue) {
        global $DB;
        list ($instance, $plugin) = $this->get_user_enrolment_components($ue);
        if ($instance && $plugin && $plugin->allow_unenrol_user($instance, $ue) && has_capability("enrol/$instance->enrol:unenrol", $this->context)) {
            $plugin->unenrol_user($instance, $ue->userid);
            return true;
        }
        return false;
    }

    /**
     * Given a user enrolment record this method returns the plugin and enrolment
     * instance that relate to it.
     *
     * @param stdClass|int $userenrolment
     * @return array array($instance, $plugin)
     */
    public function get_user_enrolment_components($userenrolment) {
        global $DB;
        if (is_numeric($userenrolment)) {
            $userenrolment = $DB->get_record('user_enrolments', array('id'=>(int)$userenrolment));
        }
        $instances = $this->get_enrolment_instances();
        $plugins = $this->get_enrolment_plugins(false);
        if (!$userenrolment || !isset($instances[$userenrolment->enrolid])) {
            return array(false, false);
        }
        $instance = $instances[$userenrolment->enrolid];
        $plugin = $plugins[$instance->enrol];
        return array($instance, $plugin);
    }

    /**
     * Removes an assigned role from a user.
     *
     * @global moodle_database $DB
     * @param int $userid
     * @param int $roleid
     * @return bool
     */
    public function unassign_role_from_user($userid, $roleid) {
        global $DB;
        // Admins may unassign any role, others only those they could assign.
        if (!is_siteadmin() and !array_key_exists($roleid, $this->get_assignable_roles())) {
            if (defined('AJAX_SCRIPT')) {
                throw new moodle_exception('invalidrole');
            }
            return false;
        }
        $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
        $ras = $DB->get_records('role_assignments', array('contextid'=>$this->context->id, 'userid'=>$user->id, 'roleid'=>$roleid));
        foreach ($ras as $ra) {
            if ($ra->component) {
                if (strpos($ra->component, 'enrol_') !== 0) {
                    continue;
                }
                if (!$plugin = enrol_get_plugin(substr($ra->component, 6))) {
                    continue;
                }
                if ($plugin->roles_protected()) {
                    continue;
                }
            }
            role_unassign($ra->roleid, $ra->userid, $ra->contextid, $ra->component, $ra->itemid);
        }
        return true;
    }

    /**
     * Assigns a role to a user.
     *
     * @param int $roleid
     * @param int $userid
     * @return int|false
     */
    public function assign_role_to_user($roleid, $userid) {
        require_capability('moodle/role:assign', $this->context);
        if (!array_key_exists($roleid, $this->get_assignable_roles())) {
            if (defined('AJAX_SCRIPT')) {
                throw new moodle_exception('invalidrole');
            }
            return false;
        }
        return role_assign($roleid, $userid, $this->context->id, '', NULL);
    }

    /**
     * Adds a user to a group
     *
     * @param stdClass $user
     * @param int $groupid
     * @return bool
     */
    public function add_user_to_group($user, $groupid) {
        require_capability('moodle/course:managegroups', $this->context);
        $group = $this->get_group($groupid);
        if (!$group) {
            return false;
        }
        return groups_add_member($group->id, $user->id);
    }

    /**
     * Removes a user from a group
     *
     * @global moodle_database $DB
     * @param StdClass $user
     * @param int $groupid
     * @return bool
     */
    public function remove_user_from_group($user, $groupid) {
        global $DB;
        require_capability('moodle/course:managegroups', $this->context);
        $group = $this->get_group($groupid);
        if (!groups_remove_member_allowed($group, $user)) {
            return false;
        }
        if (!$group) {
            return false;
        }
        return groups_remove_member($group, $user);
    }

    /**
     * Gets the requested group
     *
     * @param int $groupid
     * @return stdClass|int
     */
    public function get_group($groupid) {
        $groups = $this->get_all_groups();
        if (!array_key_exists($groupid, $groups)) {
            return false;
        }
        return $groups[$groupid];
    }

    /**
     * Edits an enrolment
     *
     * @param stdClass $userenrolment
     * @param stdClass $data
     * @return bool
     */
    public function edit_enrolment($userenrolment, $data) {
        //Only allow editing if the user has the appropriate capability
        //Already checked in /enrol/users.php but checking again in case this function is called from elsewhere
        list($instance, $plugin) = $this->get_user_enrolment_components($userenrolment);
        if ($instance && $plugin && $plugin->allow_manage($instance) && has_capability("enrol/$instance->enrol:manage", $this->context)) {
            if (!isset($data->status)) {
                $data->status = $userenrolment->status;
            }
            $plugin->update_user_enrol($instance, $userenrolment->userid, $data->status, $data->timestart, $data->timeend);
            return true;
        }
        return false;
    }

    /**
     * Returns the current enrolment filter that is being applied by this class
     * @return string
     */
    public function get_enrolment_filter() {
        return $this->instancefilter;
    }

    /**
     * Gets the roles assigned to this user that are applicable for this course.
     *
     * @param int $userid
     * @return array
     */
    public function get_user_roles($userid) {
        $roles = array();
        $ras = get_user_roles($this->context, $userid, true, 'c.contextlevel DESC, r.sortorder ASC');
        $plugins = $this->get_enrolment_plugins(false);
        foreach ($ras as $ra) {
            if ($ra->contextid != $this->context->id) {
                if (!array_key_exists($ra->roleid, $roles)) {
                    $roles[$ra->roleid] = null;
                }
                // higher ras, course always takes precedence
                continue;
            }
            if (array_key_exists($ra->roleid, $roles) && $roles[$ra->roleid] === false) {
                continue;
            }
            $changeable = true;
            if ($ra->component) {
                $changeable = false;
                if (strpos($ra->component, 'enrol_') === 0) {
                    $plugin = substr($ra->component, 6);
                    if (isset($plugins[$plugin])) {
                        $changeable = !$plugins[$plugin]->roles_protected();
                    }
                }
            }

            $roles[$ra->roleid] = $changeable;
        }
        return $roles;
    }

    /**
     * Gets the enrolments this user has in the course - including all suspended plugins and instances.
     *
     * @global moodle_database $DB
     * @param int $userid
     * @return array
     */
    public function get_user_enrolments($userid) {
        global $DB;
        list($instancessql, $params, $filter) = $this->get_instance_sql();
        $params['userid'] = $userid;
        $userenrolments = $DB->get_records_select('user_enrolments', "enrolid $instancessql AND userid = :userid", $params);
        $instances = $this->get_enrolment_instances();
        $plugins = $this->get_enrolment_plugins(false);
        $inames = $this->get_enrolment_instance_names();
        foreach ($userenrolments as &$ue) {
            $ue->enrolmentinstance     = $instances[$ue->enrolid];
            $ue->enrolmentplugin       = $plugins[$ue->enrolmentinstance->enrol];
            $ue->enrolmentinstancename = $inames[$ue->enrolmentinstance->id];
        }
        return $userenrolments;
    }

    /**
     * Gets the groups this user belongs to
     *
     * @param int $userid
     * @return array
     */
    public function get_user_groups($userid) {
        return groups_get_all_groups($this->course->id, $userid, 0, 'g.id');
    }

    /**
     * Retursn an array of params that would go into the URL to return to this
     * exact page.
     *
     * @return array
     */
    public function get_url_params() {
        $args = array(
            'id' => $this->course->id
        );
        if (!empty($this->instancefilter)) {
            $args['ifilter'] = $this->instancefilter;
        }
        if (!empty($this->rolefilter)) {
            $args['role'] = $this->rolefilter;
        }
        if ($this->searchfilter !== '') {
            $args['search'] = $this->searchfilter;
        }
        return $args;
    }

    /**
     * Returns the course this object is managing enrolments for
     *
     * @return stdClass
     */
    public function get_course() {
        return $this->course;
    }

    /**
     * Returns the course context
     *
     * @return stdClass
     */
    public function get_context() {
        return $this->context;
    }

    /**
     * Gets an array of other users in this course ready for display.
     *
     * Other users are users who have been assigned or inherited roles within this
     * course but have not been enrolled.
     *
     * @param core_enrol_renderer $renderer
     * @param moodle_url $pageurl
     * @param string $sort
     * @param string $direction ASC | DESC
     * @param int $page Starting from 0
     * @param int $perpage
     * @return array
     */
    public function get_other_users_for_display(core_enrol_renderer $renderer, moodle_url $pageurl, $sort, $direction, $page, $perpage) {

        $userroles = $this->get_other_users($sort, $direction, $page, $perpage);
        $roles = $this->get_all_roles();
        $plugins = $this->get_enrolment_plugins(false);

        $context    = $this->get_context();
        $now = time();
        $extrafields = get_extra_user_fields($context);

        $users = array();
        foreach ($userroles as $userrole) {
            $contextid = $userrole->contextid;
            unset($userrole->contextid); // This would collide with user avatar.
            if (!array_key_exists($userrole->id, $users)) {
                $users[$userrole->id] = $this->prepare_user_for_display($userrole, $extrafields, $now);
            }
            $a = new stdClass;
            $a->role = $roles[$userrole->roleid]->localname;
            if ($contextid == $this->context->id) {
                $changeable = true;
                if ($userrole->component) {
                    $changeable = false;
                    if (strpos($userrole->component, 'enrol_') === 0) {
                        $plugin = substr($userrole->component, 6);
                        if (isset($plugins[$plugin])) {
                            $changeable = !$plugins[$plugin]->roles_protected();
                        }
                    }
                }
                $roletext = get_string('rolefromthiscourse', 'enrol', $a);
            } else {
                $changeable = false;
                switch ($userrole->contextlevel) {
                    case CONTEXT_COURSE :
                        // Meta course
                        $roletext = get_string('rolefrommetacourse', 'enrol', $a);
                        break;
                    case CONTEXT_COURSECAT :
                        $roletext = get_string('rolefromcategory', 'enrol', $a);
                        break;
                    case CONTEXT_SYSTEM:
                    default:
                        $roletext = get_string('rolefromsystem', 'enrol', $a);
                        break;
                }
            }
            if (!isset($users[$userrole->id]['roles'])) {
                $users[$userrole->id]['roles'] = array();
            }
            $users[$userrole->id]['roles'][$userrole->roleid] = array(
                'text' => $roletext,
                'unchangeable' => !$changeable
            );
        }
        return $users;
    }

    /**
     * Gets an array of users for display, this includes minimal user information
     * as well as minimal information on the users roles, groups, and enrolments.
     *
     * @param core_enrol_renderer $renderer
     * @param moodle_url $pageurl
     * @param int $sort
     * @param string $direction ASC or DESC
     * @param int $page
     * @param int $perpage
     * @return array
     */
    public function get_users_for_display(course_enrolment_manager $manager, $sort, $direction, $page, $perpage) {
        $pageurl = $manager->get_moodlepage()->url;
        $users = $this->get_users($sort, $direction, $page, $perpage);

        $now = time();
        $straddgroup = get_string('addgroup', 'group');
        $strunenrol = get_string('unenrol', 'enrol');
        $stredit = get_string('edit');

        $allroles   = $this->get_all_roles();
        $assignable = $this->get_assignable_roles();
        $allgroups  = $this->get_all_groups();
        $context    = $this->get_context();
        $canmanagegroups = has_capability('moodle/course:managegroups', $context);

        $url = new moodle_url($pageurl, $this->get_url_params());
        $extrafields = get_extra_user_fields($context);

        $enabledplugins = $this->get_enrolment_plugins(true);

        $userdetails = array();
        foreach ($users as $user) {
            $details = $this->prepare_user_for_display($user, $extrafields, $now);

            // Roles
            $details['roles'] = array();
            foreach ($this->get_user_roles($user->id) as $rid=>$rassignable) {
                $unchangeable = !$rassignable;
                if (!is_siteadmin() and !isset($assignable[$rid])) {
                    $unchangeable = true;
                }
                $details['roles'][$rid] = array('text'=>$allroles[$rid]->localname, 'unchangeable'=>$unchangeable);
            }

            // Users
            $usergroups = $this->get_user_groups($user->id);
            $details['groups'] = array();
            foreach($usergroups as $gid=>$unused) {
                $details['groups'][$gid] = $allgroups[$gid]->name;
            }

            // Enrolments
            $details['enrolments'] = array();
            foreach ($this->get_user_enrolments($user->id) as $ue) {
                if (!isset($enabledplugins[$ue->enrolmentinstance->enrol])) {
                    $details['enrolments'][$ue->id] = array(
                        'text' => $ue->enrolmentinstancename,
                        'period' => null,
                        'dimmed' =>  true,
                        'actions' => array()
                    );
                    continue;
                } else if ($ue->timestart and $ue->timeend) {
                    $period = get_string('periodstartend', 'enrol', array('start'=>userdate($ue->timestart), 'end'=>userdate($ue->timeend)));
                    $periodoutside = ($ue->timestart && $ue->timeend && $now < $ue->timestart && $now > $ue->timeend);
                } else if ($ue->timestart) {
                    $period = get_string('periodstart', 'enrol', userdate($ue->timestart));
                    $periodoutside = ($ue->timestart && $now < $ue->timestart);
                } else if ($ue->timeend) {
                    $period = get_string('periodend', 'enrol', userdate($ue->timeend));
                    $periodoutside = ($ue->timeend && $now > $ue->timeend);
                } else {
                    // If there is no start or end show when user was enrolled.
                    $period = get_string('periodnone', 'enrol', userdate($ue->timecreated));
                    $periodoutside = false;
                }
                $details['enrolments'][$ue->id] = array(
                    'text' => $ue->enrolmentinstancename,
                    'period' => $period,
                    'dimmed' =>  ($periodoutside or $ue->status != ENROL_USER_ACTIVE or $ue->enrolmentinstance->status != ENROL_INSTANCE_ENABLED),
                    'actions' => $ue->enrolmentplugin->get_user_enrolment_actions($manager, $ue)
                );
            }
            $userdetails[$user->id] = $details;
        }
        return $userdetails;
    }

    /**
     * Prepare a user record for display
     *
     * This function is called by both {@link get_users_for_display} and {@link get_other_users_for_display} to correctly
     * prepare user fields for display
     *
     * Please note that this function does not check capability for moodle/coures:viewhiddenuserfields
     *
     * @param object $user The user record
     * @param array $extrafields The list of fields as returned from get_extra_user_fields used to determine which
     * additional fields may be displayed
     * @param int $now The time used for lastaccess calculation
     * @return array The fields to be displayed including userid, courseid, picture, firstname, lastseen and any
     * additional fields from $extrafields
     */
    private function prepare_user_for_display($user, $extrafields, $now) {
        $details = array(
            'userid'    => $user->id,
            'courseid'  => $this->get_course()->id,
            'picture'   => new user_picture($user),
            'firstname' => fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context())),
            'lastseen'  => get_string('never'),
        );
        foreach ($extrafields as $field) {
            $details[$field] = $user->{$field};
        }

        if ($user->lastaccess) {
            $details['lastseen'] = format_time($now - $user->lastaccess);
        }
        return $details;
    }

    public function get_manual_enrol_buttons() {
        $plugins = $this->get_enrolment_plugins(true); // Skip disabled plugins.
        $buttons = array();
        foreach ($plugins as $plugin) {
            $newbutton = $plugin->get_manual_enrol_button($this);
            if (is_array($newbutton)) {
                $buttons += $newbutton;
            } else if ($newbutton instanceof enrol_user_button) {
                $buttons[] = $newbutton;
            }
        }
        return $buttons;
    }

    public function has_instance($enrolpluginname) {
        // Make sure manual enrolments instance exists
        foreach ($this->get_enrolment_instances() as $instance) {
            if ($instance->enrol == $enrolpluginname) {
                return true;
            }
        }
        return false;
    }

    /**
     * Returns the enrolment plugin that the course manager was being filtered to.
     *
     * If no filter was being applied then this function returns false.
     *
     * @return enrol_plugin
     */
    public function get_filtered_enrolment_plugin() {
        $instances = $this->get_enrolment_instances();
        $plugins = $this->get_enrolment_plugins(false);

        if (empty($this->instancefilter) || !array_key_exists($this->instancefilter, $instances)) {
            return false;
        }

        $instance = $instances[$this->instancefilter];
        return $plugins[$instance->enrol];
    }

    /**
     * Returns and array of users + enrolment details.
     *
     * Given an array of user id's this function returns and array of user enrolments for those users
     * as well as enough user information to display the users name and picture for each enrolment.
     *
     * @global moodle_database $DB
     * @param array $userids
     * @return array
     */
    public function get_users_enrolments(array $userids) {
        global $DB;

        $instances = $this->get_enrolment_instances();
        $plugins = $this->get_enrolment_plugins(false);

        if  (!empty($this->instancefilter)) {
            $instancesql = ' = :instanceid';
            $instanceparams = array('instanceid' => $this->instancefilter);
        } else {
            list($instancesql, $instanceparams) = $DB->get_in_or_equal(array_keys($instances), SQL_PARAMS_NAMED, 'instanceid0000');
        }

        $userfields = user_picture::fields('u');
        list($idsql, $idparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED, 'userid0000');

        list($sort, $sortparams) = users_order_by_sql('u');

        $sql = "SELECT ue.id AS ueid, ue.status, ue.enrolid, ue.userid, ue.timestart, ue.timeend, ue.modifierid, ue.timecreated, ue.timemodified, $userfields
                  FROM {user_enrolments} ue
             LEFT JOIN {user} u ON u.id = ue.userid
                 WHERE ue.enrolid $instancesql AND
                       u.id $idsql
              ORDER BY $sort";

        $rs = $DB->get_recordset_sql($sql, $idparams + $instanceparams + $sortparams);
        $users = array();
        foreach ($rs as $ue) {
            $user = user_picture::unalias($ue);
            $ue->id = $ue->ueid;
            unset($ue->ueid);
            if (!array_key_exists($user->id, $users)) {
                $user->enrolments = array();
                $users[$user->id] = $user;
            }
            $ue->enrolmentinstance = $instances[$ue->enrolid];
            $ue->enrolmentplugin = $plugins[$ue->enrolmentinstance->enrol];
            $users[$user->id]->enrolments[$ue->id] = $ue;
        }
        $rs->close();
        return $users;
    }
}

/**
 * A button that is used to enrol users in a course
 *
 * @copyright 2010 Sam Hemelryk
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
class enrol_user_button extends single_button {

    /**
     * An array containing JS YUI modules required by this button
     * @var array
     */
    protected $jsyuimodules = array();

    /**
     * An array containing JS initialisation calls required by this button
     * @var array
     */
    protected $jsinitcalls = array();

    /**
     * An array strings required by JS for this button
     * @var array
     */
    protected $jsstrings = array();

    /**
     * Initialises the new enrol_user_button
     *
     * @staticvar int $count The number of enrol user buttons already created
     * @param moodle_url $url
     * @param string $label The text to display in the button
     * @param string $method Either post or get
     */
    public function __construct(moodle_url $url, $label, $method = 'post') {
        static $count = 0;
        $count ++;
        parent::__construct($url, $label, $method);
        $this->class = 'singlebutton enrolusersbutton';
        $this->formid = 'enrolusersbutton-'.$count;
    }

    /**
     * Adds a YUI module call that will be added to the page when the button is used.
     *
     * @param string|array $modules One or more modules to require
     * @param string $function The JS function to call
     * @param array $arguments An array of arguments to pass to the function
     * @param string $galleryversion The YUI gallery version of any modules required
     * @param bool $ondomready If true the call is postponed until the DOM is finished loading
     */
    public function require_yui_module($modules, $function, array $arguments = null, $galleryversion = '2010.04.08-12-35', $ondomready = false) {
        $js = new stdClass;
        $js->modules = (array)$modules;
        $js->function = $function;
        $js->arguments = $arguments;
        $js->galleryversion = $galleryversion;
        $js->ondomready = $ondomready;
        $this->jsyuimodules[] = $js;
    }

    /**
     * Adds a JS initialisation call to the page when the button is used.
     *
     * @param string $function The function to call
     * @param array $extraarguments An array of arguments to pass to the function
     * @param bool $ondomready If true the call is postponed until the DOM is finished loading
     * @param array $module A module definition
     */
    public function require_js_init_call($function, array $extraarguments = null, $ondomready = false, array $module = null) {
        $js = new stdClass;
        $js->function = $function;
        $js->extraarguments = $extraarguments;
        $js->ondomready = $ondomready;
        $js->module = $module;
        $this->jsinitcalls[] = $js;
    }

    /**
     * Requires strings for JS that will be loaded when the button is used.
     *
     * @param type $identifiers
     * @param string $component
     * @param mixed $a
     */
    public function strings_for_js($identifiers, $component = 'moodle', $a = null) {
        $string = new stdClass;
        $string->identifiers = (array)$identifiers;
        $string->component = $component;
        $string->a = $a;
        $this->jsstrings[] = $string;
    }

    /**
     * Initialises the JS that is required by this button
     *
     * @param moodle_page $page
     */
    public function initialise_js(moodle_page $page) {
        foreach ($this->jsyuimodules as $js) {
            $page->requires->yui_module($js->modules, $js->function, $js->arguments, $js->galleryversion, $js->ondomready);
        }
        foreach ($this->jsinitcalls as $js) {
            $page->requires->js_init_call($js->function, $js->extraarguments, $js->ondomready, $js->module);
        }
        foreach ($this->jsstrings as $string) {
            $page->requires->strings_for_js($string->identifiers, $string->component, $string->a);
        }
    }
}

/**
 * User enrolment action
 *
 * This class is used to manage a renderable ue action such as editing an user enrolment or deleting
 * a user enrolment.
 *
 * @copyright  2011 Sam Hemelryk
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
class user_enrolment_action implements renderable {

    /**
     * The icon to display for the action
     * @var pix_icon
     */
    protected $icon;

    /**
     * The title for the action
     * @var string
     */
    protected $title;

    /**
     * The URL to the action
     * @var moodle_url
     */
    protected $url;

    /**
     * An array of HTML attributes
     * @var array
     */
    protected $attributes = array();

    /**
     * Constructor
     * @param pix_icon $icon
     * @param string $title
     * @param moodle_url $url
     * @param array $attributes
     */
    public function __construct(pix_icon $icon, $title, $url, array $attributes = null) {
        $this->icon = $icon;
        $this->title = $title;
        $this->url = new moodle_url($url);
        if (!empty($attributes)) {
            $this->attributes = $attributes;
        }
        $this->attributes['title'] = $title;
    }

    /**
     * Returns the icon for this action
     * @return pix_icon
     */
    public function get_icon() {
        return $this->icon;
    }

    /**
     * Returns the title for this action
     * @return string
     */
    public function get_title() {
        return $this->title;
    }

    /**
     * Returns the URL for this action
     * @return moodle_url
     */
    public function get_url() {
        return $this->url;
    }

    /**
     * Returns the attributes to use for this action
     * @return array
     */
    public function get_attributes() {
        return $this->attributes;
    }
}

class enrol_ajax_exception extends moodle_exception {
    /**
     * Constructor
     * @param string $errorcode The name of the string from error.php to print
     * @param string $module name of module
     * @param string $link The url where the user will be prompted to continue. If no url is provided the user will be directed to the site index page.
     * @param object $a Extra words and phrases that might be required in the error string
     * @param string $debuginfo optional debugging information
     */
    public function __construct($errorcode, $link = '', $a = NULL, $debuginfo = null) {
        parent::__construct($errorcode, 'enrol', $link, $a, $debuginfo);
    }
}

/**
 * This class is used to manage a bulk operations for enrolment plugins.
 *
 * @copyright 2011 Sam Hemelryk
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
abstract class enrol_bulk_enrolment_operation {

    /**
     * The course enrolment manager
     * @var course_enrolment_manager
     */
    protected $manager;

    /**
     * The enrolment plugin to which this operation belongs
     * @var enrol_plugin
     */
    protected $plugin;

    /**
     * Contructor
     * @param course_enrolment_manager $manager
     * @param stdClass $plugin
     */
    public function __construct(course_enrolment_manager $manager, enrol_plugin $plugin = null) {
        $this->manager = $manager;
        $this->plugin = $plugin;
    }

    /**
     * Returns a moodleform used for this operation, or false if no form is required and the action
     * should be immediatly processed.
     *
     * @param moodle_url|string $defaultaction
     * @param mixed $defaultcustomdata
     * @return enrol_bulk_enrolment_change_form|moodleform|false
     */
    public function get_form($defaultaction = null, $defaultcustomdata = null) {
        return false;
    }

    /**
     * Returns the title to use for this bulk operation
     *
     * @return string
     */
    abstract public function get_title();

    /**
     * Returns the identifier for this bulk operation.
     * This should be the same identifier used by the plugins function when returning
     * all of its bulk operations.
     *
     * @return string
     */
    abstract public function get_identifier();

    /**
     * Processes the bulk operation on the given users
     *
     * @param course_enrolment_manager $manager
     * @param array $users
     * @param stdClass $properties
     */
    abstract public function process(course_enrolment_manager $manager, array $users, stdClass $properties);
}

redpajama_set_name: RedPajamaGithub


text:
Five reasons why Melt should be your festival of choice this summer
Words: Andrew Hannah / 09 April 2018, 09:00 BST
If you like your music with a healthy amount of cranes, rusting industrial machines and sleepless nights then we've got the perfect summer trip for you, somewhere south of Berlin. Welcome to Melt Festival.
Twenty years after it started as a gathering for techno-heads, various locations later, Germany's Melt Festival found its permanent home in the futuristic metal dystopia of Ferropolis.
Mixing its hard-dancing techno roots with some of the biggest names from the indie and hip hop worlds, Melt Festival strikes us as one of the few festivals out there that truly appeals to all types of music fan. We've delved into the lineup to bring you the stellar highlights and hidden gems to look forward to in July.
The Comeback Queen
One name sticks out like a sore, flame-haired thumb on the lineup...and that's Florence and the Machine. It's only three years since How Big, How Blue, How Beautiful but three years is a long time in an industry that changes more than ever before. In that time Florence Welch has kept a very low profile but with a track in place for Record Store Day, she's reactivating Florence just in time for some festival shows.
There's no middle ground when it comes to Florence. Welch gives everything at every show, and with a voice so powerful it could keep the main stage plus stages further afield occupied there's little doubt that this could be THE summer '18 comeback.
The Banned List
It's a few summers now since then-Home Secretary Theresa May banned Tyler, The Creator from entering the UK due to his potential visits and shows being "not conducive to the public good." In the intervening period the only way to see the US rapper has been to visit the States or somewhere in Europe, and so his appearance on the Melt lineup means it's an immediate hook for any of Tyler's British fans.
Following Flower Boy there has been something of a tentative reappraisal of Tyler, and the artist himself regrets the violent, homophobic and intolerant lyrics of his Odd Future early days. Now happy to discuss his sexuality - however cryptically - he cuts a penitent figure yet it remains hard not to label him as "problematic".
What's never been in doubt is the incendiary nature of Tyler's live shows. The fire and passion of one of modern rap's greatest lyricists and MCs which we first discovered as part of Odd Future has not abated in the intervening years and any Tyler show is likely to be one of the most memorable of the weekend.
A Queer Healing
Karen Dreijer's return as Fever Ray has been a spectacular success. Plunge was a celebration of queerness, sex and sexuality, S&M, body horror and so much more.
The Swede also returned to live shows, recasting the songs from Plunge in a bawdy, colourful, camp and sexy showcase featuring dancers, ridiculous costumes and a carnival atmosphere.
The thought of seeing this on the main stage on a Saturday night is pretty damn exciting and Fever Ray has the potential to steal the entire festival.
Dancing Choose
As mentioned earlier, Melt's heart will always belong to dance music. And boy do the organisers have some treats for those who want to move for three whole days. There's even a whole section called Sleepless Floor if you want to destroy your sleep patterns for a week.
Repping the host country are the German duo Modeselektor. The genre-crossing pair refuse to be pigeonholed go from techno to hip hop to metal to IDM and back again. Even just a DJ set from Modeselektor could be a heady journey.
The Russian pair of Nina Kraviz and Kedr Livanskiy unite in a love of experimental electronics and traditional house structures. Both delve into ambience in their sets, and in the midst of non-stop partying there's always space for moments of pure bliss. Low-key weekend highs await.
Jon Hopkins and Mount Kimbie are live veterans who never fail to deliver, George FitzGerald promises much based on new album All That Must Be while Finland's ALMA, Sweden's Little Dragon and New Yorkers Fischerspooner offer lighter pop treats for those who want some choruses while they move their feet.
Transatlanticism
BADBADNOTGOOD. The Internet. Tune-Yards. Princess Nokia. The Black Madonna. Moses Sumney. Fatima Al Qadiri.
Just some of the North America-based artists gracing Melt this year and praise has to go to the organisers and bookers for thinking outside the box when choosing this lot. Often it feels like festivals in North America and Europe have the same names on rotation when it comes to headliners, so it's incredibly refreshing to find these names taking pride of place on the bill. It shows that you can look past the big names, the ticket sellers and go with women and the non-binary, people of colour or artists you just think deserve a wider audience...and still expect to have a sell-out festival.
It's still a few months away but we can't wait for what's going to be a glorious and unforgettable summer.
Melt Festival takes place between 13-15 July at Ferropolis, Germany. Tickets are on sale.
A Touch Of Norway: The Line Of Best Fit visits Oslo
Festival Preview: Way Out West
Track By Track: Oh Wonder on Oh Wonder

redpajama_set_name: RedPajamaCommonCrawl


Parents interested in learning about child development, creativity research, etc.
The SELLER, in this case, is me, though I am about to start a cycling team and will promote the team's sponsors, as well.
College students majoring in education might encourage others to visit my blog if I offered points to my students based on how many others they "recruit" OR if I gave extra points for joining themselves.
Current educators/teachers might encourage others to read my blog if I offered some type of recognition – maybe I could have teachers guest blog post, or offer a badge on my blog that they could download if they try an idea (the badge could then be proudly displayed on their blogs/websites). This badge would be "proof" that the educator is innovative and a life-long learner.
Colleges wanting to shift their style of teaching might encourage others to visit my blog if I gave a discount to the college (on workshops and training) maybe a percentage off based on how many educators subscribe to my blog.
Parents interested in learning about child development, creativity research, etc. might be more prone to encourage others to visit my blog if they have heard about me in a parenting magazine or something similar. I think I need to author some articles and get them published.
(Surprisingly largest group of readers)…..Crafters (as I periodically post tutorials on how to make things; slightly random when you look at the first four players, but crafters make great allies in education and parenting and crafters seem to hunt down helpful tutorials.). Crafters love to create, so if I consistently offered great tutorials that were unique, I think word of mouth would spread and more pins on Pinterest would be created.
3. What could I charge each group….This part is confusing……Blogs are generally free. The ideas on my blog are free. However, I may want to create a product related to one of my blog posts and charge for it. I also want to increase my educational consulting and keynote address gigs, so the blog is a good platform to make connections with others. Ulitmately, I would like to seam my blog posts together into a book on teaching and learning.
4. Why would the players need this service? Education is struggling in the 21st century. Many schools and higher education institutions want to shift their focus from teacher-directed classrooms to more student-directed learning. I am just their gal to lead that endeavor, help them get started and share my experience and curated research. For parents, many of the ideas can cross-over from teaching to parenting. The crafters need this service, my blog, because crafters seem to scour for tutorials and "how tos," plus inspiration.


text:
Q: How to get scalar value from a SQL statement in a .Net core application? The following code in a .Net core console application (EF core 2.0/Sql server).
var sql = _context.Set<string>()
          .FromSql("select dbo.FunctionReturnVarchar({0});", id);

got the following exception?

Cannot create a DbSet for 'string' because this type is not included in the model for the context.

Is it a way without defining a class with a property of string?

A: What you need in this scenario is the ExecuteSqlCommand method with bound output parameter:
var resultParameter = new SqlParameter("@result", SqlDbType.VarChar);
resultParameter.Size = 2000; // some meaningfull value
resultParameter.Direction = ParameterDirection.Output;
_context.Database.ExecuteSqlCommand("set @result = FunctionReturnVarchar({0});", id, resultParameter);
var result = resultParameter.Value as string;

A: .Set<TEntity>() is for entities backed by the context.
You can try a workaround
DbConnection = connection = _context.Database.GetDbConnection();

using(DbCommand cmd = connection.CreateCommand()) {

    cmd.CommandText = "select dbo.FunctionReturnVarchar(@id)";

    cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.VarChar) { Value = id });

    if (connection.State.Equals(ConnectionState.Closed)) { connection.Open(); }

    var value = (string) await cmd.ExecuteScalarAsync();
}

if (connection.State.Equals(ConnectionState.Open)) { connection.Close(); }

A:  public static class TeeLinqExtensions
    {
        public static long? TeeNextSeq(this DatabaseContext pCtx)
        {
            long? seqNo=0;

            using (var command = pCtx.Database.GetDbConnection().CreateCommand())
            {
                command.CommandText = "SELECT NEXT VALUE FOR student_admin_no_seq AS seq";

                pCtx.Database.OpenConnection();

                  seqNo = command.ExecuteScalar() as long?;

                  pCtx.Database.CloseConnection();

            }

            return seqNo;

        }
    }

then use as

 var studentIdentityNo = _db.TeeNextSeq();

redpajama_set_name: RedPajamaStackExchange


text:
Home › News › Northern Ireland
Sponsor in talks with Sale Sharks after club linked to move for ex-Ulster players Paddy Jackson and Stuart Olding
Paddy Jackson
Stuart Olding
By Ryan Nugent
A lead sponsor of English rugby club Sale Sharks has spoken to the club's boss over any potential move for Paddy Jackson and Stuart Olding after they were linked with the former Ulster rugby players.
https://www.belfasttelegraph.co.uk/news/northern-ireland/sponsor-in-talks-with-sale-sharks-after-club-linked-to-move-for-exulster-players-paddy-jackson-and-stuart-olding-36871869.html
https://www.belfasttelegraph.co.uk/news/northern-ireland/article36871867.ece/bf775/AUTOCROP/h342/2018-05-04_new_40662571_I1.JPG
The move comes after the English Premiership club moved to distance themselves to links to the ex-Ireland players.
It's understood that Andy Bell - co-founder of AJ Bell, Sale's stadium sponsors - has been in touch with Director of Rugby Steve Diamond since reports circulated about a possible move for the two players.
The pair were sacked by the IRFU and Ulster Rugby last month after details of misogynistic messages were revealed during a rape trial earlier this year.
While both players were cleared of all charges following the trial in Belfast, they were let go following an internal review by the IRFU and Ulster Rugby.
A number of clubs in England and France have since distanced themselves from both players.
AJ Bell say that while it is true Mr Bell spoke with Mr Diamond on the matter, the company did not raise concerns or objections about a potential signing. In a statement last night, the company said: "Sale Sharks are very aware of the strong values engrained within our business, many of which are shared by the club and their supporters.
"We have total faith in Steve Diamond and the owners to reflect these values whilst they are stewards of the club."
On Wednesday, the club distanced itself from the players saying there was no substance to the rumour.
"Sale Sharks can confirm there is no substance to the rumours circulating in relation to the signing of the two international rugby players Paddy Jackson and Stuart Olding," the Greater Manchester club said. "Our search continues for top-class players to bolster the squad for next season."
Over 10,000 expected to attend Operation Banner 50th anniversary commemoration in...
By Ralph Hewitt More than 10,000 people are expected to mark the 50th anniversary of Operation Banner — the name given to the Army's campaign in Northern Ireland during the Troubles.
Government to introduce legislation to compensate abuse victims by 'end of year at...
By Gareth Cross The UK Government will introduce legislation to compensate victims of historical institutional abuse by "the end of the year at the latest", a spokesperson has said.
Police seize £150k worth of drugs during Belfast searches
Police have seized suspected Class A and B drugs with an estimated value of £150,000 during two searches in north Belfast on Thursday.
Rain not spoiling the party as golf's Open returns to Portrush
The rain hammered down and the home hero's victory chances were washed away but nothing was about to spoil the Portrush party on the Open's historic return.
Police probe after staff on Scotland to Northern Ireland ferry fail alcohol and... Northern Ireland
Why Rory McIlroy is wearing 'special' washing machine logo for The Open at Royal... The Open


text:
Toonarbin, West End
Captain Henry O'Reilly, an Irish master mariner, left his job sailing steam ships out of Liverpool in England to emigrate to Australia and arrived in Sydney in 1854 with thirty quid in his pocket and a belief that divine providence would present opportunities. He was correct - he was immediately hired by the Australasian Steam Navigation Company to sail steamers between Sydney and Brisbane.
O'Reilly made hundreds of trips between Sydney and Brisbane, mainly on the steamer Telegraph, and in 1863 he was made manager of the ASN operation in Brisbane, triggering a move up here. The forerunner to this building would have been his Brisbane office. Captain O'Reilly and his family for a time lived in the house Montpelier that overlooked the river in a spot known then as O'Reilly's Hill, later to become Bowen Hills and the site of Cloudland.
Subsequently Captain O'Reilly bought some land at West End from the architect Benjamin Backhouse that was offered for sale in 1868:
FOR SALE, " TOONARBIN," a Superior Suburban Property, on the River, South Brisbane, near Hill End, containing about 8 acres, thoroughly fenced, substantial Stables and Offices, well-stocked Garden, Water Dams, &c., &c. Apply to Mr. BACKHOUSE, Architect.
(Brisbane Courier 16 September 1868 via trove.nla.gov.au)
O'Reilly engaged Backhouse to design a house for him on the property and the following photograph shows the original form of the residence. The name Toonarbin that Backhouse had bestowed on the land came originally from a Henry Kingsley novel, and it was applied to the house. Here is a photograph showing the early form of the house - note the ornate chimneys on each corner.
(Photo: JOL 98162)
O'Reilly lived at Toonarbin until his death in 1877, and his wife and children continued to live there for a considerable time after that. His son Charles O"Reilly was a customs agent and his bonded stores at Margaret St in Brisbane's CBD were recently demolished despite a call for them to be added to heritage lists.
In 1926 Archbishop Duhig bought the property. Some of the land was sub-divided and sold off and the residence was converted to a convent for the Sisters of Mercy. Some improvements and alterations, including replacing the wooden balconies and facade with brick, took place then to cater for its new function.
The building operated as a convent through to around 1995 and was then vacant for a dozen years until purchased by the current owners who set about restoring the building to its former glory. A labour of love over the ensuing years has Toonarbin looking like this. Although the structure has been enlarged and enclosed in brick, the chimneys provide external evidence of the building's origins.
Proof of the success of the restoration is illustrated by the fact that Toonarbin won a High Commendation at the announcement of the National Trust's heritage awards for 2014.
This is our final post for 2014.
Seasons Greetings to all readers!
We will be back in 2015.
Labels: backhouse, duhig, highgate hill, o'reilly, toonarbin
Art Matters December 8, 2014 at 4:36 PM
I was fortunate to be able to tour this beautiful house during the October Open House Brisbane - it has been so well restored.
the foto fanatic December 12, 2014 at 8:50 PM
Love your drawing Carol!
Nathan December 8, 2014 at 6:31 PM
A photo of the original office for the ASN in Brisbane, with the O'Reilly's name visible on the facade, and possibly with the Captain being one of the people standing in front of the building, can be found at this link: http://hdl.handle.net/10462/deriv/66767
As far as I know, this building was extended to create Naldham House.
Thanks for the link to the early photo of the ASN office, which is the original form of Naldham House.
brismod December 8, 2014 at 7:16 PM
I wanted to see this home during the BOH in October. I hope it will be on the tour again next year. Best wishes for Christmas and 2015! xx
Yes, I missed it too.
The external appearance of the building is wonderful - it would be marvellous to see inside.
George Armstrong December 8, 2014 at 8:49 PM
Over the years I have heard various stories that the O'Reilly family of Toonarbin were directly related to the O'Reilly family of Lamington Plateau fame. Does anyone know if this is true? The southern half of Toonarbin's original estate, fronting the river, was subdivided in the 1930s and sold as 'Riverview' estate. Brisbane City Council has an original 'Riverview' real estate sales poster in their archives.
I have no information of any connection between Captain O'Reilly and the Binna Burra family of the same name.
Hels January 6, 2015 at 8:49 AM
When the building was renovated and preserved, did they not want to rebuild the gorgeous balconies?
the foto fanatic January 6, 2015 at 3:08 PM
I suspect the original balconies were done away with as part of the conversion to use as a convent way back in the 1920s.
Don't know why they couldn't have been restored later.
verity violet December 26, 2016 at 10:17 AM
they are now front rooms. the original house was quite narrow.


text:
Kannaway Named Small Business Company Of The Year
Medical Marijuana, Inc. ("the Company") (OTC: MJNA), the first-ever publicly traded cannabis company in the United States that launched the world's first-ever cannabis-derived nutraceutical products, brands and supply chain, announced today that its subsidiary Kannaway® was named Small Business Company of the Year in the Life Sciences, Health, Wellness, and Nutrition category by the Business Intelligence Group's 2019 BIG Awards for Business.
Also, Kannaway®'s CEO Blake Schroeder was named Small Business Executive of the Year in the Life Sciences, Health, Wellness, and Nutrition category.
The Business Intelligence Group's 2019 BIG Awards for Business were launched to acknowledge companies, products, and people that are leading their respective industries. The organization's proprietary and unique scoring system selectively measures performance across multiple business domains and then rewards those companies whose achievements stand above those of their peers.
As the first direct-selling company to bring hemp-based cannabidiol (CBD) products to market in the U.S. and Europe, Kannaway® was named Small Business Company of the Year to recognize the Company's international advocacy efforts for CBD access and education.
The Company held its European Grand Opening Event in Prague in 2018 where more than 2,000 people attended and executives revealed several new innovative CBD products. Kannaway® experienced an increase of nearly 200% in revenue over 2017 revenue, much of that success attributed to its European operations.
"We are honored and humbled to have the hard work of our team recognized by the BIG Awards for Business," said Kannaway® CEO Blake Schroeder.
"2019 was a banner year for revenue growth at the Company, especially in our international operations, and we are proud to continue to be a pioneer for the industry in educating new markets about hemp-based CBD."
Schroeder is one of 60 global leaders recognized by the 2019 BIG Awards for Business and the sole winner of the Small Business Executive of the Year for the Life Sciences, Health, Wellness, and Nutrition category. The award honors his efforts in growing the Company's revenue more than 60 times since joining the executive team along with his work to help expand the Company's product offerings to meet growing consumer demand.
"We are excited by this recognition and believe that it will help us make CBD and hemp-derived products available to people around the world,"
said Medical Marijuana, Inc. CEO Dr. Stuart Titus.
"Awards like these continue to boost our reputation as a category leader and set a standard of professionalism that we wish to impart upon the entire industry."
Details about the Business Intelligence Group BIG Awards for Business and the list of 2019 BIG Awards for Business winners are available at https://www.bintelligence.com/big-awards-for-business/.
To learn more about Kannaway, please visit https://www.kannaway.com.
About Kannaway®
Kannaway® is a network sales and marketing company specializing in the sales and marketing of hemp-based botanical products. Kannaway currently hosts weekly online sales meetings and conferences across the United States, offering unique insight and opportunity to sales professionals who are desirous of becoming successful leaders in the sale and marketing of hemp-based botanical products.
About Medical Marijuana, Inc.
We are a company of firsts®. Medical Marijuana, Inc. (MJNA) is a cannabis company with three distinct business units in the non-psychoactive cannabinoid space: a global portfolio of cannabinoid-based nutraceutical brands led by Kannaway® and HempMeds®; a pioneer in sourcing the highest-quality legal non-psychoactive cannabis products derived from industrial hemp; and a cannabinoid-based clinical research and botanical drug development sector led by its internal R&D and scientific team and its pharmaceutical investment companies and partners including AXIM® Biotechnologies, Inc. and Kannalife, Inc.
Medical Marijuana, Inc. was named a top CBD producer by CNBC. Medical Marijuana, Inc. was also the first company to receive historic import permits for CBD products from the governments of Brazil, Mexico, Argentina, and Paraguay and is a leader in the development of international markets. Medical Marijuana, Inc.'s headquarters is in San Diego, California, and additional information is available at OTCMarkets.com or by visiting www.medicalmarijuanainc.com.
Get more information, facts and figures about Kannaway, click here for the Kannaway overview.


The baby boomers have had a wonderful reign during the 40s and 60s period. The economic flourishments during those days are rapidly diminishing with the recent recessions. But thanks to the baby boomers, active participation is on the roll for real estate markets.
A lot of people have retired leaving behind a legacy of fortune that is more or less being invested in the real estate market. Most of the current positions are being managed by people having less expertise and with such a low economic period, the early investors enjoy a lot of benefits. They invest on real estate more than other ventures as it brings on a lot of money. The real estate is one such field that supports and churns out the fortunes of early baby boomers. With them retiring, there is worry on the recession front as to the need of available financial source for establishing other projects and ideas.
Real estate is booming everywhere and is offering a wider scope as a lucrative job. There are many ways to land up with a good real estate deal by means of the internet.
We can find relevant information about the current real estate deals on Google. They offer varied details about proprietors interested in selling and buying real estate. There are a lot of links on Google that can lead you to websites specially hosted for striking bargains on real estate properties. Apart from links, there is the Google ad sense that increases site trafficking for real estate deals. Majority of the real estate companies and individual firms are enlisted on Google and offer the targeted reach to a wider section of audience. People looking to buy and sell can enlist their property and look for a suitable party to bid their quotes. Most of the deals on Google are genuine and true to their word.
Green real estate is the solution for a world that supports sustainability and ecological conservation. Most of the buildings and infrastructure employ the use of hazardous chemicals and materials that cause damage to the environment.
A lot of cities like New York and Los Angeles welcome the green revolution for building structures that prove to be environmentally safe in the urban landscape. They help in reducing the overall financial budget and ensuring a safe shelter for people to exist along with the environment. A lot of building standards have been modified to create an eco friendly environment and with the use of the recycled substances. Materials that let out methane gas and other harmful gases are strictly denied and the usage of raw materials like straw, bale, recycled burnt bricks and harmless corrosive paints are being used for building houses. Therefore green real estate keeps a check on all of these for the safety of environment.
Real estate properties are being sold out widely and with lot of firms engaging in as proprietors it becomes necessary to be well informed in advance. The first and foremost would require you to study in depth about the property being sold or bought to negotiate a better deal.
It requires an expertise skill that develops over time and is sure to bag you with good offer. Look out for the overall land value of the property for a span of 5 years. It would allow you to judge the current rate and be sure to watch out for repairing works that might be needed after buying the property and ask for a lower quote. It might be helpful to some extent. Always take legal advice before signing the deals and read the documents carefully to understand the clauses. Therefore prior information is a necessity at all times for striking a good deal.


text:
Q: Where can I find good programming resources for SharePoint? I have been trying to find a book or web reference that gives me good understanding on how to build, test, and deploy ASP.NET pages, controls, and web parts to a SharePoint web site. All I have found so far is either draggy-droppy stuff or administration stuff.
Is SharePoint really flexible with ASP.NET when is comes to extending it? A series of getting started videos or tutorials would be ideal.
Thanks in advance!!

A: It is just ASP.NET and is extenable to a certain limit. It all just depends on what you want to do.
I found the wrox books very usefull:
Professional SharePoint 2007 Development
Expert WSS 3.0 and MOSS 2007 Programming
Did you check out http://MSSharePointDeveloper.com yet?

A: Another good developer reference is Inside Windows SharePoint Services 3.0. This is Microsoft's recommended reading for the core WSS developer exam and is often seen as a bible for SharePoint development.

A: If you are going to be doing any Publishing with Sharepoint Andrew Connell's book Professional Sharepoint Content Management is a must read.

A: From twitter they are announcing MSDN Office Developer Bookshop today
http://twitter.com/MSDN_Office

A: I've had remarkable luck with PilotHouse Consulting's SharePoint development DVD for getting a bunch of the basics for SharePoint development.  I'm going to check out these other answers though.


This in on stock Fedora 25. I don't have a macOS env yet to test.
I have seen it sometime not hang, but then it doesn't seem, to run any test.
It seems to go on a loop where applyElemHideEmulation() gets called infinitely, because loading script for ElemHideEmulation seems to fail.
Revision c7ae7532578a cause another breakage by not updating the test after an API change.
Issue 4962 - Fix the tests.


text:
Boris Šprem (ur. 14 kwietnia 1956 w m. Koprivnički Bregi, zm. 30 września 2012 w Houston) – chorwacki polityk i prawnik, parlamentarzysta, przewodniczący Zgromadzenia Chorwackiego.

Życiorys
Z wykształcenia prawnik, ukończył studia na Wydziale Prawa Uniwersytetu w Zagrzebiu. Od 1980 do 1993 był urzędnikiem w chorwackim parlamencie. Następnie do 2003 pracował w chorwackim krajowym automobilklubie (Hrvatski autoklub), dochodząc do stanowiska sekretarza generalnego tej organizacji. Przez rok pełnił funkcję szefa biura legislacji przy radzie ministrów, po czym do 2005 zasiadał w zarządzie przedsiębiorstwa ubezpieczeniowego. W 2005 prezydent Stjepan Mesić powierzył mu stanowisko szefa kancelarii prezydenta, które zajmował do 2007. W tym samym roku Boris Šprem z ramienia Socjaldemokratycznej Partii Chorwacji uzyskał mandat deputowanego do Zgromadzenia Chorwackiego. W wyborach w 2011, wygranych przez koalicję skupioną wokół jego ugrupowania, z powodzeniem ubiegał się o reelekcję. Został następnie wybrany na przewodniczącego parlamentu VII kadencji. Zmarł 30 września 2012 w MD Anderson Cancer Center w Houston z powodu bardzo złośliwej postaci szpiczaka mnogiego.

Przypisy

Absolwenci Uniwersytetu w Zagrzebiu
Deputowani do Zgromadzenia Chorwackiego
Politycy Socjaldemokratycznej Partii Chorwacji
Chorwaccy prawnicy
Urodzeni w 1956
Zmarli w 2012

redpajama_set_name: RedPajamaWikipedia


text:
Stolen baseball cards recovered but true value can't be measured for some
Maureen Boyle
Vintage baseball cards can cost big bucks on the market but most baseball cards – the older ones – are handed down through families where the true value is a history that can't be measured in dollars. A Bourne woman was charged with receiving stolen property after stolen baseball cards are recovered in Wareham.
When Wareham police recovered stolen, rare baseball cards this week, the owner wasn't thinking of the $11,000 appraised value.
He was thinking of his family's history with the cards, police said.
"The cards were passed down from generation to generation," Wareham officer William E. Filhman said. "They were family heirlooms, so to speak, and he was very relieved to get them back."
Vintage baseball cards can cost big bucks on the market: a mint 1952 Topps Mickey Mantle can bring up to $10,000. A 1948 Leaf Babe Ruth can cost more than $6,000.
But most baseball cards – the older and most valuable ones – are handed down through families where the true value is a history that can't be measured in dollars.
"It is memories," said Ron McCall, owner of the Bleachers, a sports card shop in Abington. "It is not really the items. It is the connection to your parents or grandparents."
McCall said some customers come in with cards and ask about the value.
"They don't want to sell it, they just want to know what it is worth," he said.
Older cards evoke fond childhood times, days with family, thoughts of grandparents.
"Most of the business is with adults; it brings the adults back to their youth. Baseball is forever," McCall said.
Major League Baseball Properties reports a 20 percent increase in card sales in recent years and, citing research from KidSay Tracker, 47 percent of children ages 8 to 12 in the country are baseball card collectors.
Al Loconte, owner of The Dugout in Brockton, said older cards fetch high prices – and so do some of the newer ones.
He said people are snapping up the 2010 Topps set to get the Stephen Strasburg rookie card, and card packs that went for $12 are soaring to $38 as people try to get his card.
"His baseball cards are flying," Loconte said.
Matt Rose at Vince's Collectibles in Taunton sees a similar trend.
"A lot of people are coming in looking for rookie cards," he said.
Keeping that collection safe at home can be a bit tricky, though.
"If you have something valuable, you put it in a safe deposit box," McCall said. "But then you can't look at it."
The best bet is not to let too many people know what you have, Loconte said.
"You have to be careful," he said. "Some people will do anything for money."
In Wareham this week, police recovered seven baseball cards, appraised at $11,000, including two Ty Cobb cards and one each of Walter Johnson, Heinie Wagner and Babe Ruth.
The cards were reported stolen on Sunday when a Wareham homeowner noticed they were gone, Filhman said
After an investigation, police stopped a car Monday on Sandwich Road and recovered the cards.
The driver, Melissa Sleeper of 7 Rainbow Circle, Bourne, was arrested on charges of receiving stolen property with a value of $250. She was arraigned Wednesday in Wareham District Court and released on personal recognizance. She is set to return to court on Aug. 26 for a pretrial hearing.
Filhman declined to say what led police to Sleeper or if she knew the victim.
Filhman said the cards, based on two independent appraisals, are valued at $11,000.
The owner of the cards, who was not identified by police, was grateful police were able to recover the items, Filhman said.
"He was very overwhelmed with emotion when he found they were recovered," Filhman said.
Maureen Boyle can be reached at mboyle@enterprisenews.com.
READ MORE about baseball cards.


You are here: Home » House Prices » Kate Faulkner's Property Watch versus BBC1!
Or skip to our own Property Watch and Price Predictions. To be fair, I was worried, would this be a series of 'scare mongering' and poor stats, or claims to get to the 'truth about property' which hasn't ever got there in the past. However, the programme was an OK mix of property stats and stories. The 'headlines' were about how prices have fallen and the fear of long term negative equity, then a story about how the falls had affected people across the UK, interspersed with some facts, albeit not so far the best ones to be following the market.
So, at least a good balanced approach. However, there are some issues with the information that they used and certainly some of the research. For example, one survey was from a company called Standard and Poors, which forgive me, isn't that the same company that gave triple AAA fantastic investment ratings to those awful subprime mortgage loans? Do we really want our hard earned tax payer's money going to this company? Not sure we do, or would we ever trust any data from this company every again thanks very much!
To measure the falls in the market, they relied on government data from the Land Registry. This is great data, and I love analysing it, but it's out of date and if they continue to use it, their figures will continue to show a falling market for some months to come. The information is based on 'sold prices' which will have come from some offers made prior to Xmas, so it's accurate, but 'old' data in property terms.
Should we still be using Halifax Data?
Other statistics used included HMRC showing an increase in sales in January, good data, but from a very low base. The Nationwide data showed one blip of an increase in prices in March, hardly revealing on its own. The Halifax data didn't seem to know whether it was going up or down and that's no surprise, are they really doing much lending at the moment. Is their data robust? I don't think so, we've seen some very strange results recently, so have taken it off our list of 'surveys to watch'.
The only real data that did help to show what's happening 'now' was data from the National Association of Estate Agents which showed the number of sales per agent going up over the last few months and coupled with lots of other data, such as information from www.hometrack.co.uk. See our Property Market Update statistics on the Buying and Selling market and what we measure.
However, the last six months have proved people don't panic. In fact they do the opposite. They batten down their hatches and if they don't have to move they don't put their property up for sale, if they do need to move, they rent it out, or drop the price. Perhaps our homeowners are much brighter than Professor Andrew Oswald and other doom and gloom economists appreciate!
Then, our new Property Hero was brought in, the most sensible man in the market. Meet Mr Andreas Panayioyou, who up until 2006, was one of the UK's biggest residential landlords. He then sold up, knowing the market wasn't returning to what it had in the past. His view? Well he's back investing in residential property because he looks at it from a business perspective. Basically says Mr Panayioyou "yield should be higher than the cost of funds and interest in the banks" and now that's back, so is the reason to invest.
Most of the stories were the usual, people who have 'dropped' their property's price by thousands of pounds or even a million. No one checked however whether the properties were ever worth their original asking prices or not and little was made of the fact that some of them had rejected offers from a year or so ago and are currently probably regretting it!
Research we have been involved with shows sellers who over price their properties typically sell for around £8,000 less than they could have done and take an additional six months or more to sell.
What the stories don't really show, although it was mentioned, is the long term rise and fall of property prices on a regional basis. For example, Wales had one of the biggest property rises over the last 10 years, so its fall was also likely to be higher than other areas. Dublin especially has seen a 52% fall in property prices, but that's no surprise, banks were giving away 100% mortgages like free pints of Guinness!
It was great to see the smart family who had realised that if they dropped the price of their own property to sell it, they could trade up and actually save money and buy a property that in the future they probably wouldn't be able to afford. Smart move, but this is old news and has been happening since January this year. It's actually this kind of purchase that has driven the property market forward over the last few months.
It was slightly sad to see the stately home "Winslow Hall" which hasn't sold for the last two years. However it's a confusing picture as they bought it (then we find out it was inherited?) in 1959. It was put on the market at £3 million and has now "dropped" to a mere £2 million. Offers of £1.5 and £1.7 million have been made, but rejected. Worst still the seller is restricting his market further as he wants to sell to the 'right people'. Seems to us that the property was worth between £1.5 and £1.7 million last year when the offers seem to have been made, but it's now worth less. So they either need to stay and sell later, rent it out (not sure about that one though!) or bite the bullet and sell at a price someone is willing and able to offer.


Navigator is adding tremendous style and profile to his progeny. If you are searching for the next bull who'll improve your odds in the show-ring, you'd better seriously consider Navigator. His progeny are not only long and clean fronted, but they exhibit the depth and soundness that's a must for today's competitive edge. Heterozygous polled, Homozygous black.


text:
Denis Patrick O'Brien, FBA (born 1939 in Knebworth, Hertfordshire, England) is an English economist who has worked in industrial economics and the history of economic thought.

O'Brien graduated in 1960 with a BSc (Economics) from University College London. From 1963 to 1972 he was Assistant Lecturer, Lecturer and then Reader in Economics at Queen's University Belfast. From 1972 to 1997 he was Professor of Economics at the University of Durham where he has since been Emeritus.

O'Brien was elected to the Fellowship of the British Academy in 1988.

Major publications
 Information Agreements, Competition and Efficiency (with D. Swann), 1969.
 J.R. McCulloch, A Study in Classical Economics, 1970.
 Competition in British Industry (with D. Swann, P. Maunder, W.S. Howe), 1974.
 The Classical Economists, 1975 (revised ed., 2004).
 Competition Policy, Profitability and Growth (with W.S. Howe, D.M. Wright, R.J. O'Brien), 1979.
 Authorship Puzzles in the History of Economics: A Statistical Approach (with A.C. Darnell), 1982.
 Lionel Robbins, 1988.
 Thomas Joplin and Classical Economics, 1993.
 The Development of Monetary Economics: A Modern Perspective on Monetary Controversies, 2007.

Edited volumes:
 The Correspondence of Lord Overstone (3 vols.), 1971.
 Pioneers of Modern Economics in Britain (ed. and contrib., with J. Presley), 1981.
 Economic Analysis in Historical Perspective (with J. Creedy), 1984.
 Foundations of Monetary Economics (6 vols.), 1994.
 Collected Works of J.R. McCulloch (8 vols.)
 The Foundations of Business Cycle Theory (3 vols.), 1997.
 A History of Taxation, (8 vols.), 1999.

References

Secondary sources
 Creedy, John (2001) - "D.P. O'Brien's contribution to the history of economic analysis", in Historians of Economics and Economic Thought. The Construction of Disciplinary Memory, ed. Steven G. Medema and Warren J. Samuels.
 M. Blaug (ed.) - Who's who in economics (3d edition), 1999.

External reference
Citation of Denis Patrick O'Brien as 2003 Distinguished Fellow of the History of Economics Society

1939 births
Living people
English economists
Historians of economic thought
Alumni of the University of London
Academics of Queen's University Belfast
Academics of Durham University
People from Knebworth
Fellows of the British Academy


Sexual Offending presents the latest theory and research relating to the social cognition, emotion, and motivational goals of individuals who have committed sexual offences.
Theresa A. Gannon is Professor of Forensic Psychology and Director of the Centre for Research and Education in Forensic Psychology (CORE-FP) at the University of Kent, UK. Dr. Gannon also works as a Practitioner Consultant Forensic Psychologist specializing in sexual offending and fire-setting for the Forensic and Specialist Service Line, Kent and Medway Partnership Trust. She has published more than 100 book chapters, articles, books, and other scholarly works related to male- and female-perpetrated sexual offending.


text:
First Published on: September 14, 2017 | Last Updated: February 2, 2020
By Kumaresh Das
Uttar Pradesh is a state that is steeped in history and culture. With influences from several cultures, the cuisine, the architecture and the beautifully blended way of life attract tourists from all over the globe. The state is home to some of the most spiritually and culturally significant destinations and monuments in India. Here are some of the most popular tourist destinations in Uttar Pradesh that you should not miss in this state trip:
This is the home of the grand Taj Mahal. What more can you ask for than visit the most glorious symbol of love and one of the most spectacular creations by man. Besides that, this city that stands on the banks of River Yamuna is home to beautiful forts, mausoleums, gardens and mosques that are reflective of the Mughal era. Make sure you visit the Itmad Ud Daula, the Chhatri of Raja Jaswant Singh, Fatehpur Sikri, Sorr Sarovar and Chini ka Rauza while you are here.
Varanasi Ganga Ghat
Located on the banks of River Ganga and most popular tourist destinations in Uttar Pradesh. This religious city is said to be one of the oldest places in the world that has been inhabited continually. The winding lanes and the beautiful temples and shrines add to its beauty. You can also find some sadhus who are dressed in the most unique clothes, sitting by these roads, often posing for pictures with the tourists. The Dasaswamedh Ghat, the Kathwala Temple, the Alamgir Mosque and the Monkey temple are among the several attractions in Varanasi.
While you are here, you can also visit the neighboring town of Saranath. It is believed to be the place where the Buddha peached the first ever sermon. It is dotted with monasteries and stupas and is the most popular destination for Buddhist devotees.
Also Read: Why You Must Visit Varanasi During Dev Deepawali
Allahabad is the most important tourist spots in India thanks to the annual Kumbh Mela. The sangam or confluence of rivers holds great spiritual value. The historical diversity of this town is reflected in the mix of Mughal tombs and forts and buildings from the British Era. While you are here, do not forget to taste the popular red guavas.
Kusum Sarovar, Mathura
Also known as Krishnabhoomi, this is where Lord Krishna lived and spent years in merriment. The sacred River Yamuna flows right through the town and it is located near the popular vrindavan. You can also witness glimpses of the Buddhist community that thrived here once upon a time through the ruins of beautiful monasteries. While you are here, pay a visit to the Krishna Janma Bhoomi Mandir, The Radha Kund, The Jama Masjid, The Kans Qila and the Vishram Ghat.
Ayodhya has been a town of several controversies but has managed to remain the most sacred towns in India. While it became infamous for communal issues for close to two decades, the fact that it is the birthplace of Lord Rama makes it a spiritually revered place. There are several temples like the Ram Lalla Temple, the Kanak Bhavan Temple, the Hanuman Garhi and the Nageshwarnath Temple that offer peace and solace to thousands of visitors each year. You can plan a temple tour while you are here and witness some of the finest examples of ancient architecture.
Bada Imambara, Lucknow
If you love food, you will love Lucknow. Make sure you try the delicious Awadhi cuisine while you are here. The town itself is filled with the aroma of spices that floats through the air. Lucknow, the capital city of Uttar Pradesh is a reflection of the best Mughal architecture that blends into a thriving cosmopolitan city. The Bada Imambara, the Chota Imambara, The Chattar Manzil, the Begum Hazrat Mahal Park, the Constantia House and Hazratganj are among the most popular tourist destinations in Lucknow.
Iskcon temple, Vrindavan
Vrindavan is one of the most popular destinations for Hindu devotees. This is the place that Krishna devotees go to to seek blessings of the Lord. There are several narrow roads that lead to some of the most popular temples like the Govind Dev Temple, the Shahji Temple, Madan Mohan Temple, The Hare Rama Hare Krishna Temple and the Prem Mandir. You can buy beautiful worship items from roadside stores. Of course, you can even taste a variety of sweets in small shops that dot the lanes of Mathura.
Religious and Spirituality
Kumaresh Das
An avid traveler, football crazy and of course love riding bike.
kumaresh Das says:
on top of reply
Why You Must Visit Varanasi During Dev Deepawali
Top Ashrams For Yoga And Meditation In Rishikesh
The Most Popular Ashrams in India
Plan Your Chota Char Dham Yatra – Uttarakhand
Jagannath Puri Ratha Yatra: Your One-Stop Guide To The Festival
Best Places to Celebrate Krishna Janmashtami in India
A Complete Travel Guide For Shri Amarnath Yatra
A Complete Travel Guide for Kailash Mansarovar Yatra
15 Sikh Pilgrimage Sites In India That You Must Visit