<?php /** * REST proxy to * http://warehouse.democracyinaction.org/o/0/p/salsa/warehouse/public/lookupLegislator.sjs **/ require_once '../kernel/setup_inc.php'; $gBitSystem->verifyPackage('diasalsa'); require_once DIASALSA_PKG_PATH . 'SalsaAction.php'; $obj = new SalsaAction(); $xml = $obj->getLegislator($_REQUEST); // Since we are returning xml we must report so in the header // we also need to tell the browser not to cache the page // see: http://mapki.com/index.php?title=Dynamic_XML // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // always modified header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // HTTP/1.1 header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", FALSE); // HTTP/1.0 header("Pragma: no-cache"); //XML Header header("content-type:text/xml"); /* * print_r( '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>' ); */ print_r($xml); // die;
require_once DIASALSA_PKG_PATH . 'SalsaAction.php'; require_once LIBERTY_PKG_PATH . 'lookup_content_inc.php'; if (empty($gContent) || !is_object($gContent) || !$gContent->isValid()) { // if someone gives us a action_key we try to find it if (!empty($_REQUEST['action_key']) && is_numeric($_REQUEST['action_key'])) { global $gBitDb; $_REQUEST['action_id'] = $gBitDb->getOne("SELECT action_id FROM `" . BIT_DB_PREFIX . "diasalsa_actions` a WHERE a.`key_id`=?", array($_REQUEST['action_key'])); if (empty($_REQUEST['action_id'])) { $gBitSystem->fatalError(tra('No action found with key id: ') . $_REQUEST['action_key']); } } // if someone gives us a action_name we try to find it if (!empty($_REQUEST['action_name'])) { global $gBitDb; $_REQUEST['action_id'] = $gBitDb->getOne("SELECT action_id FROM `" . BIT_DB_PREFIX . "diasalsa_actions` a LEFT JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (a.`content_id` = lc.`content_id`) WHERE lc.`title` = ?", array($_REQUEST['action_name'])); if (empty($_REQUEST['action_id'])) { $gBitSystem->fatalError(tra('No action found with the name: ') . $_REQUEST['action_name']); } } // if action_id supplied, use that if (@BitBase::verifyId($_REQUEST['action_id'])) { $gContent = new SalsaAction($_REQUEST['action_id']); $gContent->load(); } elseif (@BitBase::verifyId($_REQUEST['content_id'])) { $gContent = new SalsaAction(NULL, $_REQUEST['content_id']); $gContent->load(); } else { $gContent = new SalsaAction(); } $gBitSmarty->assign_by_ref('gContent', $gContent); }
function getActionList(&$pListHash) { global $gBitUser, $gBitSystem; if (empty($pListHash['sort_mode'])) { $pListHash['sort_mode'] = 'created_asc'; } LibertyContent::prepGetList($pListHash); $selectSql = ''; $joinSql = ''; $whereSql = ''; $bindVars = array(); array_push($bindVars, $this->mContentTypeGuid); $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pListHash); // this will set $find, $sort_mode, $max_records and $offset extract($pListHash); $sortModePrefix = 'lc.'; $sort_mode = $sortModePrefix . $this->mDb->convertSortmode($pListHash['sort_mode']); $query = "\n\t\t\tSELECT sa.*, lc.*, \n\t\t\t\tacm.`action_c_key_id` AS `action_content_key`, \n\t\t\t\tacm.`action_c_detail_key_id` AS `action_content_detail_key`, \n\t\t\t\tlc.*, lch.`hits`, lcds.`data` AS `summary`, lc.`last_modified` AS sort_date,\n\t\t\t\tlf.storage_path AS `image_attachment_path` \n\t\t\t\t{$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "diasalsa_actions` sa\n\t\t\t\tLEFT JOIN \t\t`" . BIT_DB_PREFIX . "diasalsa_action_content_map` acm ON acm.`content_id` = sa.`content_id`\n\t\t\t\tINNER JOIN \t\t`" . BIT_DB_PREFIX . "liberty_content` lc \t\tON lc.`content_id` \t\t = sa.`content_id`\n\t\t\t\tINNER JOIN\t\t`" . BIT_DB_PREFIX . "users_users`\t\t\t uu ON uu.`user_id`\t\t\t = lc.`user_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON lc.`content_id` = lch.`content_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_data` lcds ON (lc.`content_id` = lcds.`content_id` AND lcds.`data_type`='summary')\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` la ON la.`content_id` = lc.`content_id` AND la.`is_primary` = 'y'\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files` lf ON lf.`file_id` = la.`foreign_id`\n\t\t\t\t{$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}\n\t\t\tORDER BY {$sort_mode}"; $query_cant = "\n SELECT COUNT(*)\n FROM `" . BIT_DB_PREFIX . "diasalsa_actions` sa\n INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = sa.`content_id` ) {$joinSql}\n WHERE lc.`content_type_guid` = ? {$whereSql}"; $result = $this->mDb->query($query, $bindVars, $max_records, $offset); $ret = array(); while ($res = $result->fetchRow()) { $res['thumbnail_url'] = SalsaAction::getImageThumbnails($res); $res['display_url'] = SalsaAction::getDisplayUrl(NULL, $res); $res['action_count'] = SalsaAction::getSendersCount($res); $ret[] = $res; } $pListHash["cant"] = $this->mDb->getOne($query_cant, $bindVars); // add all pagination info to pListHash LibertyContent::postGetList($pListHash); return $ret; }