| 1 | <cfprocessingdirective pageencoding="utf-8" /> |
|---|
| 2 | |
|---|
| 3 | <cfsetting enablecfoutputonly=true> |
|---|
| 4 | <!--- |
|---|
| 5 | Name : C:\projects\blogcfc5\client\xmlrpc\xmlrpc.cfm |
|---|
| 6 | Author : Raymond Camden |
|---|
| 7 | Created : 09/15/06 |
|---|
| 8 | Last Updated : 4/13/07 |
|---|
| 9 | History : Scott Pinkstonadded newMediaObject |
|---|
| 10 | : fix for categories (rkc 10/12/06) |
|---|
| 11 | : multiple udpates related to Captivate (rkc 10/31/06) |
|---|
| 12 | : Another fix. Did someone say XML-RPC was a spec? Bull-pucky. (rkc 11/30/06) |
|---|
| 13 | : Fix so remote clients can see unreleased/future entries |
|---|
| 14 | ---> |
|---|
| 15 | |
|---|
| 16 | <cfif not isdefined("application.movabletype")> |
|---|
| 17 | <cfset application.movabletype=structNew()> |
|---|
| 18 | </cfif> |
|---|
| 19 | |
|---|
| 20 | <!---// should we escape/unescape <code> blocks from/to Text and HTML //---> |
|---|
| 21 | <cfparam name="url.parseMarkup" default="false" type="boolean" /> |
|---|
| 22 | |
|---|
| 23 | <cffunction name="translateCategory" returnType="uuid"> |
|---|
| 24 | <cfargument name="category" type="string" required="true"> |
|---|
| 25 | |
|---|
| 26 | <cfreturn application.blog.getCategoryByName(arguments.category)> |
|---|
| 27 | </cffunction> |
|---|
| 28 | |
|---|
| 29 | <cfset xmlrpc = createObject("component", "xmlrpc")> |
|---|
| 30 | |
|---|
| 31 | <cfif not len(getHTTPRequestData().content)> |
|---|
| 32 | <!--- no content sent ---> |
|---|
| 33 | <cfabort> |
|---|
| 34 | </cfif> |
|---|
| 35 | |
|---|
| 36 | <cfset requestData = xmlrpc.xmlrpc2cfml(getHTTPRequestData().content)> |
|---|
| 37 | |
|---|
| 38 | <cfset result = ""> |
|---|
| 39 | <cfset type = "responsefault"> |
|---|
| 40 | |
|---|
| 41 | <cfswitch expression="#requestData.method#"> |
|---|
| 42 | |
|---|
| 43 | <cfcase value="blogger.getUsersBlogs,metaWeblog.getUsersBlogs"> |
|---|
| 44 | <cfset info = structNew()> |
|---|
| 45 | <cfset info["url"] = application.rooturl> |
|---|
| 46 | <cfset info["blogid"] = "$string" & "1"> |
|---|
| 47 | <cfset info["blogName"] = application.blog.getProperty("name")> |
|---|
| 48 | <cfset result = arrayNew(1)> |
|---|
| 49 | <cfset result[1] = info> |
|---|
| 50 | |
|---|
| 51 | <cfset type="response"> |
|---|
| 52 | </cfcase> |
|---|
| 53 | |
|---|
| 54 | <cfcase value="metaWeblog.getCategories,mt.getCategoryList"> |
|---|
| 55 | |
|---|
| 56 | <cfset isMovabletype = requestData.method is "mt.getCategoryList"> |
|---|
| 57 | |
|---|
| 58 | <cfset appkey = requestData.params[1]> |
|---|
| 59 | <cfset username = requestData.params[2]> |
|---|
| 60 | <cfset password = requestData.params[3]> |
|---|
| 61 | |
|---|
| 62 | <cfset StructInsert(application.movabletype,username,isMovabletype,true)> |
|---|
| 63 | |
|---|
| 64 | <cfif application.blog.authenticate(username,password)> |
|---|
| 65 | <!--- This remote method isn't secured, so no need for |
|---|
| 66 | cflogin, but I still do the auth check above to |
|---|
| 67 | ensure only proper remote clients call this. |
|---|
| 68 | ---> |
|---|
| 69 | |
|---|
| 70 | <cfset result = arrayNew(1)> |
|---|
| 71 | |
|---|
| 72 | <cfset categories = application.blog.getCategories()> |
|---|
| 73 | |
|---|
| 74 | <cfloop query="categories"> |
|---|
| 75 | <cfset info = structNew()> |
|---|
| 76 | |
|---|
| 77 | <cfif requestData.method is "metaWeblog.getCategories"> |
|---|
| 78 | <cfset info["description"] = categoryname> |
|---|
| 79 | <cfset info["htmlUrl"] = "$string" & application.blog.makeCategoryLink(categoryid)> |
|---|
| 80 | <cfset info["rssUrl"] = "$string" & "#application.rootURL#/rss.cfm?mode=full&mode2=cat&catid=#categoryid#"> |
|---|
| 81 | |
|---|
| 82 | <cfset info["title"] = categoryname> |
|---|
| 83 | <!--- Added to make it work in Mars Edit ---> |
|---|
| 84 | <cfset info["categoryName"] = categoryname> |
|---|
| 85 | <cfset info["categoryid"] = categoryid> |
|---|
| 86 | <cfelse> |
|---|
| 87 | <cfset info["categoryName"] = categoryname> |
|---|
| 88 | <cfset info["categoryId"] = categoryid> |
|---|
| 89 | </cfif> |
|---|
| 90 | <cfset arrayAppend(result, info)> |
|---|
| 91 | </cfloop> |
|---|
| 92 | |
|---|
| 93 | <cfset type="response"> |
|---|
| 94 | |
|---|
| 95 | </cfif> |
|---|
| 96 | |
|---|
| 97 | </cfcase> |
|---|
| 98 | |
|---|
| 99 | <cfcase value="metaWeblog.getRecentPosts"> |
|---|
| 100 | |
|---|
| 101 | <cfset appkey = requestData.params[1]> |
|---|
| 102 | <cfset username = requestData.params[2]> |
|---|
| 103 | <cfset password = requestData.params[3]> |
|---|
| 104 | |
|---|
| 105 | <cfif application.blog.authenticate(username,password)> |
|---|
| 106 | <!--- This remote method isn't secured, so no need for |
|---|
| 107 | cflogin, but I still do the auth check above to |
|---|
| 108 | ensure only proper remote clients call this. |
|---|
| 109 | |
|---|
| 110 | Actually I lie. Sim noted that you won't get unreleased entries w/o this. |
|---|
| 111 | ---> |
|---|
| 112 | <cfloginuser name="#username#" password="#password#" roles="admin"> |
|---|
| 113 | |
|---|
| 114 | <cfset params = structNew()> |
|---|
| 115 | <cfset params.maxEntries = requestData.params[4]> |
|---|
| 116 | <cfset entries = application.blog.getEntries(params)> |
|---|
| 117 | <cfset entries = entries.entries /> |
|---|
| 118 | <cfset result = arrayNew(1)> |
|---|
| 119 | <cfloop query="entries"> |
|---|
| 120 | <cfset item = structNew()> |
|---|
| 121 | <cfset item["title"] = title> |
|---|
| 122 | <cfset item["dateCreated"] = posted> |
|---|
| 123 | <cfset item["userid"] = name> |
|---|
| 124 | <cfset item["postid"] = id> |
|---|
| 125 | <cfset item["description"] = body> |
|---|
| 126 | |
|---|
| 127 | <cfset item["link"] = application.blog.makeLink(id)> |
|---|
| 128 | <cfset item["permaLink"] = application.blog.makeLink(id)> |
|---|
| 129 | <cfset item["mt_excerpt"] = ""> |
|---|
| 130 | <cfset item["mt_text_more"]=""> |
|---|
| 131 | |
|---|
| 132 | <!--- Handle morebody ---> |
|---|
| 133 | <cfif len(morebody)> |
|---|
| 134 | <cfif structKeyExists(application.movabletype, username) and structFind(application.movabletype, username) is "NO"> |
|---|
| 135 | <cfset item["description"] = body & "<more/>" & morebody> |
|---|
| 136 | <cfelse> |
|---|
| 137 | <cfset item["mt_text_more"] = morebody> |
|---|
| 138 | </cfif> |
|---|
| 139 | </cfif> |
|---|
| 140 | |
|---|
| 141 | <cfif url.parseMarkup> |
|---|
| 142 | <cfset item["description"] = xmlrpc.escapeMarkup(item["description"]) /> |
|---|
| 143 | <cfset item["mt_text_more"] = xmlrpc.escapeMarkup(item["mt_text_more"]) /> |
|---|
| 144 | </cfif> |
|---|
| 145 | |
|---|
| 146 | <cfif allowcomments> |
|---|
| 147 | <cfset item["mt_allow_comments"] = "$int1"> |
|---|
| 148 | <cfelse> |
|---|
| 149 | <cfset item["mt_allow_comments"] = "$int0"> |
|---|
| 150 | </cfif> |
|---|
| 151 | <cfset item["mt_allow_pings"] = "$int1"> |
|---|
| 152 | <cfset item["mt_convert_breaks"] = "__default__"> |
|---|
| 153 | <cfset item["mt_keywords"] = ""> |
|---|
| 154 | |
|---|
| 155 | <cfset item["categories"] = arrayNew(1)> |
|---|
| 156 | <cfloop item="catid" collection="#categories#"> |
|---|
| 157 | <cfset arrayAppend(item["categories"], categories[currentRow][catid])> |
|---|
| 158 | </cfloop> |
|---|
| 159 | |
|---|
| 160 | <cfset arrayAppend(result,item)> |
|---|
| 161 | </cfloop> |
|---|
| 162 | |
|---|
| 163 | <cfset type="response"> |
|---|
| 164 | |
|---|
| 165 | </cfif> |
|---|
| 166 | |
|---|
| 167 | </cfcase> |
|---|
| 168 | |
|---|
| 169 | <cfcase value="metaWeblog.getPost"> |
|---|
| 170 | <cfset id = requestData.params[1]> |
|---|
| 171 | <cfset username = requestData.params[2]> |
|---|
| 172 | <cfset password = requestData.params[3]> |
|---|
| 173 | |
|---|
| 174 | <cfif application.blog.authenticate(username,password)> |
|---|
| 175 | <!--- This remote method isn't secured, so no need for |
|---|
| 176 | cflogin, but I still do the auth check above to |
|---|
| 177 | ensure only proper remote clients call this. |
|---|
| 178 | |
|---|
| 179 | Actually I lie. Sim noted that you won't get unreleased entries w/o this. |
|---|
| 180 | ---> |
|---|
| 181 | <cfloginuser name="#username#" password="#password#" roles="admin"> |
|---|
| 182 | |
|---|
| 183 | <!--- This remote method isn't secured, so no need for |
|---|
| 184 | cflogin, but I still do the auth check above to |
|---|
| 185 | ensure only proper remote clients call this. |
|---|
| 186 | ---> |
|---|
| 187 | <cfset entry = application.blog.getEntry(id,true)> |
|---|
| 188 | <cfset item = structNew()> |
|---|
| 189 | <cfset item["title"] = entry.title> |
|---|
| 190 | <cfset item["dateCreated"] = entry.posted> |
|---|
| 191 | <cfset item["userid"] = entry.name> |
|---|
| 192 | <cfset item["postid"] = entry.id> |
|---|
| 193 | <cfset item["description"] = entry.body /> |
|---|
| 194 | |
|---|
| 195 | <cfset item["link"] = application.blog.makeLink(id)> |
|---|
| 196 | <cfset item["permaLink"] = application.blog.makeLink(id)> |
|---|
| 197 | <cfset item["mt_excerpt"] = ""> |
|---|
| 198 | <cfset item["mt_text_more"] = ""> |
|---|
| 199 | |
|---|
| 200 | <cfif len(entry.morebody)> |
|---|
| 201 | <cfif structKeyExists(application.movabletype, username) and structFind(application.movabletype, username) IS "NO"> |
|---|
| 202 | <cfset item["description"] = entry.body & "<more/>" & entry.morebody> |
|---|
| 203 | <cfelse> |
|---|
| 204 | <cfset item["mt_text_more"]=entry.morebody> |
|---|
| 205 | </cfif> |
|---|
| 206 | </cfif> |
|---|
| 207 | |
|---|
| 208 | <cfif url.parseMarkup> |
|---|
| 209 | <cfset item["description"] = xmlrpc.escapeMarkup(item["description"]) /> |
|---|
| 210 | <cfset item["mt_text_more"] = xmlrpc.escapeMarkup(item["mt_text_more"]) /> |
|---|
| 211 | </cfif> |
|---|
| 212 | |
|---|
| 213 | <cfif entry.allowcomments> |
|---|
| 214 | <cfset item["mt_allow_comments"] = "$int1"> |
|---|
| 215 | <cfelse> |
|---|
| 216 | <cfset item["mt_allow_comments"] = "$int0"> |
|---|
| 217 | </cfif> |
|---|
| 218 | <cfset item["mt_allow_pings"] = "$int1"> |
|---|
| 219 | <cfset item["mt_convert_breaks"] = "__default__"> |
|---|
| 220 | <cfset item["mt_keywords"] = ""> |
|---|
| 221 | <cfset item["categories"] = ArrayNew(1)> |
|---|
| 222 | |
|---|
| 223 | <cfloop item="c" collection="#entry.categories#"> |
|---|
| 224 | <!--- <cfset item["categories"] = listAppend(item["categories"], entry.categories[c])> ---> |
|---|
| 225 | <cfset ArrayAppend(item["categories"],entry.categories[c])> |
|---|
| 226 | </cfloop> |
|---|
| 227 | |
|---|
| 228 | <cfset result = item> |
|---|
| 229 | <cfset type="response"> |
|---|
| 230 | </cfif> |
|---|
| 231 | |
|---|
| 232 | </cfcase> |
|---|
| 233 | |
|---|
| 234 | <cfcase value="blogger.deletePost"> |
|---|
| 235 | <cfset appkey = requestData.params[1]> |
|---|
| 236 | <cfset postid = requestData.params[2]> |
|---|
| 237 | <cfset username = requestData.params[3]> |
|---|
| 238 | <cfset password = requestData.params[4]> |
|---|
| 239 | <cfset publish = requestData.params[5]> |
|---|
| 240 | |
|---|
| 241 | <cfif application.blog.authenticate(username,password)> |
|---|
| 242 | <cfloginuser name="#username#" password="#password#" roles="admin"> |
|---|
| 243 | <cfset application.blog.deleteEntry(postid)> |
|---|
| 244 | <cfset result = "$boolean1"> |
|---|
| 245 | <cfelse> |
|---|
| 246 | <cfset result = "$boolean0"> |
|---|
| 247 | </cfif> |
|---|
| 248 | |
|---|
| 249 | <!--- clear cache ---> |
|---|
| 250 | <cfmodule template="../tags/scopecache.cfm" scope="application" clearall="true"> |
|---|
| 251 | |
|---|
| 252 | <cfset type="response"> |
|---|
| 253 | |
|---|
| 254 | </cfcase> |
|---|
| 255 | |
|---|
| 256 | <cfcase value="metaWeblog.newPost,metaWeblog.editPost"> |
|---|
| 257 | <cfif requestData.method is "metaWeblog.editPost"> |
|---|
| 258 | <cfset currentID = requestData.params[1]> |
|---|
| 259 | <cfelse> |
|---|
| 260 | <cfset appkey = requestData.params[1]> |
|---|
| 261 | </cfif> |
|---|
| 262 | <cfset username = requestData.params[2]> |
|---|
| 263 | <cfset password = requestData.params[3]> |
|---|
| 264 | <cfset bareentry = requestData.params[4]> |
|---|
| 265 | <cfset published = requestData.params[5]> |
|---|
| 266 | |
|---|
| 267 | <!--- This remote method isn't secured, so no need for |
|---|
| 268 | cflogin, but I still do the auth check above to |
|---|
| 269 | ensure only proper remote clients call this. |
|---|
| 270 | |
|---|
| 271 | Actually I lie. Sim noted that you won't get unreleased entries w/o this. |
|---|
| 272 | ---> |
|---|
| 273 | <cfloginuser name="#username#" password="#password#" roles="admin"> |
|---|
| 274 | |
|---|
| 275 | <!---// get existing entry or create empty structure //---> |
|---|
| 276 | <cfif structKeyExists(variables, "currentId")> |
|---|
| 277 | <cfset currentEntry = application.blog.getEntry(currentID, true) /> |
|---|
| 278 | <cfelse> |
|---|
| 279 | <!---// create default values for any of the fields we might need to reference //---> |
|---|
| 280 | <cfset currentEntry = structNew() /> |
|---|
| 281 | <cfset currentEntry.enclosure = "" /> |
|---|
| 282 | <cfset currentEntry.filesize = "0" /> |
|---|
| 283 | <cfset currentEntry.mimetype = "" /> |
|---|
| 284 | <cfset currentEntry.released = true /> |
|---|
| 285 | </cfif> |
|---|
| 286 | |
|---|
| 287 | <!--- |
|---|
| 288 | Convert the remote keys to keys blog understands. |
|---|
| 289 | ---> |
|---|
| 290 | <cfset entry = structNew()> |
|---|
| 291 | <cfset entry.title = bareentry.title> |
|---|
| 292 | <cfset entry.body = bareentry.description> |
|---|
| 293 | <cfset application.body = htmleditformat(bareentry.description)> |
|---|
| 294 | <!--- TODO: Handle <more/> ---> |
|---|
| 295 | |
|---|
| 296 | <!---// replace the ellipse character with the HTML entity //---> |
|---|
| 297 | <cfset entry.body = replace(entry.body, chr(8230), "&##8230;", "all") /> |
|---|
| 298 | <!---// replace the em dash character with the HTML entity //---> |
|---|
| 299 | <cfset entry.body = replace(entry.body, chr(8212), "&##8212;", "all") /> |
|---|
| 300 | <cfset entry.body = replace(entry.body, chr(151), "&##8212;", "all") /> |
|---|
| 301 | <cfset entry.body = replace(entry.body, "", "&##8212;", "all") /> |
|---|
| 302 | |
|---|
| 303 | <cfif url.parseMarkup> |
|---|
| 304 | <cfset entry.body = xmlrpc.unescapeMarkup(entry.body) /> |
|---|
| 305 | </cfif> |
|---|
| 306 | |
|---|
| 307 | <cfif structKeyExists(application.movabletype, username) and structFind(application.movabletype, username) IS "NO"> |
|---|
| 308 | <!--- Handle potential <more/> ---> |
|---|
| 309 | <!--- fix by Andrew ---> |
|---|
| 310 | <cfset strMoreTag = "<more/>"> |
|---|
| 311 | <cfset moreStart = findNoCase(strMoreTag,entry.body)> |
|---|
| 312 | <cfif moreStart gt 1> |
|---|
| 313 | <cfset moreText = trim(mid(entry.body,(moreStart+len(strMoreTag)),len(entry.body)))> |
|---|
| 314 | <cfset entry.body = trim(left(entry.body,moreStart-1))> |
|---|
| 315 | <cfelse> |
|---|
| 316 | <cfset moreText = ""> |
|---|
| 317 | </cfif> |
|---|
| 318 | |
|---|
| 319 | <cfset entry.morebody = moretext> |
|---|
| 320 | <cfelse> |
|---|
| 321 | <!--- Movabletype ---> |
|---|
| 322 | <cfif structKeyExists(bareentry, "mt_text_more")> |
|---|
| 323 | <cfset entry.morebody=bareentry.mt_text_more> |
|---|
| 324 | </cfif> |
|---|
| 325 | </cfif> |
|---|
| 326 | |
|---|
| 327 | <cfif structKeyExists(bareentry, "dateCreated")> |
|---|
| 328 | <cfset entry.posted = bareentry.dateCreated> |
|---|
| 329 | <cfelseif structKeyExists(bareentry, "pubDate") and isDate(bareentry.pubDate)> |
|---|
| 330 | <cfset entry.posted = bareentry.pubDate> |
|---|
| 331 | <cfelse> |
|---|
| 332 | <!---// only change the post date if the post date was requested to be changed //---> |
|---|
| 333 | <cfif requestData.method eq "metaWeblog.newPost"> |
|---|
| 334 | <cfset entry.posted = now() /> |
|---|
| 335 | </cfif> |
|---|
| 336 | </cfif> |
|---|
| 337 | |
|---|
| 338 | <!---// if posted date is in the past, but we've just published the article, update posted date //---> |
|---|
| 339 | <cfif not currentEntry.released and published> |
|---|
| 340 | <cfif not structKeyExists(entry, "posted") or (dateCompare(entry.posted, now()) lt 0)> |
|---|
| 341 | <cfset entry.posted = now() /> |
|---|
| 342 | </cfif> |
|---|
| 343 | </cfif> |
|---|
| 344 | |
|---|
| 345 | <!--- TODO: Fix allowcomments ---> |
|---|
| 346 | <cfif structKeyExists(bareentry,"mt_allow_comments") and isBoolean(bareentry.mt_allow_comments)> |
|---|
| 347 | <cfset entry.allowcomments = bareentry.mt_allow_comments> |
|---|
| 348 | <cfelse> |
|---|
| 349 | <cfset entry.allowcomments = true> |
|---|
| 350 | </cfif> |
|---|
| 351 | |
|---|
| 352 | <!--- TODO: Allow enclosures -- currently keeps previous values ---> |
|---|
| 353 | <cfset entry.enclosure = currentEntry.enclosure /> |
|---|
| 354 | <cfset entry.filesize = currentEntry.filesize /> |
|---|
| 355 | <cfset entry.mimetype = currentEntry.mimetype /> |
|---|
| 356 | <cfset entry.released = published /> |
|---|
| 357 | |
|---|
| 358 | <!--- |
|---|
| 359 | Contribute sends a fake post to generate a design template. |
|---|
| 360 | We need to ensure that this fake post doesn't send an email. |
|---|
| 361 | Let's try making it not released and see if that works. |
|---|
| 362 | |
|---|
| 363 | Nope, that didn't work. Ok, adding a new "sendemail" entry. |
|---|
| 364 | ---> |
|---|
| 365 | <cfif entry.title is "####TITLE####" and entry.body is "####CONTENT####"> |
|---|
| 366 | <cfset entry.sendemail = true> |
|---|
| 367 | </cfif> |
|---|
| 368 | |
|---|
| 369 | <cfif application.blog.authenticate(username, password)> |
|---|
| 370 | |
|---|
| 371 | <cfloginuser name="#username#" password="#password#" roles="admin"> |
|---|
| 372 | |
|---|
| 373 | <cfif requestData.method is "metaWeblog.editPost"> |
|---|
| 374 | <cfinvoke component="#application.blog#" method="saveEntry" returnVariable="newid"> |
|---|
| 375 | <cfinvokeargument name="id" value="#currentID#"> |
|---|
| 376 | <cfloop item="key" collection="#entry#"> |
|---|
| 377 | <cfinvokeargument name="#key#" value="#entry[key]#"> |
|---|
| 378 | </cfloop> |
|---|
| 379 | </cfinvoke> |
|---|
| 380 | <cfset entryid = currentID> |
|---|
| 381 | <cfset result = "$boolean1"> |
|---|
| 382 | <cfelse> |
|---|
| 383 | <cfset entry.alias = application.blog.makeTitle(entry.title)> |
|---|
| 384 | |
|---|
| 385 | <cfinvoke component="#application.blog#" method="addEntry" returnVariable="newid"> |
|---|
| 386 | <cfloop item="key" collection="#entry#"> |
|---|
| 387 | <cfinvokeargument name="#key#" value="#entry[key]#"> |
|---|
| 388 | </cfloop> |
|---|
| 389 | </cfinvoke> |
|---|
| 390 | <cfset entryid = newid> |
|---|
| 391 | <cfset result = newid> |
|---|
| 392 | </cfif> |
|---|
| 393 | |
|---|
| 394 | |
|---|
| 395 | <cfset catlist = ""> |
|---|
| 396 | <cfif structKeyExists(bareentry, "categories")> |
|---|
| 397 | <cfloop index="x" from="1" to="#arrayLen(bareentry.categories)#"> |
|---|
| 398 | <cfset catid = translateCategory(bareentry.categories[x])> |
|---|
| 399 | <cfset catlist = listAppend(catlist, catid)> |
|---|
| 400 | </cfloop> |
|---|
| 401 | <cfelseif structKeyExists(bareentry, "category") and len(bareentry.category)> |
|---|
| 402 | <cfset catid = translateCategory(bareentry.category)> |
|---|
| 403 | <cfset catlist = listAppend(catlist, catid)> |
|---|
| 404 | </cfif> |
|---|
| 405 | |
|---|
| 406 | <cfif len(catlist)> |
|---|
| 407 | <cfset application.blog.assignCategories(entryid, catlist)> |
|---|
| 408 | </cfif> |
|---|
| 409 | |
|---|
| 410 | <!--- clear cache ---> |
|---|
| 411 | <cfmodule template="../tags/scopecache.cfm" scope="application" clearall="true"> |
|---|
| 412 | |
|---|
| 413 | <cfset type="response"> |
|---|
| 414 | |
|---|
| 415 | <cfelse> |
|---|
| 416 | |
|---|
| 417 | </cfif> |
|---|
| 418 | |
|---|
| 419 | </cfcase> |
|---|
| 420 | |
|---|
| 421 | <cfcase value="metaWeblog.newMediaObject"> |
|---|
| 422 | <cfset username = requestData.params[2]> |
|---|
| 423 | <cfset password = requestData.params[3]> |
|---|
| 424 | |
|---|
| 425 | <cfif application.blog.authenticate(username,password)> |
|---|
| 426 | |
|---|
| 427 | <cfset upFileData = requestData.params[4].bits> |
|---|
| 428 | <cfset upFileName = listlast(requestData.params[4].name, "/")> |
|---|
| 429 | <cfset upFileType = requestData.params[4].type> |
|---|
| 430 | |
|---|
| 431 | <cfset destination = expandPath("../enclosures")> |
|---|
| 432 | |
|---|
| 433 | <cfif not directoryExists(destination)> |
|---|
| 434 | <cfdirectory action="create" directory="#destination#"> |
|---|
| 435 | </cfif> |
|---|
| 436 | |
|---|
| 437 | <cffile action="write" output="#upFileData#" file="#destination#/#upFileName#" nameconflict="makeunique"> |
|---|
| 438 | |
|---|
| 439 | <cfset result = structNew()> |
|---|
| 440 | <cfset result["url"] = "$string" & "#application.rootURL#/enclosures/#upFileName#"> |
|---|
| 441 | |
|---|
| 442 | <cfelse> |
|---|
| 443 | |
|---|
| 444 | <cfset result = "$boolean0"> |
|---|
| 445 | |
|---|
| 446 | </cfif> |
|---|
| 447 | |
|---|
| 448 | <cfset type="response"> |
|---|
| 449 | |
|---|
| 450 | </cfcase> |
|---|
| 451 | |
|---|
| 452 | <cfcase value="mt.getPostCategories"> |
|---|
| 453 | |
|---|
| 454 | <cfset postid = requestData.params[1]> |
|---|
| 455 | <cfset username = requestData.params[2]> |
|---|
| 456 | <cfset password = requestData.params[3]> |
|---|
| 457 | |
|---|
| 458 | <cfif application.blog.authenticate(username,password)> |
|---|
| 459 | <!--- This remote method isn't secured, so no need for |
|---|
| 460 | cflogin, but I still do the auth check above to |
|---|
| 461 | ensure only proper remote clients call this. |
|---|
| 462 | ---> |
|---|
| 463 | |
|---|
| 464 | <cfset result = arrayNew(1)> |
|---|
| 465 | |
|---|
| 466 | <cfset categories = application.blog.getCategoriesForEntry(id=postid)> |
|---|
| 467 | |
|---|
| 468 | <cfloop query="categories"> |
|---|
| 469 | <cfset info = structNew()> |
|---|
| 470 | <cfset info["categoryName"] = categoryname> |
|---|
| 471 | <cfset info["categoryId"] = categoryid> |
|---|
| 472 | <cfset arrayAppend(result, info)> |
|---|
| 473 | </cfloop> |
|---|
| 474 | |
|---|
| 475 | <cfset type="response"> |
|---|
| 476 | |
|---|
| 477 | </cfif> |
|---|
| 478 | |
|---|
| 479 | </cfcase> |
|---|
| 480 | |
|---|
| 481 | <cfcase value="mt.setPostCategories"> |
|---|
| 482 | |
|---|
| 483 | <cfset postid = requestData.params[1]> |
|---|
| 484 | <cfset username = requestData.params[2]> |
|---|
| 485 | <cfset password = requestData.params[3]> |
|---|
| 486 | |
|---|
| 487 | <cfif application.blog.authenticate(username,password)> |
|---|
| 488 | |
|---|
| 489 | <cfloginuser name="#username#" password="#password#" roles="admin"> |
|---|
| 490 | |
|---|
| 491 | <cfif arrayLen(requestData.params) gte 4> |
|---|
| 492 | |
|---|
| 493 | <cfset application.blog.removeCategories(postid)> |
|---|
| 494 | <cfset catlist = ""> |
|---|
| 495 | <cfloop index="x" from="1" to="#arrayLen(requestData.params[4])#"> |
|---|
| 496 | <cfset catlist = listAppend(catlist, requestData.params[4][x].categoryID)> |
|---|
| 497 | </cfloop> |
|---|
| 498 | <cfset application.blog.assignCategories(postid, catlist)> |
|---|
| 499 | |
|---|
| 500 | <cfset result = "$boolean1"> |
|---|
| 501 | |
|---|
| 502 | <cfset type="response"> |
|---|
| 503 | |
|---|
| 504 | </cfif> |
|---|
| 505 | </cfif> |
|---|
| 506 | |
|---|
| 507 | </cfcase> |
|---|
| 508 | |
|---|
| 509 | </cfswitch> |
|---|
| 510 | |
|---|
| 511 | <cfset pResult = arrayNew(1)> |
|---|
| 512 | <cfset pResult[1] = result> |
|---|
| 513 | <cfset resultData = xmlrpc.cfml2xmlrpc(data=pResult,type=type)> |
|---|
| 514 | |
|---|
| 515 | |
|---|
| 516 | |
|---|
| 517 | <cfcontent type="text/xml; charset=utf-8"><cfoutput><?xml version="1.0" encoding="ISO-8859-1"?>#resultData#</cfoutput> |
|---|