Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-1128

College Match - Handle Upload and Link for Photo (files) in CM App


    • Type: Task
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: None
    • Fix Version/s: Quest-CM
    • Component/s: None
    • Labels:


      This spec covers the 3 file upload instances in the CM App forms: Personal Information, Essays > Personal Statement, and Partner > Stanford > Essay.

      • Uploaded files should be placed in a sub-directory of the configured CUSTOM_UPLOADDIR. For all CM uploads we will upload to a separate directory for each student. Construct the directory as follows:

      $config->CIVICRM_CUSTOM_FILE_UPLOADDIR . $contact_sub_type . '/' . $cid

      Example - if CIVICRM_CUSTOM_FILE_UPLOADDIR = file/docs/, a picture for a "Student" with cid=145 will go in 'file/docs/Student/145/'

      • The code for uploading files is already in place in Custom. However, we should generalize into a File BAO which custom fields and others can use. The BAO should allow you to pass in the sub-directory info (for example, the structure AFTER the config directory we defined above). For this usage - we will not use a custom field - but will store the pointer info as follows. For each uploaded file there will be
      • We insert a civicrm_file record and a civicrm_entity_file record for each uploaded file. File types have been added to civicrm_option_value (in the 'file_type' option_group) as follows (source latest quest_data_cm.mysql to make sure you have these):
        For Personal Info > Upload photo : set file_type_id = 4
        For Essays > Personal Statement : set file_type_id = 5
        For Partner > Stanford > Essay : set file_type_id = 6
      • Once a file has been uploaded, we should hide the row with the "Upload your picture" label and field, and show a row with label = "Your picture" and a field cell containing a link to view the photo (see below). Below the link to view the picture - put in a small "show" link... "+ Upload a new photo". Clicking this link "shows" the original Upload your picture row with file input/browse button. Any time the form is submitted AND the upload_pics (or other upload file field) is NOT EMPTY, we upload a new file. If there was a previously uploaded file for this file type, we delete the old file on disk as well as the civicrm_file and civicrm_entity_file records.
      • To display a link to the file, we use the File api's to retrieve info on the file id associated with this contact + file type. Format a link to the files as follows (refer to Quest/Page/View/Student.php and Student.tpl for example):
        <a href=" {crmURL p='civicrm/file' q="action=view&eid=$contactId&id=`$att.file_id`"}





            • Assignee:
              anil Anil Kokitkar
              dgg David Greenberg
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: