function editpartner($showmenu = false, $id = 0) { global $xoopsDB, $smartpartner_partner_handler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; if (!isset($smartpartner_partner_handler)) { $smartpartner_partner_handler =& smartpartner_gethandler('partner'); } include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a partner if ($id != 0) { // Creating the partner object $partnerObj = new SmartpartnerPartner($id); if ($partnerObj->notLoaded()) { redirect_header("partner.php", 1, _AM_SPARTNER_NOPARTNERSELECTED); exit; } switch ($partnerObj->status()) { case _SPARTNER_STATUS_SUBMITTED: $breadcrumb_action1 = _AM_SPARTNER_SUBMITTED_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_APPROVING; $page_title = _AM_SPARTNER_SUBMITTED_TITLE; $page_info = _AM_SPARTNER_SUBMITTED_INFO; $button_caption = _AM_SPARTNER_APPROVE; $new_status = _SPARTNER_STATUS_ACTIVE; break; case _SPARTNER_STATUS_ACTIVE: $breadcrumb_action1 = _AM_SPARTNER_ACTIVE_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_ACTIVE_EDITING; $page_info = _AM_SPARTNER_ACTIVE_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_ACTIVE; break; case _SPARTNER_STATUS_INACTIVE: $breadcrumb_action1 = _AM_SPARTNER_INACTIVE_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_INACTIVE_EDITING; $page_info = _AM_SPARTNER_INACTIVE_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_INACTIVE; break; case _SPARTNER_STATUS_REJECTED: $breadcrumb_action1 = _AM_SPARTNER_REJECTED_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_REJECTED_EDITING; $page_info = _AM_SPARTNER_REJECTED_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_REJECTED; break; case "default": default: break; } if ($showmenu) { smartpartner_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; smartpartner_collapsableBar('editpartner', 'editpartmericon', $page_title, $page_info); } else { // there's no parameter, so we're adding a partner $partnerObj =& $smartpartner_partner_handler->create(); $breadcrumb_action1 = _AM_SPARTNER_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_CREATE; $button_caption = _AM_SPARTNER_CREATE; $new_status = _SPARTNER_STATUS_ACTIVE; if ($showmenu) { smartpartner_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } smartpartner_collapsableBar('addpartner', 'addpartmericon', _AM_SPARTNER_PARTNER_CREATING, _AM_SPARTNER_PARTNER_CREATING_DSC); } // PARTNER FORM $sform = new XoopsThemeForm(_AM_SPARTNER_PARTNERS, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // TITLE $title_text = new XoopsFormText(_AM_SPARTNER_TITLE, 'title', 50, 255, $partnerObj->title('e')); $sform->addElement($title_text, true); // Parent Category $mytree = new SmartTree($xoopsDB->prefix("smartpartner_categories"), "categoryid", "parentid"); ob_start(); $mytree->makeMySelBox("name", "weight", explode('|', $partnerObj->categoryid()), 0, 'categoryid', '', true); //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="") $parent_cat_select = new XoopsFormLabel(_AM_SPARTNER_CATEGORY_BELONG, ob_get_contents()); $parent_cat_select->setDescription(_AM_SPARTNER_BELONG_CATEGORY_DSC); $sform->addElement($parent_cat_select); ob_end_clean(); // LOGO $logo_array =& XoopsLists::getImgListAsArray(smartpartner_getImageDir()); $logo_select = new XoopsFormSelect('', 'image', $partnerObj->image()); $logo_select->addOption('-1', '---------------'); $logo_select->addOptionArray($logo_array); $logo_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . SMARTPARTNER_DIRNAME . '/images' . "\", \"\", \"" . XOOPS_URL . "\")'"); $logo_tray = new XoopsFormElementTray(_AM_SPARTNER_LOGO, ' '); $logo_tray->addElement($logo_select); $logo_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartpartner_getImageDir('', false) . $partnerObj->image() . "' name='image3' id='image3' alt='' />")); $logo_tray->setDescription(_AM_SPARTNER_LOGO_DSC); $sform->addElement($logo_tray); // LOGO UPLOAD $max_size = 5000000; $file_box = new XoopsFormFile(_AM_SPARTNER_LOGO_UPLOAD, "logo_file", $max_size); $file_box->setExtra("size ='45'"); $file_box->setDescription(sprintf(_AM_SPARTNER_LOGO_UPLOAD_DSC, $xoopsModuleConfig['img_max_width'], $xoopsModuleConfig['img_max_height'])); $sform->addElement($file_box); // IMAGE_URL $image_url_text = new XoopsFormText(_CO_SPARTNER_IMAGE_URL, 'image_url', 50, 255, $partnerObj->image_url()); $image_url_text->setDescription(_CO_SPARTNER_IMAGE_URL_DSC); $sform->addElement($image_url_text, false); // URL $url_text = new XoopsFormText(_AM_SPARTNER_URL, 'url', 50, 255, $partnerObj->url()); $url_text->setDescription(_AM_SPARTNER_URL_DSC); $sform->addElement($url_text, false); // SUMMARY $summary_text = new XoopsFormTextArea(_AM_SPARTNER_SUMMARY, 'summary', $partnerObj->summary(0, 'e'), 7, 60); $summary_text->setDescription(_AM_SPARTNER_SUMMARY_DSC); $sform->addElement($summary_text, true); // SHOW summary on partner page $showsum_radio = new XoopsFormRadioYN(_AM_SPARTNER_SHOW_SUMMARY, 'showsummary', $partnerObj->getVar('showsummary')); $showsum_radio->setDescription(_AM_SPARTNER_SHOW_SUMMARY_DSC); $sform->addElement($showsum_radio); // DESCRIPTION $description_text = new XoopsFormDhtmlTextArea(_AM_SPARTNER_DESCRIPTION, 'description', $partnerObj->description(0, 'e'), 15, 60); $description_text->setDescription(_AM_SPARTNER_DESCRIPTION_DSC); $sform->addElement($description_text, false); // CONTACT_NAME $contact_name_text = new XoopsFormText(_CO_SPARTNER_CONTACT_NAME, 'contact_name', 50, 255, $partnerObj->contact_name('e')); $contact_name_text->setDescription(_CO_SPARTNER_CONTACT_NAME_DSC); $sform->addElement($contact_name_text, false); // CONTACT_EMAIL $contact_email_text = new XoopsFormText(_CO_SPARTNER_CONTACT_EMAIL, 'contact_email', 50, 255, $partnerObj->contact_email('e')); $contact_email_text->setDescription(_CO_SPARTNER_CONTACT_EMAIL_DSC); $sform->addElement($contact_email_text, false); // EMAIL_PRIV $email_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_EMAILPRIV, 'email_priv', $partnerObj->email_priv('e')); $email_priv_radio->setDescription(_CO_SPARTNER_CONTACT_EMAILPRIV_DSC); $sform->addElement($email_priv_radio); // CONTACT_PHONE $contact_phone_text = new XoopsFormText(_CO_SPARTNER_CONTACT_PHONE, 'contact_phone', 50, 255, $partnerObj->contact_phone('e')); $contact_phone_text->setDescription(_CO_SPARTNER_CONTACT_PHONE_DSC); $sform->addElement($contact_phone_text, false); // PHONE_PRIV $phone_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_PHONEPRIV, 'phone_priv', $partnerObj->phone_priv('e')); $phone_priv_radio->setDescription(_CO_SPARTNER_CONTACT_PHONEPRIV_DSC); $sform->addElement($phone_priv_radio); // ADRESS //$adress_text = new XoopsFormText(_CO_SPARTNER_ADRESS, 'adress', 50, 255, $partnerObj->adress('e')); $adress_text = new XoopsFormTextArea(_CO_SPARTNER_ADRESS, 'adress', $partnerObj->adress('e')); $adress_text->setDescription(_CO_SPARTNER_ADRESS_DSC); $sform->addElement($adress_text, false); // ADRESS_PRIV $adress_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_ADRESSPRIV, 'adress_priv', $partnerObj->adress_priv('e')); $adress_priv_radio->setDescription(_CO_SPARTNER_CONTACT_ADRESSPRIV_DSC); $sform->addElement($adress_priv_radio); // STATUS $options = $partnerObj->getAvailableStatus(); $status_select = new XoopsFormSelect(_AM_SPARTNER_STATUS, 'status', $new_status); $status_select->addOptionArray($options); $status_select->setDescription(_AM_SPARTNER_STATUS_DSC); $sform->addElement($status_select); // WEIGHT $weight_text = new XoopsFormText(_AM_SPARTNER_WEIGHT, 'weight', 4, 4, $partnerObj->weight()); $weight_text->setDescription(_AM_SPARTNER_WEIGHT_DSC); $sform->addElement($weight_text); //perms global $smartpermissions_handler; include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php'; $smartpermissions_handler = new SmartobjectPermissionHandler($smartpartner_partner_handler); if ($partnerObj->id() != 0) { $grantedGroups = $smartpermissions_handler->getGrantedGroups('full_view', $partnerObj->id()); } else { $grantedGroups = $xoopsModuleConfig['default_full_view']; } $full_view_select = new XoopsFormSelectGroup(_CO_SPARTNER_FULL_PERM_READ, 'full_view', true, $grantedGroups, 5, true); $full_view_select->setDescription(_CO_SPARTNER_FULL_PERM_READ_DSC); $sform->addElement($full_view_select); if ($partnerObj->id() != 0) { $partGrantedGroups = $smartpermissions_handler->getGrantedGroups('partial_view', $partnerObj->id()); } else { $partGrantedGroups = $xoopsModuleConfig['default_part_view']; } $part_view_select = new XoopsFormSelectGroup(_CO_SPARTNER_PART_PERM_READ, 'partial_view', true, $partGrantedGroups, 5, true); $part_view_select->setDescription(_CO_SPARTNER_PART_PERM_READ_DSC); $sform->addElement($part_view_select); // Partner id $sform->addElement(new XoopsFormHidden('id', $partnerObj->id())); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'addpartner'); $button_tray->addElement($hidden); $sform->addElement(new XoopsFormHidden('original_status', $partnerObj->status())); if (!$id) { // there's no id? Then it's a new partner // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_CREATE, 'submit' ) ); $butt_create = new XoopsFormButton('', '', _AM_SPARTNER_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SPARTNER_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } else { // else, we're editing an existing partner // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_MODIFY, 'submit' ) ); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } $sform->addElement($button_tray); $sform->display(); unset($hidden); if (!$id) { smartpartner_close_collapsable('addpartner', 'addpartnericon'); } else { smartpartner_close_collapsable('editpartner', 'editpartnericon'); } if ($id != 0) { showfiles($partnerObj); } }
function edititem($showmenu = false, $itemid = 0) { global $smartsection_file_handler, $smartsection_item_handler, $smartsection_category_handler, $xoopsUser, $xoopsModule, $xoopsConfig, $xoopsDB; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a item if ($itemid != 0) { // Creating the ITEM object $itemObj = new ssItem($itemid); if ($itemObj->notLoaded()) { redirect_header("item.php", 1, _AM_SS_NOITEMSELECTED); exit; } switch ($itemObj->status()) { case _SS_STATUS_SUBMITTED: $breadcrumb_action1 = _AM_SS_SUBMITTED; $breadcrumb_action2 = _AM_SS_APPROVING; $page_title = _AM_SS_SUBMITTED_TITLE; $page_info = _AM_SS_SUBMITTED_INFO; $button_caption = _AM_SS_APPROVE; $new_status = _SS_STATUS_PUBLISHED; break; case _SS_STATUS_PUBLISHED: $breadcrumb_action1 = _AM_SS_PUBLISHED; $breadcrumb_action2 = _AM_SS_EDITING; $page_title = _AM_SS_PUBLISHEDEDITING; $page_info = _AM_SS_PUBLISHEDEDITING_INFO; $button_caption = _AM_SS_MODIFY; $new_status = _SS_STATUS_PUBLISHED; break; case _SS_STATUS_OFFLINE: $breadcrumb_action1 = _AM_SS_OFFLINE; $breadcrumb_action2 = _AM_SS_EDITING; $page_title = _AM_SS_OFFLINEEDITING; $page_info = _AM_SS_OFFLINEEDITING_INFO; $button_caption = _AM_SS_MODIFY; $new_status = _SS_STATUS_OFFLINE; break; case "default": default: break; } $categoryObj =& $itemObj->category(); if ($showmenu) { ss_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; ss_collapsableBar('edititemtable', 'edititemicon', $page_title, $page_info); } else { // there's no parameter, so we're adding an item $itemObj =& $smartsection_item_handler->create(); $categoryObj =& $smartsection_category_handler->create(); $breadcrumb_action1 = _AM_SS_ITEMS; $breadcrumb_action2 = _AM_SS_CREATINGNEW; $button_caption = _AM_SS_CREATE; $new_status = _SS_STATUS_PUBLISHED; if ($showmenu) { ss_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } $sel_categoryid = isset($_GET['categoryid']) ? $_GET['categoryid'] : 0; $categoryObj->setVar('categoryid', $sel_categoryid); ss_collapsableBar('createitemtable', 'createitemicon', _AM_SS_ITEM_CREATING, _AM_SS_ITEM_CREATING_DSC); } // ITEM FORM $sform = new XoopsThemeForm(_AM_SS_ITEMS, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // CATEGORY $mytree = new XoopsTree($xoopsDB->prefix("smartsection_categories"), "categoryid", "parentid"); ob_start(); $sform->addElement(new XoopsFormHidden('categoryid', $categoryObj->categoryid())); $mytree->makeMySelBox("name", "weight", $categoryObj->categoryid()); $category_label = new XoopsFormLabel(_AM_SS_CATEGORY, ob_get_contents()); $category_label->setDescription(_AM_SS_CATEGORY_DSC); $sform->addElement($category_label); ob_end_clean(); // TITLE $title_text = new XoopsFormText(_AM_SS_TITLE, 'title', 50, 255, $itemObj->title(0, 'e')); $sform->addElement($title_text, true); // SUMMARY $summary_text = ss_getEditor(_AM_SS_SUMMARY, 'summary', $itemObj->summary(0, 'e')); $summary_text->setDescription(_AM_SS_SUMMARY_DSC); $sform->addElement($summary_text, false); // DISPLAY_SUMMARY $display_summary_radio = new XoopsFormRadioYN(_AM_SS_DISPLAY_SUMMARY, 'display_summary', $itemObj->display_summary(), ' ' . _AM_SS_YES . '', ' ' . _AM_SS_NO . ''); $sform->addElement($display_summary_radio); // BODY $body_text = ss_getEditor(_AM_SS_BODY, 'body', $itemObj->body(0, 'e')); //$body_text = new XoopsFormDhtmlTextArea(_AM_SS_BODY, 'body', $itemObj->body(0, 'e'), 20, 60); $body_text->setDescription(_AM_SS_BODY_DSC); $sform->addElement($body_text, true); // IMAGE $image_array =& XoopsLists::getImgListAsArray(ss_getImageDir('item')); $image_select = new XoopsFormSelect('', 'image', $itemObj->image()); //$image_select -> addOption ('-1', '---------------'); $image_select->addOptionArray($image_array); $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/smartsection/images/item/' . "\", \"\", \"" . XOOPS_URL . "\")'"); $image_tray = new XoopsFormElementTray(_AM_SS_IMAGE_ITEM, ' '); $image_tray->addElement($image_select); $image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . ss_getImageDir('item', false) . $itemObj->image() . "' name='image3' id='image3' alt='' />")); $image_tray->setDescription(_AM_SS_IMAGE_ITEM_DSC); $sform->addElement($image_tray); // IMAGE UPLOAD $max_size = 5000000; $file_box = new XoopsFormFile(_AM_SS_IMAGE_UPLOAD, "image_file", $max_size); $file_box->setExtra("size ='45'"); $file_box->setDescription(_AM_SS_IMAGE_UPLOAD_ITEM_DSC); $sform->addElement($file_box); // Uid /* We need to retreive the users manually because for some reason, on the frxoops.org server, the method users::getobjects encounters a memory error */ $uid = $itemObj->uid() == 0 ? $xoopsUser->uid() : $itemObj->uid(); $uid_select = new XoopsFormSelect(_AM_SS_UID, 'uid', $uid, 1, false); $uid_select->setDescription(_AM_SS_UID_DSC); $sql = "SELECT uid, uname FROM " . $xoopsDB->prefix('users') . " ORDER BY uname ASC"; $result = $xoopsDB->query($sql); $users_array = array(); while ($myrow = $xoopsDB->fetchArray($result)) { $users_array[$myrow['uid']] = $myrow['uname']; } $uid_select->addOptionArray($users_array); $sform->addElement($uid_select); // Datesub $datesub = $itemObj->getVar('datesub') == 0 ? time() : $itemObj->getVar('datesub'); $datesub_datetime = new XoopsFormDateTime(_AM_SS_DATESUB, 'datesub', $size = 15, $datesub); $datesub_datetime->setDescription(_AM_SS_DATESUB_DSC); $sform->addElement($datesub_datetime); // STATUS $options = array(_SS_STATUS_PUBLISHED => _AM_SS_PUBLISHED, _SS_STATUS_OFFLINE => _AM_SS_OFFLINE); $status_select = new XoopsFormSelect(_AM_SS_STATUS, 'status', $new_status); $status_select->addOptionArray($options); $status_select->setDescription(_AM_SS_STATUS_DSC); $sform->addElement($status_select); // WEIGHT $sform->addElement(new XoopsFormText(_AM_SS_WEIGHT, 'weight', 5, 5, $itemObj->weight()), true); // COMMENTS $addcomments_radio = new XoopsFormRadioYN(_AM_SS_ALLOWCOMMENTS, 'cancomment', $itemObj->cancomment(), ' ' . _AM_SS_YES . '', ' ' . _AM_SS_NO . ''); $sform->addElement($addcomments_radio); // PER ITEM PERMISSIONS $member_handler =& xoops_gethandler('member'); $group_list =& $member_handler->getGroupList(); $groups_checkbox = new XoopsFormCheckBox(_AM_SS_PERMISSIONS_ITEM, 'groups[]', $itemObj->getGroups_read()); $groups_checkbox->setDescription(_AM_SS_PERMISSIONS_ITEM_DSC); foreach ($group_list as $group_id => $group_name) { if ($group_id != XOOPS_GROUP_ADMIN) { $groups_checkbox->addOption($group_id, $group_name); } } $sform->addElement($groups_checkbox); // VARIOUS OPTIONS $options_tray = new XoopsFormElementTray(_AM_SS_OPTIONS, '<br />'); $html_checkbox = new XoopsFormCheckBox('', 'dohtml', $itemObj->dohtml()); $html_checkbox->addOption(1, _AM_SS_DOHTML); $options_tray->addElement($html_checkbox); $smiley_checkbox = new XoopsFormCheckBox('', 'dosmiley', $itemObj->dosmiley()); $smiley_checkbox->addOption(1, _AM_SS_DOSMILEY); $options_tray->addElement($smiley_checkbox); $xcodes_checkbox = new XoopsFormCheckBox('', 'doxcode', $itemObj->doxcode()); $xcodes_checkbox->addOption(1, _AM_SS_DOXCODE); $options_tray->addElement($xcodes_checkbox); $images_checkbox = new XoopsFormCheckBox('', 'doimage', $itemObj->doimage()); $images_checkbox->addOption(1, _AM_SS_DOIMAGE); $options_tray->addElement($images_checkbox); $linebreak_checkbox = new XoopsFormCheckBox('', 'dobr', $itemObj->dobr()); $linebreak_checkbox->addOption(1, _AM_SS_DOLINEBREAK); $options_tray->addElement($linebreak_checkbox); $sform->addElement($options_tray); // item ID $sform->addElement(new XoopsFormHidden('itemid', $itemObj->itemid())); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'additem'); $button_tray->addElement($hidden); if (!$itemid) { // there's no itemid? Then it's a new item // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SS_CREATE, 'submit' ) ); $butt_create = new XoopsFormButton('', '', _AM_SS_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'additem\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SS_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SS_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $sform->addElement($button_tray); $sform->display(); ss_close_collapsable('createitemtable', 'createitemicon'); } else { // else, we're editing an existing item // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SS_MODIFY, 'submit' ) ); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'additem\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SS_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $sform->addElement($button_tray); $sform->display(); ss_close_collapsable('edititemtable', 'edititemicon'); } unset($hidden); if ($itemid != 0) { showfiles($itemObj); } }
echo $r['comments']; ?> </textarea> </div> </td> </tr> <?php //Associated files // $f = contractid2files($id, $dbh); $flnk = showfiles($f); $sql = "SELECT files.* from files,invoice2file,contract2inv WHERE " . " contract2inv.contractid='{$id}' AND " . " invoice2file.invoiceid=contract2inv.invid AND " . " invoice2file.fileid=files.id"; $sthi = db_execute($dbh, $sql); $f = $sthi->fetchAll(PDO::FETCH_ASSOC); $flnk .= showfiles($f, 'fileslist2', 0); //echo "<pre>"; print_r($f); echo "</pre>"; ?> <tr><td colspan=2> <table width='100%'> <tr><td><h3><?php te("Associated Files"); ?> <img onclick='window.location.href=window.location.href;' src='images/refresh.png'></h3></td></tr> <tr> <td> <!-- file links --> <?php echo $flnk;
if ($licqty == $i) { $s = "SELECTED"; } else { $s = ""; } $qtsel .= "<option {$s} value='{$i}'>{$i}</option>\n"; } $qtsel .= "</select>\n"; // //Associated files $f = softid2files($id, $dbh); $flnk = showfiles($f); $f2 = softid2invoicefiles($id, $dbh); $flnk .= showfiles($f2, 'fileslist2', 0, 'File of related invoice'); $f3 = softid2contractfiles($id, $dbh); $flnk .= showfiles($f3, 'fileslist3', 0, 'File of related contract'); $d = strlen($purchdate) ? date($dateparam, $purchdate) : ""; ?> <tr> <td class="tdtop"> <table class="tbl2" style='width:300px;'> <tr><td colspan=2><h3>Software Properties</h3></td></tr> <tr><td class="tdt">ID:</td> <td><input class='input2' type=text name='id' value='<?php echo $id; ?> ' readonly size=3></td></tr> <tr><td class="tdt"> <?php if (is_numeric($manufacturerid)) {
function edititem($showmenu = false, $itemid = 0, $clone = false) { global $smartsection_current_page, $smartsection_file_handler, $smartsection_item_handler, $smartsection_category_handler, $xoopsUser, $xoopsModule, $xoopsConfig, $xoopsDB; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; include_once SMARTSECTION_ROOT_PATH . '/class/formdatetime.php'; // if there is a parameter, and the id exists, retrieve data: we're editing a item if ($itemid != 0) { // Creating the ITEM object $itemObj = $smartsection_item_handler->get($itemid); if (!$itemObj) { redirect_header("item.php", 1, _AM_SSECTION_NOITEMSELECTED); exit; } if ($clone) { $itemObj->setNew(); $itemObj->setVar('status', _SSECTION_STATUS_NOTSET); $itemObj->setVar('datesub', time()); } switch ($itemObj->status()) { case _SSECTION_STATUS_SUBMITTED: $breadcrumb_action1 = _AM_SSECTION_SUBMITTED; $breadcrumb_action2 = _AM_SSECTION_APPROVING; $page_title = _AM_SSECTION_SUBMITTED_TITLE; $page_info = _AM_SSECTION_SUBMITTED_INFO; $button_caption = _AM_SSECTION_APPROVE; $new_status = _SSECTION_STATUS_PUBLISHED; break; case _SSECTION_STATUS_PUBLISHED: $breadcrumb_action1 = _AM_SSECTION_PUBLISHED; $breadcrumb_action2 = _AM_SSECTION_EDITING; $page_title = _AM_SSECTION_PUBLISHEDEDITING; $page_info = _AM_SSECTION_PUBLISHEDEDITING_INFO; $button_caption = _AM_SSECTION_MODIFY; $new_status = _SSECTION_STATUS_PUBLISHED; break; case _SSECTION_STATUS_OFFLINE: $breadcrumb_action1 = _AM_SSECTION_OFFLINE; $breadcrumb_action2 = _AM_SSECTION_EDITING; $page_title = _AM_SSECTION_OFFLINEEDITING; $page_info = _AM_SSECTION_OFFLINEEDITING_INFO; $button_caption = _AM_SSECTION_MODIFY; $new_status = _SSECTION_STATUS_OFFLINE; break; case _SSECTION_STATUS_REJECTED: $breadcrumb_action1 = _AM_SSECTION_REJECTED; $breadcrumb_action2 = _AM_SSECTION_REJECTED; $page_title = _AM_SSECTION_REJECTED_EDIT; $page_info = _AM_SSECTION_REJECTED_EDIT_INFO; $button_caption = _AM_SSECTION_MODIFY; $new_status = _SSECTION_STATUS_REJECTED; break; case _SSECTION_STATUS_NOTSET: // Then it's a clone... $breadcrumb_action1 = _AM_SSECTION_ITEMS; $breadcrumb_action2 = _AM_SSECTION_CLONE_NEW; $button_caption = _AM_SSECTION_CREATE; $new_status = _SSECTION_STATUS_PUBLISHED; $page_title = _AM_SSECTION_ITEM_DUPLICATING; $page_info = _AM_SSECTION_ITEM_DUPLICATING_DSC; break; case "default": default: $breadcrumb_action1 = _AM_SSECTION_ITEMS; $breadcrumb_action2 = _AM_SSECTION_EDITING; $page_title = _AM_SSECTION_PUBLISHEDEDITING; $page_info = _AM_SSECTION_PUBLISHEDEDITING_INFO; $button_caption = _AM_SSECTION_MODIFY; $new_status = _SSECTION_STATUS_PUBLISHED; break; } $categoryObj = $itemObj->category(); if ($showmenu) { smartsection_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; smartsection_collapsableBar('edititemtable', 'edititemicon', $page_title, $page_info); if (!$clone) { echo "<form><div style=\"margin-bottom: 10px;\">"; echo "<input type='button' name='button' onclick=\"location='item.php?op=clone&itemid=" . $itemObj->itemid() . "'\" value='" . _AM_SSECTION_CLONE_ITEM . "'> "; echo "</div></form>"; } } else { // there's no parameter, so we're adding an item $itemObj =& $smartsection_item_handler->create(); $itemObj->setVar('uid', $xoopsUser->uid()); $categoryObj =& $smartsection_category_handler->create(); $breadcrumb_action1 = _AM_SSECTION_ITEMS; $breadcrumb_action2 = _AM_SSECTION_CREATINGNEW; $button_caption = _AM_SSECTION_CREATE; $new_status = _SSECTION_STATUS_PUBLISHED; if ($showmenu) { smartsection_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } $sel_categoryid = isset($_GET['categoryid']) ? $_GET['categoryid'] : 0; $categoryObj->setVar('categoryid', $sel_categoryid); smartsection_collapsableBar('createitemtable', 'createitemicon', _AM_SSECTION_ITEM_CREATING, _AM_SSECTION_ITEM_CREATING_DSC); } // ITEM FORM $sform = new XoopsThemeForm(_AM_SSECTION_ITEMS, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // CATEGORY $mytree = new XoopsTree($xoopsDB->prefix("smartsection_categories"), "categoryid", "parentid"); ob_start(); //$sform->addElement(new XoopsFormHidden('categoryid', $categoryObj->categoryid())); $mytree->makeMySelBox("name", "weight", $categoryObj->categoryid()); $category_label = new XoopsFormLabel(_AM_SSECTION_CATEGORY, ob_get_contents()); $category_label->setDescription(_AM_SSECTION_CATEGORY_DSC); $sform->addElement($category_label); ob_end_clean(); // TITLE $title_text = new XoopsFormText(_AM_SSECTION_TITLE, 'title', 50, 255, $itemObj->title(0, 'e')); $sform->addElement($title_text, true); if (SMARTSECTION_LEVEL >= 5) { // SUMMARY $summary_text = smartsection_getEditor(_AM_SSECTION_SUMMARY, 'summary', $itemObj->getVar('summary', 'e')); $summary_text->setDescription(_AM_SSECTION_SUMMARY_DSC); $sform->addElement($summary_text, false); // DISPLAY_SUMMARY $display_summary_radio = new XoopsFormRadioYN(_AM_SSECTION_DISPLAY_SUMMARY, 'display_summary', $itemObj->display_summary(), ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . ''); $sform->addElement($display_summary_radio); } // BODY /*if ($itemObj->address()) { // Main body : pagewrap $address_select = new XoopsFormSelect(_AM_SSECTION_BODY_SELECTFILE, "address", $itemObj->address()); $address_select->setDescription(_AM_SSECTION_BODY_SELECTFILE_DSC); $dir = smartsection_getUploadDir(true, 'content'); $folder = dir($dir); while($file = $folder->read()) { if ($file != "." && $file != "..") { $address_select->addOption($file, "".$file.""); } } $folder->close(); $sform->addElement($address_select); $sform->addElement(new XoopsFormHidden('body', '')); } else {*/ $body_text = smartsection_getEditor(_AM_SSECTION_BODY, 'body', $itemObj->getVar('body', 'e')); if (SMARTSECTION_LEVEL >= 5) { $body_text->setDescription(sprintf(_AM_SSECTION_BODY_DSC, SMARTSECTION_URL . "/admin/pagewrap_lookup.php")); } $sform->addElement($body_text); //} if (SMARTSECTION_LEVEL >= 5) { // Available pages to wrap $wrap_pages = XoopsLists::getHtmlListAsArray(smartsection_getUploadDir(true, 'content')); $available_wrap_pages_text = array(); foreach ($wrap_pages as $page) { $available_wrap_pages_text[] = "<span onclick='smartsectionPageWrap(\"body\", \"[pagewrap={$page}] \");' onmouseover='style.cursor=\"pointer\"'>{$page}</span>"; } $available_wrap_pages = new XoopsFormLabel(_AM_SSECTION_AVAILABLE_PAGE_WRAP, implode(', ', $available_wrap_pages_text)); $available_wrap_pages->setDescription(_AM_SSECTION_AVAILABLE_PAGE_WRAP_DSC); $sform->addElement($available_wrap_pages); // Tags if (smartsection_tag_module_included()) { include_once XOOPS_ROOT_PATH . "/modules/tag/include/formtag.php"; $text_tags = new XoopsFormTag("item_tag", 60, 255, $itemObj->getVar('item_tag', 'e'), 0); $sform->addElement($text_tags); } // IMAGE $image_array = XoopsLists::getImgListAsArray(smartsection_getImageDir('item')); $image_select = new XoopsFormSelect('', 'image', $itemObj->image()); //$image_select -> addOption ('-1', '---------------'); $image_select->addOptionArray($image_array); $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/smartsection/images/item/' . "\", \"\", \"" . XOOPS_URL . "\")'"); $image_tray = new XoopsFormElementTray(_AM_SSECTION_IMAGE_ITEM, ' '); $image_tray->addElement($image_select); $image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartsection_getImageDir('item', false) . $itemObj->image() . "' name='image3' id='image3' alt='' />")); $image_tray->setDescription(_AM_SSECTION_IMAGE_ITEM_DSC); $sform->addElement($image_tray); // IMAGE UPLOAD $max_size = 5000000; $image_file_box = new XoopsFormFile(_AM_SSECTION_IMAGE_UPLOAD, "image_file", $max_size); $image_file_box->setExtra("size ='50'"); $image_file_box->setDescription(_AM_SSECTION_IMAGE_UPLOAD_ITEM_DSC); $sform->addElement($image_file_box); } // File upload UPLOAD $file_box = new XoopsFormFile(smartsection_new_feature_tag() . _AM_SSECTION_ITEM_UPLOAD_FILE, "userfile", 0); $file_box->setDescription(_AM_SSECTION_ITEM_UPLOAD_FILE_DSC . smartsection_new_feature_tag()); $file_box->setExtra("size ='50'"); $sform->addElement($file_box); // Uid /* We need to retreive the users manually because for some reason, on the frxoops.org server, the method users::getobjects encounters a memory error */ $uid = $itemObj->uid(); $uid_select = new XoopsFormSelect(_AM_SSECTION_UID, 'uid', $uid, 1, false); $uid_select->setDescription(_AM_SSECTION_UID_DSC); $sql = "SELECT uid, uname FROM " . $xoopsDB->prefix('users') . " ORDER BY uname ASC"; $result = $xoopsDB->query($sql); $users_array = array(); $users_array[0] = $xoopsConfig['anonymous']; while ($myrow = $xoopsDB->fetchArray($result)) { $users_array[$myrow['uid']] = $myrow['uname']; } $uid_select->addOptionArray($users_array); $sform->addElement($uid_select); // Datesub $datesub = $itemObj->getVar('datesub') == 0 ? time() : $itemObj->getVar('datesub'); $datesub_datetime = new SmartsectionFormDateTime(_AM_SSECTION_DATESUB, 'datesub', $size = 15, $datesub); $datesub_datetime->setDescription(_AM_SSECTION_DATESUB_DSC); $sform->addElement($datesub_datetime); // STATUS $options = array(_SSECTION_STATUS_PUBLISHED => _AM_SSECTION_PUBLISHED, _SSECTION_STATUS_OFFLINE => _AM_SSECTION_OFFLINE, _SSECTION_STATUS_SUBMITTED => _AM_SSECTION_SUBMITTED, _SSECTION_STATUS_REJECTED => _AM_SSECTION_REJECTED); $status_select = new XoopsFormSelect(_AM_SSECTION_STATUS, 'status', $new_status); $status_select->addOptionArray($options); $status_select->setDescription(_AM_SSECTION_STATUS_DSC); $sform->addElement($status_select); if (SMARTSECTION_LEVEL > 0) { // Short url $text_short_url = new XoopsFormText(_AM_SSECTION_ITEM_SHORT_URL, 'short_url', 50, 255, $itemObj->short_url('e')); $text_short_url->setDescription(_AM_SSECTION_ITEM_SHORT_URL_DSC); $sform->addElement($text_short_url); // Meta Keywords $text_meta_keywords = new XoopsFormTextArea(_AM_SSECTION_ITEM_META_KEYWORDS, 'meta_keywords', $itemObj->meta_keywords('e'), 7, 60); $text_meta_keywords->setDescription(_AM_SSECTION_ITEM_META_KEYWORDS_DSC); $sform->addElement($text_meta_keywords); // Meta Description $text_meta_description = new XoopsFormTextArea(_AM_SSECTION_ITEM_META_DESCRIPTION, 'meta_description', $itemObj->meta_description('e'), 7, 60); $text_meta_description->setDescription(_AM_SSECTION_ITEM_META_DESCRIPTION_DSC); $sform->addElement($text_meta_description); } // WEIGHT $sform->addElement(new XoopsFormText(_AM_SSECTION_WEIGHT, 'weight', 5, 5, $itemObj->weight()), true); if (SMARTSECTION_LEVEL >= 5) { // COMMENTS $addcomments_radio = new XoopsFormRadioYN(_AM_SSECTION_ALLOWCOMMENTS, 'cancomment', $itemObj->cancomment(), ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . ''); $sform->addElement($addcomments_radio); } // PER ITEM PERMISSIONS $member_handler =& xoops_gethandler('member'); $group_list = $member_handler->getGroupList(); $groups_checkbox = new XoopsFormCheckBox(_AM_SSECTION_PERMISSIONS_ITEM, 'groups[]', $itemObj->getGroups_read()); $groups_checkbox->setDescription(_AM_SSECTION_PERMISSIONS_ITEM_DSC); foreach ($group_list as $group_id => $group_name) { if ($group_id != XOOPS_GROUP_ADMIN) { $groups_checkbox->addOption($group_id, $group_name); } } $sform->addElement($groups_checkbox); $p_view_checkbox = new XoopsFormCheckBox(_AM_SSECTION_PARTIAL_VIEW, 'partial_view[]', $itemObj->partial_view()); $p_view_checkbox->setDescription(_AM_SSECTION_PARTIAL_VIEWDSC); foreach ($group_list as $group_id => $group_name) { if ($group_id != XOOPS_GROUP_ADMIN) { $p_view_checkbox->addOption($group_id, $group_name); } } $sform->addElement($p_view_checkbox); /*$partial_view_radio = new XoopsFormRadioYN(_AM_SSECTION_PARTIAL_VIEW, 'partial_view', $itemObj->partial_view(), ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . ''); $partial_view_radio->setDescription(_AM_SSECTION_PARTIAL_VIEWDSC); $sform->addElement($partial_view_radio);*/ if (SMARTSECTION_LEVEL >= 5) { // VARIOUS OPTIONS $options_tray = new XoopsFormElementTray(_AM_SSECTION_OPTIONS, '<br />'); $html_checkbox = new XoopsFormCheckBox('', 'dohtml', $itemObj->dohtml()); $html_checkbox->addOption(1, _AM_SSECTION_DOHTML); $options_tray->addElement($html_checkbox); $smiley_checkbox = new XoopsFormCheckBox('', 'dosmiley', $itemObj->dosmiley()); $smiley_checkbox->addOption(1, _AM_SSECTION_DOSMILEY); $options_tray->addElement($smiley_checkbox); $xcodes_checkbox = new XoopsFormCheckBox('', 'doxcode', $itemObj->doxcode()); $xcodes_checkbox->addOption(1, _AM_SSECTION_DOXCODE); $options_tray->addElement($xcodes_checkbox); $images_checkbox = new XoopsFormCheckBox('', 'doimage', $itemObj->doimage()); $images_checkbox->addOption(1, _AM_SSECTION_DOIMAGE); $options_tray->addElement($images_checkbox); $linebreak_checkbox = new XoopsFormCheckBox('', 'dobr', $itemObj->dobr()); $linebreak_checkbox->addOption(1, _AM_SSECTION_DOLINEBREAK); $options_tray->addElement($linebreak_checkbox); $sform->addElement($options_tray); } // item ID if ($clone) { $itemid = 0; } $sform->addElement(new XoopsFormHidden('itemid', $itemid)); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'additem'); $button_tray->addElement($hidden); if (!$itemid) { // there's no itemid? Then it's a new item // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SSECTION_CREATE, 'submit' ) ); $butt_create = new XoopsFormButton('', '', _AM_SSECTION_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'additem\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SSECTION_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SSECTION_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $sform->addElement($button_tray); $sform->display(); smartsection_close_collapsable('createitemtable', 'createitemicon'); } else { // else, we're editing an existing item // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SSECTION_MODIFY, 'submit' ) ); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'additem\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SSECTION_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $sform->addElement($button_tray); $sform->display(); smartsection_close_collapsable('edititemtable', 'edititemicon'); } if (SMARTSECTION_LEVEL >= 5) { smartsection_collapsableBar('pagewraptable', 'pagewrapicon', _AM_SSECTION_PAGEWRAP, _AM_SSECTION_PAGEWRAPDSC); $dir = smartsection_getUploadDir(true, 'content'); if (!eregi("777", decoct(fileperms($dir)))) { echo "<font color='FF0000'><h4>" . _AM_SSECTION_PERMERROR . "</h4></font>"; } // Upload File echo "<form name='form_name2' id='form_name2' action='pw_upload_file.php' method='post' enctype='multipart/form-data'>"; echo "<table cellspacing='1' width='100%' class='outer'>"; echo "<tr><th colspan='2'>" . _AM_SSECTION_UPLOAD_FILE . "</th></tr>"; echo "<tr valign='top' align='left'><td class='head'>" . _AM_SSECTION_SEARCH_PW . "</td><td class='even'><input type='file' name='fileupload' id='fileupload' size='30' /></td></tr>"; echo "<tr valign='top' align='left'><td class='head'><input type='hidden' name='MAX_FILE_SIZE' id='op' value='500000' /></td><td class='even'><input type='submit' name='submit' value='" . _AM_SSECTION_UPLOAD . "' /></td></tr>"; echo "<input type='hidden' name='backto' value='{$smartsection_current_page}'/>"; echo "</table>"; echo "</form>"; // Delete File $form = new XoopsThemeForm(_AM_SSECTION_DELETEFILE, "form_name", "pw_delete_file.php"); $pWrap_select = new XoopsFormSelect(smartsection_getUploadDir(true, 'content'), "address"); $folder = dir($dir); while ($file = $folder->read()) { if ($file != "." && $file != "..") { $pWrap_select->addOption($file, $file); } } $folder->close(); $form->addElement($pWrap_select); $delfile = "delfile"; $form->addElement(new XoopsFormHidden('op', $delfile)); $submit = new XoopsFormButton("", "submit", _AM_SSECTION_BUTTON_DELETE, "submit"); $form->addElement($submit); $form->addElement(new XoopsFormHidden('backto', $smartsection_current_page)); $form->display(); smartsection_close_collapsable('pagewraptable', 'pagewrapicon'); } unset($hidden); if ($itemid != 0) { showfiles($itemObj); } }