Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

1850
 
1851
 
1851
 
administrators.php
_> 11 <?php
  22 /*
<> 3 -  $Id: administrators.php 1850 2009-02-28 03:07:56Z hpdl $
   3+  $Id: administrators.php 1851 2009-02-28 03:08:07Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2007 osCommerce
   8+  Copyright (c) 2009 osCommerce
99 
  1010   This program is free software; you can redistribute it and/or modify
  1111   it under the terms of the GNU General Public License v2 (1991)
  1212   as published by the Free Software Foundation.
  1313 */
  1414 
<> 15 -  define('OSC_ADMINISTRATORS_ACCESS_MODE_ADD', 'add');
  16 -  define('OSC_ADMINISTRATORS_ACCESS_MODE_SET', 'set');
  17 -  define('OSC_ADMINISTRATORS_ACCESS_MODE_REMOVE', 'remove');
  18 -
1915   class osC_Administrators_Admin {
<> 20 -    function getData($id) {
   16+    const ACCESS_MODE_ADD = 'add';
   17+    const ACCESS_MODE_SET = 'set';
   18+    const ACCESS_MODE_REMOVE = 'remove';
   19+
   20+    public static function get($id) {
2121       global $osC_Database;
  2222 
<> 23 -      $Qadmin = $osC_Database->query('select id, user_name from :table_administrators where id = :id');
   23+      $Qadmin = $osC_Database->query('select * from :table_administrators where id = :id');
2424       $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
  2525       $Qadmin->bindInt(':id', $id);
  2626       $Qadmin->execute();
  2727 
<> 28 -      $modules = array( 'access_modules' => array() );
   28+      $modules = array('access_modules' => array());
2929 
  3030       $Qaccess = $osC_Database->query('select module from :table_administrators_access where administrators_id = :administrators_id');
  3131       $Qaccess->bindTable(':table_administrators_access', TABLE_ADMINISTRATORS_ACCESS);
     
 !
4545       return $data;
  4646     }
  4747 
<> 48 -    function save($id = null, $data, $modules = null) {
   48+    public static function getAll($pageset = 1) {
4949       global $osC_Database;
  5050 
<>  51+      if ( !is_numeric($pageset) || (floor($pageset) != $pageset) ) {
   52+        $pageset = 1;
   53+      }
   54+
   55+      $result = array('entries' => array());
   56+
   57+      $Qadmins = $osC_Database->query('select SQL_CALC_FOUND_ROWS * from :table_administrators order by user_name');
   58+      $Qadmins->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
   59+
   60+      if ( $pageset !== -1 ) {
   61+        $Qadmins->setBatchLimit($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS);
   62+      }
   63+
   64+      $Qadmins->execute();
   65+
   66+      while ( $Qadmins->next() ) {
   67+        $result['entries'][] = $Qadmins->toArray();
   68+      }
   69+
   70+      $result['total'] = $Qadmins->getBatchSize();
   71+
   72+      $Qadmins->freeResult();
   73+
   74+      return $result;
   75+    }
   76+
   77+    public static function find($search, $pageset = 1) {
   78+      global $osC_Database;
   79+
   80+      if ( !is_numeric($pageset) || (floor($pageset) != $pageset) ) {
   81+        $pageset = 1;
   82+      }
   83+
   84+      $result = array('entries' => array());
   85+
   86+      $Qadmins = $osC_Database->query('select SQL_CALC_FOUND_ROWS * from :table_administrators where (user_name like :user_name) order by user_name');
   87+      $Qadmins->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
   88+      $Qadmins->bindValue(':user_name', '%' . $search . '%');
   89+
   90+      if ( $pageset !== -1 ) {
   91+        $Qadmins->setBatchLimit($pageset, MAX_DISPLAY_SEARCH_RESULTS);
   92+      }
   93+
   94+      $Qadmins->execute();
   95+
   96+      while ( $Qadmins->next() ) {
   97+        $result['entries'][] = $Qadmins->toArray();
   98+      }
   99+
   100+      $result['total'] = $Qadmins->getBatchSize();
   101+
   102+      $Qadmins->freeResult();
   103+
   104+      return $result;
   105+    }
   106+
   107+    public static function save($id = null, $data, $modules = null) {
   108+      global $osC_Database;
   109+
51110       $error = false;
  52111 
  53112       $Qcheck = $osC_Database->query('select id from :table_administrators where user_name = :user_name');
     
 !
95154 
  96155         if ( $error === false ) {
  97156           if ( !empty($modules) ) {
<> 98 -            if ( in_array('*', $modules) ) {
   157+            if ( in_array('0', $modules) ) {
99158               $modules = array('*');
  100159             }
  101160 
     
 !
155214       }
  156215     }
  157216 
<> 158 -    function delete($id) {
   217+    public static function delete($id) {
159218       global $osC_Database;
  160219 
  161220       $osC_Database->startTransaction();
     
 !
185244       return false;
  186245     }
  187246 
<> 188 -    function setAccessLevels($id, $modules, $mode = OSC_ADMINISTRATORS_ACCESS_MODE_ADD) {
   247+    public static function setAccessLevels($id, $modules, $mode = self::ACCESS_MODE_ADD) {
189248       global $osC_Database;
  190249 
  191250       $error = false;
  192251 
<> 193 -      if ( in_array('*', $modules) ) {
   252+      if ( in_array('0', $modules) ) {
194253         $modules = array('*');
  195254       }
  196255 
  197256       $osC_Database->startTransaction();
  198257 
<> 199 -      if ( ($mode == OSC_ADMINISTRATORS_ACCESS_MODE_ADD) || ($mode == OSC_ADMINISTRATORS_ACCESS_MODE_SET) ) {
   258+      if ( ($mode == self::ACCESS_MODE_ADD) || ($mode == self::ACCESS_MODE_SET) ) {
200259         foreach ($modules as $module) {
  201260           $execute = true;
  202261 
     
 !
237296       }
  238297 
  239298       if ( $error === false ) {
<> 240 -        if ( ($mode == OSC_ADMINISTRATORS_ACCESS_MODE_REMOVE) || ($mode == OSC_ADMINISTRATORS_ACCESS_MODE_SET) || in_array('*', $modules) ) {
   299+        if ( ($mode == self::ACCESS_MODE_REMOVE) || ($mode == self::ACCESS_MODE_SET) || in_array('*', $modules) ) {
241300           if ( !empty($modules) ) {
  242301             $Qdel = $osC_Database->query('delete from :table_administrators_access where administrators_id = :administrators_id');
  243302 
<> 244 -            if ( $mode == OSC_ADMINISTRATORS_ACCESS_MODE_REMOVE ) {
   303+            if ( $mode == self::ACCESS_MODE_REMOVE ) {
245304               if ( !in_array('*', $modules) ) {
  246305                 $Qdel->appendQuery('and module in (":module")');
  247306                 $Qdel->bindRaw(':module', implode('", "', $modules));
     
 !
274333 
  275334       return false;
  276335     }
<>  336+
   337+    public static function getAccessModules() {
   338+      global $osC_Language;
   339+
   340+      $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/access');
   341+      $osC_DirectoryListing->setIncludeDirectories(false);
   342+
   343+      $modules = array();
   344+
   345+      foreach ( $osC_DirectoryListing->getFiles() as $file ) {
   346+        $module = substr($file['name'], 0, strrpos($file['name'], '.'));
   347+
   348+        if ( !class_exists('osC_Access_' . ucfirst($module)) ) {
   349+          $osC_Language->loadIniFile('modules/access/' . $file['name']);
   350+          include($osC_DirectoryListing->getDirectory() . '/' . $file['name']);
   351+        }
   352+
   353+        $module = 'osC_Access_' . ucfirst($module);
   354+        $module = new $module();
   355+
   356+        $modules[osC_Access::getGroupTitle( $module->getGroup() )][] = array('id' => $module->getModule(),
   357+                                                                             'text' => $module->getTitle());
   358+      }
   359+
   360+      ksort($modules);
   361+
   362+      return $modules;
   363+    }
<_ 277364   }
  278365 ?>