- Timestamp:
- 09/21/07 00:00:33 (14 months ago)
- Location:
- team/michiel/import_blogs
- Files:
-
- 3 modified
-
. (modified) (1 prop)
-
common/mvblog_admin.php (modified) (5 diffs)
-
common/mvblog_common.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
team/michiel/import_blogs
- Property svnmerge-integrated changed from /trunk:1-649 to /trunk:1-651
-
team/michiel/import_blogs/common/mvblog_admin.php
r650 r652 1064 1064 "public" => 1 1065 1065 ); 1066 /* we selected a month only */ 1066 1067 if ((array_key_exists("month", $options) && $options["month"] > 0) && (array_key_exists("year", $options) && $options["year"] > 0)) { 1067 $timestamp_start = mktime(0,0,0,$options["month"],1,$options["year"]); 1068 $timestamp_stop = mktime(0,0,0,$options["month"]+1,1,$options["year"]); 1069 $q1 = sprintf("WHERE %s BETWEEN %d AND %d", $this->db_quote("date"), $timestamp_start, $timestamp_stop); 1070 } else { 1071 $options["month"] = 0; 1072 $options["year"] = 0; 1073 $q1 = ""; 1074 } 1075 if (array_key_exists("category_id", $options) && $options["category_id"]) 1076 $q1 = sprintf("WHERE aside = 0 AND (categories_ids like '%%,%1\$d' OR categories_ids like '%1\$d,%%' OR categories_ids like '%%,%1\$d,%%' or categories_ids = '%1\$d')", $options["category_id"]); 1068 $postoptions["archive"] = 1; 1069 $postoptions["timestamp_start"] = mktime(0,0,0,$options["month"],1,$options["year"]); 1070 $postoptions["timestamp_stop"] = mktime(0,0,0,$options["month"]+1,1,$options["year"]); 1071 } 1077 1072 1078 $res_count =& $this->db->query("SELECT COUNT(*) FROM articles $q1"); 1079 $counter_r = $res_count->fetchRow(); 1080 $counter = $counter_r[0]; 1081 $this->db->setLimit($options["limit"], $options["top"]); 1082 $res =& $this->db->query("SELECT * FROM articles $q1 ORDER BY ".$this->db_quote("date")." DESC"); 1083 if (PEAR::isError($res)) { 1084 die($res->getDebugInfo()); 1085 } 1073 if (array_key_exists("category_id", $options) && $options["category_id"]) { 1074 $postoptions["archive"] = 2; 1075 $postoptions["category_id"] = $options["category_id"]; 1076 } 1077 $postoptions["start"] = $options["top"]-1; 1078 $postoptions["top"] = $options["top"]; 1079 $postoptions["limit"] = $options["limit"]; 1080 /* max time is 10 years in the future */ 1081 $postoptions["max_time"] = mktime(0, 0, 0, date("m"), date("d"), date("Y")+10); 1082 1083 $posts = $this->_get_posts($postoptions); 1084 $counter = $posts["total_count"]; 1085 1086 1086 ?> 1087 1087 <h1 class="log_post_new"><a href="./index.php?action=edit_post&id=0"><?php echo gettext("create new"); ?></a></h1><br /> … … 1093 1093 <?php 1094 1094 for ($i=1;$i<=12;$i++) { 1095 if ( $options["month"] == $i) { $selected = " SELECTED"; } else { $selected = ""; }1095 if (array_key_exists("month", $options) && $options["month"] == $i) { $selected = " SELECTED"; } else { $selected = ""; } 1096 1096 echo "<option value=\"".$i."\"".$selected.">".date("M", mktime(0,0,0,$i,1,0))."</option>\n"; 1097 1097 } … … 1107 1107 $row1 = $res1->fetchRow(); 1108 1108 for ($i=date("Y", $row1[0]);$i<=date("Y");$i++) { 1109 if ( $options["year"] == $i) { $selected1 = " SELECTED"; } else { $selected1 = ""; }1109 if (array_key_exists("year", $options) && $options["year"] == $i) { $selected1 = " SELECTED"; } else { $selected1 = ""; } 1110 1110 echo "<option value=\"".$i."\"".$selected1.">".$i."</option>\n"; 1111 1111 } … … 1131 1131 </form> 1132 1132 <?php 1133 while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {1133 foreach ($posts["posts"] as $row) { 1134 1134 if (!trim($row["title"])) { 1135 1135 $row["title"] = "[".gettext("no title")."]"; … … 1168 1168 <?php 1169 1169 } 1170 if (!array_key_exists("month", $options)) 1171 $options["month"] = 0; 1172 if (!array_key_exists("year", $options)) 1173 $options["year"] = 0; 1174 1170 1175 if ($options["top"]) { 1171 1176 echo "<a class=\"link_prev\" href=\"index.php?action=show_posts&options[month]=".(int)$options["month"]."&options[year]=".(int)$options["year"]."&options[top]=".($options["top"]-$options["limit"])."\">".gettext("previous")."</a> "; -
team/michiel/import_blogs/common/mvblog_common.php
r640 r652 585 585 else 586 586 $dossier = 0; 587 588 if (array_key_exists("active", $options)) 589 $active = $options["active"]; 590 else 591 $active = 1; 592 593 if (array_key_exists("public", $options)) 594 $public = $options["public"]; 595 else 596 $public = 1; 597 598 if (array_key_exists("adminmode", $options) && $options["adminmode"]) 599 $adminmode = 1; 600 else 601 $adminmode = 0; 587 602 588 603 switch ($archive) { … … 609 624 $options["timestamp_end"] = $time_end; 610 625 } 611 $q = sprintf("AND public=1 AND aside = 0 AND date BETWEEN %d AND %d", $options["timestamp_start"], $options["timestamp_end"]); 626 if ($adminmode) 627 $q = sprintf("AND date BETWEEN %d AND %d", $options["timestamp_start"], $options["timestamp_end"]); 628 else 629 $q = sprintf("AND public=%d AND aside = 0 AND date BETWEEN %d AND %d", $public, $options["timestamp_start"], $options["timestamp_end"]); 612 630 $title = "<p><h1 class=\"log_archive_h1\">".gettext("Archive of")." ".$archtitle."</h1></p>"; 613 631 $url_prev = "?action=archive&m=".date("mY", $options["timestamp_start"])."&top=".($options["top"]-$options["limit"]); … … 617 635 if (!array_key_exists("category_id", $options)) 618 636 $options["category_id"] = (int)$_REQUEST["c"]; 619 $q = sprintf("AND public=1 AND aside = 0 AND date <= %d AND (categories_ids like '%%,%2\$d' OR categories_ids like '%2\$d,%%' OR categories_ids like '%%,%2\$d,%%' or categories_ids = '%2\$d')", $options["max_time"], $options["category_id"]); 637 if ($adminmode) 638 $q = sprintf("AND aside = 0 AND date <= %d AND (categories_ids like '%%,%2\$d' OR categories_ids like '%2\$d,%%' OR categories_ids like '%%,%2\$d,%%' or categories_ids = '%2\$d')", $options["max_time"], $options["category_id"]); 639 else 640 $q = sprintf("AND public=%d AND aside = 0 AND date <= %d AND (categories_ids like '%%,%3\$d' OR categories_ids like '%3\$d,%%' OR categories_ids like '%%,%3\$d,%%' or categories_ids = '%3\$d')", $public, $options["max_time"], $options["category_id"]); 620 641 $title = "<p><h1 class=\"log_archive_h1\">".gettext("Archive of category")." <i>".$this->categories[$options["category_id"]]["name"]."</i></h1></p>"; 621 642 $desc = "<br /><br /><div class=\"log_dossier_description\">".$this->categories[$options["category_id"]]["desc"]."</div><br />"; … … 624 645 break; 625 646 case 3 : 626 $q = sprintf("AND public=1 AND date <= %d AND aside=1", $options["max_time"]); 647 if ($adminmode) 648 $q = sprintf("AND date <= %d AND aside=1", $options["max_time"]); 649 else 650 $q = sprintf("AND public=%d AND date <= %d AND aside=1", $public, $options["max_time"]); 627 651 $title = "<p><h1 class=\"log_archive_h1\">".gettext("Archive of")." <i>\"asides\"</i></h1></p>"; 628 652 $url_prev = "?action=archive_cat&c=aside&top=".($options["top"]-$options["limit"]); … … 637 661 $options["timestamp_start"] = $time_start; 638 662 } 639 $q = sprintf("AND public = 1 AND date <= %d", $options["timestamp_start"]); 663 if ($adminmode) 664 $q = sprintf("AND date <= %d", $options["timestamp_start"]); 665 else 666 $q = sprintf("AND public = %d AND date <= %d", $public, $options["timestamp_start"]); 640 667 $title = "<p><h1 class=\"log_archive_h1\">".gettext("Archive of articles posted before")." ".date("F Y", $options["timestamp_start"])."</h1></p>"; 641 668 $url_prev = "?action=archive_old&fromts=".$options["timestamp_start"]."&top=".($options["top"]-$options["limit"]); … … 652 679 $url_prev = "index.php?action=viewdossier&id=$dossier&top=".($options["top"]-$options["limit"]); 653 680 $url_next = "index.php?action=viewdossier&id=$dossier&top=".($options["top"]+$options["limit"]); 654 $q = sprintf("AND date <= %d AND public=1 AND dossier_id = %d", $options["max_time"], $dossier); 681 if ($adminmode) 682 $q = sprintf("AND date <= %d AND dossier_id = %d", $options["max_time"], $dossier); 683 else 684 $q = sprintf("AND date <= %d AND public=%d AND dossier_id = %d", $options["max_time"], $public, $dossier); 655 685 } else { 656 $q = sprintf("AND date <= %d AND public=1", $options["max_time"]); 686 if ($adminmode) 687 $q = sprintf("AND date <= %d", $options["max_time"]); 688 else 689 $q = sprintf("AND date <= %d AND public=%d", $options["max_time"], $public); 657 690 $title = ""; 658 691 $url_prev = "index.php?top=".($options["top"]-$options["limit"]); … … 678 711 679 712 if ($options["limit"]) { 680 $res_count =& $this->db->query("SELECT COUNT(*) FROM articles WHERE active=1 $q"); 713 $q_count = sprintf("SELECT COUNT(*) FROM articles WHERE active = 1 %s", $q); 714 $res_count =& $this->db->query($q_count); 681 715 if (PEAR::isError($res_count)) 682 716 die($res_count->getUserInfo()); … … 685 719 $posts["total_count"] = $row[0]; 686 720 $this->db->setLimit($options["limit"], $options["start"]); 687 $res =& $this->db->query("SELECT * FROM articles WHERE active=1 $q ORDER BY date DESC"); 688 } else 689 $res =& $this->db->query("SELECT * FROM articles WHERE active=1 $q"); 721 $sql = sprintf("SELECT * FROM articles WHERE active = 1 %s ORDER BY date DESC", $q); 722 $res =& $this->db->query($sql); 723 } else { 724 $sql = sprintf("SELECT * FROM articles WHERE active = 1 %s", $q); 725 $res =& $this->db->query($sql); 726 } 690 727 691 728 if (PEAR::isError($res))
