예제 #1
0
 /**
  * 
  */
 private function set_first_user()
 {
     require DIR_PLUG . 'USERS_MGMT/libs/class.USERS.php';
     $fields = array();
     $fields = array('name' => $_POST['user_kadmin'], 'user' => $_POST['user_kadmin'], 'pass' => sha1($_POST['pass_kadmin']), 'description' => 'Primer superadministrador', 'date_insert' => date('Y-m-d H:i'));
     if (isset($_POST['group_users'])) {
         $fields['idGroup'] = 1;
     }
     //fin if
     $user = new USERS(T_USERS, 'id', '', $this->_bdLink);
     $user->set_user($fields);
 }
예제 #2
0
 /**
  * 
  */
 private function do_your_data()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (strlen(trim($_POST['name'])) > 0) {
             require dirname(__FILE__) . '/libs/class.USERS.php';
             $fields = array();
             $user = new USERS(T_USERS, 'id', SESSION_NAME, $this->_bdLink);
             $resp = $user->check_change_pass($_POST['old_pass'], $_POST['pass'], $_POST['re_pass']);
             switch ($resp) {
                 case 0:
                     //With new pass
                     $fields = array('name' => $_POST['name'], 'email' => $_POST['email'], 'pass' => sha1(trim($_POST['pass'])));
                     break;
                 case 1:
                     //Without new pass
                     $fields = array('name' => $_POST['name'], 'email' => $_POST['email']);
                     break;
                 case 2:
                     $msg = array('type' => 'warning', 'text' => $this->_lang['msg']['error_data_update_2']);
                     break;
                 case 3:
                     $msg = array('type' => 'warning', 'text' => $this->_lang['msg']['error_data_update_3']);
                     break;
                 case 4:
                     $msg = array('type' => 'warning', 'text' => $this->_lang['msg']['error_data_update_4']);
                     break;
                 case 5:
                     $msg = array('type' => 'warning', 'text' => $this->_lang['msg']['error_data_update_5']);
                     break;
             }
             //fin switch
             if ($resp === 0 || $resp === 1) {
                 $msg = $user->set_user($fields, $_SESSION[SESSION_NAME]['id']) ? array('type' => 'success', 'text' => $this->_lang['msg']['user_data_updated']) : array('type' => 'error', 'text' => $this->_lang['msg']['error_updating_data']);
                 if ($msg['type'] == 'success') {
                     $user->set_session($user->get_user($_SESSION[SESSION_NAME]['id']));
                     $this->smarty->assign('session', $_SESSION[SESSION_NAME]);
                 }
                 //fin if
             }
             //fin if
         } else {
             $msg = array('type' => 'warning', 'text' => $this->_lang['msg']['error_data_update_name']);
         }
         //fin else
         $this->smarty->assign('msg', $msg);
     }
     //fin if
     return array('in_main' => true, 'inc' => 'site.user_data.tpl');
 }