/** * Handles a request to save preferences * * Validates input and, if everything is OK, deletes the OpenID. * Reloads the form with a success or error notification. * * @return void */ function savePrefs() { $orig = null; $prefs = User_openid_prefs::getKV('user_id', $this->scoped->getID()); if (!$prefs instanceof User_openid_prefs) { $prefs = new User_openid_prefs(); $prefs->user_id = $this->scoped->getID(); $prefs->created = common_sql_now(); } else { $orig = clone $prefs; } $prefs->hide_profile_link = $this->booleanintstring('hide_profile_link'); if ($orig instanceof User_openid_prefs) { $prefs->update($orig); } else { $prefs->insert(); } return _m('OpenID preferences saved.'); }
/** * Add links in the user's profile block to their OpenID URLs. * * @param Profile $profile The profile being shown * @param Array &$links Writeable array of arrays (href, text, image). * * @return boolean hook value (true) */ function onOtherAccountProfiles($profile, &$links) { $prefs = User_openid_prefs::getKV('user_id', $profile->id); if (empty($prefs) || !$prefs->hide_profile_link) { $oid = new User_openid(); $oid->user_id = $profile->id; if ($oid->find()) { while ($oid->fetch()) { $links[] = array('href' => $oid->display, 'text' => _('OpenID'), 'image' => $this->path("icons/openid-16x16.gif")); } } } return true; }
/** * Handles a request to save preferences * * Validates input and, if everything is OK, deletes the OpenID. * Reloads the form with a success or error notification. * * @return void */ function savePrefs() { $cur = common_current_user(); if (empty($cur)) { throw new ClientException(_("Not logged in.")); } $orig = null; $prefs = User_openid_prefs::getKV('user_id', $cur->id); if (empty($prefs)) { $prefs = new User_openid_prefs(); $prefs->user_id = $cur->id; $prefs->created = common_sql_now(); } else { $orig = clone $prefs; } $prefs->hide_profile_link = $this->booleanintstring('hide_profile_link'); if (empty($orig)) { $prefs->insert(); } else { $prefs->update($orig); } $this->showForm(_m('OpenID preferences saved.'), true); return; }