Example #1
0
 function getScraps($nbscraps, $criteria)
 {
     $myts = new MyTextSanitizer();
     $ret = array();
     $sql = 'SELECT scrap_id, uid, uname, user_avatar, scrap_from, scrap_text FROM ' . $this->db->prefix('yogurt_scraps') . ', ' . $this->db->prefix('users');
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $sql .= ' ' . $criteria->renderWhere();
         //attention here this is kind of a hack
         $sql .= " AND uid = scrap_from";
         if ($criteria->getSort() != '') {
             $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
         }
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
         $result = $this->db->query($sql, $limit, $start);
         $vetor = array();
         $i = 0;
         while ($myrow = $this->db->fetchArray($result)) {
             $vetor[$i]['uid'] = $myrow['uid'];
             $vetor[$i]['uname'] = $myrow['uname'];
             $vetor[$i]['user_avatar'] = $myrow['user_avatar'];
             $temptext = $myts->xoopsCodeDecode($myrow['scrap_text'], 1);
             $vetor[$i]['text'] = $myts->nl2Br($temptext);
             $vetor[$i]['id'] = $myrow['scrap_id'];
             $i++;
         }
         return $vetor;
     }
 }