Changeset 4621
- Timestamp:
- 10/27/07 04:01:25 (13 months ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
blog/owner/entry/draft/index.php (modified) (2 diffs)
-
blog/owner/entry/edit/item.php (modified) (4 diffs)
-
blog/owner/entry/update/item.php (modified) (3 diffs)
-
lib/config.php (modified) (1 diff)
-
lib/includeForBlogOwner.php (modified) (1 diff)
-
lib/model/blog.entry.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/blog/owner/entry/draft/index.php
r4599 r4621 18 18 'acceptTrackback' => array(array('0', '1'), 'default' => '0'), 19 19 'published' => array('int', 0, 'default' => 0) 20 )21 );20 ) 21 ); 22 22 require ROOT . '/lib/includeForBlogOwner.php'; 23 requireModel('blog.entry'); 24 23 25 requireStrictRoute(); 26 27 if(empty($suri['id'])) respondResultPage(1); 24 28 $entry['id'] = $suri['id']; 25 29 $entry['draft'] = 1; 26 30 $entry['visibility'] = $_POST['visibility']; 27 $entry['category'] = empty($_POST['category']) ? 0 :$_POST['category'];31 $entry['category'] = $_POST['category']; 28 32 $entry['title'] = $_POST['title']; 29 33 $entry['content'] = $_POST['content']; … … 32 36 $entry['location'] = empty($_POST['location']) ? '/' : $_POST['location']; 33 37 $entry['tag'] = empty($_POST['tag']) ? '' : $_POST['tag']; 38 $entry['slogan'] = $_POST['permalink']; 34 39 $entry['acceptComment'] = empty($_POST['acceptComment']) ? 0 : 1; 35 40 $entry['acceptTrackback'] = empty($_POST['acceptTrackback']) ? 0 : 1; 36 41 $entry['published'] = empty($_POST['published']) ? 0 : $_POST['published']; 37 if (($id = saveDraftEntry($entry)) !== false) { 42 $id = saveDraftEntry($blogid, $entry); 43 if ($id > 0) { 38 44 setBlogSetting('LatestEditedEntry_user'.getUserId(),$id); 39 45 $result = array(); 40 $result['error'] = ( ($id !== false) === true ? 0 : 1);46 $result['error'] = ($id > 0) ? 0 : 1; 41 47 $result['entryId'] = $id; 48 $result['suriid'] = $suri['id']; 42 49 printRespond($result); 50 } else { 51 respondResultPage(1); 43 52 } 44 else45 respondResultPage(1);46 53 ?> -
trunk/blog/owner/entry/edit/item.php
r4615 r4621 29 29 $suri['id'] = 0; 30 30 31 if( $_GET['draft']) {31 if(isset($_GET['draft'])) { 32 32 $entry = getEntry(getBlogId(), $suri['id'], true); 33 33 } else { … … 76 76 return true; 77 77 } 78 79 78 function setEnclosure(value) { 80 79 var filename = value.substring(0, value.indexOf("|")); … … 299 298 return false; 300 299 } 301 data = data+"&draft=1";302 300 if(entryManager.isSaved == true) { 303 var request = new HTTPRequest("POST", "<?php echo $blogURL;?>/owner/entry/ update/"+entryManager.entryId);301 var request = new HTTPRequest("POST", "<?php echo $blogURL;?>/owner/entry/draft/"+entryManager.entryId); 304 302 <?php 305 303 if($service['useRewriteEngine'] == false) { … … 359 357 if (data == null) 360 358 return false; 361 data = data+"&draft=0";362 359 if(entryManager.isSaved == true) { 363 360 var request = new HTTPRequest("POST", "<?php echo $blogURL;?>/owner/entry/update/"+entryManager.entryId); -
trunk/blog/owner/entry/update/item.php
r4617 r4621 17 17 'acceptComment' => array(array('0', '1'), 'default' => '0'), 18 18 'acceptTrackback' => array(array('0', '1'), 'default' => '0'), 19 'published' => array('int', 0, 'default' => 1), 20 'draft' => array(array('0', '1'), 'default' => '0') 19 'published' => array('int', 0, 'default' => 1) 21 20 ) 22 21 ); … … 25 24 26 25 requireStrictRoute(); 27 $entry = array(); 28 $isDraft = empty($_POST['draft']) ? 0 : $_POST['draft']; 29 if($isDraft) { // Prepare for draft saving. 30 $entry['id'] = $suri['id']; 26 27 $updateDraft = 0; 28 $entry = getEntry($blogid, $suri['id']); 29 if(empty($entry)) { 30 $entry = getEntry($blogid, $suri['id'],true); 31 $updateDraft = 1; 32 } 33 if (!empty($entry)) { 31 34 $entry['visibility'] = $_POST['visibility']; 32 35 $entry['category'] = $_POST['category']; … … 41 44 $entry['acceptTrackback'] = empty($_POST['acceptTrackback']) ? 0 : 1; 42 45 $entry['published'] = empty($_POST['published']) ? 0 : $_POST['published']; 43 $entry['draft'] = empty($_POST['draft']) ? 0 : $_POST['draft']; 44 } else if ($entry = getEntry($blogid, $suri['id'])) { // Non-draft saving. 45 $entry['visibility'] = $_POST['visibility']; 46 $entry['category'] = $_POST['category']; 47 $entry['location'] = empty($_POST['location']) ? '/' : $_POST['location']; 48 $entry['tag'] = empty($_POST['tag']) ? '' : $_POST['tag']; 49 $entry['title'] = $_POST['title']; 50 $entry['content'] = $_POST['content']; 51 $entry['contentFormatter'] = $_POST['contentFormatter']; 52 $entry['contentEditor'] = $_POST['contentEditor']; 53 $entry['slogan'] = $_POST['permalink']; 54 $entry['acceptComment'] = empty($_POST['acceptComment']) ? 0 : 1; 55 $entry['acceptTrackback'] = empty($_POST['acceptTrackback']) ? 0 : 1; 56 $entry['published'] = empty($_POST['published']) ? 0 : $_POST['published']; 57 $entry['draft'] = empty($_POST['draft']) ? 0 : $_POST['draft']; 58 } 59 if(!empty($entry)) { 60 setBlogSetting('LatestEditedEntry_user'.getUserId(),$suri['id']); 61 if($id = updateEntry($blogid, $entry)) { 46 47 if($id = updateEntry($blogid, $entry, $updateDraft)) { 62 48 fireEvent('UpdatePost', $id, $entry); 49 setBlogSetting('LatestEditedEntry_user'.getUserId(),$suri['id']); 63 50 respondResultPage(0); 64 51 } -
trunk/lib/config.php
r4615 r4621 57 57 58 58 // Include core components. 59 // Due to the global variable scope issues, use require here instead of requireComponent. 60 59 61 requireComponent('Eolin.PHP.UnifiedEnvironment'); 60 62 requireComponent('Eolin.PHP.Core'); -
trunk/lib/includeForBlogOwner.php
r4605 r4621 12 12 require 'function/image.php'; 13 13 require 'function/mail.php'; 14 //require 'function/legacy.php';14 require 'function/legacy.php'; 15 15 require 'functions.php'; 16 16 require 'database.php'; -
trunk/lib/model/blog.entry.php
r4617 r4621 83 83 } 84 84 85 function getUserIdOfEntry($blogid, $id ) {85 function getUserIdOfEntry($blogid, $id, $draft = false) { 86 86 global $database; 87 87 $result = DBQuery::queryCell("SELECT userid … … 417 417 requireModel("blog.tag"); 418 418 requireModel("blog.locative"); 419 419 420 $entry['userid'] = getUserId(); 420 421 $entry['title'] = UTF8::lessenAsEncoding(trim($entry['title']), 255); … … 448 449 } 449 450 450 $result = DBQuery::queryCount("SELECT slogan FROM {$database['prefix']}Entries WHERE blogid = $blogid AND slogan = '$slogan' AND draft = $isDraftLIMIT 1");451 $result = DBQuery::queryCount("SELECT slogan FROM {$database['prefix']}Entries WHERE blogid = $blogid AND slogan = '$slogan' AND draft = 0 LIMIT 1"); 451 452 for ($i = 1; $result > 0; $i++) { 452 453 if ($i > 1000) 453 454 return false; 454 455 $slogan = tc_escape_string(UTF8::lessenAsEncoding($slogan0, 245) . '-' . $i); 455 $result = DBQuery::queryCount("SELECT slogan FROM {$database['prefix']}Entries WHERE blogid = $blogid AND slogan = '$slogan' AND draft = $isDraftLIMIT 1");456 $result = DBQuery::queryCount("SELECT slogan FROM {$database['prefix']}Entries WHERE blogid = $blogid AND slogan = '$slogan' AND draft = 0 LIMIT 1"); 456 457 } 457 458 $userid = $entry['userid']; … … 468 469 } 469 470 470 if(isset($entry['id'])) { // entry id가 있는 경우 (주로 updateEntry에 의하여 draft를 생성하는 경우가 될 것이다) 471 if(DBQuery::queryCell("SELECT count(*) FROM {$database['prefix']}Entries WHERE blogid = $blogid AND id = {$entry['id']} AND draft = $isDraft") != 0) { // 이미 원하는 draft에 같은 id가 다 존재한다. 이 경우 저장할 수 없음. 471 if(isset($entry['id'])) { // entry id를 지정한 경우 (주로 saveDraftEntry에 의하여 draft를 생성하는 경우가 될 것이다) 472 if(DBQuery::queryCell("SELECT count(*) 473 FROM {$database['prefix']}Entries 474 WHERE blogid = $blogid 475 AND id = {$entry['id']} 476 AND draft = $isDraft") > 0) { // 이미 원하는 draft에 같은 id가 다 존재한다. 이 경우 저장할 수 없음. 472 477 return false; 473 478 } else { … … 510 515 return false; 511 516 DBQuery::query("UPDATE {$database['prefix']}Attachments SET parent = $id WHERE blogid = $blogid AND parent = 0"); 512 if(!$isDraft) { 517 if(!$isDraft) { // draft가 없는 상태에서 저장하고 나가는 경우. 513 518 DBQuery::query("DELETE FROM {$database['prefix']}Entries WHERE blogid = $blogid AND id = $id AND draft = 1"); 514 519 updateEntriesOfCategory($blogid, $entry['category']); … … 525 530 } 526 531 527 function updateEntry($blogid, $entry ) {532 function updateEntry($blogid, $entry, $updateDraft = 0) { 528 533 global $database; 529 534 global $blog; … … 535 540 536 541 if($entry['id'] == 0) return false; 537 $isDraft = empty($entry['draft']) ? 0 : $entry['draft'];538 539 // entry가 draft가 없으면서(draft = 1인 글이 없는 경우) 저장하려는 요구사항이 draft인 경우는 addEntry로 글을 더한다.540 $draftCount = DBQuery::queryCell("SELECT count(*) FROM {$database['prefix']}Entries541 WHERE blogid = $blogid542 AND id = ".$entry['id']."543 AND draft = 1");544 if(($draftCount == 0) && ($isDraft == 1)) {545 return addEntry($blogid, $entry);546 }547 // draft가 없으면서 정상적인 글을 저장하려는 경우, (이 경우는 현재 글을 update한다.)548 // draft가 있으면서 정상적인 글을 저장하려는 경우, (이 경우는 draft를 update한다.)549 // draft가 있으면서 draft를 저장하려는 경우가 남음. (이 경우도 draft를 update한다.)550 542 551 543 if(empty($entry['userid'])) $entry['userid'] = getUserId(); … … 587 579 AND slogan = '$slogan' 588 580 AND id = {$entry['id']} 589 AND draft = $isDraft LIMIT 1"); 581 AND draft = 0 582 LIMIT 1"); 590 583 if ($result == 0) { // if changed 591 $result = DBQuery::queryCount("SELECT slogan FROM {$database['prefix']}Entries WHERE blogid = $blogid AND slogan = '$slogan' AND draft = $isDraftLIMIT 1");584 $result = DBQuery::queryCount("SELECT slogan FROM {$database['prefix']}Entries WHERE blogid = $blogid AND slogan = '$slogan' AND draft = 0 LIMIT 1"); 592 585 for ($i = 1; $result > 0; $i++) { 593 586 if ($i > 1000) 594 587 return false; 595 588 $slogan = tc_escape_string(UTF8::lessenAsEncoding($slogan0, 245) . '-' . $i); 596 $result = DBQuery::queryCount("SELECT slogan FROM {$database['prefix']}Entries WHERE blogid = $blogid AND slogan = '$slogan' AND draft = $isDraftLIMIT 1");589 $result = DBQuery::queryCount("SELECT slogan FROM {$database['prefix']}Entries WHERE blogid = $blogid AND slogan = '$slogan' AND draft = 0 LIMIT 1"); 597 590 } 598 591 } … … 616 609 break; 617 610 } 618 619 // draft가 없으면서 정상적인 글을 저장하려는 경우, (이 경우는 현재 글을 update한다.) 620 if(($draftCount == 0) && ($isDraft == 0)) $draftSign = 0; 621 else $draftSign = 1; 622 623 // 원래 글이 이미 있으면서 정상적인 글을 저장하려는 경우 원래 글을 날리고 현재 draft를 update한다. 624 if(($draftCount > 0) && ($isDraft == 0)) { 625 if(!DBQuery::query("DELETE FROM {$database['prefix']}Entries WHERE blogid = $blogid AND id = {$entry['id']} AND draft = 0")) return false; 626 } 611 627 612 $result = DBQuery::query("UPDATE {$database['prefix']}Entries 628 613 SET … … 630 615 visibility = {$entry['visibility']}, 631 616 category = {$entry['category']}, 632 draft = $isDraft,617 draft = 0, 633 618 location = '$location', 634 619 title = '$title', … … 641 626 published = $published, 642 627 modified = UNIX_TIMESTAMP() 643 WHERE blogid = $blogid AND id = {$entry['id']} AND draft = $draftSign"); 644 if($isDraft == 0) { // Publishing phase. 645 if ($result) // 정상적인 글을 저장하려는 경우 draft는 날린다. 646 DBQuery::query("DELETE FROM {$database['prefix']}Entries WHERE blogid = $blogid AND id = {$entry['id']} AND draft = 1"); 647 updateEntriesOfCategory($blogid, $entry['category']); 648 if ($entry['visibility'] == 3) 649 syndicateEntry($entry['id'], 'modify'); 650 DBQuery::query("UPDATE {$database['prefix']}Attachments SET parent = {$entry['id']} WHERE blogid = $blogid AND parent = 0"); 651 if ($entry['visibility'] >= 2) 652 clearRSS(); 628 WHERE blogid = $blogid AND id = {$entry['id']} AND draft = $updateDraft"); 629 if ($result) 630 @DBQuery::query("DELETE FROM {$database['prefix']}Entries WHERE blogid = $blogid AND id = {$entry['id']} AND draft = 1"); 631 updateEntriesOfCategory($blogid, $entry['category']); 632 if ($entry['visibility'] == 3) 633 syndicateEntry($entry['id'], 'modify'); 634 DBQuery::query("UPDATE {$database['prefix']}Attachments SET parent = {$entry['id']} WHERE blogid = $blogid AND parent = 0"); 635 if ($entry['visibility'] >= 2) 636 clearRSS(); 637 return $result ? $entry['id'] : false; 638 } 639 640 function saveDraftEntry($blogid, $entry) { 641 global $database, $blog; 642 requireModel('blog.tag'); 643 requireModel('blog.locative'); 644 requireModel('blog.attachment'); 645 requireModel('blog.category'); 646 requireModel('blog.rss'); 647 648 if($entry['id'] == 0) return -11; 649 650 $draftCount = DBQuery::queryCell("SELECT count(*) FROM {$database['prefix']}Entries 651 WHERE blogid = $blogid 652 AND id = ".$entry['id']." 653 AND draft = 1"); 654 655 if($draftCount > 0) { // draft가 없으면 insert를, 있으면 update를. 656 $doUpdate = true; 657 } else { 658 $doUpdate = false; 659 } 660 // 원 글을 읽어서 몇가지 정보를 보존한다. 원래 글이 없는 경우 draft는 저장될 수 없다. 661 $origEntry = DBQuery::queryRow("SELECT created, comments, trackbacks, password 662 FROM {$database['prefix']}Entries 663 WHERE blogid = $blogid 664 AND id = ".$entry['id']." 665 AND draft = 0"); 666 if(empty($origEntry)) return -12; 667 668 $created = $origEntry['created']; 669 $comments = $origEntry['comments']; 670 $trackbacks = $origEntry['trackbacks']; 671 $password = $origEntry['password']; 672 673 if(empty($entry['userid'])) $entry['userid'] = getUserId(); 674 $entry['title'] = UTF8::lessenAsEncoding(trim($entry['title'])); 675 $entry['location'] = UTF8::lessenAsEncoding(trim($entry['location'])); 676 $entry['slogan'] = array_key_exists('slogan', $entry) ? trim($entry['slogan']) : ''; 677 if(empty($entry['slogan'])) { 678 $slogan = $slogan0 = getSlogan($entry['title']); 679 } else { 680 $slogan = $slogan0 = getSlogan($entry['slogan']); 681 } 682 $slogan = tc_escape_string(UTF8::lessenAsEncoding($slogan, 255)); 683 $title = tc_escape_string($entry['title']); 684 685 if($entry['category'] == -1) { 686 if($entry['visibility'] == 1 || $entry['visibility'] == 3) 687 return false; 688 if(DBQuery::queryCell("SELECT count(*) 689 FROM {$database['prefix']}Entries 690 WHERE blogid = $blogid 691 AND id <> {$entry['id']} 692 AND draft = 0 693 AND title = '$title' 694 AND category = -1") > 0) 695 return -13; 696 } 697 698 if ($entry['category'] < 0) { 699 if ($entry['visibility'] == 1) $entry['visibility'] = 0; 700 if ($entry['visibility'] == 3) $entry['visibility'] = 2; 701 } 702 if ($entry['category'] == -4) { 703 $entry['visibility'] = 0; 704 } 705 706 $result = DBQuery::queryCount("SELECT slogan 707 FROM {$database['prefix']}Entries 708 WHERE blogid = $blogid 709 AND slogan = '$slogan' 710 AND id = {$entry['id']} 711 AND draft = 0 LIMIT 1"); 712 if ($result == 0) { // if changed 713 $result = DBQuery::queryCount("SELECT slogan FROM {$database['prefix']}Entries WHERE blogid = $blogid AND slogan = '$slogan' AND draft = 0 LIMIT 1"); 714 for ($i = 1; $result > 0; $i++) { 715 if ($i > 1000) 716 return false; 717 $slogan = tc_escape_string(UTF8::lessenAsEncoding($slogan0, 245) . '-' . $i); 718 $result = DBQuery::queryCount("SELECT slogan FROM {$database['prefix']}Entries WHERE blogid = $blogid AND slogan = '$slogan' AND draft = 0 LIMIT 1"); 719 } 720 } 721 $tags = getTagsWithEntryString($entry['tag']); 722 modifyTagsWithEntryId($blogid, $entry['id'], $tags); 723 724 $location = tc_escape_string($entry['location']); 725 $content = tc_escape_string($entry['content']); 726 $contentFormatter = tc_escape_string($entry['contentFormatter']); 727 $contentEditor = tc_escape_string($entry['contentEditor']); 728 switch ($entry['published']) { 729 case 0: 730 $published = 'published'; 731 break; 732 case 1: 733 $published = 'UNIX_TIMESTAMP()'; 734 break; 735 default: 736 $published = $entry['published']; 737 $entry['visibility'] = 0 - $entry['visibility']; 738 break; 739 } 740 741 if($doUpdate) { 742 $result = DBQuery::query("UPDATE {$database['prefix']}Entries 743 SET 744 userid = {$entry['userid']}, 745 visibility = {$entry['visibility']}, 746 category = {$entry['category']}, 747 draft = 1, 748 location = '$location', 749 title = '$title', 750 content = '$content', 751 contentFormatter = '$contentFormatter', 752 contentEditor = '$contentEditor', 753 slogan = '$slogan', 754 acceptComment = {$entry['acceptComment']}, 755 acceptTrackback = {$entry['acceptTrackback']}, 756 published = $published, 757 modified = UNIX_TIMESTAMP() 758 WHERE blogid = $blogid AND id = {$entry['id']} AND draft = 1"); 759 } else { 760 $result = DBQuery::query("INSERT INTO {$database['prefix']}Entries 761 (blogid, userid, id, draft, visibility, category, title, slogan, content, contentFormatter, 762 contentEditor, location, password, acceptComment, acceptTrackback, published, created, modified, 763 comments, trackbacks) 764 VALUES ( 765 $blogid, 766 {$entry['userid']}, 767 {$entry['id']}, 768 1, 769 {$entry['visibility']}, 770 {$entry['category']}, 771 '$title', 772 '$slogan', 773 '$content', 774 '$contentFormatter', 775 '$contentEditor', 776 '$location', 777 '$password', 778 {$entry['acceptComment']}, 779 {$entry['acceptTrackback']}, 780 $published, 781 $created, 782 UNIX_TIMESTAMP(), 783 $comments, 784 $trackbacks)"); 653 785 } 654 786 return $result ? $entry['id'] : false;
