function mw_post_form($edit = 0) { global $xoopsConfig, $xoopsUser, $xoopsSecurity; if (!$xoopsUser) { redirect_header(MWFunctions::get_url(), 1, __('You are not allowed to do this action!', 'mywords')); die; } // Check if user is a editor $author = new MWEditor(); if (!$author->from_user($xoopsUser->uid()) && !$xoopsUser->isAdmin()) { redirect_header(MWFunctions::get_url(), 1, __('You are not allowed to do this action!', 'mywords')); die; } RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.min.js'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery-ui.min.js'); if ($edit) { $id = rmc_server_var($_GET, 'id', 0); if ($id <= 0) { redirect_header(MWFunctions::get_url(), __('Please, specify a valid post ID', 'mywords'), 1); die; } $post = new MWPost($id); if ($post->isNew()) { redirect_header(MWFunctions::get_url(), __('Specified post does not exists!', 'mywords'), 1); die; } // Check if user is the admin or a editor of this this post if ($author->id() != $post->getVar('author') && !$xoopsUser->isAdmin()) { redirect_header($post->permalink(), 1, __('You are not allowed to do this action!', 'mywords')); die; } } // Read privileges $perms = @$author->getVar('privileges'); $perms = is_array($perms) ? $perms : array(); $allowed_tracks = in_array("tracks", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_tags = in_array("tags", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_cats = in_array("cats", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_comms = in_array("comms", $perms) || $xoopsUser->isAdmin() ? true : false; $xoopsOption['module_subpage'] = 'submit'; include 'header.php'; $form = new RMForm('', '', ''); $editor = new RMFormEditor('', 'content', '99%', '300px', $edit ? $post->getVar('content') : ''); $meta_names = MWFunctions::get()->get_metas(); RMTemplate::get()->add_xoops_style('submit.css', 'mywords'); RMTemplate::get()->add_script(XOOPS_URL . '/modules/mywords/include/js/scripts.php?file=posts.js&front=1'); include RMTemplate::get()->get_template('mywords_submit_form.php', 'module', 'mywords'); include 'footer.php'; }
public function eventRmcommonLoadingSingleEditorimgs($items, $url) { if (FALSE === strpos($url, 'modules/mywords/admin/posts.php')) { return $items; } parse_str($url); if (!isset($id) || $id <= 0) { return $items; } xoops_load('mwpost.class', 'mywords'); xoops_load('mwfunctions', 'mywords'); $post = new MWPost($id); if ($post->isNew()) { return $items; } $items['links']['post'] = array('caption' => __('Link to post', 'mywords'), 'value' => $post->permalink()); return $items; }
public function eventRmcommonImageInsertLinks($links, $image, $url) { if (FALSE === strpos($url, 'modules/mywords/admin/posts.php')) { return $links; } parse_str($url); if (!isset($id) || $id <= 0) { return $links; } xoops_load('mwpost.class', 'mywords'); xoops_load('mwfunctions', 'mywords'); $post = new MWPost($id); if ($post->isNew()) { return $links; } $links['post'] = array('caption' => __('Link to post', 'mywords'), 'value' => $post->permalink()); return $links; }
public function get_item_url($params, $com) { static $posts; $params = urldecode($params); parse_str($params); if (!isset($post) || $post <= 0) { return ''; } if (isset($posts[$post])) { $ret = $posts[$post]->permalink(); return $ret; } include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwpost.class.php'; include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwfunctions.php'; $item = new MWPost($post); if ($item->isNew()) { return ''; } $posts[$post] = $item; return $item->permalink(); }
/** * Función para realizar búsquedas */ function mywords_search($qa, $andor, $limit, $offset, $userid) { global $xoopsUser; $db = XoopsDatabaseFactory::getDatabaseConnection(); include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwpost.class.php'; $util =& RMUtilities::get(); $mc =& $util->module_config('mywords'); $sql = "SELECT * FROM " . $db->prefix("mw_posts"); $adds = ''; if (is_array($qa) && ($count = count($qa))) { $adds = ''; for ($i = 0; $i < $count; $i++) { $adds .= $adds == '' ? "(title LIKE '%{$qa[$i]}%' OR content LIKE '%{$qa[$i]}%')" : " {$andor} (title LIKE '%{$qa[$i]}%' OR content LIKE '%{$qa[$i]}%')"; } } $sql .= $adds != '' ? " WHERE " . $adds : ''; if ($userid > 0) { $sql .= ($adds != '' ? " AND " : " WHERE ") . "author='{$userid}'"; } $sql .= " ORDER BY pubdate DESC"; $i = 0; $result = $db->query($sql, $limit, $offset); $ret = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); $ret[$i]['image'] = "images/post.png"; $ret[$i]['link'] = $post->permalink(); $ret[$i]['title'] = $post->getVar('title'); $ret[$i]['time'] = $post->getVar('pubdate'); $ret[$i]['uid'] = $post->getVar('author'); $ret[$i]['desc'] = substr(strip_tags($post->content()), 0, 150); $i++; } return $ret; }
} $track = new MWTrackback($xoopsConfig['sitename'], $editor->getVar('name')); $id = $track->post_id; // The id of the item being trackbacked $url = $track->url; // The URL from which we got the trackback $title = $track->title; // Subject/title send by trackback $excerpt = $track->excerpt; // Short text send by trackback $blog_name = rmc_server_var($_POST, 'blog_name', ''); if ($url == '' || $title == '' || $excerpt == '') { echo $track->recieve(false, __('Sorry, your trackback seems to be invalid!', 'mywords')); die; } $params = array('blogurl' => MWFunctions::get_url(), 'name' => 'Trackback', 'email' => '', 'url' => $url, 'text' => $excerpt, 'permalink' => $post->permalink()); $ret = RMEvents::get()->run_event('rmcommon.check.post.spam', $params); if (!$ret) { echo $track->recieve(false, __('Sorry, your trackback seems to be SPAM', 'mywords')); } else { $to = new MWTrackbackObject(); $to->setVar('date', time()); $to->setVar('title', $title); $to->setVar('blog_name', $blog_name); $to->setVar('excerpt', $excerpt); $to->setVar('url', $url); $to->setVar('post', $post->id()); if ($to->save()) { echo $track->recieve(true); } else { echo $track->recieve(false, __('We are unable to store your trackback. Please try again later!', 'mywords'));
$page = $path[$srh + 1]; } } else { $page = 1; } } $post->add_read(); // Navegación entre artículos if ($xoopsModuleConfig['shownav']) { $sql = "SELECT * FROM " . $db->prefix("mw_posts") . " WHERE id_post<" . $post->id() . " AND status='publish' ORDER BY id_post DESC LIMIT 0, 1"; $result = $db->query($sql); $pn = new MWPost(); // Anterior if ($db->getRowsNum($result) > 0) { $pn->assignVars($db->fetchArray($result)); $xoopsTpl->assign('prev_post', array('link' => $pn->permalink(), 'title' => $pn->getVar('title'))); } // Siguiente $sql = "SELECT * FROM " . $db->prefix("mw_posts") . " WHERE id_post>" . $post->id() . " AND status='publish' ORDER BY id_post ASC LIMIT 0, 1"; $result = $db->query($sql); if ($db->getRowsNum($result) > 0) { $pn->assignVars($db->fetchArray($result)); $xoopsTpl->assign('next_post', array('link' => $pn->permalink(), 'title' => $pn->getVar('title'))); } } $xoopsTpl->assign('shownav', $xoopsModuleConfig['shownav']); if ($xoopsUser && ($xoopsUser->isAdmin() || $editor->getVar('uid') == $xoopsUser->uid())) { $edit = '<a href="' . XOOPS_URL . '/modules/mywords/admin/posts.php?op=edit&id=' . $post->id() . '">' . __('Edit Post', 'mywords') . '</a>'; $xoopsTpl->assign('edit_link', $edit); unset($edit); }
RMTemplate::get()->add_jquery(); $edit = isset($edit) ? $edit : 0; if ($edit > 0) { $id = $edit; if ($id <= 0) { redirect_header(MWFunctions::get_url(), __('Please, specify a valid post ID', 'mywords'), 1); die; } $post = new MWPost($id); if ($post->isNew()) { redirect_header(MWFunctions::get_url(), __('Specified post does not exists!', 'mywords'), 1); die; } // Check if user is the admin or a editor of this this post if ($author->id() != $post->getVar('author') && !$xoopsUser->isAdmin()) { redirect_header($post->permalink(), 1, __('You are not allowed to do this action!', 'mywords')); die; } } else { $post = new MWPost(); } // Read privileges $perms = @$author->getVar('privileges'); $perms = is_array($perms) ? $perms : array(); $allowed_tracks = in_array("tracks", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_tags = in_array("tags", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_cats = in_array("cats", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_comms = in_array("comms", $perms) || $xoopsUser->isAdmin() ? true : false; $xoopsOption['module_subpage'] = 'submit'; include 'header.php'; $form = new RMForm('', '', '');
$post = new MWPost($id); if ($post->isNew()) { die; } $editor = new MWEditor($post->getVar('author')); if ($editor->isNew()) { $user = new XoopsUser($post->getVar('author')); } $tracks = $post->getVar('toping'); if (empty($tracks)) { die; } $pinged = $post->getVar('pinged'); $toping = $post->getVar('toping'); $tp = array(); $tback = new MWTrackback($xoopsModuleConfig['blogname'], $editor->isNew() ? $user->getVar('uname') : $editor->getVar('name')); foreach ($tracks as $t) { if (!empty($pinged) && in_array($t, $pinged)) { continue; } $ret = $tback->ping($t, $post->permalink(), $post->getVar('title'), TextCleaner::getInstance()->truncate($post->content(true), 240)); if ($ret) { $pinged[] = $t; } else { $tp[] = $t; } } $post->setVar('toping', empty($tp) ? '' : $tp); $post->setVar('pinged', $pinged); $post->update(); die;
// License: GPL 2.0 // -------------------------------------------------------------- if (!defined('XOOPS_ROOT_PATH')) { header('location: ./'); die; } // Authors cache $editors = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); # Generamos los vínculos $day = date('d', $post->getVar('pubdate')); $month = date('m', $post->getVar('pubdate')); $year = date('Y', $post->getVar('pubdate')); $link = $post->permalink(); # Generamos el vínculo para el autor if ($post->getVar('author') > 0) { if (!isset($editors[$post->getVar('author')])) { $editors[$post->getVar('author')] = new MWEditor($post->getVar('author'), 'user'); } if ($editors[$post->getVar('author')]->isNew()) { if ($xoopsUser && $xoopsUser->uid() == $post->author) { $user = $xoopsUser; } else { $user = new RMUser($post->author); } $editors[$post->getVar('author')]->uid = $user->uid(); $editors[$post->getVar('author')]->name = $user->getVar('name'); $editors[$post->getVar('author')]->shortname = $user->getVar('uname'); $editors[$post->getVar('author')]->privileges = array('tags', 'tracks', 'comms');