• R/O
  • SSH
  • HTTPS

epitta-bbs: Commit


Commit MetaInfo

Revision35 (tree)
Time2011-09-25 01:56:35
Authorwajett

Log Message

2011/09/25 削除。

Change Summary

Incremental Difference

--- app/actions/article_action.php (revision 34)
+++ app/actions/article_action.php (revision 35)
@@ -267,7 +267,7 @@
267267 $myContent .= getTreeHtml($tr, $this->baseSet['pubURL']);
268268 $branchMap = branchExtender($tree, $tr['id'], $tr['tree_number']);
269269 $depthBranch=array();
270- $myContent .= makeBranch($tree, $tr['id'], $branchMap, $depthBranch );
270+ $myContent .= makeBranch($tree, $tr['id'], $branchMap, $depthBranch, 1, $this->baseSet['pubURL'] );
271271 break;
272272 }
273273
--- app/actions/post_action.php (revision 34)
+++ app/actions/post_action.php (revision 35)
@@ -126,6 +126,12 @@
126126 //返信モード
127127 $artMdl = new Article_Model();
128128 $prnt = $artMdl->getSingleArticle($this->postSet['parent_id']);
129+
130+ if ( $prnt['status_code'] != 1 ) {
131+ //削除時など(とりあえず返信禁止は保留)
132+ //$this->displayError( $GLOBALS['LNG']['cantReplyToDeleted'] );
133+ }
134+
129135 $prnt['article_id'] = $prnt['id'];
130136
131137 $this->postSet['resto'] = getArticleHtml($prnt, $this->baseSet, $this->artlSet, 0, true);
@@ -556,23 +562,13 @@
556562 $this->modifyInput(2);
557563 return;
558564 }
559-
560565
561- //記事関係
562- $status = 9;
563- $parentId = $this->getPost('parent_id');
564- if ( $parentId == 0 ) {
565- //子記事の有無でstatusを制御
566- $branches = getBranchesCount($parentId);
567- if ( $branches > 0 ) {
568- $status = 8;
569- }
570- }
571-
566+ //
567+ $parentId = $this->getPost('parent_id', 0);
572568 //exit;
573569
574570 $artMdl = new Article_model();
575- $artMdl->deleteArticle($articleId, $parentId, $status);
571+ $artMdl->deleteArticle( 1, $articleId, $parentId );
576572
577573 //リダイレクト
578574 $this->redirect('act=sngl&a=' . $articleId);
--- app/models/base_model.php (revision 34)
+++ app/models/base_model.php (revision 35)
@@ -65,7 +65,8 @@
6565
6666
6767 function query($sql) {
68- if ( empty($sql) ) return array(); //echo $sql;
68+ if ( empty($sql) ) return array();
69+ //echo $sql;
6970
7071 $result = sqlite_query($this->conn, $sql, SQLITE_ASSOC, $this->dbError);
7172 if (!$result) $this->errTrigger('Failed Query!' . $this->dbError);
@@ -102,7 +103,7 @@
102103
103104 function execute($sql) {
104105 if ( empty($sql) ) trigger_error ('Empty Query!');
105- echo $sql;
106+ //echo $sql;
106107 $result = sqlite_exec($this->conn, $sql, $this->dbError);
107108 if (!$result) $this->errTrigger('Failed Execute Query!' . $this->dbError);
108109
@@ -111,7 +112,6 @@
111112 }
112113
113114
114-
115115 protected function qt($val) {
116116 return "'" . $val . "'";
117117 }
@@ -127,7 +127,23 @@
127127
128128
129129
130+ protected function begin() {
131+ $sql = "BEGIN";
132+ $result = sqlite_exec($this->conn, $sql, $this->dbError);
133+ if (!$result) $this->errTrigger('Failed Execute Query!' . $this->dbError);
134+ }
135+ protected function commit() {
136+ $sql = "COMMIT";
137+ $result = sqlite_exec($this->conn, $sql, $this->dbError);
138+ if (!$result) $this->errTrigger('Failed Execute Query!' . $this->dbError);
139+ }
140+ protected function rollback() {
141+ $sql = "ROLLBACk";
142+ $result = sqlite_exec($this->conn, $sql, $this->dbError);
143+ if (!$result) $this->errTrigger('Failed Execute Query!' . $this->dbError);
144+ }
130145
146+
131147 /**
132148 * ※SQLiteのトランザクションは微妙なので、こちらを補助に使って制御。
133149 * @param string filePath
--- app/models/article_model.php (revision 34)
+++ app/models/article_model.php (revision 35)
@@ -46,11 +46,7 @@
4646
4747 }
4848
49-/*
50- $result = $this->query($sql);
51- if (!$result) trigger_error ('Failed Query!' . $this->dbError);
52- $rows = sqlite_fetch_array($result, SQLITE_ASSOC);
53-*/
49+
5450 $rows = $this->getRecord($sql, true);
5551 $atcId = $rows['id'];
5652 //echo "atdid=" . $atcId;
@@ -63,12 +59,7 @@
6359
6460 $rows = $this->getRecord($sql);
6561
66- /*
67- $result = $this->query($sql);
68- if (!$result) trigger_error ('Failed Query!' . $this->dbError);
6962
70- $rows = sqlite_fetch_all($result, SQLITE_ASSOC);
71- */
7263
7364 $this->closeConn();
7465
@@ -82,7 +73,7 @@
8273
8374 $this->openConn();
8475
85- $sql = "SELECT * FROM epitta_articles WHERE id=" .$id. " AND status_code=1";
76+ $sql = "SELECT * FROM epitta_articles WHERE id=" .$id. " AND status_code<9";
8677
8778 $result = $this->getRecord($sql, true);
8879
@@ -385,7 +376,9 @@
385376
386377 $this->openConn(2);
387378
379+ $this->begin();
388380
381+
389382 if ( empty($data['tree_number']) ) {
390383 //tree_numberを取得
391384 $sql =
@@ -424,6 +417,13 @@
424417 //echo $sql;
425418 $result = $this->execute($sql);
426419
420+ if ( $result == false ) {
421+ $this->closeConn(2);
422+ trigger_error ('Cannot Insert!');
423+
424+ }
425+
426+
427427 $newId = sqlite_last_insert_rowid ( $this->conn );
428428
429429
@@ -435,10 +435,17 @@
435435 " WHERE id={$data['parent_id']}";
436436
437437 $result = $this->execute($sql);
438+
439+ if ( $result == false ) {
440+ $this->rollback();
441+ $this->closeConn(2);
442+ trigger_error ('Cannot Update Parent!');
443+ }
438444
439445 }
440446
441-
447+
448+ $this->commit();
442449 $this->closeConn(2);
443450
444451
@@ -452,10 +459,12 @@
452459 function updateArticle($data) {
453460
454461 //
462+ $this->openConn(2);
463+
464+ $this->begin();
465+
455466 $now = $this->qt( date( "Y-m-d H:i:s", time() ) );
456467
457- $this->openConn(2);
458-
459468 $sql =
460469 "UPDATE epitta_articles SET " .
461470 " subject=". $data['subject'] . "," .
@@ -475,6 +484,12 @@
475484
476485 $result = $this->execute($sql);
477486
487+ if ( $result == false ) {
488+ $this->closeConn(2);
489+ trigger_error ('Cannot Update!');
490+
491+ }
492+
478493
479494 if ( $result!=false and $data['parent_id'] > 0 ) {
480495 //返信時、親記事書き換え
@@ -484,9 +499,15 @@
484499 " WHERE id={$data['parent_id']}";
485500
486501 $result = $this->execute($sql);
502+ if ( $result == false ) {
503+ $this->rollback();
504+ $this->closeConn(2);
505+ trigger_error ('Cannot Update Parent!');
506+ }
487507
488- }
508+ }
489509
510+ $this->commit();
490511 $this->closeConn(2);
491512
492513
@@ -499,10 +520,13 @@
499520
500521
501522
502- function updateAddArticle($data) {
523+ function __updateAddArticle($data) {
503524
504525 $this->openConn(2);
526+
527+ $this->begin();
505528
529+
506530 $now = $this->qt( date( "Y-m-d H:i:s", time() ) );
507531
508532 $sql =
@@ -514,6 +538,11 @@
514538
515539 $result = $this->execute($sql);
516540
541+ if ( $result == false ) {
542+ $this->closeConn(2);
543+ trigger_error ('Cannot Update!');
544+
545+ }
517546
518547 if ( $data['parent_id'] > 0 ) {
519548 //返信時、親記事書き換え
@@ -524,14 +553,19 @@
524553
525554 $result = $this->execute($sql);
526555
556+ if ( $result == false ) {
557+ $this->rollback();
558+ $this->closeConn(2);
559+ trigger_error ('Cannot Update!');
560+ }
561+
527562 }
563+
564+ //echo "commit";
528565
566+ $this->commit();
529567 $this->closeConn(2);
530568
531-
532- if ( $result==false ) trigger_error ('Cannot Update!');
533-
534-
535569 return $result;
536570
537571 }
@@ -538,18 +572,64 @@
538572
539573
540574
541- function deleteArticle($id, $parentId, $status) {
575+ /***
576+ * 記事の削除
577+ *
578+ * $mode 1:通常 2:管理者
579+ * $id
580+ * $parentId
581+ *
582+ */
583+ function deleteArticle($mode=1, $id, $parentId) {
542584
543585 $this->openConn(2);
544586
587+ $this->begin();
588+
545589 $now = $this->qt( date( "Y-m-d H:i:s", time() ) );
546590
591+
592+ //返信記事の有無でstatusを制御
593+ $status = 9;
594+
595+ $sql = "SELECT COUNT(id) AS cnt FROM epitta_articles " .
596+ " WHERE status_code<9 AND parent_id=".$id;
597+
598+ $rows = $this->getRecord($sql, true);
599+
600+ if ( $rows['cnt'] > 0 ) {
601+ $status = 8;
602+ }
603+
604+
605+ $ope = "投稿者";
606+ if ( $mode == 2 ) {
607+ $ope = "管理者";
608+ }
609+ $sbjt = "[{$ope}削除]";
610+ $athr = "--";
611+ $artc = "{$ope}削除済み(" . date( "Y/m/d H:i") . ")";
612+
613+ //編集
547614 $sql =
548615 "UPDATE epitta_articles SET " .
616+ " subject='$sbjt', author='$athr'," .
617+ " password='', personkey=''," .
618+ " article='$artc', article_add=''," .
619+ " email='', email_code=0, homepage=''," .
620+ " fontcolor='', iconfile=''," .
621+ " reserved1='', reserved2='', reserved3=''," .
622+ " clipfile1='', clipfile2='', clipfile3=''," .
623+ " hostaddress='', useragent='', remarks='$artc'," .
624+ " reserved1='', reserved2='', reserved3=''," .
549625 " status_code=$status, modified=$now" .
550- " WHERE id=$id";
626+ " WHERE id=$id";
551627
552628 $result = $this->execute($sql);
629+ if ( $result == false ) {
630+ $this->closeConn(2);
631+ trigger_error ('Cannot Update Parent!');
632+ }
553633
554634
555635 if ( ! empty($parentId) ) {
@@ -560,9 +640,16 @@
560640 " WHERE id=$parentId";
561641
562642 $result = $this->execute($sql);
643+
644+ if ( $result == false ) {
645+ $this->rollback();
646+ $this->closeConn(2);
647+ trigger_error ('Cannot Update Parent!');
648+ }
563649
564650 }
565651
652+ $this->commit();
566653 $this->closeConn(2);
567654
568655
--- system/locals/ja/wordlist.php (revision 34)
+++ system/locals/ja/wordlist.php (revision 35)
@@ -106,6 +106,7 @@
106106 'notSetUserPassword' => '投稿者パスワードが投稿時に設定されていません。',
107107 'failedUserPassword' => '投稿者パスワードが合致しません。',
108108 'failedDeleteConfirm' => '削除確認がチェックされていません。',
109+'cantReplyToDeleted' => '削除済みの記事には返信できません。',
109110
110111
111112 'failedFileType' => '添付するファイルのタイプが許可されていません。',
Show on old repository browser