TaskFreak! PHP Cross Reference Groupware Applications

Source: /user_edit.php - 142 lines - 5286 bytes - Summary - Text - Print

   1  <?php
   2  /****************************************************************************\
   3  * TaskFreak!                                                                 *
   4  * multi user                                                                 *
   5  ******************************************************************************
   6  * Version: 0.6.3                                                             *
   7  * Authors: Stan Ozier <taskfreak@gmail.com>                                  *
   8  * License:  http://www.gnu.org/licenses/gpl.txt (GPL)                        *
   9  ******************************************************************************
  10  * This file is part of "TaskFreak! multi user" program.                      *
  11  *                                                                            *
  12  * TaskFreak! multi user is free software; you can redistribute it and/or     *
  13  * modify it under the terms of the GNU General Public License as published   *
  14  * by the Free Software Foundation; either version 2 of the License, or (at   *  
  15  * your option) any later version.                                            *
  16  *                                                                            *
  17  * TaskFreak! multi user is distributed in the hope that it will be           *
  18  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of     *
  19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
  20  * GNU General Public License for more details.                               *
  21  *                                                                            *
  22  * You should have received a copy of the GNU General Public License          *
  23  * along with this program; if not, write to the Free Software                *
  24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA *
  25  \****************************************************************************/
  26  
  27  include  '_common.php';
  28  
  29  $objPositionList = new GlobalPositionList();
  30  
  31  /* --- LOAD USER --------------------------------------------------- */
  32  
  33  $objEditItem = new Member();
  34  
  35  if ($_REQUEST['id']) {
  36      $objEditItem->setUid($_REQUEST['id']);
  37      if (!$objEditItem->load()) {
  38          $pMessageStatus = 'ERROR:'.$GLOBALS['langMessage']['not_found_or_denied'];
  39      }
  40      if (!$objUser->checkLevel(3) && ($objUser->id != $objEditItem->author->id)) {
  41          // only if admin or creator loads specific user
  42          // otherwise user edits its own profile
  43          $objEditItem =& $objUser;
  44      }
  45  }
  46  if (!$objEditItem->isLoaded()) {
  47      if ($objUser->checkLevel(2)) {
  48          // user is administrator and tries to create new user
  49          $objEditItem->initObjectProperties();
  50          $objEditItem->country->id = FRK_DEFAULT_COUNTRY;
  51      } else {
  52          // user is editing himself
  53          $objEditItem =& $objUser;
  54      }
  55  }
  56  
  57  /* --- SAVE USER -------------------------------------------------- */
  58  
  59  if ($_POST['submit']) {
  60  
  61      $pLevel = $objEditItem->level;
  62      
  63      $objEditItem->setAuto($_POST);
  64      
  65      if (($objEditItem->id != $objUser->id) && ($objUser->checkLevel(2))) {
  66          // check requested level is not higher than user's own level
  67          $pLevel = min($objUser->level,$_POST['level']);
  68      }
  69  
  70      $objEditItem->level = $pLevel;
  71  
  72      if ($_POST['enabled']) {
  73          $objEditItem->enabled = 1;
  74      } else if ($objEditItem->id != $objUser->id) {
  75          $objEditItem->enabled = 0;
  76      }
  77      
  78      if ($objEditItem->check($_POST['password1'],$_POST['password2'])) {
  79          
  80          if ($objEditItem->isLoaded()) {
  81              $objEditItem->update();
  82          } else {
  83              $objEditItem->author->id = $objUser->id;
  84              $objEditItem->add();
  85          }
  86          
  87          Tzn::redirect('user_details.php?id='.$objEditItem->id, $GLOBALS['langMessage']['information_saved']);
  88          
  89      } else {
  90          $pMessageStatus = 'ERROR:'.$GLOBALS['langTznCommon']['form_error'];
  91          // $objEditItem->printErrorList();
  92      }
  93  }
  94  
  95  /* --- LOAD COUNTRIES ------------------------------------------------- */
  96  
  97  $objCountryList = new Country();
  98  $objCountryList->addOrder('name');
  99  $objCountryList->loadList();
 100  
 101  /* --- LOAD STATES ---------------------------------------------------- */
 102  
 103  $objStateList = new UsState();
 104  
 105  /* --- HTML ----------------------------------------------------------- */
 106  
 107  $pageJScript = 'common.js';
 108  
 109  include  PRJ_INCLUDE_PATH.'html/header.php';
 110  ?>
 111      <div align="center">
 112        <div id="horiz">
 113          <form action="user_edit.php" method="post">
 114          <?php $objEditItem->qHidden('id'); 
 115          
 116          include  PRJ_INCLUDE_PATH.'html/user_form.php';
 117          
 118          ?><br />
 119          <p align="center">
 120              <input type="submit" name="submit" value="<?php
 121              if ($objEditItem->isLoaded()) {
 122                  echo $langButton['update'];
 123              } else {
 124                  echo $langButton['add'];
 125              }
 126              ?>" /> &nbsp; <input type="reset" value="<?php echo $langButton['reset']; ?>" />
 127              <?php
 128              if ($objUser->checkLevel(1)) {
 129              ?>
 130              &nbsp; &nbsp; &nbsp; &nbsp;
 131              <input type="button" value="<?php echo $langButton['back']; ?>" onClick="window.location.href='user_list.php'" />
 132              <?php
 133              }
 134              ?>
 135          </p>
 136          <p>&nbsp;</p>
 137          </form>
 138        </div>
 139      </div>
 140  <?php
 141  include  PRJ_INCLUDE_PATH.'html/footer.php';
 142  ?>

title

Description

title

Description

title

Description

title

title

Body