private function getForm(GWF_Download $dl) { $data = array(); $data['filename'] = array(GWF_Form::STRING, $dl->getVar('dl_filename'), $this->module->lang('th_dl_filename')); $data['group'] = array(GWF_Form::SELECT, GWF_GroupSelect::single('group', $dl->getVar('dl_gid')), $this->module->lang('th_dl_gid')); $data['level'] = array(GWF_Form::INT, $dl->getVar('dl_level'), $this->module->lang('th_dl_level')); if (GWF_User::isAdminS()) { $data['price'] = array(GWF_Form::FLOAT, $dl->getVar('dl_price'), $this->module->lang('th_dl_price')); } $data['expire'] = array(GWF_Form::STRING, GWF_Time::humanDuration($dl->getVar('dl_expire')), $this->module->lang('th_dl_expire'), $this->module->lang('tt_dl_expire')); $data['guest_view'] = array(GWF_Form::CHECKBOX, $dl->isOptionEnabled(GWF_Download::GUEST_VISIBLE), $this->module->lang('th_dl_guest_view'), $this->module->lang('tt_dl_guest_view')); $data['guest_down'] = array(GWF_Form::CHECKBOX, $dl->isOptionEnabled(GWF_Download::GUEST_DOWNLOAD), $this->module->lang('th_dl_guest_down'), $this->module->lang('tt_dl_guest_down')); $data['adult'] = array(GWF_Form::CHECKBOX, $dl->isOptionEnabled(GWF_Download::ADULT), $this->module->lang('th_adult')); $data['huname'] = array(GWF_Form::CHECKBOX, $dl->isOptionEnabled(GWF_Download::HIDE_UNAME), $this->module->lang('th_huname')); $data['enabled'] = array(GWF_Form::CHECKBOX, $dl->isEnabled(), $this->module->lang('th_enabled')); $data['descr'] = array(GWF_Form::MESSAGE, $dl->getVar('dl_descr'), $this->module->lang('th_dl_descr')); $data['buttons'] = array(GWF_Form::SUBMITS, array('edit' => $this->module->lang('btn_edit'), 'delete' => $this->module->lang('btn_delete'))); return new GWF_Form($this, $data); }
public function mayDownload($user, GWF_Download $download) { if ($user === false) { # Guest if (!$download->isEnabled()) { return $this->error('err_disabled'); } if ($download->isAdult()) { return $this->error('err_adult'); } if (!$download->isOptionEnabled(GWF_Download::GUEST_DOWNLOAD)) { return $this->error('err_guest'); } if (!$this->cfgAnonDown()) { return $this->error('err_guest'); } return false; } else { $user instanceof GWF_User; # Admin if ($user->isAdmin()) { return false; } if (!$download->isEnabled()) { return $this->error('err_disabled'); } if ($download->isAdult() && !$user->wantsAdult()) { return $this->error('err_adult'); } # Level if ($download->getVar('dl_level') > $user->getVar('user_level')) { return $this->error('err_level', $download->getVar('dl_level')); } # Group $gid = $download->getVar('dl_gid'); if (false === ($group = GWF_Group::getByID($gid))) { } elseif ($gid > 0 && !$user->isInGroupID($download->getVar('dl_gid'))) { return $this->error('err_group', $group->display('group_name')); } return false; } }