当前位置: 首页>>代码示例>>PHP>>正文


PHP Vote::setUser方法代码示例

本文整理汇总了PHP中Vote::setUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Vote::setUser方法的具体用法?PHP Vote::setUser怎么用?PHP Vote::setUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vote的用法示例。


在下文中一共展示了Vote::setUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 function execute()
 {
     global $wgUser, $wgOut, $wgVoteDirectory, $wgCommentsDirectory, $IP;
     require_once "{$wgVoteDirectory}/VoteClass.php";
     require_once "{$wgVoteDirectory}/Publish.php";
     require_once "{$wgVoteDirectory}/RSS.php";
     require_once "{$wgCommentsDirectory}/CommentClass.php";
     if ($_POST["mk"] == md5($_POST["pid"] . 'pants' . $wgUser->mName)) {
         require_once "{$IP}/extensions/UserStats/UserStatsClass.php";
         $stats = new UserStatsTrack(1, $wgUser->mId, $wgUser->mName);
         if (($_GET["Action"] == 1 || $_GET["Action"] == 2) && is_numeric($_POST["pid"]) && (is_numeric($_POST["TheVote"]) || $_GET["Action"] == 2)) {
             //echo 'test2';
             $Vote = new Vote($_POST["pid"]);
             $Vote->setUser($wgUser->mName, $wgUser->mId);
             if ($_GET["Action"] == 1) {
                 $Vote->insert($_POST["TheVote"]);
                 $stats->incVoteCount();
             } else {
                 $Vote->delete();
             }
             $CommentList = new Comment($_POST["pid"]);
             $publish = new Publish();
             $publish->PageID = $_POST["pid"];
             $publish->VoteCount = $Vote->count(1);
             $publish->CommentCount = $CommentList->count();
             $publish->check_score();
             echo $Vote->count(1);
         }
         if ($_GET["Action"] == 3) {
             $Vote = new VoteStars($_POST["pid"]);
             $Vote->setUser($wgUser->mName, $wgUser->mId);
             $Vote->insert($_POST["TheVote"]);
             $stats->incVoteCount();
             echo $Vote->display();
         }
         if ($_GET["Action"] == 4) {
             $Vote = new VoteStars($_POST["pid"]);
             $Vote->setUser($wgUser->mName, $wgUser->mId);
             $Vote->delete();
             echo $Vote->display();
         }
     }
     // This line removes the navigation and everything else from the
     // page, if you don't set it, you get what looks like a regular wiki
     // page, with the body you defined above.
     $wgOut->setArticleBodyOnly(true);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:47,代码来源:VoteAction.php

示例2: RenderVote

function RenderVote($input)
{
    global $wgUser, $wgTitle, $wgOut;
    $wgOut->addScript("<script type=\"text/javascript\" src=\"extensions/Vote-Mag/Vote.js\"></script>\n");
    require_once 'VoteClass.php';
    getValue($type, $input, "type");
    switch ($type) {
        case 0:
            $Vote = new Vote($wgTitle->mArticleID);
            break;
        case 1:
            $Vote = new VoteStars($wgTitle->mArticleID);
            break;
        default:
            $Vote = new Vote($wgTitle->mArticleID);
    }
    $Vote->setUser($wgUser->mName, $wgUser->mId);
    $output = $Vote->display();
    return $output;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:20,代码来源:Vote.php

示例3: survey_submit

function survey_submit()
{
    // get global user object
    global $user;
    // protect from unauthorized access
    if (!isset($user) || !isset($_POST['formSurveySubmit'])) {
        logout();
        die;
    }
    // create empty array for $_POST container
    $post = array();
    // escape mysql injections array
    foreach ($_POST as $key => $value) {
        $post[$key] = stripslashes($value);
    }
    $post_keys = array_keys($_POST);
    $substring = 'Answer';
    $pattern = '/' . $substring . '/';
    $survey_keys = preg_grep($pattern, $post_keys);
    foreach ($survey_keys as $key) {
        // get question
        preg_match_all('!\\d+!', $key, $matches);
        $question_id = $matches[0][0];
        $question = new Question();
        $question->get_from_db($question_id);
        //get answer value
        $answer_value = $_POST[$key];
        //get answer id
        $answer_id = $answer_value;
        if (isset($matches[0][1])) {
            $answer_id = $matches[0][1];
        }
        // get current time
        $time_now = date("Y-m-d H:i:s");
        // create vote object
        $vote = new Vote();
        $vote->setIsActive(1);
        $vote->setCreatedOn($time_now);
        $vote->setLastEditedOn($time_now);
        $vote->setUser($user->getId());
        $vote->setSurvey($question->getSurvey());
        $vote->setQuestion($question_id);
        $vote->setAnswer($answer_id);
        $vote->setValue($answer_value);
        $vote->store_in_db();
    }
    // set message cookie
    $cookie_key = 'msg';
    $cookie_value = 'Благодарим Ви за отговорения въпрос!';
    setcookie($cookie_key, $cookie_value, time() + 1);
    header('location:' . ROOT_DIR . '?page=survey');
}
开发者ID:tttodorov13,项目名称:suSurvey,代码行数:52,代码来源:functions.php


注:本文中的Vote::setUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。