[Jaws-commits] r12441 - in trunk/jaws/html/gadgets/StaticPage: . resources schema templates

afz at jaws-project.com afz at jaws-project.com
Wed Jan 18 05:10:48 UTC 2012


Author: afz
Date: 2012-01-18 05:10:48 +0000 (Wed, 18 Jan 2012)
New Revision: 12441

Modified:
   trunk/jaws/html/gadgets/StaticPage/AdminHTML.php
   trunk/jaws/html/gadgets/StaticPage/AdminModel.php
   trunk/jaws/html/gadgets/StaticPage/resources/script.js
   trunk/jaws/html/gadgets/StaticPage/schema/schema.xml
   trunk/jaws/html/gadgets/StaticPage/templates/AdminStaticPage.html
Log:
[StaticPage]: use modify others pages acl in delete action

Modified: trunk/jaws/html/gadgets/StaticPage/AdminHTML.php
===================================================================
--- trunk/jaws/html/gadgets/StaticPage/AdminHTML.php	2012-01-18 05:10:17 UTC (rev 12440)
+++ trunk/jaws/html/gadgets/StaticPage/AdminHTML.php	2012-01-18 05:10:48 UTC (rev 12441)
@@ -602,12 +602,16 @@
                 $submit =& Piwi::CreateWidget('Button', 'newpage', _t('STATICPAGE_ADD_PAGE'), STOCK_SAVE);
             } else {
                 $submit =& Piwi::CreateWidget('Button', 'editpage', _t('STATICPAGE_UPDATE_PAGE'), STOCK_SAVE);
+                $btnDelete =& Piwi::CreateWidget('Button', 'delpage', _t('GLOBAL_DELETE'), STOCK_DELETE);
+                $btnDelete->AddEvent(ON_CLICK, "javascript: deletePage($id, true);");
             }
         } else {
             if ($action == 'AddTranslation') {
                 $submit =& Piwi::CreateWidget('Button', 'newpagetrans', _t('STATICPAGE_ADD_TRANSLATION'), STOCK_SAVE);
             } else {
                 $submit =& Piwi::CreateWidget('Button', 'editpagetrans', _t('STATICPAGE_UPDATE_TRANSLATION'), STOCK_SAVE);
+                $btnDelete =& Piwi::CreateWidget('Button', 'delpagetrans', _t('GLOBAL_DELETE'), STOCK_DELETE);
+                $btnDelete->AddEvent(ON_CLICK, 'javascript: deletePageTrans(this.form);');
             }
         }
 
@@ -624,10 +628,11 @@
         $buttonbox->SetStyle(_t('GLOBAL_LANG_DIRECTION')=='rtl'?'float: left;' : 'float: right;');
         $buttonbox->PackStart($preview);
         $buttonbox->PackStart($cancel);
+        if ($this->GetPermission('DeletePage')) {
+            $buttonbox->PackStart($btnDelete);
+        }
         $buttonbox->PackStart($submit);
-
         $pageform->Add($editor);
-
         $pageform->Add($buttonbox);
 
         $tpl->setVariable('preview_header', _t('GLOBAL_PREVIEW'));

Modified: trunk/jaws/html/gadgets/StaticPage/AdminModel.php
===================================================================
--- trunk/jaws/html/gadgets/StaticPage/AdminModel.php	2012-01-18 05:10:17 UTC (rev 12440)
+++ trunk/jaws/html/gadgets/StaticPage/AdminModel.php	2012-01-18 05:10:48 UTC (rev 12441)
@@ -433,6 +433,20 @@
      */
     function DeletePage($id)
     {
+        if (!$GLOBALS['app']->Session->GetPermission('StaticPage', 'ModifyOthersPages')) {
+            $sql = '
+                SELECT COUNT([base_id])
+                FROM [[static_pages_translation]]
+                WHERE [base_id] = {id} AND [user] <> {user}';
+
+            $result = $GLOBALS['db']->queryOne($sql, array('user' => $GLOBALS['app']->Session->GetAttribute('user')));
+            if (Jaws_Error::IsError($result) || ($result > 0)) {
+                // FIXME: need new language statement
+                $GLOBALS['app']->Session->PushLastResponse(_t('STATICPAGE_ERROR_PAGE_NOT_DELETED'), RESPONSE_ERROR);
+                return new Jaws_Error(_t('STATICPAGE_ERROR_PAGE_NOT_DELETED'), _t('STATICPAGE_NAME'));
+            }
+        }
+
         $sql = 'DELETE FROM [[static_pages_translation]] WHERE [base_id] = {id}';
         $result = $GLOBALS['db']->query($sql, array('id' => $id));
         if (Jaws_Error::IsError($result)) {

Modified: trunk/jaws/html/gadgets/StaticPage/resources/script.js
===================================================================
--- trunk/jaws/html/gadgets/StaticPage/resources/script.js	2012-01-18 05:10:17 UTC (rev 12440)
+++ trunk/jaws/html/gadgets/StaticPage/resources/script.js	2012-01-18 05:10:48 UTC (rev 12441)
@@ -140,11 +140,19 @@
 }
 
 /**
- * Delete a banner : function
+ * Delete a page : function
  */
-function deletePage(id)
+function deletePage(id, redirect)
 {
-    staticpage.deletepage(id);
+    if (redirect) {
+        var response = staticpageSync.deletepage(id);
+        showResponse(response);
+        if (response[0]['css'] == 'notice-message') {
+            window.location= base_script + '?gadget=StaticPage&action=Admin';
+        }
+    } else {
+        staticpage.deletepage(id);
+    }
 }
 
 /**

Modified: trunk/jaws/html/gadgets/StaticPage/schema/schema.xml
===================================================================
--- trunk/jaws/html/gadgets/StaticPage/schema/schema.xml	2012-01-18 05:10:17 UTC (rev 12440)
+++ trunk/jaws/html/gadgets/StaticPage/schema/schema.xml	2012-01-18 05:10:48 UTC (rev 12441)
@@ -142,13 +142,6 @@
         <default>true</default>
       </field>
 
-      <index>
-        <name><variable>table_prefix</variable>static_pages_gtitle</name>
-        <field>
-          <name>title</name>
-        </field>
-      </index>
-
     </declaration>
   </table>
 

Modified: trunk/jaws/html/gadgets/StaticPage/templates/AdminStaticPage.html
===================================================================
--- trunk/jaws/html/gadgets/StaticPage/templates/AdminStaticPage.html	2012-01-18 05:10:17 UTC (rev 12440)
+++ trunk/jaws/html/gadgets/StaticPage/templates/AdminStaticPage.html	2012-01-18 05:10:48 UTC (rev 12441)
@@ -39,6 +39,9 @@
 <div id="main">
 {form}
 </div>
+<script type="text/javascript">
+    var base_script = "{base-script}";
+</script>
 <!-- END pageform -->
 
 <!-- BEGIN Properties -->



More information about the Jaws-commits mailing list