/** * Return the selected view mode if any * @return bollean|string, view mode name or false * @access getViewMode */ function getViewMode() { $enabled = Configure::read('App.gui.viewModes.enabled'); // check if different view modes are actives for this context $allowed = Common::requestAllowed($this->Controller->name, $this->Controller->action, Configure::read('App.gui.viewModes.conditions')); // options must be enabled and allowed for controller:action if ($enabled && $allowed) { // list allowed view modes $allowed = Configure::read('App.gui.viewModes.options'); $urlName = Configure::read('App.gui.viewModes.urlName'); $requested = array(); if (isset($this->Controller->params['named'][$urlName]) && isset($allowed[$this->Controller->params['named'][$urlName]])) { // check if the view mode is requested in the url $requested = $this->Controller->params['named'][$urlName]; User::setValue('Preference.gui.viewModes.default', $requested); } elseif (User::get('Preference.gui.viewModes.default')) { // check if there was any preferences in the past $requested = User::get('Preference.gui.viewModes.default'); } else { // default option $requested = Configure::read('App.gui.viewModes.default'); } return $requested; } return false; }
function index() { Loader::loadModel('User'); $oUser = new User(); $oUser->setValue('name', 'Hello World'); $this->view->data = $oUser->getValue('name'); $this->view->admin_constant = Constants::USERGROUP_ADMIN; $this->view->fruits = array('banana', 'bonana'); }
/** * Signup */ public function signupAction() { $form = new Form_User(); if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) { $userData = $form->getValues(); $userData['id'] = User::fetchNextId(); // save user $user = new User($userData['id']); $user->setValue($userData); $users = new Users(); $users->add($userData['id']); // save login to id link User::setLoginToIdLink($userData['login'], $userData['id']); $this->_redirect('/user/login'); } $this->view->form = $form; }
GROUP BY usr_id'; $pdoStatement = $gDb->query($sql); $count = $pdoStatement->rowCount(); // show error if no user found or more than one user found if ($count === 0) { $gMessage->show($gL10n->get('SYS_LOSTPW_EMAIL_ERROR', $_POST['recipient_email'])); } elseif ($count > 1) { $gMessage->show($gL10n->get('SYS_LOSTPW_SEVERAL_EMAIL', $_POST['recipient_email'])); } $row = $pdoStatement->fetch(); $user = new User($gDb, $gProfileFields, $row['usr_id']); // create and save new password and activation id $newPassword = PasswordHashing::genRandomPassword(8); $activationId = PasswordHashing::genRandomPassword(10); $user->setPassword($newPassword, true); $user->setValue('usr_activation_code', $activationId); $sysmail = new SystemMail($gDb); $sysmail->addRecipient($user->getValue('EMAIL'), $user->getValue('FIRST_NAME', 'database') . ' ' . $user->getValue('LAST_NAME', 'database')); $sysmail->setVariable(1, $newPassword); $sysmail->setVariable(2, $g_root_path . '/adm_program/system/password_activation.php?usr_id=' . $user->getValue('usr_id') . '&aid=' . $activationId); $sysmail->sendSystemMail('SYSMAIL_ACTIVATION_LINK', $user); $user->saveChangesWithoutRights(); $user->save(); $gMessage->setForwardUrl($g_root_path . '/adm_program/system/login.php'); $gMessage->show($gL10n->get('SYS_LOSTPW_SEND', $_POST['recipient_email'])); } catch (AdmException $e) { $e->showHtml(); } } else { /*********************HTML_PART*******************************/ // create html page object
$gMessage->show($gL10n->get('SYS_NO_RIGHTS')); } // pruefen, ob Modul aufgerufen werden darf if ($gPreferences['registration_mode'] == 0) { $gMessage->show($gL10n->get('SYS_MODULE_DISABLED')); } // create user objects $registrationUser = new UserRegistration($gDb, $gProfileFields, $getNewUserId); if ($getUserId > 0) { $user = new User($gDb, $gProfileFields, $getUserId); } if ($getMode == 1 || $getMode == 2) { // User-Account einem existierenden Mitglied zuordnen // Daten kopieren, aber nur, wenn noch keine Logindaten existieren if (strlen($user->getValue('usr_login_name')) == 0 && strlen($user->getValue('usr_password')) == 0) { $user->setValue('EMAIL', $registrationUser->getValue('EMAIL')); $user->setValue('usr_login_name', $registrationUser->getValue('usr_login_name')); $user->setValue('usr_password', $registrationUser->getValue('usr_password')); } try { // zuerst den neuen Usersatz loeschen, dann den alten Updaten, // damit kein Duplicate-Key wegen dem Loginnamen entsteht $registrationUser->notSendEmail(); $registrationUser->delete(); $user->save(); } catch (AdmException $e) { // exception is thrown when email couldn't be send // so save user data and then show error $user->save(); $gMessage->setForwardUrl($gNavigation->getPreviousUrl()); $e->showHtml();
$gCurrentOrganization->createBasicData($webmaster->getValue('usr_id')); // create default room for room module in database $sql = 'INSERT INTO ' . TBL_ROOMS . ' (room_name, room_description, room_capacity, room_usr_id_create, room_timestamp_create) VALUES (\'' . $gL10n->get('INS_CONFERENCE_ROOM') . '\', \'' . $gL10n->get('INS_DESCRIPTION_CONFERENCE_ROOM') . '\', 15, ' . $gCurrentUser->getValue('usr_id') . ',\'' . DATETIME_NOW . '\')'; $db->query($sql); // first create a user object "current user" with webmaster rights because webmaster // is allowed to edit firstname and lastname $gCurrentUser = new User($db, $gProfileFields, $webmaster->getValue('usr_id')); $gCurrentUser->setValue('LAST_NAME', $_SESSION['user_last_name']); $gCurrentUser->setValue('FIRST_NAME', $_SESSION['user_first_name']); $gCurrentUser->setValue('EMAIL', $_SESSION['user_email']); $gCurrentUser->save(false); // now create a full user object for system user $systemUser = new User($db, $gProfileFields, $systemUserId); $systemUser->setValue('LAST_NAME', $gL10n->get('SYS_SYSTEM')); $systemUser->save(false); // no registered user -> UserIdCreate couldn't be filled // now set current user to system user $gCurrentUser->readDataById($systemUserId); // delete session data session_unset(); // text for dialog $text = $gL10n->get('INS_INSTALLATION_SUCCESSFUL') . '<br /><br />' . $gL10n->get('INS_SUPPORT_FURTHER_DEVELOPMENT'); if (!is_writable('../../adm_my_files')) { $text = $text . ' <div class="alert alert-warning alert-small" role="alert"> <span class="glyphicon glyphicon-warning-sign"></span> ' . $gL10n->get('INS_FOLDER_NOT_WRITABLE', 'adm_my_files') . ' </div>'; }
$rowDuplicateUser = $gDb->fetch_array($result); if ($rowDuplicateUser['usr_id'] > 0) { $duplicate_user = new User($gDb, $gProfileFields, $rowDuplicateUser['usr_id']); } if ($rowDuplicateUser['usr_id'] > 0) { if ($_SESSION['user_import_mode'] == USER_IMPORT_DISPLACE) { // delete all user data of profile fields $duplicate_user->deleteUserFieldData(); } if ($_SESSION['user_import_mode'] == USER_IMPORT_COMPLETE || $_SESSION['user_import_mode'] == USER_IMPORT_DISPLACE) { // edit data of user, if user already exists foreach ($importedFields as $key => $field_name_intern) { if ($duplicate_user->getValue($field_name_intern) != $user->getValue($field_name_intern)) { if ($gProfileFields->getProperty($field_name_intern, 'usf_type') == 'DATE') { // the date must be formated $duplicate_user->setValue($field_name_intern, $user->getValue($field_name_intern, $gPreferences['system_date'])); } elseif ($field_name_intern == 'COUNTRY') { // we need the iso-code and not the name of the country $duplicate_user->setValue($field_name_intern, $gL10n->getCountryByName($user->getValue($field_name_intern))); } elseif ($gProfileFields->getProperty($field_name_intern, 'usf_type') == 'DROPDOWN' || $gProfileFields->getProperty($field_name_intern, 'usf_type') == 'RADIO_BUTTON') { // get number and not value of entry $duplicate_user->setValue($field_name_intern, $user->getValue($field_name_intern, 'database')); } else { $duplicate_user->setValue($field_name_intern, $user->getValue($field_name_intern)); } } } $user = $duplicate_user; } } if ($rowDuplicateUser['usr_id'] == 0 || $rowDuplicateUser['usr_id'] > 0 && $_SESSION['user_import_mode'] > USER_IMPORT_NOT_EDIT) {
} $phrase = $gL10n->get('SYS_DELETE_DATA'); // User aus der Admidio Datenbank loeschen $user->delete(); } elseif ($getMode == 4) { // nur Webmaster duerfen User neue Zugangsdaten zuschicken // nur ausfuehren, wenn E-Mails vom Server unterstuetzt werden // nur an Mitglieder der eigenen Organisation schicken if ($gCurrentUser->isWebmaster() == false || $gPreferences['enable_system_mails'] != 1 || $this_orga == false) { $gMessage->show($gL10n->get('SYS_NO_RIGHTS')); } if ($gPreferences['enable_system_mails'] == 1) { try { // neues Passwort generieren und abspeichern $password = substr(md5(time()), 0, 8); $user->setValue('usr_password', $password); $user->save(); // Mail an den User mit den Loginaten schicken $sysmail = new SystemMail($gDb); $sysmail->addRecipient($user->getValue('EMAIL'), $user->getValue('FIRST_NAME') . ' ' . $user->getValue('LAST_NAME')); $sysmail->setVariable(1, $password); $sysmail->sendSystemMail('SYSMAIL_NEW_PASSWORD', $user); $gMessage->setForwardUrl($gNavigation->getUrl()); $gMessage->show($gL10n->get('SYS_EMAIL_SEND')); } catch (AdmException $e) { $e->showText(); } } } elseif ($getMode == 5) { // Fragen, ob Zugangsdaten verschickt werden sollen $gMessage->setForwardYesNo($g_root_path . '/adm_program/modules/members/members_function.php?usr_id=' . $getUserId . '&mode=4');
AND LENGTH(usr_login_name) > 0 GROUP BY usr_id'; $result = $gDb->query($sql); $count = $gDb->num_rows(); // show error if no user found or more than one user found if ($count === 0) { $gMessage->show($gL10n->get('SYS_LOSTPW_EMAIL_ERROR', $_POST['recipient_email'])); } elseif ($count > 1) { $gMessage->show($gL10n->get('SYS_LOSTPW_SEVERAL_EMAIL', $_POST['recipient_email'])); } $row = $gDb->fetch_array($result); $user = new User($gDb, $gProfileFields, $row['usr_id']); // create and save new password and activation id $newPassword = substr(md5(time()), 0, 8); $activationId = substr(md5(uniqid($user->getValue('EMAIL') . time())), 0, 10); $user->setValue('usr_new_password', $newPassword); $user->setValue('usr_activation_code', $activationId); $sysmail = new SystemMail($gDb); $sysmail->addRecipient($user->getValue('EMAIL'), $user->getValue('FIRST_NAME') . ' ' . $user->getValue('LAST_NAME')); $sysmail->setVariable(1, $newPassword); $sysmail->setVariable(2, $g_root_path . '/adm_program/system/password_activation.php?usr_id=' . $user->getValue('usr_id') . '&aid=' . $activationId); $sysmail->sendSystemMail('SYSMAIL_ACTIVATION_LINK', $user); $user->saveChangesWithoutRights(); $user->save(); $gMessage->setForwardUrl($g_root_path . '/adm_program/system/login.php'); $gMessage->show($gL10n->get('SYS_LOSTPW_SEND', $_POST['recipient_email'])); } catch (AdmException $e) { $e->showHtml(); } } else { /*********************HTML_PART*******************************/
$gMessage->show($gL10n->get('SYS_NO_RIGHTS')); } if ($getMode == 'change') { /***********************************************************************/ /* Handle form input */ /***********************************************************************/ if ($gCurrentUser->isWebmaster() && $gCurrentUser->getValue('usr_id') != $getUserId) { $_POST['old_password'] = ''; } if ((strlen($_POST['old_password']) > 0 || $gCurrentUser->isWebmaster()) && strlen($_POST['new_password']) > 0 && strlen($_POST['new_password_confirm']) > 0) { if (strlen($_POST['new_password']) > 5) { if ($_POST['new_password'] == $_POST['new_password_confirm']) { // check if old password is correct. // Webmaster could change password of other users without this verification. if ($user->checkPassword($_POST['old_password']) || $gCurrentUser->isWebmaster() && $gCurrentUser->getValue('usr_id') != $getUserId) { $user->setValue('usr_password', $_POST['new_password']); $user->save(); // if password of current user changed, then update value in current session if ($user->getValue('usr_id') == $gCurrentUser->getValue('usr_id')) { $gCurrentUser->setValue('usr_password', $_POST['new_password']); } $phrase = 'success'; } else { $phrase = $gL10n->get('PRO_PASSWORD_OLD_WRONG'); } } else { $phrase = $gL10n->get('PRO_PASSWORDS_NOT_EQUAL'); } } else { $phrase = $gL10n->get('PRO_PASSWORD_LENGTH'); }