if (!empty($final)) {
    // We want to filter on final goals only:
    $SQL->WHERE_and('goal_redir_url IS NULL');
}
if (!empty($s)) {
    // We want to filter on search keyword:
    // Note: we use CONCAT_WS (Concat With Separator) because CONCAT returns NULL if any arg is NULL
    $SQL->WHERE_and('CONCAT_WS( " ", goal_name, goal_key, goal_redir_url ) LIKE "%' . $DB->escape($s) . '%"');
}
if (!empty($cat)) {
    // We want to filter on category:
    $SQL->WHERE_and('goal_gcat_ID = ' . $DB->quote($cat));
}
// Create result set:
$Results = new Results($SQL->get(), 'goals_', '-A');
$Results->Cache =& get_GoalCache();
$Results->title = T_('Goals') . get_manual_link('goal-settings');
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_goals(&$Form)
{
    $Form->checkbox_basic_input('final', get_param('final'), T_('Final only') . ' •');
    $Form->text('s', get_param('s'), 30, T_('Search'), '', 255);
    $GoalCategoryCache =& get_GoalCategoryCache(NT_('All'));
    $GoalCategoryCache->load_all();
    $Form->select_input_object('cat', get_param('cat'), $GoalCategoryCache, T_('Category'), array('allow_none' => true));
}
$Results->filter_area = array('callback' => 'filter_goals', 'url_ignore' => 'results_goals_page,final', 'presets' => array('all' => array(T_('All'), '?ctrl=goals&blog=' . $blog . '&final=0&s=&cat=0'), 'final' => array(T_('Final'), '?ctrl=goals&blog=' . $blog . '&final=1')));
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_keyphrases(&$Form)
{
    global $current_User, $datestart, $datestop;
    $Form->date_input('datestartinput', $datestart, T_('From'));
    $Form->date_input('datestopinput', $datestop, T_('to'));
    if ($current_User->check_perm('stats', 'view')) {
        // Permission to view stats for ALL blogs:
        global $goal_ID;
        $GoalCache =& get_GoalCache();
        $GoalCache->load_all();
        $Form->select_object('goal_ID', $goal_ID, $GoalCache, T_('Goal'), '', true);
    }
    $Form->text_input('goal_name', get_param('goal_name'), 20, T_('Goal names starting with'), '', array('maxlength' => 50));
    $Form->checkbox_basic_input('split_engines', get_param('split_engines'), T_('Split search engines'));
}
        // Hide comment expiration
        $Form->hidden('expiry_delay', $edited_Item->get_setting('comment_expiry_delay'));
    }
    $Form->end_fieldset();
}
// ################### GOAL TRACKING ###################
$Form->begin_fieldset(T_('Goal tracking') . get_manual_link('post-goal-tracking-panel') . action_icon(T_('Goals'), 'edit', $admin_url . '?ctrl=goals&blog=' . $Blog->ID, T_('Goals'), 3, 4, array('class' => 'action_icon pull-right')), array('id' => 'itemform_goals', 'fold' => true));
$Form->switch_layout('table');
$Form->formstart = '<table id="item_locations" cellspacing="0" class="fform">' . "\n";
$Form->labelstart = '<td class="right"><strong>';
$Form->labelend = '</strong></td>';
echo '<p class="note">' . T_('You can track a hit on a goal every time this page is displayed to a user.') . '</p>';
echo $Form->formstart;
$goal_ID = $edited_Item->get_setting('goal_ID');
$item_goal_cat_ID = 0;
$GoalCache =& get_GoalCache();
if (!empty($goal_ID) && ($item_Goal = $GoalCache->get_by_ID($goal_ID, false, false))) {
    // Get category ID of goal
    $item_goal_cat_ID = $item_Goal->gcat_ID;
}
$GoalCategoryCache =& get_GoalCategoryCache(NT_('No Category'));
$GoalCategoryCache->load_all();
$Form->select_input_object('goal_cat_ID', $item_goal_cat_ID, $GoalCategoryCache, T_('Category'), array('allow_none' => true));
// Get only the goals without a defined redirect url
$goals_where_sql = 'goal_redir_url IS NULL';
if (empty($item_goal_cat_ID)) {
    // Get the goals without category
    $goals_where_sql .= ' AND goal_gcat_ID IS NULL';
} else {
    // Get the goals by category ID
    $goals_where_sql .= ' AND goal_gcat_ID = ' . $DB->quote($item_goal_cat_ID);
Exemple #4
0
    /**
     * Check if item has a goal to insert a hit into DB
     *
     * @return boolean TRUE if goal hit was inser
     */
    function check_goal()
    {
        $goal_ID = $this->get_setting('goal_ID');
        if (empty($goal_ID)) {
            // Item has no goal ID
            return false;
        }
        $GoalCache =& get_GoalCache();
        if (($Goal = $GoalCache->get_by_ID($goal_ID, false, false)) === false) {
            // Goal ID is incorrect
            return false;
        }
        global $Hit, $DB;
        // We need to log the HIT now! Because we need the hit ID!
        $Hit->log();
        // Record a goal hit:
        return $DB->query('INSERT INTO T_track__goalhit
			       ( ghit_goal_ID, ghit_hit_ID, ghit_params )
			VALUES ( ' . $Goal->ID . ', ' . $Hit->ID . ', ' . $DB->quote('item_ID=' . $this->ID) . ' )', 'Record goal hit of item #' . $this->ID);
    }