function addRecurso($ubicacion, $idUsuario) { $bd = openBD(); $recurso_obj = new Recurso(null, $bd); $recurso_obj->setFechaPublicacion(date('Y/m/d h:i:s')); $recurso_obj->setUsuario($idUsuario); $recurso_obj->setUbicacion($ubicacion); $recurso_obj->setTipo(1); $recurso_obj->save($bd); closeBD($bd); }
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; }
<?php ini_set('display_errors', 0); error_reporting(E_ERROR | E_WARNING | E_PARSE); require_once "../bd/bd_recurso.php"; require_once "../bd/bd.php"; $bd = openBD(); closeBD($bd);