Share ideas, ask questions, and get feedback about developing for ProcessMaker
Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
By JMather
#6235
Hi!

I have a little hack I've created to make accessing uploaded documents simpler.

We plan on having non-technically proficient people trying to use the system, so it seemed it would be a good idea to make the uploaded documents as easy to access as possible, since expecting them to go a few menus deep simply wasn't going to happen.

Essentially, I added support for readonly="1" on file upload widgets. When tied to an input document, it will then list the files previously uploaded.
accessible_file_upload copy.png
Example
accessible_file_upload copy.png (15.55 KiB) Viewed 2294 times
It's a pretty simple mod to processmaker/gulliver/system/class.xmlform.php

~line 1550: Add $readonly = 0

Change:
Code: Select all
  var $required = false;
  var $input    = '';
  var $hints_message;
To
Code: Select all
  var $required = false;
  var $input    = '';
  var $readonly = 0;
  var $hints_message;


Then ~line 1561: Add the new presentation code


From:
Code: Select all
    $mode = ($this->mode == 'view') ? ' disabled="disabled"' : '';
    $html = '<input class="module_app_input___gray_file" ' . $mode . 'id="form[' . $this->name . ']" name="form[' . $this->name . ']" type=\'file\' value=\'' . $value . '\'/>';
To:
Code: Select all
    $mode = ($this->mode == 'view') ? ' disabled="disabled"' : '';
    if ($this->readonly == 1)
    {
      if (isset($this->input) && $this->input != '' && isset($_SESSION['APPLICATION']))
      {
       	$APP_UID = $_SESSION['APPLICATION'];
        require_once 'classes/model/InputDocument.php';
        $oiDoc = new InputDocument;
        $aDoc = $oiDoc->load($this->input);
        $ID_UID = $aDoc['INP_DOC_UID'];
        $c = new Criteria();
        $c->add(AppDocumentPeer::APP_UID, $APP_UID);
        $c->add(AppDocumentPeer::DOC_UID, $ID_UID);
        $c->addDescendingOrderByColumn(AppDocumentPeer::APP_DOC_INDEX);
        $c->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
        $c->addJoin(ContentPeer::CON_ID, AppDocumentPeer::APP_DOC_UID);
        $c->add(ContentPeer::CON_CATEGORY, 'APP_DOC_FILENAME');
        $c->addSelectColumn(ContentPeer::CON_VALUE);
        $c->addSelectColumn(AppDocumentPeer::APP_DOC_CREATE_DATE);
        $rs = AppDocumentPeer::doSelectRS($c);
        $html = '';
        while ($rs->next())
        {
                $url = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI']).'/cases_ShowDocument?a='.$rs->getString(1);
                $html .= '<a href="'.$url.'">'.$rs->getString(2).'</a> ('.$rs->getString(3).')<br />';
        }
        return $html;
      }
    }
    $html = '<input class="module_app_input___gray_file" ' . $mode . 'id="form[' . $this->name . ']" name="form[' . $this->name . ']" type=\'file\' value=\'' . $value . '\'/>';

To Use:

After you create a file upload tied to a input document, go to the XML view, and add readonly="1".

I don't know/haven't figured out, how to add it as an option to the file dialog. I assume it's an xmform somewhere, I just haven't looked yet.



Known problems:

A) The date display is ugly.

B) It may not be the most efficient route. This was intended to just get it running without knowing many of the internals (though I do know Propel, which saved my bacon.)

C) It doesn't take permissions into account. It assumes if you can see the task, and see this field, you can download the documents, which, IMHO, may be the smarter way to run something like this, but I'm not sure of what the other permissions implications this would cause, and YES you will still need to specifically allow people to be able to download the files if they do not show up via the long way.

If you're looking to save big on your next online […]

If you're looking to save big on your next online […]

If you're looking to save big on your next online […]

Use the latest Freecash referral code "FC2507[…]