function occindex($content = null)
 {
     if (is_array($content)) {
         if ($content['nm']['rows']['delete']) {
             list($id) = each($content['nm']['rows']['delete']);
             unset($content['nm']['rows']['delete']);
             if ($this->occ->delete(array('cp_occ_id' => $id))) {
                 $content['msg'] = lang('Occurence deleted');
             } else {
                 $content['msg'] = lang('Delete failed!');
             }
         }
     } else {
         $content['msg'] = $_GET['msg'];
     }
     // initializing of thwe nextmatch widget, through reading of stored sessiondata
     $content['nm'] = $GLOBALS['egw']->session->appsession('occ_session_data', 'courseprotocol');
     $content['nm'] = array('get_rows' => 'courseprotocol.uicourseprotocol.get_rows_occ', 'filter_label' => '', 'filter_help' => '', 'no_filter' => True, 'no_filter2' => True, 'never_hide' => True, 'lettersearch' => False, 'searchletter' => '', 'start' => 0, 'order' => 'cp_occ_date', 'sort' => 'DESC', 'col_filter' => array(), 'default_cols' => '!cp_occ_analy');
     $content['msg'] = $_GET['msg'];
     //_debug_array($content);
     $this->tmpl->read('courseprotocol.occindex');
     $this->tmpl->set_cell_attribute('debuginfo', 'disabled', !$debug);
     $this->tmpl->set_cell_attribute('myhrule', 'disabled', !$separator);
     $this->tmpl->exec('courseprotocol.uicourseprotocol.occindex', $content, array('cp_occ_type' => $this->oc_types), array(), $preserv);
     // the debug info will be displayed at the very end of the page
     //_debug_array($content);
 }
 function needs_save($cont = '', $posted_app = '', $posted_table = '', $edited_table = '')
 {
     if (!$posted_app && is_array($cont)) {
         if (isset($cont['yes'])) {
             $this->app = $cont['app'];
             $this->table = $cont['table'];
             $this->read($this->app, $this->data);
             $this->data[$this->table] = $cont['edited_table'];
             $this->changes = $cont['changes'];
             if ($cont['new_version']) {
                 $this->update($this->app, $this->data, $cont['new_version']);
             } else {
                 foreach ($this->data as $tname => $tinfo) {
                     $tables .= ($tables ? ',' : '') . "'{$tname}'";
                 }
                 $this->setup_version($this->app, '', $tables);
             }
             $msg .= $this->write($this->app, $this->data) ? lang('File writen') : lang('Error: writing file (no write-permission for the webserver) !!!');
         }
         $this->changes = array();
         // return to edit with everything set, so the user gets the table he asked for
         $this->edit(array('app' => $cont['new_app'], 'table_name' => $cont['app'] == $cont['new_app'] ? $cont['new_table'] : '', 'posted_app' => $cont['new_app']), $msg);
         return True;
     }
     $new_app = $this->app;
     // these are the ones, the users whiches to change too
     $new_table = $this->table;
     $this->app = $posted_app;
     $this->data = array();
     $this->read($posted_app, $this->data);
     if (isset($this->data[$posted_table]) && $this->tables_identical($this->data[$posted_table], $edited_table)) {
         if ($new_app != $this->app) {
             $this->app = $new_app;
             // if we change init the data empty
             $this->data = array();
         }
         return False;
         // continue edit
     }
     $content = array('app' => $posted_app, 'table' => $posted_table, 'version' => $this->setup_version($posted_app));
     $preserv = $content + array('new_app' => $new_app, 'new_table' => $new_table, 'edited_table' => $edited_table, 'changes' => $this->changes);
     $new_version = explode('.', $content['version']);
     $minor = count($new_version) - 1;
     $new_version[$minor] = sprintf('%03d', 1 + $new_version[$minor]);
     $content['new_version'] = implode('.', $new_version);
     $tmpl = new etemplate('etemplate.db-tools.ask_save');
     if (!file_exists(PHPGW_SERVER_ROOT . "/{$posted_app}/setup/tables_current.inc.php")) {
         $tmpl->disable_cells('version');
         $tmpl->disable_cells('new_version');
     }
     $tmpl->exec('etemplate.db_tools.needs_save', $content, array(), array(), $preserv);
     return True;
     // dont continue in edit
 }
 function show($post_vars = '')
 {
     if ($this->debug) {
         echo "<p>etemplate.editor.show: content=";
         _debug_array($post_vars);
     }
     if (!is_array($post_vars)) {
         $post_vars = array();
     }
     if (!is_array($this->extensions) && isset($post_vars['**extensions**'])) {
         $this->extensions = $post_vars['**extensions**'];
         unset($post_vars['**extensions**']);
     }
     if (isset($_GET['name']) && !$this->etemplate->read($_GET) || isset($post_vars['name']) && !$this->etemplate->read($post_vars)) {
         $msg = lang('Error: Template not found !!!');
         if (isset($post_vars['name'])) {
             $post_vars['version'] = '';
             // trying it without version
             if ($this->etemplate->read($post_vars)) {
                 $msg = lang('only an other Version found !!!');
             }
         }
     }
     if (!$msg && isset($post_vars['delete'])) {
         $this->delete(array(), 'show');
         return;
     }
     if (isset($post_vars['edit'])) {
         $this->edit();
         return;
     }
     list($app) = explode('.', $this->etemplate->name);
     if ($app && $app != 'etemplate') {
         $GLOBALS['phpgw']->translation->add_app($app);
         // load translations for app
     }
     $content = $this->etemplate->as_array() + array('msg' => $msg);
     $show = new etemplate('etemplate.editor.show');
     if (!$msg && isset($post_vars['values']) && !isset($post_vars['vals'])) {
         $cont = $post_vars['cont'];
         for ($r = 1; list($key, $val) = @each($cont); ++$r) {
             $vals["@{$r}"] = $key;
             $vals["A{$r}"] = is_array($val) ? htmlspecialchars(serialize($val)) . '#SeR#' : $val;
         }
         $show->data[$show->rows]['A']['name'] = 'etemplate.editor.values';
         $show->data[$show->rows]['A']['size'] = 'vals';
         $content['vals'] = $vals;
     } else {
         $show->data[$show->rows]['A']['obj'] =& $this->etemplate;
         $vals = $post_vars['vals'];
         $olds = $post_vars['olds'];
         for ($r = 1; isset($vals["A{$r}"]); ++$r) {
             $content['cont'][$olds["@{$r}"]] = substr($vals["A{$r}"], -5) == '#SeR#' ? unserialize(substr($vals["A{$r}"], 0, -5)) : $vals["A{$r}"];
         }
     }
     $show->exec('etemplate.editor.show', $content, array(), '', array('olds' => $vals, '**extensions**' => $this->extensions), '');
 }