Exemple #1
0
function fetchPerm($userinfo, $postinfo, $threadinfo, $force = false)
{
    global $vbulletin, $vbphrase;
    $canAward = $canThank = true;
    if ($userinfo['userid'] == $postinfo['userid'] or !$vbulletin->kbank['award']['enabled']) {
        return false;
    }
    $records = fetchAwarded($postinfo['postid'], true, $force);
    if (isset($records[$userinfo['userid']]) and !$vbulletin->kbank['award']['thank_multiple']) {
        //thank found and multiple thank is NOT allowed
        $canThank = false;
    }
    if (!can_moderate($threadinfo['forumid']) or $postinfo['visible'] != 1) {
        $canAward = false;
    } else {
        if (isset($records[0]) and $records[0]['points'] != 0) {
            $canAward = false;
        }
    }
    if (!$vbulletin->kbank['award']['award_enabled']) {
        $canAward = false;
    }
    if (!$vbulletin->kbank['award']['thank_enabled']) {
        $canThank = false;
    }
    return array('award' => $canAward, 'thank' => $canThank, 'text' => iif($canAward, 'award', '') . iif($canThank, 'thank', ''), 'phrase' => $vbphrase['kbank_award_button_' . iif($canAward, 'award', '') . iif($canThank, 'thank', '')]);
}
Exemple #2
0
 function parse_bbcode_thanks($message, $thanks_required)
 {
     global $vbphrase, $stylevar;
     //prepair variables
     include_once DIR . '/kbank/award_functions.php';
     //include kBank Award functions
     $thanks = fetchAwarded($this->vars['postid'], true, false, $this->registry->userinfo['userid']);
     if ($this->registry->kbank['hide']['thanksMax'] != 0) {
         //there is a limit for maximum required thank amount
         $thanks_required = min($thanks_required, $this->registry->kbank['hide']['thanksMax']);
     }
     //fix " issue
     $message = str_replace('\\"', '"', $message);
     //check permission
     $canview = false;
     if (!$this->settings['banned']) {
         if ($this->can_override()) {
             $canview = true;
         } else {
             if ($this->registry->userinfo['userid'] and is_numeric($thanks[$this->registry->userinfo['userid']]['points']) and $thanks[$this->registry->userinfo['userid']]['points'] >= $thanks_required) {
                 $canview = true;
             }
         }
     }
     //build info message
     if ($thanks_required) {
         $info_message = construct_phrase($vbphrase['kbank_hide_thanks_required_with_amount'], $thanks_required, $this->registry->kbank['name']);
     } else {
         $info_message = construct_phrase($vbphrase['kbank_hide_thanks_required']);
     }
     //prepair output
     if ($this->settings['dohtml']) {
         eval('$message = "' . fetch_template('kbank_hide_replacement_thanks') . '";');
     } else {
         $message = $canview ? $message : construct_phrase($vbphrase['kbank_hide_message_nohtml'], $info_message);
     }
     //Everything done! Return result
     return $message;
 }
Exemple #3
0
             }
         } else {
             //invalid confirmation
             outputError($vbphrase['kbank_award_err_confirm']);
         }
     } else {
         //no permission
         //outputError($vbphrase['kbank_award_mes_noperm']);
         print_no_permission();
     }
 }
 if ($_REQUEST['do'] == 'hide') {
     //hide thank
     $vbulletin->input->clean_array_gpc('r', array('id' => TYPE_UINT));
     $userid = $vbulletin->GPC['id'];
     $records = fetchAwarded($postinfo['postid'], true, false, $userid);
     if (!($userid > 0)) {
         //outputError($vbphrase['kbank_award_mes_noperm']);
         print_no_permission();
     }
     if ($records[$userid]['points'] != 0 and $vbulletin->userinfo['canRemoveAwarded']) {
         //permission is ok
         //trying to hide thank
         $vbulletin->db->query("\n\t\t\t\tUPDATE `" . TABLE_PREFIX . $vbulletin->kbank['donations'] . "`\n\t\t\t\tSET \n\t\t\t\t\t#time = " . TIMENOW . "\n\t\t\t\t\tpostid = 0\n\t\t\t\tWHERE postid = {$postinfo['postid']} AND `from` = {$userid}\n\t\t\t");
         $affected_rows = $vbulletin->db->affected_rows();
         if ($affected_rows > 0) {
             //hide complete
             $vbulletin->db->query("\n\t\t\t\t\tUPDATE `" . TABLE_PREFIX . "user`\n\t\t\t\t\tSET \n\t\t\t\t\t\t{$vbulletin->kbank['award']['thanksenttimes']} = {$vbulletin->kbank['award']['thanksenttimes']} - {$affected_rows}\n\t\t\t\t\t\t, {$vbulletin->kbank['award']['thanksentamount']} = {$vbulletin->kbank['award']['thanksentamount']} - {$records[$userid]['points']}\n\t\t\t\t\tWHERE userid = {$userid}\n\t\t\t\t");
             $vbulletin->db->query("\n\t\t\t\t\tUPDATE `" . TABLE_PREFIX . "user`\n\t\t\t\t\tSET \n\t\t\t\t\t\t{$vbulletin->kbank['award']['thankreceivedtimes']} = {$vbulletin->kbank['award']['thankreceivedtimes']} - {$affected_rows}\n\t\t\t\t\t\t, {$vbulletin->kbank['award']['thankreceivedamount']} = {$vbulletin->kbank['award']['thankreceivedamount']} - {$records[$userid]['points']}\n\t\t\t\t\tWHERE userid = {$postinfo['userid']}\n\t\t\t\t");
             $messages[] = $vbphrase['kbank_award_hide_Done'];
             output($postinfo['postid'], implode('</br>', $messages));