public function copyItem($id, $copies) { cmsCore::callEvent('COPY_CATALOG_ITEM', $id); $item = $this->inDB->get_fields('cms_uc_items', "id = '{$id}'", 'category_id, title, pubdate, published, imageurl, fieldsdata, is_comments, tags, rating, meta_desc, meta_keys, price, canmany, user_id, on_moderate'); if (!$item) { return false; } for ($c = 1; $c <= $copies; $c++) { $set = ''; foreach ($item as $field => $value) { $set .= "{$field} = '{$this->inDB->escape_string($value)}',"; } $set = rtrim($set, ','); $this->inDB->query("INSERT INTO cms_uc_items SET {$set}"); $id = $this->inDB->get_last_id('cms_uc_items'); cmsInsertTags($item['tags'], 'catalog', $id); } }
/** * Обновляет пост в блоге * @param int $post_id * @param array $item * @param bool $update_seo_link * @return bool */ public function updatePost($post_id, $item, $update_seo_link = false) { $item['id'] = $post_id; $item = cmsCore::callEvent('UPDATE_POST', $item); if ($update_seo_link) { $item['seolink'] = $this->generatePostSeoLink($item); } if (mb_strstr($item['content'], '[cut')) { $msg_to = $this->getPostShort($item['content']); $msg_to = cmsCore::parseSmiles($msg_to, true); $msg_after = $this->getPostShort($item['content'], false, true); $msg_after = cmsCore::parseSmiles($msg_after, true); $cut = $this->getPostCut($item['content']); $item['content_html'] = $msg_to . $cut . $msg_after; } else { $item['content_html'] = cmsCore::parseSmiles($item['content'], true); } $item['content'] = $this->inDB->escape_string($item['content']); $item['content_html'] = $this->inDB->escape_string($item['content_html']); $this->inDB->update('cms_blog_posts', $item, $post_id); cmsInsertTags($item['tags'], $this->getTarget('tags'), $post_id); return isset($item['seolink']) ? $item['seolink'] : true; }
/** * Обновляет данные фото * @return bool */ public function updatePhoto($photo, $id){ cmsCore::c('db')->update('cms_photo_files', cmsCore::callEvent('UPDATE_PHOTO', $photo), $id); if ($photo['tags']){ cmsInsertTags($photo['tags'], $this->getTarget('tags'), $id); } return true; }
} if ($cell_id === 'title') { $title = $celldata; } elseif ($cell_id === 'price') { $price = $celldata; } else { $fields[] = $celldata; } } $fields = serialize($fields); if ($title && $fields) { $sql = "INSERT INTO cms_uc_items (category_id, title, pubdate, published, imageurl, fieldsdata, is_comments, tags, rating, meta_desc, meta_keys, price, canmany)\r\n VALUES ({$cat_id}, '{$title}', NOW(), '{$published}', '{$imgfile}', '{$fields}', {$is_comments}, '{$tags}', 0, '{$meta_desc}', '{$meta_keys}', '{$price}', {$canmany})"; dbQuery($sql) or die('Ошибка импорта. Проверьте правильность настроек. <a href="javascript:window.history.go(-2)">Назад</a>'); if ($tags) { $lastid = dbLastId('cms_uc_items'); cmsInsertTags($tags, 'catalog', $lastid); } } } if ($file) { @unlink($file); } } else { $msg .= 'Ошибка загрузки файла Excel!'; } } else { $file = ''; } header('location:?view=components&do=config&opt=list_items&id=' . $_REQUEST['id']); } //=================================================================================================//
/** * Обновляет статью * @return bool */ public function updateArticle($id, $article, $not_upd_seo = false) { $article['id'] = $id; if (!$not_upd_seo) { if (@$article['url']) { $article['url'] = cmsCore::strToURL($article['url'], $this->config['is_url_cyrillic']); } $article['seolink'] = $this->getSeoLink($article); } else { unset($article['seolink']); unset($article['url']); } if (!$article['user_id']) { $article['user_id'] = cmsUser::getInstance()->id; } $article = cmsCore::callEvent('UPDATE_ARTICLE', $article); $this->inDB->update('cms_content', $article, $id); if (!$not_upd_seo) { $this->updateContentCommentsLink($id); } cmsInsertTags($article['tags'], 'content', $id); return true; }
/** * Обновляет статью * @return bool */ public function updateArticle($id, $article, $not_upd_seo = false) { $article['id'] = $id; cmsCore::setIdUploadImage('', $article['id'], 'content'); cmsCore::requestUploadImgTitles($article['id'], 'content'); cmsCore::updateComImages($article['id'], 'content', '', 'cms_content', 'images'); if (!$not_upd_seo) { if (@$article['url']) { $article['url'] = cmsCore::strToURL($article['url'], $this->config['is_url_cyrillic']); } $article['seolink'] = $this->getSeoLink($article); } else { unset($article['seolink']); unset($article['url']); } if (!$article['user_id']) { $article['user_id'] = cmsCore::c('user')->id; } $article = cmsCore::callEvent('UPDATE_ARTICLE', $article); cmsCore::c('db')->update('cms_content', $article, $id); if (!$not_upd_seo) { $this->updateContentCommentsLink($id); } cmsInsertTags($article['tags'], 'content', $id); return true; }
} //проверяем есть ли запись $is_exists = $inDB->rows_count("cms_{$item['component']}", "id = {$item['id']}"); if (!$is_exists) { cmsCore::jsonOutput(array('error' => true, 'html' => ' Запись с данным идентификатором не существует!')); cmsCore::halt(); } if ($item['component'] == 'blog_posts') { cmsCore::loadClass('blog'); $inBlog = cmsBlogs::getInstance(); $inBlog->updatePost($item['id'], $item); $succes = true; } elseif ($item['component'] == 'content') { //библиотека тегов cmsCore::includeFile('/core/lib_tags.php'); cmsInsertTags($item['tags'], $item['component'], $item['id']); //экранируем кавычки $item = $inDB->escape_string($item); //обновляем запись $succes = $inDB->update("cms_{$item['component']}", $item, $item['id']); } //обновляем и передаем защитный токен $item['csrf_token'] = cmsUser::getCsrfToken(); if ($succes) { cmsCore::jsonOutput(array('error' => false, 'item' => $item)); } else { cmsCore::jsonOutput(array('error' => true, 'html' => ' Произошла ошибка при обновлении данных в БД!')); } ?>