示例#1
0
 /**
  * Get an array of options to pass to the deepsight_datatable javascript object.
  * Enables drag and drop, and multiselect.
  * @return array An array of options, ready to be passed to $this->get_init_js()
  */
 public function get_table_js_opts()
 {
     $opts = parent::get_table_js_opts();
     $opts['dragdrop'] = true;
     $opts['multiselect'] = true;
     return $opts;
 }
示例#2
0
 /**
  * Gets search results for the datatable.
  *
  * @param array $filters The filter array received from js. It is an array consisting of filtername=>data, and can be
  *                       passed directly to $this->get_filter_sql() to generate the required WHERE sql.
  * @param array $sort An array of field=>direction to specify sorting for the results.
  * @param int $limitfrom The position in the dataset from which to start returning results.
  * @param int $limitnum The amount of results to return.
  * @return array An array with the first value being a page of results, and the second value being the total number of results
  */
 protected function get_search_results(array $filters, array $sort = array(), $limitfrom = null, $limitnum = null)
 {
     // Get the number of results in the full dataset.
     $joinsql = implode(' ', $this->get_join_sql($filters));
     $filtersfordisabled = $filters;
     if (!empty($filters['enrolled']) && ($filters['enrolled'][0] === 'all' || $filters['enrolled'][0] === 'enrolled')) {
         $filtersfordisabled['enrolled'][0] = 'enrolled';
         list($filtersql, $filterparams) = $this->get_filter_sql($filtersfordisabled);
         $query = 'SELECT count(1) as count FROM {' . $this->main_table . '} element ' . $joinsql . ' ' . $filtersql;
         $results = $this->DB->get_record_sql($query, $filterparams);
         $this->disabledresults = (int) $results->count;
     }
     return parent::get_search_results($filters, $sort, $limitfrom, $limitnum);
 }
示例#3
0
 /**
  * Limits results according to permissions.
  * @param array $filters An array of requested filter data. Formatted like [filtername]=>[data].
  * @return array An array consisting of the SQL WHERE clause, and the parameters for the SQL.
  */
 protected function get_filter_sql(array $filters)
 {
     global $USER;
     list($filtersql, $filterparams) = parent::get_filter_sql($filters);
     $additionalfilters = array();
     // Permissions.
     list($permadditionalfilters, $permadditionalparams) = $this->get_filter_sql_permissions();
     $additionalfilters = array_merge($additionalfilters, $permadditionalfilters);
     $filterparams = array_merge($filterparams, $permadditionalparams);
     // Add our additional filters.
     $filtersql = !empty($filtersql) ? $filtersql . ' AND ' . implode(' AND ', $additionalfilters) : 'WHERE ' . implode(' AND ', $additionalfilters);
     return array($filtersql, $filterparams);
 }