-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added function mc_user_pref_get_pref to the API to allow read access …
…to user preferences. Fixes #12946: mc_user_pref_get_pref, user_pref_get_pref API call Signed-off-by: Robert Munteanu <robert.munteanu@gmail.com>
- Loading branch information
Showing
5 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
# MantisConnect - A webservice interface to Mantis Bug Tracker | ||
# Copyright (C) 2004-2011 Victor Boctor - vboctor@users.sourceforge.net | ||
# This program is distributed under dual licensing. These include | ||
# GPL and a commercial licenses. Victor Boctor reserves the right to | ||
# change the license of future releases. | ||
# See docs/ folder for more details | ||
|
||
/** | ||
* Get the value for the specified user preference. | ||
* | ||
* @param string $p_username The user's username | ||
* @param string $p_password The user's password | ||
* @param int $p_project_id Project ID (0 = ALL_PROJECTS (mantisbt/core/constant_inc.php)) | ||
* @param string $p_pref_name The name of the preference | ||
* @return string $t_user_pref The requested preference value | ||
*/ | ||
function mc_user_pref_get_pref( $p_username, $p_password, $p_project_id, $p_pref_name ) { | ||
$t_user_id = mci_check_login( $p_username, $p_password ); | ||
if ( $t_user_id === false ) { | ||
return mci_soap_fault_login_failed(); | ||
} | ||
|
||
if ( !mci_has_readonly_access( $t_user_id ) ) { | ||
return mci_soap_fault_access_denied( $t_user_id ); | ||
} | ||
|
||
return user_pref_get_pref( $t_user_id, $p_pref_name, $p_project_id ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
# MantisBT - A PHP based bugtracking system | ||
|
||
# MantisBT is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# MantisBT is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* @package Tests | ||
* @subpackage UnitTests | ||
* @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net | ||
* @link http://www.mantisbt.org | ||
*/ | ||
|
||
require_once 'SoapBase.php'; | ||
|
||
/** | ||
* Test fixture for non-login user methods | ||
*/ | ||
class UserTest extends SoapBase { | ||
|
||
/** | ||
* Tests getting a user preference | ||
*/ | ||
public function testGetPreference() { | ||
|
||
$language = $this->client->mc_user_pref_get_pref( $this->userName, $this->password, 0 /*ALL_PROJECTS*/, 'language' ); | ||
|
||
$this->assertEquals( 'auto', $language ); | ||
|
||
} | ||
} |