Fixes #1278 fetch record image details through rest api
Merge request reports
Activity
mentioned in commit de27a076
1559 1559 } 1560 1561 /** 1562 * Function to get the attachmentsid to given crmid 1563 * @param type $crmid 1564 * @param type $webaservice entity id 1565 * @return <Array> 1566 */ 1567 static function getAttachmentIds($crmid, $WsEntityId) { 1568 $adb = PearDatabase::getInstance(); 1569 $attachmentIds = false; 1570 if(!empty($crmid)) { 1571 $query = "SELECT attachmentsid FROM vtiger_seattachmentsrel WHERE crmid = ?"; 1572 $result = $adb->pquery($query, array($crmid)); 1573 $noofrows = $adb->num_rows($result); 1574 if ($adb->num_rows($result) > 1) { @uma.s Why not simply test $noofrows here, you already have done
adb->num_rows(result) ?
1563 * @param type $crmid 1564 * @param type $webaservice entity id 1565 * @return <Array> 1566 */ 1567 static function getAttachmentIds($crmid, $WsEntityId) { 1568 $adb = PearDatabase::getInstance(); 1569 $attachmentIds = false; 1570 if(!empty($crmid)) { 1571 $query = "SELECT attachmentsid FROM vtiger_seattachmentsrel WHERE crmid = ?"; 1572 $result = $adb->pquery($query, array($crmid)); 1573 $noofrows = $adb->num_rows($result); 1574 if ($adb->num_rows($result) > 1) { 1575 for ($i = 0; $i < $noofrows; $i++) { 1576 $attachmentIds[] = vtws_getId($WsEntityId,$adb->query_result($result, $i, 'attachmentsid')); 1577 } 1578 } else if($adb->num_rows($result) > 0 && $adb->num_rows($result) == 1){ @uma.s Same here... $noofrows is already the same as
adb->num_rows(result)...Actually would a better test simply be:
} else if($noofrows === 1) {
?Actually again, why even bother doing this at all? If it's greater than 0 then get the wsid for the attachment. Why do something different if it is 1 or if it is more than 1? The loop will work fine for 1 or 2 or 3...?
@lord_alan Addressed!
1285 1285 return $allowed; 1286 1286 } 1287 1287 1288 function vtws_filedetails($fileData){ 1289 $fileDetails = array(); 1290 if(!empty($fileData)) { 1291 $fileName = $fileData['name']; 1292 $fileType = $fileData['type']; 1293 $fileName = html_entity_decode($fileName, ENT_QUOTES, vglobal('default_charset')); 1294 $filenamewithpath = $fileData['path'].'_'.$fileData['encName']; @uma.s This is incorrect. In $fileData, there is no array member with the name "encName". It should be "storedname" and you are missing the attachmentsid as well:
It should be:
$filenamewithpath = $fileData['path'].$fileData['attachmentsid'].'_'.$fileData['storedname'];
If this is fixed as above then calling vtws_file_retrieve provides the right information back including base64 encoded file data.
mentioned in issue #1278 (closed)
@lord_alan Sure! we will review this.
@uma.s This is a similar problem to the bug with the portal #1511 (closed)
@lord_alan Thank you! We will review this.