/** * Makin' the magic in the sugar field * @param $field * @param SugarQuery $query */ public function __construct($field, SugarQuery $query) { if (is_array($field)) { $this->field = $field[0]; $this->alias = $field[1]; if (!empty($field[2])) { $this->original_alias = $field[2]; } } else { $this->field = $field; } if ($query->getFromBean()) { $this->setupField($query); $this->shouldMarkNonDb(); } }
/** * This function adds a favorite filter to the sugar query * * @param SugarQuery $q The whole SugarQuery object * @param SugarQuery_Builder_Where $where The Where part of the SugarQuery object * @param string $link Which module are you adding the favorite filter to. */ protected static function addFavoriteFilter(SugarQuery $q, SugarQuery_Builder_Where $where, $link, $joinType = 'LEFT') { $sfOptions = array('joinType' => $joinType, 'favorites' => true); if ($link == '' || $link == '_this') { $link_name = 'favorites'; } else { $joinTo = $q->join($link, array('joinType' => 'LEFT')); $sfOptions['joinTo'] = $joinTo; $sfOptions['joinModule'] = $q->getFromBean()->module_name; $link_name = "sf_" . $link; } $fjoin = $q->join($link_name, $sfOptions); $where->notNull($fjoin->joinName() . '.id'); }