2
13

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','longtail','sms');

Create the table content_sms:

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

ALTER TABLE `izendsms_content_sms` ADD PRIMARY KEY (`content_id`,`locale`);
ALTER TABLE `izendsms_content_sms` MODIFY `content_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
Configuration

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

  1. global $supported_threads;
  2.  
  3. $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. global $contents_model, $supported_contents, $limited_contents;
  2.  
  3. $contents_model = array(
  4.     'text'      =>  array('text' => array('type' => 'string', 'null' => true), 'eval' => array('type' => 'boolean', 'default' => false)),
  5.     'infile'    =>  array('path' => array('type' => 'string', 'null' => true)),
  6.     'download'  =>  array('name' => array('type' => 'string', 'null' => true), 'path' => array('type' => 'string', 'null' => true)),
  7.     '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)),
  8.     'youtube'   =>  array('id' => array('type' => 'string', 'null' => true), 'width' => array('type' => 'number', 'default' => 0), 'height' => array('type' => 'number', 'default' => 0), 'miniature' => array('type' => 'string', 'null' => true), 'title' => array('type' => 'string', 'null' => true), 'autoplay' => array('type' => 'boolean'), 'controls' => array('type' => 'boolean'), 'fs' => array('type' => 'boolean'), 'rel' => array('type' => 'boolean'), 'theme' => array('type' => 'enum', 'default' => 'dark')),
  9. //  'longtail'  =>  array('file' => array('type' => 'string', 'null' => true), 'image' => array('type' => 'string', 'null' => true), 'width' => array('type' => 'number', 'default' => 0), 'height' => array('type' => 'number', 'default' => 0), 'icons' => array('type' => 'boolean'), 'skin' => array('type' => 'string', 'null' => true), 'controlbar' => array('type' => 'enum', 'default' => 'none'), 'duration' => array('type' => 'number', 'default' => 0), 'autostart' => array('type' => 'boolean'), 'repeat' => array('type' => 'boolean')),
  10.     'sms'       =>  array('text' => array('type' => 'string', 'null' => true)),
  11. );

Add the type sms to the parameter $supported_contents:

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

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 to the selector for the type of thread in the view editing/threadeditsummary in English and in French:

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

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

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

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

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

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

  1.     $content_sms_text='';

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; ?>

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 echo htmlspecialchars($content_sms_text, ENT_COMPAT, 'UTF-8'); ?></textarea>
  3. <?php break; ?>

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;
  9.         default:

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. Create a thread of type Campaign with the title Bar Foo.

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

Edit the thread Bar Foo.

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.

Add a content of type SMS.

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

a type # or #

contents

Display the node.

Create your multimedia website in a few minutes with iZend - The web engine: http://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 blocks/nodecontent.php includes/config.inc views/en/editing/nodecontenteditor.phtml views/en/editing/threadeditall.phtml views/en/editing/threadeditsummary.phtml views/fr/editing/nodecontenteditor.phtml views/fr/editing/threadeditall.phtml views/fr/editing/threadeditsummary.phtml views/nodecontent.phtml
$ git commit -m'Adds thread type campaign'

IMPORTANT: Edit the DB connector in the file includes/db.inc. Follow the instructions in the file SMS to update the DB.

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].