function JLMS_downloadFromBox($id, $option)
{
    global $JLMS_DB, $my, $Itemid;
    $course_id = intval(mosGetParam($_REQUEST, 'course_id', 0));
    //	$usertype = JLMS_GetUserType($my->id, $course_id);
    $JLMS_ACL =& JLMSFactory::getACL();
    $flag = false;
    if ($course_id && $JLMS_ACL->CheckPermissions('dropbox', 'view') && JLMS_GetDropItemCourse($id) == $course_id) {
        $query = "SELECT file_id, drp_type, drp_name, drp_description  FROM #__lms_dropbox" . "\n WHERE id = '" . $id . "' AND course_id = '" . $course_id . "'" . "\n AND (owner_id = '" . $my->id . "' OR recv_id = '" . $my->id . "')";
        $JLMS_DB->SetQuery($query);
        $file_data = $JLMS_DB->LoadObjectList();
        if (count($file_data) == 1) {
            $query = "UPDATE #__lms_dropbox" . "\n SET drp_mark = 0" . "\n WHERE id = '" . $id . "' AND course_id = '" . $course_id . "' AND recv_id = '" . $my->id . "'";
            $JLMS_DB->SetQuery($query);
            $JLMS_DB->query();
            if ($file_data[0]->drp_type == 1) {
                if ($file_data[0]->file_id == 0) {
                    $flag = true;
                } else {
                    JLMS_downloadFile($file_data[0]->file_id, $option, $file_data[0]->drp_name);
                }
            } else {
                if ($file_data[0]->drp_type == 2) {
                    if ($file_data[0]->file_id == 0) {
                        $flag = true;
                    } else {
                        $path_detect = JPATH_SITE . DS . 'components' . DS . 'com_jlms_profile' . DS . 'jlms_profile_detect.php';
                        if (file_exists($path_detect)) {
                            include_once $path_detect;
                            $detect = COMPONENT_Profile_Detect();
                            if ($detect) {
                                $TabMyFiles = new TabMyFiles($my->id);
                                $TabMyFiles->DownloadFile($file_data[0]->file_id, $my->id, $my->id, $file_data[0]->drp_name, true, array(), array('view' => 1));
                            }
                        }
                    }
                }
            }
        }
    }
    if ($flag) {
        JLMS_course_dropbox_html::viewCourseDropBox($file_data[0]->drp_description, $option, $file_data[0]->drp_name);
    } else {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=dropbox&id={$course_id}"));
    }
}
    function editDropBox(&$row, &$lists, $option, $course_id)
    {
        global $Itemid, $my;
        ?>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--
function setgood() {
	return true;
}
function submitbutton(pressbutton) {
	var form=document.adminForm;
	try {
		form.onsubmit();
	} catch(e) {
		//alert(e);
	}
	if ((pressbutton=='save_dropbox') && ((form.userfile.value=="") && (form.dropbox_name.value==""))){
			alert("<?php 
        echo _JLMS_SELECT_FILE_ENTER_NAME;
        ?>
");
	}
	 else {form.task.value = pressbutton;form.submit();}
}
//--><!]]>
</script>
<?php 
        JLMS_TMPL::OpenMT();
        $hparams = array();
        $toolbar = array();
        $toolbar[] = array('btn_type' => 'save', 'btn_js' => "javascript:submitbutton('save_dropbox');");
        $toolbar[] = array('btn_type' => 'cancel', 'btn_js' => "javascript:submitbutton('cancel_dropbox');");
        JLMS_TMPL::ShowHeader('dropbox', _JLMS_DROP_ADD_ITEM, $hparams, $toolbar);
        JLMS_TMPL::OpenTS();
        ?>
		<form action="<?php 
        echo sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}");
        ?>
" method="post" name="adminForm" enctype="multipart/form-data" onsubmit="setgood();">
			<table width="100%" cellpadding="0" cellspacing="0" border="0" id="jlms_item_properties">
				<tr>
					<td width="30%" valign="top" style="vertical-align:top"><?php 
        echo _JLMS_DROP_SEND_TO;
        ?>
</td>
					<td>
						<?php 
        echo $lists['course_users'];
        ?>
					</td>
				</tr>
				
				<tr>
					<td height="15"></td>
					<td></td>
				</tr>
				<tr>
					<td valign="middle" style="vertical-align:middle">
						<?php 
        echo _JLMS_DROP_NAME;
        ?>
					</td>
					<td>
						<input type="text" class="inputbox" name="dropbox_name" size="52" value="<?php 
        echo $row->drp_name;
        ?>
">
					</td>				
				</tr>
				<?php 
        $detect = false;
        $path_detect = JPATH_SITE . DS . 'components' . DS . 'com_jlms_profile' . DS . 'jlms_profile_detect.php';
        if (file_exists($path_detect)) {
            include_once $path_detect;
            $detect = COMPONENT_Profile_Detect();
        }
        if ($detect) {
            $params = array();
            $params['width'] = 800;
            $params['height'] = 600;
            echo showChooseFiles($params);
        } else {
            ?>
				<tr>
					<td valign="middle" style="vertical-align:middle"><br /><?php 
            echo _JLMS_CHOOSE_FILE;
            ?>
</td>
					<td>
						<br />
						<input class="inputbox" size="40" type="file" name="userfile">
					</td>
				</tr>
				<?php 
        }
        ?>
				<?php 
        //				if (JLMS_GetUserType($my->id, $course_id) == 1) {
        $JLMS_ACL =& JLMSFactory::getACL();
        if ($JLMS_ACL->CheckPermissions('dropbox', 'mark_as_corrected')) {
            ?>
				<tr>
					<td valign="middle" style="vertical-align:middle"><br /><?php 
            echo _JLMS_DROP_MARK_AS_CORRECTED;
            ?>
</td>
					<td>
						<br /><?php 
            echo mosHTML::yesnoRadioList('drp_corrected', 'class="inputbox" ', 0);
            ?>
					</td>
				</tr>
				<?php 
        }
        ?>
				<tr>
					<td colspan="2"><br /><?php 
        echo _JLMS_COMMENT;
        ?>
</td>
				</tr>
				<tr>
					<td colspan="2">
					<?php 
        JLMS_editorArea('editor1', $row->drp_description, 'drp_description', '100%;', '250', '40', '20');
        ?>
					</td>
				</tr>
			</table>
			<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
			<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
" />
			<input type="hidden" name="task" value="save_dropbox" />
			<input type="hidden" name="boxchecked" value="0" />
			<input type="hidden" name="id" value="<?php 
        echo $row->id;
        ?>
" />
			<input type="hidden" name="course_id" value="<?php 
        echo $course_id;
        ?>
" />
		</form>
<?php 
        JLMS_TMPL::CloseTS();
        JLMS_TMPL::CloseMT();
    }