Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in core repo, for Emails sending feature when calendar event is shared #2996

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static function setupBackends() {
*
* Allowed characters in the username are: "a-z", "A-Z", "0-9" and "_.@-"
*/
public static function createUser( $uid, $password ) {
public static function createUser( $uid, $password, $email ) {
// Check the name for bad characters
// Allowed are: "a-z", "A-Z", "0-9" and "_.@-"
if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $uid )) {
Expand All @@ -171,6 +171,10 @@ public static function createUser( $uid, $password ) {
if(trim($password) == '') {
throw new Exception('A valid password must be provided');
}
// No empty email
if(trim($email) == '') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use ===

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kabum Thanks.. I used "==" since it is used to trim password and user name. I will change to "===".

throw new Exception('A valid email must be provided');
}

// Check if user already exists
if( self::userExistsForCreation($uid) ) {
Expand All @@ -179,16 +183,16 @@ public static function createUser( $uid, $password ) {


$run = true;
OC_Hook::emit( "OC_User", "pre_createUser", array( "run" => &$run, "uid" => $uid, "password" => $password ));
OC_Hook::emit( "OC_User", "pre_createUser", array( "run" => &$run, "uid" => $uid, "password" => $password, "email" => $email ));

if( $run ) {
//create the user in the first backend that supports creating users
foreach(self::$_usedBackends as $backend) {
if(!$backend->implementsActions(OC_USER_BACKEND_CREATE_USER))
continue;

$backend->createUser($uid, $password);
OC_Hook::emit( "OC_User", "post_createUser", array( "uid" => $uid, "password" => $password ));
$backend->createUser($uid, $password, $email);
OC_Hook::emit( "OC_User", "post_createUser", array( "uid" => $uid, "password" => $password, "email" => $email ));

return self::userExists($uid);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/user/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ private function getHasher() {
* Creates a new user. Basic checking of username is done in OC_User
* itself, not in its subclasses.
*/
public function createUser( $uid, $password ) {
public function createUser( $uid, $password, $email ) {
if( $this->userExists($uid) ) {
return false;
}else{
$hasher=$this->getHasher();
$hash = $hasher->HashPassword($password.OC_Config::getValue('passwordsalt', ''));
$query = OC_DB::prepare( 'INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )' );
$result = $query->execute( array( $uid, $hash));
$query = OC_DB::prepare( 'INSERT INTO `*PREFIX*users` ( `uid`, `password`, `email` ) VALUES( ?, ?, ? )' );
$result = $query->execute( array( $uid, $hash, $email));

return $result ? true : false;
}
Expand Down
3 changes: 2 additions & 1 deletion settings/ajax/createuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
}
$username = $_POST["username"];
$password = $_POST["password"];
$email = $_POST["email"];

// Return Success story
try {
if (!OC_User::createUser($username, $password)) {
if (!OC_User::createUser($username, $password, $email)) {
OC_JSON::error(array('data' => array( 'message' => 'User creation failed for '.$username )));
exit();
}
Expand Down
8 changes: 8 additions & 0 deletions settings/js/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ $(document).ready(function () {
event.preventDefault();
var username = $('#newusername').val();
var password = $('#newuserpassword').val();
var email = $('#newuseremail').val();
if ($.trim(username) == '') {
OC.dialogs.alert(
t('settings', 'A valid username must be provided'),
Expand All @@ -421,13 +422,20 @@ $(document).ready(function () {
t('settings', 'Error creating user'));
return false;
}
if ($.trim(email) == '') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OC.dialogs.alert(
t('settings', 'A valid email must be provided'),
t('settings', 'Error creating user'));
return false;
}
var groups = $('#newusergroups').prev().children('div').data('settings').checked;
$('#newuser').get(0).reset();
$.post(
OC.filePath('settings', 'ajax', 'createuser.php'),
{
username: username,
password: password,
email: email,
groups: groups
},
function (result) {
Expand Down
2 changes: 1 addition & 1 deletion settings/templates/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<form id="newuser" autocomplete="off">
<input id="newusername" type="text" placeholder="<?php p($l->t('Login Name'))?>" /> <input
type="password" id="newuserpassword"
placeholder="<?php p($l->t('Password'))?>" /> <select
placeholder="<?php p($l->t('Password'))?>" /> <input id="newuseremail" type="text" placeholder="<?php p($l->t('E-mail')) ?>" /> <select
class="groupsselect"
id="newusergroups" data-placeholder="groups"
title="<?php p($l->t('Groups'))?>" multiple="multiple">
Expand Down