| verzia 1.18, 2013/10/10 11:11:13 |
verzia 1.19, 2013/10/10 17:16:24 |
| Riadok 29 require_once dirname(__FILE__).'/../phpM |
|
| Riadok 29 require_once dirname(__FILE__).'/../phpM |
|
| |
|
| class phpMyEdit_messages extends phpMyEdit |
class phpMyEdit_messages extends phpMyEdit |
| { |
{ |
| |
|
| |
// Record manipulation |
| |
var $ezin_admin_article; |
| |
|
| |
// Operation |
| |
var $deleteallinvalid; |
| |
|
| |
// Internal cache |
| |
var $_cache_get_absolut_message_parent; |
| |
|
| function phpMyEdit_messages($opts) /* {{{ */ |
function phpMyEdit_messages($opts) /* {{{ */ |
| { |
{ |
| $execute = 1; |
$execute = 1; |
| Riadok 37 class phpMyEdit_messages extends phpMyEd |
|
| Riadok 47 class phpMyEdit_messages extends phpMyEd |
|
| parent::phpMyEdit($opts); |
parent::phpMyEdit($opts); |
| $this->tb2 = $opts['tb2']; |
$this->tb2 = $opts['tb2']; |
| $this->format_date = $opts['format_date']; |
$this->format_date = $opts['format_date']; |
| |
$this->deleteallinvalid = $this->get_sys_cgi_var('operation'); |
| |
$this->labels['Delete All'] = 'Delete All'; |
| |
|
| /* Preserved article ID in CGI environment. */ |
/* Preserved article ID in CGI environment. */ |
| /* TODO: change to $this->article_id or something like this */ |
$this->ezin_admin_article = $this->get_data_cgi_var('article_id'); |
| global $ezin_admin_article; |
if ($this->ezin_admin_article <= 0) { |
| $ezin_admin_article = $this->get_data_cgi_var('article_id'); |
$this->ezin_admin_article = $this->get_sys_cgi_var('ezin_admin_article_up'); |
| $ezin_admin_article = intval($ezin_admin_article); |
|
| if ($ezin_admin_article <= 0) { |
|
| $ezin_admin_article = $this->get_sys_cgi_var('ezin_admin_article_up'); |
|
| } |
} |
| if ($ezin_admin_article <= 0) { |
if ($this->ezin_admin_article <= 0) { |
| $ezin_admin_article = $this->get_sys_cgi_var('ezin_admin_article_down'); |
$this->ezin_admin_article = $this->get_sys_cgi_var('ezin_admin_article_down'); |
| } |
} |
| $ezin_admin_article = intval($ezin_admin_article); |
$this->ezin_admin_article = intval($this->ezin_admin_article); |
| //echo "[$ezin_admin_article]"; |
|
| |
|
| $execute && $this->execute(); |
$execute && $this->execute(); |
| } /* }}} */ |
} /* }}} */ |
| |
|
| function list_table() /* {{{ */ |
function list_table() /* {{{ */ |
| { |
{ |
| global $ezin_admin_article; |
|
| $query = sprintf('SELECT article_id, count(id) AS messages FROM %s' |
$query = sprintf('SELECT article_id, count(id) AS messages FROM %s' |
| .' GROUP BY article_id HAVING article_id = %d', |
.' GROUP BY article_id HAVING article_id = %d', |
| $this->tb, intval($ezin_admin_article)); |
$this->tb, intval($this->ezin_admin_article)); |
| if (($result = $this->myquery($query)) == false) { |
if (($result = $this->myquery($query)) == false) { |
| return false; |
return false; |
| } |
} |
| Riadok 72 class phpMyEdit_messages extends phpMyEd |
|
| Riadok 79 class phpMyEdit_messages extends phpMyEd |
|
| echo '<form class="',$this->getCSSclass('form'); |
echo '<form class="',$this->getCSSclass('form'); |
| echo '" action="',$page_name,'" method="POST">',"\n"; |
echo '" action="',$page_name,'" method="POST">',"\n"; |
| |
|
| if ($this->nav_up() || $ezin_admin_article <= 0) { |
if ($this->nav_up() || $this->ezin_admin_article <= 0) { |
| $this->message_nav_buttons($ezin_admin_article, $ezin_admin_msgcount, 'up'); |
$this->message_nav_buttons($this->ezin_admin_article, $ezin_admin_msgcount, 'up'); |
| echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n"; |
echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n"; |
| } |
} |
| |
|
| if ($ezin_admin_article > 0) { |
if ($this->ezin_admin_article> 0) { |
| echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n"; |
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n"; |
| echo '<tr class="',$this->getCSSclass('header'),'">',"\n"; |
echo '<tr class="',$this->getCSSclass('header'),'">',"\n"; |
| foreach (array('ID', 'Subject', ' ', 'Author', 'Date & Time', 'IP addresses') as $str) { |
foreach (array('ID', 'Subject', ' ', 'Author', 'Date & Time', 'IP addresses') as $str) { |
| Riadok 88 class phpMyEdit_messages extends phpMyEd |
|
| Riadok 95 class phpMyEdit_messages extends phpMyEd |
|
| echo '<tr class="',$this->getCSSclass('header'),'">',"\n"; |
echo '<tr class="',$this->getCSSclass('header'),'">',"\n"; |
| echo '<th class="',$this->getCSSclass('header'),'" colspan="6">'; |
echo '<th class="',$this->getCSSclass('header'),'" colspan="6">'; |
| echo 'Valid messages</td></tr>',"\n"; |
echo 'Valid messages</td></tr>',"\n"; |
| $message_ids = $this->message_process($ezin_admin_article, 0, 0); |
$message_ids = $this->message_process($this->ezin_admin_article, 0, 0); |
| $count_message_ids = count($message_ids); |
$count_message_ids = count($message_ids); |
| if ($count_message_ids == 0) { |
if ($count_message_ids == 0) { |
| echo '<tr class="',$this->getCSSclass('row', null, 'next'),'">',"\n"; |
echo '<tr class="',$this->getCSSclass('row', null, 'next'),'">',"\n"; |
| Riadok 99 class phpMyEdit_messages extends phpMyEd |
|
| Riadok 106 class phpMyEdit_messages extends phpMyEd |
|
| $query = sprintf('SELECT id, parent, article_id, author,' |
$query = sprintf('SELECT id, parent, article_id, author,' |
| .' email, homepage, subject, datetime, ip' |
.' email, homepage, subject, datetime, ip' |
| .' FROM %s WHERE article_id = %d ORDER BY datetime ASC', |
.' FROM %s WHERE article_id = %d ORDER BY datetime ASC', |
| $this->tb, intval($ezin_admin_article)); |
$this->tb, intval($this->ezin_admin_article)); |
| if (($result = $this->myquery($query)) == false) { |
if (($result = $this->myquery($query)) == false) { |
| return false; |
return false; |
| } |
} |
| Riadok 113 class phpMyEdit_messages extends phpMyEd |
|
| Riadok 120 class phpMyEdit_messages extends phpMyEd |
|
| $all_ids = array_diff($all_ids, $message_ids); |
$all_ids = array_diff($all_ids, $message_ids); |
| echo '<tr class="',$this->getCSSclass('header'),'">',"\n"; |
echo '<tr class="',$this->getCSSclass('header'),'">',"\n"; |
| echo '<th class="',$this->getCSSclass('header'),'" colspan="6">'; |
echo '<th class="',$this->getCSSclass('header'),'" colspan="6">'; |
| echo 'Invalid messages</td></tr>',"\n"; |
echo 'Invalid messages'; |
| |
if ($this->delete_enabled()) { |
| |
echo ' '; |
| |
echo $this->htmlSubmit('operation', $this->labels['Delete All'], $this->getCSSclass('delete'), false, false, 'onclick="return confirm(\'Realy delete ?\');"'); |
| |
} |
| |
echo '</td></tr>',"\n"; |
| if (count($all_ids) > 0) { |
if (count($all_ids) > 0) { |
| /* To force buttons */ |
/* To force buttons */ |
| $count_message_ids = -1; |
$count_message_ids = -1; |
| while (count($all_ids) > 0) { |
while (count($all_ids) > 0) { |
| //echo "<p>all_ids: "; var_dump($all_ids);echo '<br>'; |
//echo "<p>all_ids: "; var_dump($all_ids);echo '<br>'; |
| $sub_ids = $this->message_process($ezin_admin_article, |
$sub_ids = $this->message_process($this->ezin_admin_article, |
| $parents[array_shift($all_ids)], 0, true); |
$parents[array_shift($all_ids)], 0, true); |
| $all_ids = array_diff($all_ids, $sub_ids); |
$all_ids = array_diff($all_ids, $sub_ids); |
| } |
} |
| Riadok 131 class phpMyEdit_messages extends phpMyEd |
|
| Riadok 143 class phpMyEdit_messages extends phpMyEd |
|
| } |
} |
| echo '</table>'; |
echo '</table>'; |
| } |
} |
| if ($this->nav_down() && $ezin_admin_article > 0) { |
if ($this->nav_down() && $this->ezin_admin_article > 0) { |
| echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n"; |
echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n"; |
| $this->message_nav_buttons($ezin_admin_article, $ezin_admin_msgcount, 'down'); |
$this->message_nav_buttons($this->ezin_admin_article, $ezin_admin_msgcount, 'down'); |
| } |
} |
| // 2013-10-09 11:51 Igor |
// 2013-10-09 11:51 Igor |
| //echo $this->htmlHiddenData('article_id', $ezin_admin_article); |
//echo $this->htmlHiddenData('article_id', $ezin_admin_article); |
| Riadok 241 class phpMyEdit_messages extends phpMyEd |
|
| Riadok 253 class phpMyEdit_messages extends phpMyEd |
|
| |
|
| function display_record_buttons($position) /* {{{ */ |
function display_record_buttons($position) /* {{{ */ |
| { |
{ |
| global $ezin_admin_article; |
|
| echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n"; |
echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n"; |
| echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n"; |
echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n"; |
| echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n"; |
echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n"; |
| $this->print_article_select($ezin_admin_article, 1, $position); |
$this->print_article_select($this->ezin_admin_article, 1, $position); |
| echo '</td>',"\n"; |
echo '</td>',"\n"; |
| if (strlen(@$this->message) > 0) { |
if (strlen(@$this->message) > 0) { |
| echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n"; |
echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n"; |
| Riadok 325 class phpMyEdit_messages extends phpMyEd |
|
| Riadok 336 class phpMyEdit_messages extends phpMyEd |
|
| return true; |
return true; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| |
function execute() { |
| |
if ($this->deleteallinvalid == $this->labels['Delete All']) { |
| |
$this->delete_enabled() && $this->do_delete_all_invalid_records(); |
| |
$this->deleteallinvalid = null; |
| |
} |
| |
parent::execute(); |
| |
} |
| |
|
| |
function get_absolut_message_parent($id) { |
| |
$id = intval($id); |
| |
if (isset($this->_cache_get_absolut_message_parent[$id])) { |
| |
return $this->_cache_get_absolut_message_parent[$id]; |
| |
} |
| |
$query = sprintf('SELECT id, parent' |
| |
.' FROM %s' |
| |
.' WHERE id = %d', |
| |
$this->tb, |
| |
intval($id)); |
| |
if (($result = $this->myquery($query)) == false) { |
| |
return false; |
| |
} |
| |
$message = @mysql_fetch_array($result, MYSQL_ASSOC); |
| |
if ($message == false) { |
| |
$this->_cache_get_absolut_message_parent[$id] = false; |
| |
return false; |
| |
} |
| |
$this->_cache_get_absolut_message_parent[$id] = ($message['parent'] == '0') |
| |
? $message['id'] |
| |
: $this->get_absolut_message_parent($message['parent']); |
| |
return $this->_cache_get_absolut_message_parent[$id]; |
| |
} |
| |
|
| |
function get_invalid_messages($article_id) /* {{{ */ |
| |
{ |
| |
$query = sprintf('SELECT *' |
| |
.' FROM %s' |
| |
.' WHERE article_id = %d' |
| |
.' AND parent != 0', |
| |
$this->tb, |
| |
intval($article_id)); |
| |
if (($result = $this->myquery($query)) == false) { |
| |
return false; |
| |
} |
| |
$ar = array(); |
| |
while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) { |
| |
if ($this->get_absolut_message_parent($row['parent']) == false) { |
| |
$ar[] = $row; |
| |
} |
| |
} |
| |
return $ar; |
| |
} |
| |
|
| |
function do_delete_all_invalid_records() |
| |
{ |
| |
$invalids = $this->get_invalid_messages($this->ezin_admin_article); |
| |
foreach ($invalids as $invalid) { |
| |
$oldvals = $invalid; |
| |
// Creating array of changed keys ($changed) |
| |
$changed = is_array($oldvals) ? array_keys($oldvals) : array(); |
| |
$newvals = array(); |
| |
// Before trigger |
| |
if ($this->exec_triggers('delete', 'before', $oldvals, $changed, $newvals) == false) { |
| |
return false; |
| |
} |
| |
// Real query |
| |
$query = 'DELETE FROM '.$this->tb.' WHERE ('.$this->key.' = ' |
| |
.$this->key_delim.$invalid[$this->key].$this->key_delim.')'; // ) |
| |
$res = $this->myquery($query, __LINE__); |
| |
$this->message = $this->sql_affected_rows($this->dbh).' '.$this->labels['record deleted']; |
| |
if (! $res) { |
| |
return false; |
| |
} |
| |
// Notify list |
| |
if (@$this->notify['delete'] || @$this->notify['all']) { |
| |
$this->email_notify($oldvals, false); |
| |
} |
| |
// Note change in log table |
| |
if ($this->logtable) { |
| |
$query = sprintf('INSERT INTO %s' |
| |
.' (updated, user, host, operation, tab, rowkey, col, oldval, newval)' |
| |
.' VALUES (NOW(), "%s", "%s", "delete", "%s", "%s", "%s", "%s", "")', |
| |
$this->logtable, addslashes($this->get_server_var('REMOTE_USER')), |
| |
addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb), |
| |
addslashes($this->rec), addslashes($key), addslashes(serialize($oldvals))); |
| |
$this->myquery($query, __LINE__); |
| |
} |
| |
// After trigger |
| |
if ($this->exec_triggers('delete', 'after', $oldvals, $changed, $newvals) == false) { |
| |
return false; |
| |
} |
| |
} |
| |
return true; |
| |
} |
| |
|
| |
|
| } |
} |
| |
|
| /* Modeline for ViM {{{ |
/* Modeline for ViM {{{ |