/** * Assign the users to the userset. * * @param array $elements An array of user information to assign to the userset. * @param bool $bulkaction Whether this is a bulk-action or not. * @return array An array to format as JSON and return to the Javascript. */ protected function _respond_to_js(array $elements, $bulkaction) { global $DB; $usersetid = required_param('id', PARAM_INT); $userset = new userset($usersetid); // Permissions. if (usersetpage::can_enrol_into_cluster($userset->id) !== true) { return array('result' => 'fail', 'msg' => get_string('not_permitted', 'local_elisprogram')); } foreach ($elements as $userid => $label) { if ($this->can_assign($userset->id, $userid) === true) { cluster_manual_assign_user($userset->id, $userid); } } return array('result' => 'success', 'msg' => 'Success'); }
/** * Assign the usersets to the user. * * @param array $elements An array of userset information to assign to the user. * @param bool $bulkaction Whether this is a bulk-action or not. * @return array An array to format as JSON and return to the Javascript. */ protected function _respond_to_js(array $elements, $bulkaction) { global $DB; $userid = required_param('id', PARAM_INT); $user = new user($userid); // Permissions. $upage = new userpage(); if ($upage->_has_capability('local/elisprogram:user_view', $userid) !== true) { return array('result' => 'fail', 'msg' => get_string('not_permitted', 'local_elisprogram')); } foreach ($elements as $usersetid => $label) { if ($this->can_assign($user->id, $usersetid) === true) { cluster_manual_assign_user($usersetid, $user->id); } } return array('result' => 'success', 'msg' => 'Success'); }
function action_savenew() { $target = $this->get_new_page(array('action' => 'savenew')); $form = new $this->form_class($target->get_moodle_url()); if ($form->is_cancelled()) { $this->action_default(); return; } $data = $form->get_data(); if ($data) { cluster_manual_assign_user($data->clusterid, $data->userid, !empty($data->autoenrol), !empty($data->leader)); $this->action_default(); } else { // Validation must have failed, redisplay form $form->display(); } }
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))); }
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->url, get_string('userset_user_assigned', 'local_elisprogram', count($data->_selection))); redirect($tmppage->url, '', 2); }
$alpha = optional_param('alpha', '', PARAM_ALPHA); $namesearch = optional_param('namesearch', '', PARAM_MULTILANG); $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;