本文整理汇总了PHP中Vote::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Vote::model方法的具体用法?PHP Vote::model怎么用?PHP Vote::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vote
的用法示例。
在下文中一共展示了Vote::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkVote
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;
}
示例2: loadModel
/**
* 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;
}
示例3: run
/**
* 关注或取消赞成
* @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()));
}
示例4: actionRestlist
/**
* 助力数据
* 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);
}
示例5: compileVoteAdded
/**
* 编译投票添加类型通知
*/
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);
}
示例6: loadModel
/**
* 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;
}
示例7: getView
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;
}
示例8: getTotalByTypeId
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;
}
示例9: actionvote
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;
// . " hlasů <span>Už jsi hlasoval/a</span>";
Yii::app()->end();
}
}
示例10: implode
<?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"));
}
示例11: array
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>";
}
?>
示例12: array
<?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')))));
}
示例13: afterSave
/**
* 修改被点赞的人员
*/
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));
}
}
示例14: getVoteDownCount
/**
* 获取反对票数量
*/
public function getVoteDownCount()
{
$result = Vote::model()->count("voteableEntityId=:entityId and value<=0", array(':entityId' => $this->getOwner()->entityId));
return intval($result);
}
示例15: run
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));
}