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)) {
             clustercurriculum::update_autoenrol($association_id, $data->autoenrol);
         }
         $this->action_default();
     } else {
         $form->display();
     }
 }
Ejemplo n.º 2
0
 /**
  * Edit clustercurriculum information.
  * @param array $elements An array of program 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;
     $programid = required_param('id', PARAM_INT);
     $autoenrol = required_param('autoenrol', PARAM_INT);
     foreach ($elements as $usersetid => $label) {
         if ($this->can_edit($programid, $usersetid) === true) {
             $associationfilters = array('clusterid' => $usersetid, 'curriculumid' => $programid);
             $association = $DB->get_record(clustercurriculum::TABLE, $associationfilters);
             if (!empty($association)) {
                 clustercurriculum::update_autoenrol($association->id, $autoenrol);
             }
         }
     }
     return array('result' => 'success', 'msg' => 'Success');
 }