All pastes #741706 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-10-18 22:18 UTC
rendered paste body
    // {module}_admin_update
    // using Uploads, hooked to the module, and set up as the field type for the icon field in the module.
    if (!xarVarFetch('icon', 'isset', $icon, "", XARVAR_NOT_REQUIRED)) return;

    if(isset($_FILES['icon_attach_upload']) && !empty($_FILES['icon_attach_upload']['name'])) {
        $fileinfo = xarModApiFunc('uploads','user', 'prepare_uploads', array('fileInfo' =>$_FILES['icon_attach_upload']) );
        $myimageinfo = current($fileinfo);
        if(isset($myimageinfo['errors'])) {
            $msg = $myimageinfo['errors'][0]['errorMesg'];
            xarErrorSet(XAR_SYSTEM_EXCEPTION, 'NO_PERMISSION', new SystemException($msg));
            return;
        }
        $imageinfo = xarModApiFunc('uploads','user', 'file_store', array('fileInfo' => $myimageinfo) );
        $icon = $imageinfo['fileId'];
    }
    $icon = !empty($icon) ? $icon : $product['icon'];
    if($delete_icon) $icon = "";