12
Well...
My first idea is making a PHP script to call the Submit code from the shell...
Quote:
include '/www/docs/os4os.org/mainfile.php';
include_once '/www/docs/os4os.org/modules/news/class/class.newsstory.php';
$module_handler =& xoops_gethandler('module');
$xoopsModule =& $module_handler->getByDirname('news');
$nohtml_db = 1;
echo "XoopsUser:".$xoopsUser."\n";
echo "xoopsModule:".$xoopsModule."\n";
var_dump($xoopsModule);
if ( $xoopsUser ) {
$uid = $xoopsUser->getVar('1');
if ( $xoopsUser->isAdmin($xoopsModule->mid()) ) {
$nohtml_db = empty($nohtml) ? 0 : 1;
}
} else {
echo "xoopsModuleConfig:".$xoopsModuleConfig['anonpost'];
if ( $xoopsModuleConfig['anonpost'] == 1 ) {
$uid = 0;
} else {
redirect_header("index.php",3,_NOPERM);
exit();
}
}
echo "Antes de NEWSSTORY";
$story = new NewsStory();
$story->setTitle("Probando");
$story->setHometext("Mensaje");
$story->setUid(1);
$story->setTopicId(1);
$story->setHostname(xoops_getenv('REMOTE_ADDR'));
$story->setNohtml($nohtml_db);
$nosmiley = isset($nosmiley) ? intval($nosmiley) : 0;
$notifypub = isset($notifypub) ? intval($notifypub) : 0;
$story->setNosmiley($nosmiley);
$story->setNotifyPub($notifypub);
$story->setType('user');
if ( $xoopsModuleConfig['autoapprove'] == 1 ) {
$approve = 1;
$story->setApproved($approve);
$story->setPublished(time());
$story->setExpired(0);
$story->setTopicalign('R');
}
$result = $story->store();
Now, I'm trying to modify this code to be executable from command line... I have to put some vars before including mainfile such as an unreal URL. xoopsModuleConfig doesn't work at the moment.
I have to improve the users managemente :)... just parametrizing it... but at the moment I only want to test if I am able to post a NEWS from shell... The rest is easy...
A filter in the mbox of the
xoops@localhost.org user, that parse a text ( simple commands and so ) and then, call the php with their parameters: FROM_USER, NEWS, TOPIC, and so...
BR.