/**
  * Apply authz rules for who may write to a SrcResponse.
  *
  * @param AIR2_Query $q
  * @param User    $u
  * @param string  $alias (optional)
  */
 public static function query_may_write(AIR2_Query $q, User $u, $alias = null)
 {
     if ($u->is_system()) {
         return;
     }
     $a = $alias ? "{$alias}." : "";
     // writable src_response_sets
     $tmp = AIR2_Query::create();
     SrcResponseSet::query_may_write($tmp, $u);
     $tmp = array_pop($tmp->getDqlPart('where'));
     $srs_ids = "select srs_id from src_response_set where {$tmp}";
     // add to query
     $q->addWhere("{$a}sr_srs_id in ({$srs_ids})");
 }