Managing the campaign thread
Code
Edit the file models/sms.inc:
- require_once 'models/thread.inc';
- function sms_create_campaign_thread($user_id, $lang, $thread_name, $thread_title) {
- global $supported_languages;
- $thread_type='campaign';
- $r = thread_create($lang, $user_id, $thread_name, $thread_title, $thread_type);
- if (!$r) {
- return false;
- }
- extract($r); /* thread_id thread_number */
- foreach ($supported_languages as $clang) {
- $r = thread_set($clang, $thread_id, $thread_name, $thread_title, $thread_type, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false);
- if (!$r) {
- $sql="DELETE FROM $tabthread WHERE thread_id=$thread_id";
- $r = db_delete($sql);
- return false;
- }
- }
- return true;
- }
- function sms_delete_campaign_thread($user_id) {
- $thread_id=sms_get_user_campaign_id($user_id);
- if (!$thread_id) {
- return false;
- }
- if (!thread_delete($thread_id)) {
- return false;
- }
- return true;
- }
- function sms_rename_campaign_thread($user_id, $thread_name, $thread_title) {
- $sqlname=db_sql_arg($thread_name, true);
- $sqltitle=db_sql_arg($thread_title, true, true);
- $tabthread=db_prefix_table('thread');
- $tabthreadlocale=db_prefix_table('thread_locale');
- $sql="UPDATE $tabthreadlocale SET title=$sqltitle, name=$sqlname WHERE thread_id=(SELECT thread_id FROM $tabthread WHERE thread_type='campaign' AND user_id=$user_id)";
- $r = db_update($sql);
- if ($r === false) {
- return false;
- }
- return true;
- }
Edit the file actions/campaigneditsummary.php:
- if ($action == 'create') {
- node_create_content($clang, $node_id, 'sms');
- }
- $viewsms=$thread_contents ? url('campaign', $clang) . '/'. $thread_id . '?' . 'slang=' . $lang : false;
Edit the file actions/campaigneditpage.php:
- $viewsms=$node_name ? url('campaign', $clang) . '/'. $thread_id . '/' . $node_id : false;
Edit the file blocks/searchlist.php:
- else {
- $thread_url=url($thread_type, $lang) . '/'. ($thread_type == 'campaign' ? $thread_id : $thread_name);
- }
- $link_url=$thread_url . '/' . ($thread_type == 'campaign' ? $node_id : $node_name);
Edit the file blocks/register.php:
- require_once 'models/sms.inc';
- $with_info=true;
- $with_client=$is_admin;
- $is_client=true;
- if ($with_client) {
- $is_client=isset($_POST['register_isclient']) ? (readarg($_POST['register_isclient']) == 'on' ? true : false) : false;
- }
- if ($with_info and !($with_client and !$is_client)) {
- if ($with_info and !($with_client and !$is_client)) {
- if ($is_client) {
- $r = sms_create_campaign_thread($user_id, $locale, $name, "$firstname $lastname");
- if (!$r) {
- $internal_error=true;
- break;
- }
- user_set_role($user_id, 'client');
- $newsletter=true;
- }
- $output = view('register', $lang, compact('token', 'connectbar', 'with_captcha', 'with_name', 'with_website', 'with_timezone', 'with_password', 'with_newsletter', 'with_confirmation', 'name', 'mail', 'website', 'timezone', 'password', 'with_client', 'is_client', 'with_info', 'lastname', 'firstname', 'newsletter', 'confirmed', 'account_created', 'errors', 'infos'));
Modify the view register
in English and in French in the files views/en/register.phtml and views/fr/register.phtml:
- <?php if ($with_client): ?>
- <p><input type="checkbox" name="register_isclient" id="register_isclient" title=""<?php if ($is_client): ?> checked="checked"<?php endif; ?> /> I want to create a client account</p>
- <?php endif; ?>
- <?php if ($with_client): ?>
- <p><input type="checkbox" name="register_isclient" id="register_isclient" title=""<?php if ($is_client): ?> checked="checked"<?php endif; ?> /> Je veux créer un compte client</p>
- <?php endif; ?>
Edit the file blocks/useredit.php:
- $user_role = user_get_role($user_id);
- $is_client=$user_role && in_array('client', $user_role);
- $with_info=$is_client;
- if ($is_owner) {
- $_SESSION['user']['lastname'] = $user_lastname;
- $_SESSION['user']['firstname'] = $user_firstname;
- }
- if ($is_client) {
- require_once 'models/sms.inc';
- $r = sms_rename_campaign_thread($user_id, $user_name, "$user_firstname $user_lastname");
- if (!$r) {
- $internal_error=true;
- break;
- }
- }
- $r = user_delete($user_id);
- if (!$r) {
- $internal_error=true;
- break;
- }
- if ($is_client) {
- require_once 'models/sms.inc';
- $r = sms_delete_campaign_thread($user_id);
- if (!$r) {
- $internal_error=true;
- break;
- }
- }
Test
Disconnect then go the identification page and follow the link To create your personal account, click here.
New account
What is your first name?
And your last name?
Create an account for John Smith
with the identifier jsmith
.
Connect with the identifier jsmith
.
Click on the large phone to list John Smith's campaigns.
John Smith
Click on the keyboard to enter the editor.
John Smith
the campaign #
Add the campaign with the title The web engine
.
Press on the flag to display the list of campaigns in French. IMPORTANT: The version of a campaign in another language is created in the editor of a campaign.
Press on the flag to display the list of campaigns in English. Click on the title The web engine.
Type Create your multimedia website in a few minutes with iZend - The web engine: http://www.izend.org.
for the content of the message, associate the campaign to the keywords iZend web engine
in the cloud and give it the subject Initial campaign for web agencies
.
Press Configure.
Click on the to switch into display mode.
Click on iZend
in the cloud.
Click on the title The web engine to display the campaign.
Go back into the editor and click on the flag to create a version in French. Notice that the title of the campaign is a number.
Try creating a campaign without a title by pressing Configure. The operation is rejected.
Create a campaign in French with the title Le moteur web
, the cloud iZend moteur web
, the subject Campagne initialed pour les agences web
and the message Créez votre site multimédias en quelques minutes avec iZend - Le moteur web : http://www.izend.org
.
Press Configure.
Click on the web to switch into display mode.
Go back into the editor , click on the the flag , display the campaign in English, click on Campaigns at the top right above the cloud. Enter the editor and press on the flag to switch languages. The campaign has one version in English and one in French.
Click on the logo to return to the home page. Follow the link To modify your identifier, your email or change your password, click here.
Change the firstname, the lastname and the identifier, e.g. Peter Miller pmiller
.
Go back to the home page and display the list of campaigns. The title has changed.
Peter Miller
Disconnect and reconnect as administrator.
Enter into the management part then look for pmiller
and edit the account.
Modify the firstname, the lastname and the identifier, e.g. John Smith jsmith
.
Go back to the management part and list the advertizers. Display John Smith's campaigns.
Export the DB of the site.
Delete the account jsmith
.
Check that the campaign thread of the account and all the nodes and all the contents of the thread have been deleted from the DB.
Git
- /izendsms.com
- actions
- campaigneditpage.php
- campaigneditsummary.php
- blocks
- register.php
- searchlist.php
- useredit.php
- models
- sms.inc
- views
- en
- register.phtml
- fr
- register.phtml
- en
- actions
Commit this version:
$ git status
$ git add actions/campaigneditpage.php actions/campaigneditsummary.php blocks/register.php blocks/useredit.php models/sms.inc views/en/register.phtml views/fr/register.phtml
$ git commit -m'Adds creating and managing campaign threads with client accounts'
IMPORTANT: Edit the DB connector in the file includes/db.inc.
Comments