本文整理汇总了PHP中Rating::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::find方法的具体用法?PHP Rating::find怎么用?PHP Rating::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: can_edit
public static function can_edit($id)
{
$v = Rating::find($id);
if ($v && static::is_logged_user($v->user_id)) {
return true;
}
return false;
}
示例2: getUserPlusTopics
public static function getUserPlusTopics($userId, $start = 0, $limit = 0)
{
$ratings = Rating::find(["entityType", Topic::ENTITY_TYPE, "userId", $userId, "valueType", self::VALUE_TYPE, "value", self::VALUE, "tag", self::TAG])->all();
if ($ratings == null || empty($ratings)) {
return array();
}
$query = Topic::find()->join("user")->join("group")->order_desc("id");
if ($ratings != null && !empty($ratings)) {
$where = "[id] in (";
$args = array();
for ($count = count($ratings), $i = 0; $i < $count; $i++) {
$where .= "?" . ($i < $count - 1 ? "," : "");
$args[] = $ratings[$i]->entityId;
}
unset($ratings);
$where .= ")";
$query = $query->where($where, $args);
}
return $start != 0 || $limit != 0 ? $query->range($start, $limit) : $query->all();
}
示例3: SummaryPapersAssignment
//.........这里部分代码省略.........
// Manage the navigation table
if ($nb_papers > MAX_ITEMS_IN_ASSIGNMENT or $nb_members > MAX_ITEMS_IN_ASSIGNMENT) {
// Show the navigation table
$tpl->set_var("nb_paper", $nb_papers);
$tpl->set_var("nb_reviewers", $nb_members);
$tpl->set_var("max_items_in_assignment", MAX_ITEMS_IN_ASSIGNMENT);
if (isset($_REQUEST['i_paper_min'])) {
// The request comes from the navigation table
$i_paper_min = $_REQUEST['i_paper_min'];
$i_paper_max = min($_REQUEST['i_paper_max'], $nb_papers);
$i_member_min = $_REQUEST['i_member_min'];
$i_member_max = min($_REQUEST['i_member_max'], $nb_members);
} else {
$i_paper_min = 1;
$i_paper_max = min($nb_papers, MAX_ITEMS_IN_ASSIGNMENT);
$i_member_min = 1;
$i_member_max = min($nb_members, MAX_ITEMS_IN_ASSIGNMENT);
}
// Show the navigation table
$tpl->set_var("NAV_TABLE", "");
$lines = "";
$script = $tpl->base_url . "/admin/chair/showassignment?1=1";
for ($i = 1; $i <= $nb_papers; $i += MAX_ITEMS_IN_ASSIGNMENT) {
$line = "";
for ($j = 1; $j <= $nb_members; $j += MAX_ITEMS_IN_ASSIGNMENT) {
$link = $script . "&i_paper_min={$i}" . "&i_paper_max=" . ($i + MAX_ITEMS_IN_ASSIGNMENT - 1) . "&i_member_min={$j}" . "&i_member_max=" . ($j + MAX_ITEMS_IN_ASSIGNMENT - 1);
if ($i == $i_paper_min and $j == $i_member_min) {
$line .= "<td bgcolor=lightblue><a href='{$link}'>" . "<font color=white>{$i}/{$j}</font></a></td>";
} else {
$line .= "<td><a href='{$link}'>{$i}/{$j}</a></td>";
}
}
$lines .= "<tr>{$line}</tr>\n";
}
$tpl->set_var("NAV_TABLE", $lines);
$tpl->append("NAVIGATION", "NAVIGATION_TABLE");
} else {
// Hide the navigation table
$i_paper_min = $i_member_min = 1;
$i_paper_max = $nb_papers;
$i_member_max = $nb_members;
$tpl->set_var("NAVIGATION", "");
}
// Put the current values in the template
$tpl->set_var("I_PAPER_MIN", $i_paper_min);
$tpl->set_var("I_PAPER_MAX", $i_paper_max);
$tpl->set_var("I_MEMBER_MIN", $i_member_min);
$tpl->set_var("I_MEMBER_MAX", $i_member_max);
// echo "I paper min=$i_paper_min I paper max = $i_paper_max<br>";
// OK, now create the table. First the columns' headers
for ($j = $i_member_min; $j <= $i_member_max; $j++) {
$members[$j]->putInView($tpl);
$tpl->member_nb_papers = $members[$j]->countPapers();
$tpl->append("MEMBERS", "MEMBER_DETAIL");
}
// then each line
$tpl->PAPERS = "";
for ($i = $i_paper_min; $i <= $i_paper_max; $i++) {
// Choose the CSS class
if ($i % 2 == 0) {
$tpl->set_var("css_class", "even");
} else {
$tpl->set_var("css_class", "odd");
}
$paper = $papers[$i];
$entity = "Paper" . "->id";
$tpl->setVar($entity, $papers[$i]->id);
$tpl->SESSION_ID = session_id();
// Get the ratings of each PC member
$nbReviewers = 0;
for ($j = $i_member_min; $j <= $i_member_max; $j++) {
$member = $members[$j];
$member->putInView($tpl);
$rating = $ratingTbl->find($paper->id, $member->id)->current();
if ($rating) {
$val = $rating->rate;
} else {
$val = 2;
}
$tpl->bg_color = "white";
$tpl->set_var("paper_rating", $val);
$tpl->set_var("CHECKED_YES", "");
$tpl->set_var("CHECKED_NO", "checked='1'");
// Check if the paper is assigned
$review = $reviewTbl->find($paper->id, $member->id)->current();
if ($review) {
$nbReviewers = $nbReviewers + 1;
$tpl->bg_color = "yellow";
$tpl->set_var("CHECKED_YES", "checked='1'");
$tpl->set_var("CHECKED_NO", "");
}
// Add to the assignment line
$tpl->append("ASSIGNMENTS", "ASSIGNMENT_DETAIL");
}
// Add to the list of papers
$tpl->setVar("paper_nb_reviewers", $nbReviewers);
$tpl->append("PAPERS", "PAPER_DETAIL");
$tpl->set_var("ASSIGNMENTS", "");
}
}
示例4: edit
/**
* Show the form for editing the specified rating.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$rating = Rating::find($id);
return View::make('ratings.edit', compact('rating'));
}
示例5: computeprefsAction
function computeprefsAction()
{
// Load the template
$this->view->setFile("content", "computeprefs.xml");
$this->view->setBlock("content", "MEMBER", "MEMBERS");
$paperTbl = new Paper();
$userTbl = new User();
$ratingTbl = new Rating();
// Loop on PC members
$members = $userTbl->fetchAll("roles LIKE '%R%'");
$i = 0;
foreach ($members as $member) {
$this->view->css_class = Config::CssCLass($i++);
$member->putInView($this->view);
// Loop on papers
if (1 == 1) {
$qPapers = "SELECT * FROM Paper";
} else {
// Loop on papers that match the reviewer's topics
$qPapers = "SELECT p.* FROM (Paper p LEFT JOIN PaperTopic t ON id=id_paper), " . " UserTopic s " . " WHERE (p.topic=s.idTopic OR t.id_topic=s.idTopic) AND s.id_user='{$user->id}' ";
}
$comments = "";
$rPapers = $this->zmax_context->db->query($qPapers);
while ($p = $rPapers->fetch(Zend_Db::FETCH_OBJ)) {
// instantiate a PaperRow object. Ok, not elegant, but easier
$paper = $paperTbl->find($p->id)->current();
$conflict = false;
// Get the rate, if exists
$rating = $ratingTbl->find($paper->id, $member->id)->current();
if (!is_object($rating)) {
// OK, the preference is unset. Check whether there is a conflict
$rating = $ratingTbl->createRow();
$rating->idPaper = $paper->id;
$rating->id_user = $member->id;
$conflict = $paper->checkConflictWithuser($member, $comments);
if ($conflict) {
// Conflict! The default preference is 0
$rating->rate = 0;
} else {
// Check whether some topics match
if ($member->matchTopic($paper->topic)) {
// Match! The default preference is 3
$comments .= "Topic match with paper {$paper->id} ({$paper->title})<br/> ";
$rating->rate = 3;
} else {
$rating->rate = 2;
}
}
// OK, now save the rating
$rating->save();
} else {
$comments = $this->zmax_context->texts->admin->conflicts_prefs_already_set;
}
}
// Loop on papers
$this->view->comments = $comments;
$this->view->append("MEMBERS", "MEMBER");
}
// End of loop on users
echo $this->view->render("layout");
}
示例6: destroy
/**
* Remove the specified rating from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$userId = Auth::user()->id;
$ratingData = Rating::find($id);
if ($userId === $ratingData["user_id"]) {
Log::info($userId);
}
if ($userId === $id) {
$ratingData = Rating::find($id);
}
if ($userId === $ratingData["user_id"]) {
Rating::destroy($id);
Log::info("rating id: {$id} deleted");
return Redirect::route('ratings.index');
} else {
return "Access Denied: this is not your rating.";
}
}