Show
Ignore:
Timestamp:
08/05/06 11:53:58 (2 years ago)
Author:
mbonetti
Message:

first mu checkin

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/multiuser/util.php

    r1516 r1524  
    339339            // check whether we already have this item 
    340340            if ($guid) { 
    341                 $sql = "select id,unread, md5sum, guid, pubdate from ".getTable("item") 
    342                        ." where cid=$cid and guid='$guid'"; 
     341                $sql = "select id, i2u.flgunread,i2u.flgdeleted, md5sum, guid, pubdate " 
     342                ."from " 
     343                .getTable('item2user') ." i2u " 
     344                ."left join " 
     345                .getTable('item') ." i " 
     346                ." on (i2u.fkiid=i.id) " 
     347                ." where cid=$cid and guid='$guid'"; 
    343348            } else { 
    344                 $sql = "select id,unread, md5sum, guid, pubdate from ".getTable("item") 
    345                        ." where cid=$cid and url='$url' and title='$dbtitle'" 
    346                        ." and (pubdate is NULL OR pubdate=$sec)"; 
     349                $sql = "select id, i2u.flgunread,i2u.flgdeleted, md5sum, guid, pubdate " 
     350                ."from " 
     351                .getTable('item2user') ." i2u " 
     352                ."left join " 
     353                .getTable('item') ." i " 
     354                ." on (i2u.fkiid=i.id) " 
     355                ." where cid=$cid and url='$url' and title='$dbtitle'" 
     356                ." and (pubdate is NULL OR pubdate=$sec)"; 
    347357            } 
    348358 
    349359            $subres = rss_query($sql); 
    350             list ($indb, $state, $dbmd5sum, $dbGuid, $dbPubDate) = rss_fetch_row($subres); 
     360            list ($indb, $unread,$deleted, $dbmd5sum, $dbGuid, $dbPubDate) = rss_fetch_row($subres); 
    351361 
    352362            if ($indb) { 
    353363                $itemIdsInFeed[] = $indb; 
    354                 if (!($state & RSS_MODE_DELETED_STATE) && $md5sum != $dbmd5sum) { 
     364                if (!$deleted && $md5sum != $dbmd5sum) { 
    355365                    // the md5sums do not match. 
    356366                    if($allowUpdates) { // Are we allowed update items in the db? 
     
    360370                        $sql = "update ".getTable("item") 
    361371                               ." set "." description='".rss_real_escape_string($description)."', " 
    362                                ." unread = unread | ".RSS_MODE_UNREAD_STATE 
    363                                .", md5sum='$md5sum'" . " where cid=$cid and id=$indb"; 
    364  
     372                               //." unread = unread | ".RSS_MODE_UNREAD_STATE 
     373                               ." md5sum='$md5sum'" . " where cid=$cid and id=$indb"; 
     374                         
    365375                        rss_query($sql); 
     376                         
     377                        rss_query("update " .getTable('item2user') . " i2u set i2u.flgunread=1 where i2u.fkiid=$indb"); 
    366378                        $updatedIds[] = $indb; 
    367379                        continue; 
     
    375387                $sql = "insert into ".getTable("item") 
    376388                       ." (cid, added, title, url, enclosure," 
    377                        ." description, author, unread, pubdate, md5sum, guid) " 
     389                       ." description, author, pubdate, md5sum, guid) " 
    378390                       ." values ("."$cid, now(), '$dbtitle', " 
    379391                       ." '$url', '".rss_real_escape_string($enclosure)."', '" 
    380392                       .rss_real_escape_string($description)."', '" 
    381393                       .rss_real_escape_string($author)."', " 
    382                        ."$mode, $sec, '$md5sum', '$guid')"; 
     394                       ." $sec, '$md5sum', '$guid')"; 
    383395 
    384396                rss_query($sql); 
    385397 
    386398                $newIid = rss_insert_id(); 
     399                $uid=$GLOBALS['rssuser']->getUserId(); 
     400                $prv=($mode & RSS_MODE_PRIVATE_STATE) ?"1":"0"; 
     401                rss_query( 
     402                    "insert into " .getTable('item2user') 
     403                    ."  (fkiid,fkuid,fkcid,flgunread,flgprivate) " 
     404                    ." values ($newIid, $uid, $cid, 1, $prv) " 
     405                ); 
     406                 
    387407                $itemIdsInFeed[] = $newIid; 
    388408                $updatedIds[] = $newIid; 
     
    884904 
    885905    $sql = "select count(*) from " 
    886            .getTable("item")    ."i, ".getTable('channels')."c " 
    887            ." where i.unread & ".RSS_MODE_UNREAD_STATE. " and not(i.unread & " . 
    888            RSS_MODE_DELETED_STATE .") and i.cid=c.id " 
     906           .getTable("item2user")    ."i2u, ".getTable('channels')."c " 
     907           ." where " 
     908           ." i2u.fkuid = " . rss_user_id() 
     909           ." and i2u.flgunread=1 and i2u.flgdeleted=0 and i2u.fkcid=c.id " 
    889910           ." and not(c.mode & ".RSS_MODE_DELETED_STATE.") "; 
    890911 
    891912    if (hidePrivate()) { 
    892         $sql .= " and not(i.unread & ".RSS_MODE_PRIVATE_STATE.")"; 
     913        $sql .= " and i2u.flgprivate=0"; 
    893914    } 
    894915