Skip to content
Snippets Groups Projects

Fixes #1278 fetch record image details through rest api

Merged Uma requested to merge uma.s/vtigercrm:Rest_API_fetch_ImageDetails into master

Merge request reports

Approval is optional

Merged by avatar (Apr 8, 2025 6:00am UTC)

Merge details

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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) {
  • Alan Lord
    Alan Lord @lord_alan started a thread on commit ba4ac81f
  • 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...?

  • 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)

  • Author Guest

    @lord_alan Sure! we will review this.

  • @uma.s This is a similar problem to the bug with the portal #1511 (closed)

  • Author Guest

    @lord_alan Thank you! We will review this.

  • Please register or sign in to reply
    Loading