/** @param $item_r where provided will give the item_id / instance_no, where not provided is safe to assume that this is a new item insert field and this information is not relevant. */ function url($name, $item_r, $item_attribute_type_r, $prompt, $length, $maxlength, $content_groups, $value, $onchange_event, $disabled = FALSE, $multi_value = FALSE) { // Default size. $size = $length; if (!is_numeric($size) || $size <= 0) { $size = 50; } if (get_opendb_config_var('widgets', 'enable_javascript_validation') !== FALSE) { if (strlen(trim($content_groups)) > 0) { // might be an array of content groups $content_group_r = prc_args($content_groups); $extensions_r = fetch_file_type_extensions_r($content_group_r); if (is_not_empty_array($extensions_r)) { $extensions = implode(', ', $extensions_r); } else { // else just list of extensions otherwise $extensions = $content_groups; $extensions_r = $content_group_r; } $url_is_not_valid_message = addslashes(get_opendb_lang_var('url_is_not_valid', array('prompt' => $prompt, 'extensions' => $extensions))); $onchange = "onchange=\"if(!isValidExtension(this.value, " . encode_javascript_array($extensions_r) . ")){alert('" . $url_is_not_valid_message . "'); this.focus(); return false;} {$onchange_event} return true;\""; } } else { $onchange = "onchange=\"{$onchange_event}\""; } if ($item_attribute_type_r['file_attribute_ind'] == 'Y') { $field .= "\n<ul class=\"urlOptionsMenu\" id=\"{$name}-tab-menu\" class=\"file-upload-menu\">"; $field .= "<li id=\"menu-{$name}_saveurl\" class=\"activeTab\" onclick=\"return activateTab('{$name}_saveurl', '{$name}-tab-menu', '{$name}-tab-content', 'activeTab', 'fieldContent');\">URL</li>"; if (is_file_upload_enabled()) { $field .= "<li id=\"menu-{$name}_upload\" onclick=\"return activateTab('{$name}_upload', '{$name}-tab-menu', '{$name}-tab-content', 'activeTab', 'fieldContent');\">Upload File</li>"; } $field .= "</ul>"; $field .= "<div class=\"urlOptionsContainer\" id=\"{$name}-tab-content\">"; $field .= "\n<div class=\"fieldContent\" id=\"{$name}_saveurl\">"; $field .= "<input type=\"text\" class=\"text\" name=\"{$name}\" value=\"{$value}\" {$onchange} size=\"" . $length . "\" " . (is_numeric($maxlength) ? "maxlength=\"" . $maxlength . "\"" : "") . ">"; $field .= "<input type=\"button\" class=\"button\" onclick=\"if(this.form['{$name}'].value.length>0){popup(this.form['{$name}'].value,'400','300');}else{alert('" . get_opendb_lang_var('prompt_must_be_specified', 'prompt', $prompt) . "');}\" value=\"" . get_opendb_lang_var('view') . "\"" . ($disabled ? ' DISABLED' : '') . ">"; $field .= "</div>"; if (is_file_upload_enabled()) { $field .= "<div class=\"fieldContentHidden\" id=\"{$name}_upload\">"; $field .= "<input type=\"file\" class=\"file\" name=\"{$name}_upload\" {$onchange} size=\"" . $size . "\"" . ($disabled ? ' DISABLED' : '') . ">"; $field .= "</div>"; } $field .= '</div>'; } else { if ($multi_value) { return multivalue_text_field('text', $name, $size, $maxlength, $onchange, $value); } else { return singlevalue_text_field('text', $name, $size, $maxlength, $onchange, $value, $disabled); } } return $field; }
} else { $page_title = get_opendb_lang_var('import_items_for_name', array('fullname' => fetch_user_name($HTTP_VARS['owner_id']), 'user_id' => $HTTP_VARS['owner_id'])); } } else { $page_title = get_opendb_lang_var('import_items'); } echo _theme_header($page_title); echo "<h2>" . $page_title . "</h2>"; echo get_upload_form($HTTP_VARS); echo _theme_footer(); } } } } else { // if(is_file_upload_enabled() && import_check_is_installed()) if (is_file_upload_enabled()) { echo _theme_header(get_opendb_lang_var('import_not_available')); echo "<p class=\"error\">" . get_opendb_lang_var('import_not_available') . "</p>"; opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Import cache table not installed.'); } else { echo _theme_header(get_opendb_lang_var('file_upload_not_available')); echo "<p class=\"error\">" . get_opendb_lang_var('file_upload_not_available') . "</p>"; } } } else { //not an administrator or own user. opendb_not_authorised_page(array(PERM_USER_IMPORT, PERM_ADMIN_IMPORT)); } } else { //invalid session // invalid login, so login instead.
function get_menu_options($user_id) { $menu_options = array(); if (is_user_granted_permission(PERM_ITEM_OWNER, $user_id)) { $menu_options['items'][] = array(link => get_opendb_lang_var('add_new_item'), url => "item_input.php?op=site-add&owner_id={$user_id}"); $menu_options['listings'][] = array(link => get_opendb_lang_var('list_my_items'), url => "listings.php?owner_id={$user_id}"); } if (is_user_granted_permission(PERM_VIEW_LISTINGS)) { $menu_options['listings'][] = array(link => get_opendb_lang_var('list_all_items'), url => "listings.php"); } if (is_file_upload_enabled()) { if (is_user_granted_permission(PERM_ADMIN_IMPORT, $user_id)) { $menu_options['items'][] = array(link => get_opendb_lang_var('import_items'), url => "import.php"); } else { if (is_user_granted_permission(PERM_USER_IMPORT, $user_id)) { $menu_options['items'][] = array(link => get_opendb_lang_var('import_my_items'), url => "import.php"); } } } if (is_user_granted_permission(PERM_ADMIN_EXPORT, $user_id)) { $menu_options['items'][] = array(link => get_opendb_lang_var('export_items'), url => "export.php"); } else { if (is_user_granted_permission(PERM_USER_EXPORT, $user_id)) { $menu_options['items'][] = array(link => get_opendb_lang_var('export_my_items'), url => "export.php"); } } if (get_opendb_config_var('borrow', 'enable') !== FALSE) { if (is_exists_borrowed() && is_user_granted_permission(PERM_ADMIN_BORROWER, $user_id)) { $menu_options['borrow'][] = array(link => get_opendb_lang_var('items_borrowed'), url => "borrow.php?op=all_borrowed"); } if (is_exists_reserved() && is_user_granted_permission(PERM_ADMIN_BORROWER, $user_id)) { $menu_options['borrow'][] = array(link => get_opendb_lang_var('items_reserved'), url => "borrow.php?op=all_reserved"); } if (is_exists_borrower_history($user_id) && is_user_granted_permission(PERM_USER_BORROWER, $user_id)) { $menu_options['borrow'][] = array(link => get_opendb_lang_var('my_history'), url => "borrow.php?op=my_history"); } if (is_exists_borrower_borrowed($user_id) && is_user_granted_permission(PERM_USER_BORROWER, $user_id)) { $menu_options['borrow'][] = array(link => get_opendb_lang_var('my_borrowed_items'), url => "borrow.php?op=my_borrowed"); } if (is_exists_borrower_reserved($user_id) && is_user_granted_permission(PERM_USER_BORROWER, $user_id)) { $menu_options['borrow'][] = array(link => get_opendb_lang_var('my_reserved_items'), url => "borrow.php?op=my_reserved"); } if (get_opendb_config_var('borrow', 'reserve_basket') !== FALSE && is_exists_my_reserve_basket($user_id)) { $menu_options['borrow'][] = array(link => get_opendb_lang_var('item_reserve_list'), url => "borrow.php?op=my_reserve_basket&order_by=title&sortorder=ASC"); } if (is_user_granted_permission(PERM_ITEM_OWNER, $user_id)) { if (is_exists_owner_reserved($user_id)) { $menu_options['borrow'][] = array(link => get_opendb_lang_var('check_out_item(s)'), url => "borrow.php?op=owner_reserved"); } if (is_exists_owner_borrowed($user_id)) { $menu_options['borrow'][] = array(link => get_opendb_lang_var('check_in_item(s)'), url => "borrow.php?op=owner_borrowed"); } } if (is_user_granted_permission(PERM_ADMIN_BORROWER, $user_id)) { if (is_exists_history()) { $menu_options['borrow'][] = array(link => get_opendb_lang_var('borrower_history'), url => "borrow.php?op=admin_history"); } $menu_options['borrow'][] = array(link => get_opendb_lang_var('quick_check_out'), url => "quick_checkout.php?op=checkout"); $menu_options['borrow'][] = array(link => get_opendb_lang_var('quick_check_in'), url => "quick_checkout.php?op=checkin"); } } if (is_user_granted_permission(PERM_VIEW_ADVANCED_SEARCH)) { $menu_options['search'][] = array(link => get_opendb_lang_var('advanced_search'), url => "search.php"); } if (is_user_granted_permission(PERM_VIEW_STATS)) { $menu_options['stats'][] = array(link => get_opendb_lang_var('statistics'), url => "stats.php"); } if (is_exists_opendb_rss_feeds()) { $menu_options['feeds'][] = array(link => get_opendb_lang_var('rss_feeds'), url => "rss.php"); } if (is_user_granted_permission(PERM_EDIT_USER_PROFILE, $user_id)) { $menu_options['users'][] = array(link => get_opendb_lang_var('edit_my_info'), url => "user_admin.php?op=edit&user_id={$user_id}"); } if (get_opendb_config_var('user_admin', 'user_passwd_change_allowed') !== FALSE && is_user_granted_permission(PERM_CHANGE_PASSWORD, $user_id)) { $menu_options['users'][] = array(link => get_opendb_lang_var('change_my_password'), url => "user_admin.php?op=change_password&user_id={$user_id}"); } if (is_user_granted_permission(PERM_ADMIN_USER_LISTING, $user_id)) { if (is_exist_users_not_activated()) { $menu_options['users'][] = array(link => get_opendb_lang_var('activate_users'), url => "user_listing.php?restrict_active_ind=X&order_by=fullname&sortorder=ASC"); } $menu_options['users'][] = array(link => get_opendb_lang_var('user_list'), url => "user_listing.php?order_by=fullname&sortorder=ASC"); } if (is_user_granted_permission(PERM_ADMIN_CREATE_USER, $user_id)) { $menu_options['users'][] = array(link => get_opendb_lang_var('add_new_user'), url => "user_admin.php?op=new_user"); } if (is_user_granted_permission(PERM_ADMIN_CHANGE_USER, $user_id)) { $menu_options['users'][] = array(link => get_opendb_lang_var('change_user'), url => "user_admin.php?op=change_user"); } if (is_user_granted_permission(PERM_ADMIN_SEND_EMAIL, $user_id)) { if (is_valid_opendb_mailer()) { $menu_options['users'][] = array(link => get_opendb_lang_var('email_users'), url => "email.php?op=send_to_all"); } } if (is_user_granted_permission(PERM_ADMIN_TOOLS, $user_id)) { $menu_options['admin_tools'][] = array(link => get_opendb_lang_var('admin_tools'), url => "admin.php"); } return $menu_options; }
function get_edit_form($op, $item_r, $status_type_r, $HTTP_VARS) { global $PHP_SELF; // Work out $op value to submit. if ($op == 'edit' || $op == 'refresh' || $op == 'newinstance') { $op2 = 'update'; } else { if ($op == 'new' || $op == 'site' || $op == 'clone_item') { $op2 = 'insert'; } else { $op2 = $op; } } // last resort! $formContents = get_edit_item_form($op, $item_r, $HTTP_VARS, $upload_file_fields); if ($formContents !== FALSE) { $pageContents = ''; $pageContents .= "<div class=\"tabContainer\">"; if ($upload_file_fields && is_file_upload_enabled()) { $pageContents .= "\n<form name=\"itemInput\" action=\"{$PHP_SELF}\" method=\"POST\" enctype=\"multipart/form-data\">"; } else { $pageContents .= "\n<form action=\"{$PHP_SELF}\" method=\"POST\">"; } if (get_opendb_config_var('widgets', 'enable_javascript_validation') !== FALSE) { $onclick_event = "if(!checkForm(this.form)){return false;}else{this.form.submit();}"; } else { $onclick_event = "this.form.submit();"; } $pageContents .= "<ul class=\"tabMenu\" id=\"tab-menu\">"; $pageContents .= "<li id=\"menu-details\" class=\"first activeTab\" onclick=\"return activateTab('details');\">" . get_opendb_lang_var('details') . "</li>"; $pageContents .= "<li id=\"menu-instance_info\" onclick=\"return activateTab('instance_info');\">" . get_opendb_lang_var('instance_info') . "</li>"; $pageContents .= "</ul>"; $pageContents .= "<div id=\"tab-content\">"; $pageContents .= "<ul class=\"saveButtons\">\n\t\t\t\t<li><input type=\"button\" class=\"button\" onclick=\"{$onclick_event}\" value=\"" . get_opendb_lang_var('save_item') . "\"></li>\n\t\t\t</ul>"; $pageContents .= "<div class=\"tabContent\" id=\"details\">"; $pageContents .= "\n<input type=\"hidden\" name=\"op\" value=\"{$op2}\">"; $pageContents .= "\n<input type=\"hidden\" name=\"start-op\" value=\"{$op}\">"; $pageContents .= "\n<input type=\"hidden\" name=\"s_item_type\" value=\"" . $item_r['s_item_type'] . "\">"; $pageContents .= "\n<input type=\"hidden\" name=\"parent_item_id\" value=\"" . $HTTP_VARS['parent_item_id'] . "\">"; $pageContents .= "\n<input type=\"hidden\" name=\"parent_instance_no\" value=\"" . $HTTP_VARS['parent_instance_no'] . "\">"; if ($op == 'clone_item' || is_not_empty_array($item_r)) { if (is_numeric($item_r['item_id'])) { $pageContents .= "\n<input type=\"hidden\" name=\"item_id\" value=\"" . $item_r['item_id'] . "\">"; } if (is_numeric($item_r['instance_no'])) { $pageContents .= "\n<input type=\"hidden\" name=\"instance_no\" value=\"" . $item_r['instance_no'] . "\">"; } } if (strlen($HTTP_VARS['owner_id']) > 0) { $pageContents .= "\n<input type=\"hidden\" name=\"owner_id\" value=\"" . $HTTP_VARS['owner_id'] . "\">"; } $pageContents .= $formContents; $action_links_rs = NULL; $pageContents .= "<ul class=\"saveButtons\">\n\t\t<li><input type=\"button\" class=\"button\" onclick=\"{$onclick_event}\" value=\"" . get_opendb_lang_var('save_item') . "\"></li>\n\t\t\t</ul>"; if (is_not_empty_array($action_links_rs)) { $pageContents .= format_footer_links($action_links_rs); } $pageContents .= "</div>"; $pageContents .= get_edit_item_instance_form($op, $item_r, $status_type_r, $HTTP_VARS); $pageContents .= "</div>"; $pageContents .= "</form>"; $pageContents .= "</div>"; return $pageContents; } else { return FALSE; } }