1
28

Looking for a campaign

Code

Edit the action search in the file actions/search.php to protect the access to a campaign:

  1. require_once 'userprofile.php';

Loads the function user_profile.

  1.         if ($thread_type == 'campaign') {
  2.             if (!(user_has_role('administrator') or (user_has_role('client') and $thread_user_id == user_profile('id')))) {
  3.                 return run('error/notfound', $lang);
  4.             }
  5.             $cloud_name=$cloud_id;
  6.         }

If the thread is a campaign and if the user is not an administrator or not the client who owns the thread, returns a protocol error.

Edit the model cloud to forbid accessing the keywords of a campaign like for the RSS thread or the thread of the newsletters:

Modify the code of the functions cloud_list_tags, cloud_search and cloud_match in the file models/cloud.inc to forbid accessing the keywords of a campaign:

  1.         $join2 .= " AND t.thread_type!='rss' AND t.thread_type!='newsletter' AND t.thread_type!='campaign'";
  1.         $join2 .= " AND t.thread_type!='rss' AND t.thread_type!='newsletter' AND t.thread_type!='campaign'";
  1.         $join2 .= " AND t.thread_type!='rss' AND t.thread_type!='newsletter' AND t.thread_type!='campaign'";

To forbid global searching, i.e. calling the action search without a thread in parameter, set the configuration parameter $search_all to 'cloud' in config.inc:

  1. $search_all='cloud';    // true, false, 'cloud'
Test

Connect as an administrator. Enter in the management part of the site.

Management

Content

Click on the large phone.

Advertisers

  1. BarFoo

Enter izend in the search box. Click the magnifying glass to display the list of campaigns of this advertiser containing the term izend.

Try clicking on one of the keywords in the cloud. Clear the input field and press Enter.

Click on the logo to display the home page. Click the magnifying glass to display the list of all the terms in the index. The page is empty. The terms associated to campaigns are not published.

Git
  1. /izendsms.com
    1. actions
      1. search.php
    2. includes
      1. includes.inc
    3. models
      1. cloud.inc

Commit this version:

$ git status
$ git add --update
$ git commit -m'Adds searching campaigns'

Displaying campaigns, Editing campaigns

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].