OSDN Git Service

merged from v3.31sp1
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / libs / ADMIN.php
index 3fcd545..8278da3 100755 (executable)
@@ -14,8 +14,8 @@
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: ADMIN.php,v 1.20 2007-03-22 03:30:14 kmorimatsu Exp $
- * @version $NucleusJP: ADMIN.php,v 1.19 2007/03/20 19:31:29 kmorimatsu Exp $
+ * @version $Id: ADMIN.php,v 1.24 2008-02-08 09:31:22 kimitake Exp $
+ * @version $NucleusJP: ADMIN.php,v 1.21.2.4 2007/10/30 19:04:24 kmorimatsu Exp $
  */
 
 if ( !function_exists('requestVar') ) exit;
@@ -840,13 +840,13 @@ class ADMIN {
 
                // start index
                if (postVar('start'))
-                       $start = postVar('start');
+                       $start = intPostVar('start');
                else
                        $start = 0;
 
                // amount of items to show
                if (postVar('amount'))
-                       $amount = postVar('amount');
+                       $amount = intPostVar('amount');
                else
                        $amount = 10;
 
@@ -892,13 +892,13 @@ class ADMIN {
 
                // start index
                if (postVar('start'))
-                       $start = postVar('start');
+                       $start = intPostVar('start');
                else
                        $start = 0;
 
                // amount of items to show
                if (postVar('amount'))
-                       $amount = postVar('amount');
+                       $amount = intPostVar('amount');
                else
                        $amount = 10;
 
@@ -933,13 +933,13 @@ class ADMIN {
 
                // start index
                if (postVar('start'))
-                       $start = postVar('start');
+                       $start = intPostVar('start');
                else
                        $start = 0;
 
                // amount of items to show
                if (postVar('amount'))
-                       $amount = postVar('amount');
+                       $amount = intPostVar('amount');
                else
                        $amount = 10;
 
@@ -986,13 +986,13 @@ class ADMIN {
 
                // start index
                if (postVar('start'))
-                       $start = postVar('start');
+                       $start = intPostVar('start');
                else
                        $start = 0;
 
                // amount of items to show
                if (postVar('amount'))
-                       $amount = postVar('amount');
+                       $amount = intPostVar('amount');
                else
                        $amount = 10;
 
@@ -1165,13 +1165,21 @@ class ADMIN {
                // edit the item for real
                ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
 
-               if ($draftid > 0) {
+               $blogid = getBlogIDFromItemID($itemid);
+               $blog =& $manager->getBlog($blogid);
+
+               $isFuture = 0;
+               if ($timestamp > $blog->getCorrectTime(time())) {
+                       $isFuture = 1;
+               }
+
+               $this->updateFuturePosted($blogid);
+
+               if ($draftid > 0 && $member->canAlterItem($draftid)) {
                        ITEM::delete($draftid);
                }
 
-               $blogid = getBlogIDFromItemID($itemid);
-               $blog =& $manager->getBlog($blogid);
-               if (!$closed && $publish && $wasdraft && $blog->pingUserland()) {
+               if (!$closed && $publish && $wasdraft && $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0 && !$isFuture) {
                        $this->action_sendping($blogid);
                        return;
                }
@@ -1262,8 +1270,33 @@ class ADMIN {
                if (!$member->canAlterItem($itemid))
                        return _ERROR_DISALLOWED;
 
+               // need to get blogid before the item is deleted
+               $blogid = getBlogIDFromItemId($itemid);
+
                $manager->loadClass('ITEM');
                ITEM::delete($itemid);
+
+               // update blog's futureposted
+               $this->updateFuturePosted($blogid);
+       }
+
+       /**
+        * Update a blog's future posted flag
+        * @param int $blogid
+        */
+       function updateFuturePosted($blogid) {
+               global $manager;
+
+               $blog =& $manager->getBlog($blogid);
+               $currenttime = $blog->getCorrectTime(time());
+               $result = sql_query("SELECT * FROM ".sql_table('item').
+                       " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
+               if (mysql_num_rows($result) > 0) {
+                               $blog->setFuturePost();
+               }
+               else {
+                               $blog->clearFuturePost();
+               }
        }
 
        /**
@@ -1324,8 +1357,16 @@ class ADMIN {
                // only allow if user is allowed to alter item
                $member->canUpdateItem($itemid, $catid) or $this->disallow();
 
+               $old_blogid = getBlogIDFromItemId($itemid);
+
                ITEM::move($itemid, $catid);
 
+               // set the futurePosted flag on the blog
+               $this->updateFuturePosted(getBlogIDFromItemId($itemid));
+
+               // reset the futurePosted in case the item is moved from one blog to another
+               $this->updateFuturePosted($old_blogid);
+
                if ($catid != intRequestVar('catid'))
                        $this->action_categoryedit($catid, $blog->getID());
                else
@@ -1370,16 +1411,16 @@ class ADMIN {
                        $this->action_categoryedit(
                                $result['catid'],
                                $blogid,
-                               $blog->pingUserland() ? $pingUrl : ''
+                               $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0 ? $pingUrl : ''
                        );
-               elseif ((postVar('actiontype') == 'addnow') && $blog->pingUserland())
+               elseif ((postVar('actiontype') == 'addnow') && $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0)
                        $this->action_sendping($blogid);
                else
                        $this->action_itemlist($blogid);
        }
 
        /**
-        * Shows a window that says we're about to ping weblogs.com.
+        * Shows a window that says we're about to ping.
         * immediately refresh to the real pinging page, which will
         * show an error, or redirect to the blog.
         *
@@ -1397,12 +1438,10 @@ class ADMIN {
 
                $this->pagehead('<meta http-equiv="refresh" content="1; url='.htmlspecialchars($rawPingUrl).'" />');
                ?>
-               <h2>Site Updated, Now pinging weblogs.com</h2>
+               <h2>Site Updated, Now pinging various weblog listing services...</h2>
 
                <p>
-                       Pinging weblogs.com! This can a while...
-                       <br />
-                       When the ping is complete (and successfull), your weblog will show up in the weblogs.com updates list.
+                       This can take a while...
                </p>
 
                <p>
@@ -1412,7 +1451,6 @@ class ADMIN {
        }
 
        /**
-        * Ping to Weblogs.com
         * Sends the real ping (can take up to 10 seconds!)
         */
        function action_rawping() {
@@ -1422,17 +1460,19 @@ class ADMIN {
                $blogid = intRequestVar('blogid');
                $blog =& $manager->getBlog($blogid);
 
-               $result = $blog->sendUserlandPing();
-
                $this->pagehead();
 
                ?>
 
-               <h2>Ping Results</h2>
+               <h2>Pinging services, please wait...</h2>
+               <div class='note'>
+                <?php
 
-               <p>The following message was returned by weblogs.com:</p>
+               // send sendPing event
+               $manager->notify('SendPing', array('blogid' => $blogid));
 
-               <div class='note'><?php echo  $result ?></div>
+                ?>
+                </div>
 
                <ul>
                        <li><a href="index.php?action=itemlist&amp;blogid=<?php echo $blog->getID()?>">View list of recent items for <?php echo htmlspecialchars($blog->getName())?></a></li>
@@ -2309,11 +2349,11 @@ class ADMIN {
 
                // check if: - there remains at least one blog admin
                //           - (there remains at least one team member)
-               $tmem = MEMBER::createFromID($memberid);
+               $mem = MEMBER::createFromID($memberid);
 
                $manager->notify('PreDeleteTeamMember', array('member' => &$mem, 'blogid' => $blogid));
 
-               if ($tmem->isBlogAdmin($blogid)) {
+               if ($mem->isBlogAdmin($blogid)) {
                        // check if there are more blog members left and at least one admin
                        // (check for at least two admins before deletion)
                        $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
@@ -2479,9 +2519,15 @@ class ADMIN {
                                /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
                        </td>
                </tr><tr>
-                       <td><?php echo _EBLOG_PING?> <?php help('pinguserland'); ?></td>
-                       <td><?php $this->input_yesno('pinguserland',$blog->pingUserland(),85); ?></td>
+               <?php
+               if (numberOfEventSubscriber('SendPing') > 0) {
+               ?>
+                       <td><?php echo _EBLOG_PING?> <?php help('sendping'); ?></td>
+                       <td><?php $this->input_yesno('sendping',$blog->sendPing(),85); ?></td>
                </tr><tr>
+               <?php
+               }
+               ?>
                        <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
                        <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo  htmlspecialchars($blog->getMaxComments()); ?>" /></td>
                </tr><tr>
@@ -2942,7 +2988,7 @@ class ADMIN {
                $blog->setDefaultSkin(intPostVar('defskin'));
                $blog->setDescription(trim(postVar('desc')));
                $blog->setPublic(postVar('public'));
-               $blog->setPingUserland(postVar('pinguserland'));
+               $blog->setPingUserland(postVar('sendping'));
                $blog->setConvertBreaks(intPostVar('convertbreaks'));
                $blog->setAllowPastPosting(intPostVar('allowpastposting'));
                $blog->setDefaultCategory(intPostVar('defcat'));
@@ -3246,7 +3292,7 @@ class ADMIN {
                                'name' => &$bname,
                                'shortname' => &$bshortname,
                                'timeoffset' => &$btimeoffset,
-                               'description' => &$bdescription,
+                               'description' => &$bdesc,
                                'defaultskin' => &$bdefskin
                        )
                );
@@ -5999,7 +6045,9 @@ selector();
                sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
                sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
 
-               $this->action_pluginlist();
+               //$this->action_pluginlist();
+               // To avoid showing ticket in the URL, redirect to pluginlist, instead.
+               redirect('?action=pluginlist');
        }
 
        /**
@@ -6030,7 +6078,9 @@ selector();
                sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
                sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
 
-               $this->action_pluginlist();
+               //$this->action_pluginlist();
+               // To avoid showing ticket in the URL, redirect to pluginlist, instead.
+               redirect('?action=pluginlist');
        }
 
        /**
@@ -6222,4 +6272,4 @@ selector();
 
 } // class ADMIN
 
-?>
\ No newline at end of file
+?>