function pathConfiguration() { global $xoopsModule; // Upload and Images Folders smartclient_collapsableBar('configtable', 'configtableicon'); echo "<img id='configtableicon' name='configtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . _AM_SCLIENT_PATHCONFIGURATION . "</h3>"; echo "<div id='configtable'>"; echo "<br />"; echo "<table width='100%' class='outer' cellspacing='1' cellpadding='3' border='0' ><tr>"; echo "<td class='bg3'><b>" . _AM_SCLIENT_PATH_ITEM . "</b></td>"; echo "<td class='bg3'><b>" . _AM_SCLIENT_PATH . "</b></td>"; echo "<td class='bg3' align='center'><b>" . _AM_SCLIENT_STATUS . "</b></td></tr>"; echo "<tr><td class='odd'>" . _AM_SCLIENT_PATH_IMAGES . "</td>"; $image_path = smartclient_getImageDir(); echo "<td class='odd'>" . $image_path . "</td>"; echo "<td class='even' style='text-align: center;'>" . smartclient_admin_getPathStatus('images') . "</td></tr>"; echo "</table>"; echo "<br />"; echo "</div>"; }
function editclient($showmenu = false, $id = 0) { global $client_handler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a client if ($id != 0) { // Creating the client object $clientObj = new SmartclientClient($id); if ($clientObj->notLoaded()) { redirect_header("client.php", 1, _AM_SCLIENT_NOCLIENTSELECTED); exit; } switch ($clientObj->status()) { case _SCLIENT_STATUS_SUBMITTED: $breadcrumb_action1 = _AM_SCLIENT_SUBMITTED_CLIENTS; $breadcrumb_action2 = _AM_SCLIENT_APPROVING; $page_title = _AM_SCLIENT_SUBMITTED_TITLE; $page_info = _AM_SCLIENT_SUBMITTED_INFO; $button_caption = _AM_SCLIENT_APPROVE; $new_status = _SCLIENT_STATUS_ACTIVE; break; case _SCLIENT_STATUS_ACTIVE: $breadcrumb_action1 = _AM_SCLIENT_ACTIVE_CLIENTS; $breadcrumb_action2 = _AM_SCLIENT_EDITING; $page_title = _AM_SCLIENT_ACTIVE_EDITING; $page_info = _AM_SCLIENT_ACTIVE_EDITING_INFO; $button_caption = _AM_SCLIENT_MODIFY; $new_status = _SCLIENT_STATUS_ACTIVE; break; case _SCLIENT_STATUS_INACTIVE: $breadcrumb_action1 = _AM_SCLIENT_INACTIVE_CLIENTS; $breadcrumb_action2 = _AM_SCLIENT_EDITING; $page_title = _AM_SCLIENT_INACTIVE_EDITING; $page_info = _AM_SCLIENT_INACTIVE_EDITING_INFO; $button_caption = _AM_SCLIENT_MODIFY; $new_status = _SCLIENT_STATUS_INACTIVE; break; case _SCLIENT_STATUS_REJECTED: $breadcrumb_action1 = _AM_SCLIENT_REJECTED_CLIENTS; $breadcrumb_action2 = _AM_SCLIENT_EDITING; $page_title = _AM_SCLIENT_REJECTED_EDITING; $page_info = _AM_SCLIENT_REJECTED_EDITING_INFO; $button_caption = _AM_SCLIENT_MODIFY; $new_status = _SCLIENT_STATUS_REJECTED; break; case "default": default: break; } if ($showmenu) { smartclient_adminMenu(1, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; smartclient_collapsableBar('bottomtable', 'bottomtableicon'); echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . $page_title . "</h3>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $page_info . "</span>"; echo "<div id='bottomtable'>"; } else { // there's no parameter, so we're adding a client $clientObj =& $client_handler->create(); $breadcrumb_action1 = _AM_SCLIENT_CLIENTS; $breadcrumb_action2 = _AM_SCLIENT_CREATE; $button_caption = _AM_SCLIENT_CREATE; $new_status = _SCLIENT_STATUS_ACTIVE; if ($showmenu) { smartclient_adminMenu(1, $breadcrumb_action1 . " > " . $breadcrumb_action2); } smartclient_collapsableBar('bottomtable', 'bottomtableicon'); echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . _AM_SCLIENT_CLIENT_CREATING . "</h3>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SCLIENT_CLIENT_CREATING_DSC . "</span>"; echo "<div id='bottomtable'>"; } // CLIENT FORM $sform = new XoopsThemeForm(_AM_SCLIENT_CLIENTS, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // TITLE $title_text = new XoopsFormText(_CO_SCLIENT_TITLE_REQ, 'title', 50, 255, $clientObj->title('e')); $sform->addElement($title_text, true); // LOGO $logo_array =& XoopsLists::getImgListAsArray(smartclient_getImageDir()); $logo_select = new XoopsFormSelect('', 'image', $clientObj->image()); $logo_select->addOption('-1', '---------------'); $logo_select->addOptionArray($logo_array); $logo_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . SMARTCLIENT_DIRNAME . '/images' . "\", \"\", \"" . XOOPS_URL . "\")'"); $logo_tray = new XoopsFormElementTray(_AM_SCLIENT_LOGO, ' '); $logo_tray->addElement($logo_select); $logo_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartclient_getImageDir('', false) . $clientObj->image() . "' name='image3' id='image3' alt='' />")); $logo_tray->setDescription(_AM_SCLIENT_LOGO_DSC); $sform->addElement($logo_tray); // LOGO UPLOAD $max_size = 5000000; $file_box = new XoopsFormFile(_AM_SCLIENT_LOGO_UPLOAD, "logo_file", $max_size); $file_box->setExtra("size ='45'"); $file_box->setDescription(sprintf(_AM_SCLIENT_LOGO_UPLOAD_DSC, $xoopsModuleConfig['img_max_width'], $xoopsModuleConfig['img_max_height'])); $sform->addElement($file_box); // IMAGE_URL $image_url_text = new XoopsFormText(_CO_SCLIENT_IMAGE_URL, 'image_url', 50, 255, $clientObj->image_url()); $image_url_text->setDescription(_CO_SCLIENT_IMAGE_URL_DSC); $sform->addElement($image_url_text, false); // URL $url_text = new XoopsFormText(_AM_SCLIENT_URL, 'url', 50, 255, $clientObj->url()); $url_text->setDescription(_AM_SCLIENT_URL_DSC); $sform->addElement($url_text, false); // SUMMARY $summary_text = new XoopsFormTextArea(_AM_SCLIENT_SUMMARY_REQ, 'summary', $clientObj->summary(0, 'e'), 7, 60); $summary_text->setDescription(_AM_SCLIENT_SUMMARY_DSC); $sform->addElement($summary_text, true); // DESCRIPTION $description_text = new XoopsFormDhtmlTextArea(_AM_SCLIENT_DESCRIPTION, 'description', $clientObj->description(0, 'e'), 15, 60); $description_text->setDescription(_AM_SCLIENT_DESCRIPTION_DSC); $sform->addElement($description_text, false); // CONTACT_NAME $contact_name_text = new XoopsFormText(_CO_SCLIENT_CONTACT_NAME, 'contact_name', 50, 255, $clientObj->contact_name('e')); $contact_name_text->setDescription(_CO_SCLIENT_CONTACT_NAME_DSC); $sform->addElement($contact_name_text, false); // CONTACT_EMAIL $contact_email_text = new XoopsFormText(_CO_SCLIENT_CONTACT_EMAIL, 'contact_email', 50, 255, $clientObj->contact_email('e')); $contact_email_text->setDescription(_CO_SCLIENT_CONTACT_EMAIL_DSC); $sform->addElement($contact_email_text, false); // CONTACT_PHONE $contact_phone_text = new XoopsFormText(_CO_SCLIENT_CONTACT_PHONE, 'contact_phone', 50, 255, $clientObj->contact_phone('e')); $contact_phone_text->setDescription(_CO_SCLIENT_CONTACT_PHONE_DSC); $sform->addElement($contact_phone_text, false); // ADRESS //$adress_text = new XoopsFormText(_CO_SCLIENT_ADRESS, 'adress', 50, 255, $clientObj->adress('e')); $adress_text = new XoopsFormTextArea(_CO_SCLIENT_ADRESS, 'adress', $clientObj->adress('e')); $adress_text->setDescription(_CO_SCLIENT_ADRESS_DSC); $sform->addElement($adress_text, false); // STATUS $options = $clientObj->getAvailableStatus(); $status_select = new XoopsFormSelect(_AM_SCLIENT_STATUS, 'status', $new_status); $status_select->addOptionArray($options); $status_select->setDescription(_AM_SCLIENT_STATUS_DSC); $sform->addElement($status_select); // WEIGHT $weight_text = new XoopsFormText(_AM_SCLIENT_WEIGHT, 'weight', 4, 4, $clientObj->weight()); $weight_text->setDescription(_AM_SCLIENT_WEIGHT_DSC); $sform->addElement($weight_text); // Client id $sform->addElement(new XoopsFormHidden('id', $clientObj->id())); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'addclient'); $button_tray->addElement($hidden); $sform->addElement(new XoopsFormHidden('original_status', $clientObj->status())); if (!$id) { // there's no id? Then it's a new client // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SCLIENT_CREATE, 'submit' ) ); $butt_create = new XoopsFormButton('', '', _AM_SCLIENT_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addclient\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SCLIENT_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SCLIENT_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } else { // else, we're editing an existing client // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SCLIENT_MODIFY, 'submit' ) ); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addclient\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SCLIENT_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } $sform->addElement($button_tray); $sform->display(); unset($hidden); echo "</div>"; }
// Uploading the logo, if any // Retreive the filename to be uploaded if ($_FILES['logo_file']['name'] != "") { $filename = $_POST["xoops_upload_file"][0]; if (!empty($filename) || $filename != "") { global $xoopsModuleConfig; $max_size = 10000000; $max_imgwidth = $xoopsModuleConfig['img_max_width']; $max_imgheight = $xoopsModuleConfig['img_max_height']; $allowed_mimetypes = smartclient_getAllowedMimeTypes(); include_once XOOPS_ROOT_PATH . "/class/uploader.php"; if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) { redirect_header('javascript:history.go(-1)', 2, _CO_SCLIENT_FILE_UPLOAD_ERROR); exit; } $uploader = new XoopsMediaUploader(smartclient_getImageDir(), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($filename) && $uploader->upload()) { $clientObj->setVar('image', $uploader->getSavedFileName()); } else { redirect_header('javascript:history.go(-1)', 2, _CO_SCLIENT_FILE_UPLOAD_ERROR . $uploader->getErrors()); exit; } } } // Putting the values in the client object $clientObj->setVar('id', isset($_POST['id']) ? intval($_POST['id']) : 0); $clientObj->setVar('title', $_POST['title']); $clientObj->setVar('summary', $_POST['summary']); $clientObj->setVar('description', $_POST['description']); $clientObj->setVar('contact_name', $_POST['contact_name']); $clientObj->setVar('contact_email', $_POST['contact_email']);
function getImagePath() { if ($this->getVar('image') != '' && $this->getVar('image') != 'blank.png') { return smartclient_getImageDir() . $this->image(); } else { return false; } }