本文整理汇总了PHP中lcm_panic函数的典型用法代码示例。如果您正苦于以下问题:PHP lcm_panic函数的具体用法?PHP lcm_panic怎么用?PHP lcm_panic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lcm_panic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDataString
function setDataString($field, $value)
{
if (!is_string($value)) {
lcm_panic("Incorrect format: value is not a string.");
}
$this->data[$field] = $value;
}
示例2: panic_not_implemented
function panic_not_implemented($table1, $table2)
{
// [ML] Eventually we should print a more user-friendly message,
// but for now, lcm_panic() is the easiest to debug.
$GLOBALS['errors']['join'] = "Report not implemented: join of {$table1} and {$table2}.\n\tPlease write to legalcase-devel@lists.sf.net and explain the report you are\n\ttrying to generate. If possible, please send a sample report with fictive\n\tvalues. It is possible that either it is possible to generate this report\n\tby another way, or that it may be necessary to write a custom report.";
lcm_panic($GLOBALS['errors']['join']);
}
示例3: read_author_data
function read_author_data($id_author)
{
$q = "SELECT * FROM lcm_author WHERE id_author=" . $id_author;
$result = lcm_query($q);
if (!($usr = lcm_fetch_array($result))) {
lcm_panic("The user #{$id_author} does not exist in the database.");
}
return $usr;
}
示例4: upgrade_db_version
function upgrade_db_version($version, $test = true)
{
if ($test) {
write_meta('lcm_db_version', $version);
lcm_log("Upgraded database to version: {$version}", 'upgrade');
} else {
// DEPRECATED ?
include_lcm('inc_lang');
lcm_panic(_T('install_warning_update_impossible', array('db_version' => $version)));
exit;
}
}
示例5: update_keyword
function update_keyword($id_keyword)
{
$kw_title = _request('kw_title');
$kw_name = _request('kw_name');
// only for new keyword
$kw_desc = _request('kw_desc');
$kw_ac_author = _request('kw_ac_author');
// show/hide keyword
$kw_hasvalue = _request('kw_hasvalue');
// show field to enter text value
$kw_idgroup = intval(_request('id_group'));
//
// Check for errors
//
if (!$id_keyword) {
// new keyword
global $system_kwg;
if (!$kw_idgroup) {
lcm_panic("update_keyword: missing or badly formatted id_keyword or id_group");
}
$kwg_info = get_kwg_from_id($kw_idgroup);
if (!$kw_name) {
$_SESSION['errors']['name'] = _Ti('keywords_input_name') . _T('warning_field_mandatory');
}
if (isset($system_kwg[$kwg_info['name']]['keywords'][$kw_name])) {
// XXX [ML] what about user keywords?
$_SESSION['errors']['name'] = _Ti('keywords_input_name') . _T('keywords_warning_kw_code_exists');
}
}
if (!$kw_title) {
$_SESSION['errors']['title'] = _Ti('keywords_input_name') . _T('warning_field_mandatory');
}
if (count($_SESSION['errors'])) {
lcm_header("Location: " . $_SERVER['HTTP_REFERER']);
exit;
}
//
// Apply to database
//
$fl = "description = '{$kw_desc}',\n\t\t\ttitle = '{$kw_title}' ";
if ($kw_ac_author == 'Y' || $kw_ac_author == 'N') {
$fl .= ", ac_author = '{$kw_ac_author}'";
}
if ($kw_hasvalue == 'Y' || $kw_hasvalue == 'N') {
$query .= ", hasvalue = '{$kw_hasvalue}'";
}
if (!$id_keyword) {
// new
$query = "INSERT INTO lcm_keyword\n\t\t\t\tSET id_group = {$kw_idgroup}, \n\t\t\t\t\tname = '{$kw_name}',\n\t\t\t\t\t{$fl} ";
lcm_query($query);
$id_keyword = lcm_insert_id('lcm_keyword', 'id_keyword');
$kw_info = get_kw_from_id($id_keyword);
// for redirection later
} else {
// Get current info about keyword (don't trust the user)
$kw_info = get_kw_from_id($id_keyword);
$query = "UPDATE lcm_keyword\n\t\t\t\t\tSET {$fl}\n\t\t\t\t\tWHERE id_keyword = " . $id_keyword;
lcm_query($query);
}
write_metas();
// update inc_meta_cache.php
$tab = $kw_info['type'] == 'system' ? 'system' : 'user';
lcm_header("Location: keywords.php?tab=" . $tab . "#" . $kw_info['kwg_name']);
exit;
}
示例6: install_step_3
function install_step_3()
{
$db_address = _request('db_address');
$db_login = _request('db_login');
$db_password = _request('db_password');
global $lcm_db_version;
$install_log = "";
$upgrade_log = "";
// Possible errors will get trapped in the output buffer and displayed later,
// so that they don't mess up with headers/html.
ob_start();
if (_request('db_choice') == "__manual__") {
$sel_db = _request('manual_db');
} else {
$sel_db = _request('db_choice');
}
$link = lcm_connect_db($db_address, 0, $db_login, $db_password, $sel_db);
$io_output = ob_get_contents();
ob_end_clean();
if (!$link) {
install_html_start('AUTO', '', 3);
lcm_panic("connection denied: " . lcm_sql_error());
}
//
// TEMPORARY (used by testing the installer)
/*
lcm_query("DROP TABLE lcm_case", true);
lcm_query("DROP TABLE lcm_case_attachment", true);
lcm_query("DROP TABLE lcm_stage", true);
lcm_query("DROP TABLE lcm_followup", true);
lcm_query("DROP TABLE lcm_author", true);
lcm_query("DROP TABLE lcm_client", true);
lcm_query("DROP TABLE lcm_client_attachment", true);
lcm_query("DROP TABLE lcm_org", true);
lcm_query("DROP TABLE lcm_org_attachment", true);
lcm_query("DROP TABLE lcm_contact", true);
lcm_query("DROP TABLE lcm_keyword", true);
lcm_query("DROP TABLE lcm_keyword_case", true);
lcm_query("DROP TABLE lcm_keyword_client", true);
lcm_query("DROP TABLE lcm_keyword_org", true);
lcm_query("DROP TABLE lcm_keyword_group", true);
lcm_query("DROP TABLE lcm_report", true);
lcm_query("DROP TABLE lcm_fields", true);
lcm_query("DROP TABLE lcm_filter", true);
lcm_query("DROP TABLE lcm_app", true);
lcm_query("DROP TABLE lcm_app_client_org", true);
lcm_query("DROP TABLE lcm_app_fu", true);
lcm_query("DROP TABLE lcm_author_app", true);
lcm_query("DROP TABLE lcm_case_client_org", true);
lcm_query("DROP TABLE lcm_case_author", true);
lcm_query("DROP TABLE lcm_client_org", true);
lcm_query("DROP TABLE lcm_rep_col", true);
lcm_query("DROP TABLE lcm_rep_line", true);
lcm_query("DROP TABLE lcm_rep_filters", true);
lcm_query("DROP TABLE lcm_filter_conds", true);
lcm_query("DROP TABLE lcm_rep_filter", true);
lcm_query("DROP TABLE lcm_meta", true);
*/
// Test if the software was already installed
$result = lcm_query("SELECT * FROM lcm_meta", true);
$already_installed = !lcm_sql_errno() && lcm_num_rows($result);
$old_lcm_version = 'NONE';
if ($already_installed) {
lcm_log("LCM already installed", 'install');
// Find the current database version
$old_lcm_db_version = 0;
$query = "SELECT value FROM lcm_meta WHERE name = 'lcm_db_version'";
$result = lcm_query_db($query);
while ($row = lcm_fetch_array($result)) {
$old_lcm_db_version = $row['value'];
}
lcm_log("LCM version installed is {$old_lcm_db_version}", 'install');
// Check if upgrade is needed
if ($old_lcm_db_version < $lcm_db_version) {
lcm_log("Calling the upgrade procedure (since < {$lcm_db_version})", 'install');
include_lcm('inc_db_upgrade');
$upgrade_log = upgrade_database($old_lcm_db_version);
} else {
lcm_log("Upgrade _not_ called, looks OK (= {$lcm_db_version})", 'install');
}
} else {
lcm_log("Creating the database from scratch", 'install');
include_lcm('inc_db_create');
$install_log .= create_database();
lcm_log("DB creation complete", 'install');
}
// Create default meta + keywords
include_lcm('inc_meta');
include_lcm('inc_keywords_default');
include_lcm('inc_meta_defaults');
init_default_config();
init_languages();
$skwg = get_default_keywords();
create_groups($skwg);
write_metas();
// regenerate inc/data/inc_meta_cache.php
// Test DB: not used for now..
include_lcm('inc_db_test');
$structure_ok = lcm_structure_test();
if (!empty($install_log)) {
//.........这里部分代码省略.........
示例7: intval
$case = intval(_request('case', 0));
$client = intval(_request('client', 0));
$org = intval(_request('org', 0));
if ($case > 0) {
$type = 'case';
$id_type = $case;
} else {
if ($client > 0) {
$type = 'client';
$id_type = $client;
} else {
if ($org > 0) {
$type = 'org';
$id_type = $org;
} else {
lcm_panic("Missing object type for attachment.");
}
}
}
$_SESSION['errors'] = array();
if (isset($_POST['rem_file']) && is_array($_POST['rem_file']) && count($_POST['rem_file']) > 0) {
$rem_files = join(',', $_POST['rem_file']);
$result = lcm_query("UPDATE lcm_{$type}_attachment\n\t\t\t\tSET date_removed=NOW(),content=NULL\n\t\t\t\tWHERE id_{$type}={$id_type}\n\t\t\t\tAND id_attachment IN ({$rem_files})");
}
if (strlen($_FILES['filename']['name']) > 0) {
$_SESSION['user_file'] = $_FILES['filename'];
$_SESSION['user_file']['description'] = _request('description');
$filename = $_SESSION['user_file']['tmp_name'];
if (is_uploaded_file($filename) && $_SESSION['user_file']['size'] > 0) {
$file = fopen($filename, "r");
$file_contents = fread($file, filesize($filename));
示例8: lcm_panic
if ($GLOBALS['author_session']['status'] != 'admin') {
lcm_panic("You don't have permission to export!");
}
$item = clean_input($_REQUEST['item']);
if (!empty($_REQUEST['id'])) {
$id = intval($_REQUEST['id']);
}
$data = array();
switch ($item) {
case 'case':
load_case($id, $data, _LOAD_ALL);
break;
case 'followup':
$data = load_followup($id, $data, _LOAD_ALL);
break;
case 'client':
$data = load_client($id, $data, _LOAD_ALL);
break;
case 'org':
$data = load_org($id, $data, _LOAD_ALL);
break;
default:
lcm_panic("Incorrect export item type!");
exit;
}
// Send proper headers to browser
header("Content-Type: text/xml");
header("Content-Disposition: filename={$item}_{$id}.xml");
header("Content-Description: " . "Export of {$item} ID{$id}");
echo '<?xml version="1.0"?>' . "\n";
echo xml_encode("{$item}_{$id}", $data);
示例9: save
function save()
{
$errors = $this->validate();
if (count($errors)) {
return $errors;
}
//
// Update
//
$fl = " date_start = '" . $this->getDataString('date_start') . "',\n\t\t\t\tdate_end = '" . $this->getDataString('date_end') . "',\n\t\t\t\ttype = '" . $this->getDataString('type') . "',\n\t\t\t\tsumbilled = " . $this->getDataFloat('sumbilled', 0.0);
if ($this->getDataString('type') == 'stage_change') {
// [ML] To be honest, we should "assert" most of the
// following values, but "new_stage" is the most important.
lcm_assert_value($this->getDataString('new_stage', '__ASSERT__'));
$desc = array('description' => $this->getDataString('description'), 'result' => $this->getDataString('result'), 'conclusion' => $this->getDataString('conclusion'), 'sentence' => $this->getDataString('sentence'), 'sentence_val' => $this->getDataString('sentence_val'), 'new_stage' => $this->getDataString('new_stage'));
$fl .= ", description = '" . serialize($desc) . "'";
} elseif (is_status_change($this->getDataString('type'))) {
$desc = array('description' => $this->getDataString('description'), 'result' => $this->getDataString('result'), 'conclusion' => $this->getDataString('conclusion'), 'sentence' => $this->getDataString('sentence'), 'sentence_val' => $this->getDataString('sentence_val'));
$fl .= ", description = '" . serialize($desc) . "'";
} else {
$fl .= ", description = '" . $this->getDataString('description') . "'";
}
if ($this->getDataInt('id_followup') > 0) {
// Edit of existing follow-up
$id_followup = $this->getDataInt('id_followup');
if (!allowed($this->getDataInt('id_case'), 'e')) {
lcm_panic("You don't have permission to modify this case's information. (" . $this->getDataInt('id_case') . ")");
}
// TODO: check if hiding this FU is allowed
if (allowed($this->getDataInt('id_case'), 'a') && !(is_status_change($this->getDataString('type')) || $this->getDataString('type') == 'assignment' || $this->getDataString('type') == 'unassignment')) {
if ($this->getDataString('delete')) {
$fl .= ", hidden = 'Y'";
} else {
$fl .= ", hidden = 'N'";
}
} else {
$fl .= ", hidden = 'N'";
}
$q = "UPDATE lcm_followup SET {$fl} WHERE id_followup = {$id_followup}";
$result = lcm_query($q);
// Get stage of the follow-up entry
$q = "SELECT id_stage, case_stage FROM lcm_followup WHERE id_followup = {$id_followup}";
$result = lcm_query($q);
if ($row = lcm_fetch_array($result)) {
$case_stage = lcm_assert_value($row['case_stage']);
} else {
lcm_panic("There is no such follow-up (" . $id_followup . ")");
}
// Update the related lcm_stage entry
$q = "UPDATE lcm_stage SET\n\t\t\t\t\tdate_conclusion = '" . $this->getDataString('date_end') . "',\n\t\t\t\t\tkw_result = '" . $this->getDataString('result') . "',\n\t\t\t\t\tkw_conclusion = '" . $this->getDataString('conclusion') . "',\n\t\t\t\t\tkw_sentence = '" . $this->getDataString('sentence') . "',\n\t\t\t\t\tsentence_val = '" . $this->getDataString('sentence_val') . "',\n\t\t\t\t\tdate_agreement = '" . $this->getDataString('date_end') . "'\n\t\t\t\tWHERE id_case = " . $this->getDataInt('id_case') . "\n\t\t\t\t AND kw_case_stage = '" . $case_stage . "'";
lcm_query($q);
} else {
// New follow-up
if (!allowed($this->getDataInt('id_case'), 'w')) {
lcm_panic("You don't have permission to add information to this case. (" . $this->getDataInt('id_case') . ")");
}
// Get the current case stage
$q = "SELECT id_stage, stage FROM lcm_case WHERE id_case=" . $this->getDataInt('id_case', '__ASSERT__');
$result = lcm_query($q);
if ($row = lcm_fetch_array($result)) {
$case_stage = lcm_assert_value($row['stage']);
$case_stage_id = lcm_assert_value($row['id_stage']);
} else {
lcm_panic("There is no such case (" . $this->getDataInt('id_case') . ")");
}
// Add the new follow-up
$q = "INSERT INTO lcm_followup\n\t\t\t\t\tSET id_case=" . $this->getDataInt('id_case') . ",\n\t\t\t\t\t\tid_author=" . $GLOBALS['author_session']['id_author'] . ",\n\t\t\t\t\t\t{$fl},\n\t\t\t\t\t\tid_stage = {$case_stage_id},\n\t\t\t\t\t\tcase_stage='{$case_stage}'";
lcm_query($q);
$this->data['id_followup'] = lcm_insert_id('lcm_followup', 'id_followup');
// Set relation to the parent appointment, if any
if ($this->getDataInt('id_app')) {
$q = "INSERT INTO lcm_app_fu \n\t\t\t\t\t\tSET id_app=" . $this->getDataInt('id_app') . ",\n\t\t\t\t\t\t\tid_followup=" . $this->getDataInt('id_followup', '__ASSERT__') . ",\n\t\t\t\t\t\t\trelation='child'";
$result = lcm_query($q);
}
// Update case status
$status = '';
$stage = '';
switch ($this->getDataString('type')) {
case 'conclusion':
$status = 'closed';
break;
case 'suspension':
$status = 'suspended';
break;
case 'opening':
case 'resumption':
case 'reopening':
$status = 'open';
break;
case 'merge':
$status = 'merged';
break;
case 'deletion':
$status = 'deleted';
break;
case 'stage_change':
$stage = lcm_assert_value($this->getDataString('new_stage'));
break;
}
if ($status || $stage) {
//.........这里部分代码省略.........
示例10: show_find_box
}
show_find_box('exp', $find_exp_string);
//
// For "Filter expense owner"
//
$prefs_change = false;
$types_owner = array('my' => 1, 'public' => 1);
$types_period = array('m1' => 30, 'm3' => 91, 'm6' => 182, 'y1' => 365);
// 30 days, 3 months, 6 months, 1 year
if ($author_session['status'] == 'admin') {
$types_owner['all'] = 1;
}
if ($v = _request('case_owner')) {
if ($prefs['case_owner'] != $v) {
if (!array_key_exists($v, $types_owner)) {
lcm_panic("Value for case owner not permitted: " . htmlspecialchars($v));
}
$prefs['case_owner'] = _request('case_owner');
$prefs_change = true;
}
}
// always include 'my' cases [ML] $q_owner is re-used below
$q_owner = " (e.id_author = " . $author_session['id_author'];
if ($prefs['case_owner'] == 'public') {
$q_owner .= " OR e.pub_read = 1";
}
if ($author_session['status'] == 'admin' && $prefs['case_owner'] == 'all') {
$q_owner .= " OR 1=1 ";
}
$q_owner .= " ) ";
//
示例11: getCaseIterator
function getCaseIterator()
{
global $prefs;
if ($this->getCaseDone()) {
lcm_panic("LcmOrg::getCaseIterator called but getCaseDone() returned true");
}
return array_shift($this->cases);
}
示例12: printList
function printList()
{
global $prefs;
// Select cases of which the current user is author
$q = "SELECT DISTINCT c.id_case, title, status, public, pub_write, date_creation\n\t\t\tFROM lcm_case as c NATURAL JOIN lcm_case_author as a ";
if ($this->search) {
$q .= " NATURAL LEFT JOIN lcm_keyword_case as kc ";
}
//
// Apply filters to SELECT output
//
$q .= " WHERE 1=1 ";
// Add search criteria, if any
if ($this->search) {
$q .= " AND (";
if (is_numeric($this->search)) {
$q .= " (c.id_case = {$this->search}) OR ";
}
$q .= " (kc.value LIKE '%" . $this->search . "%') OR " . " (c.title LIKE '%" . $this->search . "%') ";
$q .= " )";
}
//
// Case owner: may be used by listcases.php, archives.php, author_det.php, etc.
// Also, it may be a user checking another user's profile (in that case, show only public cases)
// or it may be an admin checking another user's profile. etc.
//
global $author_session;
$owner_filter = $this->getDataString('owner', $prefs['case_owner']);
$owner_id = $this->getDataInt('id_author', $author_session['id_author']);
$q_owner = " (a.id_author = " . $owner_id;
if ($owner_id == $author_session['id_author']) {
// Either in listcases, or user looking at his page in author_det
if ($owner_filter == 'public') {
$q_owner .= " OR c.public = 1";
}
if ($author_session['status'] == 'admin' && $owner_filter == 'all') {
$q_owner .= " OR 1=1 ";
}
} else {
// If not an admin, show only public cases of that user
if ($author_session['status'] != 'admin') {
$q_owner .= " AND c.public = 1";
}
}
$q_owner .= " ) ";
$q .= " AND " . $q_owner;
// Period (date_creation) to show
if ($this->date_start || $this->date_end) {
if ($this->date_start) {
$q .= " AND date_creation >= '" . $this->date_start . "'";
}
if ($this->date_end) {
$q .= " AND date_creation <= '" . $this->date_end . "'";
}
} else {
if ($prefs['case_period'] < 1900) {
// since X days
$q .= " AND " . lcm_query_subst_time('date_creation', 'NOW()') . ' < ' . $prefs['case_period'] * 3600 * 24;
} else {
// for year X
$q .= " AND " . lcm_query_trunc_field('date_creation', 'year') . ' = ' . $prefs['case_period'];
}
}
//
// Sort results
//
$sort_clauses = array();
$sort_allow = array('ASC' => 1, 'DESC' => 1);
// Sort cases by creation date
if ($sort_allow[_request('status_order')]) {
$sort_clauses[] = "status " . _request('status_order');
}
if ($sort_allow[_request('case_order')]) {
$sort_clauses[] = 'date_creation ' . _request('case_order');
} elseif ($sort_allow[_request('upddate_order')]) {
$sort_clauses[] = "date_update " . _request('upddate_order');
} else {
$sort_clauses[] = 'date_creation DESC';
}
// default
$q .= " ORDER BY " . implode(', ', $sort_clauses);
$result = lcm_query($q);
// Check for correct start position of the list
$this->number_of_rows = lcm_num_rows($result);
if ($this->list_pos >= $this->number_of_rows) {
$this->list_pos = 0;
}
// Position to the page info start
if ($this->list_pos > 0) {
if (!lcm_data_seek($result, $this->list_pos)) {
lcm_panic("Error seeking position " . $this->list_pos . " in the result");
}
}
for ($i = 0; $i < $prefs['page_rows'] && ($row = lcm_fetch_array($result)); $i++) {
show_listcase_item($row, $i, $this->search);
}
}
示例13: export
function export($type, $format, $search = '')
{
switch ($type) {
case 'case':
// List cases in the system + search criterion if any
$q = "SELECT id_case,title,legal_reason,alledged_crime,notes,status,stage\n\t\t\t\t\tFROM lcm_case";
if (strlen($search) > 1) {
// Add search criteria
$q .= " WHERE ((title LIKE '%{$search}%')\n\t\t\t\t\t\tOR (status LIKE '%{$search}%')\n\t\t\t\t\t\tOR (stage LIKE '%{$search}%'))";
}
break;
case 'client':
// List clients in the system + search criterion if any
$q = "SELECT id_client,name_first,name_middle,name_last,citizen_number,civil_status,income,gender,notes\n\t\t\t\t\tFROM lcm_client";
if (strlen($search) > 1) {
// Add search criteria
$q .= " WHERE ((name_first LIKE '%{$search}%')\n\t\t\t\t\t\tOR (name_middle LIKE '%{$search}%')\n\t\t\t\t\t\tOR (name_last LIKE '%{$search}%'))";
}
break;
case 'org':
// List organizations in the system + search criterion if any
$q = "SELECT id_org,name,notes,court_reg,tax_number,stat_number\n\t\t\t\t\tFROM lcm_org";
if (strlen($search) > 1) {
// Add search criteria
$q .= " WHERE (name LIKE '%{$search}%')";
}
break;
default:
lcm_panic("invalid type: {$type}");
return 0;
}
$mime_types = array('csv' => 'text/comma-separated-values', 'xml' => 'text/xml');
if (!($mime_type = $mime_types[$format])) {
lcm_panic("invalid type: {$type}");
return 0;
}
$result = lcm_query($q);
if (lcm_num_rows($result) > 0) {
// Send proper headers to browser
header("Content-Type: " . $mime_type);
header("Content-Disposition: filename={$type}.{$format}");
header("Content-Description: " . "Export of {$type}s");
header("Content-Transfer-Encoding: binary");
// echo ( get_magic_quotes_runtime() ? stripslashes($row['content']) : $row['content'] );
// Document start
switch ($format) {
case 'csv':
// Export columns headers
break;
case 'xml':
echo "<document>\r\n";
break;
}
// Document contents
while ($row = lcm_fetch_assoc($result)) {
// Export row start
switch ($format) {
case 'csv':
break;
case 'xml':
echo "\t<row>\r\n";
break;
}
// Prepare row fields
$fields = array();
foreach ($row as $key => $value) {
// Remove escaping if any
$value = get_magic_quotes_runtime() ? stripslashes($value) : $value;
switch ($format) {
case 'csv':
if (is_string($value)) {
// Escape double quote in CVS style
$value = str_replace('"', '""', $value);
// Add double quotes
$value = "\"{$value}\"";
}
break;
case 'xml':
$value = is_string($value) ? htmlspecialchars($value) : $value;
$value = "\t\t<{$key}>{$value}</{$key}>\r\n";
break;
}
$fields[] = $value;
}
// Export row end
switch ($format) {
case 'csv':
echo join(',', $fields) . "\r\n";
break;
case 'xml':
echo join('', $fields);
echo "\t</row>\r\n";
break;
}
}
// Document end
switch ($format) {
case 'csv':
break;
case 'xml':
//.........这里部分代码省略.........
示例14: update_keywords_request
function update_keywords_request($type_obj, $id_obj, $id_obj_sec = 0)
{
//
// Update existing keywords
//
if (isset($_REQUEST['kw_value_' . $type_obj])) {
$kw_entries = $_REQUEST['kw_entry_' . $type_obj];
$kw_values = $_REQUEST['kw_value_' . $type_obj];
$kwg_ids = $_REQUEST['kwg_id_' . $type_obj];
// Check if the keywords provided are really attached to the object
for ($cpt = 0; isset($kw_entries[$cpt]) && $kw_entries[$cpt]; $cpt++) {
// TODO
}
for ($cpt = 0; isset($kw_entries[$cpt]); $cpt++) {
if ($_REQUEST['kw_del_' . $type_obj . $cpt] || empty($kw_values[$cpt])) {
if ($type_obj == 'stage') {
// The id_case and id_stage are specified explicitely
// even if redundant for security (not to delete on other
// cases) and for integrety checks.
$query = "DELETE FROM lcm_keyword_case\n\t\t\t\t\t\t\t\tWHERE id_case = {$id_obj}\n\t\t\t\t\t\t\t\t AND id_stage = {$id_obj_sec}\n\t\t\t\t\t\t\t\t AND id_entry = " . $kw_entries[$cpt];
} else {
// The id_$type_obj (ex: case, client, org) is specified
// explicitely even if redundant for security and integrity.
$query = "DELETE FROM lcm_keyword_" . $type_obj . "\n\t\t\t\t\t\t\t\tWHERE id_{$type_obj} = {$id_obj}\n\t\t\t\t\t\t\t\t AND id_entry = " . $kw_entries[$cpt];
}
} else {
if ($kw_values[$cpt]) {
if ($type_obj == 'stage') {
$query = "UPDATE lcm_keyword_case\n\t\t\t\t\t\t\t\tSET id_keyword = " . $kw_values[$cpt] . ",\n\t\t\t\t\t\t\t\t\tid_stage = " . $id_obj_sec;
} else {
$query = "UPDATE lcm_keyword_" . $type_obj . " \n\t\t\t\t\t\t\t\tSET id_keyword = " . $kw_values[$cpt];
}
if ($_REQUEST['kw_entryval_' . $type_obj . $cpt]) {
$query .= ", value = '" . $_REQUEST['kw_entryval_' . $type_obj . $cpt] . "'";
}
$query .= " WHERE id_entry = " . $kw_entries[$cpt];
}
}
lcm_query($query);
}
}
//
// New keywords
//
if ($id_obj && isset($_REQUEST['new_keyword_' . $type_obj . '_value'])) {
$cpt = 0;
$new_keywords = $_REQUEST['new_keyword_' . $type_obj . '_value'];
$new_kwg_id = $_REQUEST['new_kwg_' . $type_obj . '_id'];
while (isset($new_keywords[$cpt])) {
// Process new keywords which have a value
if ($new_keywords[$cpt]) {
if (!$new_kwg_id[$cpt]) {
lcm_panic("Empty kwg name");
}
// optionally, we can validate whether it makes sense
// to apply this kwg to this 'object' ... (TODO ?)
if ($type_obj == 'stage') {
$query = "INSERT INTO lcm_keyword_case\n\t\t\t\t\t\t\tSET id_keyword = " . $new_keywords[$cpt] . ",\n\t\t\t\t\t\t\t\tid_case = " . $id_obj . ",\n\t\t\t\t\t\t\t\tid_stage = " . $id_obj_sec;
} else {
$query = "INSERT INTO lcm_keyword_" . $type_obj . "\n\t\t\t\t\t\t\tSET id_keyword = " . $new_keywords[$cpt] . ",\n\t\t\t\t\t\t\t\tid_" . $type_obj . " = " . $id_obj;
}
if (isset($_REQUEST['new_kw_entryval_' . $type_obj . $cpt])) {
if ($_REQUEST['new_kw_entryval_' . $type_obj . $cpt]) {
$query .= ", value = '" . $_REQUEST['new_kw_entryval_' . $type_obj . $cpt] . "'";
} else {
$query = "";
}
}
if ($query) {
lcm_query($query);
}
}
$cpt++;
}
}
}
示例15: lcm_query_trunc_field
function lcm_query_trunc_field($date, $type)
{
$ret = "";
switch ($type) {
case 'day':
$ret = "DATE_FORMAT({$date}, '%Y-%m-%d')";
break;
case 'year':
$ret = "YEAR({$date})";
break;
default:
lcm_panic("Not supported");
}
return $ret;
}