示例#1
0
     * @param $value
     * @param $context \Workflow\VTEntity
     * @return array|void
     */
    public function doAction($configuration, $filepath, $filename, $context, $targetRecordIds = array())
    {
        if (\Workflow2::$isAjax === true) {
            $workflow = $this->getWorkflow();
            if (!empty($workflow)) {
                $id = md5(microtime(false) . rand(10000, 99999));
                copy($filepath, vglobal('root_directory') . '/modules/Workflow2/tmp/download/' . $id);
                $workflow->setSuccessRedirection('index.php?module=Workflow2&action=DownloadFile&filename=' . urlencode($filename) . '&id=' . $id);
                $workflow->setSuccessRedirectionTarget('new');
                return;
            }
        }
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-type: application/octet-stream");
        header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: " . filesize($filepath));
        @readfile($filepath);
        exit;
    }
}
\Workflow\FileAction::register('download', '\\Workflow\\Plugins\\FileActions\\Download');
示例#2
0
        $next_id = $adb->getUniqueID("vtiger_crmentity");
        copy($filepath, $upload_file_path . $next_id . "_" . $filename);
        $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?, ?, ?, ?, ?, ?, ?)";
        $params1 = array($next_id, $context->get('assigned_user_id'), $context->get('assigned_user_id'), "Documents Attachment", 'Documents Attachment', date("Y-m-d H:i:s"), date("Y-m-d H:i:s"));
        $adb->pquery($sql1, $params1);
        $filetype = "application/octet-stream";
        $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)";
        $params2 = array($next_id, $filename, $docDescr, $filetype, $upload_file_path);
        $adb->pquery($sql2, $params2, true);
        $sql3 = 'insert into vtiger_seattachmentsrel values(?,?)';
        $adb->pquery($sql3, array($focus->id, $next_id));
        if ($configuration["relation"] === "1") {
            foreach ($targetRecordIds as $id) {
                $sql = "INSERT INTO vtiger_senotesrel SET crmid = " . $id . ", notesid = " . $focus->id;
                $adb->query($sql);
            }
        } else {
            $sql = "DELETE FROM vtiger_senotesrel WHERE crmid = " . $context->getId() . " AND notesid = " . $focus->id;
            $adb->query($sql);
        }
        $newContext = \Workflow\VTEntity::getForId($focus->id, "Documents");
        if ($configuration['workflowid'] !== "") {
            $objWorkflow = new \Workflow\Main($configuration['workflowid'], false, $context->getUser());
            $objWorkflow->setContext($newContext);
            $objWorkflow->isSubWorkflow(true);
            $objWorkflow->start();
        }
    }
}
\Workflow\FileAction::register('documents', '\\Workflow\\Plugins\\FileActions\\Documents');
示例#3
0
                         )
    */
    public function getActions($moduleName)
    {
        $return = array('id' => 'filestore', 'title' => 'Store in Filestore', 'options' => array('filestoreid' => array('type' => 'templatefield', 'label' => 'Filestore ID', 'placeholder' => 'ID, which will be used to store the file'), 'filename' => array('type' => 'templatefield', 'label' => 'Filename', 'placeholder' => 'Name of file (empty use the original one)')));
        return $return;
    }
    /**
     * @param array $configuration - Array with all configuration options, the user configure
     * @param string $filepath  - The temporarily filepath of the file, which should be transformed
     * @param string $filename  - The filename of this file
     * @param \Workflow\VTEntity $context - The Context of the Workflow
     * @param array $targetRecordIds
     * @return void
     */
    public function doAction($configuration, $filepath, $filename, $context, $targetRecordIds = array())
    {
        $adb = \PearDatabase::getInstance();
        $overwrite_filename = $configuration['filename'];
        if (!empty($overwrite_filename)) {
            $filenamedata = pathinfo($filename);
            $overwrite_filename = str_replace('$extension', $filenamedata['extension'], $overwrite_filename);
            $filename = \Workflow\VTTemplate::parse($overwrite_filename, $context);
        }
        $filestoreid = $configuration['filestoreid'];
        $filestoreid = \Workflow\VTTemplate::parse($filestoreid, $context);
        $context->addTempFile($filepath, $filestoreid, $filename);
    }
}
\Workflow\FileAction::register('filestore', '\\Workflow\\Plugins\\FileActions\\Filestore');