Changeset 1524 for branches/multiuser

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

first mu checkin

Location:
branches/multiuser
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • branches/multiuser/ajax.php

    r1493 r1524  
    7878    $readItems = new ItemList(); 
    7979 
    80     $readItems -> populate(" not(i.unread & ". RSS_MODE_UNREAD_STATE  .") and i.cid= $cid", "", 0, 2, ITEM_SORT_HINT_READ); 
     80    $readItems -> populate(" i2u.flgunread=0 and i.cid= $cid", "", 0, 2, ITEM_SORT_HINT_READ); 
    8181    $readItems -> setTitle(LBL_H2_RECENT_ITEMS); 
    8282    $readItems -> setRenderOptions(IL_TITLE_NO_ESCAPE); 
  • branches/multiuser/cls/channels.php

    r1483 r1524  
    170170        _pf(' ... totalCount');      
    171171        $sql =  
    172         "select count(*) from ".getTable("item") . "i , " . getTable('channels') . " c " 
     172        "select count(*) from ".getTable("item2user") . "i , " . getTable('channels') . " c " 
    173173             
    174             ." where i.cid=c.id and not(i.unread & ".RSS_MODE_DELETED_STATE.") " 
     174            ." where i.fkcid=c.id and i.flgdeleted=0 " 
    175175            ." and not (c.mode & " .RSS_MODE_DELETED_STATE.")" 
    176             . (hidePrivate()? " and not(unread & ".RSS_MODE_PRIVATE_STATE.")":""); 
     176            . (hidePrivate()? " and i.flgprivate=0":""); 
    177177             
    178178            //echo $sql; 
     
    219219            $sql = "select f.id, f.name, count(*) as cnt " 
    220220            ." from " 
    221             .getTable('item') ." i, " 
     221            .getTable('item2user') ." i2u, " 
    222222            .getTable('channels') . " c, " 
    223223            .getTable('folders') ." f " 
    224             ." where i.unread & ". RSS_MODE_UNREAD_STATE 
    225             ." and not(i.unread & ". RSS_MODE_DELETED_STATE .")"; 
     224            ." where i2u.flgunread =1 " 
     225            ." and i2u.flgdeleted=0 "; 
    226226            if (hidePrivate()) { 
    227                 $sql .=" and not(unread & " . RSS_MODE_PRIVATE_STATE .") "; 
     227                $sql .=" and i2u.flgprivate =0 "; 
    228228            } 
    229229            $sql .= " and not(c.mode & " . RSS_MODE_DELETED_STATE .") "; 
    230             $sql .= " and i.cid=c.id and c.parent=f.id " 
     230            $sql .= " and i2u.fkcid=c.id and c.parent=f.id " 
    231231            ." group by f.id";  
    232232            _pf('query'); 
     
    266266        $this -> feedCount = rss_num_rows($res); 
    267267         
    268         $ucres = rss_query ("select cid, count(*) from " .getTable("item") 
    269         ." where unread & "  . RSS_MODE_UNREAD_STATE 
    270         . " and not(unread & " . RSS_MODE_DELETED_STATE .") group by cid"); 
     268        $ucres = rss_query ("select fkcid, count(*) from " .getTable("item2user") 
     269        ." i2u where i2u.flgunread=1 and i2u.flgdeleted=0 and i2u.fkuid=" .rss_user_id() ." group by i2u.fkcid"); 
    271270        $uc = array(); 
    272271        while (list($uccid,$ucuc) = rss_fetch_row($ucres)) { 
  • branches/multiuser/cls/items.php

    r1475 r1524  
    6060     * ctor 
    6161     */ 
    62     function Item($id, $title, $url, $enclosure, $parent, $author, $description, $date, $isPubDate, $unread, $rating) { 
     62    function Item($id, $title, $url, $enclosure, $parent, $author, $description, $date, $isPubDate, $unread,$private, $sticky, $flagged) { 
    6363        $this->rss = &$GLOBALS['rss']; 
    6464        $this->id = $id; 
    65         $this->flags = $unread; 
     65        //$this->flags = $unread; 
    6666        if ($title) { 
    6767            $this->title = $title; 
     
    8787        $this -> tags=array(); 
    8888        $this -> rating = $rating; 
    89         $this ->isUnread    = $unread & RSS_MODE_UNREAD_STATE; 
    90         $this ->isPrivate   = $unread & RSS_MODE_PRIVATE_STATE; 
    91         $this ->isDeleted   = $unread & RSS_MODE_DELETED_STATE; 
    92         $this ->isSticky    = $unread & RSS_MODE_STICKY_STATE; 
    93     $this ->isFlag    = $unread & RSS_MODE_FLAG_STATE; 
     89        $this ->isUnread    = $unread; 
     90        $this ->isPrivate   = $private; 
     91        $this ->isDeleted   = $deleted; 
     92        $this ->isSticky    = $sticky; 
     93        $this ->isFlag      = $flagged; 
    9494        //$this -> key = md5(rand(0,10000)); 
    9595         
     
    193193        $this->items[] = $item; 
    194194         
    195         if ((!$this -> hasUnreadItems) && $item->flags & RSS_MODE_UNREAD_STATE) { 
     195        if ((!$this -> hasUnreadItems) && $item->isUnread) { 
    196196            $this -> hasUnreadItems = true; 
    197197        } 
     
    260260         
    261261        // Predefined alternate ordering 
    262         $this -> ORDER_BY_UNREAD_FIRST = " order by i.unread & " . RSS_MODE_UNREAD_STATE . " desc, "; 
     262        $this -> ORDER_BY_UNREAD_FIRST = " order by i2u.flgunread desc, "; 
    263263        if (getConfig('rss.config.absoluteordering')) { 
    264264            $this -> ORDER_BY_UNREAD_FIRST .= " f.position asc, c.position asc"; 
     
    283283 
    284284      _pf('ItemList::populate()'); 
    285         $this -> _sqlActualWhat = " i.title,  c.title, c.id, i.unread, " 
     285        $this -> _sqlActualWhat = " i.title,  c.title, c.id, " 
     286        ."i2u.flgunread, i2u.flgprivate, i2u.flgsticky, i2u.flgdeleted, i2u.flgflagged," 
    286287            ."i.url, i.enclosure, i.author, i.description, c.icon, " 
    287288            ." unix_timestamp(ifnull(i.pubdate,i.added)) as ts, " 
    288             ." i.pubdate is not null as ispubdate, i.id, r.rating  "; 
    289         $this -> _sqlActualFrom =   getTable("item") ." i " 
    290             ." left join " 
    291             . getTable("rating") ." r on (i.id = r.iid), " 
    292             .getTable("channels")." c, " 
    293             .getTable("folders") ." f "; 
    294  
    295         $this -> _sqlActualWhere = " i.cid = c.id and " 
    296             ." f.id=c.parent and ". (false == $includeDeprecated ? " not(c.mode & ".RSS_MODE_DELETED_STATE.") and " : "") 
    297             ." not(i.unread & ".RSS_MODE_DELETED_STATE.") and "; 
    298              
    299  
    300  
     289            ." i.pubdate is not null as ispubdate, i.id " 
     290            //.", r.rating  " 
     291            ; 
     292             
     293        $this -> _sqlActualFrom =   "" 
     294            .getTable('item2user') . " i2u " 
     295            ." left join " 
     296            .getTable("item") ." i " 
     297            ." on (i2u.fkiid = i.id) left join " 
     298            //." left join " 
     299            //. getTable("rating") ." r on (i.id = r.iid), " 
     300            .getTable("channels")." c on (i.cid=c.id) left join " 
     301            .getTable("folders") ." f on (c.parent=f.id) "; 
     302 
     303 
     304        $this -> _sqlActualWhere = " i2u.fkuid= " . $GLOBALS['rssuser']->getUserId() . " "; 
    301305        if (hidePrivate()) { 
    302             $this -> _sqlActualWhere .= " not(i.unread & ".RSS_MODE_PRIVATE_STATE.") and "; 
    303         } 
     306            $this -> _sqlActualWhere .= " and i2u.flgprivate=0 "; 
     307        } 
     308         
     309        $this -> _sqlActualWhere .= " and " 
     310            . (false == $includeDeprecated ? " not(c.mode & ".RSS_MODE_DELETED_STATE.") and " : "") 
     311            ." i2u.flgdeleted=0 and "; 
     312             
     313 
     314 
     315 
    304316 
    305317        if ($this -> _sqlActualWhere) { 
     
    347359        $this -> _sqlActualLimit = " $startItem, $itemCount"; 
    348360 
    349         $sql = "select " 
     361        $sql = "\nselect\n\t " 
    350362            .$this -> _sqlActualWhat 
    351             . " from " 
     363            . " \nfrom\n\t " 
    352364            .$this -> _sqlActualFrom 
    353             . " where " 
     365            . " \nwhere\n\t " 
    354366            . $this -> _sqlActualWhere 
    355             . " order by " 
     367            . " \norder by\n\t " 
    356368            . $this -> _sqlActualOrder 
    357             . " limit " 
     369            . " \nlimit " 
    358370            . $this -> _sqlActualLimit; 
    359371             
    360         //echo $sql;         
     372        //die( $sql ); 
    361373        $this -> iids = array(); 
    362         $res = $GLOBALS['rss_db']->rss_query($sql); 
     374        $res = rss_query($sql); 
    363375        $this -> rowCount = $GLOBALS['rss_db']->rss_num_rows($res); 
    364376        $prevCid = -1; 
    365377        $curIdx = 0; 
    366378        $f=null; 
    367         while (list ($ititle_, $ctitle_, $cid_, $iunread_, $iurl_, $ienclosure_, $iauthor_, $idescr_, $cicon_, $its_, $iispubdate_, $iid_, $rrating_) = $GLOBALS['rss_db']->rss_fetch_row($res)) { 
     379        while (list ($ititle_, $ctitle_, $cid_, $iunread_, $iprivate_, $isticky_, $ideleted_, $iflagged_, $iurl_, $ienclosure_, $iauthor_, $idescr_, $cicon_, $its_, $iispubdate_, $iid_) = $GLOBALS['rss_db']->rss_fetch_row($res)) { 
    368380             
    369381            // Built a new Item 
    370             $i = new Item($iid_, $ititle_, $iurl_, $ienclosure_, $cid_, $iauthor_, $idescr_, $its_, $iispubdate_, $iunread_, $rrating_); 
     382            $i = new Item($iid_, $ititle_, $iurl_, $ienclosure_, $cid_, $iauthor_, $idescr_, $its_, $iispubdate_, $iunread_, $iprivate_, $isticky_, $iflagged_); 
    371383             
    372384            // no dupes, please 
     
    400412            // Some stats... 
    401413            $this -> itemCount++;            
    402             if ($iunread_ & RSS_MODE_UNREAD_STATE) { 
     414            if ($iunread_) { 
    403415                $this -> unreadCount++;  
    404416                $this -> unreadIids[] = $iid_; 
  • branches/multiuser/cls/update.php

    r1516 r1524  
    100100        if (!hidePrivate() || $ignorePrivate) { 
    101101            if (count($newIds) > 0 && getConfig('rss.config.markreadonupdate')) { 
    102                 rss_query("update ".getTable("item")." set unread = unread & " 
    103                           .SET_MODE_READ_STATE." where unread & ".RSS_MODE_UNREAD_STATE 
    104                           ." and id not in (".implode(",", $newIds).")"); 
     102                rss_query("update ".getTable("item2user")." i2u set i2u.flgunread=0 where i2u.flgunread=1" 
     103                          ." and i2u.fkiid not in (".implode(",", $newIds).")"); 
    105104            } 
    106105        } 
     
    413412    ."<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n" 
    414413    ."<html>\n"."<head>\n"."<title>Redirecting...</title>\n" 
    415     ."<meta http-equiv=\"refresh\" content=\"0;url=index.php\"/>\n" 
     414    ."<meta http-equiv=\"refresh\" content=\"0;url=index.php\"/>\n" 
    416415    ."</head>\n"."<body/>\n"."</html>"; 
    417416 
     
    475474 
    476475        var ids = new Array(); 
    477         kids = document.getElementById('updatetable').getElementsByTagName("tr"); 
     476        var kids = document.getElementById('updatetable').getElementsByTagName("tr"); 
    478477        var i=0; 
    479478        var added = 0; 
     
    572571 
    573572    function ajaxUpdate(batch) { 
    574         sBatch=''; 
     573        var sBatch=''; 
    575574        //alert(batch.length); 
    576575        for(var i=0;i<batch.length;i++) { 
  • branches/multiuser/cls/user.php

    r1461 r1524  
    224224        return $this -> _level; 
    225225    } 
     226     
     227    function getUserId() { 
     228        return $this -> _uid; 
     229    } 
    226230} 
    227231 
  • branches/multiuser/cls/wrappers/user.php

    r1461 r1524  
    3434} 
    3535 
     36function rss_user_id() { 
     37    return $GLOBALS['rssuser'] -> getUserId(); 
     38} 
     39 
    3640function rss_user_logout() { 
    3741    $GLOBALS['rssuser'] -> logout(); 
  • branches/multiuser/constants.php

    r1502 r1524  
    177177// Profiling  
    178178//  - The profiling information is "html commented out" at the end of every html page 
    179 //define('PROFILING', 1); 
    180 //define('PROFILING_DB', 1); 
     179define('PROFILING', 1); 
     180define('PROFILING_DB', 1); 
    181181 
    182182?> 
  • branches/multiuser/feed.php

    r1509 r1524  
    317317        /* Redirect! If this feed has more unread items, self-redirect */ 
    318318 
    319         $sql = "select count(*) from " .getTable("item") . " i " 
    320                ." where i.unread & " .RSS_MODE_UNREAD_STATE 
    321                ." and i.cid=$cid" 
    322                ." and not(i.unread & " . RSS_MODE_DELETED_STATE  .") " 
     319        $sql = "select count(*) from " .getTable("item2user") . " i2u " 
     320               ." where i2u.flgunread=1 " 
     321               ." and i2u.fkcid=$cid" 
     322               ." and i2u.flgdeleted=0 " 
    323323               ; 
    324324        if (hidePrivate()) { 
    325             $sql .=" and not(i.unread & " . RSS_MODE_PRIVATE_STATE .") "; 
     325            $sql .=" and i2u.flgprivate =0"; 
    326326        } 
    327327        list($hasMoreUnreads) = rss_fetch_row(rss_query($sql)); 
     
    363363 
    364364            // 2: Get the unread count for each feed: 
    365             $sql = "select cid, count(*) from " .getTable('item') 
    366                    ." where (unread & ".RSS_MODE_UNREAD_STATE . ") " 
    367                    ." and not (unread & " .RSS_MODE_DELETED_STATE . ") "; 
     365            $sql = "select fkcid, count(*) from " .getTable('item2user') 
     366                   ." i2u where i2u.flgunread=1 " 
     367                   ." and i2u.flgdeletd=0"; 
    368368            if (hidePrivate()) { 
    369                 $sql .= " and not (i.unread & " . RSS_MODE_PRIVATE_STATE . ") "; 
    370             } 
    371             $sql .= " group by cid"; 
     369                $sql .= " and i2u.flgprivate=0 "; 
     370            } 
     371            $sql .= " group by i2u.fkcid"; 
    372372            $res = rss_query($sql); 
    373373            while (list($cid__,$uc__) = rss_fetch_row($res)) { 
     
    424424         
    425425         
    426         $sql = "update " .getTable('item') 
    427                . " set unread = unread & ".SET_MODE_READ_STATE 
    428                . " where cid  in (" .implode(',', $cids_) . ") "; 
     426        $sql = "update " .getTable('item2user') 
     427               . " set unread = 0 " 
     428               . " where fkcid  in (" .implode(',', $cids_) . ") "; 
    429429          unset($cids_); 
    430430        if (count($IdsToMarkAsRead)) { 
    431             $sql .= " and id in (" . implode(',',$IdsToMarkAsRead) .")"; 
     431            $sql .= " and fkiid in (" . implode(',',$IdsToMarkAsRead) .")"; 
    432432        } 
    433433 
     
    450450            if( $found || !$first_fid ) { 
    451451                $sql = "select count(*) from " 
    452                        .getTable('item') ." i, " 
     452                       .getTable('item2user') ." i2u, " 
    453453                       .getTable('channels') ." c " 
    454                        ." where i.unread & " .RSS_MODE_UNREAD_STATE ." and i.cid = c.id and c.parent = $fid__"; 
     454                       ." where i2u.flgunread=1 and i2u.fkcid = c.id and c.parent = $fid__" 
     455                       ." and i2u.fkuid=" . rss_user_id(); 
    455456                if (hidePrivate()) { 
    456                     $sql .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ")"; 
     457                    $sql .= " and i2u.flgprivate=0 "; 
    457458                } 
    458459     
     
    498499        } 
    499500         
    500         $sql = "update " .getTable('item')  
    501       . " set unread = unread & ".SET_MODE_READ_STATE 
    502       . " where cid in (" .implode(',',$fids_). ")"; 
     501        $sql = "update " .getTable('item2user')  
     502      . " set unread = 0 " 
     503      . " where fkcid in (" .implode(',',$fids_). ")" 
     504      . " and fkuid=". rss_user_id(); 
     505       
    503506 
    504507        if (count($IdsToMarkAsRead)) { 
    505             $sql .= " and id in (" . implode(',',$IdsToMarkAsRead) .")"; 
     508            $sql .= " and fkiid in (" . implode(',',$IdsToMarkAsRead) .")"; 
    506509        } 
    507510 
     
    521524            if( $found || !$first_vfid ) { 
    522525                // check for unread items in next virtual folder 
    523                 $sql = "select count(distinct(i.id)) as cnt from " 
     526                $sql = "select count(distinct(i.fkiid)) as cnt from " 
    524527                       .getTable('metatag') ." left join " 
    525                        .getTable('item') . "i on (i.cid=fid) " 
     528                       .getTable('item2user') . "i2u on (i2u.fkcid=fid) " 
    526529                       ."where tid = $tid__ and ttype = 'channel' " 
    527                        ." and (i.unread & ".RSS_MODE_UNREAD_STATE.") " 
    528                        ."and not(i.unread & ".RSS_MODE_DELETED_STATE.")"; 
     530                       ." and i2u.flgunread=1 " 
     531                       ." and i2u.fkuid=" .rss_user_id() 
     532                       ." and i2u.flgdeleted=0 "; 
    529533                if (hidePrivate()) { 
    530                     $sql .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ")"; 
     534                    $sql .= " and i2u.flgprivate=0 "; 
    531535                } 
    532536                list($c) = rss_fetch_row(rss_query($sql)); 
     
    682686    // "item mode" 
    683687    $res = rss_query ("select c.title, c.icon, i.title from " . getTable("channels") ." c, " 
    684                       .getTable("item") ." i where c.id = $cid and i.cid=c.id and i.id=$iid" 
    685                       ." and not(i.unread & " . RSS_MODE_DELETED_STATE  .") " 
     688                      .getTable("item") ." i, " 
     689                      .getTable('item2user') ." i2u where i2u.fkiid=i.id and " 
     690                      ." c.id = $cid and i.cid=c.id and i.id=$iid" 
     691                      ." and i2u.flgdeleted=0 " 
    686692                     ); 
    687693 
     
    726732        } else { 
    727733            // archives, folders, channels 
    728             $sql = "select count(*) from " . getTable('item') . " where" 
    729                    ." (unread & " . RSS_MODE_UNREAD_STATE .")" 
    730                    ." and not(unread & " . RSS_MODE_DELETED_STATE  .") "; 
     734            $sql = "select count(*) from " . getTable('item2user')  
     735                . " i2u left join ".getTable('item')." i on (i2u.fkiid=i.id) where" 
     736                   ."  i2u.flgunread=1 and i2u.flgdeleted=0"; 
    731737 
    732738            //archive? 
     
    739745            } 
    740746            if ($cids && count($cids)) { 
    741                 $sql .= " and cid in (".implode(',',$cids).")"; 
     747                $sql .= " and i.cid in (".implode(',',$cids).")"; 
    742748            } 
    743749            list($unreadCount) = rss_fetch_row(rss_query($sql)); 
     
    760766        $hint = ITEM_SORT_HINT_MIXED; 
    761767        if  ($do_show == SHOW_UNREAD_ONLY) { 
    762             $sqlWhere .= " and (i.unread & " . RSS_MODE_UNREAD_STATE .") "; 
     768            $sqlWhere .= " and i2u.flgunread=1 "; 
    763769            $hint = ITEM_SORT_HINT_UNREAD; 
    764770        } 
     
    787793                $sqlWhere = "i.cid = $cid"; 
    788794                if  ($do_show == SHOW_UNREAD_ONLY) { 
    789                     $sqlWhere .= " and (i.unread & " . RSS_MODE_UNREAD_STATE .") "; 
     795                    $sqlWhere .= " and i2u.flgunread=1 "; 
    790796                    $hint = ITEM_SORT_HINT_UNREAD; 
    791797                } 
  • branches/multiuser/index.php

    r1424 r1524  
    4747    && !hidePrivate()) { 
    4848     
    49     $sql = "update " .getTable("item") . " set unread=unread & " 
    50      .SET_MODE_READ_STATE ." where unread  & " . RSS_MODE_UNREAD_STATE; 
     49    $sql = "update " .getTable("item2user") . " i2u set i2u.flgunread=0 where i2u.flgunread=1 and i2u.fkuid=" .rss_user_id(); 
     50     
     51     
    5152      
    5253   if (hidePrivate()) { 
    53         $sql .= " and not(unread & " . RSS_MODE_PRIVATE_STATE . ")"; 
     54        $sql .= " and i2u.flgprivate=0 "; 
    5455     } 
    5556 
    5657    if (array_key_exists('markreadids',$_POST)) { 
    57         $sql .= " and id in (" . rss_real_escape_string($_POST['markreadids']) .")"; 
     58        $sql .= " and i2u.fkiid in (" . rss_real_escape_string($_POST['markreadids']) .")"; 
    5859    } 
    5960     rss_query( $sql ); 
     
    122123    $numItems = getConfig('rss.output.frontpage.numitems'); 
    123124     
    124     /* 
    125     $hiddenIds = getHiddenChannelIds(); 
    126     if (count($hiddenIds)) { 
    127         $sqlWhereHidden = " and c.id not in (" . implode(',',$hiddenIds) . ") "; 
    128     } else { 
    129         $sqlWhereHidden = ""; 
    130     } 
    131     */ 
    132     $sqlWhereHidden = ""; 
    133      
    134     $unreadItems -> populate("i.unread & " . RSS_MODE_UNREAD_STATE . $sqlWhereHidden, "", 0, $numItems,ITEM_SORT_HINT_UNREAD); 
    135      
     125     
     126    $unreadItems -> populate(" i2u.flgunread=1 ", "", 0, $numItems,ITEM_SORT_HINT_UNREAD); 
     127    //var_dump($unreadItems); 
    136128    _pf('end populate unread items'); 
    137129    if ($unreadItems ->unreadCount) { 
     
    187179        $res1=rss_query($sql); 
    188180        while ($readItems->itemCount < $limit && (list($cid) = rss_fetch_row($res1))) { 
    189             $sqlWhere  = " not(i.unread & ". RSS_MODE_UNREAD_STATE  .") and i.cid= $cid"; 
     181            $sqlWhere  = " i2u.flgunread=0 and i.cid= $cid"; 
    190182            $sqlWhere .= " and i.pubdate <= now() "; 
    191183             
     
    200192            return; 
    201193        } 
    202         $sqlWhere  = " not(i.unread & ". RSS_MODE_UNREAD_STATE  .")  "; 
     194        $sqlWhere  = " i2u.flgunread=0  "; 
    203195        $sqlWhere .= " and i.pubdate <= now() "; 
    204196    //  $sqlWhere .= $sqlWhereHidden; 
  • branches/multiuser/schema.php

    r1520 r1524  
    5050        "dashboard" => trim(getTable("dashboard")), 
    5151        "properties" => trim(getTable("properties")), 
     52        "item2user" => trim(getTable("item2user")), 
    5253 
    5354    ); 
     
    6465        } 
    6566    } 
    66      
    6767    $updated  = 0; 
    6868    if (count($missing_tables) > 0) { 
     
    258258            // guid of an item - added in 0.5.3 
    259259            rss_query('alter table ' . getTable('item') . ' add column guid text null'); 
    260             rss_query('alter table ' . getTable('item') . ' add index `guid` (`guid`(10))'); 
     260            rss_query('alter table ' . getTable('item') . " add index 'guid' ('guid'(10))"); 
    261261            if (rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 
    262262                $updated++; 
     
    681681} 
    682682 
     683 
     684/////////////////////////////////////////////////////////////////////////////// 
     685 
     686function _init_item2user() { 
     687    $table = getTable('item2user'); 
     688    rss_query_wrapper ('DROP TABLE IF EXISTS ' . $table, true, true); 
     689    $sql_create = str_replace('__table__',$table, <<< _SQL_ 
     690        CREATE TABLE __table__ ( 
     691          fkiid bigint(16) NOT NULL, 
     692          fkuid bigint(16) NOT NULL, 
     693          fkcid bigint(11) NOT NULL, 
     694          flgunread tinyint(1) NOT NULL default '1', 
     695          flgsticky tinyint(1) NOT NULL default '0', 
     696          flgprivate tinyint(1) NOT NULL default '0', 
     697          flgdeleted tinyint(1) NOT NULL default '0', 
     698          flgflagged tinyint(1) NOT NULL default '0', 
     699          KEY flgunread (flgunread), 
     700          KEY flgsticky (flgsticky), 
     701          KEY flgprivate (flgprivate), 
     702          KEY flgdeleted (flgdeleted), 
     703          KEY flgflagged (flgflagged), 
     704          KEY fkuid (fkuid), 
     705          KEY iids (fkiid) 
     706        ) ENGINE=MyISAM;         
     707_SQL_ 
     708); 
     709 
     710    rss_query_wrapper($sql_create, false, true); 
     711 
     712    if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 
     713        rss_error('The ' . $table . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR); 
     714        return 0; 
     715    } else { 
     716        $fillSql = "insert into $table (fkiid,fkuid,fkcid,flgunread,flgsticky,flgprivate,flgdeleted,flgflagged) " 
     717        ."select id, " . rss_user_id() . ", cid, " 
     718        ." unread & ".RSS_MODE_UNREAD_STATE." = ".RSS_MODE_UNREAD_STATE.", " 
     719        ." unread & ".RSS_MODE_STICKY_STATE." = ".RSS_MODE_STICKY_STATE.", " 
     720        ." unread & ".RSS_MODE_PRIVATE_STATE." = ".RSS_MODE_PRIVATE_STATE.", " 
     721        ." unread & ".RSS_MODE_DELETED_STATE." = ".RSS_MODE_DELETED_STATE.", " 
     722        ." unread & ".RSS_MODE_FLAG_STATE." = ".RSS_MODE_FLAG_STATE." from " .getTable('item'); 
     723        rss_query_wrapper($fillSql, false, true); 
     724 
     725        return rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR); 
     726    } 
     727} 
     728 
     729 
     730 
    683731///////////////////////////////////////////////////////////////////////////////