public function getSubscribers($obj = null, $action = 127, $delivery = 15) { if (is_null($obj)) { return array(); } $cls = get_class($obj); switch ($cls) { case "Default_Model_Researcher": $type = 'app'; break; case "Default_Model_Applciation": $type = 'ppl'; break; default: return array(); } $act = array(); if (NewsEventType::has($action, NewsEventType::E_INSERT)) { $act[] = "insert"; } if (NewsEventType::has($action, NewsEventType::E_UPDATE)) { $act[] = "update"; } if (NewsEventType::has($action, NewsEventType::E_INSERT_COMMENT)) { $act[] = "insertcmm"; } if (NewsEventType::has($action, NewsEventType::E_INSERT_CONTACT)) { $act[] = "insertcnt"; } $subs = new Default_Model_MailSubscriptions(); $subs->filter->type->equals($type)->and($subs->filter->events->hasbit($event))->and($subd->filter->delivery->hasbit($delivery)); if ($subs->count() == 0) { return array(); } $subs = $subs->items; foreach ($subs as $sub) { switch ($type) { case "app-entry": $f = FilterParser::getApplications($sub->flt); break; case "app": $f = FilterParser::getApplications($sub->flt); break; case "ppl": $f = FilterParser::getPeople($sub->flt); break; } $news = new Default_Model_AggregateNews(); $nf = new Default_Model_AggregateNewsFilter(); if (count($act) > 0) { for ($i = 0; $i < count($act); $i += 1) { if (isset($a)) { $a = $a->or($nf->action->equals(trim($act[$i]))); } else { $a = $nf->action->equals(trim($act[$i])); } } $news->filter = $news->filter->chain($nf, "AND"); } $nf->subjecttype->equals(trim($type)); $news->filter = $news->filter->chain($nf, "AND"); $news->filter->orderBy('timestamp DESC'); $news->refresh(); } return array(); }
/** * @overrides get() from RestResource */ public function get() { if (parent::get() !== false) { $s = '<dissemination:filter>'; $s .= FilterParser::fieldsToXML("any dissemination application sender country vo discipline middleware category", "dissemination"); $s .= '</dissemination:filter>'; return new XMLFragmentRestResponse($s, $this); } else { return false; } }
/** * @overrides get() from RestResource */ public function get($extraFilter = null) { if (parent::get() !== false) { global $application; $isAdmin = $this->userIsAdmin(); $mapper = new Default_Model_VOsMapper(); $db = $application->getBootstrap()->getResource('db'); $flt = $this->getParam("flt"); $select = $mapper->getDbTable()->getAdapter()->select()->distinct()->from('vos'); $from = ''; $where = ''; $orderby = ''; $limit = ''; $filter = FilterParser::getVOs($flt); if (is_array($filter->expr())) { $ex = implode(" ", $filter->expr()); } else { $ex = $filter->expr(); } $fltexp = $filter->expr(); if (!is_array($fltexp)) { $fltexp = array($fltexp); } foreach ($fltexp as $x) { getZendSelectParts($select, $from, $where, $orderby, $limit); if (!$isAdmin) { if (strpos($from, ' applications ') !== false && (strpos($ex, 'applications.moderated) IS FALSE') === false || strpos($ex, 'applications.deleted) IS FALSE') === false)) { $f = new Default_Model_ApplicationsFilter(); $f->moderated->equals(false)->and($f->deleted->equals(false)); $filter->chain($f, "AND"); } if (strpos($from, ' researchers ') !== false && strpos($ex, 'researchers.deleted) IS FALSE') === false) { $f = new Default_Model_ResearchersFilter(); $f->deleted->equals(false); $filter->chain($f, "AND"); } } if (strpos($ex, 'vos.deleted) IS FALSE') === false) { $f = new Default_Model_VOsFilter(); $f->deleted->equals(false); $filter->chain($f, "AND"); } } if (!is_null($extraFilter)) { $filter->chain($extraFilter, "AND"); } $mapper->joins($select, $filter); if (is_array($filter->expr())) { $from = array(); $where = array(); foreach ($filter->expr() as $x) { $s = clone $select; $s->where($x); getZendSelectParts($s, $f, $w, $orderby, $limit); $from[] = $f; $where[] = $w; } $flt = str_replace("''", "\\'", php_to_pg_array($filter->fltstr, false)); $from = str_replace("''", "\\'", php_to_pg_array($from, false)); $where = str_replace("''", "\\'", php_to_pg_array($where, false)); } else { $select->where($filter->expr()); getZendSelectParts($select, $from, $where, $orderby, $limit); } $db->setFetchMode(Zend_Db::FETCH_BOTH); $rs = $db->query('SELECT * FROM vo_logistics(?,?,?)', array($flt, $from, $where))->fetchAll(); if (count($rs) > 0) { $rs = $rs[0]; $x = $rs['vo_logistics']; } else { $x = ''; } return new XMLFragmentRestResponse($x, $this); } else { return false; } }
public function reflectfilterAction() { $s = '<person:filter xmlns:person="http://appdb.egi.eu/api/0.2/person" xmlns:filter="http://appdb.egi.eu/api/0.2/filter">'; $s .= FilterParser::fieldsToXML("any person country application vo discipline subdiscipline middleware", "person"); $s .= '</person:filter>'; $this->view->entries = $s; }
public function exportAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); if (array_key_exists("type", $_GET)) { $type = $_GET['type']; } else { $type = 'xml'; } $apps = new Default_Model_Applications(); $apps->filter = FilterParser::getApplications($this->_getParam("flt")); if ($type === "xml") { $apps->refresh("xmlexport"); } else { $apps->refresh("csvexport"); } $s = ''; foreach ($apps->items as $item) { $s = $s . preg_replace("/[\n\r]/", '', $item) . "\n"; } header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename=apps' . time() . '.' . $type); header('Content-type: text/' . ($type === "xml" ? "xml" : "x-csv")); header("Pragma: no-cache"); header("Expires: 0"); header('Content-Length: ' . strlen($s)); if ($type === "xml") { echo '<applications>' . $s . '</applications>'; } else { echo '"Name","Description","Abstract","Date Added","Added By","Owner","Status","Categories","Middlewares","VOs","Disciplines","Countries","URLs","Researchers"' . "\n"; echo $s; } }
public static function buildFilter(&$filter, $fltstr, $isfuzzy = false) { $fltstr = trim($fltstr); if (substr($fltstr, 0, 1) === "|") { $fltstr = trim(substr($fltstr, 1)); } if (substr($fltstr, -1, 1) === "|") { $fltstr = trim(substr($fltstr, 0, -1)); } $fltstr_parts = explode(" | ", $fltstr); $exprs = array(); foreach ($fltstr_parts as $fltstr_part) { if (trim($fltstr_part) != '') { $filter->_expr = ''; FilterParser::__buildFilter($filter, $fltstr_part, $isfuzzy); $exprs[] = $filter->expr(); } } if (count($exprs) === 0) { debug_log("buildFilter: null expression"); } elseif (count($exprs) === 1) { $filter->_expr = $exprs[0]; $filter->fltstr = $fltstr_parts[0]; } else { $filter->_expr = $exprs; $filter->fltstr = $fltstr_parts; } }