* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Data
- * @package GNUSocial
+ * @package GNUsocial
* @author Mikael Nordfeldth <mmn@hethane.se>
* @copyright 2013 Free Software Foundation, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
static function getAll(Profile $profile)
{
- $prefs = self::listFind('profile_id', $profile->id);
+ try {
+ $prefs = self::listFind('profile_id', $profile->id);
+ } catch (NoResultException $e) {
+ return array();
+ }
$list = array();
while ($entry = $prefs->fetch()) {
}
static function getTopic(Profile $profile, $namespace, $topic) {
- $pref = self::pkeyGet(array('profile_id'=>$profile->id, 'namespace'=>$namespace, 'topic'=>$topic));
- if (is_null($pref)) {
+ $pref = new Profile_prefs;
+ $pref->profile_id = $profile->id;
+ $pref->namespace = $namespace;
+ $pref->topic = $topic;
+
+ if (!$pref->find(true)) {
throw new NoResultException($pref);
}
return $pref;
static function getConfigData(Profile $profile, $namespace, $topic) {
try {
$data = self::getData($profile, $namespace, $topic);
- } catch (Exception $e) {
+ } catch (NoResultException $e) {
$data = common_config($namespace, $topic);
}
return $data;
$pref->topic = $topic;
$pref->data = $data;
- if (!$pref->insert()) {
+ if ($pref->insert() === false) {
throw new ServerException('Could not save profile preference.');
}
return true;