*/
class ACTION
{
-
/**
+ * ACTION::ACTION()
* Constructor for an new ACTION object
+ *
+ * @param void
+ * @return void
+ *
*/
function ACTION()
{
- // do nothing
+ return;
}
-
-
+
/**
+ * ACTION::doAction()
* Calls functions that handle an action called from action.php
+ *
+ * @param string $action action type
+ * @return mixed
*/
function doAction($action)
{
- switch($action)
+ switch ( $action )
{
case 'autodraft':
return $this->autoDraft();
break;
-
+
case 'updateticket':
return $this->updateTicket();
break;
-
+
case 'addcomment':
return $this->addComment();
break;
-
+
case 'sendmessage':
return $this->sendMessage();
break;
-
+
case 'createaccount':
return $this->createAccount();
break;
-
+
case 'forgotpassword':
return $this->forgotPassword();
break;
-
+
case 'votepositive':
return $this->doKarma('pos');
break;
-
+
case 'votenegative':
return $this->doKarma('neg');
break;
-
+
case 'plugin':
return $this->callPlugin();
break;
-
+
default:
doError(_ERROR_BADACTION);
break;
}
}
-
+
/**
* ACTION::addComment()
* Adds a new comment to an item (if IP isn't banned)
*
- * @param Void
- * @return Void
+ * @param void
+ * @return void
+ *
*/
function addComment()
{
global $CONF, $errormessage, $manager;
- $post['itemid'] = intPostVar('itemid');
+ $post['itemid'] = intPostVar('itemid');
$post['user'] = postVar('user');
- $post['userid'] = postVar('userid');
- $post['email'] = postVar('email');
+ $post['userid'] = postVar('userid');
+ $post['email'] = postVar('email');
$post['body'] = postVar('body');
$post['remember'] = intPostVar('remember');
// note: PreAddComment and PostAddComment gets called somewhere inside addComment
$errormessage = $comments->addComment($blog->getCorrectTime(), $post);
- if ( $errormessage == '1' )
+ if ( $errormessage != '1' )
+ {
+ // show error message using default skin for blo
+ return array(
+ 'message' => $errormessage,
+ 'skinid' => $blog->getDefaultSkin()
+ );
+ }
+ else
{
// redirect when adding comments succeeded
if ( postVar('url') )
redirect($url);
}
}
- // else, show error message using default skin for blo
- else
- {
- return array(
- 'message' => $errormessage,
- 'skinid' => $blog->getDefaultSkin()
- );
- }
exit;
}
* ACTION::sendMessage()
* Sends a message from the current member to the member given as argument
*
- * @param Void
- * @return Void
+ * @param void
+ * @return void
+ *
*/
function sendMessage()
{
$tomem = new MEMBER();
$tomem->readFromId(postVar('memberid') );
-
+
$message = _MMAIL_MSG . ' ' . $fromName . "\n"
. '(' . _MMAIL_FROMNUC. ' ' . $CONF['IndexURL'] .") \n\n"
. _MMAIL_MAIL . " \n\n"
$title = _MMAIL_TITLE . ' ' . $fromName;
NOTIFICATION::mail($tomem->getEmail(), $title, $message, $fromMail, i18n::get_current_charset());
- if ( postVar('url') )
- {
- redirect(postVar('url') );
- }
- else
+ if ( !postVar('url') )
{
$CONF['MemberURL'] = $CONF['IndexURL'];
{
$url = $CONF['IndexURL'] . LINK::create_member_link($tomem->getID());
}
-
redirect($url);
}
+ else
+ {
+ redirect(postVar('url') );
+ }
exit;
}
* Checks if a mail to a member is allowed
* Returns a string with the error message if the mail is disallowed
*
- * @param void
+ * @param void
* @return String Null character string
+ *
*/
function validateMessage()
{
return _ERROR_BADMAILADDRESS;
}
- // let plugins do verification (any plugin which thinks the comment is invalid
- // can change 'error' to something other than '')
+ /*
+ * let plugins do verification (any plugin which thinks the comment is
+ * invalid can change 'error' to something other than '')
+ */
$result = '';
$manager->notify('ValidateForm', array('type' => 'membermail', 'error' => &$result) );
*
* @param Void
* @return Mixed
+ *
*/
function createAccount()
{
}
/**
- * Sends a new password
+ * ACTION::forgotPassword()
+ * Sends a new password
+ *
+ * @param void
+ * @return void
+ *
*/
function forgotPassword()
{
$membername = trim(postVar('name') );
-
+
if ( !MEMBER::exists($membername) )
{
doError(_ERROR_NOSUCHMEMBER);
}
-
+
$mem = MEMBER::createFromName($membername);
- /* below keeps regular users from resetting passwords using forgot password feature
- Removing for now until clear why it is required.*/
- /*if (!$mem->canLogin())
- doError(_ERROR_NOLOGON_NOACTIVATE);*/
-
// check if e-mail address is correct
- if ( !($mem->getEmail() == postVar('email') ) )
+ if ( $mem->getEmail() != postVar('email') )
{
doError(_ERROR_INCORRECTEMAIL);
}
-
+
// send activation link
$mem->sendActivationLink('forgot');
-
- if ( postVar('url') )
+
+ if ( !postVar('url') )
{
- redirect(postVar('url') );
+ echo _MSG_ACTIVATION_SENT;
+ echo '<br /><br />Return to <a href="'.$CONF['IndexURL'].'" title="'.$CONF['SiteName'].'">'.$CONF['SiteName'].'</a>';
}
else
{
- echo _MSG_ACTIVATION_SENT;
- echo '<br /><br />Return to <a href="'.$CONF['IndexURL'].'" title="'.$CONF['SiteName'].'">'.$CONF['SiteName'].'</a>';
+ redirect(postVar('url') );
}
-
exit;
}
-
-
+
/**
* ACTION::doKarma()
* Handle karma votes
*
* @param String $type pos or neg
* @return Void
+ *
*/
function doKarma($type)
{
$refererUrl = serverVar('HTTP_REFERER');
- if ( $refererUrl )
+ if ( !$refererUrl )
{
- $url = $refererUrl;
+ $url = $itemLink;
}
else
{
- $url = $itemLink;
+ $url = $refererUrl;
}
redirect($url);
exit;
}
-
-
+
/**
- * Calls a plugin action
- */
+ * ACTION::callPlugin()
+ * Calls a plugin action
+ *
+ * @param void
+ * @return void
+ *
+ */
function callPlugin()
{
global $manager;
-
+
$pluginName = 'NP_' . requestVar('name');
$actionType = requestVar('type');
-
+
// 1: check if plugin is installed
if ( !$manager->pluginInstalled($pluginName) )
{
doError(_ERROR_NOSUCHPLUGIN);
}
-
+
// 2: call plugin
$pluginObject =& $manager->getPlugin($pluginName);
-
- if ( $pluginObject )
+
+ if ( !$pluginObject )
{
- $error = $pluginObject->doAction($actionType);
+ $error = 'Could not load plugin (see actionlog)';
}
else
{
- $error = 'Could not load plugin (see actionlog)';
+ $error = $pluginObject->doAction($actionType);
}
-
- // doAction returns error when:
- // - an error occurred (duh)
- // - no actions are allowed (doAction is not implemented)
+
+ /*
+ * doAction returns error when:
+ * - an error occurred (duh)
+ * - no actions are allowed (doAction is not implemented)
+ */
if ( $error )
{
doError($error);
}
-
exit;
-
}
-
-
+
/**
+ * ACTION::checkban()
* Checks if an IP or IP range is banned
+ *
+ * @param integer $blogid
+ * @return void
+ *
*/
function checkban($blogid)
{
// check if banned
$ban = BAN::isBanned($blogid, serverVar('REMOTE_ADDR') );
-
+
if ( $ban != 0 )
{
doError(_ERROR_BANNED1 . $ban->iprange . _ERROR_BANNED2 . $ban->message . _ERROR_BANNED3);
}
-
+ return;
}
-
-
+
/**
+ * ACTION::updateTicket()
* Gets a new ticket
+ *
+ * @param void
+ * @return boolean FALSE
+ *
*/
function updateTicket()
{
global $manager;
- if ( $manager->checkTicket() )
+ if ( !$manager->checkTicket() )
{
- echo $manager->getNewTicket();
+ echo _ERROR . ':' . _ERROR_BADTICKET;
}
else
{
- echo _ERROR . ':' . _ERROR_BADTICKET;
+ echo $manager->getNewTicket();
}
-
return FALSE;
}
-
-
+
/**
+ * ACTION::autoDraft()
* Handles AutoSaveDraft
+ *
+ * @param void
+ * @return boolean FALSE
+ *
*/
function autoDraft()
{
global $manager;
-
- if ( $manager->checkTicket() )
+
+ if ( !$manager->checkTicket() )
+ {
+ echo _ERROR . ':' . _ERROR_BADTICKET;
+ }
+ else
{
$manager->loadClass('ITEM');
$info = ITEM::createDraftFromRequest();
-
- if ( $info['status'] == 'error' )
+
+ if ( $info['status'] != 'error' )
{
- echo $info['message'];
+ echo $info['draftid'];
}
else
{
- echo $info['draftid'];
+ echo $info['message'];
}
}
- else
- {
- echo _ERROR . ':' . _ERROR_BADTICKET;
- }
-
return FALSE;
}
-
}