Exemplo n.º 1
0
 public static function checkVote($relatedModule, $relatedId, $uid = 0)
 {
     $result = false;
     $uid = empty($uid) ? Ibos::app()->user->uid : $uid;
     $condition = "relatedmodule=:relatedmodule AND relatedid=:relatedid";
     $params = array(":relatedmodule" => $relatedModule, ":relatedid" => $relatedId);
     $vote = Vote::model()->fetch($condition, $params);
     if (!empty($vote)) {
         $voteid = $vote["voteid"];
         $voteItemList = VoteItem::model()->fetchAll("voteid=:voteid", array(":voteid" => $voteid));
         foreach ($voteItemList as $voteItem) {
             $itemid = $voteItem["itemid"];
             $itemCountList = VoteItemCount::model()->fetchAll("itemid=:itemid", array(":itemid" => $itemid));
             if (!empty($itemCountList) && 0 < count($itemCountList)) {
                 foreach ($itemCountList as $itemCount) {
                     if ($itemCount["uid"] == $uid) {
                         $result = true;
                         break;
                     }
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Vote::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('VoteModule.vote', 'Запрошенная страница не найдена!'));
     }
     return $model;
 }
Exemplo n.º 3
0
 /**
  * 关注或取消赞成
  * @param unknown_type $id
  */
 public function run($id, $value)
 {
     $model = $this->controller->loadModel($id, $value);
     $model->toggleVote(Yii::app()->user->id, $value);
     $vote = Vote::model()->findByAttributes(array('voteableEntityId' => $model->entityId, 'userId' => Yii::app()->user->id));
     if (isset($vote) && $vote) {
         if ($vote->userId != $model->userId) {
             $result = Notice::send($model->userId, $model->entity->type . "_vote_added", array('voteId' => $vote->id));
         }
     }
     //feed
     //	Feed::send("vote_added", array('voteid'=>$vote->id));
     $this->controller->renderPartial('//vote/result', array('score' => $model->voteUpNum, 'voteUpers' => $model->getVoteUperDataProvider()->getData()));
 }
Exemplo n.º 4
0
 /**
  * 助力数据
  * GET api/activity/dream/{dreamId}/vote 
  */
 public function actionRestlist()
 {
     $this->checkRestAuth();
     $dream = Dream::model()->findByPk($_GET['dreamId']);
     if ($dream == null || $dream->nickname == null) {
         $this->sendResponse(404, 'not found');
     }
     $criteria = new CDbCriteria();
     $take = 100;
     $criteria->compare('dream_id', $dream->id);
     $criteria->limit = $take;
     $criteria->offset = 0;
     $criteria->order = 'created_time DESC';
     $result = Vote::model()->findAll($criteria);
     $json = new JsonData();
     $json->limit = $take;
     $json->total = (int) Vote::model()->count($criteria);
     $json->result = $this->JSONArrayMapper($result);
     echo CJSON::encode($json);
 }
 /**
  * 编译投票添加类型通知
  */
 public function compileVoteAdded()
 {
     $owner = $this->getOwner();
     $data = $owner->getData();
     error_log(print_r($data, true));
     try {
         $voteId = isset($data['voteId']) ? $data['voteId'] : $data['voteid'];
         $vote = Vote::model()->findByPk($voteId);
         if ($vote) {
             $entity = $vote->voteableEntity;
         } else {
             throw new Exception();
         }
         $model = $entity->getModel();
         $viewFile = "_" . $entity->type . "_vote_added";
         $viewData = array('vote' => $vote, $entity->type => $model);
     } catch (Exception $e) {
         return false;
     }
     return array('viewFile' => $viewFile, 'viewData' => $viewData);
 }
Exemplo n.º 6
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Vote::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 7
0
 public static function getView($view)
 {
     $currentController = Yii::app()->getController();
     $basePath = "application.modules.vote.views.default.";
     $relatedModule = Ibos::getCurrentModuleName();
     $relatedId = EnvUtil::getRequest($relatedModule . "id");
     if ($view == "articleView") {
         $voteData = Vote::model()->fetchVote($relatedModule, $relatedId);
         $votes = VoteUtil::processVoteData($voteData);
         if (!empty($votes)) {
             $voteItemList = $votes["voteItemList"];
             $voteType = $voteItemList[0]["type"];
             if ($voteType == 1) {
                 $view = "articleTextView";
             } elseif ($voteType == 2) {
                 $view = "articleImageView";
             }
             $selectView = $basePath . $view;
             $votePeopleNumber = Vote::model()->fetchUserVoteCount($relatedModule, $relatedId);
             $userHasVote = VoteUtil::checkVote($relatedModule, $relatedId);
             $mothedName = "get" . ucfirst($relatedModule) . "Vote";
             $voteStatus = ICVotePlugManager::$mothedName()->getStatus($relatedModule, $relatedId, $votes["vote"]);
             $votes["vote"]["subject"] = StringUtil::cutStr($votes["vote"]["subject"], 60);
             $data = array("voteData" => $votes, "votePeopleNumber" => $votePeopleNumber, "userHasVote" => $userHasVote, "voteStatus" => $voteStatus, "attachUrl" => Yii::app()->setting->get("setting/attachurl"));
             if ($voteStatus == 2) {
                 $partView = null;
             } else {
                 $partView = $currentController->renderPartial($selectView, $data, true);
             }
         } else {
             $partView = null;
         }
     } elseif ($view == "articleAdd") {
         $selectView = $basePath . $view;
         $partView = $currentController->renderPartial($selectView, array("uploadConfig" => AttachUtil::getUploadConfig()), true);
     } elseif ($view == "articleEdit") {
         $selectView = $basePath . $view;
         $voteData = Vote::model()->fetchVote($relatedModule, $relatedId);
         if (!empty($voteData) && isset($voteData["voteItemList"])) {
             foreach ($voteData["voteItemList"] as $k => $voteItem) {
                 $voteData["voteItemList"][$k]["thumburl"] = FileUtil::fileName($voteItem["picpath"]);
             }
         }
         $data = array("voteData" => $voteData, "uploadConfig" => AttachUtil::getUploadConfig());
         $partView = $currentController->renderPartial($selectView, $data, true);
     }
     return $partView;
 }
Exemplo n.º 8
0
 public static function getTotalByTypeId($id, $type = "article", $userId = '')
 {
     $createUser = $userId == "" ? Yii::app()->user->id : $userId;
     $criteria = new CDbCriteria();
     $count = 0;
     if ($type == "article" || $type == "question") {
         $criteria->addSearchCondition('topic_ids', ',' . trim($id) . ",");
     }
     if ($type != "disagree") {
         $criteria->addCondition("create_user = :create_user");
         $criteria->params[':create_user'] = $createUser;
     }
     if ($type == "article") {
         $criteria->addCondition("publish = 1");
         $count = Article::model()->count($criteria);
     } else {
         if ($type == "question") {
             $count = Question::model()->count($criteria);
         } else {
             if ($type == "disagree") {
                 $criteria->addCondition("to_user = :to_user and opinion=0");
                 $criteria->params[':to_user'] = $createUser;
                 $voteModel = Vote::model()->findAll($criteria);
                 foreach ($voteModel as $key => $value) {
                     $topic_ids = "";
                     if ($value->model == "article") {
                         $topic_ids = Article::model()->findByPk($value->pk_id)->topic_ids;
                     } else {
                         if ($value->model == "question") {
                             $topic_ids = Question::model()->findByPk($value->pk_id)->topic_ids;
                         } else {
                             if ($value->model == "answer") {
                                 $answerModel = Answer::model()->findByPk($value->pk_id);
                                 if ($userId != "" && $answerModel->is_anonymous == 0) {
                                     $topic_ids = $answerModel->topic_ids;
                                 } else {
                                     $topic_ids = ",0,";
                                 }
                             }
                         }
                     }
                     if (in_array($id, explode(",", trim($topic_ids, ",")))) {
                         $count++;
                     }
                 }
             } else {
                 if ($type == "answer") {
                     if ($userId != "") {
                         $criteria->addCondition("is_anonymous = 0");
                     }
                     $answerModel = Answer::model()->findAll($criteria);
                     foreach ($answerModel as $key => $value) {
                         $questionModel = Question::model()->findByPk($value->question_id);
                         if (in_array($id, explode(",", trim($questionModel->topic_ids, ",")))) {
                             $count++;
                         }
                     }
                 }
             }
         }
     }
     return $count;
 }
Exemplo n.º 9
0
 public function actionvote()
 {
     $imageId = $_REQUEST['imageId'];
     if (isset($imageId)) {
         $n = Vote::model()->countBySql("SELECT COUNT(*) FROM votes WHERE fbid='" . $_SESSION["fbid"] . "' AND imageId=" . $imageId);
         if (isset($n) && $n < 1) {
             //you can vote
             //only when you have not voted yet
             $vote = new Vote();
             $vote->created = new CDbExpression('NOW()');
             $vote->imageId = $_POST['imageId'];
             $vote->fbid = $_SESSION["fbid"];
             $vote->save();
         }
         $n = Vote::model()->countBySql("SELECT COUNT(*) FROM votes WHERE imageId=" . $imageId);
         $image = FImage::model()->findByPk($imageId);
         if (isset($image)) {
             //update count of votes on image
             $image->votes = $n;
             $image->save();
         }
         echo $n;
         // . "&nbsp;hlasů&nbsp;&nbsp;&nbsp;<span>Už jsi hlasoval/a</span>";
         Yii::app()->end();
     }
 }
Exemplo n.º 10
0
<?php

$articleComments = Comment::model()->fetchAllByAttributes(array("module" => "article"));
$cidArr = ConvertUtil::getSubByKey($articleComments, "cid");
if (!empty($articleComments)) {
    $cidStr = implode(",", $cidArr);
    Comment::model()->deleteAll("rowid IN({$cidStr})");
    Comment::model()->deleteAllByAttributes(array("module" => "article"));
}
$isInstallVote = ModuleUtil::getIsEnabled("vote");
if ($isInstallVote) {
    $articleVotes = Vote::model()->fetchAllByAttributes(array("relatedmodule" => "article"));
    $voteidArr = ConvertUtil::getSubByKey($articleVotes, "voteid");
    $voteidStr = implode(",", $voteidArr);
    $articleVoteItems = VoteItem::model()->fetchAll("FIND_IN_SET(voteid, '{$voteidStr}')");
    $itemidArr = ConvertUtil::getSubByKey($articleVoteItems, "itemid");
    $itemidStr = implode(",", $itemidArr);
    VoteItemCount::model()->deleteAll("FIND_IN_SET(itemid, '{$itemidStr}')");
    VoteItem::model()->deleteAll("FIND_IN_SET(itemid, '{$itemidStr}')");
    Vote::model()->deleteAllByAttributes(array("relatedmodule" => "article"));
}
Exemplo n.º 11
0
    echo $data->create_user == Yii::app()->user->id ? '<a name="Notanonymous" href="javascript:;" data-answerid="' . $data->id . '"><i class="icon-pushpin"></i>取消匿名</a>' : '';
} else {
    ?>
<a class="user-label" href="javascript:;" data-id="<?php 
    echo $data->create_user;
    ?>
"><img style="height: 24px;width: 24px;vertical-align:top;border-radius: 2px;" height="24" width="24" src="<?php 
    echo $this->createUrl("getimage", array("id" => $data->create_user, "type" => "avatar"));
    ?>
"></a><?php 
}
?>
</span></p>
                    <div class="vote-info">
                        <?php 
$voteOpinion = Vote::model()->findAll("pk_id = :pk_id and model=:model and opinion=0 order by create_time desc", array(":pk_id" => $data->id, ":model" => "answer"));
?>
                        <?php 
if (count($voteOpinion) > 0) {
    ?>
                            <span class="voters vote-some">
                                <?php 
    $i = 0;
    foreach ($voteOpinion as $key => $value) {
        $i++;
        if ($i == 4) {
            break;
        }
        echo $i == 3 && count($voteOpinion) >= 3 || $i == 2 && count($voteOpinion) == 2 || $i == 1 && count($voteOpinion) == 1 ? "<a class='user-label' href='javascropt:;' data-id='" . $value->create_user . "' data-value='" . $value->create_user . "'>" . User::getNameById($value->create_user) . "</a>" : "<a data-value='" . $value->create_user . "' class='user-label' href='javascropt:;' data-id='" . $value->create_user . "' data-value='" . $value->create_user . "'>" . User::getNameById($value->create_user) . "</a>" . "<span>、</span>";
    }
    ?>
Exemplo n.º 12
0
<?php

if ($type != "hot") {
    $this->widget('bootstrap.widgets.TbGroupGridView', array('id' => $type . '-question-grid', 'dataProvider' => Question::model()->search($type), 'extraRowColumns' => array('create_time'), 'template' => '{items}{pager}', 'ajaxUpdate' => true, 'emptyText' => '<div class="alert alert-info">暂无问题</div>', 'hideHeader' => true, 'extraRowExpression' => 'User::dateToText($data->update_time,"long")', 'columns' => array(array('name' => 'create_time', 'value' => 'User::dateToText($data->update_time,"short")', 'headerHtmlOptions' => array('style' => 'display:none;'), 'htmlOptions' => array('style' => 'display:none;')), array('name' => 'title', 'value' => array($this, 'renderDiv'), 'type' => 'raw', 'headerHtmlOptions' => array('style' => 'width: 100%'), 'htmlOptions' => array('class' => 'ellipsis list-product')))));
} else {
    $this->widget('bootstrap.widgets.TbGroupGridView', array('id' => 'question-grid', 'dataProvider' => Vote::model()->search(), 'template' => '{items}{pager}', 'emptyText' => '<div class="alert alert-info">暂无问题</div>', 'ajaxUpdate' => true, 'hideHeader' => true, 'columns' => array(array('name' => 'title', 'value' => array($this, 'renderVoteDiv'), 'type' => 'raw', 'headerHtmlOptions' => array('style' => 'width: 100%'), 'htmlOptions' => array('class' => 'ellipsis list-product')))));
}
Exemplo n.º 13
0
 /**
  * 修改被点赞的人员
  */
 public function afterSave()
 {
     parent::afterSave();
     $to_user = "";
     if ($this->model == "answer") {
         $to_user = Answer::model()->findByPk($this->pk_id)->create_user;
     } else {
         if ($this->model == "article") {
             $to_user = Article::model()->findByPk($this->pk_id)->create_user;
         } else {
             if ($this->model == "question") {
                 $to_user = Question::model()->findByPk($this->pk_id)->create_user;
             }
         }
     }
     if ($to_user != "") {
         Vote::model()->updateByPk($this->id, array("to_user" => $to_user));
     }
 }
Exemplo n.º 14
0
 /**
  * 获取反对票数量
  */
 public function getVoteDownCount()
 {
     $result = Vote::model()->count("voteableEntityId=:entityId and value<=0", array(':entityId' => $this->getOwner()->entityId));
     return intval($result);
 }
Exemplo n.º 15
0
 public function run()
 {
     $vote = Vote::model()->find('model = :model AND model_id = :model_id AND user_id = :user_id', array('model' => $this->model, 'model_id' => $this->model_id, 'user_id' => $this->user_id));
     $this->render('votewidget', array('model' => $vote));
 }
Exemplo n.º 16
0
 /**
  * 更新user表 
  */
 public function afterDelete()
 {
     parent::afterDelete();
     $createUser = Yii::app()->user->id;
     $time = strtotime(date("Y-m-d", time()));
     $count = self::model()->count("create_user = "******" and update_time > " . $time);
     if ($count == 0 && $this->update_time > $time && $this->publish == 1) {
         $userModal = User::model()->findByPk($createUser);
         $score = Sys::model()->getvaluesByType("artice_score");
         $wealthModel = new Wealth();
         if (Sys::model()->getvaluesByType("artice_type") == "0") {
             $userModal->wealth = $userModal->wealth - intval($score);
             $content = "删除文章成功,花费" . $score . "个财富值";
             $data = array('content' => $content, 'create_time' => time());
             $wealthModel->insertWealth($data);
         }
         $userModal->save();
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("pk_id=" . $this->id);
     $criteria->addCondition("model='article'");
     $commentModel = Comment::model()->findAll($criteria);
     foreach ($commentModel as $value) {
         Comment::model()->findByPk($value->id)->delete();
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("pk_id=" . $this->id);
     $criteria->addCondition("model='article'");
     Vote::model()->deleteAll($criteria);
     $notificationCriteria = new CDbCriteria();
     $notificationCriteria->addCondition("pk_id=" . $this->id);
     $notificationCriteria->addCondition("notification_type='createarticle'");
     $notifyModel = NotificationContent::model()->find($notificationCriteria);
     if ($notifyModel != null) {
         NotificationContent::model()->findByPk($notifyModel->id)->delete();
     }
 }
Exemplo n.º 17
0
 private function getVoteCount()
 {
     if ($this->getVoteInstalled()) {
         $relatedId = EnvUtil::getRequest("relatedid");
         $count = Vote::model()->fetchUserVoteCount("article", $relatedId);
         echo $count;
         exit;
     }
 }
Exemplo n.º 18
0
 回答</span></span><span class="pull-right"><a class="user-label" href="javascript:;" data-id="<?php 
echo $data->create_user;
?>
"><img style="height: 24px;width: 24px;vertical-align:top;border-radius: 2px;" height="24" width="24" src="<?php 
echo $this->createUrl("getimage", array("id" => $data->create_user, "type" => "avatar"));
?>
"></a></span></p>
            <p><?php 
echo strlen(strip_tags($data->content)) > 300 ? mb_strcut(strip_tags($data->content), 0, 300, 'utf-8') . "..." : $data->content;
?>
</p>
            <?php 
$commentCount = Comment::model()->count("pk_id=:pk_id and model=:model and parent_id=0", array(":model" => "answer", ":pk_id" => $data->id));
?>
            <?php 
$voteCount = Vote::model()->count("pk_id=:pk_id and opinion=0 and model='answer'", array(":pk_id" => $data->id));
?>
            <div class="clearfix" style="font-size: 12px;padding-top: 5px;color:#ccc;"><a title="<?php 
echo $voteCount . "个赞同";
?>
" href="<?php 
echo $this->createUrl("answer", array("id" => $data->id));
?>
" style="margin-right: 10px;"><i class="icon-thumbs-up" style="margin-right: 4px;"></i><?php 
echo $voteCount;
?>
 赞同</a> <a href="<?php 
echo $this->createUrl("answer", array("id" => $data->id));
?>
" title="<?php 
echo $commentCount;
Exemplo n.º 19
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Vote::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Exemplo n.º 20
0
 function actionDisagreevote()
 {
     $pk_id = $_POST['pk_id'];
     $modelName = isset($_POST['model']) ? $_POST['model'] : "answer";
     $return = array();
     $count = Vote::model()->count("create_user=:create_user and model=:model and pk_id=:pk_id", array(":pk_id" => $pk_id, ":create_user" => Yii::app()->user->id, ":model" => $modelName));
     if ($count > 0) {
         $Vote = Vote::model()->find("create_user=:create_user and model=:model and pk_id=:pk_id", array(":pk_id" => $pk_id, ":create_user" => Yii::app()->user->id, ":model" => $modelName));
         if ($Vote->opinion == 1) {
             $return['message'] = $Vote->delete() ? "ok" : "false";
         } else {
             $Vote->opinion = 1;
             $Vote->model = $modelName;
             $Vote->create_time = time();
             $return['message'] = $Vote->save() ? "ok" : "false";
         }
     } else {
         $model = new Vote();
         $model->pk_id = $pk_id;
         $model->create_user = Yii::app()->user->id;
         $model->create_time = time();
         $model->model = $modelName;
         $model->opinion = 1;
         $return['message'] = $model->save() ? "ok" : "false";
     }
     $return['count'] = Vote::model()->count("opinion=0 and model=:model and pk_id=:pk_id", array(":pk_id" => $pk_id, ":model" => $modelName));
     echo json_encode($return);
 }
Exemplo n.º 21
0
 public function getActualRevotesCount($userId)
 {
     $revokedCount = Vote::model()->count($condition = new CDbCriteria(array('condition' => 'election_id = ' . $this->id . ' AND user_id = ' . $userId)));
     $revotesCount = $revokedCount;
     $lastVote = $this->getLastVote($userId);
     if (!$lastVote || $lastVote->status !== Vote::STATUS_PASSED) {
         $revotesCount--;
     }
     return $revotesCount;
 }
Exemplo n.º 22
0
 public function actionView($id)
 {
     $this->pageName = "imageview";
     $this->bgImage = "images/logo32.jpg";
     self::publishJQAssets();
     $imageId = (int) $id;
     if ($imageId > 0) {
         //load image
         $img = $this->loadModel($imageId);
         if (isset($img)) {
             $name = "";
             $fu = self::loadUserByFBID($img->fbid);
             if (isset($fu)) {
                 $name = $fu->nick;
             }
             self::updateViewCount($imageId);
             $n = Vote::model()->countBySql("SELECT COUNT(*) FROM votes WHERE imageId=" . $imageId);
             $isvoted = Vote::model()->countBySql("SELECT COUNT(*) FROM votes WHERE fbid='" . $_SESSION["fbid"] . "' AND imageId=" . $imageId);
             $this->drawMenu = false;
             $this->render('view', array('img' => $img, 'name' => $name, 'votes' => $n, 'isvoted' => $isvoted, 'req_per_day' => self::loadRequestsPerDay()));
         } else {
             throw new CHttpException(400, 'Položka nebyla nalezena.');
         }
     } else {
         throw new CHttpException(400, 'Položka nebyla nalezena.');
     }
 }
Exemplo n.º 23
0
 <div class="content-left">
     <div class="question-body clearfix">
         <div class="pull-left vote-number clearfix">
             <div class="pull-left opt-list" style="width: 50px;"> <a  rel="tooltip" data-original-title="<?php echo Vote::model()->count("opinion=0 and model=:model and pk_id=:pk_id and create_user=:create_user", array(":create_user" => Yii::app()->user->id, ":pk_id" => $model->id, ":model" => "article")) > 0 ? '取消赞同' : '赞同'; ?>"  class="btn btn-mini <?php echo Vote::model()->count("opinion=0  and pk_id=:pk_id and create_user=:create_user and model=:model", array(":model" => "article", ":create_user" => Yii::app()->user->id, ":pk_id" => $model->id)) > 0 ? 'active' : ''; ?>" name="<?php echo (Yii::app()->user->isGuest) ? 'noLogin' : 'agreeeAnswer'; ?>" data-model="article" data-pk="<?php echo $model->id; ?>"><i class="icon icon-arrow-up"></i><br/><span class="count"><?php echo Vote::model()->count("opinion=0 and model=:model and pk_id=:pk_id", array(":model" => "article", ":pk_id" => $model->id)); ?></span></a> <br/><a class="btn btn-mini <?php echo Vote::model()->count("opinion=1 and model=:model and pk_id=:pk_id and create_user=:create_user", array(":model" => "article", ":create_user" => Yii::app()->user->id, ":pk_id" => $model->id)) > 0 ? 'active' : ''; ?>" rel="tooltip" data-original-title="<?php echo Vote::model()->count("opinion=1 and pk_id=:pk_id and model=:model and create_user=:create_user", array(":create_user" => Yii::app()->user->id, ":pk_id" => $model->id, ":model" => "article")) > 0 ? '取消反对' : '反对,不会显示你的姓名'; ?>"  data-placement="bottom" name="<?php echo (Yii::app()->user->isGuest) ? 'noLogin' : 'disagreeeAnswer'; ?>"   data-model="article" data-pk="<?php echo $model->id; ?>"><i style="font-size:14px;" class="icon icon-arrow-down"></i></a></div>
         </div>
         <div class="question-content" style="margin-left:50px;">
                     <p><?php $topicArray = explode(",",trim($model->topic_ids,","));?><?php for($i=0;$i<count($topicArray);$i++){?>
              <?php  $topicModel = Topic::model()->findByPk($topicArray[$i]);?>
                 <?php if($topicModel){?>
             <a href="javascropt:;" data-id="<?php echo $topicArray[$i];?>" class="topic-label"><span class="label"><?php echo $topicModel->name;?><span></a>
                 <?php }?>
             <?php }?>                 <a  href="javascript:;" onclick="report(<?php echo $model->id;?>, 'article')" title="举报" class="pull-right"><i class="icon-flag" style="margin-right: 4px;"></i> 举报</a></p>
             <h3><?php echo $model->subject; ?></h3>
             <p class="clearfix " style="font-size: 12px;height: 24px;line-height: 24px;"><span class="pull-left"><a href='<?php echo $this->createUrl("userinfo", array("user_id" => $model->create_user)); ?>' class="user-label" data-id="<?php echo $model->create_user; ?>" title="<?php echo User::getNameById($model->create_user); ?>"><?php echo User::getNameById($model->create_user); ?></a><span style="color:#ccc;margin-left: 10px;"><?php echo Comment::timeintval($model->create_time); ?> 发表</span></span><span class="pull-right"><a class="user-label" href="javascript:;" data-id="<?php echo $model->create_user; ?>"><img style="height: 24px;width: 24px;vertical-align:top;border-radius: 2px;" height="24" width="24" src="<?php echo $this->createUrl("getimage", array("id" => $model->create_user, "type" => "avatar")); ?>"></a></span></p>
             <div class="vote-info">
                 <?php $voteOpinion = Vote::model()->findAll("pk_id = :pk_id and model=:model and opinion=0 order by create_time desc", array(":pk_id" => $model->id, ":model" => "article")); ?>
                 <?php if (count($voteOpinion) > 0) { ?>
                     <span class="voters vote-some">
                         <?php
                         $i = 0;
                         foreach ($voteOpinion as $key => $value) {
                             $i++;
                             if ($i == 4)
                                 break;
                             echo ((($i == 3) && (count($voteOpinion)) >= 3) || (($i == 2) && (count($voteOpinion)) == 2) || (($i == 1) && (count($voteOpinion) == 1))) ? "<a class='user-label' href='javascropt:;' data-id='" . $value->create_user . "' data-value='" . $value->create_user . "'>" . User::getNameById($value->create_user) . "</a>" : "<a data-value='" . $value->create_user . "' class='user-label' href='javascropt:;' data-id='" . $value->create_user . "' data-value='" . $value->create_user . "'>" . User::getNameById($value->create_user) . "</a>" . "<span>、</span>";
                         }
                         ?>
                     </span>
                     <span class="voters vote-all" style="display:none;">
                         <?php
                         $j = 0;
Exemplo n.º 24
0
        
          </div><!-- end tags blocks -->
    </div>
 
</div>



<?php 
// $this->renderPartial('application.views.common._share_2',array('thisUrl'=>$url,'image'=>$image));
?>
</div><!-- itemListView -->
<div >
  <?php
  $ip = MHelper::Ip()->getIp();
  $vote = Vote::model()->find(array('condition'=>'review=:id and ip=:ip','params'=>array(':id'=>$model->id,':ip'=>$ip)));
  if($vote){ ?>

  <div class="vote text-right c9" style="margin-top:10px;" id="vote<?php echo $model->id; ?>">
   <span class="c-gray f-11" style="margin-right:5px;">Полезен ли обзор?</span> <span class="user_votes c-9"><span  class="user_pro  <?php if($vote->vote == 1) { echo 'user_mine';} ?>"><i class="zmdi zmdi-thumb-up"></i></span> <span class="user_num"><?php echo $model->yes?$model->yes:' '; ?></span>  <span class="user_contra <?php if($vote->vote != 1) { echo 'user_mine';} ?>" ><i class="zmdi zmdi-thumb-down"></i></span> <span class="user_contra-num"><?php echo $model->no?$model->no:' '; ?></span></span></div>
  
  <?php } else {
       
  ?>
  <div class="vote text-right c9 active" style="margin-top:10px;" id="vote<?php echo $model->id; ?>">
  <span class="c-gray f-11" style="margin-right:5px;">Полезен ли обзор?</span> <span class="user_votes"><span onclick="toVoteArticle(<?php echo $model->id; ?>, 1);" class="user_pro"><i class="zmdi zmdi-thumb-up"></i></span> <span class="user_num"><?php echo $model->yes?$model->yes:' '; ?></span>  <span class="user_contra" onclick="toVoteArticle(<?php echo $model->id; ?>, 0);"><i class="zmdi zmdi-thumb-down"></i></span> <span class="user_contra-num"><?php echo $model->no?$model->no:' '; ?></span></span></div>
  <?php
  }
  ?>
  </div> 
<div class="woocommerce">
Exemplo n.º 25
0
    echo $userModel->desc;
} else {
    echo "<span style='color:#999'>暂无个人简介</span>";
}
?>
</td></tr>
                                </tbody></table>
                        </div> 
                    </div>
                </div>
            </div>
            <div class="profile-header-operation">
                <div class="profile-header-info-list pull-left">
                    <span class="profile-header-info-title" style="margin-right: 4px;">获得</span>
                    <i class="icon-thumbs-up"></i>  <span style="color:#ff0000"><?php 
echo Vote::model()->count("to_user=:to_user and opinion=0", array(":to_user" => $userModel->id));
?>
 </span> 赞同
                    <a style="color:#666;margin-left: 10px;" class="item <?php 
echo $_GET["type"] == "wealth" ? "active" : "";
?>
" href="<?php 
echo $this->createUrl("default/userinfo", array("type" => "wealth", "user_id" => $_GET["user_id"]));
?>
">

                        <i class="icon-coins"></i> <span class="num"><?php 
echo $userModel->wealth;
?>
</span> 财富值
                    </a>
Exemplo n.º 26
0
<?php

/* @var $this NoticeController */
/* @var $data Notice */
$vote = Vote::model()->findByPk($data['voteId']);
$comment = null;
if ($vote) {
    $comment = Comment::model()->findByAttributes(array('entityId' => $vote->voteableEntityId));
}
if (!$comment) {
    return false;
}
?>
你的评论
<?php 
echo CHtml::link(mb_substr(strip_tags($comment->content), 0, 20), array('comment/view', 'id' => $comment->id));
//echo CHtml::link($comment->entity->getTitle(),array($comment->entity->type.'/view','id'=>$model->id));
?>
新增加一个<em><?php 
echo $vote->value > 0 ? "<span style=\"color:green\">赞同</span>" : "<span style=\"color:red\">反对</span>";
?>
</em>
Exemplo n.º 27
0
 public function testRevokeVoteFailsWithMessageBecauseOfTimeout()
 {
     $this->login("*****@*****.**", "qwerty");
     $this->open('election/candidates/1');
     $this->waitForPageToLoad("30000");
     $voteBox = "css=div.checkbox.vote";
     $this->waitForElementPresent($voteBox);
     //first vote
     $this->click($voteBox);
     $this->waitForElementContainsText($voteBox . ' span.value', '✓');
     //Simulating that timer is expired
     $candidate = Candidate::model()->findByAttributes(array('electoral_list_pos' => 1, 'election_id' => 1));
     $vote = Vote::model()->findByAttributes(array('candidate_id' => $candidate->id, 'user_id' => 1));
     $voted = new DateTime($vote->date);
     $voted->sub(new DateInterval('PT' . (Election::model()->findByPk(1)->remove_vote_time - 1) . 'M' . '54S'));
     $voted = $voted->format('Y-m-d H:i:s');
     Yii::app()->db->createCommand()->update('vote', array('date' => $voted), 'id = ' . $vote->id);
     $this->open('election/candidates/1');
     $this->sleep(7000);
     $this->click($voteBox);
     $this->assertElementPresent($errorBox = 'css=div.flash-messages div.alert-error');
     $this->assertElementContainsText($errorBox, 'Action is unavailable because of timeout');
     //check all candidates are inactive for voting
     $this->waitForCssCount($voteBox . '.inactive', 3);
 }
Exemplo n.º 28
0
 public function actionToVoteArticle()
 {
     $id = (int) $_POST['id'];
     $voter = (int) $_POST['vote'];
     $ret = array();
     // check
     $ip = MHelper::Ip()->getIp();
     $vote = Vote::model()->find(array('condition' => 'review=:id and ip=:ip', 'params' => array(':id' => $id, ':ip' => $ip)));
     if (!$vote) {
         $vote = new Vote();
         $vote->vote = $voter;
         $vote->review = $id;
         $vote->ip = $ip;
         if (!Yii::app()->user->isGuest) {
             $vote->user_id = Yii::app()->user->id;
         }
         $vote->save();
         $sql = "SELECT COUNT(*) FROM vote WHERE review={$id} and vote={$voter}";
         $numClients = Yii::app()->db->createCommand($sql)->queryScalar();
         if ($voter == 1) {
             $review = Article::model()->updateByPk($id, array('yes' => $numClients));
         } else {
             $review = Article::model()->updateByPk($id, array('no' => $numClients));
         }
         $ret['flag'] = true;
         $ret['count'] = $numClients;
         echo CJSON::encode($ret);
     }
 }