/**
  * Prints a deletion confirmation form.
  * @param $obj record whose deletion is being confirmed
  */
 function print_delete_form($obj)
 {
     global $CURMAN;
     if ($CURMAN->db->record_exists('crlm_cluster', 'parent', $obj->id)) {
         // cluster has sub-clusters
         $a = new stdClass();
         $a->name = $obj->to_string();
         $a->subclusters = $CURMAN->db->count_records('crlm_cluster', 'parent', $obj->id);
         $context = get_context_instance(context_level_base::get_custom_context_level('cluster', 'block_curr_admin'), $obj->id);
         $like = $CURMAN->db->sql_compare();
         $a->descendants = $CURMAN->db->count_records_select('context', "path {$like} '{$context->path}/%'") - $a->subclusters;
         print_string($a->descendants ? 'confirm_delete_with_subclusters_and_descendants' : 'confirm_delete_with_subclusters', 'block_curr_admin', $a);
         require_once CURMAN_DIRLOCATION . '/form/clusterform.class.php';
         $target = $this->get_new_page(array('action' => 'confirm'));
         $form = new clusterdeleteform($target->get_moodle_url(), array('obj' => $obj, 'a' => $a));
         $form->display();
     } else {
         parent::print_delete_form($obj);
     }
 }
Esempio n. 2
0
 /**
  * Prints a deletion confirmation form.
  * @param $obj record whose deletion is being confirmed
  */
 function print_delete_form($obj)
 {
     global $DB;
     if ($count = userset::count(new field_filter('parent', $obj->id))) {
         // cluster has sub-clusters, so ask the user if they want to
         // promote or delete the sub-clusters
         $a = new stdClass();
         $a->name = $obj;
         $a->subclusters = $count;
         $context = \local_elisprogram\context\userset::instance($obj->id);
         $like = $DB->sql_like('path', '?');
         $a->descendants = $DB->count_records_select('context', $DB->sql_like('path', '?'), array("{$context->path}/%")) - $a->subclusters;
         print_string($a->descendants ? 'confirm_delete_with_usersubsets_and_descendants' : 'confirm_delete_with_usersubsets', 'local_elisprogram', array('name' => $obj->name, 'subclusters' => $count));
         $target = $this->get_new_page(array('action' => 'delete', 'confirm' => '1'));
         $form = new usersetdeleteform($target->url, array('obj' => $obj, 'a' => $a));
         $form->display();
     } else {
         parent::print_delete_form($obj);
     }
 }