| 183 | | * Persists a copy of the current user cookie into the browser cookie stash. |
| 184 | | */ |
| 185 | | </mt:Ignore> |
| 186 | | function mtSaveUser(f) { |
| 187 | | // We can't reliably store the user cookie during a preview. |
| 188 | | if (is_preview) return; |
| 189 | | |
| 190 | | var u = mtGetUser(); |
| 191 | | |
| 192 | | if (f && (!u || u.is_anonymous)) { |
| 193 | | if ( !u ) { |
| 194 | | u = {}; |
| 195 | | u.is_authenticated = false; |
| 196 | | u.can_comment = true; |
| 197 | | u.is_author = false; |
| 198 | | u.is_banned = false; |
| 199 | | u.is_anonymous = true; |
| 200 | | u.is_trusted = false; |
| 201 | | } |
| 202 | | if (f.author != undefined) u.name = f.author.value; |
| 203 | | if (f.email != undefined) u.email = f.email.value; |
| 204 | | if (f.url != undefined) u.url = f.url.value; |
| 205 | | } |
| 206 | | |
| 207 | | if (!u) return; |
| 208 | | |
| 209 | | var cache_period = mtCookieTimeout * 1000; |
| 210 | | |
| 211 | | // cache anonymous user info for a long period if the |
| 212 | | // user has requested to be remembered |
| 213 | | if (u.is_anonymous && f && f.bakecookie && f.bakecookie.checked) |
| 214 | | cache_period = 365 * 24 * 60 * 60 * 1000; |
| 215 | | |
| 216 | | var now = new Date(); |
| 217 | | mtFixDate(now); |
| 218 | | now.setTime(now.getTime() + cache_period); |
| 219 | | |
| 220 | | var cmtcookie = mtBakeUserCookie(u); |
| 221 | | mtSetCookie(mtCookieName, cmtcookie, now, mtCookiePath, mtCookieDomain, |
| 222 | | location.protocol == 'https:'); |
| 223 | | } |
| 224 | | |
| 225 | | <mt:Ignore> |
| 226 | | /*** |