HomeHelpTrac

Ignore:
Timestamp:
12/07/09 21:07:35 (2 years ago)
Author:
Alexander Trofimov
Message:

Ticket #543

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc/BxDolXMLRPCMedia.php

    r13378 r13382  
    135135            return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); 
    136136 
    137         return BxDolXMLRPCMedia::_getMediaAlbums ('music', $iIdProfile); 
     137        return BxDolXMLRPCMedia::_getMediaAlbums ('music', $iIdProfile, $iId); 
    138138    } 
    139139 
     
    144144            return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); 
    145145 
    146         return BxDolXMLRPCMedia::_getMediaAlbums ('video', $iIdProfile); 
    147     } 
    148  
    149     function _getMediaAlbums ($sType, $iIdProfile, $isShowEmptyAlbums = false) 
     146        return BxDolXMLRPCMedia::_getMediaAlbums ('video', $iIdProfile, $iId); 
     147    } 
     148 
     149    function _getMediaAlbums ($sType, $iIdProfile, $iIdProfileViewer, $isShowEmptyAlbums = false) 
     150    {         
     151        $aAlbums = BxDolXMLRPCMedia::_getMediaAlbumsArray ($sType, $iIdProfile, $iIdProfileViewer, $isShowEmptyAlbums); 
     152 
     153        $aXmlRpc = array (); 
     154 
     155        foreach ($aAlbums as $r) 
     156        { 
     157            $a = array ( 
     158                'Id' => new xmlrpcval($r['Id']), 
     159                'Title' => new xmlrpcval($r['Title']), 
     160                'Num' =>new xmlrpcval($r['Num']), 
     161            ); 
     162            $aXmlRpc[] = new xmlrpcval($a, 'struct'); 
     163        } 
     164 
     165        return new xmlrpcval ($aXmlRpc, "array"); 
     166    }     
     167 
     168    function _getMediaCount ($sType, $iIdProfile, $iIdProfileViewer) { 
     169        $a = BxDolXMLRPCMedia::_getMediaAlbumsArray ($sType, $iIdProfile, $iIdProfileViewer); 
     170        $iNum = 0; 
     171        foreach ($a as $r)  
     172            $iNum += $r['Num']; 
     173        return $iNum; 
     174    } 
     175 
     176    function _getMediaAlbumsArray ($sType, $iIdProfile, $iIdProfileViewer, $isShowEmptyAlbums = false) 
    150177    {         
    151178        switch ($sType) { 
    152179            case 'photo': 
     180                $sModuleName = 'photos'; 
    153181                $sType = 'bx_photos'; 
    154182                break; 
    155183            case 'video': 
     184                $sModuleName = 'videos'; 
    156185                $sType = 'bx_videos'; 
    157186                break; 
    158187            case 'music': 
     188                $sModuleName = 'sounds'; 
    159189                $sType = 'bx_sounds'; 
    160190                break;           
    161191            default: 
    162                 return new xmlrpcval (array(), "array"); 
     192                return array(); 
    163193        } 
    164194        bx_import('BxDolAlbums'); 
    165195        $o = new BxDolAlbums ($sType, (int)$iIdProfile); 
    166196        $aList = $o->getAlbumList (array('owner' => (int)$iIdProfile, 'show_empty' => $isShowEmptyAlbums)); 
    167         $aXmlRpc = array (); 
     197        $aRet = array (); 
    168198        foreach ($aList as $r) 
    169199        { 
    170             $a = array ( 
    171                 'Id' => new xmlrpcval($r['ID']), 
    172                 'Title' => new xmlrpcval($r['Caption']), 
    173                 'Num' =>new xmlrpcval($r['ObjCount']), 
    174             ); 
    175             $aXmlRpc[] = new xmlrpcval($a, 'struct'); 
    176         } 
    177         return new xmlrpcval ($aXmlRpc, "array"); 
    178     }     
     200            if ($iIdProfile != $iIdProfileViewer && !BxDolService::call ($sModuleName, 'get_album_privacy', array((int)$r['ID'], $iIdProfileViewer), 'Search')) 
     201                continue; 
     202             
     203            $aRet[] = array ( 
     204                'Id' => $r['ID'], 
     205                'Title' => $r['Caption'], 
     206                'Num' => $r['ObjCount'], 
     207            ); 
     208        } 
     209        return $aRet; 
     210    } 
    179211 
    180212    // ----------------- file list in albums  
     
    186218            return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); 
    187219 
    188         return BxDolXMLRPCMedia::_getFilesInAlbum ('videos', $iIdProfile, $iAlbumId, 'video', 'getToken', 'flash/modules/video/files/get_mobile.php?id='); 
     220        return BxDolXMLRPCMedia::_getFilesInAlbum ('videos', $iIdProfile, $iId, $iAlbumId, 'video', 'getToken', 'flash/modules/video/files/get_mobile.php?id='); 
    189221    } 
    190222 
     
    195227            return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); 
    196228 
    197         return BxDolXMLRPCMedia::_getFilesInAlbum ('sounds', $iIdProfile, $iAlbumId, 'mp3', 'getMp3Token', 'flash/modules/mp3/files/get_file.php?id='); 
    198     } 
    199  
    200     function _getFilesInAlbum ($sModuleName, $iIdProfile, $iAlbumId, $sWidget = '', $sFuncToken = '', $sTokenUrl = '') 
     229        return BxDolXMLRPCMedia::_getFilesInAlbum ('sounds', $iIdProfile, $iId, $iAlbumId, 'mp3', 'getMp3Token', 'flash/modules/mp3/files/get_file.php?id='); 
     230    } 
     231 
     232    function _getFilesInAlbum ($sModuleName, $iIdProfile, $iIdProfileViewer, $iAlbumId, $sWidget = '', $sFuncToken = '', $sTokenUrl = '') 
    201233    {      
    202234        if ($sWidget && preg_match('/^[a-zA-Z0-9_]+$/', $sWidget)) { 
     
    207239        } 
    208240 
    209         $a = BxDolService::call ($sModuleName, 'get_files_in_album', array((int)$iAlbumId), 'Search'); 
     241        $a = BxDolService::call ($sModuleName, 'get_files_in_album', array((int)$iAlbumId, $iIdProfileViewer != $iIdProfile, $iIdProfileViewer), 'Search'); 
    210242        if (!$a) 
    211243            return new xmlrpcval (array(), "array"); 
Note: See TracChangeset for help on using the changeset viewer.