*
* @license http://nucleuscms.org/license.txt GNU General Public License
* @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: BLOG.php,v 1.12.2.1 2007-05-01 08:39:01 kimitake Exp $
- * $NucleusJP: BLOG.php,v 1.12 2007/04/13 16:51:49 shizuki Exp $
+ * @version $Id: BLOG.php,v 1.12.2.2 2007-08-08 05:26:22 kimitake Exp $
+ * $NucleusJP: BLOG.php,v 1.12.2.1 2007/05/01 08:39:01 kimitake Exp $
*/
if ( !function_exists('requestVar') ) exit;
/**
* Adds an item to this blog
*/
- function additem($catid, $title, $body, $more, $blogid, $authorid, $timestamp, $closed, $draft) {
+ function additem($catid, $title, $body, $more, $blogid, $authorid, $timestamp, $closed, $draft, $posted='1') {
global $manager;
$blogid = intval($blogid);
$more = addBreaks($more);
}
- if ($closed != '1') $closed = '0';
+ if ($closed != '1') $closed = '0';
if ($draft != '0') $draft = '1';
if (!$this->isValidCategory($catid))
$body = addslashes($body);
$more = addslashes($more);
- $query = 'INSERT INTO '.sql_table('item').' (ITITLE, IBODY, IMORE, IBLOG, IAUTHOR, ITIME, ICLOSED, IDRAFT, ICAT) '
- . "VALUES ('$title', '$body', '$more', $blogid, $authorid, '$timestamp', $closed, $draft, $catid)";
+ $query = 'INSERT INTO '.sql_table('item').' (ITITLE, IBODY, IMORE, IBLOG, IAUTHOR, ITIME, ICLOSED, IDRAFT, ICAT, IPOSTED) '
+ . "VALUES ('$title', '$body', '$more', $blogid, $authorid, '$timestamp', $closed, $draft, $catid, $posted)";
sql_query($query);
$itemid = mysql_insert_id();
. " btimeoffset=" . $offset . ","
. " bpublic=" . intval($this->isPublic()) . ","
. " breqemail=" . intval($this->emailRequired()) . ","
- . " bsendping=" . intval($this->pingUserland()) . ","
+ . " bsendping=" . intval($this->sendPing()) . ","
. " bconvertbreaks=" . intval($this->convertBreaks()) . ","
. " ballowpast=" . intval($this->allowPastPosting()) . ","
. " bnotify='" . addslashes($this->getNotifyAddress()) . "',"
}
- /**
- * Sends a XML-RPC ping message to Userland, so the weblog can
- * show up in the weblogs.com updates-list
- */
- function sendUserlandPing() {
- global $php_errormsg;
-
- if ($this->pingUserland()) {
- // testmessage for adding an item
- $message = new xmlrpcmsg('weblogUpdates.ping',array(
- new xmlrpcval($this->getName(),'string'),
- new xmlrpcval($this->getURL(),'string')
- ));
-
- $c = new xmlrpc_client('/RPC2', 'rpc.weblogs.com', 80);
-
- // $c->setDebug(1);
-
- $r = $c->send($message,15); // 15 seconds timeout...
-
- if (($r == 0) && ($r->errno || $r->errstring)) {
- return 'Error ' . $r->errno . ' : ' . $r->errstring;
- } elseif (($r == 0) && ($php_errormsg)) {
- return 'PHP Error: ' . $php_errormsg;
- } elseif ($r == 0) {
- return 'Error while trying to send ping. Sorry about that.';
- } elseif ($r->faultCode() != 0) {
- return 'Error: ' . $r->faultString();
- } else {
- $r = $r->value(); // get response struct
- // get values
- $flerror = $r->structmem('flerror');
- $flerror = $flerror->scalarval();
-
-
- $message = $r->structmem('message');
- $message = $message->scalarval();
-
- if ($flerror != 0)
- return 'Error (flerror=1): ' . $message;
- else
- return 'Success: ' . $message;
- }
- }
- }
-
function isValidCategory($catid) {
$query = 'SELECT * FROM '.sql_table('category').' WHERE cblog=' . $this->getID() . ' and catid=' . intval($catid);
- $res = mysql_query($query);
+ $res = sql_query($query);
return (mysql_num_rows($res) != 0);
}
function getCategoryName($catid) {
- $res = mysql_query('SELECT cname FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and catid=' . intval($catid));
+ $res = sql_query('SELECT cname FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and catid=' . intval($catid));
$o = mysql_fetch_object($res);
return $o->cname;
}
function getCategoryDesc($catid) {
- $res = mysql_query('SELECT cdesc FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and catid=' . intval($catid));
+ $res = sql_query('SELECT cdesc FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and catid=' . intval($catid));
$o = mysql_fetch_object($res);
return $o->cdesc;
}
function getCategoryIdFromName($name) {
- $res = mysql_query('SELECT catid FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and cname="' . addslashes($name) . '"');
+ $res = sql_query('SELECT catid FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and cname="' . addslashes($name) . '"');
if (mysql_num_rows($res) > 0) {
$o = mysql_fetch_object($res);
return $o->catid;
}
}
- function pingUserland() {
+ function sendPing() {
return $this->getSetting('bsendping');
}
return (mysql_num_rows($r) != 0);
}
+ // flag there is a future post pending
+ function setFuturePost() {
+ $query = 'UPDATE '.sql_table('blog')
+ . " SET bfuturepost='1' WHERE bnumber=" . $this->getID();
+ sql_query($query);
+ }
+
+ // clear there is a future post pending
+ function clearFuturePost() {
+ $query = 'UPDATE '.sql_table('blog')
+ . " SET bfuturepost='0' WHERE bnumber=" . $this->getID();
+ sql_query($query);
+ }
+
+ // check if we should throw justPosted event
+ function checkJustPosted() {
+ global $manager;
+
+ if ($this->settings['bfuturepost'] == 1) {
+ $blogid = $this->getID();
+ $result = sql_query("SELECT * FROM " . sql_table('item')
+ . " WHERE iposted=0 AND iblog=" . $blogid . " AND itime<NOW()");
+ if (mysql_num_rows($result) > 0) {
+ // This $pinged is allow a plugin to tell other hook to the event that a ping is sent already
+ // Note that the plugins's calling order is subject to thri order in the plugin list
+ $pinged = false;
+ $manager->notify(
+ 'JustPosted',
+ array('blogid' => $blogid,
+ 'pinged' => &$pinged
+ )
+ );
+
+ // clear all expired future posts
+ sql_query("UPDATE " . sql_table('item') . " SET iposted='1' WHERE iblog=" . $blogid . " AND itime<NOW()");
+
+ // check to see any pending future post, clear the flag is none
+ $result = sql_query("SELECT * FROM " . sql_table('item')
+ . " WHERE iposted=0 AND iblog=" . $blogid);
+ if (mysql_num_rows($result) == 0) {
+ $this->clearFuturePost();
+ }
+ }
+ }
+ }
}