Changeset 1541

Show
Ignore:
Timestamp:
08/21/06 19:48:40 (2 years ago)
Author:
mbonetti
Message:

Some more multi-user-hacking

Location:
branches/multiuser
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • branches/multiuser/cls/channels.php

    r1524 r1541  
    170170        _pf(' ... totalCount');      
    171171        $sql =  
    172         "select count(*) from ".getTable("item2user") . "i , " . getTable('channels') . " c " 
    173              
    174             ." where i.fkcid=c.id and i.flgdeleted=0 " 
    175             ." and not (c.mode & " .RSS_MODE_DELETED_STATE.")" 
     172            "select count(*) from ".getTable("item2user") . "i , "  
     173            . getTable('channels2user') . " c2u "    
     174            ." where i.fkcid=c2u.fkcid and i.flgdeleted=0 " 
     175            ." and c2u.fkuid=" . rss_user_id() 
     176            ." and i.fkuid=" . rss_user_id() 
     177            ." and c2u.flgdeleted=0" 
    176178            . (hidePrivate()? " and i.flgprivate=0":""); 
    177179             
     
    184186        _pf(' ... feedsCount');              
    185187        $res = rss_query("select count(*) from " 
    186             .getTable("channels")." where not(mode & ".RSS_MODE_DELETED_STATE.")" 
    187             . (hidePrivate()? " and not(mode & ".RSS_MODE_PRIVATE_STATE.")":"") 
     188            .getTable("channels2user")." where flgdeleted=0 " 
     189            ." and fkuid=" . rss_user_id() 
     190            . (hidePrivate()? " and flgprivate=0":"") 
    188191            ); 
    189192             
     
    220223            ." from " 
    221224            .getTable('item2user') ." i2u, " 
    222             .getTable('channels') . " c, " 
     225            .getTable('channels2user') . " c2u, " 
    223226            .getTable('folders') ." f " 
    224227            ." where i2u.flgunread =1 " 
     
    227230                $sql .=" and i2u.flgprivate =0 "; 
    228231            } 
    229             $sql .= " and not(c.mode & " . RSS_MODE_DELETED_STATE .") "; 
    230             $sql .= " and i2u.fkcid=c.id and c.parent=f.id " 
     232            $sql .= " and c2u.fkuid=" . rss_user_id(); 
     233            $sql .= " and c2u.flgdeleted=0 "; 
     234            $sql .= " and c2u.parent=f.id " 
    231235            ." group by f.id";  
    232236            _pf('query'); 
     
    249253    function populate() { 
    250254        _pf('FeedList->populate() ...'); 
    251         $sql = "select "." c.id, c.title, c.url, c.siteurl, f.name, c.parent, c.icon, c.descr, c.mode "." from ".getTable("channels")." c, " 
    252         .getTable("folders")." f "." where f.id = c.parent"; 
    253  
     255        $sql = "select " 
     256        ." c.id, c.title, c.url, c.siteurl, f.name, c2u.parent, c2u.icon, c.descr, c2u.flgdeleted,c2u.flgprivate " 
     257        ." from " 
     258        .getTable("channels")." c, " 
     259        .getTable("channels2user")." c2u, " 
     260        .getTable("folders")." f " 
     261         
     262        ." where " 
     263        ." f.id = c.parent " 
     264        ." and c2u.fkcid=c.id " 
     265        . " and c2u.fkuid=" . rss_user_id(); 
    254266        if (hidePrivate()) { 
    255             $sql .= " and not(c.mode & ".RSS_MODE_PRIVATE_STATE.") "; 
    256         } 
    257  
    258         $sql .= " and not(c.mode & ".RSS_MODE_DELETED_STATE.") "; 
     267            $sql .= " and c2u.flgprivate=0 "; 
     268        } 
     269 
     270        $sql .= " and c2u.flgdeleted=0 "; 
    259271 
    260272        if (getConfig('rss.config.absoluteordering')) { 
    261             $sql .= " order by f.position asc, c.position asc"; 
     273            $sql .= " order by f.position asc, c2u.position asc"; 
    262274        } else { 
    263275            $sql .= " order by f.name, c.title asc"; 
  • branches/multiuser/cls/items.php

    r1524 r1541  
    262262        $this -> ORDER_BY_UNREAD_FIRST = " order by i2u.flgunread desc, "; 
    263263        if (getConfig('rss.config.absoluteordering')) { 
    264             $this -> ORDER_BY_UNREAD_FIRST .= " f.position asc, c.position asc"; 
     264            $this -> ORDER_BY_UNREAD_FIRST .= " f.position asc, c2u.position asc"; 
    265265        } else { 
    266266            $this -> ORDER_BY_UNREAD_FIRST .= " f.name asc, c.title asc"; 
     
    284284      _pf('ItemList::populate()'); 
    285285        $this -> _sqlActualWhat = " i.title,  c.title, c.id, " 
    286         ."i2u.flgunread, i2u.flgprivate, i2u.flgsticky, i2u.flgdeleted, i2u.flgflagged," 
    287             ."i.url, i.enclosure, i.author, i.description, c.icon, " 
     286        ."i2u.flgunread, i2u.flgprivate, i2u.flgsticky, i2u.flgdeleted, " 
     287        ." i2u.flgflagged," 
     288            ."i.url, i.enclosure, i.author, i.description, c2u.icon, " 
    288289            ." unix_timestamp(ifnull(i.pubdate,i.added)) as ts, " 
    289290            ." i.pubdate is not null as ispubdate, i.id " 
     
    298299            //." left join " 
    299300            //. 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) "; 
     301            .getTable('channels2user') ." c2u on (i.cid=c2u.fkcid) left join " 
     302            .getTable("channels")." c on (c2u.fkcid=c.id) left join " 
     303            .getTable("folders") ." f on (c2u.parent=f.id) "; 
    302304 
    303305 
     
    308310         
    309311        $this -> _sqlActualWhere .= " and " 
    310             . (false == $includeDeprecated ? " not(c.mode & ".RSS_MODE_DELETED_STATE.") and " : "") 
     312            . (false == $includeDeprecated ? " c2u.flgdeleted=0 and " : "") 
    311313            ." i2u.flgdeleted=0 and "; 
    312314             
     
    337339            if (!getConfig('rss.config.feedgrouping')) { 
    338340                if(getConfig("rss.config.datedesc.$skey")){ 
    339                     $this -> _sqlActualOrder = " ts desc, f.position asc, c.position asc "; 
     341                    $this -> _sqlActualOrder = " ts desc, f.position asc, c2u.position asc "; 
    340342                }else{ 
    341                     $this -> _sqlActualOrder = " ts asc, f.position asc, c.position asc "; 
     343                    $this -> _sqlActualOrder = " ts asc, f.position asc, c2u.position asc "; 
    342344                } 
    343345            } elseif (getConfig('rss.config.absoluteordering')) { 
    344                 $this -> _sqlActualOrder = " f.position asc, c.position asc"; 
     346                $this -> _sqlActualOrder = " f.position asc, c2u.position asc"; 
    345347            } else { 
    346348                $this -> _sqlActualOrder = " f.name asc, c.title asc"; 
  • branches/multiuser/feed.php

    r1524 r1541  
    6161) { 
    6262    $sqlid = sanitize($_REQUEST['channel'], RSS_SANITIZER_SIMPLE_SQL | RSS_SANITIZER_NO_SPACES); 
    63     $sql = "select id from " . getTable("channels") ." where title like '$sqlid'"; 
     63    $sql = "select c.id from "  
     64    . getTable("channels")  
     65    ." c left join " .getTable('channels2user') ." c2u on (c.id=c2u.fkcid) " 
     66    ." where c.title like '$sqlid'"; 
    6467    if (hidePrivate()) { 
    65         $sql .=" and not(mode & " . RSS_MODE_PRIVATE_STATE .") "; 
     68        $sql .=" and c2u.flgprivate=0 "; 
    6669    } 
    6770    // don't hide deprecated items becuase we want items of deprecated feeds to be accessible 
     
    7679 
    7780        // is this a folder? 
    78         $sql = "select c.id, c.parent from ". getTable('channels')." c, " 
     81        $sql = "select c.id, c.parent from ". getTable('channels')." c left join " 
     82               . getTable('channels2user') .' c2u on (c.id=c2u.fkcid), ' 
    7983               . getTable('folders') . " f " 
    8084               ." where c.parent=f.id and f.name like '$sqlid' and f.id > 0"; 
    8185 
    8286        if (hidePrivate()) { 
    83             $sql .=" and not(c.mode & " . RSS_MODE_PRIVATE_STATE .") "; 
    84         } 
    85         $sql .= " and not(c.mode & " .  RSS_MODE_DELETED_STATE .") "; 
     87            $sql .=" and c2u.flgprivate=0 "; 
     88        } 
     89        $sql .= " and c2u.flgdeleted=0 "; 
    8690 
    8791        $res = rss_query( $sql ); 
  • branches/multiuser/index.php

    r1524 r1541  
    162162        } 
    163163    $sql = "select " 
    164           ." c.id" 
     164          ." c2u.fkcid" 
    165165          ." from "  
    166             .getTable("channels") . " c, "  
     166            .getTable("channels2user") . " c2u, "  
    167167            .getTable("folders") ." f " 
    168           ." where c.parent = f.id "; 
     168          ." where c2u.parent = f.id "; 
    169169           
    170170         // $sql .= $sqlWhereHidden; 
    171171     
    172         $sql .= " and not(c.mode & " . RSS_MODE_DELETED_STATE  .") "; 
     172        $sql .= " and c2u.flgdeleted=0 "; 
    173173         
    174174        if (getConfig('rss.config.absoluteordering')) { 
    175             $sql .= " order by f.position asc, c.position asc"; 
     175            $sql .= " order by f.position asc, c2u.position asc"; 
    176176        } else { 
    177             $sql .=" order by f.name asc, c.title asc"; 
     177            $sql .=" order by f.name asc, c2u.title asc"; 
    178178        } 
    179179        $res1=rss_query($sql); 
  • branches/multiuser/schema.php

    r1535 r1541  
    5252        "properties" => trim(getTable("properties")), 
    5353        "item2user" => trim(getTable("item2user")), 
     54        "channels2user" => trim(getTable("channels2user")), 
     55 
    5456 
    5557    ); 
     
    269271         
    270272        break; 
     273        case 'm.fkuid': 
     274            // userid on metatags - added in 0.5.5 
     275            rss_query('alter table ' . getTable('metatag') . ' add column fkuid bigint(15) not null'); 
     276            rss_query('alter table ' . getTable('metatag') . " add index 'fkuid' ('fkuid')"); 
     277            if (rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 
     278                $updated++; 
     279                rss_error('updated schema for table ' . getTable('metatag'), RSS_ERROR_NOTICE); 
     280            } else { 
     281                rss_error('Failed updating schema for table ' . getTable('metatag') . ': ' 
     282                    . rss_sql_error_message(), RSS_ERROR_ERROR); 
     283            } 
     284         
     285        break;       
    271286    } 
    272287    return $updated; 
     
    567582            fid bigint(16) NOT NULL default '0',                     
    568583            tid bigint(16) NOT NULL default '0',  
     584            fkuid bigint(16) NOT NULL default '1', 
    569585            ttype enum('item','folder','channel') NOT NULL default 'item',  
    570586            KEY fid (fid),  
    571587            KEY tid (tid), 
     588            KEY fkuid (fkuid), 
    572589            KEY ttype (ttype) 
    573590        ) TYPE=MyISAM;     
     
    728745} 
    729746 
     747/////////////////////////////////////////////////////////////////////////////// 
     748 
     749function _init_channels2user() { 
     750    $table = getTable('channels2user'); 
     751    rss_query_wrapper ('DROP TABLE IF EXISTS ' . $table, true, true); 
     752    $sql_create = str_replace('__table__',$table, <<< _SQL_ 
     753        CREATE TABLE __table__ ( 
     754          id bigint(16) not null auto_increment, 
     755          fkcid bigint(16) NOT NULL, 
     756          fkuid bigint(16) NOT NULL, 
     757          icon varchar(255) default NULL, 
     758          position int(11) NOT NULL default '0', 
     759          parent tinyint(4) default '0', 
     760          flgprivate tinyint(1) NOT NULL default '0', 
     761          flgdeleted tinyint(1) not null default '0', 
     762          primary key (id), 
     763          KEY flgprivate (flgprivate), 
     764          KEY flgdeleted (flgdeleted), 
     765          KEY fkuid (fkuid), 
     766          KEY iids (fkcid) 
     767        ) ENGINE=MyISAM; 
     768_SQL_ 
     769); 
     770 
     771 
     772    rss_query_wrapper($sql_create, false, true); 
     773 
     774    if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 
     775        rss_error('The ' . $table . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR); 
     776        return 0; 
     777    } else { 
     778        $fillSql = "insert into $table " 
     779        ." (fkcid,fkuid,icon,position,parent,flgprivate,flgdeleted) " 
     780        ."select id, " . rss_user_id() . ", icon, position, parent, " 
     781        ." mode & ".RSS_MODE_PRIVATE_STATE." = ".RSS_MODE_PRIVATE_STATE.", " 
     782        ." mode & ".RSS_MODE_DELETED_STATE." = ".RSS_MODE_DELETED_STATE." " 
     783        ." from " .getTable('channels') 
     784        ." where url != ''"; 
     785        //die($fillSql); 
     786        rss_query_wrapper($fillSql, false, true); 
     787         
     788        rss_query( 
     789            'update ' .getTable('metatag') .' m ' 
     790            .'set m.fkuid=' .rss_user_id()); 
     791        /* 
     792        $rs = rss_query( "select id, fkcid from " .getTable('channels2user')); 
     793        $cids=array(); 
     794        while(list($c2uid,$cid) = rss_fetch_row($rs)) { 
     795            $cids[$cid]=$c2uid; 
     796        } 
     797        */ 
     798        return rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR); 
     799    } 
     800} 
     801 
     802 
    730803 
    731804 
     
    776849 
    777850"; 
    778     foreach (array("channels","config","folders","item","metatag","tag","rating", "users", "dashboard","item2user") as $tbl) { 
     851    foreach (array("channels","config","folders","item","metatag","tag","rating", "users", "dashboard","item2user","channels2user") as $tbl) { 
    779852        call_user_func("_init_$tbl");  
    780853    }