function _get_projects_for_pm($pm) { $returnArray = array(); $states = _get_project_states_in_order(); $stateString = surround_and_join($states, "'", "'", ','); $where = "state IN ({$stateString})"; $collator = "FIELD(state,{$stateString})"; $query = "SELECT projectid, state, nameofwork FROM projects WHERE username='******' AND {$where} ORDER BY {$collator}, nameofwork"; $res = mysql_query($query); while ($ar = mysql_fetch_array($res)) { $returnArray[$ar["projectid"]] = array($ar["nameofwork"], $ar["state"]); } return $returnArray; }
// ----------------------------------------------- // Restate the requested changes, and perform them. $headers = array('remove' => _("Removing holds for the following states:"), 'keep' => _("Keeping holds for the following states:"), 'add' => _("Adding holds for the following states:")); foreach ($headers as $w => $header) { $states = $delta_[$w]; if (count($states)) { echo "<p>{$header}</p>\n"; echo "<ul>\n"; foreach ($states as $state) { echo "<li>", get_medium_label_for_project_state($state), "</li>\n"; } echo "</ul>\n"; // ----------------------------------- $sql = NULL; if ($w == 'remove') { $states_str = surround_and_join($states, "'", "'", ", "); $sql = "\n DELETE FROM project_holds\n WHERE projectid='{$projectid}'\n AND state in ({$states_str})\n "; $event_type = 'remove_holds'; } elseif ($w == 'add') { $values = ''; foreach ($states as $state) { if ($values) { $values .= ",\n"; } $values .= "('{$projectid}', '{$state}')"; } $sql = "\n INSERT INTO project_holds\n VALUES {$values}\n "; $event_type = 'add_holds'; } if ($sql) { // echo $sql;
function get_sql_contribution() { $value = @$_GET[$this->id]; if ($value == '') { return NULL; } $contrib_template = $this->q_contrib; if (is_string($contrib_template) && function_exists($contrib_template)) { $contribution = $contrib_template($value); } else { if ($this->q_part == 'WHERE') { list($column_name, $comparator) = $this->q_contrib; if (@$this->can_be_multiple) { if ($this->type == 'text') { $values = preg_split("({$this->separator})", trim($value)); } elseif ($this->type == 'select') { $values = $value; // If $value isn't an array, someone is mucking with // the URL -- return instead of erroring out below. if (!is_array($values)) { return NULL; } // If the user picks the 'any' option as well as some others, // it's as if they'd just picked the 'any' option. if (in_array('', $values)) { return NULL; } } if ($comparator == '=') { $values_list = surround_and_join($values, "'", "'", ","); $contribution = "{$column_name} IN ({$values_list})"; } elseif ($comparator == 'LIKE') { $likes_str = surround_and_join($values, "{$column_name} LIKE '%", "%'", ' OR '); $contribution = "({$likes_str})"; } } else { if ($comparator == '=') { $contribution = "{$column_name} = '{$value}'"; } elseif ($comparator == 'LIKE') { $contribution = "{$column_name} LIKE '%{$value}%'"; } } } else { $contribution = str_replace('{VALUE}', $value, $contrib_template); } } return $contribution; }