Changeset 11418 for trunk/xmlrpc/BxDolXMLRPCMedia.php
- Timestamp:
- 07/15/09 05:07:42 (3 years ago)
- File:
-
- 1 edited
-
trunk/xmlrpc/BxDolXMLRPCMedia.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xmlrpc/BxDolXMLRPCMedia.php
r11011 r11418 3 3 class BxDolXMLRPCMedia 4 4 { 5 // ------------------ get files in category 6 5 7 function getVideoInCategory($sUser, $sPwd, $sNick, $sCat) 6 8 { … … 20 22 return BxDolXMLRPCMedia::_getFilesInCategory ('sounds', $iIdProfile, $sCat); 21 23 } 22 23 function getAudioCategories ($sUser, $sPwd, $sNick)24 {25 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick);26 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd)))27 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));28 29 return BxDolXMLRPCMedia::_getMediaCategories ('music', $iIdProfile);30 }31 32 function getVideoCategories ($sUser, $sPwd, $sNick)33 {34 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick);35 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd)))36 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));37 38 return BxDolXMLRPCMedia::_getMediaCategories ('video', $iIdProfile);39 }40 41 function _getMediaCategories ($sType, $iIdProfile)42 {43 switch ($sType) {44 case 'photo':45 $sTable = 'bx_photos_files';46 $sFieldId = 'ID';47 $sFieldOwner = 'Owner';48 $sType = 'bx_photos';49 break;50 case 'video':51 $sTable = 'RayVideoFiles';52 $sFieldId = 'ID';53 $sFieldOwner = 'Owner';54 $sType = 'bx_videos';55 break;56 case 'music':57 $sTable = 'RayMp3Files';58 $sFieldId = 'ID';59 $sFieldOwner = 'Owner';60 $sType = 'bx_sounds';61 break;62 default:63 return new xmlrpcval (array(), "array");64 }65 66 if (!($r = db_res ("67 SELECT `c`.`Category`, COUNT(`f`.`$sFieldId`) AS `Num`68 FROM `sys_categories` AS `c`69 LEFT JOIN `$sTable` AS `f` ON (`f`.`$sFieldId` = `c`.`ID` AND `f`.`$sFieldOwner` = '$iIdProfile')70 WHERE `c`.`Type` = '$sType' AND (`c`.`Owner` = '0' OR `c`.`Owner` = '$iIdProfile')71 GROUP BY `c`.`Category`")))72 return new xmlrpcval (array(), "array");73 $aFiles = array ();74 while ($a = mysql_fetch_array ($r))75 {76 $aFile = array (77 'Id' => new xmlrpcval($a['Category']),78 'Title' => new xmlrpcval($a['Category']),79 'Num' =>new xmlrpcval($a['Num']),80 );81 $aFiles[] = new xmlrpcval($aFile, 'struct');82 }83 return new xmlrpcval ($aFiles, "array");84 }85 24 86 25 function _getFilesInCategory ($sModuleName, $iIdProfile, $sCat) … … 106 45 return new xmlrpcval ($aFiles, "array"); 107 46 } 47 48 // ------------------ categories list 49 50 function getAudioCategories ($sUser, $sPwd, $sNick) 51 { 52 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); 53 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) 54 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); 55 56 return BxDolXMLRPCMedia::_getMediaCategories ('music', $iIdProfile); 57 } 58 59 function getVideoCategories ($sUser, $sPwd, $sNick) 60 { 61 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); 62 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) 63 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); 64 65 return BxDolXMLRPCMedia::_getMediaCategories ('video', $iIdProfile); 66 } 67 68 function _getMediaCategories ($sType, $iIdProfile) 69 { 70 switch ($sType) { 71 case 'photo': 72 $sTable = 'bx_photos_files'; 73 $sFieldId = 'ID'; 74 $sFieldOwner = 'Owner'; 75 $sType = 'bx_photos'; 76 break; 77 case 'video': 78 $sTable = 'RayVideoFiles'; 79 $sFieldId = 'ID'; 80 $sFieldOwner = 'Owner'; 81 $sType = 'bx_videos'; 82 break; 83 case 'music': 84 $sTable = 'RayMp3Files'; 85 $sFieldId = 'ID'; 86 $sFieldOwner = 'Owner'; 87 $sType = 'bx_sounds'; 88 break; 89 default: 90 return new xmlrpcval (array(), "array"); 91 } 92 93 if (!($r = db_res (" 94 SELECT `c`.`Category`, COUNT(`f`.`$sFieldId`) AS `Num` 95 FROM `sys_categories` AS `c` 96 LEFT JOIN `$sTable` AS `f` ON (`f`.`$sFieldId` = `c`.`ID` AND `f`.`$sFieldOwner` = '$iIdProfile') 97 WHERE `c`.`Type` = '$sType' AND (`c`.`Owner` = '0' OR `c`.`Owner` = '$iIdProfile') 98 GROUP BY `c`.`Category`"))) 99 return new xmlrpcval (array(), "array"); 100 $aFiles = array (); 101 while ($a = mysql_fetch_array ($r)) 102 { 103 $aFile = array ( 104 'Id' => new xmlrpcval($a['Category']), 105 'Title' => new xmlrpcval($a['Category']), 106 'Num' =>new xmlrpcval($a['Num']), 107 ); 108 $aFiles[] = new xmlrpcval($aFile, 'struct'); 109 } 110 return new xmlrpcval ($aFiles, "array"); 111 } 112 113 // ----------------- albums list 114 115 function getAudioAlbums ($sUser, $sPwd, $sNick) 116 { 117 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); 118 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) 119 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); 120 121 return BxDolXMLRPCMedia::_getMediaAlbums ('music', $iIdProfile); 122 } 123 124 function getVideoAlbums ($sUser, $sPwd, $sNick) 125 { 126 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); 127 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) 128 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); 129 130 return BxDolXMLRPCMedia::_getMediaAlbums ('video', $iIdProfile); 131 } 132 133 function _getMediaAlbums ($sType, $iIdProfile) 134 { 135 switch ($sType) { 136 case 'photo': 137 $sType = 'bx_photos'; 138 break; 139 case 'video': 140 $sType = 'bx_videos'; 141 break; 142 case 'music': 143 $sType = 'bx_sounds'; 144 break; 145 default: 146 return new xmlrpcval (array(), "array"); 147 } 148 bx_import('BxDolAlbums'); 149 $o = new BxDolAlbums ($sType, $iIdProfile); 150 $aList = $o->getAlbumList (array('owner' => $iIdProfile)); 151 $aXmlRpc = array (); 152 while ($aList = mysql_fetch_array ($r)) 153 { 154 $a = array ( 155 'Id' => new xmlrpcval($a['ID']), 156 'Title' => new xmlrpcval($a['Caption']), 157 'Num' =>new xmlrpcval($a['ObjCount']), 158 ); 159 $aXmlRpc[] = new xmlrpcval($aFile, 'struct'); 160 } 161 return new xmlrpcval ($aXmlRpc, "array"); 162 } 163 164 // ----------------- file list in albums 165 166 function getVideoInAlbum($sUser, $sPwd, $sNick, $iAlbumId) 167 { 168 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); 169 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) 170 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); 171 172 return BxDolXMLRPCMedia::_getFilesInAlbum ('videos', $iIdProfile, $iAlbumId); 173 } 174 175 function getAudioInAlbum($sUser, $sPwd, $sNick, $iAlbumId) 176 { 177 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); 178 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) 179 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); 180 181 return BxDolXMLRPCMedia::_getFilesInAlbum ('sounds', $iIdProfile, $iAlbumId); 182 } 183 184 function _getFilesInAlbum ($sModuleName, $iIdProfile, $iAlbumId) 185 { 186 $a = BxDolService::call ($sModuleName, 'get_files_in_album', array($iAlbumId), 'Search'); 187 if (!$a) 188 return new xmlrpcval (array(), "array"); 189 foreach ($a as $k => $aRow) 190 { 191 $a = array ( 192 'id' => new xmlrpcval($aRow['id']), 193 'title' => new xmlrpcval($aRow['title']), 194 'desc' => new xmlrpcval(BxDolService::call ($sModuleName, 'get_length', array($aRow['size']), 'Search')), 195 'icon' => new xmlrpcval($aRow['icon']), 196 'thumb' => new xmlrpcval($aRow['thumb']), 197 'file' => new xmlrpcval($aRow['file']), 198 'cat' => new xmlrpcval($sCat), 199 'rate' => new xmlrpcval($aRow['voting_rate']), 200 'rate_count' => new xmlrpcval((int)$aRow['voting_count']), 201 ); 202 $aFiles[] = new xmlrpcval($a, 'struct'); 203 } 204 return new xmlrpcval ($aFiles, "array"); 205 } 108 206 } 109 207
Note: See TracChangeset
for help on using the changeset viewer.