예제 #1
0
파일: lostpw.php 프로젝트: negram/flyspray
 /**
  * action_sendmagic 
  * 
  * @access public
  * @return array
  */
 function action_sendmagic()
 {
     global $db, $baseurl;
     // Check that the username exists
     if (strpos(Post::val('user_name'), '@') === false) {
         $user = Flyspray::getUserDetails(Flyspray::UserNameToId(Post::val('user_name')));
     } else {
         $user_id = $db->x->GetOne('SELECT user_id FROM {users} WHERE email_address = ?', null, Post::val('user_name'));
         $user = Flyspray::getUserDetails($user_id);
     }
     // If the username doesn't exist, throw an error
     if (!is_array($user) || !count($user)) {
         return array(ERROR_RECOVER, L('usernotexist'));
     }
     $magic_url = md5(uniqid(mt_rand(), true));
     // Insert the random "magic url" into the user's profile
     $db->x->execParam('UPDATE {users}
                           SET magic_url = ?
                         WHERE user_id = ?', array($magic_url, $user['user_id']));
     Notifications::send($user['user_id'], ADDRESS_USER, NOTIFY_PW_CHANGE, array($baseurl, $magic_url));
     return array(SUBMIT_OK, L('magicurlsent'));
 }
예제 #2
0
 /**
  * Deletes a user
  * @param integer $uid
  * @access public
  * @return bool
  * @version 1.0
  */
 public static function delete_user($uid)
 {
     global $db, $user;
     if (!$user->perms('is_admin')) {
         return false;
     }
     $userDetails = Flyspray::getUserDetails($uid);
     if (is_file(BASEDIR . '/avatars/' . $userDetails['profile_image'])) {
         unlink(BASEDIR . '/avatars/' . $userDetails['profile_image']);
     }
     $tables = array('users', 'users_in_groups', 'searches', 'notifications', 'assigned', 'votes', 'effort');
     # FIXME Deleting a users effort without asking when user is deleted may not be wanted in every situation.
     # For example for billing a project and the deleted user worked for a project.
     # The better solution is to just deactivate the user, but maybe there are cases a user MUSt be deleted from the database.
     # Move that effort to an 'anonymous users' effort if the effort(s) was legal and should be measured for project(s)?
     foreach ($tables as $table) {
         if (!$db->Query('DELETE FROM ' . '{' . $table . '}' . ' WHERE user_id = ?', array($uid))) {
             return false;
         }
     }
     if (!empty($userDetails['profile_image']) && is_file(BASEDIR . '/avatars/' . $userDetails['profile_image'])) {
         unlink(BASEDIR . '/avatars/' . $userDetails['profile_image']);
     }
     $db->Query('DELETE FROM {registrations} WHERE email_address = ?', array($userDetails['email_address']));
     $db->Query('DELETE FROM {user_emails} WHERE id = ?', array($uid));
     $db->Query('DELETE FROM {reminders} WHERE to_user_id = ? OR from_user_id = ?', array($uid, $uid));
     // for the unusual situuation that a user ID is re-used, make sure that the new user doesn't
     // get permissions for a task automatically
     $db->Query('UPDATE {tasks} SET opened_by = 0 WHERE opened_by = ?', array($uid));
     Flyspray::logEvent(0, 31, serialize($userDetails));
     return true;
 }
예제 #3
0
 /**
  * Deletes a user
  * @param integer $uid
  * @access public
  * @return bool
  * @version 1.0
  */
 function delete_user($uid)
 {
     global $db, $user;
     if (!$user->perms('is_admin')) {
         return false;
     }
     $user_data = Flyspray::getUserDetails($uid);
     $tables = array('users', 'users_in_groups', 'searches', 'notifications', 'assigned');
     foreach ($tables as $table) {
         if (!$db->x->execParam('DELETE FROM ' . '{' . $table . '}' . ' WHERE user_id = ?', $uid)) {
             return false;
         }
     }
     // for the unusual situuation that a user ID is re-used, make sure that the new user doesn't
     // get permissions for a task automatically
     $db->x->execParam('UPDATE {tasks} SET opened_by = 0 WHERE opened_by = ?', $uid);
     Backend::UpdateRedudantUserData($user_data['user_name']);
     Flyspray::logEvent(0, 31, serialize($user_data));
     return true;
 }
예제 #4
0
 /**
  * Deletes a user
  * @param integer $uid
  * @access public
  * @return bool
  * @version 1.0
  */
 public static function delete_user($uid)
 {
     global $db, $user;
     if (!$user->perms('is_admin')) {
         return false;
     }
     $userDetails = Flyspray::getUserDetails($uid);
     if (is_file(BASEDIR . '/avatars/' . $userDetails['profile_image'])) {
         unlink(BASEDIR . '/avatars/' . $userDetails['profile_image']);
     }
     $tables = array('users', 'users_in_groups', 'searches', 'notifications', 'assigned', 'votes', 'effort');
     foreach ($tables as $table) {
         if (!$db->Query('DELETE FROM ' . '{' . $table . '}' . ' WHERE user_id = ?', array($uid))) {
             return false;
         }
     }
     if (!empty($userDetails['profile_image']) && is_file(BASEDIR . '/avatars/' . $userDetails['profile_image'])) {
         unlink(BASEDIR . '/avatars/' . $userDetails['profile_image']);
     }
     $db->Query('DELETE FROM {registrations} WHERE email_address = ?', array($userDetails['email_address']));
     $db->Query('DELETE FROM {user_emails} WHERE email_address = ?', array($userDetails['email_address']));
     $db->Query('DELETE FROM {reminders} WHERE to_user_id = ? OR from_user_id = ?', array($uid, $uid));
     // for the unusual situuation that a user ID is re-used, make sure that the new user doesn't
     // get permissions for a task automatically
     $db->Query('UPDATE {tasks} SET opened_by = 0 WHERE opened_by = ?', array($uid));
     Flyspray::logEvent(0, 31, serialize($userDetails));
     return true;
 }