/** * * * Analogue of adodb GetMenu2, but display referenced values (using getvalues) * */ function GetValuesMenu($db, $selectname, $selected, $tablename, $columnname, $whereclause = false, $jscript = false) { global $max_menu_length; $tableinfo = new tableinfo($db, $tablename); $r = $db->Execute("SELECT id FROM {$tablename} {$whereclause}"); while ($r && !$r->EOF) { $values[] = getvalues($db, $tableinfo, $columnname, 'id', $r->fields[0]); $r->MoveNext(); } $text = "<select name='{$selectname}' {$jscript}>\n"; $text .= "<option value=''></option>\n"; if (is_array($values)) { foreach ($values as $value) { $v["{$value[0]['recordid']}"] = $value[0]['text']; } asort($v); while (list($key, $val) = each($v)) { if ($key == $selected) { $selecttext = 'selected'; } else { $selecttext = false; } $text .= "<option {$selecttext} value='{$key}'>{$val}</option>\n"; } } $text .= "</select>\n"; return $text; }
/** * * * return a single entry for a report * */ function test_report($db, $offset, $tablename) { global $_POST, $_GET, $system_settings; $_GET['tablename'] = $tablename; $tableinfo = new tableinfo($db); $real_tablename = get_cell($db, "tableoftables", "real_tablename", "tablename", $tablename); $reportid = $_POST["report_id"][$offset]; $r = $db->Execute("SELECT * FROM {$real_tablename}"); $fields = comma_array_SQL($db, $tableinfo->desname, "columnname"); $Allfields = getvalues($db, $tableinfo, $fields, "id", $r->fields["id"]); $tp = @fopen($system_settings["templatedir"] . "/{$reportid}.tpl", "r"); if ($tp) { while (!feof($tp)) { $template .= fgets($tp, 64000); } fclose($tp); } require './includes/report_inc.php'; $report = make_report($db, $template, $Allfields, $tableinfo, 1); return $report; }
/** * Checks if these values exist in the mpulldown table * Adds them if they do not exist. * Makes the needed links in the ass table linking data and mpulldown tables */ function addmpulldown($db, $tableinfo, $id, $to_field, $field) { /** * Analyze $field first, accept <br> as field seperators */ $Allfields = getvalues($db, $tableinfo, $to_field); $fields = explode('<br>', $field); foreach ($fields as $value) { /** * Checks if this value is already in the mpulldown table, if not, add it: */ if ($value && $value != ' ') { $r = $db->Execute("SELECT id FROM {$Allfields[0]['ass_t']} WHERE type='{$value}' OR typeshort='{$value}'"); $rassid = $r->fields[0]; if (!$rassid) { /** * Value not found, insert it now */ $rassid = $db->genID($Allfields[0]['ass_t'] . '_id_seq'); $r = $db->query("INSERT INTO {$Allfields[0]['ass_t']} (id,type,typeshort)\n VALUES({$rassid},'{$value}','{$value}')"); } // now link make the links in the keytable if ($rassid) { $db->Execute("INSERT INTO {$Allfields[0]['key_t']} (recordid,typeid) VALUES ({$id},{$rassid})"); } } } }
$fields = preg_replace('/,id/', '', $fields); $headers = getvalues($db, $tableinfo, $fields); if ($_GET['valuesOnly']) { $valuesOnly = true; } foreach ($headers as $header) { if ($header['label']) { fwrite($fp, $pre_seperator . $header['label'] . $post_seperator); } else { fwrite($fp, $pre_seperator . 'id' . $post_seperator); } } fwrite($fp, "\n"); $r = $db->Execute("SELECT {$fields} FROM " . $tableinfo->realname); while ($r->fields['id'] && !$r->EOF) { $rowvalues = getvalues($db, $tableinfo, $fields, 'id', $r->fields['id']); foreach ($rowvalues as $row) { if (is_array($row)) { // files will be exported to the directory files if ($row['datatype'] == 'file') { $files = get_files($db, $tableinfo->name, $row['recordid'], $row['columnid'], 0); fwrite($fp, $pre_seperator); for ($i = 0; $i < sizeof($files); $i++) { $filecounter++; // write a temp table with all the file info,and provide an comma separated list of ids to that table here fwrite($ff, ++$filenr . "\t" . $files[$i]['name'] . "\t" . $files[$i]['mime'] . "\t" . $files[$i]['size'] . "\t" . $files[$i]['type'] . "\n"); fwrite($fp, $filenr . ','); $path = file_path($db, $files[$i]['id']); // $cpstr="cp $path {$filedir}{$filenr}_{$files[$i]['name']}"; //`$cpstr`; copy($path, "{$filedir}{$filenr}_{$files[$i]['name']}");
function print_scripts($id, $container, $language, $style, $views, $buttons, $edition, $sample, $otherparamsvalue, $palette, $viewdefault, $numberOfMonths, $start_weekday, $notPlugin, $matches) { global $JC_JQUERY_SPECIAL; $mainframe = JFactory::getApplication(); $msg = ""; if ($id == -1) { $user =& JFactory::getUser(); $db =& JFactory::getDBO(); $db->setQuery('SELECT * FROM #__dc_mv_calendars where owner=' . $user->id); $rows1 = $db->loadObjectList(); if (count($rows1) > 0) { $id = $rows1[0]->id; } else { $id = "none"; $msg = "No calendar found for this user"; } } if (!is_numeric($id) && $msg == "") { $msg = "No calendar found"; } if ($msg == "") { $document =& JFactory::getDocument(); if (JC_JQUERY_MV) { $document->addScript("components/com_multicalendar/DC_MultiViewCal/js/jquery-1.7.2.min.js"); } if (JC_JQUERY_UI_MV) { $document->addScript("components/com_multicalendar/DC_MultiViewCal/js/jquery-ui-1.8.20.custom.min.js"); } if (count($JC_JQUERY_SPECIAL) > 0) { for ($i = 0; $i < count($JC_JQUERY_SPECIAL); $i++) { if (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off") { $JC_JQUERY_SPECIAL[$i] = str_replace("http://", "https://", $JC_JQUERY_SPECIAL[$i]); } $document->addScript($JC_JQUERY_SPECIAL[$i]); } } $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/underscore.js"); $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/rrule.js"); $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/Common.js"); if (file_exists("components/com_multicalendar/DC_MultiViewCal/language/multiview_lang_" . $language . ".js")) { $document->addScript("components/com_multicalendar/DC_MultiViewCal/language/multiview_lang_" . $language . ".js"); } else { $document->addScript("components/com_multicalendar/DC_MultiViewCal/language/multiview_lang_en-GB.js"); } $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/jquery.calendar.js"); $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/jquery.alert.js"); $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/multiview.js"); if (file_exists("components/com_multicalendar/DC_MultiViewCal/css/" . $style . "/calendar.css")) { $document->addStyleSheet("components/com_multicalendar/DC_MultiViewCal/css/" . $style . "/calendar.css"); } else { $document->addStyleSheet("components/com_multicalendar/DC_MultiViewCal/css/cupertino/calendar.css"); } $document->addStyleSheet("components/com_multicalendar/DC_MultiViewCal/css/main.css"); if (!$notPlugin) { if (!function_exists('getvalues')) { function getvalues($param, $ar) { if (!is_array($param)) { $param = array(); } for ($i = 0; $i < count($ar); $i++) { if (count($param) <= $i || $param[$i] != $ar[$i]) { array_splice($param, $i, 0, "false"); } else { $param[$i] = "true"; } } return $param; } } $view = getvalues($views, array("viewDay", "viewWeek", "viewMonth", "viewNMonth", "viewList")); $buttons = getvalues($buttons, array("btoday", "bnavigation", "brefresh")); $edition = $edition == "1" ? "true" : "false"; $nmonths = $sample; if ($nmonths[0] != '1') { array_splice($nmonths, 0, 0, "false"); } else { $nmonths[0] = "true"; } if ($nmonths[1] != 'mouseover') { $nmonths[1] = 1; } else { $nmonths[1] = 0; } if ($nmonths[2] != '1') { array_splice($nmonths, 2, 0, "false"); } else { $nmonths[2] = "true"; } if ($nmonths[1] == 1) { $nmonths[2] = "false"; } if ($nmonths[4] != 'new_window') { $nmonths[4] = 1; } else { $nmonths[4] = 0; } } else { $view = array(); $view[] = (int) $matches[2][0] == 1 ? "true" : "false"; $view[] = (int) $matches[2][1] == 1 ? "true" : "false"; $view[] = (int) $matches[2][2] == 1 ? "true" : "false"; $view[] = (int) $matches[2][3] == 1 ? "true" : "false"; $view[] = (int) $matches[2][4] == 1 ? "true" : "false"; $buttons = array(); $buttons[] = (int) $matches[7][0] == 1 ? "true" : "false"; $buttons[] = (int) $matches[7][1] == 1 ? "true" : "false"; $buttons[] = (int) $matches[7][2] == 1 ? "true" : "false"; $edition = $edition == "1" ? "true" : "false"; $nmonths = array(); $nmonths[] = (int) $matches[9] == 1 ? "true" : "false"; $nmonths[] = (string) $matches[10] != "mouseover" ? "1" : "0"; $nmonths[] = (int) $matches[11] == 1 ? "true" : "false"; $nmonths[] = $matches[13]; $nmonths[] = (string) $matches[12] != "new_window" ? "1" : "0"; } $otherparams = trim($otherparamsvalue); $otherparams = str_replace("\n", "", $otherparams); $otherparams = str_replace("\r", "", $otherparams); $newp = ""; if ($otherparams != "") { $p = explode(",", $otherparams); for ($i = 0; $i < count($p); $i++) { if (trim($p[$i]) != "") { $newp .= ", " . $p[$i]; } } } $user =& JFactory::getUser(); $db =& JFactory::getDBO(); $db->setQuery('SELECT * FROM #__dc_mv_calendars where id=' . $id); $rows = $db->loadObjectList(); if (count($rows) > 0) { $p = explode(";", $rows[0]->permissions); if (isValid($p[0], $p[1], $user->getAuthorisedGroups(), $user->id)) { $newp .= ", userAdd:true"; } else { $newp .= ", userAdd:false"; } if (isValid($p[2], $p[3], $user->getAuthorisedGroups(), $user->id)) { $newp .= ", userEdit:true"; } else { $newp .= ", userEdit:false"; } if (isValid($p[4], $p[5], $user->getAuthorisedGroups(), $user->id)) { $newp .= ", userDel:true"; } else { $newp .= ", userDel:false"; } if (isValidOwner($p[2])) { $newp .= ", userEditOwner:true"; } else { $newp .= ", userEditOwner:false"; } if (isValidOwner($p[4])) { $newp .= ", userDelOwner:true"; } else { $newp .= ", userDelOwner:false"; } $newp .= ", userOwner:" . $user->id . ""; } $db->setQuery("select * from #__dc_mv_configuration where id=1"); $configuration = $db->loadObjectList(); $administration = unserialize($configuration[0]->administration); $palettes = unserialize($configuration[0]->palettes); if (count($palettes) > $palette) { $newp .= ", palette:" . $palette . ""; $newp .= ", paletteDefault:\"" . $palettes[$palette]["default"] . "\""; } $document->addScriptDeclaration(getlist("dc_subjects", $rows[0]->subjectlist, $administration["subjectlist"]) . getlist("dc_locations", $rows[0]->locationlist, $administration["locationlist"])); $p = parse_url(JURI::root()); if (strlen($p["path"]) > 0 && $p["path"][strlen($p["path"]) - 1] == "/") { $p["path"] = substr($p["path"], 0, strlen($p["path"]) - 1); } $path = $p["path"]; $showtooltipdwm_mouseover = "false"; $showtooltipdwm = "false"; if ($nmonths[0] == 'true') { if ($nmonths[1] != 1) { $showtooltipdwm_mouseover = 'true'; } else { $showtooltipdwm = 'true'; } } $document->addScriptDeclaration("initMultiViewCal(\"" . $container . "\"," . $id . ",{viewDay:" . $view[0] . ",viewWeek:" . $view[1] . ",viewMonth:" . $view[2] . ",viewNMonth:" . $view[3] . ",viewList:" . $view[4] . ",viewdefault:\"" . $viewdefault . "\",numberOfMonths:" . $numberOfMonths . ",showtooltip:" . $nmonths[0] . ",tooltipon:" . $nmonths[1] . ",shownavigate:" . $nmonths[2] . ",url:\"" . $nmonths[3] . "\",target:" . $nmonths[4] . ",showtooltipdwm_mouseover:" . $showtooltipdwm_mouseover . ",showtooltipdwm:" . $showtooltipdwm . ",start_weekday:" . $start_weekday . ",language:\"" . $language . "\",cssStyle:\"" . $style . "\",edition:" . $edition . ",btoday:" . $buttons[0] . ",bnavigation:" . $buttons[1] . ",brefresh:" . $buttons[2] . ",bnew:" . $edition . ",path:\"" . $path . "/\"" . $newp . "});"); } return $msg; }
/** * Searches (nested) for a match with $value * * returns the id of the record in the associated value by searching recursively * that can be used in a SQL search */ function find_nested_match($db, $tableinfo, $field, $value, $first = true) { $info = getvalues($db, $tableinfo, $field); if ($info[0]['datatype'] == 'table') { $ass_tableinfo = new tableinfo($db, $info[0]['ass_table_name']); $value = find_nested_match($db, $ass_tableinfo, $info[0]['ass_column_name'], $value, false); } elseif ($info[0]['datatype'] == 'int') { $value = trim($value); // I am getting desperate, but the browser inserts junk in the first postions, test if it is a number, if not, delete it. if (!is_numeric($value[0])) { $value = substr($value, 1); } return get_cell($db, $tableinfo->realname, 'id', $field, (int) $value); } elseif ($info[0]['datatype'] == 'float') { $value = trim($value); if (!is_numeric($value[0])) { $value = substr($value, 1); } return get_cell($db, $tableinfo->realname, 'id', $field, (double) $value); } elseif ($info[0]['datatype'] == 'pulldown') { $value = get_cell($db, $info[0]['ass_t'], 'id', 'typeshort', $value); return get_cell($db, $tableinfo->realname, 'id', $field, $value); } elseif (!$first) { return get_cell($db, $tableinfo->realname, 'id', $field, $value); } return $value; }
if ($reportid > 0) { echo make_report($db, $template, $Allfields, $tableinfo, $USER['settings']['reportoutput'], $counter); } elseif ($reportid == -1) { echo make_xml($db, $Allfields, $tableinfo); } elseif ($reportid == -2) { echo make_sheet($db, $Allfields, $tableinfo, $USER['settings']['reportoutput'], $Fieldscomma, "\t", false); } elseif ($reportid == -3) { echo make_sheet($db, $Allfields, $tableinfo, $USER['settings']['reportoutput'], $Fieldscomma, ',', false); } $r->MoveNext(); $counter++; } if ($reportid > 0) { foreach ($Allfields as $column) { if ($column['name']) { //$sums is defined as global in function make_reports. It sums whatever it finds while looping through the records it displays. All occurences of '&fieldname' in the footer will be replaced with the sum of the rows. $footer = str_replace("&" . $column['name'], $sums[$column['name']], $footer); } } echo $footer; } elseif ($reportid == -1) { echo '</' . "phplabware_base>\n>"; } } } else { // just a single record $fields = comma_array_SQL($db, $tableinfo->desname, 'columnname'); $Allfields = getvalues($db, $tableinfo, $fields, 'id', $recordid); $report = make_report($db, $template, $Allfields, $tableinfo); echo $report; }
} echo "</tr>\n</table>\n"; next_previous_buttons($rp, true, $num_p_r, $numrows, ${$pagename}, $db, $tableinfo, $viewid); // get a list with ids we may see, $listb has all the ids we may see if ($db_type == 'mysql') { $lista = make_SQL_csf($r, false, 'id', $nr_records); if (!$lista) { $lista = "-1"; } $lista = " id IN ({$lista}) "; } else { make_temp_table($db, 'tempa', $r); $lista = " ({$tableinfo->realname}.id=tempa.uniqueid) "; } // get a list of all fields that are displayed in the table $Allfields = getvalues($db, $tableinfo, $Fieldscomma, false, false); // javascript to automatically execute search when pulling down $jscript = "onChange='document.g_form.searchj.value=\"Search\"; document.g_form.submit()'"; echo "<input type='hidden' name='searchj' value=''>\n"; // print header of table echo "<table border='1' align='center'>\n"; // row with search form echo "<tr align='center'>\n"; foreach ($Allfields as $nowfield) { if ($_GET[$nowfield['name']]) { $list = $listb['sql']; $count = $listb['numrows']; } else { $list = $lista; $count = $listb['numrows']; }