* Copyright (c) 2002-2006 Platon Group, http://platon.sk/ * All rights reserved. * * See README file for more information about this software. * See COPYING file for license information. * * Download the latest version from * http://platon.sk/projects/phpMyEdit/ */ /* $Platon: Metafox/lib/phpMyEdit/extensions/phpMyEdit-messages.class.php,v 1.7 2013-10-09 10:24:43 igor Exp $ */ /* This extension is part of phpMyEzin: Content Management System project, where it handles discussion messages for particular articles. It depends on some phpMyEzin characteristics, thus extension should not and cannot be used outside this project. However there are planned some improvements for future to make this extension handle any kind of tree-structured data. */ require_once dirname(__FILE__).'/../phpMyEdit.class.php'; 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) /* {{{ */ { $execute = 1; isset($opts['execute']) && $execute = $opts['execute']; $opts['execute'] = 0; parent::phpMyEdit($opts); $this->tb2 = $opts['tb2']; $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. */ $this->ezin_admin_article = $this->get_data_cgi_var('article_id'); if ($this->ezin_admin_article <= 0) { $this->ezin_admin_article = $this->get_sys_cgi_var('ezin_admin_article_up'); } if ($this->ezin_admin_article <= 0) { $this->ezin_admin_article = $this->get_sys_cgi_var('ezin_admin_article_down'); } $this->ezin_admin_article = intval($this->ezin_admin_article); $execute && $this->execute(); } /* }}} */ function list_table() /* {{{ */ { $query = sprintf('SELECT article_id, count(id) AS messages FROM %s' .' GROUP BY article_id HAVING article_id = %d', $this->tb, intval($this->ezin_admin_article)); if (($result = $this->myquery($query)) == false) { return false; } $row = @mysql_fetch_array($result, MYSQL_ASSOC); //$ezin_admin_article = intval($row['article_id']); $ezin_admin_msgcount = intval($row['messages']); @mysql_free_result($result); echo '
',"\n"; } /* }}} */ function message_process($article_id, $id, $level = 0, $parent = true) /* {{{ */ { $id = intval($id); $level = intval($level); $query = sprintf('SELECT id, parent, article_id, author,' .' email, homepage, subject, datetime, ip' .' FROM %s WHERE %s = %d AND article_id = %d' .' ORDER BY datetime ASC', $this->tb, $parent == true ? 'parent' : 'id', intval($id), intval($article_id)); if (($result = $this->myquery($query)) == false) { return false; } $ar = array(); $ar_out = array(); for ($i = 0; ($row = @mysql_fetch_array($result, MYSQL_ASSOC)); $i++) { $ar[$i] = $row; $ar_out[] = $row['id']; } $checked = ! $level && $parent ? ' checked' : ''; for ($i = 0; $i < count($ar); $i++) { echo '| ',"\n"; $this->print_article_select($article_id, 0, $position); echo ' | ',"\n"; echo '',"\n"; if ($article_id > 0) { if ($this->add_enabled()) { echo $this->htmlSubmit('operation', 'Add', $this->getCSSclass('add', $position), false, false); } if ($this->view_enabled()) { echo ' '; echo $this->htmlSubmit('operation', 'View', $this->getCSSclass('view', $position), false, $messages_count <= 0); } if ($this->change_enabled()) { echo ' '; echo $this->htmlSubmit('operation', 'Change', $this->getCSSclass('change', $position), false, $messages_count <= 0); } if ($this->delete_enabled()) { echo ' '; echo $this->htmlSubmit('operation', 'Delete', $this->getCSSclass('delete', $position), false, $messages_count <= 0); } } echo ' |
| ',"\n"; $this->print_article_select($this->ezin_admin_article, 1, $position); echo ' | ',"\n"; if (strlen(@$this->message) > 0) { echo '',"\n"; } echo '',"\n"; if ($this->change_operation()) { echo $this->htmlSubmit('savechange', 'Save', $this->getCSSclass('save', $position), true), ' '; echo $this->htmlSubmit('morechange', 'Apply', $this->getCSSclass('more', $position), true), ' '; echo $this->htmlSubmit('cancelchange', 'Cancel', $this->getCSSclass('cancel', $position), false); } elseif ($this->add_operation()) { echo $this->htmlSubmit('saveadd', 'Save', $this->getCSSclass('save', $position), true), ' '; echo $this->htmlSubmit('moreadd', 'More', $this->getCSSclass('more', $position), true), ' '; echo $this->htmlSubmit('canceladd', 'Cancel', $this->getCSSclass('cancel', $position), false); } elseif ($this->delete_operation()) { echo $this->htmlSubmit('savedelete', 'Delete', $this->getCSSclass('save', $position), false), ' '; echo $this->htmlSubmit('canceldelete', 'Cancel', $this->getCSSclass('cancel', $position), false); } elseif ($this->view_operation()) { if ($this->change_enabled()) { echo $this->htmlSubmit('operation', 'Change', $this->getCSSclass('save', $position), false), ' '; } echo $this->htmlSubmit('cancelview', 'Cancel', $this->getCSSclass('cancel', $position), false); } // Message is now written here echo ' | ',"\n"; echo '