$time = explode("-", $schedule); $schedule = mktime($time[3], $time[4], 0, $time[1], $time[0], $time[2]); if ($schedule <= time()) { $schedule = 0; } $editor = new MWEditor($xoopsUser->uid(), 'user'); if ($editor->isNew()) { $editor->setVar('uid', $xoopsUser->uid()); $editor->setVar('shortname', $xoopsUser->getVar('uname')); $editor->setVar('name', $xoopsUser->getVar('name')); $editor->setVar('bio', $xoopsUser->getVar('bio')); $editor->setVar('active', 0); $editor->save(); } // Add Data $post->setVar('title', $title); $post->setVar('shortname', $shortname); $post->setVar('content', $content); if ($editor->isNew() && !$xoopsUser->isAdmin()) { $status = 'pending'; } else { if ($xoopsUser->isAdmin()) { $status = $status; } elseif ($mc->approve && $editor->active) { $status = $status; } else { $status = 'pending'; } } $post->setVar('status', $status); $post->setVar('visibility', $visibility);
$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;
$categories = array(MWFunctions::get()->default_category_id()); } // Check publish options if ($visibility == 'password' && $vis_password == '') { return_error(__('You must provide a password for this post or select another visibility option', 'mywords'), true); die; } $time = explode("-", $schedule); $schedule = mktime($time[3], $time[4], 0, $time[1], $time[0], $time[2]); if ($schedule <= time()) { $schedule = 0; } $author = !isset($author) || $author <= 0 ? $xoopsUser->uid() : $author; $authorname = !isset($author) || $author <= 0 ? $xoopsUser->uname() : MWFunctions::author_name($author); // Add Data $post->setVar('title', $title); $post->setVar('shortname', $shortname); $post->setVar('content', $content); $post->setVar('status', $schedule > time() && $status != 'draft' ? 'scheduled' : $status); $post->setVar('visibility', $visibility); $post->setVar('schedule', $schedule); $post->setVar('password', $vis_password); $post->setVar('author', $author); $post->setVar('comstatus', isset($comstatus) ? $comstatus : 0); $post->setVar('pingstatus', isset($pingstatus) ? $pingstatus : 0); $post->setVar('authorname', $authorname); $post->setVar('image', $image); if ($edit) { $post->setVar('modified', time()); } if ($schedule <= time() && !$edit) {
/** * Imports a single article from Publisher */ public function article() { global $xoopsSecurity, $xoopsDB; $this->prepare_ajax_response(); $functions = MWFunctions::get(); if (!$xoopsSecurity->check(true, false, 'CUTOKEN')) { $this->ajax_response(__('Session token not valid!', 'mywords'), 1, 0); } $id = RMHttpRequest::post('id', 'integer', 0); if ($id <= 0) { $this->ajax_response(sprintf(__('Article ID %u is not valid!', 'mywords'), $id), 0, 1, ['result' => 'error']); } $sql = "SELECT * FROM " . $xoopsDB->prefix("publisher_items") . " WHERE itemid = {$id}"; $result = $xoopsDB->query($sql); if ($xoopsDB->getRowsNum($result)) { if ($id <= 0) { $this->ajax_response(sprintf(__('Article with ID %u was not found!', 'mywords'), $id), 0, 1, ['result' => 'error']); } } $row = $xoopsDB->fetchArray($result); $cache = $this->loadCache(); $post = new MWPost(); $post->setVar('title', $row['title']); $post->setVar('shortname', TextCleaner::getInstance()->sweetstring($row['title'])); $post->setVar('content', $row['body']); switch ($row['status']) { case 1: case 4: $status = 'pending'; break; case 2: $status = 'publish'; break; case 3: $status = 'draft'; break; } $post->setVar('status', $status); $post->setVar('visibility', 'public'); $post->setVar('author', $row['uid']); $post->setVar('comstatus', 1); $post->setVar('pubdate', $row['datesub']); $post->setVar('created', $row['datesub']); $post->setVar('reads', $row['counter']); $post->setVar('description', $row['summary']); $post->setVar('keywords', $row['meta_keywords']); $post->setVar('format', 'post'); if (isset($cache['categories'][$row['categoryid']])) { $post->add_categories($cache['categories'][$row['categoryid']]); } unset($row); if (!$post->save()) { $this->ajax_response(sprintf(__('Article %s could not be saved!', 'mywords'), $post->title), 0, 1, ['result' => 'error']); } $this->ajax_response(sprintf(__('Article %s imported successfully!', 'mywords'), '<strong>' . $post->title . '</strong>'), 0, 1, ['result' => 'success']); }