Completed plugin first version. Includes user capability features.
authorChuck Scott <cscott@gaslightmedia.com>
Wed, 12 Nov 2014 03:18:03 +0000 (22:18 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Wed, 12 Nov 2014 03:18:03 +0000 (22:18 -0500)
13 files changed:
controllers/admin.php
index.php
lib/smartyTemplateSupport.php
models/activate.php
models/admin/add/index.php
models/admin/prototypes/display.php
models/admin/prototypes/edit.php
models/admin/prototypes/index.php
models/deactivate.php
views/admin/add/index.html
views/admin/prototypes/display.html
views/admin/prototypes/edit.html
views/admin/prototypes/index.html

index ca0deb7..1877d65 100644 (file)
@@ -185,7 +185,7 @@ class glmProtoAdmin
 
         // Add a new main menu item for management and display of customer
         // prototypes.
-        add_menu_page('Site Prototypes', 'Prototypes', 'manage_options',
+        add_menu_page('Site Prototypes', 'Prototypes', 'read',
                 'glm-proto-admin-menu-prototypes',
                 array(
                         $this,
@@ -195,12 +195,18 @@ class glmProtoAdmin
         // Add sub-menu for adding a new prototype under the Prototypes main
         // menu item.
 
-        add_submenu_page('glm-proto-admin-menu-prototypes', 'Site Prototypes',
-                'Add', 'manage_options', 'glm-proto-admin-menu-add',
-                array(
-                        $this,
-                        'glmProtoAdminMenuAdd'
-                ));
+        // See if user is permitted to add, edit, and delete prototypes
+        $canEdit = current_user_can('glm_proto_edit');
+        $user_ID = get_current_user_id();
+        if ($canEdit) {
+            add_submenu_page('glm-proto-admin-menu-prototypes',
+                    'Site Prototypes', 'Add', 'manage_options',
+                    'glm-proto-admin-menu-add',
+                    array(
+                            $this,
+                            'glmProtoAdminMenuAdd'
+                    ));
+        }
     }
 
     /*
@@ -272,7 +278,8 @@ class glmProtoAdmin
      *
      * Controller parameters
      *
-     * @menuItem string Name of the menu item that is being processed
+     * @param string $menuItem
+     *            Name of the menu item that is being processed
      *
      * @return void
      * @access public
@@ -358,16 +365,15 @@ class glmProtoAdmin
         $smarty = new smartyTemplateSupport();
 
         // Add some standard parameters
-        $smarty->templateAssign(
-                array(
-                        'request_uri' => $_SERVER['REQUEST_URI']
-                ));
+        $smarty->templateAssign('request_uri', $_SERVER['REQUEST_URI']);
 
         // Add data from model to Smarty template
         $haveData = false;
         if (is_array($results['data']) && count($results['data']) > 0) {
-            $haveData = true;
-            $smarty->templateAssign('data', $results['data']);
+            foreach ($results['data'] as $k => $d) {
+                $haveData = true;
+                $smarty->templateAssign($k, $d);
+            }
         }
         $smarty->templateAssign('haveData', $haveData);
 
index 85e9752..ce0cdf7 100644 (file)
--- a/index.php
+++ b/index.php
@@ -209,9 +209,9 @@ function glmProtoPluginDeactivate ()
 {
     global $wpdb;
     require_once (GLM_PROTO_PLUGIN_DIR . '/models/deactivate.php');
-    new glmProtoPluginDectivate($wpdb);
+    new glmProtoPluginDeactivate($wpdb);
 }
-register_deactivation_hook(__FILE__, 'glmProtoPluginDeativate');
+register_deactivation_hook(__FILE__, 'glmProtoPluginDeactivate');
 
 // Uninstall
 function glmProtoPluginUninstall ()
index 39244a3..7325035 100644 (file)
@@ -76,12 +76,11 @@ class smartyTemplateSupport
      * Assign parameters to the template
      *
      * This method assigns either one parameter to the template object in this
-     * class
-     * or an array of parameters.
+     * class or an array of parameters.
      *
      * Submit an array of parameters to the template.
      *
-     * @param array Array of arrays with parameter name (key), value pairs
+     * @name array Array of arrays with parameter name (key), value pairs
      *
      * or
      *
@@ -97,7 +96,6 @@ class smartyTemplateSupport
 
         // If this is a single assignment
         if ($value !== null) {
-
             $this->template->assign($param, $value);
 
             // Otherwise it's an array of parameter/value pairs
index 4d6b5cd..2141999 100644 (file)
@@ -17,6 +17,9 @@
 /*
  * This class performs all necessary additional work when this
  * plugin is activated.
+ *
+ * Currently the only actions are to add role capability to display and modify
+ * prototypes.
  */
 class glmProtoPluginActivate
 {
@@ -45,7 +48,42 @@ class glmProtoPluginActivate
         // Save WordPress Database object
         $this->wpdb = $wpdb;
 
-        // Perform any activation tasks here
+        /*
+         * Perform any activation tasks here
+         */
+
+        // Add user capabilties
+        $this->addRoleCapability('glm_proto_edit', false);
+    }
+
+    /*
+     * Add a role capability to all current roles
+     *
+     * @param string $capability Name of capability to add
+     * @param string $default Whether capability should be on by default
+     *
+     * @return void
+     * @access public
+     */
+    public function addRoleCapability ($capability, $default)
+    {
+        // Get list of role objects
+        $roleObjects = $GLOBALS['wp_roles']->role_objects;
+
+        // Get list of roles we can edit
+        $roles = get_editable_roles();
+
+        // For each role object
+        foreach ($roleObjects as $key => $role) {
+
+            // Check if the role exists in list of editable roles and capability
+            // does not exist
+            if (isset($roles[$key]) && ! isset($role->capabilities[$capability])) {
+
+                // Add the role
+                $role->add_cap($capability, $default);
+            }
+        }
     }
 }
 
index 6bc1ae7..1c6bac8 100644 (file)
@@ -90,7 +90,7 @@ class glmProtoAdmin_add_index
      */
     public function modelAction ()
     {
-        $data = array(
+        $content = array(
                 'glm_proto_title' => '',
                 'glm_proto_title_error' => '',
                 'glm_proto_width' => '1500',
@@ -111,51 +111,51 @@ class glmProtoAdmin_add_index
         if (isset($_REQUEST['glm_proto_title'])) {
 
             // Clean up all input
-            $data['glm_proto_title'] = sanitize_text_field(
+            $content['glm_proto_title'] = sanitize_text_field(
                     $_REQUEST['glm_proto_title']);
-            $data['glm_proto_width'] = sanitize_text_field(
+            $content['glm_proto_width'] = sanitize_text_field(
                     $_REQUEST['glm_proto_width']);
-            $data['glm_proto_height'] = sanitize_text_field(
+            $content['glm_proto_height'] = sanitize_text_field(
                     $_REQUEST['glm_proto_height']);
-            $data['glm_proto_background'] = sanitize_text_field(
+            $content['glm_proto_background'] = sanitize_text_field(
                     $_REQUEST['glm_proto_background']);
-            $data['glm_proto_prototype'] = sanitize_text_field(
+            $content['glm_proto_prototype'] = sanitize_text_field(
                     $_REQUEST['glm_proto_prototype']);
 
             // Check title field
-            if ($data['glm_proto_title'] == '') {
-                $data['glm_proto_title_error'] = 'Required title not supplied';
+            if ($content['glm_proto_title'] == '') {
+                $content['glm_proto_title_error'] = 'Required title not supplied';
                 $submitError = true;
             }
 
             // Check width field
-            if ($data['glm_proto_width'] == '') {
-                $data['glm_proto_width_error'] = 'Required width not supplied';
+            if ($content['glm_proto_width'] == '') {
+                $content['glm_proto_width_error'] = 'Required width not supplied';
                 $submitError = true;
             }
 
             // Check height field
-            if ($data['glm_proto_height'] == '') {
-                $data['glm_proto_height_error'] = 'Required height not supplied';
+            if ($content['glm_proto_height'] == '') {
+                $content['glm_proto_height_error'] = 'Required height not supplied';
                 $submitError = true;
             }
 
             // Check background image - Not required but must exist if provided
-            if ($data['glm_proto_background'] != '' && ! $this->glmProtoIsUploaded(
-                    $data['glm_proto_background'])) {
-                $data['glm_proto_background_error'] = 'Supplied background image does not exists';
+            if ($content['glm_proto_background'] != '' && ! $this->glmProtoIsUploaded(
+                    $content['glm_proto_background'])) {
+                $content['glm_proto_background_error'] = 'Supplied background image does not exists';
                 $submitError = true;
             }
 
             // Check prototype image
-            if ($data['glm_proto_prototype'] == '') {
-                $data['glm_proto_prototype_error'] = 'Required prototype image not supplied ';
+            if ($content['glm_proto_prototype'] == '') {
+                $content['glm_proto_prototype_error'] = 'Required prototype image not supplied ';
                 $submitError = true;
             } else {
                 $exists = $this->glmProtoIsUploaded(
-                        $data['glm_proto_prototype']);
+                        $content['glm_proto_prototype']);
                 if (! $exists) {
-                    $data['glm_proto_prototype_error'] .= 'Supplied prototype image does not exists';
+                    $content['glm_proto_prototype_error'] .= 'Supplied prototype image does not exists';
                     $submitError = true;
                 }
             }
@@ -169,13 +169,13 @@ class glmProtoAdmin_add_index
                 $gmtDate = date('Y-m-d', time());
                 date_default_timezone_set($timezoneBackup);
 
-                $content = serialize(
+                $contentSerialized = serialize(
                         array(
-                                'title' => $data['glm_proto_title'],
-                                'width' => $data['glm_proto_width'],
-                                'height' => $data['glm_proto_height'],
-                                'background' => $data['glm_proto_background'],
-                                'prototype' => $data['glm_proto_prototype']
+                                'title' => $content['glm_proto_title'],
+                                'width' => $content['glm_proto_width'],
+                                'height' => $content['glm_proto_height'],
+                                'background' => $content['glm_proto_background'],
+                                'prototype' => $content['glm_proto_prototype']
                         ));
 
                 // Store into wp_posts table
@@ -183,15 +183,15 @@ class glmProtoAdmin_add_index
                         array(
                                 'post_date' => $date,
                                 'post_date_gmt' => $gmtDate,
-                                'post_content' => $content,
-                                'post_title' => $data['glm_proto_title'],
+                                'post_content' => $contentSerialized,
+                                'post_title' => $content['glm_proto_title'],
                                 'post_type' => 'glm_proto'
                         ));
 
                 // If there was a problem storing the prototype, pass that to
                 // the template
                 if (! $result) {
-                    $data['glm_proto_title_error'] = 'There was an unknown problem storing this prototype.';
+                    $content['glm_proto_title_error'] = 'There was an unknown problem storing this prototype.';
                 }
 
                 $prototypeSubmitted = true;
@@ -218,7 +218,9 @@ class glmProtoAdmin_add_index
                 'menuItemRedirect' => false,
                 'modelRedirect' => false,
                 'view' => $view,
-                'data' => $data
+                'data' => array(
+                        'content' => $content
+                )
         );
     }
 
index 49d59e1..2945d69 100644 (file)
@@ -107,7 +107,6 @@ class glmProtoAdmin_prototypes_display
                 $d = unserialize($res['post_content']);
                 $res['content'] = $d;
             }
-
         }
 
         // Return status, any suggested view, and any data to controller
@@ -116,7 +115,9 @@ class glmProtoAdmin_prototypes_display
                 'menuItemRedirect' => false,
                 'modelRedirect' => false,
                 'view' => 'admin/prototypes/display.html',
-                'data' => $res['content']
+                'data' => array(
+                        'content' => $res['content']
+                )
         );
     }
 }
index 39f5533..f8fecf9 100644 (file)
@@ -117,7 +117,7 @@ class glmProtoAdmin_prototypes_edit
         }
 
         // Setup input data array
-        $data = array(
+        $content = array(
                 'glm_proto_title' => $content['title'],
                 'glm_proto_title_error' => '',
                 'glm_proto_width' => $content['width'],
@@ -138,51 +138,51 @@ class glmProtoAdmin_prototypes_edit
         if (isset($_REQUEST['glm_proto_title'])) {
 
             // Clean up all input
-            $data['glm_proto_title'] = sanitize_text_field(
+            $content['glm_proto_title'] = sanitize_text_field(
                     $_REQUEST['glm_proto_title']);
-            $data['glm_proto_width'] = sanitize_text_field(
+            $content['glm_proto_width'] = sanitize_text_field(
                     $_REQUEST['glm_proto_width']);
-            $data['glm_proto_height'] = sanitize_text_field(
+            $content['glm_proto_height'] = sanitize_text_field(
                     $_REQUEST['glm_proto_height']);
-            $data['glm_proto_background'] = sanitize_text_field(
+            $content['glm_proto_background'] = sanitize_text_field(
                     $_REQUEST['glm_proto_background']);
-            $data['glm_proto_prototype'] = sanitize_text_field(
+            $content['glm_proto_prototype'] = sanitize_text_field(
                     $_REQUEST['glm_proto_prototype']);
 
             // Check title field
-            if ($data['glm_proto_title'] == '') {
-                $data['glm_proto_title_error'] = 'Required title not supplied';
+            if ($content['glm_proto_title'] == '') {
+                $content['glm_proto_title_error'] = 'Required title not supplied';
                 $submitError = true;
             }
 
             // Check width field
-            if ($data['glm_proto_width'] == '') {
-                $data['glm_proto_width_error'] = 'Required width not supplied';
+            if ($content['glm_proto_width'] == '') {
+                $content['glm_proto_width_error'] = 'Required width not supplied';
                 $submitError = true;
             }
 
             // Check height field
-            if ($data['glm_proto_height'] == '') {
-                $data['glm_proto_height_error'] = 'Required height not supplied';
+            if ($content['glm_proto_height'] == '') {
+                $content['glm_proto_height_error'] = 'Required height not supplied';
                 $submitError = true;
             }
 
             // Check background image - Not required but must exist if provided
-            if ($data['glm_proto_background'] != '' && ! $this->glmProtoIsUploaded(
-                    $data['glm_proto_background'])) {
-                $data['glm_proto_background_error'] = 'Supplied background image does not exists';
+            if ($content['glm_proto_background'] != '' && ! $this->glmProtoIsUploaded(
+                    $content['glm_proto_background'])) {
+                $content['glm_proto_background_error'] = 'Supplied background image does not exists';
                 $submitError = true;
             }
 
             // Check prototype image
-            if ($data['glm_proto_prototype'] == '') {
-                $data['glm_proto_prototype_error'] = 'Required prototype image not supplied ';
+            if ($content['glm_proto_prototype'] == '') {
+                $content['glm_proto_prototype_error'] = 'Required prototype image not supplied ';
                 $submitError = true;
             } else {
                 $exists = $this->glmProtoIsUploaded(
-                        $data['glm_proto_prototype']);
+                        $content['glm_proto_prototype']);
                 if (! $exists) {
-                    $data['glm_proto_prototype_error'] .= 'Supplied prototype image does not exists';
+                    $content['glm_proto_prototype_error'] .= 'Supplied prototype image does not exists';
                     $submitError = true;
                 }
             }
@@ -196,13 +196,13 @@ class glmProtoAdmin_prototypes_edit
                 $gmtDate = date('Y-m-d', time());
                 date_default_timezone_set($timezoneBackup);
 
-                $content = serialize(
+                $contentSerialized = serialize(
                         array(
-                                'title' => $data['glm_proto_title'],
-                                'width' => $data['glm_proto_width'],
-                                'height' => $data['glm_proto_height'],
-                                'background' => $data['glm_proto_background'],
-                                'prototype' => $data['glm_proto_prototype']
+                                'title' => $content['glm_proto_title'],
+                                'width' => $content['glm_proto_width'],
+                                'height' => $content['glm_proto_height'],
+                                'background' => $content['glm_proto_background'],
+                                'prototype' => $content['glm_proto_prototype']
                         ));
 
                 // Store into wp_posts table
@@ -211,8 +211,8 @@ class glmProtoAdmin_prototypes_edit
                         array(
                                 'post_date' => $date,
                                 'post_date_gmt' => $gmtDate,
-                                'post_content' => $content,
-                                'post_title' => $data['glm_proto_title'],
+                                'post_content' => $contentSerialized,
+                                'post_title' => $content['glm_proto_title'],
                                 'post_type' => 'glm_proto'
                         ),
                         array(
@@ -222,7 +222,7 @@ class glmProtoAdmin_prototypes_edit
                 // If there was a problem storing the prototype, pass that to
                 // the template
                 if (! $result) {
-                    $data['glm_proto_title_error'] = 'There was an unknown problem updating this prototype.';
+                    $content['glm_proto_title_error'] = 'There was an unknown problem updating this prototype.';
                 }
 
                 $prototypeSubmitted = true;
@@ -249,7 +249,9 @@ class glmProtoAdmin_prototypes_edit
                 'menuItemRedirect' => false,
                 'modelRedirect' => false,
                 'view' => $view,
-                'data' => $data
+                'data' => array(
+                    'content' => $content
+                )
         );
     }
 
index 8c8bc71..43738af 100644 (file)
@@ -102,13 +102,19 @@ class glmProtoAdmin_prototypes_index
             }
         }
 
+        // Determine if current user can add, edit, delete prototypes
+        $canEdit = current_user_can('glm_proto_edit');
+
         // Return status, suggested view, and data to controller
         return array(
                 'status' => $success,
                 'menuItemRedirect' => false,
                 'modelRedirect' => false,
                 'view' => 'admin/prototypes/index.html',
-                'data' => $list
+                'data' => array(
+                        'prototypes' => $list,
+                        'canEdit' => $canEdit
+                )
         );
     }
 
index 7022c29..9555394 100644 (file)
@@ -45,7 +45,36 @@ class glmProtoPluginDeactivate
         // Save WordPress Database object
         $this->wpdb = $wpdb;
 
-        // Perform any deactivation tasks here
+        // Add user capabilties
+        $this->removeRoleCapability('glm_proto_edit');
+    }
+
+    /*
+     * Remove a role capability from all current roles
+     *
+     * @param string $capability
+     *
+     * @return void
+     * @access public
+     */
+    public function removeRoleCapability ($capability)
+    {
+        // Get list of role objects
+        $roleObjects = $GLOBALS['wp_roles']->role_objects;
+
+        // Get list of roles we can edit
+        $roles = get_editable_roles();
+
+        // For each role object
+        foreach ($roleObjects as $key => $role) {
+            // Check if the role exists in list of editable roles and capability
+            // does not exist
+            if (isset($roles[$key]) && isset($role->capabilities[$capability])) {
+
+                // Remove role
+                $role->remove_cap($capability);
+            }
+        }
     }
 }
 
index f7270a4..713453d 100644 (file)
@@ -2,44 +2,44 @@
     
     <h2>Add a New Prototype</h2>
 
-    <form action="{$data.request_uri}" method="post" enctype="multipart/form-data">
+    <form action="{$content.request_uri}" method="post" enctype="multipart/form-data">
         <input type="hidden" name="glm_proto_action" value="add_submit">
         <table class="form-table">
             <tr>
                 <th scope="row"><label for="glm_proto_title">Title for this Prototype <span class="glm-proto-required">*</span></label></th>
                 <td>
-                    <input name="glm_proto_title" type="text" id="glm_proto_title" value="{$data.glm_proto_title}" class="regular-text" />
-                    {if $data.glm_proto_title_error != ''}<br><span class="glm-proto-error">{$data.glm_proto_title_error}</span>{/if}
+                    <input name="glm_proto_title" type="text" id="glm_proto_title" value="{$content.glm_proto_title}" class="regular-text" />
+                    {if $content.glm_proto_title_error != ''}<br><span class="glm-proto-error">{$content.glm_proto_title_error}</span>{/if}
                 </td>
             </tr>
             <tr>
                 <th scope="row"><label for="glm_proto_width">Desired initial display width<span class="glm-proto-required">*</span></label></th>
                 <td>
-                    <input name="glm_proto_width" type="text" id="glm_proto_width" value="{$data.glm_proto_width}" class="regular-text" style="width: 4em;" />
-                    {if $data.glm_proto_width_error != ''}<br><span class="glm-proto-error">{$data.glm_proto_width_error}</span>{/if}
+                    <input name="glm_proto_width" type="text" id="glm_proto_width" value="{$content.glm_proto_width}" class="regular-text" style="width: 4em;" />
+                    {if $content.glm_proto_width_error != ''}<br><span class="glm-proto-error">{$content.glm_proto_width_error}</span>{/if}
                 </td>
             </tr>
             <tr>
                 <th scope="row"><label for="glm_proto_height">Desired initial display height<span class="glm-proto-required">*</span></label></th>
                 <td>
-                    <input name="glm_proto_height" type="text" id="glm_proto_height" value="{$data.glm_proto_height}" class="regular-text" style="width: 4em;" />
-                    {if $data.glm_proto_height_error != ''}<br><span class="glm-proto-error">{$data.glm_proto_height_error}</span>{/if}
+                    <input name="glm_proto_height" type="text" id="glm_proto_height" value="{$content.glm_proto_height}" class="regular-text" style="width: 4em;" />
+                    {if $content.glm_proto_height_error != ''}<br><span class="glm-proto-error">{$content.glm_proto_height_error}</span>{/if}
                 </td>
             </tr>
             <tr>
                 <th scope="row"><label for="glm_proto_background">Prototype Background</label></th>
                 <td>
-                    <input id="glm-proto-background" class="glm-proto-media-uploader" type="text" size="36" name="glm_proto_background" value="{$data.glm_proto_background}" />
+                    <input id="glm-proto-background" class="glm-proto-media-uploader" type="text" size="36" name="glm_proto_background" value="{$content.glm_proto_background}" />
                     <input class="glm-protp-upload-button button" data-id="glm-proto-background" type="button" value="Upload Image" />
-                    {if $data.glm_proto_background_error != ''}<br><span class="glm-proto-error">{$data.glm_proto_background_error}</span>{/if}
+                    {if $content.glm_proto_background_error != ''}<br><span class="glm-proto-error">{$content.glm_proto_background_error}</span>{/if}
                 </td>
             </tr>
             <tr>
                 <th scope="row"><label for="glm_proto_prototype">Prototype Image <span class="glm-proto-required">*</span></label></th>
                 <td>
-                    <input id="glm-proto-prototype" class="glm-proto-media-uploader" type="text" size="36" name="glm_proto_prototype" value="{$data.glm_proto_prototype}" />
+                    <input id="glm-proto-prototype" class="glm-proto-media-uploader" type="text" size="36" name="glm_proto_prototype" value="{$content.glm_proto_prototype}" />
                     <input class="glm-protp-upload-button button" data-id="glm-proto-prototype" type="button" value="Upload Image" />
-                    {if $data.glm_proto_prototype_error != ''}<br><span class="glm-proto-error">{$data.glm_proto_prototype_error}</span>{/if}
+                    {if $content.glm_proto_prototype_error != ''}<br><span class="glm-proto-error">{$content.glm_proto_prototype_error}</span>{/if}
                 </td>
             </tr>
             <tr>
index 8c27573..7689f9e 100644 (file)
@@ -1,11 +1,11 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
-        <title>Prototype: {$data.title}</title>
+        <title>Prototype: {$content.title}</title>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     </head>
     <body style="margin:0;padding:0; background: #e7e7df;">      
-        <div style="min-width:1400px;min-height:2500px; background: url({$data.prototype}) top center no-repeat; z-index: 10;"></div>
-        <div style="min-width:100%;min-height:784px; background: url({$data.background}) top left repeat-x; position: absolute; top: 0; z-index: -1;"></div>
+        <div style="min-width:1400px;min-height:2500px; background: url({$content.prototype}) top center no-repeat; z-index: 10;"></div>
+        <div style="min-width:100%;min-height:784px; background: url({$content.background}) top left repeat-x; position: absolute; top: 0; z-index: -1;"></div>
     </body>
 </html>
index 79739ed..5d627b7 100644 (file)
@@ -2,44 +2,44 @@
     
     <h2>Edit a Prototype</h2>
 
-    <form action="{$data.request_uri}" method="post" enctype="multipart/form-data">
+    <form action="{$content.request_uri}" method="post" enctype="multipart/form-data">
         <input type="hidden" name="glm_action" value="edit">
         <table class="form-table">
             <tr>
                 <th scope="row"><label for="glm_proto_title">Title for this Prototype <span class="glm-proto-required">*</span></label></th>
                 <td>
-                    <input name="glm_proto_title" type="text" id="glm_proto_title" value="{$data.glm_proto_title}" class="regular-text" />
-                    {if $data.glm_proto_title_error != ''}<br><span class="glm-proto-error">{$data.glm_proto_title_error}</span>{/if}
+                    <input name="glm_proto_title" type="text" id="glm_proto_title" value="{$content.glm_proto_title}" class="regular-text" />
+                    {if $content.glm_proto_title_error != ''}<br><span class="glm-proto-error">{$content.glm_proto_title_error}</span>{/if}
                 </td>
             </tr>
             <tr>
                 <th scope="row"><label for="glm_proto_width">Desired initial display width<span class="glm-proto-required">*</span></label></th>
                 <td>
-                    <input name="glm_proto_width" type="text" id="glm_proto_width" value="{$data.glm_proto_width}" class="regular-text" style="width: 4em;" />
-                    {if $data.glm_proto_width_error != ''}<br><span class="glm-proto-error">{$data.glm_proto_width_error}</span>{/if}
+                    <input name="glm_proto_width" type="text" id="glm_proto_width" value="{$content.glm_proto_width}" class="regular-text" style="width: 4em;" />
+                    {if $content.glm_proto_width_error != ''}<br><span class="glm-proto-error">{$content.glm_proto_width_error}</span>{/if}
                 </td>
             </tr>
             <tr>
                 <th scope="row"><label for="glm_proto_height">Desired initial display height<span class="glm-proto-required">*</span></label></th>
                 <td>
-                    <input name="glm_proto_height" type="text" id="glm_proto_height" value="{$data.glm_proto_height}" class="regular-text" style="width: 4em;" />
-                    {if $data.glm_proto_height_error != ''}<br><span class="glm-proto-error">{$data.glm_proto_height_error}</span>{/if}
+                    <input name="glm_proto_height" type="text" id="glm_proto_height" value="{$content.glm_proto_height}" class="regular-text" style="width: 4em;" />
+                    {if $content.glm_proto_height_error != ''}<br><span class="glm-proto-error">{$content.glm_proto_height_error}</span>{/if}
                 </td>
             </tr>
             <tr>
                 <th scope="row"><label for="glm_proto_background">Prototype Background</label></th>
                 <td>
-                    <input id="glm-proto-background" class="glm-proto-media-uploader" type="text" size="36" name="glm_proto_background" value="{$data.glm_proto_background}" />
+                    <input id="glm-proto-background" class="glm-proto-media-uploader" type="text" size="36" name="glm_proto_background" value="{$content.glm_proto_background}" />
                     <input class="glm-protp-upload-button button" data-id="glm-proto-background" type="button" value="Upload Image" />
-                    {if $data.glm_proto_background_error != ''}<br><span class="glm-proto-error">{$data.glm_proto_background_error}</span>{/if}
+                    {if $content.glm_proto_background_error != ''}<br><span class="glm-proto-error">{$content.glm_proto_background_error}</span>{/if}
                 </td>
             </tr>
             <tr>
                 <th scope="row"><label for="glm_proto_prototype">Prototype Image <span class="glm-proto-required">*</span></label></th>
                 <td>
-                    <input id="glm-proto-prototype" class="glm-proto-media-uploader" type="text" size="36" name="glm_proto_prototype" value="{$data.glm_proto_prototype}" />
+                    <input id="glm-proto-prototype" class="glm-proto-media-uploader" type="text" size="36" name="glm_proto_prototype" value="{$content.glm_proto_prototype}" />
                     <input class="glm-protp-upload-button button" data-id="glm-proto-prototype" type="button" value="Upload Image" />
-                    {if $data.glm_proto_prototype_error != ''}<br><span class="glm-proto-error">{$data.glm_proto_prototype_error}</span>{/if}
+                    {if $content.glm_proto_prototype_error != ''}<br><span class="glm-proto-error">{$content.glm_proto_prototype_error}</span>{/if}
                 </td>
             </tr>
             <tr>
index 26d81dc..6afe6dc 100644 (file)
             </tr>
         </thead>
         <tbody>
+        
 {if $haveData}
-    {foreach $data as $d}
+    {foreach $prototypes as $p}
             <tr>
-                <td>{$d.p_date}</td>
-                <td>{$d.post_title}</td>
+                <td>{$p.p_date}</td>
+                <td>{$p.post_title}</td>
                 <td>
-                    <a href="{$request_uri}&glm_action=display&proto_id={$d.id}&glm_display_direct=true&glm_menu_item=prototypes" name="Edit" class="button-primary"
-                        onClick="dispProtoWindow('{$request_uri}&glm_action=display&proto_id={$d.id}&glm_display_direct=true&glm_menu_item=prototypes', {$d.content.width}, {$d.content.height}); return false;"
+                    <a href="{$request_uri}&glm_action=display&proto_id={$p.id}&glm_display_direct=true&glm_menu_item=prototypes" name="Edit" class="button-primary"
+                        onClick="dispProtoWindow('{$request_uri}&glm_action=display&proto_id={$p.id}&glm_display_direct=true&glm_menu_item=prototypes', {$p.content.width}, {$p.content.height}); return false;"
                     >View</a>
-                    <a href="{$request_uri}&glm_action=edit&proto_id={$d.id}" name="Edit" class="button-primary">Edit</a>
-                    <a href="{$request_uri}&glm_action=delete&proto_id={$d.id}" name="Edit" class="button-primary">Delete</a>
+        {if $canEdit}
+                    <a href="{$request_uri}&glm_action=edit&proto_id={$p.id}" name="Edit" class="button-primary">Edit</a>
+                    <a href="{$request_uri}&glm_action=delete&proto_id={$p.id}" name="Edit" class="button-primary">Delete</a>
+        {/if}
                 </td>
             </tr>
     {/foreach}