Exemplo n.º 1
0
 public function getAgo()
 {
     if (!empty($this->updated)) {
         return FoodleUtils::date_diff(time() - $this->updated);
     }
     if (!empty($this->created)) {
         return FoodleUtils::date_diff(time() - $this->created);
     }
     return NULL;
 }
Exemplo n.º 2
0
 public function getExpireText()
 {
     if (empty($this->expire)) {
         return 'This foodle will not expire';
     }
     if ($this->isExpired()) {
         return 'This foodle is expired';
     }
     return date("Y-m-d H:i", (int) $this->expire) . ' (expires in ' . FoodleUtils::date_diff((int) $this->expire - time()) . ')';
 }
Exemplo n.º 3
0
 public function readDiscussion(Data_Foodle $foodle, $maxago = null)
 {
     $maxclause = '';
     if ($maxago !== null) {
         $maxclause = ' AND UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(created) < ' . mysql_real_escape_string($maxago);
     }
     $sql = "\n\t\t\tSELECT *, UNIX_TIMESTAMP(created) AS createdu\n\t\t\tFROM discussion \n\t\t\tWHERE foodleid = '" . $foodle->identifier . "' " . $maxclause . "\n\t\t\tORDER BY discussion.created DESC \n\t\t\t";
     $result = $this->q($sql);
     $discussion = array();
     if (!empty($result)) {
         foreach ($result as $row) {
             try {
                 if (!empty($row['userid'])) {
                     $ruser = $this->readUser($row['userid']);
                     if ($ruser !== false) {
                         $row['user'] = $ruser;
                     }
                 }
             } catch (Exception $e) {
             }
             $row['agotext'] = FoodleUtils::date_diff(time() - $row['createdu']);
             $discussion[] = $row;
         }
     }
     return $discussion;
 }