[opw-web] Add "application_prefill"



commit 9517d685f5fd5517c9a5095ddecec9e16b27e7f6
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Mar 14 21:13:36 2016 -0400

    Add "application_prefill"
    
    For each program, let the administrator specify text that will be filled into
    the "Application Text" field for new applications or applications where nothing
    has been filled in yet.

 lang/en-gb.php                                     |    1 +
 modules/mod_manage_programs.php                    |    9 +++++++--
 modules/mod_view_projects.php                      |    4 ++++
 schema.sql                                         |    2 ++
 .../html/tpl_manage_programs_editor.html           |    7 +++++++
 5 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/lang/en-gb.php b/lang/en-gb.php
index 701d2f7..f32306a 100644
--- a/lang/en-gb.php
+++ b/lang/en-gb.php
@@ -51,6 +51,7 @@ $lang_data = array(
     'project_title'         => 'Project title',
     'organization'          => 'Organization',
     'description'           => 'Description',
+    'application_prefill'   => 'Initial application text',
     'no_programs'           => 'There are no programs to display',
     'no_organizations'      => 'There are no organizations to display',
     'error_occurred'        => 'An error occurred while processing your request',
diff --git a/modules/mod_manage_programs.php b/modules/mod_manage_programs.php
index 07e7ef6..9a0f129 100644
--- a/modules/mod_manage_programs.php
+++ b/modules/mod_manage_programs.php
@@ -12,6 +12,7 @@ $action = $core->variable('a', 'list');
 $id = $core->variable('p', 0);
 $title = $core->variable('title', '', false, true);
 $description = $core->variable('description', '', false, true);
+$application_prefill = $core->variable('application_prefill', '', false, true);
 $start_date = $core->variable('start_date', '', false, true);
 $end_date = $core->variable('end_date', '', false, true);
 $dl_student_date = $core->variable('dl_student', '', false, true);
@@ -104,6 +105,7 @@ else if ($action == 'editor')
             $params = array('id' => $id,
                             'title' => $title,
                             'description' => $description,
+                            'application_prefill' => $application_prefill,
                             'start_time' => $start_time,
                             'end_time' => $end_time,
                             'dl_student' => $dl_student,
@@ -119,6 +121,7 @@ else if ($action == 'editor')
                 $sql = "UPDATE {$db->prefix}programs " .
                        "SET title = :title, " .
                        "    description = :description, " .
+                       "    application_prefill = :application_prefill, " .
                        "    start_time = :start_time, " .
                        "    end_time = :end_time, " .
                        "    dl_student = :dl_student, " .
@@ -142,9 +145,9 @@ else if ($action == 'editor')
             {
                 // Insert program data
                 $sql = "INSERT INTO {$db->prefix}programs " .
-                       "(title, description, start_time, end_time, " .
+                       "(title, description, application_prefill, start_time, end_time, " .
                        " dl_student, dl_mentor, is_active) " .
-                       "VALUES (:title, :description, :start_time, " .
+                       "VALUES (:title, :description, :application_prefill, :start_time, " .
                        "        :end_time, :dl_student, :dl_mentor, :active)";
                 $db->query($sql, $params);
 
@@ -176,6 +179,7 @@ else if ($action == 'editor')
         // Set loaded data
         $title = $row['title'];
         $description = $row['description'];
+        $application_prefill = $row['application_prefill'];
         $start_date = date('M d Y, h:i a', $row['start_time']);
         $end_date = date('M d Y, h:i a', $row['end_time']);
         $dl_student = date('M d Y, h:i a', $row['dl_student']);
@@ -189,6 +193,7 @@ else if ($action == 'editor')
         'editor_title'      => $page_title,
         'title'             => htmlspecialchars($title),
         'description'       => escapenewlines(htmlspecialchars($description)),
+        'application_prefill' => escapenewlines(htmlspecialchars($application_prefill)),
         'start_date'        => $start_date,
         'end_date'          => $end_date,
         'dl_student'        => $dl_student,
diff --git a/modules/mod_view_projects.php b/modules/mod_view_projects.php
index 1220b07..a983aba 100644
--- a/modules/mod_view_projects.php
+++ b/modules/mod_view_projects.php
@@ -125,6 +125,10 @@ if ($action == 'editor')
         }
     }
 
+    // Prefill text from the program admin if no text has been saved yet
+    if ($description == '')
+      $description = $program_data['application_prefill'];
+
     // Only mentor/admins can mark project as complete and pass a student
     $can_decide = ($role == 'm' && $is_owner) || $user->is_admin;
 
diff --git a/schema.sql b/schema.sql
index 2265791..6f0c25d 100644
--- a/schema.sql
+++ b/schema.sql
@@ -7,10 +7,12 @@ INSERT INTO `opw_cron` (
 ) VALUES (0);
 
 /* alter table opw_programs add `contracts_active` tinyint(1) NOT NULL DEFAULT 0 ; */
+/* alter table opw_programs add `application_prefill` mediumtext NOT NULL DEFAULT '' ; */
 CREATE TABLE `opw_programs` (
   `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT,
   `title` varchar(255) NOT NULL DEFAULT '',
   `description` mediumtext DEFAULT '',
+  `application_prefill` mediumtext DEFAULT '',
   `start_time` int(11) unsigned NOT NULL,
   `end_time` int(11) unsigned NOT NULL,
   `dl_student` int(11) unsigned NOT NULL,
diff --git a/skins/easterngreen/html/tpl_manage_programs_editor.html 
b/skins/easterngreen/html/tpl_manage_programs_editor.html
index 7df24ad..2cbef5b 100644
--- a/skins/easterngreen/html/tpl_manage_programs_editor.html
+++ b/skins/easterngreen/html/tpl_manage_programs_editor.html
@@ -25,6 +25,13 @@
 </div>
 
 <div class="control-group">
+    <label class="control-label">{{application_prefill}} &nbsp;</label>
+    <div class="controls">
+        <textarea name="application_prefill" rows="8" 
class="input-xxlarge">[[application_prefill]]</textarea>
+    </div>
+</div>
+
+<div class="control-group">
     <label class="control-label">{{start_date}} *</label>
     <div class="controls">
         <input type="text" name="start_date" class="input-medium datepicker" value="[[start_date]]"  />


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]