Go to the documentation of this file.00001 <?php
00002
00008 class User_Main extends oxAdminDetails
00009 {
00010
00011 private $_sSaveError = null;
00012
00020 public function render()
00021 {
00022 $myConfig = $this->getConfig();
00023 $soxId = $this->getEditObjectId();
00024
00025 parent::render();
00026
00027
00028 $oAuthUser = oxNew('oxuser');
00029 $oAuthUser->loadAdminUser();
00030 $blisMallAdmin = $oAuthUser->oxuser__oxrights->value == "malladmin";
00031
00032
00033 $sViewName = getViewName("oxgroups", $this->_iEditLang);
00034 $oGroups = oxNew("oxlist");
00035 $oGroups->init("oxgroups");
00036 $oGroups->selectString("select * from {$sViewName} order by {$sViewName}.oxtitle");
00037
00038
00039 $aUserRights = array();
00040 $oLang = oxRegistry::getLang();
00041 $iTplLang = $oLang->getTplLanguage();
00042
00043 $iPos = count($aUserRights);
00044 $aUserRights[$iPos] = new stdClass();
00045 $aUserRights[$iPos]->name = $oLang->translateString("user", $iTplLang);
00046 $aUserRights[$iPos]->id = "user";
00047
00048 if ($blisMallAdmin) {
00049 $iPos = count($aUserRights);
00050 $aUserRights[$iPos] = new stdClass();
00051 $aUserRights[$iPos]->id = "malladmin";
00052 $aUserRights[$iPos]->name = $oLang->translateString("Admin", $iTplLang);
00053 }
00054
00055
00056 $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00057 if ($soxId != "-1" && isset($soxId)) {
00058
00059 $oUser = oxNew("oxuser");
00060 $oUser->load($soxId);
00061 $this->_aViewData["edit"] = $oUser;
00062
00063 if (!($oUser->oxuser__oxrights->value == "malladmin" && !$blisMallAdmin)) {
00064
00065 reset($aUserRights);
00066 while (list(, $val) = each($aUserRights)) {
00067 if ($val->id == $oUser->oxuser__oxrights->value) {
00068 $val->selected = 1;
00069 break;
00070 }
00071 }
00072 }
00073 }
00074
00075
00076 $oCountryList = oxNew("oxCountryList");
00077 $oCountryList->loadActiveCountries($oLang->getObjectTplLanguage());
00078
00079 $this->_aViewData["countrylist"] = $oCountryList;
00080
00081 $this->_aViewData["allgroups"] = $oGroups;
00082
00083 $this->_aViewData["rights"] = $aUserRights;
00084
00085 if ($this->_sSaveError) {
00086 $this->_aViewData["sSaveError"] = $this->_sSaveError;
00087 }
00088
00089 if (!$this->_allowAdminEdit($soxId)) {
00090 $this->_aViewData['readonly'] = true;
00091 }
00092 if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
00093 $oUserMainAjax = oxNew('user_main_ajax');
00094 $this->_aViewData['oxajax'] = $oUserMainAjax->getColumns();
00095
00096 return "popups/user_main.tpl";
00097 }
00098
00099 return "user_main.tpl";
00100 }
00101
00107 public function save()
00108 {
00109 parent::save();
00110
00111
00112 $soxId = $this->getEditObjectId();
00113 if ($this->_allowAdminEdit($soxId)) {
00114
00115 $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00116
00117
00118 if (!isset($aParams['oxuser__oxactive'])) {
00119 $aParams['oxuser__oxactive'] = 0;
00120 }
00121
00122 $oUser = oxNew("oxuser");
00123 if ($soxId != "-1") {
00124 $oUser->load($soxId);
00125 } else {
00126 $aParams['oxuser__oxid'] = null;
00127 }
00128
00129
00130 if (($sNewPass = oxRegistry::getConfig()->getRequestParameter("newPassword"))) {
00131 $oUser->setPassword($sNewPass);
00132 }
00133
00134
00135 if ($oUser->checkIfEmailExists($aParams['oxuser__oxusername'])) {
00136 $this->_sSaveError = 'EXCEPTION_USER_USEREXISTS';
00137
00138 return;
00139 }
00140
00141 $oUser->assign($aParams);
00142
00143
00144
00145 $oUser->oxuser__oxbirthdate->fldtype = 'char';
00146
00147 try {
00148 $oUser->save();
00149
00150
00151 $this->setEditObjectId($oUser->getId());
00152 } catch (Exception $oExcp) {
00153 $this->_sSaveError = $oExcp->getMessage();
00154 }
00155 }
00156 }
00157 }