/** * Return a dictionary of attribute->value pairs * that were pre-asserted about the given eppn. */ function get_asserted_attributes($eppn) { $table_name = "km_asserted_attribute"; $conn = db_conn(); $sql = "select * from " . $table_name . " where LOWER(eppn) " . " = LOWER(" . $conn->quote($eppn, 'text') . ")"; $result = db_fetch_rows($sql); if ($result[RESPONSE_ARGUMENT::CODE] != RESPONSE_ERROR::NONE) { $db_error = $result[RESPONSE_ARGUMENT::OUTPUT]; geni_syslog(GENI_SYSLOG_PREFIX::MA, "Database error: {$db_error}"); geni_syslog(GENI_SYSLOG_PREFIX::MA, "Query was: " . $sql); // return an empty array because we couldn't load any attributes. return array(); } // SUCCESS -- create the return value from the db results $value = array(); foreach ($result[RESPONSE_ARGUMENT::VALUE] as $row) { $value[$row['name']] = $row['value']; } return $value; }
function check_duplicate_request($urn) { $conn = portal_conn(); $sql = "SELECT * from lead_request where " . "requester_urn =" . $conn->quote($urn, 'text') . " and status ='open'"; $rows = db_fetch_rows($sql, "check duplicate lead request"); $open_requests = $rows[RESPONSE_ARGUMENT::VALUE]; return count($open_requests) > 0; }
function get_pending_requests_for_user($args) { $account_id = null; if (array_key_exists(RQ_ARGUMENTS::ACCOUNT_ID, $args)) { $account_id = $args[RQ_ARGUMENTS::ACCOUNT_ID]; } if (!isset($account_id) or is_null($account_id)) { return generate_response(RESPONSE_ERROR::ARGS, '', 'No account_id given'); } // FIXME: Context type is ignored!? That may be OK given that this is implemented in // a specific controller. But if so, remove it? $context_type = null; if (array_key_exists(RQ_ARGUMENTS::CONTEXT_TYPE, $args)) { $context_type = $args[RQ_ARGUMENTS::CONTEXT_TYPE]; } $context_id = null; if (array_key_exists(RQ_ARGUMENTS::CONTEXT_ID, $args)) { $context_id = $args[RQ_ARGUMENTS::CONTEXT_ID]; } $conn = db_conn(); $user_for_context_query = ''; if ($context_id != null) { // Limit to given context $user_for_context_query = RQ_REQUEST_TABLE_FIELDNAME::CONTEXT_ID . " = " . $conn->quote($context_id, 'text') . ' AND '; } // Limit to contexts where this account has privileges to make changes // Note that this is in ADDITION to limiting to a specific context if provided. $user_for_context_query = $user_for_context_query . RQ_REQUEST_TABLE_FIELDNAME::CONTEXT_ID . " IN (" . user_context_query($account_id, $context_type) . ")"; $sql = "SELECT * from " . get_request_tablename($context_type) . " WHERE " . RQ_REQUEST_TABLE_FIELDNAME::STATUS . " = " . RQ_REQUEST_STATUS::PENDING . " AND " . $user_for_context_query; // error_log("get_pending_requests_for_user.sql = " . $sql); $result = db_fetch_rows($sql); return $result; }
function deleteRSpecById($id, $user) { $conn = portal_conn(); // check that you are the owner before deleting $conn = portal_conn(); $sql = "SELECT id FROM rspec WHERE id ="; $sql .= $conn->quote($id, 'integer'); $sql .= " AND owner_id ="; $sql .= $conn->quote($user->account_id, 'text'); geni_syslog(GENI_SYSLOG_PREFIX::PORTAL, $sql); // error_log($sql); $result = db_fetch_rows($sql, "deleteRSpecById"); $owned_rspec = $result[RESPONSE_ARGUMENT::VALUE]; if (count($owned_rspec) == 0) { $msg = "deleteRSpecById: Can not delete rspec. User didn't create rspec."; geni_syslog(GENI_SYSLOG_PREFIX::PORTAL, $msg); error_log($msg); return false; } // now delete rspec $sql = "DELETE FROM rspec WHERE id = "; $sql .= $conn->quote($id, 'integer'); $result = db_execute_statement($sql, "deleteRSpecById"); if ($result[RESPONSE_ARGUMENT::CODE] != RESPONSE_ERROR::NONE) { $msg = "deleteRSpecById: " . $result[RESPONSE_ARGUMENT::OUTPUT]; geni_syslog(GENI_SYSLOG_PREFIX::PORTAL, $msg); return false; } else { return true; } }
<li style="border-right: none"><a href='#slicesearch'>Slice Search</a></li> </ul> </div> <div id ='loading' style='display: none;'><h2 style="border: 0px; text-align: center;">Loading...</h2></div> <div style='text-align:center; font-weight: bold;' id='resultsbox'></div> <div id='leadrequests'> <h2>Open lead requests</h2> <?php // Find open lead requests and display table with information about the requesters $ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY); $conn = portal_conn(); $sql = "SELECT *" . " FROM lead_request WHERE status='open'"; $rows = db_fetch_rows($sql, "fetch all lead requests for admin page"); $lead_requests = $rows[RESPONSE_ARGUMENT::VALUE]; $requester_uuids = array(); foreach ($lead_requests as $lead_request) { $requester_uuids[] = $lead_request['requester_uuid']; } $requester_details = lookup_member_details($ma_url, $user, $requester_uuids); print "<table><tr><th>Name</th><th>Link</th><th>Requested At</th><th>Email</th><th>Admin Notes</th><th>Actions</th></tr>"; $open_requests = 0; foreach ($lead_requests as $lead_request) { $requester_uuid = $lead_request['requester_uuid']; $notes = $lead_request['notes'] == "" ? "None" : $lead_request['notes']; $timestamp = dateUIFormat($lead_request['request_ts']); $request_id = $lead_request['id']; $details = $requester_details[$requester_uuid]; make_user_info_rows($details, $requester_uuid, $request_id, $notes, $timestamp);