Esempio n. 1
0
 function process_selection($data)
 {
     foreach ($data->_selection as $userid) {
         cluster_manual_assign_user($data->id, $userid, !empty($data->autoenrol), !empty($data->leader));
     }
     $tmppage = new clusteruserpage(array('id' => $data->id));
     redirect($tmppage->get_url(), get_string('cluster_user_assigned', 'block_curr_admin', count($data->_selection)));
 }
Esempio n. 2
0
 /**
  * Determine whether the current user can assign the given user to the given userset.
  *
  * @param int $userid The ID of the user.
  * @param int $usersetid The ID of the userset.
  * @return bool Whether the user can assign (true) or not (false)
  */
 protected function can_unassign($userid, $usersetid)
 {
     return clusteruserpage::can_manage_assoc($userid, $usersetid);
 }
Esempio n. 3
0
 /**
  * Formats various attributes for human consumption.
  * @param array $row An array for a single result.
  * @return array The transformed result.
  */
 protected function results_row_transform(array $row)
 {
     static $canenrolintocluster = null;
     if ($canenrolintocluster === null) {
         $canenrolintocluster = usersetpage::can_enrol_into_cluster($this->usersetid);
     }
     $row = parent::results_row_transform($row);
     $row['canunassign'] = $canenrolintocluster === true ? '1' : '0';
     if (clusteruserpage::can_manage_assoc($row['element_id'], $this->usersetid) !== true) {
         $row['canunassign'] = '0';
     }
     if (isset($row['clstass_plugin'])) {
         if ($row['clstass_plugin'] !== 'manual') {
             $row['canunassign'] = '0';
         }
         $row['clstass_plugin'] = $row['clstass_plugin'] === 'manual' ? 'no' : 'yes';
         $row['clstass_plugin'] = get_string($row['clstass_plugin'], 'moodle');
     }
     return $row;
 }
Esempio n. 4
0
$dir = optional_param('dir', 'ASC', PARAM_ALPHA);
if ($dir != 'ASC' && $dir != 'DESC') {
    $dir = 'ASC';
}
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 30, PARAM_INT);
// add user to cluster
if ($userid) {
    require_once $CFG->dirroot . '/curriculum/cluster/manual/assignpopup_form.php';
    $assignform = new assignpopup_form();
    if ($assignform->is_cancelled()) {
        // do something
    } elseif ($data = $assignform->get_data()) {
        cluster_manual_assign_user($data->clusterid, $data->userid, !empty($data->autoenrol), !empty($data->leader));
        // reload the main page with the new assignments
        $target = new clusteruserpage(array('id' => $clusterid));
        ?>
<script type="text/javascript">
//<![CDATA[
window.opener.location = "<?php 
        echo htmlspecialchars_decode($target->get_url());
        ?>
";
//]]>
</script>
<?php 
    } else {
        $a = new object();
        $a->site = $site->shortname;
        $a->name = $cluster->name;
        print_header(get_string('assign_user_cluster', 'block_curr_admin', $a));