[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/administrator/components/com_syndicate/ -> admin.syndicate.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @subpackage Syndicate
   5  * @author Mambo Foundation Inc see README.php
   6  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   7  * See COPYRIGHT.php for copyright notices and details.
   8  * @license GNU/GPL Version 2, see LICENSE.php
   9  *
  10  * Redistributions of files must retain the above copyright notice.
  11  *
  12  * Mambo is free software; you can redistribute it and/or
  13  * modify it under the terms of the GNU General Public License
  14  * as published by the Free Software Foundation; version 2 of the License.
  15  */
  16  
  17  /** ensure this file is being included by a parent file */
  18  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  19  
  20  // ensure user has access to this function
  21  if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' ) | $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'com_contact' ))) {
  22      mosRedirect( 'index2.php', T_('You are not authorized to view this resource.') );
  23  }
  24  
  25  require_once( $mainframe->getPath( 'admin_html' ) );
  26  
  27  
  28  switch ($task) {
  29  
  30      case 'save':
  31          saveSyndicate( $option );
  32          break;
  33  
  34    case 'cancel':
  35          cancelSyndicate( );
  36          break;
  37  
  38      default:
  39          showSyndicate( $option );
  40          break;
  41  }
  42  
  43  /**
  44  * List the records
  45  * @param string The current GET/POST option
  46  */
  47  function showSyndicate( $option ) {
  48      global $database, $mainframe, $mosConfig_list_limit;
  49      
  50      // @RawSQLUse, trivial_implementation, SELECT
  51      $query = "SELECT a.id"
  52      . "\n FROM #__components AS a"
  53      . "\n WHERE a.name = 'Syndicate'"
  54      ;
  55      $database->setQuery( $query );
  56      $id = $database->loadResult();
  57  
  58      // load the row from the db table
  59      $row = new mosComponent( $database );
  60      $row->load( $id );
  61  
  62      // get params definitions
  63      $params =& new mosAdminParameters( $row->params, $mainframe->getPath( 'com_xml', $row->option ), 'component' );
  64  
  65      HTML_syndicate::settings( $option, $params, $id );
  66  }
  67  
  68  /**
  69  * Saves the record from an edit form submit
  70  * @param string The current GET/POST option
  71  */
  72  function saveSyndicate( $option ) {
  73      global $database;
  74  
  75      $params = mosGetParam( $_POST, 'params', '' );
  76      if (is_array( $params )) {
  77          $txt = array();
  78          foreach ($params as $k=>$v) {
  79              $txt[] = "$k=$v";
  80          }
  81          $_POST['params'] = mosParameters::textareaHandling( $txt );
  82      }
  83  
  84      $id = mosGetParam( $_POST, 'id', '17' );
  85      $row = new mosComponent( $database );
  86      $row->load( $id );
  87  
  88      if (!$row->bind( $_POST )) {
  89          echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
  90          exit();
  91      }
  92  
  93      if (!$row->check()) {
  94          echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
  95          exit();
  96      }
  97      if (!$row->store()) {
  98          echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
  99          exit();
 100      }
 101  
 102      $msg = T_('Settings successfully Saved');
 103      mosRedirect( 'index2.php?option='. $option, $msg );
 104  }
 105  
 106  /** 
 107  * Cancels editing and checks in the record
 108  */
 109  function cancelSyndicate(){
 110      mosRedirect( 'index2.php' );
 111  }
 112  ?>