From d8948e6fc97e5c5e6ae4c298eceaf371f37e5a5b Mon Sep 17 00:00:00 2001 From: "Duck (Jakob Munih)" Date: Sun, 1 Mar 2009 15:15:24 +0100 Subject: [PATCH] Add option to delete a picture from a news. Add driver based class --- news/edit.php | 59 ++- news/files.php | 21 +- news/lib/Driver.php | 77 ++++ news/lib/Driver/sql.php | 632 +++++++++++++++++++++++++++++ news/lib/News.php | 8 +- news/lib/Search.php | 139 +++++++ news/lib/version.php | 1 + news/mail.php | 10 +- news/po/news.pot | 261 ++++++------ news/templates/edit/info.inc | 107 ----- news/templates/edit/info.php | 17 +- news/themes/microfila/graphics/favicon.ico | Bin 318 -> 0 bytes 12 files changed, 1068 insertions(+), 264 deletions(-) create mode 100644 news/lib/Driver.php create mode 100644 news/lib/Driver/sql.php create mode 100644 news/lib/Search.php create mode 100755 news/lib/version.php delete mode 100755 news/templates/edit/info.inc delete mode 100755 news/themes/microfila/graphics/favicon.ico diff --git a/news/edit.php b/news/edit.php index c558738cc..95e0d3ab0 100644 --- a/news/edit.php +++ b/news/edit.php @@ -23,9 +23,9 @@ if (empty($allowed_cats)) { exit; } -$id = Util::getFormData('id', 0); -$page = Util::getFormData('page', 0); -$browse_url = Horde::applicationUrl('edit.php'); +$id = (int)Util::getFormData('id', 0); +$page = (int)Util::getFormData('page', 0); +$browse_url = Util::addParameter(Horde::applicationUrl('edit.php'), array('page' => $page, 'id' => $id), null, false); $edit_url = Horde::applicationUrl('add.php'); $read_url = Horde::applicationUrl('reads.php'); $has_comments = $registry->hasMethod('forums/doComments'); @@ -33,7 +33,7 @@ $actionID = Util::getFormData('actionID'); // save as future version if (!empty($actionID) && $id > 0) { - $version = $news->db->getOne('SELECT MAX(version) FROM ' . $news->prefix . '_versions WHERE id=?', array($id)); + $version = $news->db->getOne('SELECT MAX(version) FROM ' . $news->prefix . '_versions WHERE id = ?', array($id)); $result = $news->write_db->query('INSERT INTO ' . $news->prefix . '_versions (id, version, action, created, user_uid) VALUES (?,?,?,NOW(),?)', array($id, $version + 1, $actionID, Auth::getAuth())); } @@ -43,9 +43,32 @@ if ($id) { } switch ($actionID) { +case 'deletepicture'; + + $result = News::deleteImage($id); + if ($result instanceof PEAR_Error) { + $notification->push($result); + } + + $result = $news->write_db->query('UPDATE ' . $news->prefix . ' SET picture = ? WHERE id = ?', array(0, $id)); + if ($result instanceof PEAR_Error) { + $notification->push($result); + } else { + $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("picture deleted")), 'horde.success'); + } + + header('Location: ' . $browse_url); + exit; + +break; + case 'deactivate'; - $news->write_db->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::UNCONFIRMED, $id)); + $result = $news->write_db->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::UNCONFIRMED, $id)); + if ($result instanceof PEAR_Error) { + $notification->push($result); + } + $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("deactivated")), 'horde.success'); header('Location: ' . $browse_url); exit; @@ -53,7 +76,11 @@ case 'deactivate'; break; case 'activate'; - $news->write_db->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::CONFIRMED, $id)); + $result = $news->write_db->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::CONFIRMED, $id)); + if ($result instanceof PEAR_Error) { + $notification->push($result); + } + $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("activated")), 'horde.success'); header('Location: ' . $browse_url); exit; @@ -61,7 +88,11 @@ case 'activate'; break; case 'lock'; - $news->write_db->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::LOCKED, $id)); + $result = $news->write_db->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::LOCKED, $id)); + if ($result instanceof PEAR_Error) { + $notification->push($result); + } + $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("locked")), 'horde.success'); header('Location: ' . $browse_url); exit; @@ -69,7 +100,11 @@ case 'lock'; break; case 'unlock'; - $news->write_db->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::UNCONFIRMED, $id)); + $result = $news->write_db->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::UNCONFIRMED, $id)); + if ($result instanceof PEAR_Error) { + $notification->push($result); + } + $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("unlocked")), 'horde.success'); header('Location: ' . $browse_url); exit; @@ -81,9 +116,15 @@ case 'renew'; $version_data = $news->db->getRow('SELECT content FROM ' . $news->prefix . '_versions WHERE id = ? AND version = ?', array($id, $version), DB_FETCHMODE_ASSOC); + if ($version_data instanceof PEAR_Error) { + $notification->push($version_data); + } $version_data['content'] = unserialize($version_data['content']); - $news->write_db->query('DELETE FROM ' . $news->prefix . '_body WHERE id = ?', array($id)); + $result = $news->write_db->query('DELETE FROM ' . $news->prefix . '_body WHERE id = ?', array($id)); + if ($result instanceof PEAR_Error) { + $notification->push($result); + } $new_version = array(); $sql = 'INSERT INTO ' . $news->prefix . '_body (id,lang,title,abbreviation,content) VALUES (?,?,?,?,?)'; diff --git a/news/files.php b/news/files.php index 58a135c2e..f673499c6 100644 --- a/news/files.php +++ b/news/files.php @@ -35,6 +35,11 @@ case 'download_file': case 'view_file': $data = file_get_contents($conf['attributes']['attachments'] . '/' . $file_id); + if ($data === false) { + header('HTTP/1.0 404 Not Found'); + echo 'HTTP/1.0 404 Not Found'; + exit; + } $mime_part = new Horde_Mime_Part(); $mime_part->setName($file_id); @@ -47,15 +52,15 @@ case 'view_file': if (!empty($render)) { reset($render); $key = key($render); - $browser->downloadHeaders($file_id, $render[$key]['type'], true, strlen($render[$key]['data'])); + $browser->downloadHeaders($file_name, $render[$key]['type'], true, strlen($render[$key]['data'])); echo $render[$key]['data']; } - } else { - // We cannnot see this file, so download it - $browser->downloadHeaders($file_name, $file_type, false, $file_size); - echo $data; } + // We cannnot see this file, so download it + $browser->downloadHeaders($file_name, $file_type, false, $file_size); + echo $data; + break; case 'download_zip_all': @@ -88,6 +93,12 @@ case 'download_zip': $zipfiles = array('data' => file_get_contents($conf['attributes']['attachments'] . '/' . $file_id), 'name' => $file_id); + if ($zipfiles[0]['data'] === false) { + header('HTTP/1.0 404 Not Found'); + echo 'HTTP/1.0 404 Not Found'; + exit; + } + $zip = Horde_Compress::singleton('zip'); $body = @$zip->compress($zipfiles); $browser->downloadHeaders($file_id . '.zip', 'application/zip', false, strlen($body)); diff --git a/news/lib/Driver.php b/news/lib/Driver.php new file mode 100644 index 000000000..d759af623 --- /dev/null +++ b/news/lib/Driver.php @@ -0,0 +1,77 @@ + + * @package News + */ +class News_Driver { + + /** + * Hash containing connection parameters. + * + * @var array + */ + protected $_params = array(); + + /** + * Attempts to return a concrete News_Driver instance based on $driver. + * + * @param string $driver The type of the concrete News_Driver subclass + * to return. The class name is based on the + * storage driver ($driver). The code is + * dynamically included. + * + * @param array $params A hash containing any additional configuration + * or connection parameters a subclass might need. + * + * @return News_Driver The newly created concrete News_Driver + * instance, or false on an error. + */ + static function factory($driver = 'sql', $params = array()) + { + $class_name = 'News_Driver_' . $driver; + require_once NEWS_BASE . '/lib/Driver/' . $driver . '.php'; + + if (!class_exists($class_name)) { + Horde::fatal('DRIVER MISSING', __FILE__, __LINE__); + } + + return new $class_name($params); + } + + /** + * Get news + * + * @param int $news news id + * + * @return true on succes PEAR_Error on failure + */ + public function get($id) + { + // Admins bypass the cache (can read nonpublished and locked news) + if (!Auth::isAdmin('news:admin')) { + $key = 'news_' . News::getLang() . '_' . $id; + $data = $GLOBALS['cache']->get($key, $GLOBALS['conf']['cache']['default_lifetime']); + if ($data) { + return unserialize($data); + } + } + + $data = $this->_get($id); + if ($data instanceof PEAR_Error) { + return $data; + } + + if (!Auth::isAdmin('news:admin')) { + $GLOBALS['cache']->set($key, serialize($data)); + } + + return $data; + } +} diff --git a/news/lib/Driver/sql.php b/news/lib/Driver/sql.php new file mode 100644 index 000000000..6f04bf87e --- /dev/null +++ b/news/lib/Driver/sql.php @@ -0,0 +1,632 @@ + + * @package News + */ +class News_Driver_sql extends News_Driver { + + /** + * Handle for the current database connection. + * + * @var DB + */ + public $db; + + /** + * Handle for the current database connection, used for writing. Defaults + * to the same handle as $db if a separate write database is not required. + * + * @var DB + */ + public $write_db; + + /** + * Handle for the tables prefix. + * + * @var prefix + */ + public $prefix = 'news'; + + /** + * Constructor + */ + public function __construct() + { + $this->_params = Horde::getDriverConfig('storage', 'sql'); + $this->_connect(); + } + + /** + * Updates schedul comments counter + * + * @param int $id schedul id + * + * @return true on succes PEAR_Error on failure + */ + public function updateComments($id, $count) + { + return $this->write_db->query('UPDATE ' . $this->prefix . ' SET comments = ? WHERE id = ?', array($count, $id)); + } + + /** + * Get news + * + * @param int $news news id + * + * @return true on succes PEAR_Error on failure + */ + protected function _get($id) + { + $query = 'SELECT n.publish, n.user, n.source, n.sourcelink, n.category1, n.parents, ' . + ' n.category2, n.attachments, n.picture, n.comments, n.gallery, n.sponsored, ' . + ' l.title, l.content, l.picture_comment, l.tags, n.selling, n.trackbacks, n.threads, ' . + ' n.form_id, n.form_ttl FROM ' . $this->prefix . ' AS n, ' . $this->prefix . '_body AS l ' . + ' WHERE n.id = ? AND n.id=l.id AND l.lang = ?'; + + /** TODO Allow for now to allow static linked news, but not shown in list + if (!Auth::isAdmin('news:admin')) { + $query .= ' AND n.status = ' . News::CONFIRMED; + } + */ + + $data = $this->db->getRow($query, array($id, News::getLang()), DB_FETCHMODE_ASSOC); + if ($data instanceof PEAR_Error) { + return $data; + } + + if (empty($data)) { + return PEAR::raiseError(sprintf(_("There requested news %s don't exist."), $id)); + } + + /* Get talks backs */ + if ($data['trackbacks']) { + $sql = 'SELECT excerpt, created, title, url, blog_name FROM ' . $this->prefix . '_trackback WHERE id = ?'; + $data['trackback'] = $this->db->getAll($sql, array($id), DB_FETCHMODE_ASSOC); + if ($data['trackback'] instanceof PEAR_Error) { + return $data['trackback']; + } + } + + /* Get parents */ + if ($data['parents']) { + $sql = 'SELECT n.id, n.publish, n.comments, l.title ' . + ' FROM ' . $this->prefix . ' AS n, ' . $this->prefix . '_body AS l ' . + ' WHERE n.id IN (' . $data['parents'] . ') AND n.id = l.id AND l.lang = ?'; + $data['parents'] = $this->db->getAssoc($sql, false, array(News::getLang()), DB_FETCHMODE_ASSOC); + if ($data['parents'] instanceof PEAR_Error) { + return $data['parents']; + } + } + + /* Get threads */ + if ($data['threads']) { + $sql = 'SELECT message_id, forum_id, message_subject, message_seq ' . + ' FROM agora_messages WHERE message_id IN (' . $data['threads'] . ')'; + $data['threads'] = $this->db->getAssoc($sql, false, null, DB_FETCHMODE_ASSOC); + if ($data['threads'] instanceof PEAR_Error) { + return $data['threads']; + } + } + + return $data; + } + + /** + * Get news attached files + * + * @param int $news_id news id + * @param string $news_lang news language + * + * @return true on succes PEAR_Error on failure + */ + public function getFiles($news_id, $news_lang = null) + { + if (is_null($news_lang)) { + $news_lang = News::getLang(); + } + + $sql = 'SELECT file_id, news_id, news_lang, file_name, file_size, file_type FROM ' . $this->prefix . '_files' + . ' WHERE news_id = ? AND news_lang = ?'; + + return $this->db->getAll($sql, array($news_id, $news_lang), DB_FETCHMODE_ASSOC); + } + + /** + * Get version + * + * @param intiger $id news id + * @param array $info array with all news info + * + * @return result of the insert + */ + public function getVerison($id, $version) + { + $sql = 'SELECT id, created, user_uid, content FROM ' . $this->prefix . '_versions WHERE id = ? AND version = ?'; + $result = $this->db->getRow($sql, array($id, $version), DB_FETCHMODE_ASSOC); + $result['content'] = unserialize($result['content']); + return $result; + } + + /** + * Get versions + * + * @param intiger $id news id + * @param array $info array with all news info + * + * @return result of the insert + */ + public function getVerisons($id) + { + $sql = 'SELECT version, created, user_uid, content, action FROM ' . $this->prefix . '_versions WHERE id = ? ORDER BY version DESC'; + return $this->db->getAll($sql, array($id), DB_FETCHMODE_ASSOC); + } + + /** + * Logs a news view. + * + * @return boolean True, if the view was logged, false if the message was aleredy seen + */ + public function logView($id) + { + if ($GLOBALS['browser']->isRobot()) { + exit; + } + + /* We already read this story? */ + if (isset($_COOKIE['news_viewed_news']) && + strpos($_COOKIE['news_viewed_news'], ':' . $id . '|') !== false) { + return false; + } + + /* Rembember when we see a story */ + if (!isset($_COOKIE['news_viewed_news'])) { + $_COOKIE['news_viewed_news'] = ':'; + } + $_COOKIE['news_viewed_news'] .= $id . '|' . $_SERVER['REQUEST_TIME'] . ':'; + + setcookie('news_viewed_news', $_COOKIE['news_viewed_news'], $_SERVER['REQUEST_TIME'] + 22896000, $GLOBALS['conf']['cookie']['path'], + $GLOBALS['conf']['cookie']['domain'], $GLOBALS['conf']['use_ssl'] == 1 ? 1 : 0); + + /* Update the count */ + $sql = 'UPDATE ' . $this->prefix . ' SET view_count = view_count + 1 WHERE id = ?'; + $result = $this->write_db->query($sql, array($id)); + if ($result instanceof PEAR_Error) { + return $result; + } + + /* Log it */ + $sql = 'INSERT INTO ' . $this->prefix . '_user_reads (id,user,ip,useragent,readdate) VALUES (?, ?, ? , ?, NOW())'; + $result = $this->write_db->query($sql, array($id, Auth::getAuth(), $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'])); + if ($result instanceof PEAR_Error) { + return $result; + } + + return true; + } + + /** + * Attach a trackback + */ + public function saveTrackback($id, $title, $url, $excerpt, $blog_name, $trackback_url) + { + $sql = 'SELECT COUNT(*) FROM ' . $this->prefix . '_trackback WHERE id = ? AND url = ?'; + $result = $this->db->getOne($sql, array($id, $url)); + if ($result > 0) { + return PEAR::raiseError(sprintf(_("URL already trackbacked: %s"), $url)); + } + + $params = array('id' => $id, + 'title' => $title, + 'url' => $url, + 'excerpt' => $excerpt, + 'blog_name' => $blog_name, + 'created' => date('Y-m-d H:i:s')); + + $sql = 'INSERT INTO ' . $this->prefix . '_trackback (' . implode(',', array_keys($params)) . ') VALUES (?, ?, ?, ?, ?, ?)'; + $result = $this->write_db->query($sql, $params); + if ($result instanceof PEAR_Error) { + return $result; + } + + /* Update trackback count */ + $GLOBALS['cache']->expire('news_' . News::getLang() . '_' . $id); + return $this->write_db->query('UPDATE ' . $this->prefix . ' SET trackbacks = trackbacks + 1 WHERE id = ?', array($id)); + } + + /** + * Delete a source + * + * @param integer $id The source id to delete. + * + * @return boolean + */ + public function deleteSource($id) + { + $GLOBALS['cache']->expire('newsSources'); + $this->deleteImage($id, 'sources'); + $sql = 'DELETE FROM ' . $this->prefix . '_sources WHERE sources_id = ?'; + return $this->write_db->query($sql, array($id)); + } + + /** + * Fetches sources list + * + * @return array An array containing all sources names + */ + public function getSources($flat = false) + { + $sources = $GLOBALS['cache']->get('newsSources'); + if (empty($sources)) { + $sql = 'SELECT source_id, source_name, source_url FROM ' . $this->prefix . '_sources ORDER BY source_name ASC'; + $sources = $this->db->getAssoc($sql, true, array(), DB_FETCHMODE_ASSOC); + $GLOBALS['cache']->set('newsSources', serialize($sources)); + } else { + $sources = unserialize($sources); + } + + if (!$flat) { + foreach ($sources as $source_id => $source) { + $sources[$source_id] = $source['source_name']; + } + } + + return $sources; + } + + /** + * Save a source data into the backend from edit form. + * + * @param array $info The source data to save. + * + * @return mixed PEAR error. + */ + public function saveSource($info) + { + /* Update/Insert source. */ + if (!empty($info['source_id'])) { + $result = $this->_updateSource($info['source_id'], $info); + if ($result instanceof PEAR_Error) { + return $result; + } + } else { + $info['source_id'] = $this->_insertSource($info); + if ($info['source_id'] instanceof PEAR_Error) { + return $info['source_id']; + } + } + + /* If image uploaded save to backend. */ + if (!empty($info['source_image']['name'])) { + $image = $this->_saveImage($info['source_id'], $info['source_image']['file'], 'sources', $info['source_image_resize']); + if ($image instanceof PEAR_Error) { + return $image; + } + + $sql = 'UPDATE ' . $this->prefix . '_sources SET source_image = ? WHERE source_id = ?'; + $this->write_db->query($sql, array(1, $info['source_id'])); + } + + $GLOBALS['cache']->expire('newsSources'); + return $info['source_id']; + } + + /** + * Insert source data. + * + * @param mixed $data The source data to insert. + * + * @return array Inserted ID or PEAR error. + */ + private function _insertSource($data) + { + $new_id = $this->write_db->nextId('news_sources'); + + $sql = 'INSERT INTO ' . $this->prefix . '_sources' . + ' (source_id, source_name, source_url)' . + ' VALUES (?, ?, ?)'; + $values = array($new_id, + $data['source_name'], + $data['source_url']); + + $source = $this->write_db->query($sql, $values); + if ($source instanceof PEAR_Error) { + Horde::logMessage($source, __FILE__, __LINE__, PEAR_LOG_ERR); + return $source; + } + + return $new_id; + } + + /** + * Update source data. + * + * @param integer $source_id The source id to update. + * @param array $data The source data to update. + * + * @return array NULL or PEAR error. + */ + private function _updateSource($source_id, $data) + { + $sql = 'UPDATE ' . $this->prefix . '_sources' . + ' SET source_name = ?, source_url = ?' . + ' WHERE source_id = ?'; + $values = array($data['source_name'], + $data['source_url'], + $source_id); + + $source = $this->write_db->query($sql, $values); + if ($source instanceof PEAR_Error) { + Horde::logMessage($source, __FILE__, __LINE__, PEAR_LOG_ERR); + return $source; + } + } + + /** + * Attempts to open a persistent connection to the SQL server. + * + * @return boolean True on success; exits (Horde::fatal()) on error. + */ + private function _connect() + { + Horde::assertDriverConfig($this->_params, 'storage', + array('phptype', 'charset')); + + if (!isset($this->_params['database'])) { + $this->_params['database'] = ''; + } + if (!isset($this->_params['username'])) { + $this->_params['username'] = ''; + } + if (!isset($this->_params['hostspec'])) { + $this->_params['hostspec'] = ''; + } + if (isset($this->_params['prefix'])) { + $this->prefix = $this->_params['prefix']; + } + + /* Connect to the SQL server using the supplied parameters. */ + require_once 'DB.php'; + $this->write_db = &DB::connect($this->_params, + array('persistent' => !empty($this->_params['persistent']))); + if ($this->write_db instanceof PEAR_Error) { + Horde::fatal($this->write_db, __FILE__, __LINE__); + } + + // Set DB portability options. + switch ($this->write_db->phptype) { + case 'mssql': + $this->write_db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS | DB_PORTABILITY_RTRIM); + break; + default: + $this->write_db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS); + } + + /* Check if we need to set up the read DB connection seperately. */ + if (!empty($this->_params['splitread'])) { + $params = array_merge($this->_params, $this->_params['read']); + $this->db = &DB::connect($params, + array('persistent' => !empty($params['persistent']))); + if ($this->db instanceof PEAR_Error) { + Horde::fatal($this->db, __FILE__, __LINE__); + } + + // Set DB portability options. + switch ($this->db->phptype) { + case 'mssql': + $this->db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS | DB_PORTABILITY_RTRIM); + break; + default: + $this->db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS); + } + + } else { + /* Default to the same DB handle for the writer too. */ + $this->db =& $this->write_db; + } + + return true; + } + + /** + * Build whare search + */ + public function buildQuery($perms = PERMS_READ, $criteria = array()) + { + static $parts; + + $id = serialize($criteria); + if (isset($parts[$id])) { + return $parts[$id]; + } + + $sql = 'FROM ' . $GLOBALS['news']->prefix . ' AS n, ' . $GLOBALS['news']->prefix . '_body AS l ' + . ' WHERE n.id = l.id AND l.lang = ?'; + $params = array('_lang' => NLS::select()); + + if ($perms == PERMS_READ) { + $sql .= ' AND n.publish <= ? '; + $params['_perms'] = date('Y-m-d H:i:s'); + $sql .= ' AND n.status = ? '; + $params['_status'] = News::CONFIRMED; + } + + if (empty($criteria)) { + $parts[$id] = array($sql, $params); + return $parts[$id]; + } + + /* check status */ + if (isset($criteria['status'])) { + $sql .= ' AND n.status = ?'; + $params['status'] = $criteria['status']; + } + + /* check status */ + if (isset($criteria['source'])) { + $sql .= ' AND n.source = ?'; + $params['source'] = $criteria['source']; + } + + /* get category */ + if (isset($criteria['category'])) { + $sql .= ' AND (n.category1 = ? OR n.category2 = ?)'; + $params['category'] = $criteria['category']; + $params['_category'] = $criteria['category']; + } + + /* seaching for a pericolar word */ + if (isset($criteria['word'])) { + $sql .= ' AND (l.title LIKE ? OR l.content LIKE ? OR l.tags LIKE ?)'; + $params['word'] = '%' . $criteria['word'] . '%'; + $params['_word'] = '%' . $criteria['word'] . '%'; + $params['tags'] = '%' . $criteria['word'] . '%'; + } + + /* submitter */ + if (isset($criteria['user'])) { + $sql .= ' AND n.user = ? '; + $params['user'] = $criteria['user']; + } + + /* editor */ + if (isset($criteria['editor'])) { + $sql .= ' AND n.editor = ? '; + $params['editor'] = $criteria['editor']; + } + + /* publish time */ + if (isset($criteria['published_to'])) { + $sql .= ' AND n.publish <= ? '; + $params['published_to'] = $criteria['published_to']; + } + + if (isset($criteria['published_from'])) { + $sql .= ' AND n.publish >= ? '; + $params['published_from'] = $criteria['published_from']; + } + + $parts[$id] = array($sql, $params); + + return $parts[$id]; + } + + /** + * Count news + * + * @param array $criteria Filter parameter + + * @param int $perms Permissions filter + * + * @return Nimber of news + */ + public function countNews($criteria = array(), $perms = PERMS_READ) + { + $binds = $this->buildQuery($perms, $criteria); + $binds[0] = 'SELECT COUNT(*) ' . $binds[0]; + + return $this->db->getOne($binds[0], $binds[1]); + } + + /** + * List news + * + * @param array $criteria Filter parameter + * @param int $from Offset + * @param int $count Limit rows + * @param int $perms Permissions filter + * + * @return array of news data + */ + public function listNews($criteria = array(), $from = 0, $count = 0, $perms = PERMS_READ) + { + $binds = $this->buildQuery($perms, $criteria); + + if (!isset($criteria['sort_by'])) { + $criteria['sort_by'] = 'n.publish'; + } + if (!isset($criteria['sort_dir'])) { + $criteria['sort_dir'] = 'DESC'; + } + + $binds[0] = 'SELECT n.id, n.publish, n.user, n.category1, n.category2, n.comments, ' + . ' n.picture, n.chars, l.title, l.abbreviation ' . $binds[0] + . ' ORDER BY ' . $criteria['sort_by'] + . ' ' . $criteria['sort_dir']; + + if ($count) { + $binds[0] = $this->db->modifyLimitQuery($binds[0], $from, $count); + } + + return $this->db->getAll($binds[0], $binds[1], DB_FETCHMODE_ASSOC); + } + + /** + * Construct tag cloud + * + * @param boolean $minimize Minimize tag cloud + * (remove 1 length strings, and single occurrence) + * + * @return mixed The HTML for the tag cloud | PEAR_Error + */ + public function getCloud($minimize = false) + { + $cache_key = 'news_cloud_' . $minimize; + $cloud = $GLOBALS['cache']->get($cache_key, $GLOBALS['conf']['cache']['default_lifetime']); + if ($cloud) { + return $cloud; + } + + $sql = 'SELECT l.tags, n.publish FROM ' . $this->prefix . '_body AS l, ' + . $this->prefix . ' AS n WHERE l.lang = ? AND n.id = l.id AND n.status = ? ORDER BY n.publish DESC LIMIT 0, ' + . ($minimize ? '100' : '500'); + + $result = $this->db->query($sql, array(NLS::select(), News::CONFIRMED)); + if ($result instanceof PEAR_Error) { + return $result; + } + + $tags_elemets = array(); + while ($news = $result->fetchRow(DB_FETCHMODE_ASSOC)) { + foreach (explode(' ', $news['tags']) as $tag) { + if ($minimize && strlen($tag) < 2) { + continue; + } + $tags_elemets[$tag][] = strtotime($news['publish']); + } + } + + if ($minimize) { + foreach ($tags_elemets as $tag => $content) { + if (count($content) == 1) { + unset($tags_elemets[$tag]); + } + } + } + + if (empty($tags_elemets)) { + return ''; + } + + $i = 0; + $tags = new News_TagCloud(); + $tag_link = Horde::applicationUrl('search.php'); + foreach ($tags_elemets as $tag => $time) { + sort($time); + $tags->addElement($tag, Util::addParameter($tag_link, array('word' => $tag)), + count($tags_elemets[$tag]), $time[0]); + } + + $cloud = $tags->buildHTML(); + $GLOBALS['cache']->set($cache_key, $cloud); + + return $cloud; + } + +} diff --git a/news/lib/News.php b/news/lib/News.php index d18f2c0c1..48c81abc1 100644 --- a/news/lib/News.php +++ b/news/lib/News.php @@ -339,9 +339,11 @@ class News { } $vfs_name = $id . '.' . $GLOBALS['conf']['images']['image_type']; - $vfs->deleteFile(self::VFS_PATH . '/images/small/', $vfs_name); - $vfs->deleteFile(self::VFS_PATH . '/images/big/', $vfs_name); - $vfs->deleteFile(self::VFS_PATH . '/images/full/', $vfs_name); + $result = $vfs->deleteFile(self::VFS_PATH . '/images/news/full', $vfs_name); + $result = $vfs->deleteFile(self::VFS_PATH . '/images/news/small', $vfs_name); + $result = $vfs->deleteFile(self::VFS_PATH . '/images/news/big', $vfs_name); + + return $result; } /** diff --git a/news/lib/Search.php b/news/lib/Search.php new file mode 100644 index 000000000..a22f7a04c --- /dev/null +++ b/news/lib/Search.php @@ -0,0 +1,139 @@ + + * @package News + */ +class News_Search extends Horde_Form { + + /** + * Creator + */ + public function __construct($vars) + { + parent::__construct($vars, _("Search"), 'news_search'); + + $this->_submit = _("Search"); + + $this->addVariable(_("Search world"), 'word', 'text', false, false, false); + + $s = array(News::UNCONFIRMED => _("Unconfirmed"), + News::CONFIRMED => _("Confirmed"), + News::LOCKED => _("Locked")); + $this->addVariable(_("Status"), 'status', 'enum', false, false, false, array($s, _("-- select --"))); + + $allowed_cats = $GLOBALS['news_cat']->getAllowed(PERMS_DELETE); + $this->addVariable(_("Category"), 'category', 'enum', false, false, false, array($allowed_cats, _("-- select --"))); + + $sources = $GLOBALS['news']->getSources(); + if (!empty($sources)) { + $this->addVariable(_("Source"), 'source', 'enum', false, false, false, array($sources, _("-- select --"))); + } + + $this->addVariable(_("Order by"), 'sort_by', 'enum', false, false, false, array(array('n.publish' => _("Publish date"), + 'n.id' => _("Id"), + 'l.title' => _("Title"), + 'n.comments' => _("Comments"), + 'n.reads' => _("Reads"), + 'n.attachemt' => _("Attachments")))); + + $this->addVariable(_("Sort order"), 'sort_dir', 'enum', false, false, false, array(array('DESC' => _("Descending"), + 'ASC' => _("Ascending")))); + + $this->addVariable(_("Publish"), 'publish', 'datetime', false, false, false, News::datetimeParams()); + $this->addVariable(_("Unpublish"), 'unpublish', 'datetime', false, false, false, News::datetimeParams()); + $this->addVariable(_("User"), 'user', 'text', false, false, false); + + if (Auth::isAdmin()) { + $this->addVariable(_("Editor"), 'editor', 'text', false, false, false); + } + + } + + /** + * Get pager + */ + static public function getPager($info, $count, $url) + { + $pager = new Horde_UI_Pager('news_page', + Variables::getDefaultVariables(), + array('num' => $count, + 'url' => $url, + 'page_count' => 10, + 'perpage' => $GLOBALS['prefs']->getValue('per_page'))); + + foreach ($info as $key => $value) { + if (substr($key, 0, 1) == '_') { + continue; + } elseif ($key == 'word') { + $pager->preserve($key, substr($value, 1, -1)); + } else { + $pager->preserve($key, $value); + } + } + + return $pager; + } + /** + * Fetch the field values of the submitted form. + * + * @param Variables $vars A Variables instance, optional since Horde 3.2. + * @param array $info Array to be filled with the submitted field + * values. + */ + function getInfo($vars, &$info) + { + $this->_getInfoFromVariables($this->getVariables(), $this->_vars, $info); + } + + /** + * Fetch the field values from a given array of variables. + * + * @access private + * + * @param array $variables An array of Horde_Form_Variable objects to + * fetch from. + * @param object $vars The Variables object. + * @param array $info The array to be filled with the submitted + * field values. + */ + function _getInfoFromVariables($variables, &$vars, &$info) + { + foreach ($variables as $var) { + $value = $var->getValue($vars); + if (empty($value)) { + continue; + } + + if (Horde_Array::getArrayParts($var->getVarName(), $base, $keys)) { + if (!isset($info[$base])) { + $info[$base] = array(); + } + $pointer = &$info[$base]; + while (count($keys)) { + $key = array_shift($keys); + if (!isset($pointer[$key])) { + $pointer[$key] = array(); + } + $pointer = &$pointer[$key]; + } + $var->getInfo($vars, $pointer); + } else { + $var->getInfo($vars, $info[$var->getVarName()]); + } + + } + } + +} diff --git a/news/lib/version.php b/news/lib/version.php new file mode 100755 index 000000000..acdca3471 --- /dev/null +++ b/news/lib/version.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/news/mail.php b/news/mail.php index cddd01aa4..2ae563cf7 100644 --- a/news/mail.php +++ b/news/mail.php @@ -54,12 +54,12 @@ $body = sprintf(_("%s would you like to invite you to read the news\n Title: %s\ News::getUrlFor('news', $id, true, -1)); $mail = new Horde_Mime_Mail($row['title'], $body, $to, $from, NLS::getCharset()); -try { - $mail->send($conf['mailer']['type'], $conf['mailer']['params']); +$result = $mail->send($conf['mailer']['type'], $conf['mailer']['params']); +if ($result instanceof PEAR_Error) { + $notification->push($result); +} else { $notification->push(sprintf(_("News succesfully send to %s"), $to), 'horde.success'); -} catch (Horde_Mime_Exception $e) { - $notification->push($e); } header('Location: ' . News::getUrlFor('news', $id)); -exit; +exit; \ No newline at end of file diff --git a/news/po/news.pot b/news/po/news.pot index b3846866c..e51a75ae3 100644 --- a/news/po/news.pot +++ b/news/po/news.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: dev@lists.horde.org\n" -"POT-Creation-Date: 2009-01-30 16:08+0100\n" +"POT-Creation-Date: 2009-02-18 15:38+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -20,16 +20,16 @@ msgstr "" msgid " at " msgstr "" -#: news.php:35 templates/edit/info.php:94 +#: news.php:39 templates/edit/info.php:94 msgid " by " msgstr "" -#: content_edit.php:26 +#: content_edit.php:28 #, php-format msgid "%s :: Add Content" msgstr "" -#: mail.php:46 +#: mail.php:50 #, php-format msgid "" "%s would you like to invite you to read the news\n" @@ -43,8 +43,8 @@ msgstr "" msgid "* Sponsored news" msgstr "" -#: add.php:129 add.php:136 add.php:153 lib/Forms/Search.php:31 -#: lib/Forms/Search.php:34 lib/Forms/Search.php:38 +#: add.php:132 add.php:139 add.php:156 lib/Search.php:34 lib/Search.php:37 +#: lib/Search.php:41 msgid "-- select --" msgstr "" @@ -56,11 +56,11 @@ msgstr "" msgid "Activate" msgstr "" -#: lib/News.php:1141 +#: lib/News.php:496 msgid "Add" msgstr "" -#: content.php:24 +#: content.php:26 msgid "Add Content" msgstr "" @@ -68,7 +68,7 @@ msgstr "" msgid "Add New" msgstr "" -#: lib/Categories.php:471 lib/Categories.php:485 +#: lib/Categories.php:483 lib/Categories.php:497 msgid "Add New Item" msgstr "" @@ -80,7 +80,7 @@ msgstr "" msgid "Add category" msgstr "" -#: add.php:95 +#: add.php:98 msgid "Add news" msgstr "" @@ -92,15 +92,15 @@ msgstr "" msgid "Add to notes." msgstr "" -#: add.php:152 +#: add.php:155 msgid "Additional news attributes" msgstr "" -#: add.php:218 lib/api.php:49 +#: add.php:221 lib/api.php:52 msgid "Admin" msgstr "" -#: lib/News.php:1149 +#: lib/News.php:504 msgid "Administration" msgstr "" @@ -108,19 +108,19 @@ msgstr "" msgid "Allow comments" msgstr "" -#: lib/News.php:1139 +#: lib/News.php:494 msgid "Archive" msgstr "" -#: delete_file.php:22 +#: delete_file.php:26 msgid "Are you sure you want to delete file?" msgstr "" -#: delete.php:22 +#: delete.php:26 msgid "Are you sure you want to delete this news?" msgstr "" -#: lib/Forms/Search.php:49 +#: lib/Search.php:52 msgid "Ascending" msgstr "" @@ -128,15 +128,15 @@ msgstr "" msgid "Ascesending" msgstr "" -#: lib/News.php:215 +#: lib/News.php:205 msgid "Attached files: " msgstr "" -#: lib/Forms/Search.php:46 +#: lib/Search.php:49 msgid "Attachments" msgstr "" -#: add.php:151 +#: add.php:154 msgid "Attributes" msgstr "" @@ -144,7 +144,7 @@ msgstr "" msgid "Besed" msgstr "" -#: trackback.php:65 +#: trackback.php:68 #, php-format msgid "Blog entry %s does not exist." msgstr "" @@ -153,7 +153,7 @@ msgstr "" msgid "Blogs" msgstr "" -#: browse.php:16 search.php:16 +#: browse.php:19 search.php:17 msgid "Browse" msgstr "" @@ -161,21 +161,21 @@ msgstr "" msgid "By" msgstr "" -#: delete_file.php:23 delete.php:23 admin/categories/delete.php:18 +#: delete_file.php:27 delete.php:27 admin/categories/delete.php:18 #: admin/sources/delete.php:19 msgid "Cancel" msgstr "" -#: add.php:199 +#: add.php:202 msgid "Caption" msgstr "" -#: admin/tabs.php:25 lib/api.php:57 lib/Block/categories.php:3 +#: admin/tabs.php:25 lib/api.php:60 lib/Block/categories.php:3 #: lib/Block/categories.php:21 msgid "Categories" msgstr "" -#: templates/menu.inc:4 templates/news/info.php:6 lib/Forms/Search.php:34 +#: templates/menu.inc:4 templates/news/info.php:6 lib/Search.php:37 #: lib/Block/category.php:35 msgid "Category" msgstr "" @@ -205,29 +205,28 @@ msgstr "" msgid "Click for full picture" msgstr "" -#: templates/browse/row.inc:10 templates/edit/header.inc:13 -#: lib/Forms/Search.php:44 +#: templates/browse/row.inc:10 templates/edit/header.inc:13 lib/Search.php:47 msgid "Comments" msgstr "" -#: lib/News.php:490 +#: lib/News.php:457 msgid "Comments are not supported." msgstr "" -#: lib/News.php:220 +#: lib/News.php:210 #, php-format msgid "Compress and dowload %s" msgstr "" -#: lib/News.php:214 +#: lib/News.php:204 msgid "Compress and dowload all files at once" msgstr "" -#: templates/edit/row.php:46 lib/Forms/Search.php:29 +#: templates/edit/row.php:46 lib/Search.php:32 msgid "Confirmed" msgstr "" -#: add.php:124 add.php:147 +#: add.php:127 add.php:150 msgid "Content" msgstr "" @@ -241,20 +240,20 @@ msgstr "" #: templates/edit/row.php:23 admin/categories/index.php:29 #: admin/categories/index.php:32 admin/sources/index.php:27 -#: admin/sources/index.php:34 lib/News.php:205 +#: admin/sources/index.php:34 lib/News.php:195 msgid "Delete" msgstr "" -#: lib/News.php:225 +#: lib/News.php:215 #, php-format msgid "Delete %s" msgstr "" -#: add.php:101 add.php:118 +#: add.php:104 add.php:121 msgid "Delete existing picture" msgstr "" -#: lib/Forms/Search.php:48 +#: lib/Search.php:51 msgid "Descending" msgstr "" @@ -266,11 +265,11 @@ msgstr "" msgid "Description" msgstr "" -#: diff.php:14 templates/edit/info.php:103 +#: diff.php:18 templates/edit/info.php:103 msgid "Diff" msgstr "" -#: add.php:227 +#: add.php:230 msgid "Disallow comments" msgstr "" @@ -282,20 +281,20 @@ msgstr "" msgid "Do you really wont to delete this source?" msgstr "" -#: lib/News.php:209 +#: lib/News.php:199 msgid "Dowload" msgstr "" -#: lib/News.php:221 +#: lib/News.php:211 #, php-format msgid "Dowload %s" msgstr "" -#: lib/News.php:210 +#: lib/News.php:200 msgid "Dowload Zip Compressed" msgstr "" -#: edit.php:110 templates/edit/row.php:6 templates/edit/row.php:7 +#: edit.php:113 templates/edit/row.php:6 templates/edit/row.php:7 #: admin/categories/index.php:27 admin/categories/index.php:34 #: admin/sources/index.php:25 admin/sources/index.php:36 msgid "Edit" @@ -313,40 +312,40 @@ msgstr "" msgid "Edit history: " msgstr "" -#: add.php:552 +#: add.php:558 msgid "Edit news" msgstr "" -#: templates/edit/info.php:27 lib/Forms/Search.php:56 +#: templates/edit/info.php:27 lib/Search.php:59 msgid "Editor" msgstr "" -#: lib/api.php:52 +#: lib/api.php:55 msgid "Editors" msgstr "" -#: lib/News.php:1148 +#: lib/News.php:503 msgid "Editorship" msgstr "" -#: add.php:177 +#: add.php:180 msgid "Enter gallery ID or upload images below" msgstr "" -#: add.php:155 +#: add.php:158 msgid "Enter news ids separated by commas." msgstr "" -#: add.php:145 +#: add.php:148 msgid "" "Enter one or more keywords that describe your news. Separate them by spaces." msgstr "" -#: add.php:158 +#: add.php:161 msgid "Enter threads separated by commas." msgstr "" -#: delete_file.php:53 +#: delete_file.php:57 #, php-format msgid "Error deleteing file \"%s\" from news \"%s\"" msgstr "" @@ -355,34 +354,34 @@ msgstr "" msgid "Events on this day." msgstr "" -#: add.php:211 +#: add.php:214 msgid "File" msgstr "" -#: delete_file.php:72 +#: delete_file.php:76 #, php-format msgid "File \"%s\" was deleted from news \"%s\"" msgstr "" -#: delete_file.php:79 +#: delete_file.php:83 #, php-format msgid "File \"%s\" was not deleted from news \"%s\"" msgstr "" -#: add.php:204 add.php:463 +#: add.php:207 add.php:466 msgid "Files" msgstr "" -#: files.php:59 +#: files.php:68 #, php-format msgid "FilesOfNews-%s" msgstr "" -#: add.php:258 +#: add.php:261 msgid "Form ID" msgstr "" -#: add.php:259 +#: add.php:262 msgid "Form to" msgstr "" @@ -390,11 +389,11 @@ msgstr "" msgid "From: " msgstr "" -#: add.php:180 add.php:187 +#: add.php:183 add.php:190 msgid "Gallery" msgstr "" -#: lib/api.php:101 +#: lib/api.php:104 #, php-format msgid "Has commented news \"%s\"" msgstr "" @@ -421,7 +420,7 @@ msgid "IP" msgstr "" #: templates/categories/index.php:5 templates/sources/index.php:5 -#: lib/Forms/Search.php:42 config/prefs.php.dist:29 +#: lib/Search.php:45 config/prefs.php.dist:29 msgid "Id" msgstr "" @@ -429,11 +428,11 @@ msgstr "" msgid "Image" msgstr "" -#: add.php:161 +#: add.php:164 msgid "Images" msgstr "" -#: add.php:196 +#: add.php:199 msgid "" "Images will be added to a gallery linked with this article. You can edit and " "manage images in gallery." @@ -487,7 +486,7 @@ msgstr "" msgid "Last news in category" msgstr "" -#: note.php:24 pdf.php:51 +#: note.php:28 pdf.php:55 msgid "Link" msgstr "" @@ -495,11 +494,11 @@ msgstr "" msgid "Lock" msgstr "" -#: templates/edit/row.php:50 lib/Forms/Search.php:30 +#: templates/edit/row.php:50 lib/Search.php:33 msgid "Locked" msgstr "" -#: add.php:82 +#: add.php:85 #, php-format msgid "Maximum file size: %s; with a total of: %s" msgstr "" @@ -513,32 +512,32 @@ msgstr "" msgid "News" msgstr "" -#: edit.php:46 edit.php:54 edit.php:62 edit.php:70 edit.php:103 +#: edit.php:49 edit.php:57 edit.php:65 edit.php:73 edit.php:106 #, php-format msgid "News \"%s\" (%s): %s" msgstr "" -#: reads.php:28 +#: reads.php:30 #, php-format msgid "News %s" msgstr "" -#: delete.php:74 delete.php:78 +#: delete.php:81 delete.php:85 #, php-format msgid "News %s: %s" msgstr "" -#: add.php:540 +#: add.php:546 msgid "" "News added. The editors will check the entry and confirm it if they find it " "suitable." msgstr "" -#: add.php:219 +#: add.php:222 msgid "News administrator options" msgstr "" -#: add.php:125 +#: add.php:128 msgid "News content" msgstr "" @@ -546,7 +545,7 @@ msgstr "" msgid "News data" msgstr "" -#: add.php:162 +#: add.php:165 msgid "News images" msgstr "" @@ -554,20 +553,20 @@ msgstr "" msgid "News of this day." msgstr "" -#: add.php:542 +#: add.php:548 msgid "News published." msgstr "" -#: mail.php:57 +#: mail.php:61 #, php-format msgid "News succesfully send to %s" msgstr "" -#: note.php:40 +#: note.php:44 msgid "News sucessfuly added to you notes." msgstr "" -#: add.php:544 +#: add.php:550 msgid "News updated." msgstr "" @@ -575,11 +574,11 @@ msgstr "" msgid "No" msgstr "" -#: diff.php:55 +#: diff.php:59 msgid "No change." msgstr "" -#: mail.php:36 +#: mail.php:40 msgid "No mail entered." msgstr "" @@ -587,7 +586,7 @@ msgstr "" msgid "Number of comments to display" msgstr "" -#: note.php:23 pdf.php:50 templates/news/info.php:5 +#: note.php:27 pdf.php:54 templates/news/info.php:5 msgid "On" msgstr "" @@ -595,23 +594,23 @@ msgstr "" msgid "On this day" msgstr "" -#: delete_file.php:16 delete.php:16 +#: delete_file.php:20 delete.php:20 msgid "Only admin can delete a news." msgstr "" -#: add.php:90 +#: add.php:93 msgid "Only authenticated users can post news." msgstr "" -#: mail.php:31 +#: mail.php:35 msgid "Only authenticated users can send mails." msgstr "" -#: lib/Forms/Search.php:41 +#: lib/Search.php:44 msgid "Order by" msgstr "" -#: lib/News.php:1137 +#: lib/News.php:492 msgid "Overview" msgstr "" @@ -623,15 +622,15 @@ msgstr "" msgid "Parent" msgstr "" -#: add.php:155 templates/news/parents.php:5 templates/edit/info.php:35 +#: add.php:158 templates/news/parents.php:5 templates/edit/info.php:35 msgid "Parents" msgstr "" -#: add.php:165 add.php:198 +#: add.php:168 add.php:201 msgid "Picture" msgstr "" -#: add.php:169 +#: add.php:172 msgid "Picture comment" msgstr "" @@ -643,12 +642,12 @@ msgstr "" msgid "Preview" msgstr "" -#: lib/News.php:222 +#: lib/News.php:212 #, php-format msgid "Preview %s" msgstr "" -#: add.php:129 templates/edit/info.php:12 +#: add.php:132 templates/edit/info.php:12 msgid "Primary category" msgstr "" @@ -656,7 +655,7 @@ msgstr "" msgid "Printer firendly" msgstr "" -#: add.php:127 lib/Forms/Search.php:51 +#: add.php:130 lib/Search.php:54 msgid "Publish" msgstr "" @@ -664,7 +663,7 @@ msgstr "" msgid "Publish at" msgstr "" -#: lib/Forms/Search.php:41 config/prefs.php.dist:28 +#: lib/Search.php:44 config/prefs.php.dist:28 msgid "Publish date" msgstr "" @@ -672,11 +671,11 @@ msgstr "" msgid "Read" msgstr "" -#: templates/edit/header.inc:10 lib/Forms/Search.php:45 +#: templates/edit/header.inc:10 lib/Search.php:48 msgid "Reads" msgstr "" -#: delete_file.php:23 delete_file.php:49 delete.php:23 delete.php:34 +#: delete_file.php:27 delete_file.php:53 delete.php:27 delete.php:38 #: admin/categories/delete.php:18 admin/categories/delete.php:24 #: admin/sources/delete.php:19 admin/sources/delete.php:25 msgid "Remove" @@ -686,7 +685,7 @@ msgstr "" msgid "Renew" msgstr "" -#: add.php:118 add.php:120 add.php:587 +#: add.php:121 add.php:123 add.php:593 msgid "Reset" msgstr "" @@ -694,23 +693,23 @@ msgstr "" msgid "Resize Image" msgstr "" -#: add.php:120 +#: add.php:123 msgid "Save" msgstr "" -#: lib/News.php:1140 lib/Forms/Search.php:22 lib/Forms/Search.php:24 +#: lib/News.php:495 lib/Search.php:25 lib/Search.php:27 msgid "Search" msgstr "" -#: lib/Forms/Search.php:26 +#: lib/Search.php:29 msgid "Search world" msgstr "" -#: add.php:153 templates/edit/info.php:15 +#: add.php:156 templates/edit/info.php:15 msgid "Secondary category" msgstr "" -#: lib/Categories.php:478 +#: lib/Categories.php:490 msgid "Select Category" msgstr "" @@ -718,7 +717,7 @@ msgstr "" msgid "Select a feed." msgstr "" -#: add.php:247 templates/edit/info.php:49 +#: add.php:250 templates/edit/info.php:49 msgid "Selling item" msgstr "" @@ -726,7 +725,7 @@ msgstr "" msgid "Send by mail" msgstr "" -#: lib/News.php:100 +#: lib/News.php:65 msgid "Services/Trackback is not installed." msgstr "" @@ -742,11 +741,11 @@ msgstr "" msgid "Sort news by" msgstr "" -#: add.php:154 templates/edit/info.php:31 lib/Forms/Search.php:48 +#: add.php:157 templates/edit/info.php:31 lib/Search.php:51 msgid "Sort order" msgstr "" -#: add.php:136 templates/edit/info.php:39 lib/Forms/Search.php:38 +#: add.php:139 templates/edit/info.php:39 lib/Search.php:41 msgid "Source" msgstr "" @@ -754,7 +753,7 @@ msgstr "" msgid "Source deleted." msgstr "" -#: add.php:138 templates/edit/info.php:43 +#: add.php:141 templates/edit/info.php:43 msgid "Source link" msgstr "" @@ -782,19 +781,19 @@ msgstr "" msgid "Sources Administration" msgstr "" -#: add.php:222 +#: add.php:225 msgid "Sponsored" msgstr "" -#: templates/edit/header.inc:6 lib/Forms/Search.php:31 +#: templates/edit/header.inc:6 lib/Search.php:34 msgid "Status" msgstr "" -#: lib/News.php:1144 +#: lib/News.php:499 msgid "Tag cloud" msgstr "" -#: add.php:145 lib/Block/tags_cloud.php:3 lib/Block/tags_cloud.php:24 +#: add.php:148 lib/Block/tags_cloud.php:3 lib/Block/tags_cloud.php:24 msgid "Tags" msgstr "" @@ -810,29 +809,29 @@ msgstr "" msgid "There are no news to display." msgstr "" -#: lib/News.php:562 +#: lib/Driver/sql.php:85 #, php-format msgid "There requested news %s don't exist." msgstr "" -#: news.php:29 +#: news.php:33 msgid "There requested version don't exist." msgstr "" -#: add.php:438 +#: add.php:441 msgid "There was an error creating gallery: " msgstr "" -#: add.php:454 +#: add.php:457 msgid "There was an error with the uploaded image: " msgstr "" -#: add.php:158 templates/news/threads.php:6 +#: add.php:161 templates/news/threads.php:6 #, php-format msgid "Threads in %s" msgstr "" -#: add.php:143 templates/edit/header.inc:7 lib/Forms/Search.php:43 +#: add.php:146 templates/edit/header.inc:7 lib/Search.php:46 #: lib/Block/my_comments.php:56 config/prefs.php.dist:30 msgid "Title" msgstr "" @@ -845,12 +844,12 @@ msgstr "" msgid "Trackback this blog on this site." msgstr "" -#: lib/News.php:715 +#: lib/Driver/sql.php:222 #, php-format msgid "URL already trackbacked: %s" msgstr "" -#: templates/edit/row.php:42 lib/Forms/Search.php:28 +#: templates/edit/row.php:42 lib/Search.php:31 msgid "Unconfirmed" msgstr "" @@ -858,7 +857,7 @@ msgstr "" msgid "Unlock" msgstr "" -#: lib/Forms/Search.php:52 +#: lib/Search.php:55 msgid "Unpublish" msgstr "" @@ -866,7 +865,7 @@ msgstr "" msgid "Unpublish date" msgstr "" -#: add.php:118 add.php:586 templates/edit/info.php:88 +#: add.php:121 add.php:592 templates/edit/info.php:88 msgid "Update" msgstr "" @@ -878,8 +877,8 @@ msgstr "" msgid "Use the following link to trackback from your own site: " msgstr "" -#: templates/reads/header.inc:6 templates/edit/header.inc:9 -#: lib/Forms/Search.php:53 lib/Block/my_comments.php:57 +#: templates/reads/header.inc:6 templates/edit/header.inc:9 lib/Search.php:56 +#: lib/Block/my_comments.php:57 msgid "User" msgstr "" @@ -903,38 +902,38 @@ msgstr "" msgid "You are not authorised for this action." msgstr "" -#: mail.php:42 +#: mail.php:46 msgid "You have no email set." msgstr "" -#: edit.php:18 +#: edit.php:21 msgid "You have not editor permission on any category." msgstr "" -#: edit.php:54 +#: edit.php:57 msgid "activated" msgstr "" -#: edit.php:46 +#: edit.php:49 msgid "deactivated" msgstr "" -#: delete.php:74 +#: delete.php:81 msgid "deleted" msgstr "" -#: edit.php:62 +#: edit.php:65 msgid "locked" msgstr "" -#: delete.php:78 +#: delete.php:85 msgid "not deleted" msgstr "" -#: edit.php:103 +#: edit.php:106 msgid "renewed" msgstr "" -#: edit.php:70 +#: edit.php:73 msgid "unlocked" msgstr "" diff --git a/news/templates/edit/info.inc b/news/templates/edit/info.inc deleted file mode 100755 index d62b55593..000000000 --- a/news/templates/edit/info.inc +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - -
-\n"; - -if ($row['category2']>0) { - echo _("Secondary category") . ': ' . $allowed_cats[$row['category2']] . "
\n"; -} - -if (substr($row['unpublish'], 0, 1) != 0) { - echo _("Unpublish date") . ': ' . $row['unpublish'] . "
\n"; -} - -if ($conf['comments']['allow']) { - echo _("Allow comments") . ': ' . ($row['comments']>-1 ? _("Yes") : _("No")) . "
\n"; -} - -if ($row['editor']) { - echo _("Editor") . ': ' . $row['editor'] . "
\n"; -} - -if ($row['sortorder']) { - echo _("Sort order") . ': ' . $row['sortorder'] . "
\n"; -} - -if (isset($row['parents'])) { - echo _("Parents") . ': ' . sizeof($row['parents']) . "
\n"; -} - -if (!empty($row['source']) && isset($GLOBALS['cfgSources'][$row['source']])) { - echo _("Source") . ': ' . $GLOBALS['cfgSources'][$row['source']]['title'] . '
'; -} - -if (isset($row['sourcelink'])) { - echo _("Source link") . ': ' . $row['sourcelink'] . '
'; -} - -// schedul -if (!empty($row['selling'])) { - $item = explode('|', $row['selling']); - echo _("Selling item") . ': ' . $registry->get('name', $registry->hasInterface($item[0])); - $articles = $registry->call($item[0] . '/listCostObjects'); - foreach ($articles[0]['objects'] as $item_data) { - if ($item_data['id'] == $item[1]) { - echo ' - ' . $item_data['name']; - break; - } - } -} - -if ($row['attachments']) { - echo News::format_attached($id); -} - -?> -
-getVerisons($id); -if ($versions instanceof PEAR_Error) { - echo $versions->getMessage(); - echo $versions->getDebugInfo(); -} - -unset($versions[0]); // current version - -if (sizeof($versions)>0) { - echo _("Edit history: ") . '
'; - - foreach ($versions as $version) { - - switch ($version['action']) { - case 'update': - echo _("Update"); - default: - echo _("Insert"); - break; - } - echo _(" by ") . $version['user_uid'] . _(" at ") . $version['created'] . "\n("; - - $url = Util::addParameter(Horde::applicationUrl('news.php'), array('id' => $id, 'version' => $version['version'])); - echo Horde::link($url, _("View"), '', '_blank', '', _("View")) . _("View") . ' | '; - - $url = Util::addParameter(Horde::applicationUrl('edit.php'), array('id' => $id, 'actionID' => 'renew')); - echo Horde::link(Util::addParameter($url,'version', $version['version']),_("Renew")) . _("Renew") . ' | '; - - $url = Util::addParameter(Horde::applicationUrl('diff.php'), array('id' => $id, 'version' => $version['version'])); - echo Horde::link('#', _("Diff"), '', '', "popup('$url')") . _("Diff") . ' '; - - echo ')
' . "\n"; - } -} - -?> -
- - - diff --git a/news/templates/edit/info.php b/news/templates/edit/info.php index 850502a04..c21c76201 100644 --- a/news/templates/edit/info.php +++ b/news/templates/edit/info.php @@ -3,13 +3,22 @@ -
- + + +"> + +
+');"> +
\n"; +if (isset($allowed_cats[$row['category1']])) { + echo _("Primary category") . ': ' . $allowed_cats[$row['category1']] . "
\n"; +} else { + echo _("Primary category") . ': ' . $row['category1'] . '!!!
' . "\n"; +} if ($row['category2']>0) { echo _("Secondary category") . ': ' . $allowed_cats[$row['category2']] . "
\n"; @@ -62,7 +71,7 @@ if (!empty($row['form'])) { } if ($row['attachments']) { - echo $news->format_attached($id); + echo News::format_attached($id); } ?> diff --git a/news/themes/microfila/graphics/favicon.ico b/news/themes/microfila/graphics/favicon.ico deleted file mode 100755 index f8694d53c78c8bff0e21a2e007695069d0c7617d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 318 ncmZQzU<5(|0RbS%!l1#(z#zuJz@P!d0zj+)#31oefIS2N_