PageRenderTime 55ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/baser/plugins/blog/controllers/blog_posts_controller.php

https://github.com/hashing/basercms
PHP | 708 lines | 413 code | 83 blank | 212 comment | 75 complexity | e08803706635beccd5d8ed8d7e3b0836 MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. /* SVN FILE: $Id: blog_posts_controller.php 42 2011-08-23 19:20:59Z ryuring $ */
  3. /**
  4. * 記事コントローラー
  5. *
  6. * PHP versions 5
  7. *
  8. * baserCMS : Based Website Development Project <http://basercms.net>
  9. * Copyright 2008 - 2012, baserCMS Users Community <http://sites.google.com/site/baserusers/>
  10. *
  11. * @copyright Copyright 2008 - 2012, baserCMS Users Community
  12. * @link http://basercms.net baserCMS Project
  13. * @package baser.plugins.blog.controllers
  14. * @since baserCMS v 0.1.0
  15. * @version $Revision: 42 $
  16. * @modifiedby $LastChangedBy: ryuring $
  17. * @lastmodified $Date: 2011-08-24 04:20:59 +0900 (水, 24 8 2011) $
  18. * @license http://basercms.net/license/index.html
  19. */
  20. /**
  21. * Include files
  22. */
  23. /**
  24. * 記事コントローラー
  25. *
  26. * @package baser.plugins.blog.controllers
  27. */
  28. class BlogPostsController extends BlogAppController {
  29. /**
  30. * クラス名
  31. *
  32. * @var string
  33. * @access public
  34. */
  35. var $name = 'BlogPosts';
  36. /**
  37. * モデル
  38. *
  39. * @var array
  40. * @access public
  41. */
  42. var $uses = array('Blog.BlogCategory', 'Blog.BlogPost', 'Blog.BlogContent');
  43. /**
  44. * ヘルパー
  45. *
  46. * @var array
  47. * @access public
  48. */
  49. var $helpers = array(BC_TEXT_HELPER, BC_TIME_HELPER, BC_FORM_HELPER, BC_CKEDITOR_HELPER, 'Blog.Blog');
  50. /**
  51. * コンポーネント
  52. *
  53. * @var array
  54. * @access public
  55. */
  56. var $components = array('BcAuth','Cookie','BcAuthConfigure', 'BcEmail');
  57. /**
  58. * ぱんくずナビ
  59. *
  60. * @var string
  61. * @access public
  62. */
  63. var $crumbs = array(
  64. array('name' => 'プラグイン管理', 'url' => array('plugin' => '', 'controller' => 'plugins', 'action' => 'index')),
  65. array('name' => 'ブログ管理', 'url' => array('controller' => 'blog_contents', 'action' => 'index'))
  66. );
  67. /**
  68. * サブメニューエレメント
  69. *
  70. * @var array
  71. * @access public
  72. */
  73. var $subMenuElements = array();
  74. /**
  75. * ブログコンテンツデータ
  76. *
  77. * @var array
  78. * @access public
  79. */
  80. var $blogContent;
  81. /**
  82. * beforeFilter
  83. *
  84. * @return void
  85. * @access public
  86. */
  87. function beforeFilter() {
  88. parent::beforeFilter();
  89. if(isset($this->params['pass'][0])) {
  90. $this->BlogContent->recursive = -1;
  91. $this->blogContent = $this->BlogContent->read(null,$this->params['pass'][0]);
  92. $this->crumbs[] = array('name' => $this->blogContent['BlogContent']['title'].'管理', 'url' => array('controller' => 'blog_posts', 'action' => 'index', $this->params['pass'][0]));
  93. if($this->params['prefix'] == 'admin') {
  94. $this->subMenuElements = array('blog_posts','blog_categories','blog_common');
  95. }
  96. }
  97. }
  98. /**
  99. * beforeRender
  100. *
  101. * @return void
  102. * @access public
  103. */
  104. function beforeRender() {
  105. parent::beforeRender();
  106. $this->set('blogContent',$this->blogContent);
  107. }
  108. /**
  109. * [ADMIN] 一覧表示
  110. *
  111. * @return void
  112. * @access public
  113. */
  114. function admin_index($blogContentId) {
  115. if(!$blogContentId || !$this->blogContent) {
  116. $this->Session->setFlash('無効な処理です。');
  117. $this->redirect(array('controller' => 'blog_contents', 'action' => 'index'));
  118. }
  119. /* 画面情報設定 */
  120. $default = array('named' => array('num' => $this->siteConfigs['admin_list_num']));
  121. $this->setViewConditions('BlogPost', array('group' => $blogContentId, 'default' => $default));
  122. /* 検索条件生成 */
  123. $joins = array();
  124. if(!empty($this->data['BlogPost']['blog_tag_id'])) {
  125. $db =& ConnectionManager::getDataSource($this->BlogPost->useDbConfig);
  126. if($db->config['driver'] != 'bc_csv') {
  127. $joins = array(
  128. array(
  129. 'table' => $db->config['prefix'].'blog_posts_blog_tags',
  130. 'alias' => 'BlogPostsBlogTag',
  131. 'type' => 'inner',
  132. 'conditions'=> array('BlogPostsBlogTag.blog_post_id = BlogPost.id')
  133. ),
  134. array(
  135. 'table' => $db->config['prefix'].'blog_tags',
  136. 'alias' => 'BlogTag',
  137. 'type' => 'inner',
  138. 'conditions'=> array('BlogTag.id = BlogPostsBlogTag.blog_tag_id', 'BlogTag.id' => $this->data['BlogPost']['blog_tag_id'])
  139. ));
  140. }
  141. }
  142. $conditions = $this->_createAdminIndexConditions($blogContentId, $this->data);
  143. $this->paginate = array('conditions'=>$conditions,
  144. 'joins' => $joins,
  145. 'order' =>'BlogPost.no DESC',
  146. 'limit' =>$this->passedArgs['num']
  147. );
  148. $this->set('posts', $this->paginate('BlogPost'));
  149. if($this->RequestHandler->isAjax() || !empty($this->params['url']['ajax'])) {
  150. $this->render('ajax_index');
  151. return;
  152. }
  153. $this->pageTitle = '['.$this->blogContent['BlogContent']['title'].'] 記事一覧';
  154. $this->search = 'blog_posts_index';
  155. $this->help = 'blog_posts_index';
  156. }
  157. /**
  158. * ページ一覧用の検索条件を生成する
  159. *
  160. * @param array $blogContentId
  161. * @param array $data
  162. * @return array $conditions
  163. * @access protected
  164. */
  165. function _createAdminIndexConditions($blogContentId, $data) {
  166. unset($data['ListTool']);
  167. $name = $blogCategoryId = '';
  168. if(isset($data['BlogPost']['name'])) {
  169. $name = $data['BlogPost']['name'];
  170. }
  171. unset($data['BlogPost']['name']);
  172. unset($data['_Token']);
  173. if(isset($data['BlogPost']['status']) && $data['BlogPost']['status'] === '') {
  174. unset($data['BlogPost']['status']);
  175. }
  176. if(isset($data['BlogPost']['user_id']) && $data['BlogPost']['user_id'] === '') {
  177. unset($data['BlogPost']['user_id']);
  178. }
  179. if(!empty($data['BlogPost']['blog_category_id'])) {
  180. $blogCategoryId = $data['BlogPost']['blog_category_id'];
  181. }
  182. unset($data['BlogPost']['blog_category_id']);
  183. $conditions = array('BlogPost.blog_content_id'=>$blogContentId);
  184. // CSVの場合はHABTM先のテーブルの条件を直接設定できない為、タグに関連するポストを抽出して条件を生成
  185. $db =& ConnectionManager::getDataSource($this->BlogPost->useDbConfig);
  186. if($db->config['driver'] == 'bc_csv') {
  187. if(!empty($data['BlogPost']['blog_tag_id'])) {
  188. $blogTags = $this->BlogPost->BlogTag->read(null, $data['BlogPost']['blog_tag_id']);
  189. if($blogTags) {
  190. $conditions['BlogPost.id'] = Set::extract('/BlogPost/id', $blogTags);
  191. }
  192. }
  193. }
  194. unset($data['BlogPost']['blog_tag_id']);
  195. // ページカテゴリ(子カテゴリも検索条件に入れる)
  196. if($blogCategoryId) {
  197. $blogCategoryIds = array($blogCategoryId);
  198. $children = $this->BlogCategory->children($blogCategoryId);
  199. if($children) {
  200. foreach($children as $child) {
  201. $blogCategoryIds[] = $child['BlogCategory']['id'];
  202. }
  203. }
  204. $conditions['BlogPost.blog_category_id'] = $blogCategoryIds;
  205. } else {
  206. unset($data['BlogPost']['blog_category_id']);
  207. }
  208. $_conditions = $this->postConditions($data);
  209. if($_conditions) {
  210. $conditions = am($conditions, $_conditions);
  211. }
  212. if($name) {
  213. $conditions['BlogPost.name LIKE'] = '%'.$name.'%';
  214. }
  215. return $conditions;
  216. }
  217. /**
  218. * [ADMIN] 登録処理
  219. *
  220. * @param int $blogContentId
  221. * @return void
  222. * @access public
  223. */
  224. function admin_add($blogContentId) {
  225. if(!$blogContentId || !$this->blogContent) {
  226. $this->Session->setFlash('無効な処理です。');
  227. $this->redirect(array('controller' => 'blog_contents', 'action' => 'index'));
  228. }
  229. if(empty($this->data)) {
  230. $this->data = $this->BlogPost->getDefaultValue($this->BcAuth->user());
  231. }else {
  232. $this->data['BlogPost']['blog_content_id'] = $blogContentId;
  233. $this->data['BlogPost']['no'] = $this->BlogPost->getMax('no',array('BlogPost.blog_content_id'=>$blogContentId))+1;
  234. $this->data['BlogPost']['posts_date'] = str_replace('/','-',$this->data['BlogPost']['posts_date']);
  235. $this->BlogPost->create($this->data);
  236. // データを保存
  237. if($this->BlogPost->saveAll()) {
  238. clearViewCache();
  239. $id = $this->BlogPost->getLastInsertId();
  240. $message = '記事「'.$this->data['BlogPost']['name'].'」を追加しました。';
  241. $this->Session->setFlash($message);
  242. $this->BlogPost->saveDbLog($message);
  243. $this->BcPluginHook->executeHook('afterBlogPostAdd', $this);
  244. // 編集画面にリダイレクト
  245. $this->redirect(array('action' => 'edit', $blogContentId, $id));
  246. }else {
  247. $this->Session->setFlash('エラーが発生しました。内容を確認してください。');
  248. }
  249. }
  250. // 表示設定
  251. $user = $this->BcAuth->user();
  252. $userModel = $this->getUserModel();
  253. $categories = $this->BlogPost->getControlSource('blog_category_id', array(
  254. 'blogContentId' => $this->blogContent['BlogContent']['id'],
  255. 'rootEditable' => $this->checkRootEditable(),
  256. 'userGroupId' => $user[$userModel]['user_group_id'],
  257. 'postEditable' => true,
  258. 'empty' => '指定しない'
  259. ));
  260. $this->set('editable', true);
  261. $this->set('categories', $categories);
  262. $this->set('previewId', 'add_'.mt_rand(0, 99999999));
  263. $this->set('ckEditorOptions1', array('width' => 'auto', 'useDraft' => true, 'draftField' => 'content_draft', 'disableDraft' => true));
  264. $this->set('ckEditorOptions2', array('width' => 'auto', 'useDraft' => true, 'draftField' => 'detail_draft', 'disableDraft' => true));
  265. $this->set('users',$this->BlogPost->User->getUserList(array('User.id' => $user[$userModel]['id'])));
  266. $this->pageTitle = '['.$this->blogContent['BlogContent']['title'].'] 新規記事登録';
  267. $this->help = 'blog_posts_form';
  268. $this->render('form');
  269. }
  270. /**
  271. * [ADMIN] 編集処理
  272. *
  273. * @param int $blogContentId
  274. * @param int $id
  275. * @return void
  276. * @access public
  277. */
  278. function admin_edit($blogContentId,$id) {
  279. if(!$blogContentId || !$id) {
  280. $this->Session->setFlash('無効な処理です。');
  281. $this->redirect(array('controller' => 'blog_contents', 'action' => 'index'));
  282. }
  283. if(empty($this->data)) {
  284. $this->data = $this->BlogPost->read(null, $id);
  285. $this->data['BlogPost']['content_tmp'] = $this->data['BlogPost']['content'];
  286. $this->data['BlogPost']['detail_tmp'] = $this->data['BlogPost']['detail'];
  287. }else {
  288. if(!empty($this->data['BlogPost']['posts_date'])){
  289. $this->data['BlogPost']['posts_date'] = str_replace('/','-',$this->data['BlogPost']['posts_date']);
  290. }
  291. $this->BlogPost->set($this->data);
  292. // データを保存
  293. if($this->BlogPost->saveAll()) {
  294. clearViewCache();
  295. $message = '記事「'.$this->data['BlogPost']['name'].'」を更新しました。';
  296. $this->Session->setFlash($message);
  297. $this->BlogPost->saveDbLog($message);
  298. $this->BcPluginHook->executeHook('afterBlogPostEdit', $this);
  299. $this->redirect(array('action' => 'edit', $blogContentId, $id));
  300. }else {
  301. $this->Session->setFlash('エラーが発生しました。内容を確認してください。');
  302. }
  303. }
  304. // 表示設定
  305. $user = $this->BcAuth->user();
  306. $userModel = $this->getUserModel();
  307. $editable = false;
  308. $blogCategoryId = '';
  309. if(isset($this->data['BlogPost']['blog_category_id'])) {
  310. $blogCategoryId = $this->data['BlogPost']['blog_category_id'];
  311. }
  312. if(!$blogCategoryId) {
  313. $currentCatOwner = $this->siteConfigs['root_owner_id'];
  314. } else {
  315. $currentCatOwner = $this->data['BlogCategory']['owner_id'];
  316. }
  317. $editable = ($currentCatOwner == $user[$userModel]['user_group_id'] ||
  318. $user[$userModel]['user_group_id'] == 1 || !$currentCatOwner);
  319. $categories = $this->BlogPost->getControlSource('blog_category_id', array(
  320. 'blogContentId' => $this->blogContent['BlogContent']['id'],
  321. 'rootEditable' => $this->checkRootEditable(),
  322. 'blogCategoryId'=> $blogCategoryId,
  323. 'userGroupId' => $user[$userModel]['user_group_id'],
  324. 'postEditable' => $editable,
  325. 'empty' => '指定しない'
  326. ));
  327. if($this->data['BlogPost']['status']) {
  328. $this->set('publishLink', '/' . $this->blogContent['BlogContent']['name'] . '/archives/' . $this->data['BlogPost']['no']);
  329. }
  330. $this->set('editable', $editable);
  331. $this->set('categories', $categories);
  332. $this->set('previewId', $this->data['BlogPost']['id']);
  333. $this->set('users',$this->BlogPost->User->getUserList());
  334. $this->set('ckEditorOptions1', array('width' => 'auto', 'useDraft' => true, 'draftField' => 'content_draft', 'disableDraft' => false));
  335. $this->set('ckEditorOptions2', array('width' => 'auto', 'useDraft' => true, 'draftField' => 'detail_draft', 'disableDraft' => false));
  336. $this->pageTitle = '['.$this->blogContent['BlogContent']['title'].'] 記事編集: '.$this->data['BlogPost']['name'];
  337. $this->help = 'blog_posts_form';
  338. $this->render('form');
  339. }
  340. /**
  341. * [ADMIN] 削除処理 (ajax)
  342. *
  343. * @param int $blogContentId
  344. * @param int $id
  345. * @return void
  346. * @access public
  347. */
  348. function admin_ajax_delete($blogContentId, $id = null) {
  349. if(!$id) {
  350. $this->ajaxError(500, '無効な処理です。');
  351. }
  352. // 削除実行
  353. if($this->_del($id)) {
  354. clearViewCache();
  355. exit(true);
  356. }
  357. exit();
  358. }
  359. /**
  360. * 一括削除
  361. *
  362. * @param array $ids
  363. * @return boolean
  364. * @access protected
  365. */
  366. function _batch_del($ids) {
  367. if($ids) {
  368. foreach($ids as $id) {
  369. $this->_del($id);
  370. }
  371. }
  372. return true;
  373. }
  374. /**
  375. * データを削除する
  376. *
  377. * @param int $id
  378. * @return boolean
  379. * @access protected
  380. */
  381. function _del($id) {
  382. // メッセージ用にデータを取得
  383. $post = $this->BlogPost->read(null, $id);
  384. // 削除実行
  385. if($this->BlogPost->del($id)) {
  386. $this->BlogPost->saveDbLog($post['BlogPost']['name'].' を削除しました。');
  387. return true;
  388. } else {
  389. return false;
  390. }
  391. }
  392. /**
  393. * [ADMIN] 削除処理
  394. *
  395. * @param int $blogContentId
  396. * @param int $id
  397. * @return void
  398. * @access public
  399. */
  400. function admin_delete($blogContentId,$id = null) {
  401. if(!$blogContentId || !$id) {
  402. $this->Session->setFlash('無効な処理です。');
  403. $this->redirect(array('controller' => 'blog_contents', 'action' => 'index'));
  404. }
  405. // メッセージ用にデータを取得
  406. $post = $this->BlogPost->read(null, $id);
  407. // 削除実行
  408. if($this->BlogPost->del($id)) {
  409. clearViewCache();
  410. $message = $post['BlogPost']['name'].' を削除しました。';
  411. $this->Session->setFlash($message);
  412. $this->BlogPost->saveDbLog($message);
  413. }else {
  414. $this->Session->setFlash('データベース処理中にエラーが発生しました。');
  415. }
  416. $this->redirect(array('action' => 'index',$blogContentId));
  417. }
  418. /**
  419. * 外部データインポート
  420. * WordPressのみ対応(2.2.3のみ検証済)
  421. *
  422. * @return void
  423. * @access public
  424. */
  425. function admin_import() {
  426. // 入力チェック
  427. $check = true;
  428. $message = '';
  429. if(!isset($this->data['Import']['blog_content_id']) || !$this->data['Import']['blog_content_id']) {
  430. $message .= '取り込み対象のブログを選択してください<br />';
  431. $check = false;
  432. }
  433. if(!isset($this->data['Import']['user_id']) || !$this->data['Import']['user_id']) {
  434. $message .= '記事の投稿者を選択してください<br />';
  435. $check = false;
  436. }
  437. if(!isset($this->data['Import']['file']['tmp_name'])) {
  438. $message .= 'XMLデータを選択してください<br />';
  439. $check = false;
  440. }
  441. if($this->data['Import']['file']['type'] != 'text/xml') {
  442. $message .= 'XMLデータを選択してください<br />';
  443. $check = false;
  444. }else {
  445. // XMLデータを読み込む
  446. App::import('Xml');
  447. $xml = new Xml($this->data['Import']['file']['tmp_name']);
  448. $_posts = Set::reverse($xml);
  449. if(!isset($_posts['Rss']['Channel']['Item'])) {
  450. $message .= 'XMLデータが不正です<br />';
  451. $check = false;
  452. }else {
  453. $_posts = $_posts['Rss']['Channel']['Item'];
  454. }
  455. }
  456. // 送信内容に問題がある場合には元のページにリダイレクト
  457. if(!$check) {
  458. $this->Session->setFlash($message);
  459. $this->redirect(array('controller' => 'blog_configs', 'action' => 'form'));
  460. }
  461. // カテゴリ一覧の取得
  462. $blogCategoryList = $this->BlogCategory->find('list',array('conditions'=>array('blog_content_id'=>$this->data['Import']['blog_content_id'])));
  463. $blogCategoryList = array_flip($blogCategoryList);
  464. // ポストデータに変換し1件ずつ保存
  465. $count = 0;
  466. foreach($_posts as $_post) {
  467. if(!$_post['Encoded'][0]) {
  468. continue;
  469. }
  470. $post = array();
  471. $post['blog_content_id'] = $this->data['Import']['blog_content_id'];
  472. $post['no'] = $this->BlogPost->getMax('no',array('BlogPost.blog_content_id'=>$this->data['Import']['blog_content_id']))+1;
  473. $post['name'] = $_post['title'];
  474. $_post['Encoded'][0] = str_replace("\n","<br />",$_post['Encoded'][0]);
  475. $encoded = split('<!--more-->',$_post['Encoded'][0]);
  476. $post['content'] = $encoded[0];
  477. if(isset($encoded[1])) {
  478. $post['detail'] = $encoded[1];
  479. }else {
  480. $post['detail'] = '';
  481. }
  482. if(isset($_post['Category'])) {
  483. $_post['category'] = $_post['Category'][0];
  484. }elseif(isset($_post['category'])) {
  485. $_post['category'] = $_post['category'];
  486. }else {
  487. $_post['category'] = '';
  488. }
  489. if(isset($blogCategoryList[$_post['category']])) {
  490. $post['blog_category_no'] = $blogCategoryList[$_post['category']];
  491. }else {
  492. $no = $this->BlogCategory->getMax('no',array('BlogCategory.blog_content_id'=>$this->data['Import']['blog_content_id']))+1;
  493. $this->BlogCategory->create(array('name'=>$_post['category'],'blog_content_id'=>$this->data['Import']['blog_content_id'],'no'=>$no));
  494. $this->BlogCategory->save();
  495. $post['blog_category_id'] = $this->BlogCategory->getInsertID();
  496. $blogCategoryList[$_post['category']] = $post['blog_category_id'];
  497. }
  498. $post['user_id'] = $this->data['Import']['user_id'];
  499. $post['status'] = 1;
  500. $post['posts_date'] = $_post['post_date'];
  501. $this->BlogPost->create($post);
  502. if($this->BlogPost->save()) {
  503. $count++;
  504. }
  505. }
  506. $this->Session->setFlash( $count . ' 件の記事を取り込みました');
  507. $this->redirect(array('controller' => 'blog_configs', 'action' => 'form'));
  508. }
  509. /**
  510. * [ADMIN] 無効状態にする(AJAX)
  511. *
  512. * @param string $blogContentId
  513. * @param string $blogPostId beforeFilterで利用
  514. * @param string $blogCommentId
  515. * @return void
  516. * @access public
  517. */
  518. function admin_ajax_unpublish($blogContentId, $id) {
  519. if(!$id) {
  520. $this->ajaxError(500, '無効な処理です。');
  521. }
  522. if($this->_changeStatus($id, false)) {
  523. clearViewCache();
  524. exit(true);
  525. } else {
  526. $this->ajaxError(500, $this->BlogPost->validationErrors);
  527. }
  528. exit();
  529. }
  530. /**
  531. * [ADMIN] 有効状態にする(AJAX)
  532. *
  533. * @param string $blogContentId
  534. * @param string $blogPostId beforeFilterで利用
  535. * @param string $blogCommentId
  536. * @return void
  537. * @access public
  538. */
  539. function admin_ajax_publish($blogContentId, $id) {
  540. if(!$id) {
  541. $this->ajaxError(500, '無効な処理です。');
  542. }
  543. if($this->_changeStatus($id, true)) {
  544. clearViewCache();
  545. exit(true);
  546. } else {
  547. $this->ajaxError(500, $this->BlogPost->validationErrors);
  548. }
  549. exit();
  550. }
  551. /**
  552. * 一括公開
  553. *
  554. * @param array $ids
  555. * @return boolean
  556. * @access protected
  557. */
  558. function _batch_publish($ids) {
  559. if($ids) {
  560. foreach($ids as $id) {
  561. $this->_changeStatus($id, true);
  562. }
  563. }
  564. clearViewCache();
  565. return true;
  566. }
  567. /**
  568. * 一括非公開
  569. *
  570. * @param array $ids
  571. * @return boolean
  572. * @access protected
  573. */
  574. function _batch_unpublish($ids) {
  575. if($ids) {
  576. foreach($ids as $id) {
  577. $this->_changeStatus($id, false);
  578. }
  579. }
  580. clearViewCache();
  581. return true;
  582. }
  583. /**
  584. * ステータスを変更する
  585. *
  586. * @param int $id
  587. * @param boolean $status
  588. * @return boolean
  589. */
  590. function _changeStatus($id, $status) {
  591. $statusTexts = array(0 => '公開状態', 1 => '非公開状態');
  592. $data = $this->BlogPost->find('first', array('conditions' => array('BlogPost.id' => $id), 'recursive' => -1));
  593. $data['BlogPost']['status'] = $status;
  594. $data['BlogPost']['publish_begin'] = '';
  595. $data['BlogPost']['publish_end'] = '';
  596. $this->BlogPost->set($data);
  597. if($this->BlogPost->save()) {
  598. $statusText = $statusTexts[$status];
  599. $this->BlogPost->saveDbLog('ブログ記事「'.$data['BlogPost']['name'].'」 を'.$statusText.'にしました。');
  600. return true;
  601. } else {
  602. return false;
  603. }
  604. }
  605. /**
  606. * [ADMIN] コピー
  607. *
  608. * @param int $id
  609. * @return void
  610. * @access public
  611. */
  612. function admin_ajax_copy($blogContentId, $id = null) {
  613. $result = $this->BlogPost->copy($id);
  614. if($result) {
  615. // タグ情報を取得するため読み込みなおす
  616. $this->BlogPost->recursive = 1;
  617. $data = $this->BlogPost->read();
  618. $this->setViewConditions('BlogPost', array('action' => 'admin_index'));
  619. $this->set('data', $data);
  620. } else {
  621. $this->ajaxError(500, $this->BlogPost->validationErrors);
  622. }
  623. }
  624. }
  625. ?>