OSDN Git Service

CANGE: i18n::formatted_datetime()を整備。mysqldate()関数を非推奨に。
[nucleus-jp/nucleus-next.git] / nucleus / libs / ITEM.php
index e4e05e2..c17a925 100644 (file)
@@ -45,12 +45,14 @@ class ITEM
        }
        
        /**
+        * ITEM::getitem()
         * Returns one item with the specific itemid
         *
         * @param int $item_id
         * @param bool $allow_draft
         * @param bool $allow_future
         * @return mixed
+        * 
         */
        static public function getitem($item_id, $allow_draft, $allow_future)
        {
@@ -59,35 +61,35 @@ class ITEM
                $item_id = intval($item_id);
                
                $query = 'SELECT ' .
-                       '`i`.`idraft` AS `draft`, ' .
-                       '`i`.`inumber` AS `itemid`, ' .
-                       '`i`.`iclosed` AS `closed`, ' .
-                       '`i`.`ititle` AS `title`, ' .
-                       '`i`.`ibody` AS `body`, ' .
-                       '`m`.`mname` AS `author`, ' .
-                       '`i`.`iauthor` AS `authorid`, ' .
-                       '`i`.`itime`, ' .
-                       '`i`.`imore` AS `more`, ' .
-                       '`i`.`ikarmapos` AS `karmapos`, ' .
-                       '`i`.`ikarmaneg` AS `karmaneg`, ' .
-                       '`i`.`icat` AS `catid`, ' .
-                       '`i`.`iblog` AS `blogid` ' .
-                       'FROM `%s` AS `i`, `%s` AS `m`, `%s` AS `b` ' .
-                       'WHERE `i`.`inumber` = %d ' .
-                       'AND `i`.`iauthor` = `m`.`mnumber` ' .
-                       'AND `i`.`iblog` = `b`.`bnumber`';
+                       'i.idraft AS draft, ' .
+                       'i.inumber AS itemid, ' .
+                       'i.iclosed AS closed, ' .
+                       'i.ititle AS title, ' .
+                       'i.ibody AS body, ' .
+                       'm.mname AS author, ' .
+                       'i.iauthor AS authorid, ' .
+                       'i.itime, ' .
+                       'i.imore AS more, ' .
+                       'i.ikarmapos AS karmapos, ' .
+                       'i.ikarmaneg AS karmaneg, ' .
+                       'i.icat AS catid, ' .
+                       'i.iblog AS blogid ' .
+                       'FROM %s AS i, %s AS m, %s AS b ' .
+                       'WHERE i.inumber = %d ' .
+                       'AND i.iauthor = m.mnumber ' .
+                       'AND i.iblog = b.bnumber ';
                
                $query = sprintf($query, sql_table('item'), sql_table('member'), sql_table('blog'), $item_id);
                
                if ( !$allow_draft )
                {
-                       $query .= 'AND `i`.`idraft` = 0 ';
+                       $query .= "AND i.idraft = 0 ";
                }
                
                if ( !$allow_future )
                {
                        $blog =& $manager->getBlog(getBlogIDFromItemID($item_id));
-                       $query .= 'AND `i`.`itime` <= ' . mysqldate($blog->getCorrectTime());
+                       $query .= "AND `i`.`itime` <= '" . i18n::formatted_datetime('mysql', $blog->getCorrectTime()) ."'";
                }
                
                $query .= ' LIMIT 1';
@@ -113,6 +115,7 @@ class ITEM
         * @static
         * @param       void
         * @return      array   (status = added/error/newcategory, message)
+        * 
         */
        static public function createFromRequest()
        {
@@ -265,6 +268,7 @@ class ITEM
                $old_blogid = getBlogIDFromItemID($itemid);
                
                // move will be done on end of method
+               $moveNeeded = 0;
                if ( $new_blogid != $old_blogid )
                {
                        $moveNeeded = 1;
@@ -342,13 +346,13 @@ class ITEM
                {
                        $query .= ', idraft = 1';
                        // set timestamp back to zero for a draft
-                       $query .= ', itime = ' . mysqldate($timestamp);
+                       $query .= ", itime = '" . i18n::formatted_datetime('mysql', $timestamp) ."'";
                }
                
                // update timestamp when needed
                if ( $timestamp != 0 )
                {
-                       $query .= ', itime = ' . mysqldate($timestamp);
+                       $query .= ", itime = '" . i18n::formatted_datetime('mysql', $timestamp) ."'";
                }
                
                // make sure the correct item is updated
@@ -478,6 +482,7 @@ class ITEM
         * @param       boolean $future
         * @param       boolean $draft
         * @return      boolean exists or not
+        * 
         */
        static public function exists($itemid, $future, $draft)
        {
@@ -494,7 +499,7 @@ class ITEM
                                return 0;
                        }
                        $blog =& $manager->getBlog($blogid);
-                       $query .= ' and itime<=' . mysqldate($blog->getCorrectTime());
+                       $query .= " and itime<='" . i18n::formatted_datetime('mysql', $blog->getCorrectTime()) ."'";
                }
                if ( !$draft )
                {