Xaraya / Postnuke CVS Notices - Message

Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites

View Statistics - Next Notice - Previous Notice

Directory filter : [ all ] / postnuke_official / html / modules / blocks [ view in CVS ]


Deprecated: Function gmstrftime() is deprecated in /home/mikespub/www/list.php on line 509
Date Directory [filter] File(s) [view] Author [filter]
29 Jul 2002 04:35:49postnuke_official/html/modules/blockspnadmin.php,1.43,1.44 pnadminapi.php,1.15,1.16Paul Rosania
 added group delete functionality

Update of /home/cvsroot/postnuke_official/html/modules/blocks
In directory ns7.hostnuke.net:/tmp/cvs-serv6122

Modified Files:
	pnadmin.php pnadminapi.php 
Log Message:
added group delete functionality


Index: pnadmin.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/modules/blocks/pnadmin.php,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** pnadmin.php	28 Jul 2002 17:12:22 -0000	1.43
--- pnadmin.php	29 Jul 2002 04:35:47 -0000	1.44
***************
*** 43,48 ****
      // Permissions check
      if (!pnSecAuthAction(0, 'Blocks::', '::', ACCESS_ADMIN)) {
!         $output->Text(_BLOCKSNOAUTH);
!         return $output->GetOutput();
      }
      
--- 43,47 ----
      // Permissions check
      if (!pnSecAuthAction(0, 'Blocks::', '::', ACCESS_ADMIN)) {
!         return _BLOCKSNOAUTH;
      }
      
***************
*** 92,97 ****
      // Permissions check
      if (!pnSecAuthAction(0, 'Blocks::', '::', ACCESS_ADMIN)) {
!         $output->Text(_BLOCKSNOAUTH);
!         return $output->GetOutput();
      }
      
--- 91,95 ----
      // Permissions check
      if (!pnSecAuthAction(0, 'Blocks::', '::', ACCESS_ADMIN)) {
!         return _BLOCKSNOAUTH;
      }
      
***************
*** 155,160 ****
      // Permissions check
      if (!pnSecAuthAction(0, 'Blocks::', '::', ACCESS_ADMIN)) {
!         $output->Text(_BLOCKSNOAUTH);
!         return $output->GetOutput();
      }
      
--- 153,157 ----
      // Permissions check
      if (!pnSecAuthAction(0, 'Blocks::', '::', ACCESS_ADMIN)) {
!         return _BLOCKSNOAUTH;
      }
      
***************
*** 550,555 ****
      // Load block
      if (!pnBlockLoad($blockinfo['module'], $blockinfo['type'])) {
!         $output->Text(_NOSUCHBLOCK);
!         return true;
      }
  
--- 547,551 ----
      // Load block
      if (!pnBlockLoad($blockinfo['module'], $blockinfo['type'])) {
!         return pnML('Block instance not found.');
      }
  
***************
*** 580,584 ****
                       $blockinfo)) {
          // Success
!         pnSessionSetVar('statusmsg', _UPDATEDBLOCK);
  
          if (!empty($resequence)) {
--- 576,580 ----
                       $blockinfo)) {
          // Success
!         pnSessionSetVar('statusmsg', pnML('Block instance updated.'));
  
          if (!empty($resequence)) {
***************
*** 682,686 ****
      if ($block_id != false) {
          // Success
!         pnSessionSetVar('statusmsg', _BLOCKCREATED);
  
          // Send to modify page to update block specifics
--- 678,682 ----
      if ($block_id != false) {
          // Success
!         pnSessionSetVar('statusmsg', pnML('Block instance created.'));
  
          // Send to modify page to update block specifics
***************
*** 700,706 ****
  function blocks_admin_new_group()
  {
-     list($dbconn) = pnDBGetConn();
-     $pntable = pnDBGetTables();
- 
      return array();
  }
--- 696,699 ----
***************
*** 735,744 ****
      if ($group_id != false) {
          // Success
!         pnSessionSetVar('statusmsg', _GROUPCREATED);
  
          // Send to modify page to update group specifics
          pnRedirect(pnModURL('blocks',
                              'admin',
!                             'modify_group', array('group_id' => $group_id)));
  
          return true;
--- 728,737 ----
      if ($group_id != false) {
          // Success
!         pnSessionSetVar('statusmsg', pnML('Block group created.'));
  
          // Send to modify page to update group specifics
          pnRedirect(pnModURL('blocks',
                              'admin',
!                             'modify_group', array('gid' => $group_id)));
  
          return true;
***************
*** 751,754 ****
--- 744,944 ----
  
  /**
+  * modify a block group
+  */
+ function blocks_admin_modify_group()
+ {
+     // Get parameters
+     list($gid, $confirm) = pnVarCleanFromInput('gid', 'confirm');
+ 
+     // Get details on current group           
+         
+     // Load up database
+     list($dbconn) = pnDBGetConn();
+     $pntable = pnDBGetTables();
+     $block_group_instances_table = $pntable['block_group_instances'];
+     $block_instances_table = $pntable['block_instances'];
+     $block_groups_table = $pntable['block_groups'];
+     $block_types_table = $pntable['block_types'];
+ 
+     $query = "SELECT    pn_id as id,
+                         pn_name as name,
+                         pn_template as template
+               FROM      $block_groups_table
+               WHERE     pn_id = $gid";
+     $result = $dbconn->Execute($query);
+ 
+     // Check for db errors
+     if ($dbconn->ErrorNo() != 0) {
+         $msg = pnMLByKey('DATABASE_ERROR', $query);
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
+         return NULL;
+     }
+ 
+     // Load up groups array
+     if($result->EOF) {
+     // error
+     }
+ 
+     $group = $result->GetRowAssoc(false);
+ 
+     $result->Close();
+ 
+     // Query for instances in this group
+     $query = "SELECT    inst.pn_id as bid,
+                         types.pn_type as type,
+                         types.pn_module as module,
+                         inst.pn_title as title,
+                         group_inst.pn_position as position
+               FROM      $block_groups_table as groups
+               LEFT JOIN $block_group_instances_table as group_inst
+               ON        group_inst.pn_group_id = groups.pn_id
+               LEFT JOIN $block_instances_table as inst
+               ON        inst.pn_id = group_inst.pn_instance_id 
+               LEFT JOIN $block_types_table as types
+               ON        types.pn_id = inst.pn_type_id
+               WHERE     groups.pn_id = '{$group['id']}'
+               ORDER BY  group_inst.pn_position ASC";
+     $result = $dbconn->Execute($query);
+ 
+     // Check for db errors
+     if ($dbconn->ErrorNo() != 0) {
+         $msg = pnMLByKey('DATABASE_ERROR', $query);
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
+         return NULL;
+     }
+ 
+     // Load up list of group's instances
+     $instances = array();
+     while (!$result->EOF) {
+         $inst = $result->GetRowAssoc(false);
+         $instances[] = $inst;
+         $result->MoveNext();
+     }
+ 
+     $result->Close();
+ 
+     $group['instances'] = $instances;
+ 
+     return array('group' => $group,
+                  'authid' => pnSecGenAuthKey());
+ }
+ 
+ /**
+  * delete a block group
+  */
+ function blocks_admin_delete_group()
+ {
+ 
+     // Get parameters
+     list($gid, $confirm) = pnVarCleanFromInput('gid', 'confirm');
+ 
+     // Check for confirmation
+     if (empty($confirm)) {
+         // No confirmation yet - get one
+ 
+         // Get details on current group
+         
+         // Load up database
+         list($dbconn) = pnDBGetConn();
+         $pntable = pnDBGetTables();
+         $block_group_instances_table = $pntable['block_group_instances'];
+         $block_instances_table = $pntable['block_instances'];
+         $block_groups_table = $pntable['block_groups'];
+         $block_types_table = $pntable['block_types'];
+ 
+         $query = "SELECT    pn_id as id,
+                             pn_name as name,
+                             pn_template as template
+                   FROM      $block_groups_table
+                   WHERE     pn_id = $gid";
+ 
+         $result = $dbconn->Execute($query);
+ 
+         // Check for db errors
+         if ($dbconn->ErrorNo() != 0) {
+             $msg = pnMLByKey('DATABASE_ERROR', $query);
+             pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                            new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
+             return NULL;
+         }
+ 
+         // Load up groups array
+         if($result->EOF) {
+         // error
+         }
+         
+         $group = $result->GetRowAssoc(false);
+         
+         $result->Close();
+         
+         // Query for instances in this group
+         $query = "SELECT    inst.pn_id as bid,
+                             types.pn_type as type,
+                             types.pn_module as module,
+                             inst.pn_title as title,
+                             group_inst.pn_position as position
+                   FROM      $block_groups_table as groups
+                   LEFT JOIN $block_group_instances_table as group_inst
+                   ON        group_inst.pn_group_id = groups.pn_id
+                   LEFT JOIN $block_instances_table as inst
+                   ON        inst.pn_id = group_inst.pn_instance_id 
+                   LEFT JOIN $block_types_table as types
+                   ON        types.pn_id = inst.pn_type_id
+                   WHERE     groups.pn_id = '{$group['id']}'
+                   ORDER BY  group_inst.pn_position ASC";
+ 
+         $result = $dbconn->Execute($query);
+ 
+         // Check for db errors
+         if ($dbconn->ErrorNo() != 0) {
+             $msg = pnMLByKey('DATABASE_ERROR', $query);
+             pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                            new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
+             return NULL;
+         }
+         
+         // Load up list of group's instances
+         $instances = array();
+         while(!$result->EOF) {
+             $inst = $result->GetRowAssoc(false);
+             $instances[] = $inst;
+             $result->MoveNext();
+         }
+         
+         $result->Close();
+ 
+         $group['instances'] = $instances;
+ 
+         return array('group' => $group,
+                      'authid' => pnSecGenAuthKey());
+     }
+ 
+     // Confirm authorisation code
+     if (!pnSecConfirmAuthKey()) {
+         pnSessionSetVar('errormsg', _BADAUTHKEY);
+         pnRedirect(pnModURL('blocks', 'admin', 'main'));
+         return true;
+     }
+ 
+     // Load in API
+     pnModAPILoad('blocks', 'admin');
+ 
+     // Pass to API
+     if (pnModAPIFunc('blocks',
+                      'admin',
+                      'delete_group', array('gid' => $gid))) {
+         // Success
+         pnSessionSetVar('statusmsg', pnML('Block group deleted.'));
+ 
+     }
+ 
+     pnRedirect(pnModURL('blocks', 'admin', 'main'));
+ 
+     return true;
+ }
+ 
+ /**
   * delete a block instance
   */
***************
*** 785,789 ****
                       'delete_instance', array('bid' => $bid))) {
          // Success
!         pnSessionSetVar('statusmsg', _BLOCKDELETED);
  
      }
--- 975,979 ----
                       'delete_instance', array('bid' => $bid))) {
          // Success
!         pnSessionSetVar('statusmsg', pnML('Block instance deleted.'));
  
      }
***************
*** 792,797 ****
  
      return true;
- 
  }
  /**
   * Any config options would likely go here in the future
--- 982,987 ----
  
      return true;
  }
+ 
  /**
   * Any config options would likely go here in the future
***************
*** 800,804 ****
  {
  
! //    $output->FormCheckBox('collapseable', pnModGetVar('blocks', 'collapseable'));
      return array();
  }
--- 990,994 ----
  {
  
! //    pnModGetVar('blocks', 'collapseable')
      return array();
  }
***************
*** 847,852 ****
      //$modinfo = pnModGetInfo($bkey);
      if (!pnBlockLoad($modname, $bkey)) {
!         $output->Text(_NOSUCHBLOCK);
!         return true;
      }
      $output = new pnHTML();
--- 1037,1041 ----
      //$modinfo = pnModGetInfo($bkey);
      if (!pnBlockLoad($modname, $bkey)) {
!         return pnML('Block instance does not exist.');
      }
      $output = new pnHTML();

Index: pnadminapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/modules/blocks/pnadminapi.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** pnadminapi.php	28 Jul 2002 03:52:14 -0000	1.15
--- pnadminapi.php	29 Jul 2002 04:35:47 -0000	1.16
***************
*** 360,364 ****
      // TODO: group add permissions
      // Security check
!     if (!pnSecAuthAction(0, 'Blocks::', "$title::", ACCESS_ADD)) {
          pnSessionSetVar('errormsg', _BLOCKSNOAUTH);
          return false;
--- 360,364 ----
      // TODO: group add permissions
      // Security check
!     if (!pnSecAuthAction(0, 'Blocks::', "$name::", ACCESS_ADD)) {
          pnSessionSetVar('errormsg', _BLOCKSNOAUTH);
          return false;
***************
*** 534,537 ****
--- 534,633 ----
  }
  
+ /**
+  * delete a group
+  * @param $args['gid'] the ID of the block group to delete
+  * @returns bool
+  * @return true on success, false on failure
+  */
+ function blocks_adminapi_delete_group($args)
+ {
+     // Get arguments from argument array
+     extract($args);
+ 
+     // Argument check
+     if (!isset($gid)) {
+         pnSessionSetVar('errormsg', _MODARGSERROR);
+         return false;
+     }
+ 
+     // Security check
+     if (!pnSecAuthAction(0, 'Blocks::', "::$gid", ACCESS_DELETE)) {
+         pnSessionSetVar('errormsg', _BLOCKSNOAUTH);
+         return false;
+     }
+     list($dbconn) = pnDBGetConn();
+     $pntable = pnDBGetTables();
+     $block_groups_table = $pntable['block_groups'];
+     $block_instances_table = $pntable['block_instances'];
+     $block_group_instances_table = $pntable['block_group_instances'];
+ 
+     // Query for instances in this group
+     $query = "SELECT    inst.pn_id as id
+               FROM      $block_group_instances_table as group_inst
+               LEFT JOIN $block_instances_table as inst
+               ON        inst.pn_id = group_inst.pn_instance_id 
+               WHERE     group_inst.pn_group_id = '$gid'";
+     $result = $dbconn->Execute($query);
+ 
+     // Check for db errors
+     if ($dbconn->ErrorNo() != 0) {
+         $msg = pnMLByKey('DATABASE_ERROR', $query);
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
+         return false;
+     }
+ 
+     // Load up list of group's instances
+     $instances = array();
+     while (!$result->EOF) {
+         $instances[] = $result->GetRowAssoc(false);
+         $result->MoveNext();
+     }
+     
+     $result->Close();
+ 
+     // Delete group member instance definitions
+     foreach ($instances as $instance) {
+         $query = "DELETE FROM $block_instances_table
+                   WHERE       pn_id = ".$instance['id'];echo $query;
+         $dbconn->Execute($query);
+         
+         // Check for db errors
+         if ($dbconn->ErrorNo() != 0) {
+             $msg = pnMLByKey('DATABASE_ERROR', $query);
+             pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                            new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
+             return false;
+         }
+     }
+     
+     // Delete block group definition
+     $query = "DELETE FROM $block_groups_table
+               WHERE pn_id=" . pnVarPrepForStore($gid);
+     $dbconn->Execute($query);
+ 
+     // Check for db errors
+     if ($dbconn->ErrorNo() != 0) {
+         $msg = pnMLByKey('DATABASE_ERROR', $query);
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
+         return false;
+     }
+ 
+     // Delete group-instance links
+     $query = "DELETE FROM $block_group_instances_table
+               WHERE pn_group_id=" . pnVarPrepForStore($gid);
+     $dbconn->Execute($query);
+ 
+     // Check for db errors
+     if ($dbconn->ErrorNo() != 0) {
+         $msg = pnMLByKey('DATABASE_ERROR', $query);
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
+                        new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
+         return false;
+     }
+ 
+     return true;
+ }
  
  /**


Directory filter : [ all ] / postnuke_official / html / modules / blocks [ view in CVS ]

View Statistics - Next Notice - Previous Notice


Visit Developer Site - Browse CVS Repository Syndicate via backend.rss
(max. once per hour please)
Powered by CVSNotice 0.1.3