function selectedArticles($current_user_id, $current_time = null) { if (!isset($current_time)) { $current_time = time(); } $last = strtotime('last Sunday', $current_time); $next = strtotime('next Sunday', $current_time); $lastSunday = mktime(8, 0, 0, date('m', $last), date('d', $last), date('Y', $last)); $nextSunday = mktime(8, 0, 0, date('m', $next), date('d', $next), date('Y', $next)); $list_articles = '<table id="list-articles">'; $list_articles .= '<tr class="title"><td>Date</td><td>Auteur</td><td>Titre</td><td>Cotation</td><td>Action</td><td>Intervenants</td></tr>'; connectBD(); /* On recupere les infomations des articles */ $sql = "SELECT DISTINCT (num_article), nom_membre, article_titre, article_url, article_pub\n\t\tFROM article, membre, article_pool\n\t\tWHERE article.num_membre = membre.num_membre\n\t\tAND article_pool.article_id = article.num_article\n\t\tAND article_pool.period = " . $nextSunday . "\n\t\tORDER BY article_pub DESC"; $request = mysql_query($sql) or die("Error with request {$sql}"); $nb_articles = 0; while ($article = mysql_fetch_row($request)) { $nb_articles++; $article_id = $article[0]; $article_author = $article[1]; $article_date = date("d/m/Y", $article[4]); $article_titre = decode_strip($article[2], 100); $article_titre = '<a href="' . $article[3] . '" target="_blank">' . $article_titre . '</a>'; $sql = "SELECT user_id, login, cotation\n\t\t\tFROM article_pool, user\n\t\t\tWHERE article_pool.user_id = user.id\n\t\t\tAND article_id = " . $article_id; $res = mysql_query($sql); $users = '<ul class="userlist">'; $status = 'unselected'; $cotation = array('nb_votes' => 0, 'style' => 0, 'recherche' => 0, 'contenu' => 0); while ($vote = mysql_fetch_row($res)) { $n++; if ($vote[0] == $current_user_id) { $status = 'selected'; } $users .= '<li>' . $vote[1] . "</li>"; $user_vote = json_decode($vote[2]); $cotation['nb_votes'] += 1; $cotation['style'] += $user_vote->{'style'}; $cotation['contenu'] += $user_vote->{'contenu'}; $cotation['recherche'] += $user_vote->{'recherche'}; } $users .= '</ul>'; $cotation = compute_cotation($cotation); if ($status == 'selected') { $action = '<img src="images/like-light.png" title="Sélectionner cet article" />'; } else { $action = '<a href="javascript:select(' . $article_id . ')"><img src="images/like.png" title="Sélectionner cet article" /></a>'; } $list_articles .= '<tr id="line' . $article_id . '" class="' . $status . '">'; $list_articles .= '<td>' . $article_date . '</td>'; $list_articles .= '<td><b>' . $article_author . '</b></td>'; $list_articles .= '<td>' . $article_titre . '</td>'; $list_articles .= '<td>' . $cotation . '</td>'; $list_articles .= '<td><span id="action' . $article_id . '">' . $action . '</span></td>'; $list_articles .= '<td>' . $users . '</td></tr>'; } $list_articles .= "</table>"; $content = '<h3>Articles déjà selectionnés</h3>'; $content .= $list_articles; closeBD(); if ($nb_articles == 0) { return $content . '<p>Aucun article trouvé</p>'; } return $content; }
$filter = ""; if (!empty($_POST['user_id'])) { $filter = ' AND ' . $core->prefix . 'post.user_id = \'' . urldecode($_POST['user_id']) . '\' '; } $sql = "SELECT user_fullname, post_pubdate, post_title, post_permalink, post_status, post_id\n\t\t\tFROM " . $core->prefix . "post, " . $core->prefix . "user\n\t\t\tWHERE " . $core->prefix . "post.user_id = " . $core->prefix . "user.user_id\n\t\t\tAND user_status = '1' " . $filter . "\n\t\t\tORDER BY post_pubdate DESC\n\t\t\tLIMIT " . $count; $list = '<table id="post-list" class="table-member">'; $list .= '<thead>'; $list .= '<tr class="title">'; $list .= '<th>' . T_('Date') . '</td>'; $list .= '<th style="text-align:center;">' . T_('Author') . '</td>'; $list .= '<th>' . T_('Title') . '</td>'; $list .= '<th style="text-align:center;">' . T_('Action') . '</td></tr></thead>'; $rs = $core->con->select($sql); if ($rs->count() > 0) { while ($rs->fetch()) { $post_title = decode_strip($rs->post_title, 100); $post_title = '<a href="' . $rs->post_permalink . '" target="_blank">' . $post_title . '</a>'; if ($rs->post_status) { $status = 'active'; $action = '<img src="meta/icons/true-light.png" title="' . T_('Accept') . '" /> '; $action .= '<a href="javascript:refuse(' . $rs->post_id . ', \'' . $rs->user_fullname . '\', \'' . $rs->post_permalink . '\')">'; $action .= '<img src="meta/icons/warn.png" title="' . T_('Refuse') . '" /></a>'; } else { $status = 'inactive'; $action = '<a href="javascript:accept(' . $rs->post_id . ', \'' . $rs->user_fullname . '\')">'; $action .= '<img src="meta/icons/true.png" title="' . T_('Accept') . '" /></a> '; $action .= '<img src="meta/icons/warn-light.png" title="' . T_('Refuse') . '" />'; } $list .= '<tr id="line' . $rs->post_id . '" class="' . $status . '">'; $list .= '<td>' . mysqldatetime_to_date("d/m/Y", $rs->post_pubdate) . '</td>'; $list .= '<td style="text-align:center;"><b>' . $rs->user_fullname . '</b></td>';