function action_edit()
 {
     $id = $this->required_param('id', PARAM_INT);
     $association_id = $this->required_param('association_id', PARAM_INT);
     require_once CURMAN_DIRLOCATION . '/form/' . $this->edit_form_class . '.class.php';
     $target = $this->get_new_page(array('action' => 'edit', 'id' => $id, 'association_id' => $association_id));
     $form = new $this->edit_form_class($target->get_moodle_url(), array('id' => $id, 'association_id' => $association_id));
     $form->set_data(array('id' => $id, 'association_id' => $association_id));
     if ($data = $form->get_data()) {
         if (!isset($data->cancel)) {
             clustertrack::update_autoenrol($association_id, $data->autoenrol);
         }
         $this->action_default();
     } else {
         $form->display();
     }
 }
Exemplo n.º 2
0
 /**
  * Edit clustertrack information.
  * @param array $elements An array of track 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);
     $autoenrol = required_param('autoenrol', PARAM_INT);
     foreach ($elements as $trackid => $label) {
         if ($this->can_edit($usersetid, $trackid) === true) {
             $association = $DB->get_record(clustertrack::TABLE, array('clusterid' => $usersetid, 'trackid' => $trackid));
             if (!empty($association)) {
                 clustertrack::update_autoenrol($association->id, $autoenrol);
             }
         }
     }
     return array('result' => 'success', 'msg' => 'Success');
 }