2
52

Campaign thread

DB

Add the value campaign to the field thread_type to the table thread:

ALTER TABLE `izendsms_thread` CHANGE `thread_type` `thread_type` ENUM('thread','folder','story','book','rss','newsletter','campaign');

Add the value sms to the field content_type to the table node_content:

ALTER TABLE `izendsms_node_content` CHANGE `content_type` `content_type` ENUM('text','file','download','infile','youtube','sms');

Create the table content_sms:

CREATE TABLE `izendsms_content_sms` (
  `content_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `locale` enum('en','fr') NOT NULL DEFAULT 'fr',
  `text` text,
  PRIMARY KEY (`content_id`,`locale`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Configuration

In the file config.inc, add to thread type campaign to the parameter $supported_threads :

  1. $supported_threads=array('thread', 'folder', 'story', 'book', 'rss', 'newsletter', 'campaign'); // 'thread', 'folder', 'story', 'book', 'rss', 'newsletter'

Add the description of a sms content to the parameter $contents_model:

  1. $contents_model = array(
  2.     'text'      =>  array('text' => array('type' => 'string', 'null' => true), 'eval' => array('type' => 'boolean', 'default' => false)),
  3.     'infile'    =>  array('path' => array('type' => 'string', 'null' => true)),
  4.     'download'  =>  array('name' => array('type' => 'string', 'null' => true), 'path' => array('type' => 'string', 'null' => true)),
  5.     'file'      =>  array('path' => array('type' => 'string', 'null' => true), 'start' => array('type' => 'number', 'default' => 0), 'end' => array('type' => 'number', 'default' => 0), 'format' => array('type' => 'string', 'null' => true), 'lineno' => array('type' => 'boolean', 'default' => true)),
  6.     'youtube'   =>  array('id' => array('type' => 'string', 'null' => true), 'width' => array('type' => 'number', 'default' => 0), 'height' => array('type' => 'number', 'default' => 0), 'center' => array('type' => 'boolean'), 'miniature' => array('type' => 'string', 'null' => true), 'title' => array('type' => 'string', 'null' => true), 'autoplay' => array('type' => 'boolean')),
  7.     'sms'       =>  array('text' => array('type' => 'string', 'null' => true)),
  8. );

Add the type sms to the parameter $supported_contents:

  1. $supported_contents=array('text', 'infile', 'download', 'file', 'youtube', 'sms');  // 'text', 'infile', 'download', 'file', 'youtube'

Limit the types of contents of the thread type campaign to sms by editing the parameter $limited_contents:

  1. $limited_contents=array('rss' => array('text'), 'newsletter' => array('text'), 'campaign' => array('sms'));
Code

Add the option campaign after the option newsletter to the selector for the type of thread in the view editing/threadeditsummary in English and in French:

  1. <?php elseif ($type == 'newsletter'): ?>
  2. <option value="newsletter"<?php if ($thread_type == 'newsletter'): ?> selected="selected"<?php endif; ?>>Newsletter</option>
  3. <?php elseif ($type == 'campaign'): ?>
  4. <option value="campaign"<?php if ($thread_type == 'campaign'): ?> selected="selected"<?php endif; ?>>Campaign</option>
  5. <?php endif; ?>
  1. <?php elseif ($type == 'newsletter'): ?>
  2. <option value="newsletter"<?php if ($thread_type == 'newsletter'): ?> selected="selected"<?php endif; ?>>Infolettre</option>
  3. <?php elseif ($type == 'campaign'): ?>
  4. <option value="campaign"<?php if ($thread_type == 'campaign'): ?> selected="selected"<?php endif; ?>>Campagne</option>
  5. <?php endif; ?>

Add the option campaign after the option newsletter to the selector for the type of thread in the view editing/threadeditall in English and in French:

  1. <?php elseif ($type == 'newsletter'): ?>
  2. <option value="newsletter"<?php if ($new_thread_type == 'newsletter'): ?> selected="selected"<?php endif; ?>>Newsletter</option>
  3. <?php elseif ($type == 'campaign'): ?>
  4. <option value="campaign"<?php if ($new_thread_type == 'campaign'): ?> selected="selected"<?php endif; ?>>Campaign</option>
  5. <?php endif; ?>
  1. <?php elseif ($type == 'newsletter'): ?>
  2. <option value="newsletter"<?php if ($new_thread_type == 'newsletter'): ?> selected="selected"<?php endif; ?>>Infolettre</option>
  3. <?php elseif ($type == 'campaign'): ?>
  4. <option value="campaign"<?php if ($new_thread_type == 'campaign'): ?> selected="selected"<?php endif; ?>>Campagne</option>
  5. <?php endif; ?>

Add processing a content type sms after the content type youtube in the view editing/nodecontenteditor in English and in French:

  1. <?php elseif ($type == 'youtube'): ?>
  2. <option value="youtube" <?php echo $selected == 'youtube' ? 'selected="youtube"' : ''; ?>>YouTube</option>
  3. <?php elseif ($type == 'sms'): ?>
  4. <option value="sms" <?php echo $selected == 'sms' ? 'selected="selected"' : ''; ?>>SMS</option>
  5. <?php endif; ?>

Adds the option sms after the option youtube to the selector for the content type.

  1.     $content_sms_text='';
  2.     extract($c);    /* content_id content_number content_ignored content_type ... */

Initializes the variable containing the text of the SMS bebore extracting the data collected by the block nodecontenteditor.

  1. <?php case 'sms': ?>
  2. <label>SMS:</label>
  3. <?php break; ?>
  4. <?php endswitch; ?>

Displays the label of the content.

  1. <?php case 'sms': ?>
  2. <textarea id="content_sms_text_<?php echo $i; ?>" name="content_sms_text[<?php echo $i; ?>]" cols="80" rows="5"><?php if ($content_sms_text): ?><?php echo htmlspecialchars($content_sms_text, ENT_COMPAT, 'UTF-8'); ?><?php endif; ?></textarea>
  3. <?php break; ?>
  4. <?php endswitch; ?>

Displays the input field of the text of a SMS.

Adds displaying a content of type sms to the view nodecontent:

  1.         case 'sms':
  2.             $text = $c['text'];
  3.             if ($text) {
  4.                 echo '<div class="sms">', PHP_EOL;
  5.                 echo '<p>', htmlspecialchars($text, ENT_COMPAT, 'UTF-8'), '</p>', PHP_EOL;
  6.                 echo '</div>', PHP_EOL;
  7.             }
  8.             break;

Adds preparing the parameters of the view for a content of type sms in the block nodecontent:

  1.                 case 'sms':
  2.                     $text=$c['content_sms_text'];
  3.                     $contents[] = compact('type', 'text');
  4.                     break;
Test

Connect as an administrator. Navigate in the editor to the list of threads. Add a thread of type Campaign with the title BarFoo.

NOTE: This thread contains all the campaigns managed by a client. In a later chapter, it will be created automatically when a new user is registered.

Edit the thread BarFoo.

Create a content with the title The web engine. Edit it.

Enter First promotional campaign of iZend for software editors for the abstract and the keywords iZend web engine in the cloud. Uncheck all the options.

Press Edit.

Add a content of type SMS.

Type Create your multimedia website in a few minutes with iZend - The web engine: https://www.izend.org for the text of the SMS.

a type # or #

contents

Press Modify.

Display the node.

Create your multimedia website in a few minutes with iZend - The web engine: https://www.izend.org

Click on the keyboard to go back to editing mode.

Press on the flag to display the version in French.

Enter the title Le moteur web.

Enter Première campagne de promotion d'iZend auprès des éditeurs de logiciels for the abstract and the keywords iZend moteur web in the cloud. Press Edit.

Enter Créez votre site multimédias en quelques minutes avec iZend - Le moteur web : https://www.izend.org for the text of the SMS. Press Modify.

Display the node.

Créez votre site multimédias en quelques minutes avec iZend - Le moteur web : https://www.izend.org

Git
  1. /izendsms.com
    1. blocks
      1. nodecontent.php
    2. includes
      1. config.inc
    3. views
      1. nodecontent.phtml
      2. en
        1. editing
          1. nodecontenteditor.phtml
          2. threadeditall.phtml
          3. threadeditsummary.phtml
      3. fr
        1. editing
          1. nodecontenteditor.phtml
          2. threadeditall.phtml
          3. threadeditsummary.phtml

Commit this version:

$ git status
$ git add --update
$ git commit -m'Adds thread type campaign'

Client space, Displaying 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].