コード例 #1
0
 public function setPrefs($module, $data)
 {
     // Traiter passwd1 et passwd2
     if ($data['passwd1'] == $data['passwd2'] && strlen($data['passwd1']) > 0) {
         $bu = Kernel::getSessionBU();
         $dao = _dao('kernel|kernel_copixuser');
         $user = $dao->get($bu['user_id']);
         $user->password_dbuser = md5($data['passwd1']);
         $dao->update($user);
     }
     unset($data['passwd1']);
     unset($data['passwd2']);
     // Traiter l'effacement d'un avatar
     if (isset($data['avatar_delete']) && $data['avatar_delete'] == '1') {
         $path2data = realpath("static");
         $path2prefs = $path2data . "/prefs";
         $path2avatars = $path2prefs . "/avatar";
         if ($avatar_old = Prefs::get('prefs', 'avatar')) {
             @unlink($path2avatars . '/' . $avatar_old);
             Prefs::del('prefs', 'avatar');
         }
     }
     // Traiter l'ajout d'un avatar
     if (ereg("^image/(.+)\$", $_FILES['prefs_avatar_upload']['type'], $regs)) {
         if (in_array($regs[1], array('jpeg', 'gif', 'png'))) {
             $path2data = realpath("static");
             $path2prefs = $path2data . "/prefs";
             // if( !is_dir($path2prefs) ) mkdir($path2prefs);
             $path2avatars = $path2prefs . "/avatar";
             // if( !is_dir($path2avatars) ) mkdir($path2avatars);
             if ($avatar_old = Prefs::get('prefs', 'avatar')) {
                 @unlink($path2avatars . '/' . $avatar_old);
             }
             $avatar_file = $path2avatars . "/" . _currentUser()->getLogin() . '.' . $regs[1];
             move_uploaded_file($_FILES['prefs_avatar_upload']['tmp_name'], $avatar_file);
             $data['avatar'] = _currentUser()->getLogin() . '.' . $regs[1];
         }
     }
     if (!isset($data['assistance'])) {
         $data['assistance'] = 0;
     }
     if (!isset($data['assistance_ien'])) {
         $data['assistance_ien'] = 0;
     }
     /*
     if( !isset($data['alerte_mail_active']) ) $data['alerte_mail_active']=0;
     */
     // Enregistrement du reste dans la base principale
     $pref_service =& CopixClassesFactory::Create('prefs|prefs');
     $pref_service->setPrefs($module, $data);
 }