Ejemplo n.º 1
0
 protected function table_format(Table $table, $attrs)
 {
     $template = new Template('data_table.html');
     $template->table = $table;
     $template->links = false;
     $template->record = $table->get_default_record();
     $template->records = $table->get_records(false);
     return $template->render();
 }
Ejemplo n.º 2
0
 public function save($args)
 {
     if (!isset($args['schema'])) {
         $url = admin_url('admin.php?page=tabulate_schema');
         wp_redirect($url);
     }
     $db = new Database($this->wpdb);
     $schema = $db->get_table($args['schema']);
     $new_name = $args['schema'];
     if ($schema instanceof Table && !empty($args['new_name'])) {
         $schema->rename($args['new_name']);
         $new_name = $schema->get_name();
     }
     $template = new Template('schema.html');
     $template->add_notice('updated', 'Schema updated.');
     $url = admin_url('admin.php?page=tabulate_schema&schema=' . $new_name);
     wp_redirect($url);
 }
Ejemplo n.º 3
0
 public function save()
 {
     $grants = new \WordPress\Tabulate\DB\Grants();
     // Validate the POSTed grants.
     $new_grants = array();
     foreach ($_POST as $table => $table_grants) {
         if (in_array($table, $this->table_names)) {
             $new_grants[$table] = array();
             foreach ($table_grants as $capability => $roles) {
                 if (in_array($capability, $grants->get_capabilities())) {
                     $new_grants[$table][$capability] = array_keys($roles);
                 }
             }
         }
     }
     // Save the grants and return to the granting table.
     $grants->set($new_grants);
     $this->template->add_notice('updated', 'Grants saved.');
     wp_redirect($this->get_url('index'));
     exit;
 }