function phpMyEdit_messages($opts)
 {
     $execute = 1;
     isset($opts['execute']) && ($execute = $opts['execute']);
     $opts['execute'] = 0;
     parent::phpMyEdit($opts);
     $this->tb2 = $opts['tb2'];
     $this->format_date = $opts['format_date'];
     /* Preserved article ID in CGI environment. */
     /* TODO: change to $this->article_id or something like this */
     global $ezin_admin_article;
     $ezin_admin_article = $this->get_data_cgi_var('article_id');
     $execute && $this->execute();
 }
 function execute($opts)
 {
     if ($this->get_sys_cgi_var('rec_change') && ($this->next_operation() || $this->prev_operation())) {
         $this->operation = $this->labels['Change'];
     }
     if (!$this->change_operation()) {
         $this->operation = $this->labels['View'];
     }
     if ($this->prev_operation()) {
         !$this->ext['prev_disabled'] && ($this->rec = $this->get_sys_cgi_var('rec_prev'));
         $this->prev = '';
     }
     if ($this->next_operation()) {
         !$this->ext['next_disabled'] && ($this->rec = $this->get_sys_cgi_var('rec_next'));
         $this->next = '';
     }
     if (!$this->rec) {
         $this->rec = $this->ext['rec'];
     }
     if (!$this->rec || !$this->ext['prev_disable'] && !$this->ext['prev'] || !$this->ext['next_disable'] && !$this->ext['next']) {
         if ($this->connect() == false) {
             return false;
         }
         $query_parts = array('type' => 'select', 'select' => 'PMEtable0.' . $this->key, 'from' => $this->get_SQL_join_clause(), 'where' => $this->get_SQL_where_from_query_opts());
         // TODO: order by clausule according to default sort order options
         $res = $this->myquery($this->get_SQL_query($query_parts), __LINE__);
         $ids = array();
         while (($row = @mysql_fetch_array($res, MYSQL_NUM)) !== false) {
             $ids[] = $row[0];
         }
         @mysql_free_result($res);
         if ($this->rec) {
             $idx = array_search($this->rec, $ids);
             $idx === false && ($idx = 0);
         } else {
             $idx = 0;
         }
         $this->rec = $ids[$idx];
         !$this->ext['prev'] && ($this->ext['prev'] = $ids[$idx - 1]);
         !$this->ext['next'] && ($this->ext['next'] = $ids[$idx + 1]);
     }
     $this->default_buttons['V'] = array('change', 'cancel', isset($this->ext['prev']) ? '+prev' : 'prev', isset($this->ext['next']) ? '+next' : 'next', array('code' => '<input type="hidden" name="' . $this->cgi['prefix']['sys'] . 'rec_prev" value="' . $this->ext['prev'] . '">'), array('code' => '<input type="hidden" name="' . $this->cgi['prefix']['sys'] . 'rec_next" value="' . $this->ext['next'] . '">'));
     $this->recreate_fdd();
     $this->recreate_displayed();
     parent::execute();
 }
Example #3
0
 function get_data_cgi_var($name, $default_value = null)
 {
     if (isset($this)) {
         return $this->get_cgi_var($this->cgi['prefix']['data'] . $name, $default_value);
     }
     return phpMyEdit::get_cgi_var(phpMyEdit::get_default_cgi_prefix('data') . $name, $default_value);
 }
 function execute()
 {
     global $HTTP_GET_VARS;
     global $HTTP_POST_VARS;
     /*
      * Extracting field names
      */
     $table_cols = array();
     $all_table_cols = array();
     if ($this->connect() == false) {
         return false;
     }
     $query_parts = array('type' => 'select', 'select' => '*', 'from' => $this->tb, 'limit' => '1');
     $result = $this->myquery($this->get_SQL_query($query_parts), __LINE__);
     $all_table_cols = array_keys(@mysql_fetch_array($result, MYSQL_ASSOC));
     if (count($all_table_cols) <= 0) {
         $this->error('database fetch error');
         return false;
     }
     foreach (array_keys($this->fdd) as $field_name) {
         if (preg_match('/^\\d*$/', $field_name)) {
             continue;
         }
         if (($idx = array_search($field_name, $all_table_cols)) !== false) {
             $table_cols[$field_name] = mysql_field_len($result, $idx);
         }
     }
     @mysql_free_result($result);
     unset($all_table_cols);
     /*
      * Preparing variables
      */
     $fields_select = $this->get_cgi_var('fields_select');
     $filter = $this->get_cgi_var('filter');
     $prepare_filter = $this->get_cgi_var('prepare_filter');
     $this->inc = intval($this->get_cgi_cookie_var('inc'));
     $force_select = true;
     $none_displayed = true;
     $expire_time = time() + 3600 * 24 * 30 * 12 * 5;
     // five years
     $headers_sent = @headers_sent();
     foreach (array_merge(array('@inc'), array_keys($table_cols)) as $col) {
         $varname = $col[0] == '@' ? substr($col, 1) : 'have_' . $col;
         if (isset($HTTP_POST_VARS[$varname]) || isset($HTTP_GET_VARS[$varname])) {
             $value = $HTTP_POST_VARS[$varname];
             if (isset($HTTP_GET_VARS[$varname])) {
                 $value = $HTTP_GET_VARS[$varname];
             }
             if ($varname != 'inc' && !empty($value)) {
                 $force_select = false;
             }
             $headers_sent || setcookie($varname . '_' . $this->tb . '_cookie', $value, $expire_time);
             $this->cgi['persist'] .= '&' . urlencode($varname);
             $this->cgi['persist'] .= '=' . urlencode($value);
         } else {
             $headers_sent || setcookie($varname . '_' . $this->tb . '_cookie', '', time() - 10000);
         }
     }
     $i = -1;
     foreach (array_keys($this->fdd) as $key) {
         $i++;
         if (preg_match('/^\\d*$/', $key)) {
             continue;
         }
         $varname = 'have_' . $key;
         $value = @$this->get_cgi_cookie_var($varname, '');
         $options = @$value ? 'LV' : '';
         $this->fdd[$i]['options'] = $options;
         $this->fdd[$key]['options'] = $options;
         $this->displayed[$i] = @$value ? true : false;
         $value && ($none_displayed = false);
     }
     /*
      * Redirecting when neccessary
      * (hackity hack with unregistering/unchecking fields)
      */
     if ($prepare_filter && !$headers_sent) {
         $this->execute_redirect();
         exit;
     }
     /*
      * Check if field selection report screen has to be displayed
      */
     if (isset($fields_select) || $force_select || $none_displayed) {
         $this->execute_report_screen($table_cols);
         return true;
     }
     if (0) {
         $this->message .= $this->get_select_fields_link();
     }
     // parent class call
     return parent::execute();
 }