user_extend.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class User_Extend extends oxAdminDetails
00009 {
00010 
00017     public function render()
00018     {
00019         parent::render();
00020 
00021         $soxId = $this->getEditObjectId();
00022         if ($soxId != "-1" && isset($soxId)) {
00023             // load object
00024             $oUser = oxNew("oxuser");
00025             $oUser->load($soxId);
00026 
00027             //show country in active language
00028             $oCountry = oxNew("oxCountry");
00029             $oCountry->loadInLang(oxRegistry::getLang()->getObjectTplLanguage(), $oUser->oxuser__oxcountryid->value);
00030             $oUser->oxuser__oxcountry = new oxField($oCountry->oxcountry__oxtitle->value);
00031 
00032             $this->_aViewData["edit"] = $oUser;
00033         }
00034 
00035         if (!$this->_allowAdminEdit($soxId)) {
00036             $this->_aViewData['readonly'] = true;
00037         }
00038 
00039         return "user_extend.tpl";
00040     }
00041 
00047     public function save()
00048     {
00049         parent::save();
00050 
00051         $soxId = $this->getEditObjectId();
00052 
00053         if (!$this->_allowAdminEdit($soxId)) {
00054             return false;
00055         }
00056 
00057         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00058 
00059         $oUser = oxNew("oxuser");
00060         if ($soxId != "-1") {
00061             $oUser->load($soxId);
00062         } else {
00063             $aParams['oxuser__oxid'] = null;
00064         }
00065 
00066         // checkbox handling
00067         $aParams['oxuser__oxactive'] = $oUser->oxuser__oxactive->value;
00068 
00069         $blNewsParams = oxRegistry::getConfig()->getRequestParameter("editnews");
00070         if (isset($blNewsParams)) {
00071             $oNewsSubscription = $oUser->getNewsSubscription();
00072             $oNewsSubscription->setOptInStatus((int) $blNewsParams);
00073             $oNewsSubscription->setOptInEmailStatus((int) oxRegistry::getConfig()->getRequestParameter("emailfailed"));
00074         }
00075 
00076         $oUser->assign($aParams);
00077         $oUser->save();
00078 
00079         // set oxid if inserted
00080         $this->setEditObjectId($oUser->getId());
00081     }
00082 }