Esempio n. 1
0
function Login($username, $password, $forward)
{
    APP_User::get()->login($username, $password);
    if (APP_User::loggedIn()) {
        if (!empty($forward)) {
            header("Location: {$forward}");
        }
    }
}
Esempio n. 2
0
 /**
  * Callback function for InviteAFriend page
  *
  * @param Object $args
  * @param Object $action 
  * @param Object $mem_redirect memory for the page after redirect
  * @param Object $mem_resend memory for resending the form
  * @return string relative request for redirect
  */
 public function InviteCallback($args, $action, $mem_redirect, $mem_resend)
 {
     $count = $action->count;
     $redirect_req = $action->redirect_req;
     $mem_redirect->post = $args->post;
     if (!APP_User::loggedIn()) {
         // not logged in.
         // the login form will be shown after the automatic redirect
         // after successful login, the message is recovered.
     } else {
         if ($count < 0) {
             // session has expired while user was typing.
             $mem_redirect->expired = true;
         } else {
             if ($mem_resend->already_sent_as) {
                 // form has already been processed, with the message sent!
                 // for a new message, the user needs a new form.
                 // tell the redirected page which message has been already sent!
                 $mem_redirect->already_sent_as = $mem_resend->already_sent_as;
             } else {
                 if ($count > 0) {
                     // form has been already processed $count times,
                     // but the last time it was not successful.
                     // so, we can send again
                     // but tell the page how many times it had failed before
                     $mem_redirect->fail_count = $count;
                 } else {
                     // first time to try sending the form
                 }
                 // now finally try to send it.
                 $result = new ReadOnlyObject($this->model->sendOrComplain($args->post));
                 if (count($result->problems) > 0) {
                     $mem_redirect->problems = $result->problems;
                 } elseif (!$result->status) {
                     $mem_redirect->problems = array('email', 'Unknown error - Invitation not sent.');
                 } else {
                     // sending message was successful
                     $mem_resend->already_sent_as = $result->message_id;
                     return "invite/sent";
                 }
             }
         }
     }
     return implode('/', $args->request);
 }
Esempio n. 3
0
 /**
  * callback for deleting/updating messages
  *
  * @param object $args
  * @param object $action
  * @param object $mem_redirect
  * @param object $mem_resend
  * @access public
  * @return string
  */
 public function mailBoxCallback($args, $action, $mem_redirect, $mem_resend)
 {
     $BW_Rights = new MOD_right();
     $layoutkit = $count = $action->count;
     $return = $args->req;
     if (!APP_User::loggedIn()) {
         return $return;
     }
     if ($count < 0) {
         $mem_redirect->expired = true;
         return $return;
     }
     if ($mem_resend->already_sent_as) {
         $mem_redirect->already_sent_as = $mem_resend->already_sent_as;
         return $return;
     }
     // now finally try to send it.
     $words = new MOD_words();
     $model = new MessagesModel();
     $post = $args->post;
     if (isset($post['message-mark']) && count($post['message-mark']) > 0 && isset($post['submit_multi'])) {
         foreach ($post['message-mark'] as $message) {
             if (!($m = $model->getMessage($message))) {
                 $mem_redirect->problems = true;
                 return $return;
             } elseif ($post['submit_multi'] == 'delete') {
                 $result = $model->deleteMessage($m->id);
             } elseif ($post['submit_multi'] == 'markasread') {
                 $result = $model->markMessage($m->id);
             } elseif ($post['submit_multi'] == 'markasspam') {
                 $result = $model->moveMessage($m->id, 'Spam');
                 $model->updateSpamInfo($m->id, 'SpamSayMember', 'NotSpam', $m->SpamInfo);
             } elseif ($post['submit_multi'] == 'nospam') {
                 $result = $model->moveMessage($m->id, 'Normal');
                 $model->updateSpamInfo($m->id, 'NotSpam', array('SpamSayMember', 'SpamSayChecker'), $m->SpamInfo);
             } else {
                 $mem_redirect->problems = true;
                 return $return;
             }
         }
     } else {
         $result = false;
     }
     $mem_redirect->result = $result;
     return $return;
 }
Esempio n. 4
0
// instantiate user model
$User = new User();
// get current request
$request = PRequest::get()->request;
$loginText = array();
$i18n = new MOD_i18n('apps/user/login.php');
$loginText = $i18n->getText('loginText');
$words = new MOD_words();
if (!isset($redirect_url)) {
    $redirect_url = 'main';
}
/*
 * LOGIN FORM
 */
if (!APP_User::loggedIn()) {
    // retrieve the callback ID
    $callbackId = $User->loginProcess();
    // get the saved post vars
    $vars =& PPostHandler::getVars($callbackId);
    if (isset($vars['errors']) && is_array($vars['errors']) && in_array('not_logged_in', $vars['errors'])) {
        ?>
 <p class="error"><?php 
        echo $loginText['not_logged_in'];
        ?>
</p>
<?php 
    }
    ?>

<div class="info">
Esempio n. 5
0
 /**
  * callback for deleting/updating notes
  *
  * @param object $args
  * @param object $action
  * @param object $mem_redirect
  * @param object $mem_resend
  * @access public
  * @return string
  */
 public function NotifyAdminCallback($args, $action, $mem_redirect, $mem_resend)
 {
     $BW_Rights = new MOD_right();
     $layoutkit = $count = $action->count;
     $return = $args->req;
     if (!APP_User::loggedIn()) {
         return $return;
     }
     if ($count < 0) {
         $mem_redirect->expired = true;
         return $return;
     }
     if ($mem_resend->already_sent_as) {
         $mem_redirect->already_sent_as = $mem_resend->already_sent_as;
         return $return;
     }
     $post = $args->post;
     if (isset($post['action']) && $post['action'] == 'create' && !empty($post['IdMember']) || !empty($post['IdRelMember']) || !empty($post['Type']) || !empty($post['WordCode'])) {
         $result = $this->_model->createNote($post);
     } elseif (isset($post['action']) && $post['action'] == 'delete' && count($post['note-mark']) > 0) {
         $result = $this->_model->deleteNotes($post['note-mark']);
     } else {
         $mem_redirect->problems = true;
         return $return;
     }
     $mem_redirect->result = $result;
     return $return;
 }
Esempio n. 6
0
 /**
  * callback for changing group settings
  *
  * @param object $args         contains vars
  * @param object $action       contains something else
  * @param object $mem_redirect memory for the page after redirect
  * @param object $mem_resend   memory for resending the form
  *
  * @access public
  * @return string
  */
 public function changeGroupSettings($args, $action, $mem_redirect, $mem_resend)
 {
     $count = $action->count;
     $return = $args->req;
     if (!APP_User::loggedIn()) {
         return $return;
     }
     if ($count < 0) {
         $mem_redirect->expired = true;
         return $return;
     }
     if ($mem_resend->already_sent_as) {
         $mem_redirect->already_sent_as = $mem_resend->already_sent_as;
         return $return;
     }
     $post = $args->post;
     if (empty($post['GroupDesc_']) || empty($post['Type']) || empty($post['group_id']) || empty($post['VisiblePosts']) || empty($post['VisibleComments']) || !($group = $this->_model->findGroup($post['group_id'])) || !$this->_model->canAccessGroupAdmin($group)) {
         $mem_redirect->problems = array('General' => true);
         return $return;
     }
     $result = $this->_model->updateGroupSettings($group, $post['GroupDesc_'], $post['Type'], $post['VisiblePosts'], $post['VisibleComments']);
     if ($result === true || !is_array($result)) {
         $this->logWrite("Member #{$this->_model->getLoggedInMember()->getPKValue()} changed group settings for group #{$post['group_id']}");
         $mem_redirect->result = true;
     } else {
         $mem_redirect->problems = $result;
         $mem_redirect->result = false;
     }
     $mem_redirect->post = $post;
     return $return;
 }