Index: branches/salvatoreingala/Gadgets/ApiSetGadgetPrefs.php |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | $this->getResult()->addValue( |
59 | 59 | null, $this->getModuleName(), array( 'result' => 'Success' ) ); |
60 | 60 | } else { |
61 | | - $this->dieUsage( 'Invalid preferences.', 'invalidprefs' ); |
| 61 | + $this->dieUsage( 'Invalid preferences', 'invalidprefs' ); |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
— | — | @@ -98,6 +98,16 @@ |
99 | 99 | return 'Allows user code to set preferences for gadgets'; |
100 | 100 | } |
101 | 101 | |
| 102 | + public function getPossibleErrors() { |
| 103 | + return array_merge( parent::getPossibleErrors(), array( |
| 104 | + array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to get gadget\'s preferences' ), |
| 105 | + array( 'sessionfailure' ), |
| 106 | + array( 'code' => 'notfound', 'info' => 'Gadget not found' ), |
| 107 | + array( 'code' => 'notjson', 'info' => 'The \'pref\' parameter must be valid JSON' ), |
| 108 | + array( 'code' => 'invalidprefs', 'info' => 'Invalid preferences' ), |
| 109 | + ) ); |
| 110 | + } |
| 111 | + |
102 | 112 | public function needsToken() { |
103 | 113 | return true; |
104 | 114 | } |
Index: branches/salvatoreingala/Gadgets/ApiGetGadgetPrefs.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | $prefsDescription = $gadget->getPrefsDescription(); |
45 | 45 | |
46 | 46 | if ( $prefsDescription === null ) { |
47 | | - $this->dieUsage( 'Gadget ' . $gadget->getName() . ' does not have any preference.', 'noprefs' ); |
| 47 | + $this->dieUsage( 'Gadget ' . $gadget->getName() . ' does not have any preference', 'noprefs' ); |
48 | 48 | } |
49 | 49 | |
50 | 50 | $userPrefs = $gadget->getPrefs(); |
— | — | @@ -76,9 +76,17 @@ |
77 | 77 | } |
78 | 78 | |
79 | 79 | public function getDescription() { |
80 | | - return 'Allows user code to get preferences for gadgets, along with preference descriptions'; |
| 80 | + return 'Allows user code to get preferences for gadgets, along with preference descriptions and values for currently logged in user'; |
81 | 81 | } |
82 | 82 | |
| 83 | + public function getPossibleErrors() { |
| 84 | + return array_merge( parent::getPossibleErrors(), array( |
| 85 | + array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to get gadget\'s preferences' ), |
| 86 | + array( 'code' => 'notfound', 'info' => 'Gadget not found' ), |
| 87 | + array( 'code' => 'noprefs', 'info' => 'Gadget gadgetname does not have any preferences' ), |
| 88 | + ) ); |
| 89 | + } |
| 90 | + |
83 | 91 | public function getVersion() { |
84 | 92 | return __CLASS__ . ': $Id$'; |
85 | 93 | } |