Compare commits
2 Commits
PARTYTOOL1
...
SQL_ADDON_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bedeb61a8 | ||
|
|
e93cddc998 |
19
mozilla/extensions/sql/Makefile.in
Normal file
19
mozilla/extensions/sql/Makefile.in
Normal file
@@ -0,0 +1,19 @@
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = \
|
||||
base \
|
||||
pgsql \
|
||||
build
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += \
|
||||
sqltest \
|
||||
tests
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
11
mozilla/extensions/sql/base/Makefile.in
Normal file
11
mozilla/extensions/sql/base/Makefile.in
Normal file
@@ -0,0 +1,11 @@
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
DIRS = \
|
||||
public \
|
||||
src \
|
||||
resources
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
19
mozilla/extensions/sql/base/public/Makefile.in
Normal file
19
mozilla/extensions/sql/base/public/Makefile.in
Normal file
@@ -0,0 +1,19 @@
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
MODULE = sql
|
||||
|
||||
XPIDLSRCS = \
|
||||
mozISqlConnection.idl \
|
||||
mozISqlRequest.idl \
|
||||
mozISqlDataSource.idl \
|
||||
mozISqlInputStream.idl \
|
||||
mozISqlRequestObserver.idl \
|
||||
mozISqlResult.idl \
|
||||
mozISqlResultEnumerator.idl \
|
||||
mozISqlService.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
124
mozilla/extensions/sql/base/public/mozISqlConnection.idl
Normal file
124
mozilla/extensions/sql/base/public/mozISqlConnection.idl
Normal file
@@ -0,0 +1,124 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jan Varga <varga@utcru.sk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface mozISqlResult;
|
||||
interface mozISqlRequest;
|
||||
interface mozISqlRequestObserver;
|
||||
|
||||
/**
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
|
||||
[scriptable, uuid(f16397a4-1ecb-4e08-84f8-27750c04b779)]
|
||||
interface mozISqlConnection : nsISupports
|
||||
{
|
||||
|
||||
readonly attribute AString serverVersion;
|
||||
|
||||
/**
|
||||
* The most recent error message.
|
||||
*/
|
||||
readonly attribute AString errorMessage;
|
||||
|
||||
/**
|
||||
* The ID of the most recently added record.
|
||||
*/
|
||||
readonly attribute long lastID;
|
||||
|
||||
/**
|
||||
* Set up the connection.
|
||||
*
|
||||
* @param aHost The host name.
|
||||
* @param aPort The port at which the host is listening.
|
||||
* @param aDatabase The real database name to connect to.
|
||||
* @param aUsername The username to connect as.
|
||||
* @param aPassword The password to use in authentification phase.
|
||||
*/
|
||||
void init(in AString aHost,
|
||||
in long aPort,
|
||||
in AString aDatabase,
|
||||
in AString aUsername,
|
||||
in AString aPassword);
|
||||
|
||||
/**
|
||||
* Execute the query synchronously and return database result.
|
||||
*
|
||||
* @param aQuery The query to execute.
|
||||
*/
|
||||
mozISqlResult executeQuery(in AString aQuery);
|
||||
|
||||
/**
|
||||
* Execute the update synchronously and return number of updated rows.
|
||||
*
|
||||
* @param aUpdate The update to execute.
|
||||
*/
|
||||
long executeUpdate(in AString aUpdate);
|
||||
|
||||
mozISqlRequest asyncExecuteQuery(in AString aQuery,
|
||||
in nsISupports aContext,
|
||||
in mozISqlRequestObserver aObserver);
|
||||
|
||||
mozISqlRequest asyncExecuteUpdate(in AString aQuery,
|
||||
in nsISUpports aContext,
|
||||
in mozISqlRequestObserver aObserver);
|
||||
|
||||
/**
|
||||
* Begin transaction.
|
||||
*/
|
||||
void beginTransaction();
|
||||
|
||||
/**
|
||||
* Commit transaction.
|
||||
*/
|
||||
void commitTransaction();
|
||||
|
||||
/**
|
||||
* Rollback transaction.
|
||||
*/
|
||||
void rollbackTransaction();
|
||||
|
||||
/**
|
||||
* Get primary keys.
|
||||
*
|
||||
* @param aSchema The schema.
|
||||
* @param aTable The table name.
|
||||
*/
|
||||
mozISqlResult getPrimaryKeys(in AString aSchema, in AString aTable);
|
||||
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@@ -12,14 +11,15 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jan Varga <varga@utcru.sk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -34,21 +34,32 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class HashComponent extends Object {
|
||||
|
||||
function password($pass, $data) {
|
||||
$string = $pass.uniqid(rand(), true).$data;
|
||||
$salt = substr(md5($string), 0, 9);
|
||||
$p = sha1($pass.$salt);
|
||||
$rv = array('pass' => $p, 'salt' => $salt);
|
||||
return $rv;
|
||||
}
|
||||
#include "nsISupports.idl"
|
||||
|
||||
function keygen($chars) {
|
||||
$key = null;
|
||||
$pool = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
for ($i = 0; $i < $chars; $i++)
|
||||
$key .= $pool{rand(0,61)};
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
interface nsIRDFResource;
|
||||
|
||||
/**
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
|
||||
[scriptable, uuid(3c0a954f-b595-46a4-932c-3660f55e2e10)]
|
||||
interface mozISqlDataSource : nsISupports
|
||||
{
|
||||
|
||||
/**
|
||||
* Retrieve the RDF resource associated with the specified row.
|
||||
*
|
||||
* @param aRowIndex The row index.
|
||||
*/
|
||||
|
||||
nsIRDFResource getResourceAtIndex(in long aRowIndex);
|
||||
|
||||
/**
|
||||
* Retrieve the index associated with specified RDF resource.
|
||||
*
|
||||
* @param aResource The resource.
|
||||
*/
|
||||
long getIndexOfResource(in nsIRDFResource aResource);
|
||||
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@@ -12,14 +11,15 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jan Varga <varga@utcru.sk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -34,14 +34,19 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
if (empty($_REQUEST['s']))
|
||||
die();
|
||||
|
||||
include('../../vendors/webServices.php');
|
||||
include('../../config/bootstrap.php');
|
||||
#include "nsISupports.idl"
|
||||
|
||||
$suggest = new webServices(array('type' => 'gsuggest'));
|
||||
$string = $suggest->GSuggest($_REQUEST['s']);
|
||||
header('Content-type: text/plain');
|
||||
echo $string;
|
||||
?>
|
||||
/**
|
||||
* @status UNDER_DEVELOPMENT
|
||||
*/
|
||||
|
||||
[scriptable, uuid(555f2485-ba82-4c5c-9dd2-d801104dc09e)]
|
||||
interface mozISqlInputStream : nsISupports
|
||||
{
|
||||
|
||||
AString getColumnHeader(in long aColumnIndex);
|
||||
|
||||
void setColumnHeader(in long aColumnIndex, in AString aLabel);
|
||||
|
||||
};
|
||||
66
mozilla/webtools/partytool/models/comment.php → mozilla/extensions/sql/base/public/mozISqlRequest.idl
Executable file → Normal file
66
mozilla/webtools/partytool/models/comment.php → mozilla/extensions/sql/base/public/mozISqlRequest.idl
Executable file → Normal file
@@ -1,4 +1,3 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@@ -12,14 +11,15 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jan Varga <varga@utcru.sk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -34,28 +34,44 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Comment extends AppModel {
|
||||
var $name = 'Comment';
|
||||
|
||||
var $validate = array(
|
||||
'text' => "/^\S/"
|
||||
);
|
||||
#include "nsISupports.idl"
|
||||
|
||||
function canComment($pid, $uid) {
|
||||
$status = $this->query('SELECT owner, guestcomments FROM parties WHERE id = '.$pid);
|
||||
$guest = null;
|
||||
if ($status[0]['parties']['owner'] != $uid)
|
||||
$guest = $this->query('SELECT uid FROM guests WHERE pid = '.$pid.' AND uid = '.$uid);
|
||||
interface mozISqlConnection;
|
||||
interface mozISqlRequestObserver;
|
||||
interface mozISqlResult;
|
||||
|
||||
if ($status[0]['parties']['guestcomments'] == 1) {
|
||||
if (!empty($guest[0]['guests']['uid']) || $uid == $status[0]['parties']['owner'])
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
[scriptable, uuid(f67cb817-5e07-49ff-aacc-5c80585c5031)]
|
||||
interface mozISqlRequest : nsISupports
|
||||
{
|
||||
readonly attribute AString errorMessage;
|
||||
|
||||
readonly attribute mozISqlResult result;
|
||||
|
||||
readonly attribute long affectedRows;
|
||||
|
||||
readonly attribute long lastID;
|
||||
|
||||
|
||||
readonly attribute AString query;
|
||||
|
||||
readonly attribute nsISupports ctxt;
|
||||
|
||||
readonly attribute mozISqlRequestObserver observer;
|
||||
|
||||
|
||||
const long STATUS_NONE = 0;
|
||||
const long STATUS_EXECUTED = 1;
|
||||
const long STATUS_COMPLETE = 2;
|
||||
const long STATUS_ERROR = 3;
|
||||
const long STATUS_CANCELLED = 4;
|
||||
|
||||
readonly attribute long status;
|
||||
|
||||
void cancel();
|
||||
|
||||
};
|
||||
39
mozilla/webtools/partytool/models/feed.php → mozilla/extensions/sql/base/public/mozISqlRequestObserver.idl
Executable file → Normal file
39
mozilla/webtools/partytool/models/feed.php → mozilla/extensions/sql/base/public/mozISqlRequestObserver.idl
Executable file → Normal file
@@ -1,4 +1,3 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@@ -12,14 +11,15 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jan Varga <varga@utcru.sk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -34,18 +34,23 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Feed extends AppModel {
|
||||
var $name = 'Feeds';
|
||||
var $useTable = "parties";
|
||||
|
||||
function getComments($aParty) {
|
||||
$rv = $this->query("SELECT * FROM comments WHERE assoc = ".$aParty." LIMIT 10");
|
||||
return $rv;
|
||||
}
|
||||
#include "nsISupports.idl"
|
||||
|
||||
function getUserCount() {
|
||||
$rv = $this->query("SELECT COUNT(*) FROM users");
|
||||
return $rv[0][0]['COUNT(*)'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
interface mozISqlRequest;
|
||||
|
||||
/**
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
|
||||
[scriptable, uuid(9e950bc0-e252-41ef-ac6f-3e3c4acd9dd8)]
|
||||
interface mozISqlRequestObserver : nsISupports
|
||||
{
|
||||
|
||||
void onStartRequest(in mozISqlRequest aRequest,
|
||||
in nsISupports aContext);
|
||||
|
||||
void onStopRequest(in mozISqlRequest aRequest,
|
||||
in nsISupports aContext);
|
||||
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@@ -12,14 +11,15 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jan Varga <varga@utcru.sk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -34,38 +34,54 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
uses('sanitize');
|
||||
|
||||
class CommentsController extends AppController {
|
||||
var $name = 'Comments';
|
||||
var $components = array('Security');
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface mozISqlConnection;
|
||||
interface mozISqlResultEnumerator;
|
||||
interface mozISqlInputStream;
|
||||
|
||||
/**
|
||||
* @status UNDER_DEVELOPMENT
|
||||
*/
|
||||
|
||||
[scriptable, uuid(08c220b0-7140-456a-89e9-c94609a7392d)]
|
||||
interface mozISqlResult : nsISupports
|
||||
{
|
||||
|
||||
readonly attribute mozISqlConnection connection;
|
||||
|
||||
readonly attribute AString query;
|
||||
|
||||
readonly attribute AString tableName;
|
||||
|
||||
readonly attribute long rowCount;
|
||||
|
||||
readonly attribute long columnCount;
|
||||
|
||||
AString getColumnName(in long aColumnIndex);
|
||||
|
||||
long getColumnIndex(in AString aColumnName);
|
||||
|
||||
const long TYPE_STRING = 1;
|
||||
const long TYPE_INT = 2;
|
||||
const long TYPE_FLOAT = 3;
|
||||
const long TYPE_DECIMAL = 4;
|
||||
const long TYPE_DATE = 5;
|
||||
const long TYPE_TIME = 6;
|
||||
const long TYPE_DATETIME = 7;
|
||||
const long TYPE_BOOL = 8;
|
||||
|
||||
function beforeFilter() {
|
||||
$this->Security->requirePost('add');
|
||||
}
|
||||
long getColumnType(in long aColumnIndex);
|
||||
|
||||
function add($pid, $uid) {
|
||||
if (!$this->Session->check('User') || $uid != $_SESSION['User']['id'])
|
||||
$this->redirect('/');
|
||||
AString getColumnTypeAsString(in long aColumnIndex);
|
||||
|
||||
if (!empty($this->data) && $this->Comment->canComment($pid, $uid)) {
|
||||
// Explictly destroy the last model to avoid an edit instead of an insert
|
||||
$this->Comment->create();
|
||||
long getColumnDisplaySize(in long aColumnIndex);
|
||||
|
||||
$clean = new Sanitize();
|
||||
$text = $clean->html($this->data['Comment']['text']);
|
||||
$this->data['Comment']['text'] = nl2br($text);
|
||||
$this->data['Comment']['owner'] = $uid;
|
||||
$this->data['Comment']['assoc'] = $pid;
|
||||
$this->data['Comment']['time'] = mktime();
|
||||
mozISqlResultEnumerator enumerate();
|
||||
|
||||
if ($this->Comment->save($this->data)) {
|
||||
$this->redirect('/parties/view/'.$pid.'#c'.$this->Comment->getLastInsertID());
|
||||
}
|
||||
}
|
||||
mozISqlInputStream open();
|
||||
|
||||
else
|
||||
$this->redirect('/parties/view/'.$pid);
|
||||
}
|
||||
}
|
||||
?>
|
||||
void reload();
|
||||
|
||||
};
|
||||
126
mozilla/extensions/sql/base/public/mozISqlResultEnumerator.idl
Normal file
126
mozilla/extensions/sql/base/public/mozISqlResultEnumerator.idl
Normal file
@@ -0,0 +1,126 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jan Varga <varga@utcru.sk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIVariant;
|
||||
|
||||
/**
|
||||
* @status UNDER_DEVELOPMENT
|
||||
*/
|
||||
|
||||
[scriptable, uuid(dcc0d29e-2b44-460e-b39f-89121ff8b963)]
|
||||
interface mozISqlResultEnumerator : nsISupports
|
||||
{
|
||||
|
||||
readonly attribute AString errorMessage;
|
||||
|
||||
boolean next();
|
||||
|
||||
boolean previous();
|
||||
|
||||
void beforeFirst();
|
||||
|
||||
void first();
|
||||
|
||||
void last();
|
||||
|
||||
void relative(in long aRows);
|
||||
|
||||
void absolute(in long aRowIndex);
|
||||
|
||||
|
||||
boolean isNull(in long aColumnIndex);
|
||||
|
||||
nsIVariant getVariant(in long aColumnIndex);
|
||||
|
||||
AString getString(in long aColumnIndex);
|
||||
|
||||
long getInt(in long aColumnIndex);
|
||||
|
||||
float getFloat(in long aColumnIndex);
|
||||
|
||||
float getDecimal(in long aColumnIndex);
|
||||
|
||||
long long getDate(in long aColumnIndex);
|
||||
|
||||
boolean getBool(in long aColumnIndex);
|
||||
|
||||
|
||||
void setNull(in long aColumnIndex);
|
||||
|
||||
void setDefault(in long aColumnIndex);
|
||||
|
||||
void copy(in long aColumnIndex);
|
||||
|
||||
void setVariant(in long aColumnIndex, in nsIVariant aValue);
|
||||
|
||||
void setString(in long aColumnIndex, in AString aValue);
|
||||
|
||||
void setInt(in long aColumnIndex, in long aValue);
|
||||
|
||||
void setFloat(in long aColumnIndex, in float aValue);
|
||||
|
||||
void setDecimal(in long aColumnIndex, in float aValue);
|
||||
|
||||
void setDate(in long aColumnIndex, in long long aValue);
|
||||
|
||||
void setBool(in long aColumnIndex, in boolean aValue);
|
||||
|
||||
|
||||
void setNullValues();
|
||||
|
||||
void setDefaultValues();
|
||||
|
||||
void copyValues();
|
||||
|
||||
|
||||
boolean canInsert();
|
||||
|
||||
boolean canUpdate();
|
||||
|
||||
boolean canDelete();
|
||||
|
||||
long insertRow();
|
||||
|
||||
long updateRow();
|
||||
|
||||
long deleteRow();
|
||||
|
||||
readonly attribute AString currentCondition;
|
||||
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@@ -12,14 +11,15 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jan Varga <varga@utcru.sk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -34,42 +34,48 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class UnicodeComponent extends Object {
|
||||
/**
|
||||
* Unicode utilities. Converts and encodes characters up to 0xFFFF (65535)
|
||||
*/
|
||||
function unicode2utf($char) {
|
||||
if ($char < 128) {
|
||||
$rv = chr($char);
|
||||
}
|
||||
|
||||
else if ($char < 2048) {
|
||||
$rv = chr(192 + (($char - ($char % 64)) / 64));
|
||||
$rv .= chr(128 + ($char % 64));
|
||||
}
|
||||
#include "nsISupports.idl"
|
||||
|
||||
else {
|
||||
$rv = chr(224 + (($char - ($char % 4096)) / 4096));
|
||||
$rv .= chr(128 + ((($char % 4096) - ($char % 64)) / 64));
|
||||
$rv .= chr(128 + ($char % 64));
|
||||
}
|
||||
interface mozISqlConnection;
|
||||
|
||||
return $rv;
|
||||
}
|
||||
/**
|
||||
* @status UNDER_DEVELOPMENT
|
||||
*/
|
||||
|
||||
function utf2unicode($char) {
|
||||
if (ord($char{0}) < 128)
|
||||
$rv = ord($char);
|
||||
[scriptable, uuid(1ceb35b7-daa8-4ce4-ac67-125fb17cb019)]
|
||||
interface mozISqlService : nsISupports
|
||||
{
|
||||
|
||||
else if (ord($char{0}) < 224)
|
||||
$rv = ((ord($char{0}) - 192) * 64) + (ord($char{1}) - 128);
|
||||
readonly attribute AString errorMessage;
|
||||
|
||||
else if (ord($char{0}) < 240)
|
||||
$rv = ((ord($char{0}) - 224) * 4096) + ((ord($char{1}) - 128) * 64 + (ord($char{2}) - 128));
|
||||
void addAlias(in ACString aURI,
|
||||
in AString aName,
|
||||
in AString aType,
|
||||
in AString aHostname,
|
||||
in long aPort,
|
||||
in AString aDatabase);
|
||||
|
||||
else
|
||||
$rv = ((ord($char{0}) - 240) * 262144) + ((ord($char{1}) - 128) * 4096) + ((ord($char{2}) - 128) * 64) + (ord($char{3}) - 128);
|
||||
boolean hasAlias(in ACString aURI);
|
||||
|
||||
return $rv;
|
||||
}
|
||||
}
|
||||
void getAlias(in ACString aURI,
|
||||
out AString aName,
|
||||
out AString aType,
|
||||
out AString aHostname,
|
||||
out long aPort,
|
||||
out AString aDatabase);
|
||||
|
||||
void updateAlias(in ACString aURI,
|
||||
in AString aName,
|
||||
in AString aType,
|
||||
in AString aHostname,
|
||||
in long aPort,
|
||||
in AString aDatabase);
|
||||
|
||||
void removeAlias(in ACString aURI);
|
||||
|
||||
mozISqlConnection getConnection(in ACString aURI);
|
||||
|
||||
mozISqlConnection getNewConnection(in ACString aURI);
|
||||
|
||||
};
|
||||
6
mozilla/extensions/sql/base/resources/Makefile.in
Normal file
6
mozilla/extensions/sql/base/resources/Makefile.in
Normal file
@@ -0,0 +1,6 @@
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
39
mozilla/extensions/sql/base/resources/content/aliasDialog.js
Normal file
39
mozilla/extensions/sql/base/resources/content/aliasDialog.js
Normal file
@@ -0,0 +1,39 @@
|
||||
var sqlService = null;
|
||||
|
||||
var name;
|
||||
var type;
|
||||
var hostname;
|
||||
var port;
|
||||
var database;
|
||||
|
||||
function init() {
|
||||
sqlService = Components.classes["@mozilla.org/sql/service;1"]
|
||||
.getService(Components.interfaces.mozISqlService);
|
||||
|
||||
name = document.getElementById("name");
|
||||
type = document.getElementById("type");
|
||||
hostname = document.getElementById("hostname");
|
||||
port = document.getElementById("port");
|
||||
database = document.getElementById("database");
|
||||
|
||||
if (window.arguments) {
|
||||
// get original values
|
||||
var uri = window.arguments[0];
|
||||
sqlService.getAlias(uri, name, type, hostname, port, database);
|
||||
}
|
||||
}
|
||||
|
||||
function onAccept() {
|
||||
if (window.arguments) {
|
||||
// update an existing alias
|
||||
var uri = window.arguments[0];
|
||||
sqlService.updateAlias(uri, name.value, type.value, hostname.value,
|
||||
port.value, database.value);
|
||||
}
|
||||
else {
|
||||
// add a new database
|
||||
var uri = "urn:aliases:" + name.value;
|
||||
sqlService.addAlias(uri, name.value, type.value, hostname.value,
|
||||
port.value, database.value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
|
||||
|
||||
<!DOCTYPE dialog SYSTEM "chrome://sql/locale/aliasDialog.dtd">
|
||||
|
||||
<dialog id="aliasDialog"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&window.title;"
|
||||
width="250" height="180"
|
||||
buttons="accept,cancel" buttonpack="center"
|
||||
ondialogaccept="return onAccept(event);"
|
||||
onload="init()">
|
||||
|
||||
<script type="application/x-javascript" src="aliasDialog.js"/>
|
||||
|
||||
<grid flex="1">
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="&name.label;"/>
|
||||
<textbox id="name"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="&type.label;"/>
|
||||
<textbox id="type"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="&hostname.label;"/>
|
||||
<textbox id="hostname"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="&port.label;"/>
|
||||
<textbox id="port"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="&database.label;"/>
|
||||
<textbox id="database"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
</dialog>
|
||||
21
mozilla/extensions/sql/base/resources/content/contents.rdf
Normal file
21
mozilla/extensions/sql/base/resources/content/contents.rdf
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
|
||||
|
||||
<!-- list all the packages being supplied by this jar -->
|
||||
<RDF:Seq about="urn:mozilla:package:root">
|
||||
<RDF:li resource="urn:mozilla:package:sql"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- package information -->
|
||||
<RDF:Description about="urn:mozilla:package:sql"
|
||||
chrome:displayName="SQL support"
|
||||
chrome:author="mozilla.org"
|
||||
chrome:authorURL="http://www.mozilla.org/projects/sql/index.html"
|
||||
chrome:name="sql"
|
||||
chrome:extension="true"
|
||||
chrome:settingsURL="chrome://sql/content/sqlSettings.xul"
|
||||
chrome:description="Allow applications to directly connect to SQL databases.">
|
||||
</RDF:Description>
|
||||
|
||||
</RDF:RDF>
|
||||
36
mozilla/extensions/sql/base/resources/content/sqlSettings.js
Normal file
36
mozilla/extensions/sql/base/resources/content/sqlSettings.js
Normal file
@@ -0,0 +1,36 @@
|
||||
var sqlService = null;
|
||||
|
||||
function getSqlService() {
|
||||
if (! sqlService)
|
||||
sqlService = Components.classes["@mozilla.org/sql/service;1"]
|
||||
.getService(Components.interfaces.mozISqlService);
|
||||
return sqlService;
|
||||
}
|
||||
|
||||
function getSelectedAlias() {
|
||||
var tree = document.getElementById("aliasesTree");
|
||||
return tree.builderView.getResourceAtIndex(tree.currentIndex).Value;
|
||||
}
|
||||
|
||||
function updateButtons() {
|
||||
var tree = document.getElementById("aliasesTree");
|
||||
const buttons = ["updateButton", "removeButton"];
|
||||
for (i = 0; i < buttons.length; i++)
|
||||
document.getElementById(buttons[i]).disabled = tree.currentIndex < 0;
|
||||
}
|
||||
|
||||
function addAlias() {
|
||||
window.openDialog("aliasDialog.xul", "addAlias", "chrome,modal=yes,resizable=no,centerscreen");
|
||||
}
|
||||
|
||||
function updateAlias() {
|
||||
var alias = getSelectedAlias();
|
||||
window.openDialog("aliasDialog.xul", "updateDatabase", "chrome,modal=yes,resizable=no,centerscreen", alias);
|
||||
}
|
||||
|
||||
function removeAlias() {
|
||||
var sqlService = getSqlService();
|
||||
var alias = getSelectedAlias();
|
||||
sqlService.removeAlias(alias);
|
||||
updateButtons();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
|
||||
<!DOCTYPE dialog SYSTEM "chrome://sql/locale/sqlSettings.dtd">
|
||||
|
||||
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&header.label;"
|
||||
width="450" height="350">
|
||||
|
||||
<script type="application/x-javascript" src="sqlSettings.js"/>
|
||||
|
||||
<groupbox flex="1">
|
||||
<caption label="&aliases.label;"/>
|
||||
<hbox flex="1">
|
||||
<tree id="aliasesTree" flex="1"
|
||||
seltype="single"
|
||||
datasources="rdf:sql" ref="SQL:AliasesRoot" flags="dont-build-content"
|
||||
onselect="updateButtons()">
|
||||
<treecols>
|
||||
<treecol id="nameCol" flex="1" label="&nameCol.label;"
|
||||
sort="rdf:http://www.mozilla.org/SQL-rdf#name"
|
||||
sortActive="true" sortDirection="ascending"/>
|
||||
<treecol id="typeCol" flex="1" label="&typeCol.label;"
|
||||
sort="rdf:http://www.mozilla.org/SQL-rdf#type"/>
|
||||
<treecol id="hostnameCol" flex="1" label="&hostnameCol.label;"
|
||||
sort="rdf:http://www.mozilla.org/SQL-rdf#hostname"/>
|
||||
<treecol id="portCol" flex="1" label="&portCol.label;"
|
||||
sort="rdf:http://www.mozilla.org/SQL-rdf#port"/>
|
||||
<treecol id="databaseCol" flex="1" label="&databaseCol.label;"
|
||||
sort="rdf:http://www.mozilla.org/SQL-rdf#database"/>
|
||||
</treecols>
|
||||
<template>
|
||||
<treechildren>
|
||||
<treeitem uri="rdf:*">
|
||||
<treerow>
|
||||
<treecell label="rdf:http://www.mozilla.org/SQL-rdf#name"/>
|
||||
<treecell label="rdf:http://www.mozilla.org/SQL-rdf#type"/>
|
||||
<treecell label="rdf:http://www.mozilla.org/SQL-rdf#hostname"/>
|
||||
<treecell label="rdf:http://www.mozilla.org/SQL-rdf#port"/>
|
||||
<treecell label="rdf:http://www.mozilla.org/SQL-rdf#database"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</template>
|
||||
</tree>
|
||||
<vbox>
|
||||
<button id="addButton" label="&add.label;" oncommand="addAlias()"/>
|
||||
<button id="updateButton" label="&update.label;" disabled="true" oncommand="updateAlias()"/>
|
||||
<button id="removeButton" label="&remove.label;" disabled="true" oncommand="removeAlias()"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
||||
</dialog>
|
||||
9
mozilla/extensions/sql/base/resources/jar.mn
Normal file
9
mozilla/extensions/sql/base/resources/jar.mn
Normal file
@@ -0,0 +1,9 @@
|
||||
sql.jar:
|
||||
content/sql/contents.rdf (content/contents.rdf)
|
||||
content/sql/sqlSettings.xul (content/sqlSettings.xul)
|
||||
content/sql/sqlSettings.js (content/sqlSettings.js)
|
||||
content/sql/aliasDialog.xul (content/aliasDialog.xul)
|
||||
content/sql/aliasDialog.js (content/aliasDialog.js)
|
||||
locale/en-US/sql/contents.rdf (locale/en-US/contents.rdf)
|
||||
locale/en-US/sql/sqlSettings.dtd (locale/en-US/sqlSettings.dtd)
|
||||
locale/en-US/sql/aliasDialog.dtd (locale/en-US/aliasDialog.dtd)
|
||||
@@ -0,0 +1,7 @@
|
||||
<!ENTITY window.title "Alias">
|
||||
|
||||
<!ENTITY name.label "Name:">
|
||||
<!ENTITY type.label "Type:">
|
||||
<!ENTITY hostname.label "Hostname:">
|
||||
<!ENTITY port.label "Port:">
|
||||
<!ENTITY database.label "Database:">
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
|
||||
|
||||
<!-- list all the locales being supplied by this package -->
|
||||
<RDF:Seq about="urn:mozilla:locale:root">
|
||||
<RDF:li resource="urn:mozilla:locale:en-US"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- locale information -->
|
||||
<RDF:Description about="urn:mozilla:locale:en-US"
|
||||
chrome:displayName="English(US)"
|
||||
chrome:author="mozilla.org"
|
||||
chrome:name="en-US"
|
||||
chrome:previewURL="http://www.mozilla.org/locales/en-US.gif">
|
||||
<chrome:packages>
|
||||
<RDF:Seq about="urn:mozilla:locale:en-US:packages">
|
||||
<RDF:li resource="urn:mozilla:locale:en-US:sql"/>
|
||||
</RDF:Seq>
|
||||
</chrome:packages>
|
||||
</RDF:Description>
|
||||
|
||||
</RDF:RDF>
|
||||
@@ -0,0 +1,12 @@
|
||||
<!ENTITY header.label "SQL support">
|
||||
|
||||
<!ENTITY aliases.label "Aliases">
|
||||
<!ENTITY nameCol.label "Name">
|
||||
<!ENTITY typeCol.label "Type">
|
||||
<!ENTITY hostnameCol.label "Hostname">
|
||||
<!ENTITY portCol.label "Port">
|
||||
<!ENTITY databaseCol.label "Database">
|
||||
|
||||
<!ENTITY add.label "Add alias">
|
||||
<!ENTITY update.label "Update alias">
|
||||
<!ENTITY remove.label "Remove alias">
|
||||
33
mozilla/extensions/sql/base/src/Makefile.in
Normal file
33
mozilla/extensions/sql/base/src/Makefile.in
Normal file
@@ -0,0 +1,33 @@
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = sql
|
||||
LIBRARY_NAME = sqlbase_s
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
unicharutil \
|
||||
locale \
|
||||
necko \
|
||||
rdf \
|
||||
windowwatcher \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
mozSqlConnection.cpp \
|
||||
mozSqlRequest.cpp \
|
||||
mozSqlResult.cpp \
|
||||
mozSqlService.cpp
|
||||
|
||||
EXPORTS = \
|
||||
mozSqlConnection.h \
|
||||
mozSqlRequest.h \
|
||||
mozSqlResult.h \
|
||||
mozSqlService.h
|
||||
|
||||
FORCE_STATIC_LIB=1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
237
mozilla/extensions/sql/base/src/mozSqlConnection.cpp
Normal file
237
mozilla/extensions/sql/base/src/mozSqlConnection.cpp
Normal file
@@ -0,0 +1,237 @@
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "mozSqlRequest.h"
|
||||
#include "mozSqlConnection.h"
|
||||
|
||||
mozSqlConnection::mozSqlConnection()
|
||||
: mLock(nsnull),
|
||||
mCondVar(nsnull),
|
||||
mThread(nsnull),
|
||||
mShutdown(PR_FALSE),
|
||||
mWaiting(PR_FALSE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mExecLock = PR_NewLock();
|
||||
}
|
||||
|
||||
mozSqlConnection::~mozSqlConnection()
|
||||
{
|
||||
mRequests.Clear();
|
||||
|
||||
if (mCondVar)
|
||||
PR_DestroyCondVar(mCondVar);
|
||||
PR_DestroyLock(mExecLock);
|
||||
if (mLock)
|
||||
PR_DestroyLock(mLock);
|
||||
}
|
||||
|
||||
// We require a special implementation of Release, which knows about
|
||||
// a circular strong reference
|
||||
NS_IMPL_THREADSAFE_ADDREF(mozSqlConnection)
|
||||
NS_IMPL_THREADSAFE_QUERY_INTERFACE3(mozSqlConnection,
|
||||
mozISqlConnection,
|
||||
nsIRunnable,
|
||||
nsISupportsWeakReference)
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
mozSqlConnection::Release()
|
||||
{
|
||||
PR_AtomicDecrement((PRInt32*)&mRefCnt);
|
||||
// Delete if the last reference is our strong circular reference.
|
||||
if (mThread && mRefCnt == 1) {
|
||||
PR_Lock(mLock);
|
||||
mRequests.Clear();
|
||||
mShutdown = PR_TRUE;
|
||||
if (mWaiting)
|
||||
PR_NotifyCondVar(mCondVar);
|
||||
else
|
||||
CancelExec();
|
||||
PR_Unlock(mLock);
|
||||
return 0;
|
||||
}
|
||||
else if (mRefCnt == 0) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::GetServerVersion(nsAString& aServerVersion)
|
||||
{
|
||||
aServerVersion = mServerVersion;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::GetErrorMessage(nsAString& aErrorMessage)
|
||||
{
|
||||
aErrorMessage = mErrorMessage;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::GetLastID(PRInt32* aLastID)
|
||||
{
|
||||
*aLastID = mLastID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::Init(const nsAString & aHost, PRInt32 aPort,
|
||||
const nsAString & aDatabase, const nsAString & aUsername,
|
||||
const nsAString & aPassword)
|
||||
{
|
||||
// descendants have to implement this themselves
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::ExecuteQuery(const nsAString& aQuery, mozISqlResult** _retval)
|
||||
{
|
||||
PR_Lock(mExecLock);
|
||||
nsresult rv = RealExec(aQuery, _retval, nsnull);
|
||||
PR_Unlock(mExecLock);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::ExecuteUpdate(const nsAString& aUpdate, PRInt32* _retval)
|
||||
{
|
||||
PR_Lock(mExecLock);
|
||||
nsresult rv = RealExec(aUpdate, nsnull, _retval);
|
||||
PR_Unlock(mExecLock);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::AsyncExecuteQuery(const nsAString& aQuery, nsISupports* aCtxt,
|
||||
mozISqlRequestObserver* aObserver,
|
||||
mozISqlRequest **_retval)
|
||||
{
|
||||
if (!mThread) {
|
||||
mLock = PR_NewLock();
|
||||
mCondVar = PR_NewCondVar(mLock);
|
||||
NS_NewThread(getter_AddRefs(mThread), this, 0, PR_UNJOINABLE_THREAD);
|
||||
}
|
||||
|
||||
mozSqlRequest* request = new mozSqlRequest(this);
|
||||
if (! request)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
request->mIsQuery = PR_TRUE;
|
||||
request->mQuery = aQuery;
|
||||
request->mCtxt = aCtxt;
|
||||
|
||||
nsresult rv = NS_GetProxyForObject(NS_CURRENT_EVENTQ,
|
||||
NS_GET_IID(mozISqlRequestObserver),
|
||||
aObserver,
|
||||
PROXY_SYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(request->mObserver));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PR_Lock(mLock);
|
||||
mRequests.AppendObject(request);
|
||||
if (mWaiting && mRequests.Count() == 1)
|
||||
PR_NotifyCondVar(mCondVar);
|
||||
PR_Unlock(mLock);
|
||||
|
||||
NS_ADDREF(*_retval = request);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::AsyncExecuteUpdate(const nsAString& aQuery, nsISupports* aCtxt,
|
||||
mozISqlRequestObserver* aObserver,
|
||||
mozISqlRequest **_retval)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::BeginTransaction()
|
||||
{
|
||||
PRInt32 affectedRows;
|
||||
return ExecuteUpdate(NS_LITERAL_STRING("begin"), &affectedRows);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::CommitTransaction()
|
||||
{
|
||||
PRInt32 affectedRows;
|
||||
return ExecuteUpdate(NS_LITERAL_STRING("commit"), &affectedRows);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::RollbackTransaction()
|
||||
{
|
||||
PRInt32 affectedRows;
|
||||
return ExecuteUpdate(NS_LITERAL_STRING("rollback"), &affectedRows);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::GetPrimaryKeys(const nsAString& aSchema, const nsAString& aTable, mozISqlResult** _retval)
|
||||
{
|
||||
// descendants have to implement this themselves
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnection::Run()
|
||||
{
|
||||
while(!mShutdown) {
|
||||
PR_Lock(mLock);
|
||||
|
||||
while (mRequests.Count()) {
|
||||
mCurrentRequest = mRequests[0];
|
||||
mRequests.RemoveObjectAt(0);
|
||||
|
||||
|
||||
mozSqlRequest* r = (mozSqlRequest*)mCurrentRequest.get();
|
||||
|
||||
r->mObserver->OnStartRequest(mCurrentRequest, r->mCtxt);
|
||||
|
||||
r->mStatus = mozISqlRequest::STATUS_EXECUTED;
|
||||
|
||||
PR_Unlock(mLock);
|
||||
|
||||
nsresult rv = ExecuteQuery(r->mQuery, getter_AddRefs(r->mResult));
|
||||
|
||||
PR_Lock(mLock);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
r->mStatus = mozISqlRequest::STATUS_COMPLETE;
|
||||
else {
|
||||
r->mStatus = mozISqlRequest::STATUS_ERROR;
|
||||
GetErrorMessage(r->mErrorMessage);
|
||||
}
|
||||
|
||||
r->mObserver->OnStopRequest(mCurrentRequest, r->mCtxt);
|
||||
|
||||
mCurrentRequest = nsnull;
|
||||
|
||||
}
|
||||
|
||||
mWaiting = PR_TRUE;
|
||||
PR_WaitCondVar(mCondVar, PR_INTERVAL_NO_TIMEOUT);
|
||||
mWaiting = PR_FALSE;
|
||||
PR_Unlock(mLock);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlConnection::CancelRequest(mozISqlRequest* aRequest)
|
||||
{
|
||||
PR_Lock(mLock);
|
||||
if (mCurrentRequest == aRequest)
|
||||
CancelExec();
|
||||
else {
|
||||
if (mRequests.RemoveObject(aRequest))
|
||||
((mozSqlRequest*)aRequest)->mStatus = mozISqlRequest::STATUS_CANCELLED;
|
||||
}
|
||||
PR_Unlock(mLock);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
53
mozilla/extensions/sql/base/src/mozSqlConnection.h
Normal file
53
mozilla/extensions/sql/base/src/mozSqlConnection.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef mozSqlConnection_h
|
||||
#define mozSqlConnection_h
|
||||
|
||||
#include "prcvar.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "mozISqlConnection.h"
|
||||
#include "mozISqlRequest.h"
|
||||
#include "mozISqlResult.h"
|
||||
|
||||
class mozSqlConnection : public mozISqlConnection,
|
||||
public nsIRunnable,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
mozSqlConnection();
|
||||
virtual ~mozSqlConnection();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_MOZISQLCONNECTION
|
||||
|
||||
NS_DECL_NSIRUNNABLE
|
||||
|
||||
friend class mozSqlRequest;
|
||||
friend class mozSqlResult;
|
||||
|
||||
protected:
|
||||
virtual nsresult RealExec(const nsAString& aQuery,
|
||||
mozISqlResult** aResult, PRInt32* aAffectedRows) = 0;
|
||||
virtual nsresult CancelExec() = 0;
|
||||
virtual nsresult GetIDName(nsAString& aIDName) = 0;
|
||||
|
||||
nsresult CancelRequest(mozISqlRequest* aRequest);
|
||||
|
||||
nsString mServerVersion;
|
||||
nsString mErrorMessage;
|
||||
PRInt32 mLastID;
|
||||
|
||||
PRLock* mLock;
|
||||
PRCondVar* mCondVar;
|
||||
PRLock* mExecLock;
|
||||
nsCOMPtr<nsIThread> mThread;
|
||||
nsCOMArray<mozISqlRequest> mRequests;
|
||||
nsCOMPtr<mozISqlRequest> mCurrentRequest;
|
||||
PRBool mShutdown;
|
||||
PRBool mWaiting;
|
||||
};
|
||||
|
||||
#endif // mozSqlConnection_h
|
||||
86
mozilla/extensions/sql/base/src/mozSqlRequest.cpp
Normal file
86
mozilla/extensions/sql/base/src/mozSqlRequest.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
#include "mozSqlConnection.h"
|
||||
#include "mozSqlRequest.h"
|
||||
|
||||
mozSqlRequest::mozSqlRequest(mozISqlConnection* aConnection)
|
||||
: mAffectedRows(-1),
|
||||
mIsQuery(PR_TRUE),
|
||||
mStatus(mozISqlRequest::STATUS_NONE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mConnection = do_GetWeakReference(aConnection);
|
||||
}
|
||||
|
||||
mozSqlRequest::~mozSqlRequest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(mozSqlRequest,
|
||||
mozISqlRequest);
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlRequest::GetErrorMessage(nsAString & aErrorMessage)
|
||||
{
|
||||
aErrorMessage = mErrorMessage;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlRequest::GetResult(mozISqlResult * *aResult)
|
||||
{
|
||||
NS_IF_ADDREF(*aResult = mResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlRequest::GetAffectedRows(PRInt32 *aAffectedRows)
|
||||
{
|
||||
*aAffectedRows = mAffectedRows;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlRequest::GetLastID(PRInt32* aLastID)
|
||||
{
|
||||
*aLastID = mLastID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlRequest::GetQuery(nsAString & aQuery)
|
||||
{
|
||||
aQuery = mQuery;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlRequest::GetCtxt(nsISupports * *aCtxt)
|
||||
{
|
||||
NS_IF_ADDREF(*aCtxt = mCtxt);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlRequest::GetObserver(mozISqlRequestObserver * *aObserver)
|
||||
{
|
||||
NS_IF_ADDREF(*aObserver = mObserver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlRequest::GetStatus(PRInt32 *aStatus)
|
||||
{
|
||||
*aStatus = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlRequest::Cancel()
|
||||
{
|
||||
nsCOMPtr<mozISqlConnection> connection = do_QueryReferent(mConnection);
|
||||
if (!connection)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mozISqlConnection* connectionRaw = connection.get();
|
||||
return ((mozSqlConnection*)connectionRaw)->CancelRequest(this);
|
||||
}
|
||||
41
mozilla/extensions/sql/base/src/mozSqlRequest.h
Normal file
41
mozilla/extensions/sql/base/src/mozSqlRequest.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef mozSqlRequest_h
|
||||
#define mozSqlRequest_h
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "mozISqlConnection.h"
|
||||
#include "mozISqlResult.h"
|
||||
#include "mozISqlRequest.h"
|
||||
#include "mozISqlRequestObserver.h"
|
||||
|
||||
class mozSqlRequest : public mozISqlRequest
|
||||
{
|
||||
public:
|
||||
mozSqlRequest(mozISqlConnection* aConnection);
|
||||
virtual ~mozSqlRequest();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_MOZISQLREQUEST
|
||||
|
||||
friend class mozSqlConnection;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIWeakReference> mConnection;
|
||||
|
||||
nsString mErrorMessage;
|
||||
nsCOMPtr<mozISqlResult> mResult;
|
||||
PRInt32 mAffectedRows;
|
||||
PRInt32 mLastID;
|
||||
|
||||
PRBool mIsQuery;
|
||||
nsString mQuery;
|
||||
nsCOMPtr<nsISupports> mCtxt;
|
||||
nsCOMPtr<mozISqlRequestObserver> mObserver;
|
||||
|
||||
PRInt32 mStatus;
|
||||
|
||||
};
|
||||
|
||||
#endif // mozSqlRequest_h
|
||||
1918
mozilla/extensions/sql/base/src/mozSqlResult.cpp
Normal file
1918
mozilla/extensions/sql/base/src/mozSqlResult.cpp
Normal file
File diff suppressed because it is too large
Load Diff
367
mozilla/extensions/sql/base/src/mozSqlResult.h
Normal file
367
mozilla/extensions/sql/base/src/mozSqlResult.h
Normal file
@@ -0,0 +1,367 @@
|
||||
#ifndef mozSqlResult_h
|
||||
#define mozSqlResult_h
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "nsFixedSizeAllocator.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFRemoteDataSource.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "mozISqlConnection.h"
|
||||
#include "mozISqlDataSource.h"
|
||||
#include "mozISqlResult.h"
|
||||
#include "mozISqlResultEnumerator.h"
|
||||
#include "mozISqlInputStream.h"
|
||||
|
||||
#define CELL_FLAG_NULL 0x80
|
||||
#define CELL_FLAG_DEFAULT 0x40
|
||||
#define CELL_FLAG_MASK ~(CELL_FLAG_NULL | CELL_FLAG_DEFAULT)
|
||||
|
||||
class ColumnInfo {
|
||||
public:
|
||||
static ColumnInfo*
|
||||
Create(nsFixedSizeAllocator& aAllocator,
|
||||
PRUnichar* aName,
|
||||
PRInt32 aType,
|
||||
PRInt32 aSize,
|
||||
PRInt32 aMod,
|
||||
nsIRDFResource* aProperty) {
|
||||
void* place = aAllocator.Alloc(sizeof(ColumnInfo));
|
||||
return place ? ::new(place) ColumnInfo(aName, aType, aSize, aMod, aProperty) : nsnull;
|
||||
}
|
||||
|
||||
static void
|
||||
Destroy(nsFixedSizeAllocator& aAllocator, ColumnInfo* aColumnInfo) {
|
||||
aColumnInfo->~ColumnInfo();
|
||||
aAllocator.Free(aColumnInfo, sizeof(ColumnInfo));
|
||||
}
|
||||
|
||||
ColumnInfo(PRUnichar* aName, PRInt32 aType, PRInt32 aSize, PRInt32 aMod, nsIRDFResource* aProperty)
|
||||
: mName(aName),
|
||||
mType(aType),
|
||||
mSize(aSize),
|
||||
mMod(aMod),
|
||||
mProperty(aProperty) {
|
||||
NS_IF_ADDREF(mProperty);
|
||||
}
|
||||
|
||||
~ColumnInfo() {
|
||||
if (mName)
|
||||
nsMemory::Free(mName);
|
||||
NS_IF_RELEASE(mProperty);
|
||||
}
|
||||
|
||||
PRUnichar* mName;
|
||||
PRInt32 mType;
|
||||
PRInt32 mSize;
|
||||
PRInt32 mMod;
|
||||
nsIRDFResource* mProperty;
|
||||
|
||||
private:
|
||||
// Hide so that only Create() and Destroy() can be used to
|
||||
// allocate and deallocate from the heap
|
||||
static void* operator new(size_t) CPP_THROW_NEW { return 0; }
|
||||
static void operator delete(void*, size_t) {}
|
||||
};
|
||||
|
||||
class Cell {
|
||||
public:
|
||||
static Cell*
|
||||
Create(nsFixedSizeAllocator& aAllocator,
|
||||
PRInt32 aType) {
|
||||
void* place = aAllocator.Alloc(sizeof(Cell));
|
||||
return place ? ::new(place) Cell(aType) : nsnull;
|
||||
}
|
||||
|
||||
static Cell*
|
||||
Create(nsFixedSizeAllocator& aAllocator,
|
||||
PRInt32 aType,
|
||||
Cell* aSrcCell) {
|
||||
void* place = aAllocator.Alloc(sizeof(Cell));
|
||||
if (! place)
|
||||
return nsnull;
|
||||
Cell* newCell = ::new(place) Cell(aType);
|
||||
Copy(aSrcCell, newCell);
|
||||
return newCell;
|
||||
}
|
||||
|
||||
static void
|
||||
Copy(Cell* aSrcCell, Cell* aDestCell) {
|
||||
if (aSrcCell->IsNull())
|
||||
aDestCell->SetNull(PR_TRUE);
|
||||
else {
|
||||
aDestCell->SetNull(PR_FALSE);
|
||||
PRInt32 type = aSrcCell->GetType();
|
||||
if (type == mozISqlResult::TYPE_STRING)
|
||||
aDestCell->SetString(nsCRT::strdup(aSrcCell->mString));
|
||||
else if (type == mozISqlResult::TYPE_INT)
|
||||
aDestCell->mInt = aSrcCell->mInt;
|
||||
else if (type == mozISqlResult::TYPE_FLOAT ||
|
||||
type == mozISqlResult::TYPE_DECIMAL)
|
||||
aDestCell->mFloat = aSrcCell->mFloat;
|
||||
else if (type == mozISqlResult::TYPE_DATE ||
|
||||
type == mozISqlResult::TYPE_TIME ||
|
||||
type == mozISqlResult::TYPE_DATETIME)
|
||||
aDestCell->mDate = aSrcCell->mDate;
|
||||
else if (type == mozISqlResult::TYPE_BOOL)
|
||||
aDestCell->mBool = aSrcCell->mBool;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Destroy(nsFixedSizeAllocator& aAllocator, Cell* aCell) {
|
||||
aCell->~Cell();
|
||||
aAllocator.Free(aCell, sizeof(Cell));
|
||||
}
|
||||
|
||||
Cell(PRInt32 aType)
|
||||
: mString(nsnull),
|
||||
mType(aType | CELL_FLAG_NULL) {
|
||||
}
|
||||
|
||||
~Cell() {
|
||||
if ((GetType() == mozISqlResult::TYPE_STRING) && mString) {
|
||||
nsMemory::Free(mString);
|
||||
}
|
||||
}
|
||||
|
||||
void SetString(PRUnichar* aString) {
|
||||
if (mString)
|
||||
nsMemory::Free(mString);
|
||||
mString = aString;
|
||||
}
|
||||
|
||||
PRInt32 GetType() {
|
||||
return mType & CELL_FLAG_MASK;
|
||||
}
|
||||
|
||||
void SetNull(PRBool aNull) {
|
||||
mType &= CELL_FLAG_MASK;
|
||||
if (aNull)
|
||||
mType |= CELL_FLAG_NULL;
|
||||
}
|
||||
|
||||
void SetDefault(PRBool aDefault) {
|
||||
mType &= CELL_FLAG_MASK;
|
||||
if (aDefault)
|
||||
mType |= CELL_FLAG_DEFAULT;
|
||||
}
|
||||
|
||||
PRBool IsNull() {
|
||||
return mType & CELL_FLAG_NULL;
|
||||
}
|
||||
|
||||
PRBool IsDefault() {
|
||||
return mType & CELL_FLAG_DEFAULT;
|
||||
}
|
||||
|
||||
union {
|
||||
PRUnichar* mString;
|
||||
PRInt32 mInt;
|
||||
float mFloat;
|
||||
PRInt64 mDate;
|
||||
PRBool mBool;
|
||||
};
|
||||
|
||||
private:
|
||||
static void* operator new(size_t) CPP_THROW_NEW { return 0; }
|
||||
static void operator delete(void*, size_t) {}
|
||||
|
||||
PRInt8 mType;
|
||||
};
|
||||
|
||||
class Row {
|
||||
public:
|
||||
static Row*
|
||||
Create(nsFixedSizeAllocator& aAllocator,
|
||||
nsIRDFResource* aSource,
|
||||
nsVoidArray& aColumnInfo) {
|
||||
void* place = aAllocator.Alloc(sizeof(Row));
|
||||
if (! place)
|
||||
return nsnull;
|
||||
Row* newRow = ::new(place) Row(aSource, aColumnInfo.Count());
|
||||
for (PRInt32 i = 0; i < aColumnInfo.Count(); i++) {
|
||||
Cell* newCell = Cell::Create(aAllocator, ((ColumnInfo*)aColumnInfo[i])->mType);
|
||||
newRow->mCells[i] = newCell;
|
||||
}
|
||||
return newRow;
|
||||
}
|
||||
|
||||
static Row*
|
||||
Create(nsFixedSizeAllocator& aAllocator,
|
||||
nsIRDFResource* aSource,
|
||||
nsVoidArray& aColumnInfo,
|
||||
Row* aSrcRow) {
|
||||
void* place = aAllocator.Alloc(sizeof(Row));
|
||||
if (! place)
|
||||
return nsnull;
|
||||
Row* newRow = ::new(place) Row(aSource, aColumnInfo.Count());
|
||||
for (PRInt32 i = 0; i < aColumnInfo.Count(); i++) {
|
||||
Cell* srcCell = aSrcRow->mCells[i];
|
||||
Cell* newCell = Cell::Create(aAllocator, ((ColumnInfo*)aColumnInfo[i])->mType, srcCell);
|
||||
newRow->mCells[i] = newCell;
|
||||
}
|
||||
return newRow;
|
||||
}
|
||||
|
||||
static void
|
||||
Copy(PRInt32 aColumnCount, Row* aSrcRow, Row* aDestRow) {
|
||||
for (PRInt32 i = 0; i < aColumnCount; i++) {
|
||||
Cell* srcCell = aSrcRow->mCells[i];
|
||||
Cell* destCell = aDestRow->mCells[i];
|
||||
Cell::Copy(srcCell, destCell);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Destroy(nsFixedSizeAllocator& aAllocator, PRInt32 aColumnCount, Row* aRow) {
|
||||
for (PRInt32 i = 0; i < aColumnCount; i++)
|
||||
Cell::Destroy(aAllocator, aRow->mCells[i]);
|
||||
aRow->~Row();
|
||||
aAllocator.Free(aRow, sizeof(*aRow));
|
||||
}
|
||||
|
||||
Row(nsIRDFResource* aSource, PRInt32 aColumnCount)
|
||||
: mSource(aSource)
|
||||
{
|
||||
NS_IF_ADDREF(mSource);
|
||||
mCells = new Cell*[aColumnCount];
|
||||
}
|
||||
|
||||
~Row() {
|
||||
delete[] mCells;
|
||||
NS_IF_RELEASE(mSource);
|
||||
}
|
||||
|
||||
nsIRDFResource* mSource;
|
||||
Cell** mCells;
|
||||
private:
|
||||
static void* operator new(size_t) CPP_THROW_NEW { return 0; }
|
||||
static void operator delete(void*, size_t) {}
|
||||
};
|
||||
|
||||
class mozSqlResult : public mozISqlResult,
|
||||
public mozISqlDataSource,
|
||||
public nsIRDFDataSource,
|
||||
public nsIRDFRemoteDataSource
|
||||
{
|
||||
public:
|
||||
mozSqlResult(mozISqlConnection* aConnection,
|
||||
const nsAString& aQuery);
|
||||
nsresult Init();
|
||||
nsresult Rebuild();
|
||||
virtual ~mozSqlResult();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_MOZISQLRESULT
|
||||
|
||||
NS_DECL_MOZISQLDATASOURCE
|
||||
|
||||
NS_DECL_NSIRDFDATASOURCE
|
||||
|
||||
NS_DECL_NSIRDFREMOTEDATASOURCE
|
||||
|
||||
friend class mozSqlResultEnumerator;
|
||||
friend class mozSqlResultStream;
|
||||
|
||||
protected:
|
||||
virtual nsresult BuildColumnInfo() = 0 ;
|
||||
virtual nsresult BuildRows() = 0;
|
||||
virtual void ClearNativeResult() = 0;
|
||||
|
||||
void ClearColumnInfo();
|
||||
void ClearRows();
|
||||
|
||||
nsresult EnsureTableName();
|
||||
nsresult EnsurePrimaryKeys();
|
||||
|
||||
void AppendValue(Cell* aCell, nsAutoString& aValues);
|
||||
nsresult AppendKeys(Row* aRow, nsAutoString& aKeys);
|
||||
nsresult GetValues(Row* aRow, mozISqlResult** aResult, PRBool aUseID);
|
||||
nsresult CopyValues(mozISqlResult* aResult, Row* aRow);
|
||||
|
||||
virtual nsresult CanInsert(PRBool* _retval) = 0;
|
||||
virtual nsresult CanUpdate(PRBool* _retval) = 0;
|
||||
virtual nsresult CanDelete(PRBool* _retval) = 0;
|
||||
|
||||
nsresult InsertRow(Row* aSrcRow, PRInt32* _retval);
|
||||
nsresult UpdateRow(PRInt32 aRowIndex, Row* aSrcRow, PRInt32* _retval);
|
||||
nsresult DeleteRow(PRInt32 aRowIndex, PRInt32* _retval);
|
||||
nsresult GetCondition(Row* aRow, nsAString& aCurrentCondition);
|
||||
|
||||
static PRInt32 gRefCnt;
|
||||
static nsIRDFService* gRDFService;
|
||||
static nsIDateTimeFormat* gFormat;
|
||||
static nsIRDFResource* kSQL_ResultRoot;
|
||||
static nsIRDFResource* kNC_Child;
|
||||
static nsIRDFLiteral* kNullLiteral;
|
||||
static nsIRDFLiteral* kTrueLiteral;
|
||||
static nsIRDFLiteral* kFalseLiteral;
|
||||
|
||||
nsCOMPtr<mozISqlConnection> mConnection;
|
||||
nsString mErrorMessage;
|
||||
nsString mQuery;
|
||||
nsString mTableName;
|
||||
nsFixedSizeAllocator mAllocator;
|
||||
nsAutoVoidArray mColumnInfo;
|
||||
nsVoidArray mRows;
|
||||
nsObjectHashtable mSources;
|
||||
nsCOMArray<nsIRDFObserver> mObservers;
|
||||
nsCOMPtr<mozISqlResultEnumerator> mPrimaryKeys;
|
||||
PRInt32 mCanInsert;
|
||||
PRInt32 mCanUpdate;
|
||||
PRInt32 mCanDelete;
|
||||
};
|
||||
|
||||
class mozSqlResultEnumerator : public mozISqlResultEnumerator,
|
||||
public nsISimpleEnumerator
|
||||
{
|
||||
public:
|
||||
mozSqlResultEnumerator(mozSqlResult* aResult);
|
||||
virtual ~mozSqlResultEnumerator();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_MOZISQLRESULTENUMERATOR
|
||||
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
private:
|
||||
mozSqlResult* mResult;
|
||||
PRInt32 mCurrentIndex;
|
||||
Row* mCurrentRow;
|
||||
Row* mBuffer;
|
||||
};
|
||||
|
||||
class mozSqlResultStream : public mozISqlInputStream,
|
||||
public nsIInputStream
|
||||
{
|
||||
public:
|
||||
mozSqlResultStream(mozSqlResult* aResult);
|
||||
virtual ~mozSqlResultStream();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_MOZISQLINPUTSTREAM
|
||||
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
|
||||
protected:
|
||||
nsresult EnsureBuffer();
|
||||
|
||||
private:
|
||||
mozSqlResult* mResult;
|
||||
char* mBuffer;
|
||||
PRUint32 mLength;
|
||||
PRUint32 mPosition;
|
||||
};
|
||||
|
||||
#endif // mozSqlResult_h
|
||||
624
mozilla/extensions/sql/base/src/mozSqlService.cpp
Normal file
624
mozilla/extensions/sql/base/src/mozSqlService.cpp
Normal file
@@ -0,0 +1,624 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "rdf.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIRDFXMLSink.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "mozSqlService.h"
|
||||
#include "mozSqlConnection.h"
|
||||
|
||||
#define SQL_NAMESPACE_URI "http://www.mozilla.org/SQL-rdf#"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
|
||||
nsIRDFService* mozSqlService::gRDFService;
|
||||
nsIRDFContainerUtils* mozSqlService::gRDFContainerUtils;
|
||||
|
||||
nsIRDFResource* mozSqlService::kSQL_AliasesRoot;
|
||||
nsIRDFResource* mozSqlService::kSQL_Name;
|
||||
nsIRDFResource* mozSqlService::kSQL_Type;
|
||||
nsIRDFResource* mozSqlService::kSQL_Hostname;
|
||||
nsIRDFResource* mozSqlService::kSQL_Port;
|
||||
nsIRDFResource* mozSqlService::kSQL_Database;
|
||||
|
||||
|
||||
mozSqlService::mozSqlService()
|
||||
: mConnectionCache(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
mozSqlService::~mozSqlService()
|
||||
{
|
||||
gRDFService->UnregisterDataSource(this);
|
||||
|
||||
delete mConnectionCache;
|
||||
|
||||
NS_IF_RELEASE(kSQL_AliasesRoot);
|
||||
NS_IF_RELEASE(kSQL_Name);
|
||||
NS_IF_RELEASE(kSQL_Type);
|
||||
NS_IF_RELEASE(kSQL_Hostname);
|
||||
NS_IF_RELEASE(kSQL_Port);
|
||||
NS_IF_RELEASE(kSQL_Database);
|
||||
|
||||
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFContainerUtils);
|
||||
gRDFContainerUtils = nsnull;
|
||||
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
|
||||
gRDFService = nsnull;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3(mozSqlService,
|
||||
mozISqlService,
|
||||
nsIRDFDataSource,
|
||||
nsIRDFRemoteDataSource);
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetErrorMessage(nsAString& aErrorMessage)
|
||||
{
|
||||
aErrorMessage = mErrorMessage;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlService::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService),
|
||||
(nsISupports**) &gRDFService);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kRDFContainerUtilsCID, NS_GET_IID(nsIRDFContainerUtils),
|
||||
(nsISupports**) &gRDFContainerUtils);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
gRDFService->GetResource(NS_LITERAL_CSTRING("SQL:AliasesRoot"),
|
||||
&kSQL_AliasesRoot);
|
||||
gRDFService->GetResource(NS_LITERAL_CSTRING(SQL_NAMESPACE_URI "name"),
|
||||
&kSQL_Name);
|
||||
gRDFService->GetResource(NS_LITERAL_CSTRING(SQL_NAMESPACE_URI "type"),
|
||||
&kSQL_Type);
|
||||
gRDFService->GetResource(NS_LITERAL_CSTRING(SQL_NAMESPACE_URI "hostname"),
|
||||
&kSQL_Hostname);
|
||||
gRDFService->GetResource(NS_LITERAL_CSTRING(SQL_NAMESPACE_URI "port"),
|
||||
&kSQL_Port);
|
||||
gRDFService->GetResource(NS_LITERAL_CSTRING(SQL_NAMESPACE_URI "database"),
|
||||
&kSQL_Database);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = file->AppendNative(NS_LITERAL_CSTRING("sql.rdf"));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCAutoString sql;
|
||||
NS_GetURLSpecFromFile(file, sql);
|
||||
|
||||
rv = gRDFService->GetDataSourceBlocking(sql.get(), getter_AddRefs(mInner));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIRDFXMLSink> sink = do_QueryInterface(mInner);
|
||||
if (sink) {
|
||||
nsCOMPtr<nsIAtom> prefix = getter_AddRefs(NS_NewAtom("SQL"));
|
||||
sink->AddNameSpace(prefix, NS_ConvertASCIItoUCS2(SQL_NAMESPACE_URI));
|
||||
}
|
||||
|
||||
return gRDFService->RegisterDataSource(this, PR_FALSE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::AddAlias(const nsACString& aURI,
|
||||
const nsAString& aName,
|
||||
const nsAString& aType,
|
||||
const nsAString& aHostname,
|
||||
PRInt32 aPort,
|
||||
const nsAString& aDatabase)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
gRDFService->GetResource(aURI, getter_AddRefs(resource));
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> rdfLiteral;
|
||||
nsCOMPtr<nsIRDFInt> rdfInt;
|
||||
|
||||
gRDFService->GetLiteral(PromiseFlatString(aName).get(), getter_AddRefs(rdfLiteral));
|
||||
mInner->Assert(resource, kSQL_Name, rdfLiteral, PR_TRUE);
|
||||
|
||||
gRDFService->GetLiteral(PromiseFlatString(aType).get(), getter_AddRefs(rdfLiteral));
|
||||
mInner->Assert(resource, kSQL_Type, rdfLiteral, PR_TRUE);
|
||||
|
||||
gRDFService->GetLiteral(PromiseFlatString(aHostname).get(), getter_AddRefs(rdfLiteral));
|
||||
mInner->Assert(resource, kSQL_Hostname, rdfLiteral, PR_TRUE);
|
||||
|
||||
gRDFService->GetIntLiteral(aPort, getter_AddRefs(rdfInt));
|
||||
mInner->Assert(resource, kSQL_Port, rdfInt, PR_TRUE);
|
||||
|
||||
gRDFService->GetLiteral(PromiseFlatString(aDatabase).get(), getter_AddRefs(rdfLiteral));
|
||||
mInner->Assert(resource, kSQL_Database, rdfLiteral, PR_TRUE);
|
||||
|
||||
nsresult rv = EnsureAliasesContainer();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
mAliasesContainer->AppendElement(resource);
|
||||
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::HasAlias(const nsACString& aURI, PRBool* _retval)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
gRDFService->GetResource(aURI, getter_AddRefs(resource));
|
||||
|
||||
nsresult rv = EnsureAliasesContainer();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRInt32 aliasIndex;
|
||||
mAliasesContainer->IndexOf(resource, &aliasIndex);
|
||||
|
||||
*_retval = aliasIndex != -1;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetAlias(const nsACString& aURI,
|
||||
nsAString& aName,
|
||||
nsAString& aType,
|
||||
nsAString& aHostname,
|
||||
PRInt32* aPort,
|
||||
nsAString& aDatabase)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
gRDFService->GetResource(aURI, getter_AddRefs(resource));
|
||||
|
||||
nsCOMPtr<nsIRDFNode> rdfNode;
|
||||
nsCOMPtr<nsIRDFLiteral> rdfLiteral;
|
||||
nsCOMPtr<nsIRDFInt> rdfInt;
|
||||
const PRUnichar* value;
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Name, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
if (rdfNode) {
|
||||
rdfLiteral = do_QueryInterface(rdfNode);
|
||||
rdfLiteral->GetValueConst(&value);
|
||||
aName.Assign(value);
|
||||
}
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Type, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
if (rdfNode) {
|
||||
rdfLiteral = do_QueryInterface(rdfNode);
|
||||
rdfLiteral->GetValueConst(&value);
|
||||
aType.Assign(value);
|
||||
}
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Hostname, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
if (rdfNode) {
|
||||
rdfLiteral = do_QueryInterface(rdfNode);
|
||||
rdfLiteral->GetValueConst(&value);
|
||||
aHostname.Assign(value);
|
||||
}
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Port, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
if (rdfNode) {
|
||||
rdfInt = do_QueryInterface(rdfNode);
|
||||
rdfInt->GetValue(aPort);
|
||||
}
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Database, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
if (rdfNode) {
|
||||
rdfLiteral = do_QueryInterface(rdfNode);
|
||||
rdfLiteral->GetValueConst(&value);
|
||||
aDatabase.Assign(value);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::UpdateAlias(const nsACString& aURI,
|
||||
const nsAString& aName,
|
||||
const nsAString& aType,
|
||||
const nsAString& aHostname,
|
||||
PRInt32 aPort,
|
||||
const nsAString& aDatabase)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
gRDFService->GetResource(aURI, getter_AddRefs(resource));
|
||||
|
||||
nsCOMPtr<nsIRDFNode> rdfNode;
|
||||
nsCOMPtr<nsIRDFLiteral> rdfLiteral;
|
||||
nsCOMPtr<nsIRDFInt> rdfInt;
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Name, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
gRDFService->GetLiteral(PromiseFlatString(aName).get(), getter_AddRefs(rdfLiteral));
|
||||
mInner->Change(resource, kSQL_Name, rdfNode, rdfLiteral);
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Type, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
gRDFService->GetLiteral(PromiseFlatString(aType).get(), getter_AddRefs(rdfLiteral));
|
||||
mInner->Change(resource, kSQL_Type, rdfNode, rdfLiteral);
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Hostname, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
gRDFService->GetLiteral(PromiseFlatString(aHostname).get(), getter_AddRefs(rdfLiteral));
|
||||
mInner->Change(resource, kSQL_Hostname, rdfNode, rdfLiteral);
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Port, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
gRDFService->GetIntLiteral(aPort, getter_AddRefs(rdfInt));
|
||||
mInner->Change(resource, kSQL_Port, rdfNode, rdfInt);
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Database, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
gRDFService->GetLiteral(PromiseFlatString(aDatabase).get(), getter_AddRefs(rdfLiteral));
|
||||
mInner->Change(resource, kSQL_Database, rdfNode, rdfLiteral);
|
||||
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::RemoveAlias(const nsACString &aURI)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
gRDFService->GetResource(aURI, getter_AddRefs(resource));
|
||||
|
||||
nsCOMPtr<nsIRDFNode> rdfNode;
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Name, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
mInner->Unassert(resource, kSQL_Name, rdfNode);
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Type, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
mInner->Unassert(resource, kSQL_Type, rdfNode);
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Hostname, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
mInner->Unassert(resource, kSQL_Hostname, rdfNode);
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Port, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
mInner->Unassert(resource, kSQL_Port, rdfNode);
|
||||
|
||||
mInner->GetTarget(resource, kSQL_Database, PR_TRUE, getter_AddRefs(rdfNode));
|
||||
mInner->Unassert(resource, kSQL_Database, rdfNode);
|
||||
|
||||
nsresult rv = EnsureAliasesContainer();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
mAliasesContainer->RemoveElement(resource, PR_TRUE);
|
||||
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetConnection(const nsACString &aURI, mozISqlConnection **_retval)
|
||||
{
|
||||
nsCStringKey key(aURI);
|
||||
nsCOMPtr<nsIWeakReference> weakRef;
|
||||
nsCOMPtr<mozISqlConnection> conn;
|
||||
|
||||
if (mConnectionCache) {
|
||||
weakRef = getter_AddRefs(NS_STATIC_CAST(nsIWeakReference*, mConnectionCache->Get(&key)));
|
||||
if (weakRef) {
|
||||
conn = do_QueryReferent(weakRef);
|
||||
if (conn)
|
||||
NS_ADDREF(*_retval = conn);
|
||||
}
|
||||
}
|
||||
|
||||
if (! *_retval) {
|
||||
nsresult rv = GetNewConnection(aURI, getter_AddRefs(conn));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
weakRef = do_GetWeakReference(conn);
|
||||
|
||||
if (! mConnectionCache)
|
||||
mConnectionCache = new nsSupportsHashtable(16);
|
||||
mConnectionCache->Put(&key, weakRef);
|
||||
|
||||
NS_ADDREF(*_retval = conn);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetNewConnection(const nsACString &aURI, mozISqlConnection **_retval)
|
||||
{
|
||||
PRBool hasAlias;
|
||||
HasAlias(aURI, &hasAlias);
|
||||
if (!hasAlias)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsAutoString name;
|
||||
nsAutoString type;
|
||||
nsAutoString hostname;
|
||||
PRInt32 port;
|
||||
nsAutoString database;
|
||||
GetAlias(aURI, name, type, hostname, &port, database);
|
||||
|
||||
nsCAutoString contractID(
|
||||
NS_LITERAL_CSTRING("@mozilla.org/sql/connection;1?type=") +
|
||||
NS_ConvertUCS2toUTF8(type));
|
||||
|
||||
nsCOMPtr<mozISqlConnection> conn = do_CreateInstance(contractID.get());
|
||||
if (! conn)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> watcher(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsIPrompt> prompter;
|
||||
watcher->GetNewPrompter(0, getter_AddRefs(prompter));
|
||||
|
||||
PRBool retval;
|
||||
do {
|
||||
nsXPIDLString username;
|
||||
nsXPIDLString password;
|
||||
prompter->PromptUsernameAndPassword(
|
||||
nsnull, // in wstring dialogTitle
|
||||
nsnull, // in wstring text
|
||||
getter_Copies(username),
|
||||
getter_Copies(password),
|
||||
nsnull, // in wstring checkMsg
|
||||
nsnull, // inout boolean checkValue
|
||||
&retval
|
||||
);
|
||||
|
||||
if (retval) {
|
||||
rv = conn->Init(hostname, port, database, username, password);
|
||||
if (NS_FAILED(rv)) {
|
||||
conn->GetErrorMessage(mErrorMessage);
|
||||
prompter->Alert(nsnull, mErrorMessage.get());
|
||||
}
|
||||
}
|
||||
} while(retval && NS_FAILED(rv));
|
||||
|
||||
NS_IF_ADDREF(*_retval = conn);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetURI(char** aURI)
|
||||
{
|
||||
if (!aURI)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aURI = nsCRT::strdup("rdf:sql");
|
||||
if (!(*aURI))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetSource(nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aTarget,
|
||||
PRBool aTruthValue,
|
||||
nsIRDFResource** aSource)
|
||||
{
|
||||
return mInner->GetSource(aProperty, aTarget, aTruthValue, aSource);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetSources(nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aTarget,
|
||||
PRBool aTruthValue,
|
||||
nsISimpleEnumerator** aSources) {
|
||||
return mInner->GetSources(aProperty, aTarget, aTruthValue, aSources);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetTarget(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
PRBool aTruthValue,
|
||||
nsIRDFNode** aTarget) {
|
||||
return mInner->GetTarget(aSource, aProperty, aTruthValue, aTarget);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetTargets(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
PRBool aTruthValue,
|
||||
nsISimpleEnumerator** aTargets) {
|
||||
return mInner->GetTargets(aSource, aProperty, aTruthValue, aTargets);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::Assert(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aTarget,
|
||||
PRBool aTruthValue)
|
||||
{
|
||||
return mInner->Assert(aSource, aProperty, aTarget, aTruthValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::Unassert(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aTarget)
|
||||
{
|
||||
return mInner->Unassert(aSource, aProperty, aTarget);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::Change(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aOldTarget,
|
||||
nsIRDFNode* aNewTarget)
|
||||
{
|
||||
return mInner->Change(aSource, aProperty, aOldTarget, aNewTarget);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::Move(nsIRDFResource* aOldSource,
|
||||
nsIRDFResource* aNewSource,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aTarget)
|
||||
{
|
||||
return mInner->Move(aOldSource, aNewSource, aProperty, aTarget);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::HasAssertion(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aTarget,
|
||||
PRBool aTruthValue,
|
||||
PRBool* hasAssertion)
|
||||
{
|
||||
return mInner->HasAssertion(aSource, aProperty, aTarget, aTruthValue, hasAssertion);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::AddObserver(nsIRDFObserver* aObserver)
|
||||
{
|
||||
return mInner->AddObserver(aObserver);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::RemoveObserver(nsIRDFObserver* aObserver)
|
||||
{
|
||||
return mInner->RemoveObserver(aObserver);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::HasArcIn(nsIRDFNode* aNode,
|
||||
nsIRDFResource* aArc,
|
||||
PRBool* _retval)
|
||||
{
|
||||
return mInner->HasArcIn(aNode, aArc, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::HasArcOut(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aArc,
|
||||
PRBool* _retval)
|
||||
{
|
||||
return mInner->HasArcOut(aSource, aArc, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::ArcLabelsIn(nsIRDFNode* aNode,
|
||||
nsISimpleEnumerator** aLabels)
|
||||
{
|
||||
return mInner->ArcLabelsIn(aNode, aLabels);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::ArcLabelsOut(nsIRDFResource* aSource,
|
||||
nsISimpleEnumerator** aLabels)
|
||||
{
|
||||
return mInner->ArcLabelsIn(aSource, aLabels);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetAllResources(nsISimpleEnumerator** aResult)
|
||||
{
|
||||
return mInner->GetAllResources(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetAllCmds(nsIRDFResource* aSource,
|
||||
nsISimpleEnumerator** aCommands)
|
||||
{
|
||||
return mInner->GetAllCmds(aSource, aCommands);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::IsCommandEnabled(nsISupportsArray* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray* aArguments,
|
||||
PRBool* aResult)
|
||||
{
|
||||
return mInner->IsCommandEnabled(aSources, aCommand, aArguments, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::DoCommand(nsISupportsArray* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray* aArguments)
|
||||
{
|
||||
return mInner->DoCommand(aSources, aCommand, aArguments);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::BeginUpdateBatch()
|
||||
{
|
||||
return mInner->BeginUpdateBatch();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::EndUpdateBatch()
|
||||
{
|
||||
return mInner->EndUpdateBatch();
|
||||
}
|
||||
|
||||
|
||||
// nsIRDFRemoteDataSource
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::GetLoaded(PRBool* aResult)
|
||||
{
|
||||
nsCOMPtr<nsIRDFRemoteDataSource> remote(do_QueryInterface(mInner));
|
||||
return remote->GetLoaded(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::Init(const char* aURI)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::Refresh(PRBool aBlocking)
|
||||
{
|
||||
nsCOMPtr<nsIRDFRemoteDataSource> remote(do_QueryInterface(mInner));
|
||||
return remote->Refresh(aBlocking);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::Flush()
|
||||
{
|
||||
nsCOMPtr<nsIRDFRemoteDataSource> remote(do_QueryInterface(mInner));
|
||||
return remote->Flush();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlService::FlushTo(const char *aURI)
|
||||
{
|
||||
nsCOMPtr<nsIRDFRemoteDataSource> remote(do_QueryInterface(mInner));
|
||||
return remote->FlushTo(aURI);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
mozSqlService::EnsureAliasesContainer()
|
||||
{
|
||||
if (! mAliasesContainer) {
|
||||
PRBool isContainer;
|
||||
nsresult rv = gRDFContainerUtils->IsContainer(mInner, kSQL_AliasesRoot, &isContainer);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!isContainer) {
|
||||
rv = gRDFContainerUtils->MakeSeq(mInner, kSQL_AliasesRoot, getter_AddRefs(mAliasesContainer));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
mAliasesContainer = do_CreateInstance(NS_RDF_CONTRACTID "/container;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = mAliasesContainer->Init(mInner, kSQL_AliasesRoot);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
52
mozilla/extensions/sql/base/src/mozSqlService.h
Normal file
52
mozilla/extensions/sql/base/src/mozSqlService.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef mozSqlService_h
|
||||
#define mozSqlService_h
|
||||
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFRemoteDataSource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFContainerUtils.h"
|
||||
#include "mozISqlService.h"
|
||||
|
||||
#define MOZ_SQLSERVICE_CLASSNAME "SQL service"
|
||||
#define MOZ_SQLSERVICE_CID \
|
||||
{0x1ceb35b7, 0xdaa8, 0x4ce4, {0xac, 0x67, 0x12, 0x5f, 0xb1, 0x7c, 0xb0, 0x19}}
|
||||
#define MOZ_SQLSERVICE_CONTRACTID "@mozilla.org/sql/service;1"
|
||||
#define MOZ_SQLDATASOURCE_CONTRACTID "@mozilla.org/rdf/datasource;1?name=sql"
|
||||
|
||||
class mozSqlService : public mozISqlService,
|
||||
public nsIRDFDataSource,
|
||||
public nsIRDFRemoteDataSource
|
||||
{
|
||||
public:
|
||||
mozSqlService();
|
||||
virtual ~mozSqlService();
|
||||
nsresult Init();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_MOZISQLSERVICE
|
||||
NS_DECL_NSIRDFDATASOURCE
|
||||
NS_DECL_NSIRDFREMOTEDATASOURCE
|
||||
|
||||
protected:
|
||||
nsresult EnsureAliasesContainer();
|
||||
|
||||
private:
|
||||
static nsIRDFService* gRDFService;
|
||||
static nsIRDFContainerUtils* gRDFContainerUtils;
|
||||
|
||||
static nsIRDFResource* kSQL_AliasesRoot;
|
||||
static nsIRDFResource* kSQL_Name;
|
||||
static nsIRDFResource* kSQL_Type;
|
||||
static nsIRDFResource* kSQL_Hostname;
|
||||
static nsIRDFResource* kSQL_Port;
|
||||
static nsIRDFResource* kSQL_Database;
|
||||
|
||||
nsString mErrorMessage;
|
||||
nsCOMPtr<nsIRDFDataSource> mInner;
|
||||
nsCOMPtr<nsIRDFContainer> mAliasesContainer;
|
||||
nsSupportsHashtable* mConnectionCache;
|
||||
|
||||
};
|
||||
|
||||
#endif /* mozSqlService_h */
|
||||
21
mozilla/extensions/sql/build/Makefile.in
Normal file
21
mozilla/extensions/sql/build/Makefile.in
Normal file
@@ -0,0 +1,21 @@
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = \
|
||||
src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
XPI_FILE = sql-$(shell date +%Y%m%d)-$(OS_ARCH).xpi
|
||||
|
||||
xpi:
|
||||
zip -j $(DIST)/$(XPI_FILE) $(srcdir)/install.js
|
||||
cd $(DIST); zip -r $(XPI_FILE) \
|
||||
bin/components/sql.xpt \
|
||||
bin/components/sqlpgsql.xpt \
|
||||
bin/components/$(LIB_PREFIX)sql$(DLL_SUFFIX) \
|
||||
bin/chrome/sql.jar
|
||||
58
mozilla/extensions/sql/build/install.js
Normal file
58
mozilla/extensions/sql/build/install.js
Normal file
@@ -0,0 +1,58 @@
|
||||
// this function verifies disk space in kilobytes
|
||||
function verifyDiskSpace(dirPath, spaceRequired)
|
||||
{
|
||||
var spaceAvailable;
|
||||
|
||||
// Get the available disk space on the given path
|
||||
spaceAvailable = fileGetDiskSpaceAvailable(dirPath);
|
||||
|
||||
// Convert the available disk space into kilobytes
|
||||
spaceAvailable = parseInt(spaceAvailable / 1024);
|
||||
|
||||
// do the verification
|
||||
if(spaceAvailable < spaceRequired)
|
||||
{
|
||||
logComment("Insufficient disk space: " + dirPath);
|
||||
logComment(" required : " + spaceRequired + " K");
|
||||
logComment(" available: " + spaceAvailable + " K");
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
var srDest = 200;
|
||||
|
||||
var err = initInstall("SQL Support", "SQL", "0.1");
|
||||
logComment("initInstall: " + err);
|
||||
|
||||
var fProgram = getFolder("Program");
|
||||
logComment("fProgram: " + fProgram);
|
||||
|
||||
if (verifyDiskSpace(fProgram, srDest))
|
||||
{
|
||||
err = addDirectory("Program", "0.1", "bin", fProgram, "", true);
|
||||
|
||||
logComment("addDirectory() returned: " + err);
|
||||
|
||||
var chromeFolder = getFolder("Chrome", "sql.jar");
|
||||
registerChrome(CONTENT | DELAYED_CHROME, chromeFolder, "content/sql/");
|
||||
registerChrome(LOCALE | DELAYED_CHROME, chromeFolder, "locale/en-US/sql/");
|
||||
|
||||
err = getLastError();
|
||||
if (err == ACCESS_DENIED) {
|
||||
alert("Unable to write to program directory " + fProgram + ".\n You will need to restart the browser with administrator/root privileges to install this software. After installing as root (or administrator), you will need to restart the browser one more time to register the installed software.\n After the second restart, you can go back to running the browser without privileges!");
|
||||
cancelInstall(err);
|
||||
logComment("cancelInstall() due to error: " + err);
|
||||
}
|
||||
else if (err != SUCCESS) {
|
||||
cancelInstall(err);
|
||||
logComment("cancelInstall() due to error: " + err);
|
||||
}
|
||||
else {
|
||||
performInstall();
|
||||
logComment("performInstall() returned: " + err);
|
||||
}
|
||||
}
|
||||
else
|
||||
cancelInstall(INSUFFICIENT_DISK_SPACE);
|
||||
40
mozilla/extensions/sql/build/src/Makefile.in
Normal file
40
mozilla/extensions/sql/build/src/Makefile.in
Normal file
@@ -0,0 +1,40 @@
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = sql
|
||||
MODULE_NAME = sqlModule
|
||||
LIBRARY_NAME = sql
|
||||
SHORT_LIBNAME = sql
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
rdf \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
mozSqlModule.cpp
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)sqlbase_s.$(LIB_SUFFIX)
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_ENABLE_PGSQL
|
||||
DEFINES += -DMOZ_ENABLE_PGSQL
|
||||
SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)sqlpgsql_s.$(LIB_SUFFIX)
|
||||
EXTRA_DSO_LDOPTS += -L$(MOZ_PGSQL_LIBS) -lpq
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifdef MOZ_ENABLE_PGSQL
|
||||
INCLUDES += -I$(MOZ_PGSQL_INCLUDES)
|
||||
endif
|
||||
33
mozilla/extensions/sql/build/src/mozSqlModule.cpp
Normal file
33
mozilla/extensions/sql/build/src/mozSqlModule.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "mozSqlService.h"
|
||||
#ifdef MOZ_ENABLE_PGSQL
|
||||
#include "mozSqlConnectionPgsql.h"
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozSqlService, Init)
|
||||
#ifdef MOZ_ENABLE_PGSQL
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(mozSqlConnectionPgsql)
|
||||
#endif
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ MOZ_SQLSERVICE_CLASSNAME,
|
||||
MOZ_SQLSERVICE_CID,
|
||||
MOZ_SQLSERVICE_CONTRACTID,
|
||||
mozSqlServiceConstructor
|
||||
},
|
||||
{ MOZ_SQLSERVICE_CLASSNAME,
|
||||
MOZ_SQLSERVICE_CID,
|
||||
MOZ_SQLDATASOURCE_CONTRACTID,
|
||||
mozSqlServiceConstructor
|
||||
},
|
||||
#ifdef MOZ_ENABLE_PGSQL
|
||||
{ MOZ_SQLCONNECTIONPGSQL_CLASSNAME,
|
||||
MOZ_SQLCONNECTIONPGSQL_CID,
|
||||
MOZ_SQLCONNECTIONPGSQL_CONTRACTID,
|
||||
mozSqlConnectionPgsqlConstructor
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("sql", components)
|
||||
10
mozilla/extensions/sql/pgsql/Makefile.in
Normal file
10
mozilla/extensions/sql/pgsql/Makefile.in
Normal file
@@ -0,0 +1,10 @@
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
DIRS = \
|
||||
public \
|
||||
src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
14
mozilla/extensions/sql/pgsql/public/Makefile.in
Normal file
14
mozilla/extensions/sql/pgsql/public/Makefile.in
Normal file
@@ -0,0 +1,14 @@
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
MODULE = sql
|
||||
XPIDL_MODULE = sqlpgsql
|
||||
|
||||
XPIDLSRCS = \
|
||||
mozISqlConnectionPgsql.idl \
|
||||
mozISqlResultPgsql.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(0cf1eefe-611d-48fa-ae27-0a6f40d6a33e)]
|
||||
|
||||
interface mozISqlConnectionPgsql : nsISupports
|
||||
{
|
||||
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(f6573169-286d-4a20-8253-9abb07bdba29)]
|
||||
|
||||
interface mozISqlResultPgsql : nsISupports
|
||||
{
|
||||
|
||||
};
|
||||
28
mozilla/extensions/sql/pgsql/src/Makefile.in
Normal file
28
mozilla/extensions/sql/pgsql/src/Makefile.in
Normal file
@@ -0,0 +1,28 @@
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = sql
|
||||
LIBRARY_NAME = sqlpgsql_s
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
locale \
|
||||
rdf \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
mozSqlConnectionPgsql.cpp \
|
||||
mozSqlResultPgsql.cpp
|
||||
|
||||
EXPORTS = \
|
||||
mozSqlConnectionPgsql.h \
|
||||
mozSqlResultPgsql.h
|
||||
|
||||
FORCE_STATIC_LIB=1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(MOZ_PGSQL_INCLUDES)
|
||||
240
mozilla/extensions/sql/pgsql/src/mozSqlConnectionPgsql.cpp
Normal file
240
mozilla/extensions/sql/pgsql/src/mozSqlConnectionPgsql.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
#include "prprf.h"
|
||||
#include "mozSqlConnectionPgsql.h"
|
||||
#include "mozSqlResultPgsql.h"
|
||||
|
||||
mozSqlConnectionPgsql::mozSqlConnectionPgsql()
|
||||
: mConnection(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
mozSqlConnectionPgsql::~mozSqlConnectionPgsql()
|
||||
{
|
||||
if (mConnection)
|
||||
PQfinish(mConnection);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(mozSqlConnectionPgsql, mozSqlConnection)
|
||||
NS_IMPL_RELEASE_INHERITED(mozSqlConnectionPgsql, mozSqlConnection)
|
||||
|
||||
// QueryInterface
|
||||
NS_INTERFACE_MAP_BEGIN(mozSqlConnectionPgsql)
|
||||
NS_INTERFACE_MAP_ENTRY(mozISqlConnectionPgsql)
|
||||
NS_INTERFACE_MAP_END_INHERITING(mozSqlConnection)
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnectionPgsql::Init(const nsAString & aHost, PRInt32 aPort,
|
||||
const nsAString & aDatabase, const nsAString & aUsername,
|
||||
const nsAString & aPassword)
|
||||
{
|
||||
if (mConnection)
|
||||
return NS_OK;
|
||||
|
||||
if (aPort == -1)
|
||||
aPort = 5432;
|
||||
char port[11];
|
||||
char options[] = "";
|
||||
char tty[] = "";
|
||||
PR_snprintf(port, 11, "%d", aPort);
|
||||
|
||||
mConnection = PQsetdbLogin(NS_ConvertUCS2toUTF8(aHost).get(),
|
||||
port, options, tty,
|
||||
NS_ConvertUCS2toUTF8(aDatabase).get(),
|
||||
NS_ConvertUCS2toUTF8(aUsername).get(),
|
||||
NS_ConvertUCS2toUTF8(aPassword).get());
|
||||
|
||||
return Setup();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSqlConnectionPgsql::GetPrimaryKeys(const nsAString& aSchema, const nsAString& aTable, mozISqlResult** _retval)
|
||||
{
|
||||
nsAutoString select;
|
||||
nsAutoString from;
|
||||
nsAutoString where;
|
||||
if (mVersion >= SERVER_VERSION(7,3,0)) {
|
||||
select = NS_LITERAL_STRING("SELECT n.nspname AS TABLE_SCHEM, ");
|
||||
from = NS_LITERAL_STRING(" FROM pg_catalog.pg_namespace n, pg_catalog.pg_class ct, pg_catalog.pg_class ci, pg_catalog.pg_attribute a, pg_catalog.pg_index i");
|
||||
where = NS_LITERAL_STRING(" AND ct.relnamespace = n.oid ");
|
||||
if (!aSchema.IsEmpty()) {
|
||||
where.Append(NS_LITERAL_STRING(" AND n.nspname = '") + aSchema);
|
||||
where.Append(PRUnichar('\''));
|
||||
}
|
||||
}
|
||||
else {
|
||||
select = NS_LITERAL_STRING("SELECT NULL AS TABLE_SCHEM, ");
|
||||
from = NS_LITERAL_STRING(" FROM pg_class ct, pg_class ci, pg_attribute a, pg_index i ");
|
||||
}
|
||||
|
||||
if (!aTable.IsEmpty()) {
|
||||
where.Append(NS_LITERAL_STRING(" AND ct.relname = '") + aTable);
|
||||
where.Append(PRUnichar('\''));
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_STRING(select2, " ct.relname AS TABLE_NAME, a.attname AS COLUMN_NAME, a.attnum AS KEY_SEQ, ci.relname AS PK_NAME ");
|
||||
NS_NAMED_LITERAL_STRING(where2, " WHERE ct.oid=i.indrelid AND ci.oid=i.indexrelid AND a.attrelid=ci.oid AND i.indisprimary ");
|
||||
NS_NAMED_LITERAL_STRING(order2, " ORDER BY table_name, pk_name, key_seq");
|
||||
|
||||
return RealExec(select + select2 + from + where2 + where + order2, _retval, nsnull);
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlConnectionPgsql::Setup()
|
||||
{
|
||||
if (PQstatus(mConnection) == CONNECTION_BAD) {
|
||||
mErrorMessage.Assign(NS_ConvertUTF8toUCS2(PQerrorMessage(mConnection)));
|
||||
mConnection = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PQsetClientEncoding(mConnection, "UNICODE");
|
||||
|
||||
/*
|
||||
PGresult* result = PQexec(mConnection, "SET DATESTYLE TO US");
|
||||
PRInt32 stat = PQresultStatus(result);
|
||||
if (stat != PGRES_COMMAND_OK) {
|
||||
mErrorMessage.Assign(NS_ConvertUTF8toUCS2(PQresultErrorMessage(result)));
|
||||
PQfinish(mConnection);
|
||||
mConnection = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*/
|
||||
|
||||
PGresult* result = PQexec(mConnection, "select version()");
|
||||
PRInt32 stat = PQresultStatus(result);
|
||||
if (stat != PGRES_TUPLES_OK) {
|
||||
mErrorMessage.Assign(NS_ConvertUTF8toUCS2(PQresultErrorMessage(result)));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
char* version = PQgetvalue(result, 0, 0);
|
||||
NS_ConvertUTF8toUCS2 buffer(version);
|
||||
nsAString::const_iterator start, end, iter;
|
||||
buffer.BeginReading(iter);
|
||||
buffer.EndReading(end);
|
||||
while (iter != end && !nsCRT::IsAsciiSpace(*iter))
|
||||
++iter;
|
||||
while (iter != end && nsCRT::IsAsciiSpace(*iter))
|
||||
++iter;
|
||||
start = iter;
|
||||
while (iter != end && !nsCRT::IsAsciiSpace(*iter))
|
||||
++iter;
|
||||
mServerVersion = Substring(start,iter);
|
||||
|
||||
PRInt32 numbers[3] = {0,0,0};
|
||||
mServerVersion.BeginReading(iter);
|
||||
mServerVersion.EndReading(end);
|
||||
for (PRInt32 i = 0; i < 3; i++) {
|
||||
start = iter;
|
||||
while (iter != end && *iter != PRUnichar('.'))
|
||||
++iter;
|
||||
nsAutoString v(Substring(start,iter));
|
||||
PRInt32 err;
|
||||
numbers[i] = v.ToInteger(&err);
|
||||
while (iter != end && *iter == PRUnichar('.'))
|
||||
++iter;
|
||||
}
|
||||
mVersion = SERVER_VERSION(numbers[0], numbers[1], numbers[2]);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlConnectionPgsql::RealExec(const nsAString& aQuery,
|
||||
mozISqlResult** aResult, PRInt32* aAffectedRows)
|
||||
{
|
||||
if (! mConnection)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PGresult* r;
|
||||
r = PQexec(mConnection, NS_ConvertUCS2toUTF8(aQuery).get());
|
||||
PRInt32 stat = PQresultStatus(r);
|
||||
|
||||
if (PQstatus(mConnection) == CONNECTION_BAD) {
|
||||
PQreset(mConnection);
|
||||
nsresult rv = Setup();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
r = PQexec(mConnection, NS_ConvertUCS2toUTF8(aQuery).get());
|
||||
stat = PQresultStatus(r);
|
||||
}
|
||||
|
||||
if (stat == PGRES_TUPLES_OK) {
|
||||
if (!aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
static char select1[] = "select t.oid, case when t.typbasetype = 0 then t.typname else (select t2.typname from pg_type t2 where t2.oid=t.typbasetype) end as typname from pg_type t where t.oid in (";
|
||||
static char select2[] = "select oid, typname from pg_type where oid in (";
|
||||
char* select;
|
||||
if (mVersion >= SERVER_VERSION(7,3,0))
|
||||
select = select1;
|
||||
else
|
||||
select = select2;
|
||||
PRInt32 columnCount = PQnfields(r);
|
||||
char* query = (char*)malloc(strlen(select) + columnCount * 11 + 2);
|
||||
strcpy(query, select);
|
||||
for (PRInt32 i = 0; i < columnCount; i++) {
|
||||
PRInt32 oid = PQftype(r, i);
|
||||
char oidStr[11];
|
||||
if (i)
|
||||
sprintf(oidStr, ",%d", oid);
|
||||
else
|
||||
sprintf(oidStr, "%d", oid);
|
||||
strcat(query, oidStr);
|
||||
}
|
||||
strcat(query, ")");
|
||||
PGresult* types = PQexec(mConnection, query);
|
||||
free(query);
|
||||
stat = PQresultStatus(types);
|
||||
if (stat != PGRES_TUPLES_OK) {
|
||||
mErrorMessage.Assign(NS_ConvertUTF8toUCS2(PQresultErrorMessage(types)));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (*aResult) {
|
||||
((mozSqlResultPgsql*)*aResult)->SetResult(r, types);
|
||||
nsresult rv = ((mozSqlResult*)*aResult)->Rebuild();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ADDREF(*aResult);
|
||||
}
|
||||
else {
|
||||
mozSqlResult* result = new mozSqlResultPgsql(this, aQuery);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
((mozSqlResultPgsql*)result)->SetResult(r, types);
|
||||
nsresult rv = result->Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ADDREF(*aResult = result);
|
||||
}
|
||||
}
|
||||
else if (stat == PGRES_COMMAND_OK) {
|
||||
if (!aAffectedRows)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
PR_sscanf(PQcmdTuples(r), "%d", aAffectedRows);
|
||||
mLastID = PQoidValue(r);
|
||||
}
|
||||
else {
|
||||
mErrorMessage.Assign(NS_ConvertUTF8toUCS2(PQresultErrorMessage(r)));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlConnectionPgsql::CancelExec()
|
||||
{
|
||||
if (!PQrequestCancel(mConnection)) {
|
||||
mErrorMessage.Assign(NS_ConvertUTF8toUCS2(PQerrorMessage(mConnection)));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlConnectionPgsql::GetIDName(nsAString& aIDName)
|
||||
{
|
||||
aIDName = NS_LITERAL_STRING("OID");
|
||||
return NS_OK;
|
||||
}
|
||||
47
mozilla/extensions/sql/pgsql/src/mozSqlConnectionPgsql.h
Normal file
47
mozilla/extensions/sql/pgsql/src/mozSqlConnectionPgsql.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef mozSqlConnectionPgsql_h
|
||||
#define mozSqlConnectionPgsql_h
|
||||
|
||||
#include "libpq-fe.h"
|
||||
#include "mozSqlConnection.h"
|
||||
#include "mozISqlConnectionPgsql.h"
|
||||
|
||||
#define MOZ_SQLCONNECTIONPGSQL_CLASSNAME "PosgreSQL SQL Connection"
|
||||
#define MOZ_SQLCONNECTIONPGSQL_CID \
|
||||
{0x0cf1eefe, 0x611d, 0x48fa, {0xae, 0x27, 0x0a, 0x6f, 0x40, 0xd6, 0xa3, 0x3e }}
|
||||
#define MOZ_SQLCONNECTIONPGSQL_CONTRACTID "@mozilla.org/sql/connection;1?type=pgsql"
|
||||
|
||||
#define SERVER_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
||||
|
||||
class mozSqlConnectionPgsql : public mozSqlConnection,
|
||||
public mozISqlConnectionPgsql
|
||||
{
|
||||
public:
|
||||
mozSqlConnectionPgsql();
|
||||
virtual ~mozSqlConnectionPgsql();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(const nsAString& aHost, PRInt32 aPort,
|
||||
const nsAString& aDatabase, const nsAString& aUsername,
|
||||
const nsAString& aPassword);
|
||||
|
||||
NS_IMETHOD GetPrimaryKeys(const nsAString& aSchema, const nsAString& aTable, mozISqlResult** _retval);
|
||||
|
||||
NS_DECL_MOZISQLCONNECTIONPGSQL
|
||||
|
||||
protected:
|
||||
nsresult Setup();
|
||||
|
||||
virtual nsresult RealExec(const nsAString& aQuery,
|
||||
mozISqlResult** aResult, PRInt32* aAffectedRows);
|
||||
|
||||
virtual nsresult CancelExec();
|
||||
|
||||
virtual nsresult GetIDName(nsAString& aIDName);
|
||||
|
||||
private:
|
||||
PGconn* mConnection;
|
||||
PRInt32 mVersion;
|
||||
};
|
||||
|
||||
#endif // mozSqlConnectionPgsql_h
|
||||
235
mozilla/extensions/sql/pgsql/src/mozSqlResultPgsql.cpp
Normal file
235
mozilla/extensions/sql/pgsql/src/mozSqlResultPgsql.cpp
Normal file
@@ -0,0 +1,235 @@
|
||||
|
||||
#include "prprf.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "mozSqlResultPgsql.h"
|
||||
|
||||
mozSqlResultPgsql::mozSqlResultPgsql(mozISqlConnection* aConnection,
|
||||
const nsAString& aQuery)
|
||||
: mozSqlResult(aConnection, aQuery),
|
||||
mResult(nsnull),
|
||||
mTypes(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
mozSqlResultPgsql::SetResult(PGresult* aResult,
|
||||
PGresult* aTypes)
|
||||
{
|
||||
mResult = aResult;
|
||||
mTypes = aTypes;
|
||||
}
|
||||
|
||||
mozSqlResultPgsql::~mozSqlResultPgsql()
|
||||
{
|
||||
ClearNativeResult();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(mozSqlResultPgsql, mozSqlResult)
|
||||
NS_IMPL_RELEASE_INHERITED(mozSqlResultPgsql, mozSqlResult)
|
||||
|
||||
// QueryInterface
|
||||
NS_INTERFACE_MAP_BEGIN(mozSqlResultPgsql)
|
||||
NS_INTERFACE_MAP_ENTRY(mozISqlResultPgsql)
|
||||
NS_INTERFACE_MAP_END_INHERITING(mozSqlResult)
|
||||
|
||||
PRInt32
|
||||
mozSqlResultPgsql::GetColType(PRInt32 aColumnIndex)
|
||||
{
|
||||
PRInt32 oid = PQftype(mResult, aColumnIndex);
|
||||
|
||||
for (PRInt32 i = 0; i < PQntuples(mTypes); i++) {
|
||||
char* value = PQgetvalue(mTypes, i, 0);
|
||||
PRInt32 o;
|
||||
PR_sscanf(value, "%d", &o);
|
||||
if (o == oid) {
|
||||
char* type = PQgetvalue(mTypes, i, 1);
|
||||
if (! strcmp(type, "int2"))
|
||||
return mozISqlResult::TYPE_INT;
|
||||
else if (! strcmp(type, "int4"))
|
||||
return mozISqlResult::TYPE_INT;
|
||||
else if (! strcmp(type, "float4"))
|
||||
return mozISqlResult::TYPE_STRING;
|
||||
else if (! strcmp(type, "numeric"))
|
||||
return mozISqlResult::TYPE_STRING;
|
||||
else if (! strcmp(type, "date"))
|
||||
return mozISqlResult::TYPE_STRING;
|
||||
else if (! strcmp(type, "time"))
|
||||
return mozISqlResult::TYPE_STRING;
|
||||
else if (! strcmp(type, "timestamp"))
|
||||
return mozISqlResult::TYPE_STRING;
|
||||
else if (! strcmp(type, "bool"))
|
||||
return mozISqlResult::TYPE_BOOL;
|
||||
else
|
||||
return mozISqlResult::TYPE_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
return mozISqlResult::TYPE_STRING;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlResultPgsql::BuildColumnInfo()
|
||||
{
|
||||
for (PRInt32 i = 0; i < PQnfields(mResult); i++) {
|
||||
char* n = PQfname(mResult, i);
|
||||
PRUnichar* name = ToNewUnicode(NS_ConvertUTF8toUCS2(n));
|
||||
PRInt32 type = GetColType(i);
|
||||
PRInt32 size = PQfsize(mResult, i);
|
||||
PRInt32 mod = PQfmod(mResult, i);
|
||||
|
||||
nsCAutoString uri(NS_LITERAL_CSTRING("http://www.mozilla.org/SQL-rdf#"));
|
||||
uri.Append(n);
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
gRDFService->GetResource(uri, getter_AddRefs(property));
|
||||
|
||||
ColumnInfo* columnInfo = ColumnInfo::Create(mAllocator, name, type, size, mod, property);
|
||||
mColumnInfo.AppendElement(columnInfo);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlResultPgsql::BuildRows()
|
||||
{
|
||||
for(PRInt32 i = 0; i < PQntuples(mResult); i++) {
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
nsresult rv = gRDFService->GetAnonymousResource(getter_AddRefs(resource));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
Row* row = Row::Create(mAllocator, resource, mColumnInfo);
|
||||
|
||||
for (PRInt32 j = 0; j < mColumnInfo.Count(); j++) {
|
||||
if (! PQgetisnull(mResult, i, j)) {
|
||||
char* value = PQgetvalue(mResult, i, j);
|
||||
Cell* cell = row->mCells[j];
|
||||
cell->SetNull(PR_FALSE);
|
||||
PRInt32 type = cell->GetType();
|
||||
if (type == mozISqlResult::TYPE_STRING)
|
||||
cell->SetString(ToNewUnicode(NS_ConvertUTF8toUCS2(value)));
|
||||
else if (type == mozISqlResult::TYPE_INT)
|
||||
PR_sscanf(value, "%d", &cell->mInt);
|
||||
else if (type == mozISqlResult::TYPE_FLOAT)
|
||||
PR_sscanf(value, "%f", &cell->mFloat);
|
||||
else if (type == mozISqlResult::TYPE_DECIMAL)
|
||||
PR_sscanf(value, "%f", &cell->mFloat);
|
||||
else if (type == mozISqlResult::TYPE_DATE ||
|
||||
type == mozISqlResult::TYPE_TIME ||
|
||||
type == mozISqlResult::TYPE_DATETIME)
|
||||
PR_ParseTimeString(value, PR_FALSE, &cell->mDate);
|
||||
else if (type == mozISqlResult::TYPE_BOOL)
|
||||
cell->mBool = !strcmp(value, "t");
|
||||
}
|
||||
}
|
||||
|
||||
mRows.AppendElement(row);
|
||||
nsVoidKey key(resource);
|
||||
mSources.Put(&key, row);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
mozSqlResultPgsql::ClearNativeResult()
|
||||
{
|
||||
if (mResult) {
|
||||
PQclear(mResult);
|
||||
mResult = nsnull;
|
||||
}
|
||||
if (mTypes) {
|
||||
PQclear(mTypes);
|
||||
mTypes = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlResultPgsql::EnsureTablePrivileges()
|
||||
{
|
||||
nsresult rv = EnsureTableName();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_NAMED_LITERAL_STRING(select, "select ");
|
||||
NS_NAMED_LITERAL_STRING(func, "has_table_privilege(SESSION_USER, '");
|
||||
NS_NAMED_LITERAL_STRING(comma, ", ");
|
||||
NS_NAMED_LITERAL_STRING(ins, "', 'INSERT')");
|
||||
NS_NAMED_LITERAL_STRING(upd, "', 'UPDATE')");
|
||||
NS_NAMED_LITERAL_STRING(del, "','DELETE')");
|
||||
|
||||
nsCOMPtr<mozISqlResult> result;
|
||||
rv = mConnection->ExecuteQuery(
|
||||
select + func + mTableName + ins +
|
||||
comma + func + mTableName + upd +
|
||||
comma + func + mTableName + del,
|
||||
getter_AddRefs(result));
|
||||
if (NS_FAILED(rv)) {
|
||||
mConnection->GetErrorMessage(mErrorMessage);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<mozISqlResultEnumerator> enumerator;
|
||||
rv = result->Enumerate(getter_AddRefs(enumerator));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = enumerator->First();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = enumerator->GetBool(0, &mCanInsert);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = enumerator->GetBool(1, &mCanUpdate);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
return enumerator->GetBool(2, &mCanDelete);
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlResultPgsql::CanInsert(PRBool* _retval)
|
||||
{
|
||||
if (mCanInsert >= 0) {
|
||||
*_retval = mCanInsert;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = EnsureTablePrivileges();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
*_retval = mCanInsert;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlResultPgsql::CanUpdate(PRBool* _retval)
|
||||
{
|
||||
if (mCanUpdate >= 0) {
|
||||
*_retval = mCanUpdate;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = EnsureTablePrivileges();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
*_retval = mCanUpdate;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSqlResultPgsql::CanDelete(PRBool* _retval)
|
||||
{
|
||||
if (mCanDelete >= 0) {
|
||||
*_retval = mCanDelete;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = EnsureTablePrivileges();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
*_retval = mCanDelete;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
39
mozilla/extensions/sql/pgsql/src/mozSqlResultPgsql.h
Normal file
39
mozilla/extensions/sql/pgsql/src/mozSqlResultPgsql.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef mozSqlResultPgsql_h
|
||||
#define mozSqlResultPgsql_h
|
||||
|
||||
#include "libpq-fe.h"
|
||||
#include "mozSqlResult.h"
|
||||
#include "mozISqlResultPgsql.h"
|
||||
|
||||
class mozSqlResultPgsql : public mozSqlResult,
|
||||
public mozISqlResultPgsql
|
||||
{
|
||||
public:
|
||||
mozSqlResultPgsql(mozISqlConnection* aConnection,
|
||||
const nsAString& aQuery);
|
||||
void SetResult(PGresult* aResult,
|
||||
PGresult* aTypes);
|
||||
virtual ~mozSqlResultPgsql();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_MOZISQLRESULTPGSQL
|
||||
|
||||
protected:
|
||||
PRInt32 GetColType(PRInt32 aColumnIndex);
|
||||
|
||||
virtual nsresult BuildColumnInfo();
|
||||
virtual nsresult BuildRows();
|
||||
virtual void ClearNativeResult();
|
||||
|
||||
nsresult EnsureTablePrivileges();
|
||||
virtual nsresult CanInsert(PRBool* _retval);
|
||||
virtual nsresult CanUpdate(PRBool* _retval);
|
||||
virtual nsresult CanDelete(PRBool* _retval);
|
||||
|
||||
private:
|
||||
PGresult* mResult;
|
||||
PGresult* mTypes;
|
||||
};
|
||||
|
||||
#endif // mozSqlResultPgsql_h
|
||||
15
mozilla/extensions/sql/sqltest/Makefile.in
Normal file
15
mozilla/extensions/sql/sqltest/Makefile.in
Normal file
@@ -0,0 +1,15 @@
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
XPI_FILE = sqltest-$(shell date +%Y%m%d).xpi
|
||||
|
||||
xpi:
|
||||
zip -j $(DIST)/$(XPI_FILE) $(srcdir)/install.js
|
||||
cd $(DIST); zip -r $(XPI_FILE) \
|
||||
bin/chrome/sqltest.jar
|
||||
17
mozilla/extensions/sql/sqltest/contents.rdf
Normal file
17
mozilla/extensions/sql/sqltest/contents.rdf
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
|
||||
|
||||
<!-- list all the packages being supplied by this jar -->
|
||||
<RDF:Seq about="urn:mozilla:package:root">
|
||||
<RDF:li resource="urn:mozilla:package:sqltest"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- package information -->
|
||||
<RDF:Description about="urn:mozilla:package:sqltest"
|
||||
chrome:displayName="SQL test"
|
||||
chrome:author="mozilla.org"
|
||||
chrome:name="sqltest">
|
||||
</RDF:Description>
|
||||
|
||||
</RDF:RDF>
|
||||
57
mozilla/extensions/sql/sqltest/install.js
Normal file
57
mozilla/extensions/sql/sqltest/install.js
Normal file
@@ -0,0 +1,57 @@
|
||||
// this function verifies disk space in kilobytes
|
||||
function verifyDiskSpace(dirPath, spaceRequired)
|
||||
{
|
||||
var spaceAvailable;
|
||||
|
||||
// Get the available disk space on the given path
|
||||
spaceAvailable = fileGetDiskSpaceAvailable(dirPath);
|
||||
|
||||
// Convert the available disk space into kilobytes
|
||||
spaceAvailable = parseInt(spaceAvailable / 1024);
|
||||
|
||||
// do the verification
|
||||
if(spaceAvailable < spaceRequired)
|
||||
{
|
||||
logComment("Insufficient disk space: " + dirPath);
|
||||
logComment(" required : " + spaceRequired + " K");
|
||||
logComment(" available: " + spaceAvailable + " K");
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
var srDest = 100;
|
||||
|
||||
var err = initInstall("SQL test", "SQLTEST", "0.1");
|
||||
logComment("initInstall: " + err);
|
||||
|
||||
var fProgram = getFolder("Program");
|
||||
logComment("fProgram: " + fProgram);
|
||||
|
||||
if (verifyDiskSpace(fProgram, srDest))
|
||||
{
|
||||
err = addDirectory("Program", "0.1", "bin", fProgram, "", true);
|
||||
|
||||
logComment("addDirectory() returned: " + err);
|
||||
|
||||
var chromeFolder = getFolder("Chrome", "sqltest.jar");
|
||||
registerChrome(CONTENT | DELAYED_CHROME, chromeFolder, "content/sqltest/");
|
||||
|
||||
err = getLastError();
|
||||
if (err == ACCESS_DENIED) {
|
||||
alert("Unable to write to program directory " + fProgram + ".\n You will need to restart the browser with administrator/root privileges to install this software. After installing as root (or administrator), you will need to restart the browser one more time to register the installed software.\n After the second restart, you can go back to running the browser without privileges!");
|
||||
cancelInstall(err);
|
||||
logComment("cancelInstall() due to error: " + err);
|
||||
}
|
||||
else if (err != SUCCESS) {
|
||||
cancelInstall(err);
|
||||
logComment("cancelInstall() due to error: " + err);
|
||||
}
|
||||
else {
|
||||
performInstall();
|
||||
logComment("performInstall() returned: " + err);
|
||||
}
|
||||
}
|
||||
else
|
||||
cancelInstall(INSUFFICIENT_DISK_SPACE);
|
||||
7
mozilla/extensions/sql/sqltest/jar.mn
Normal file
7
mozilla/extensions/sql/sqltest/jar.mn
Normal file
@@ -0,0 +1,7 @@
|
||||
sqltest.jar:
|
||||
content/sqltest/contents.rdf (contents.rdf)
|
||||
content/sqltest/sqltest.xul (sqltest.xul)
|
||||
content/sqltest/sqltest.js (sqltest.js)
|
||||
content/sqltest/sqltest.css (sqltest.css)
|
||||
content/sqltest/sqltestDialog.xul (sqltestDialog.xul)
|
||||
content/sqltest/sqltestDialog.js (sqltestDialog.js)
|
||||
8
mozilla/extensions/sql/sqltest/sqltest.css
Normal file
8
mozilla/extensions/sql/sqltest/sqltest.css
Normal file
@@ -0,0 +1,8 @@
|
||||
treechildren:-moz-tree-cell {
|
||||
border-right: 1px solid ThreeDFace;
|
||||
border-bottom: 1px solid ThreeDFace;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
height: 10px;
|
||||
}
|
||||
126
mozilla/extensions/sql/sqltest/sqltest.js
Normal file
126
mozilla/extensions/sql/sqltest/sqltest.js
Normal file
@@ -0,0 +1,126 @@
|
||||
const alias = "urn:aliases:sqltest";
|
||||
const complete = Components.interfaces.mozISqlRequest.STATUS_COMPLETE;
|
||||
|
||||
var connection;
|
||||
var result;
|
||||
|
||||
var startupObserver = {
|
||||
onStartRequest: function(request, ctxt) {
|
||||
},
|
||||
onStopRequest: function(request, ctxt) {
|
||||
if (request.status == complete) {
|
||||
result = request.result;
|
||||
var ds = result.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
|
||||
var menulist = document.getElementById("statesMenulist");
|
||||
menulist.database.AddDataSource(ds);
|
||||
menulist.builder.rebuild();
|
||||
menulist.selectedIndex = 0;
|
||||
|
||||
var tree = document.getElementById("statesTree");
|
||||
tree.database.AddDataSource(ds);
|
||||
tree.builder.rebuild();
|
||||
}
|
||||
else {
|
||||
alert(request.errorMessage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var observer = {
|
||||
onStartRequest: function(request, ctxt) {
|
||||
},
|
||||
|
||||
onStopRequest: function(request, ctxt) {
|
||||
if (request.status == complete) {
|
||||
var element = document.getElementById("asyncStateName");
|
||||
if (request.result.rowCount) {
|
||||
var enumerator = request.result.enumerate();
|
||||
enumerator.first();
|
||||
element.value = enumerator.getVariant(0);
|
||||
}
|
||||
else {
|
||||
element.value = "Not found";
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert(request.errorMessage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function init() {
|
||||
var service = Components.classes["@mozilla.org/sql/service;1"]
|
||||
.getService(Components.interfaces.mozISqlService);
|
||||
|
||||
if (!service.hasAlias(alias)) {
|
||||
alert("The alias for the sqltest was not defined.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
connection = service.getConnection(alias);
|
||||
}
|
||||
catch (ex) {
|
||||
alert(service.errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
var query = "select code, name from states";
|
||||
var request = connection.asyncExecuteQuery(query, null, startupObserver);
|
||||
}
|
||||
|
||||
function syncFindState() {
|
||||
var code = document.getElementById("syncStateCode").value
|
||||
var query = "select name from states where code = '" + code + "'";
|
||||
try {
|
||||
var result = connection.executeQuery(query);
|
||||
var element = document.getElementById("syncStateName");
|
||||
if (result.rowCount) {
|
||||
var enumerator = result.enumerate();
|
||||
enumerator.first();
|
||||
element.value = enumerator.getVariant(0);
|
||||
}
|
||||
else {
|
||||
element.value = "Not found";
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
alert(connection.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
function asyncFindState() {
|
||||
var code = document.getElementById("asyncStateCode").value;
|
||||
var query = "select name from states where code = '" + code + "'";
|
||||
var request = connection.asyncExecuteQuery(query, null, observer);
|
||||
}
|
||||
|
||||
function getSelectedRowIndex() {
|
||||
var tree = document.getElementById("statesTree");
|
||||
var currentIndex = tree.currentIndex;
|
||||
var resource = tree.builderView.getResourceAtIndex(currentIndex);
|
||||
var datasource = result.QueryInterface(Components.interfaces.mozISqlDataSource);
|
||||
return datasource.getIndexOfResource(resource);
|
||||
}
|
||||
|
||||
function doInsert() {
|
||||
window.openDialog("sqltestDialog.xul", "testDialog", "chrome,modal=yes,resizable=no", result);
|
||||
}
|
||||
|
||||
function doUpdate() {
|
||||
var rowIndex = this.getSelectedRowIndex();
|
||||
window.openDialog("sqltestDialog.xul", "testDialog", "chrome,modal=yes,resizable=no", result, rowIndex);
|
||||
}
|
||||
|
||||
function doDelete() {
|
||||
var rowIndex = this.getSelectedRowIndex();
|
||||
var enumerator = result.enumerate();
|
||||
enumerator.absolute(rowIndex);
|
||||
try {
|
||||
enumerator.deleteRow();
|
||||
}
|
||||
catch(ex) {
|
||||
alert(enumerator.errorMessage);
|
||||
}
|
||||
}
|
||||
118
mozilla/extensions/sql/sqltest/sqltest.xul
Normal file
118
mozilla/extensions/sql/sqltest/sqltest.xul
Normal file
@@ -0,0 +1,118 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="sqltest.css" type="text/css"?>
|
||||
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
orient="vertical"
|
||||
width="640" height="480"
|
||||
title="SQL test"
|
||||
onload="init()">
|
||||
|
||||
<script type="application/x-javascript" src="sqltest.js"/>
|
||||
|
||||
<popupset>
|
||||
<popup id="editContextMenu">
|
||||
<menuitem label="Insert" oncommand="doInsert()"/>
|
||||
<menuitem label="Update" oncommand="doUpdate()"/>
|
||||
<menuitem label="Delete" oncommand="doDelete()"/>
|
||||
</popup>
|
||||
</popupset>
|
||||
|
||||
<tabbox flex="1">
|
||||
<tabs>
|
||||
<tab label="Sync test"/>
|
||||
<tab label="Async test"/>
|
||||
<tab label="Widgets"/>
|
||||
</tabs>
|
||||
<tabpanels flex="1">
|
||||
<vbox>
|
||||
<text class="label" value="Type a state code and then hit ENTER. You should get a state name."/>
|
||||
<spacer class="spacer"/>
|
||||
<grid>
|
||||
<columns>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<text class="label" value="State code:"/>
|
||||
<hbox>
|
||||
<textbox id="syncStateCode" size="2" maxlength="2" onkeyup="if (event.keyCode == 13) syncFindState()"/>
|
||||
</hbox>
|
||||
</row>
|
||||
<row>
|
||||
<text class="label" value="State name:"/>
|
||||
<textbox id="syncStateName"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<text class="label" value="Type a state code and then hit ENTER. You should get a state name."/>
|
||||
<spacer class="spacer"/>
|
||||
<grid>
|
||||
<columns>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<text class="label" value="State code:"/>
|
||||
<hbox>
|
||||
<textbox id="asyncStateCode" size="2" maxlength="2" onkeyup="if (event.keyCode == 13) asyncFindState()"/>
|
||||
</hbox>
|
||||
</row>
|
||||
<row>
|
||||
<text class="label" value="State name:"/>
|
||||
<textbox id="asyncStateName"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<text class="label" value="You should see a menulist filled with all the states."/>
|
||||
<spacer class="spacer"/>
|
||||
<hbox>
|
||||
<menulist id="statesMenulist"
|
||||
datasources="rdf:null" ref="SQL:ResultRoot">
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem uri="..."
|
||||
value="rdf:http://www.mozilla.org/SQL-rdf#code"
|
||||
label="rdf:http://www.mozilla.org/SQL-rdf#name"/>
|
||||
</menupopup>
|
||||
</template>
|
||||
</menulist>
|
||||
</hbox>
|
||||
<spacer class="spacer"/>
|
||||
<text value="You should see codes and names of all states in this tree. You can even edit them using the context menu."/>
|
||||
<spacer class="spacer"/>
|
||||
<tree id="statesTree" flex="1"
|
||||
context="editContextMenu"
|
||||
seltype="single" enableColumnDrag="true"
|
||||
datasources="rdf:null" ref="SQL:ResultRoot" flags="dont-build-content">
|
||||
<treecols>
|
||||
<treecol id="codeCol"
|
||||
label="State code"
|
||||
sort="rdf:http://www.mozilla.org/SQL-rdf#code"
|
||||
sortActive="true" sortDirection="ascending"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="nameCol" flex="1"
|
||||
label="State name"
|
||||
sort="rdf:http://www.mozilla.org/SQL-rdf#name"/>
|
||||
</treecols>
|
||||
<template>
|
||||
<treechildren>
|
||||
<treeitem uri="rdf:*">
|
||||
<treerow>
|
||||
<treecell label="rdf:http://www.mozilla.org/SQL-rdf#code"/>
|
||||
<treecell label="rdf:http://www.mozilla.org/SQL-rdf#name"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</template>
|
||||
</tree>
|
||||
</vbox>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
|
||||
</window>
|
||||
41
mozilla/extensions/sql/sqltest/sqltestDialog.js
Normal file
41
mozilla/extensions/sql/sqltest/sqltestDialog.js
Normal file
@@ -0,0 +1,41 @@
|
||||
var result;
|
||||
var enumerator;
|
||||
|
||||
function init() {
|
||||
result = window.arguments[0];
|
||||
enumerator = result.enumerate();
|
||||
if (window.arguments.length == 2) {
|
||||
enumerator.absolute(window.arguments[1]);
|
||||
var columnCount = result.columnCount;
|
||||
for(var i = 0; i < columnCount; i++) {
|
||||
if (!enumerator.isNull(i)) {
|
||||
var element = document.getElementById(result.getColumnName(i));
|
||||
element.value = enumerator.getVariant(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onAccept() {
|
||||
var columnCount = result.columnCount;
|
||||
for (var i = 0; i < columnCount; i++) {
|
||||
var element = document.getElementById(result.getColumnName(i));
|
||||
if (element.value)
|
||||
enumerator.setVariant(i, element.value);
|
||||
else
|
||||
enumerator.setNull(i);
|
||||
}
|
||||
|
||||
try {
|
||||
if (window.arguments.length == 2)
|
||||
enumerator.updateRow();
|
||||
else
|
||||
enumerator.insertRow();
|
||||
}
|
||||
catch(ex) {
|
||||
alert(enumerator.errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
33
mozilla/extensions/sql/sqltest/sqltestDialog.xul
Normal file
33
mozilla/extensions/sql/sqltest/sqltestDialog.xul
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
|
||||
<dialog id="testDialog"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Test dialog"
|
||||
buttons="accept,cancel" buttonpack="center"
|
||||
ondialogaccept="return onAccept();"
|
||||
onload="init()">
|
||||
|
||||
<script type="application/x-javascript" src="sqltestDialog.js"/>
|
||||
|
||||
<grid flex="1">
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="Code:"/>
|
||||
<hbox>
|
||||
<textbox id="code" size="2" maxlength="2" oninput="this.value = this.value.toUpperCase()"/>
|
||||
</hbox>
|
||||
</row>
|
||||
<row>
|
||||
<label value="Name:"/>
|
||||
<textbox id="name" size="30" maxlength="30"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
</dialog>
|
||||
4
mozilla/extensions/sql/sqltest/states.sql
Normal file
4
mozilla/extensions/sql/sqltest/states.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
create table states (
|
||||
code varchar(2) primary key,
|
||||
name varchar(30)
|
||||
);
|
||||
51
mozilla/extensions/sql/sqltest/states.txt
Normal file
51
mozilla/extensions/sql/sqltest/states.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
AL Alabama
|
||||
AK Alaska
|
||||
AZ Arizona
|
||||
AR Arkansas
|
||||
CA California
|
||||
CO Colorado
|
||||
CT Connecticut
|
||||
DE Delaware
|
||||
FL Florida
|
||||
GA Georgia
|
||||
HI Hawaii
|
||||
ID Idaho
|
||||
IL Illinois
|
||||
IN Indiana
|
||||
IA Iowa
|
||||
KS Kansas
|
||||
KY Kentucky
|
||||
LA Louisiana
|
||||
ME Maine
|
||||
MD Maryland
|
||||
MA Massachusetts
|
||||
MI Michigan
|
||||
MN Minnesota
|
||||
MS Mississippi
|
||||
MO Missouri
|
||||
MT Montana
|
||||
NE Nebraska
|
||||
NV Nevada
|
||||
NH New Hampshire
|
||||
NJ New Jersey
|
||||
NM New Mexico
|
||||
NY New York
|
||||
NC North Carolina
|
||||
ND North Dakota
|
||||
OH Ohio
|
||||
OK Oklahoma
|
||||
OR Oregon
|
||||
PA Pennsylvania
|
||||
RI Rhode Island
|
||||
SC South Carolina
|
||||
SD South Dakota
|
||||
TN Tennessee
|
||||
TX Texas
|
||||
UT Utah
|
||||
VT Vermont
|
||||
VA Virginia
|
||||
WA Washington
|
||||
DC Washington,D.C.
|
||||
WV West Virginia
|
||||
WI Wisconsin
|
||||
WY Wyoming
|
||||
6
mozilla/extensions/sql/tests/Makefile.in
Normal file
6
mozilla/extensions/sql/tests/Makefile.in
Normal file
@@ -0,0 +1,6 @@
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -1,5 +0,0 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ webroot/ [L]
|
||||
RewriteRule (.*) webroot/$1 [L]
|
||||
</IfModule>
|
||||
@@ -1,25 +0,0 @@
|
||||
SERVER REQUIREMENTS
|
||||
- Apache 1.3 or higher with mod_rewrite enabled
|
||||
- PHP 4.3.2 or higher
|
||||
- CakePHP 1.1.7.3363 or higher
|
||||
- MySQL (preferred) or PostgreSQL
|
||||
|
||||
INSTALLATION:
|
||||
- All files accompanying this README should be placed into the /app directory of
|
||||
your CakePHP install. Once complete, you should have a directory structure similar
|
||||
to the following where (/) is the base of your domain:
|
||||
/
|
||||
app/
|
||||
config/
|
||||
controllers/
|
||||
models/
|
||||
webroot/
|
||||
...
|
||||
cake/
|
||||
vendors/
|
||||
|
||||
- Import the database schema (/app/config/dist.sql) into your database
|
||||
- Rename database.dist.php to database.php and edit the file to reflect your
|
||||
database configuration
|
||||
- Rename bootstrap.dist.php to bootstrap.php and follow the editing instructions
|
||||
within. All fields except APP_* and MAX_YEAR are optional.
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
class AppController extends Controller {
|
||||
}
|
||||
?>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
class AppModel extends Model {
|
||||
}
|
||||
?>
|
||||
@@ -1,76 +0,0 @@
|
||||
;<?php die() ?>
|
||||
; SVN FILE: $Id: acl.ini.php,v 1.3 2006-10-08 03:39:21 reed%reedloden.com Exp $
|
||||
;/**
|
||||
; * Short description for file.
|
||||
; *
|
||||
; *
|
||||
; * PHP versions 4 and 5
|
||||
; *
|
||||
; * CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
; * Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
; * 1785 E. Sahara Avenue, Suite 490-204
|
||||
; * Las Vegas, Nevada 89104
|
||||
; *
|
||||
; * Licensed under The MIT License
|
||||
; * Redistributions of files must retain the above copyright notice.
|
||||
; *
|
||||
; * @filesource
|
||||
; * @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
; * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
; * @package cake
|
||||
; * @subpackage cake.app.config
|
||||
; * @since CakePHP v 0.10.0.1076
|
||||
; * @version $Revision: 1.3 $
|
||||
; * @modifiedby $LastChangedBy: phpnut $
|
||||
; * @lastmodified $Date: 2006-10-08 03:39:21 $
|
||||
; * @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
; */
|
||||
|
||||
; acl.ini.php - Cake ACL Configuration
|
||||
; ---------------------------------------------------------------------
|
||||
; Use this file to specify user permissions.
|
||||
; aco = access control object (something in your application)
|
||||
; aro = access request object (something requesting access)
|
||||
;
|
||||
; User records are added as follows:
|
||||
;
|
||||
; [uid]
|
||||
; groups = group1, group2, group3
|
||||
; allow = aco1, aco2, aco3
|
||||
; deny = aco4, aco5, aco6
|
||||
;
|
||||
; Group records are added in a similar manner:
|
||||
;
|
||||
; [gid]
|
||||
; allow = aco1, aco2, aco3
|
||||
; deny = aco4, aco5, aco6
|
||||
;
|
||||
; The allow, deny, and groups sections are all optional.
|
||||
; NOTE: groups names *cannot* ever be the same as usernames!
|
||||
;
|
||||
; ACL permissions are checked in the following order:
|
||||
; 1. Check for user denies (and DENY if specified)
|
||||
; 2. Check for user allows (and ALLOW if specified)
|
||||
; 3. Gather user's groups
|
||||
; 4. Check group denies (and DENY if specified)
|
||||
; 5. Check group allows (and ALLOW if specified)
|
||||
; 6. If no aro, aco, or group information is found, DENY
|
||||
;
|
||||
; ---------------------------------------------------------------------
|
||||
|
||||
;-------------------------------------
|
||||
;Users
|
||||
;-------------------------------------
|
||||
|
||||
[username-goes-here]
|
||||
groups = group1, group2
|
||||
deny = aco1, aco2
|
||||
allow = aco3, aco4
|
||||
|
||||
;-------------------------------------
|
||||
;Groups
|
||||
;-------------------------------------
|
||||
|
||||
[groupname-goes-here]
|
||||
deny = aco5, aco6
|
||||
allow = aco7, aco8
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
/* REQUIRED - APP_NAME is used on all <title>s and mail names/subjects. APP_BASE
|
||||
* should be a FQDN with protocol minus the trailing slash e.g. http://example.tld/party
|
||||
*/
|
||||
define('APP_NAME', '');
|
||||
define('APP_EMAIL', '');
|
||||
define('APP_BASE', '');
|
||||
|
||||
/* You should specify a Google Map API key here. Without it, all mapping features
|
||||
* will be disabled. To obtain a key, visit http://www.google.com/apis/maps/
|
||||
*/
|
||||
define('GMAP_API_KEY', '');
|
||||
|
||||
/* The search API key is used to generate spelling suggestions for locations not
|
||||
* not found during a Geocode operation. You may obtain a key here: http://code.google.com/apis/soapsearch/
|
||||
*/
|
||||
define('GSEARCH_API_KEY', '');
|
||||
|
||||
/* The maximum year shown for party registrations */
|
||||
define('MAX_YEAR', 2007);
|
||||
|
||||
/* The Flickr API is used to show photos of each party on the individual party
|
||||
* pages and home page. See http://flickr.com/services/api/keys/ to obtain a key
|
||||
*/
|
||||
define('FLICKR_API_KEY', '');
|
||||
|
||||
/* The tag prefix is used to limit the results returned to a specific party.
|
||||
* e.g. any photo tagged with FirefoxParty11 will be shown on party 11's page.
|
||||
* Photos tagged with only the prefix are shown on the front page (so choose wisely! ;) ).
|
||||
*/
|
||||
define('FLICKR_TAG_PREFIX', '');
|
||||
?>
|
||||
@@ -1,147 +0,0 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id: core.php,v 1.4 2006-10-08 03:39:21 reed%reedloden.com Exp $ */
|
||||
/**
|
||||
* This is core configuration file.
|
||||
*
|
||||
* Use it to configure core behaviour ofCake.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP v 0.2.9
|
||||
* @version $Revision: 1.4 $
|
||||
* @modifiedby $LastChangedBy: phpnut $
|
||||
* @lastmodified $Date: 2006-10-08 03:39:21 $
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
/**
|
||||
* If you do not have mod rewrite on your system
|
||||
* or if you prefer to use CakePHP pretty urls.
|
||||
* uncomment the line below.
|
||||
* Note: If you do have mod rewrite but prefer the
|
||||
* CakePHP pretty urls, you also have to remove the
|
||||
* .htaccess files
|
||||
* release/.htaccess
|
||||
* release/app/.htaccess
|
||||
* release/app/webroot/.htaccess
|
||||
*/
|
||||
// define ('BASE_URL', env('SCRIPT_NAME'));
|
||||
/**
|
||||
* Set debug level here:
|
||||
* - 0: production
|
||||
* - 1: development
|
||||
* - 2: full debug with sql
|
||||
* - 3: full debug with sql and dump of the current object
|
||||
*
|
||||
* In production, the "flash messages" redirect after a time interval.
|
||||
* With the other debug levels you get to click the "flash message" to continue.
|
||||
*
|
||||
*/
|
||||
define('DEBUG', 0);
|
||||
/**
|
||||
* Turn of caching checking wide.
|
||||
* You must still use the controller var cacheAction inside you controller class.
|
||||
* You can either set it controller wide, or in each controller method.
|
||||
* use var $cacheAction = true; or in the controller method $this->cacheAction = true;
|
||||
*/
|
||||
define('CACHE_CHECK', false);
|
||||
/**
|
||||
* Error constant. Used for differentiating error logging and debugging.
|
||||
* Currently PHP supports LOG_DEBUG
|
||||
*/
|
||||
define('LOG_ERROR', 2);
|
||||
/**
|
||||
* CakePHP includes 3 types of session saves
|
||||
* database or file. Set this to your preferred method.
|
||||
* If you want to use your own save handler place it in
|
||||
* app/config/name.php DO NOT USE file or database as the name.
|
||||
* and use just the name portion below.
|
||||
*
|
||||
* Setting this to cake will save files to /cakedistro/tmp directory
|
||||
* Setting it to php will use the php default save path
|
||||
* Setting it to database will use the database
|
||||
*
|
||||
*
|
||||
*/
|
||||
define('CAKE_SESSION_SAVE', 'database');
|
||||
/**
|
||||
* If using you own table name for storing sessions
|
||||
* set the table name here.
|
||||
* DO NOT INCLUDE PREFIX IF YOU HAVE SET ONE IN database.php
|
||||
*
|
||||
*/
|
||||
define('CAKE_SESSION_TABLE', 'sessions');
|
||||
/**
|
||||
* Set a random string of used in session.
|
||||
*
|
||||
*/
|
||||
define('CAKE_SESSION_STRING', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
|
||||
/**
|
||||
* Set the name of session cookie
|
||||
*
|
||||
*/
|
||||
define('CAKE_SESSION_COOKIE', 'sess');
|
||||
/**
|
||||
* Set level of Cake security.
|
||||
*
|
||||
*/
|
||||
define('CAKE_SECURITY', 'high');
|
||||
/**
|
||||
* Set Cake Session time out.
|
||||
* If CAKE_SECURITY define is set
|
||||
* high: multiplied by 10
|
||||
* medium: is multiplied by 100
|
||||
* low is: multiplied by 300
|
||||
*
|
||||
* Number below is seconds.
|
||||
*/
|
||||
define('CAKE_SESSION_TIMEOUT', '120');
|
||||
/**
|
||||
* Uncomment the define below to use cake built in admin routes.
|
||||
* You can set this value to anything you want.
|
||||
* All methods related to the admin route should be prefixed with the
|
||||
* name you set CAKE_ADMIN to.
|
||||
* For example: admin_index, admin_edit
|
||||
*/
|
||||
// define('CAKE_ADMIN', 'admin');
|
||||
/**
|
||||
* The define below is used to turn cake built webservices
|
||||
* on or off. Default setting is off.
|
||||
*/
|
||||
define('WEBSERVICES', 'off');
|
||||
/**
|
||||
* Compress output CSS (removing comments, whitespace, repeating tags etc.)
|
||||
* This requires a/var/cache directory to be writable by the web server (caching).
|
||||
* To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use Controller::cssTag().
|
||||
*/
|
||||
define('COMPRESS_CSS', false);
|
||||
/**
|
||||
* If set to true, helpers would output data instead of returning it.
|
||||
*/
|
||||
define('AUTO_OUTPUT', false);
|
||||
/**
|
||||
* If set to false, session would not automatically be started.
|
||||
*/
|
||||
define('AUTO_SESSION', true);
|
||||
/**
|
||||
* Set the max size of file to use md5() .
|
||||
*/
|
||||
define('MAX_MD5SIZE', (5 * 1024) * 1024);
|
||||
/**
|
||||
* To use Access Control Lists with Cake...
|
||||
*/
|
||||
define('ACL_CLASSNAME', 'DB_ACL');
|
||||
define('ACL_FILENAME', 'dbacl' . DS . 'db_acl');
|
||||
?>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
class DATABASE_CONFIG {
|
||||
var $default = array('driver' => 'mysql',
|
||||
'connect' => 'mysql_connect',
|
||||
'host' => 'localhost',
|
||||
'login' => '',
|
||||
'password' => '',
|
||||
'database' => '');
|
||||
}
|
||||
?>
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id: inflections.php,v 1.3 2006-10-08 03:39:21 reed%reedloden.com Exp $ */
|
||||
/**
|
||||
* Custom Inflected Words.
|
||||
*
|
||||
* This file is used to hold words that are not matched in the normail Inflector::pluralize() and
|
||||
* Inflector::singularize()
|
||||
*
|
||||
* PHP versions 4 and %
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP v 1.0.0.2312
|
||||
* @version $Revision: 1.3 $
|
||||
* @modifiedby $LastChangedBy: phpnut $
|
||||
* @lastmodified $Date: 2006-10-08 03:39:21 $
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
/**
|
||||
* This is a key => value array of regex used to match words.
|
||||
* If key matches then the value is returned.
|
||||
*
|
||||
* $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice');
|
||||
*/
|
||||
$pluralRules = array();
|
||||
/**
|
||||
* This is a key only array of plural words that should not be inflected.
|
||||
* Notice the last comma
|
||||
*
|
||||
* $uninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox');
|
||||
*/
|
||||
$uninflectedPlural = array();
|
||||
/**
|
||||
* This is a key => value array of plural irregular words.
|
||||
* If key matches then the value is returned.
|
||||
*
|
||||
* $irregularPlural = array('atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers')
|
||||
*/
|
||||
$irregularPlural = array();
|
||||
/**
|
||||
* This is a key => value array of regex used to match words.
|
||||
* If key matches then the value is returned.
|
||||
*
|
||||
* $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i')
|
||||
*/
|
||||
$singularRules = array();
|
||||
/**
|
||||
* This is a key only array of singular words that should not be inflected.
|
||||
* You should not have to change this value below if you do change it use same format
|
||||
* as the $uninflectedPlural above.
|
||||
*/
|
||||
$uninflectedSingular = $uninflectedPlural;
|
||||
/**
|
||||
* This is a key => value array of singular irregular words.
|
||||
* Most of the time this will be a reverse of the above $irregularPlural array
|
||||
* You should not have to change this value below if you do change it use same format
|
||||
*
|
||||
* $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother')
|
||||
*/
|
||||
$irregularSingular = array_flip($irregularPlural);
|
||||
?>
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id: routes.php,v 1.5 2006-10-10 20:18:59 reed%reedloden.com Exp $ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* In this file, you set up routes to your controllers and their actions.
|
||||
* Routes are very important mechanism that allows you to freely connect
|
||||
* different urls to chosen controllers and their actions (functions).
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP v 0.2.9
|
||||
* @version $Revision: 1.5 $
|
||||
* @modifiedby $LastChangedBy: phpnut $
|
||||
* @lastmodified $Date: 2006-10-10 20:18:59 $
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
/**
|
||||
* Here, we are connecting '/' (base path) to controller called 'Pages',
|
||||
* its action called 'display', and we pass a param to select the view file
|
||||
* to use (in this case, /app/views/pages/home.thtml)...
|
||||
*/
|
||||
$Route->connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
||||
/**
|
||||
* ...and connect the rest of 'Pages' controller's urls.
|
||||
*/
|
||||
$Route->connect('/pages/edit', array('controller' => 'pages', 'action' => 'edit'));
|
||||
$Route->connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
|
||||
$Route->connect('/privacy-policy', array('controller' => 'pages', 'action' => 'privacy'));
|
||||
?>
|
||||
@@ -1,80 +0,0 @@
|
||||
CREATE TABLE `comments` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`assoc` int(10) NOT NULL default '0',
|
||||
`owner` int(10) NOT NULL default '0',
|
||||
`time` int(15) NOT NULL default '0',
|
||||
`text` text collate utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE `guests` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`pid` int(10) NOT NULL default '0',
|
||||
`uid` int(10) NOT NULL default '0',
|
||||
`invited` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `pid` (`pid`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE `pages` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`text` text collate utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
INSERT INTO `pages` (`id`, `text`) VALUES (1, '<h2>Join the Fun!</h2>\n<p>All over the world, we're celebrating the launch of Firefox 2. Join the fun by hosting or attending a party. We're targeting the weekend of October 27th for the shared celebration, but if you're hosting, you make the call.</p>\n\n<p>To join the fun, <a href="/users/register">register</a> for a Firefox Party account, and sign up to host or attend.</p>\n\n<p style="border: 1px solid #555; background: #faffd4; padding: 5px; font-weight: bold">Be one of the first 50 party hosts registered and get three extra launch exclusive t-shirts with your purchase of the <a href="">Firefox 2 Party Pack</a>. We're selling the party packs and shirts at cost, so it's a great deal, and for parties with unusually large attendance, we'll be sending out additional swag for door prizes and other give-aways. Stay tuned for updates!</p>');
|
||||
INSERT INTO `pages` (`id`, `text`) VALUES (2, '1162007940');
|
||||
|
||||
CREATE TABLE `parties` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`owner` int(10) NOT NULL default '0',
|
||||
`name` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`vname` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`address` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`tz` int(2) NOT NULL default '0',
|
||||
`website` text collate utf8_unicode_ci NOT NULL,
|
||||
`notes` text collate utf8_unicode_ci NOT NULL,
|
||||
`date` int(10) NOT NULL default '0',
|
||||
`duration` tinyint(2) NOT NULL default '2',
|
||||
`confirmed` tinyint(1) NOT NULL default '1',
|
||||
`canceled` tinyint(1) NOT NULL default '0',
|
||||
`guestcomments` tinyint(1) NOT NULL default '0',
|
||||
`inviteonly` tinyint(1) NOT NULL default '0',
|
||||
`invitecode` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`lat` float NOT NULL default '0',
|
||||
`long` float NOT NULL default '0',
|
||||
`zoom` tinyint(2) NOT NULL default '1',
|
||||
`useflickr` tinyint(1) NOT NULL default '0',
|
||||
`flickrperms` tinyint(1) NOT NULL default '0',
|
||||
`flickrid` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`flickrusr` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE `sessions` (
|
||||
`id` varchar(255) character set latin1 NOT NULL default '',
|
||||
`data` text character set latin1,
|
||||
`expires` int(11) default NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE `users` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`role` tinyint(1) NOT NULL default '0',
|
||||
`email` varchar(255) collate utf8_unicode_ci NOT NULL,
|
||||
`active` varchar(10) collate utf8_unicode_ci NOT NULL default '0',
|
||||
`password` varchar(75) collate utf8_unicode_ci NOT NULL default '',
|
||||
`salt` varchar(9) collate utf8_unicode_ci NOT NULL default '',
|
||||
`name` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`location` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`tz` tinyint(2) NOT NULL default '0',
|
||||
`website` text collate utf8_unicode_ci NOT NULL,
|
||||
`lat` float NOT NULL default '0',
|
||||
`long` float NOT NULL default '0',
|
||||
`zoom` tinyint(2) NOT NULL default '1',
|
||||
`showemail` tinyint(1) NOT NULL default '0',
|
||||
`showloc` tinyint(1) NOT NULL default '1',
|
||||
`showmap` tinyint(1) NOT NULL default '1',
|
||||
UNIQUE KEY `email` (`email`),
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
@@ -1,163 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
uses('sanitize');
|
||||
class AdminController extends AppController {
|
||||
var $name = 'Admin';
|
||||
var $uses = array('Party', 'User', 'Comment');
|
||||
var $components = array('Unicode');
|
||||
|
||||
function beforeFilter() {
|
||||
if (empty($_SESSION['User']) || $_SESSION['User']['role'] != 1) {
|
||||
$this->redirect('/');
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
function index() {
|
||||
$this->set('parties', $this->Party->findAll(null, null, "id ASC"));
|
||||
}
|
||||
|
||||
function users() {
|
||||
$this->set('users', $this->User->findAll(null, null, "id ASC"));
|
||||
}
|
||||
|
||||
function comments() {
|
||||
$this->set('comments', $this->Comment->findAll(null, null, "id ASC"));
|
||||
}
|
||||
|
||||
function edit($type, $id) {
|
||||
if (empty($this->data)) {
|
||||
switch($type) {
|
||||
case 'user':
|
||||
$this->User->id = $id;
|
||||
$user = $this->User->read();
|
||||
$this->set('user', $user);
|
||||
$this->data = $user;
|
||||
break;
|
||||
|
||||
case 'party':
|
||||
$this->Party->id = $id;
|
||||
$party = $this->Party->read();
|
||||
$this->set('party', $party);
|
||||
$this->data = $party;
|
||||
$this->data['Party']['name'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['name']));
|
||||
$this->data['Party']['vname'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['vname']));
|
||||
$this->data['Party']['website'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['website']));
|
||||
$this->data['Party']['address'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['address']));
|
||||
$this->data['Party']['notes'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['notes']));
|
||||
$this->data['Party']['flickrusr'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['flickrusr']));
|
||||
break;
|
||||
|
||||
case 'comment':
|
||||
$this->Comment->id = $id;
|
||||
$comment = $this->Comment->read();
|
||||
$this->set('comment', $comment);
|
||||
|
||||
$uid = $this->User->findById($comment['Comment']['owner']);
|
||||
$this->set('owner', $uid['User']['name']);
|
||||
|
||||
$this->data = $comment;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
switch($type) {
|
||||
case 'user':
|
||||
$this->User->id = $id;
|
||||
$this->User->save($this->data);
|
||||
break;
|
||||
|
||||
case 'party':
|
||||
$this->Party->id = $id;
|
||||
$clean = new Sanitize();
|
||||
$clean->cleanArray($this->data);
|
||||
$this->Party->save($this->data);
|
||||
break;
|
||||
|
||||
case 'comment':
|
||||
$this->Comment->id = $id;
|
||||
$this->Comment->save($this->data);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($type != 'party')
|
||||
$this->redirect('/admin/'.$type.'s');
|
||||
|
||||
else
|
||||
$this->redirect('/admin/');
|
||||
}
|
||||
}
|
||||
|
||||
function delete($type, $id) {
|
||||
switch($type) {
|
||||
case 'user':
|
||||
$this->User->del($id);
|
||||
$this->User->query("DELETE FROM guests WHERE uid = $id");
|
||||
break;
|
||||
|
||||
case 'party':
|
||||
$this->Party->del($id);
|
||||
$this->Party->query("DELETE FROM guests WHERE pid = $id");
|
||||
$this->Party->query("DELETE FROM comments WHERE assoc = $id");
|
||||
break;
|
||||
|
||||
case 'comment':
|
||||
$this->Comment->del($id);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($type != 'party')
|
||||
$this->redirect('/admin/'.$type.'s');
|
||||
|
||||
else
|
||||
$this->redirect('/admin/');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
class MailComponent extends Object {
|
||||
var $from;
|
||||
var $to;
|
||||
var $reply;
|
||||
var $subject;
|
||||
var $message;
|
||||
var $envelope;
|
||||
var $head = "<strong>Firefox Party!</strong><br/>";
|
||||
var $foot;
|
||||
|
||||
|
||||
function mail($params) {
|
||||
if (array_key_exists('from', $params))
|
||||
$this->from = $params['from'];
|
||||
|
||||
if (array_key_exists('to', $params))
|
||||
$this->to = $params['to'];
|
||||
|
||||
if (array_key_exists('reply', $params))
|
||||
$this->reply = $params['reply'];
|
||||
|
||||
if (array_key_exists('subject', $params))
|
||||
$this->subject = $params['subject'];
|
||||
|
||||
if (array_key_exists('message', $params))
|
||||
$this->message = $params['message'];
|
||||
|
||||
if (array_key_exists('envelope', $params))
|
||||
$this->envelope = $params['envelope'];
|
||||
|
||||
if (array_key_exists('type', $params)) {
|
||||
switch($params['type']) {
|
||||
case 'act':
|
||||
$this->message = $this->head."<br/>\nThank you for registering! To activate your account, <a href=\"".$params['link']."\">click here</a> or paste the link below into your browser:<br/> ".$params['link'].$this->foot;
|
||||
break;
|
||||
|
||||
case 'prec':
|
||||
$this->message = $this->head."<br/>\nTo reset your password, <a href=\"".$params['link']."\">click here</a> or paste the link below into your browser:<br/> ".$params['link'].$this->foot;
|
||||
break;
|
||||
|
||||
case 'invite':
|
||||
$this->message = $this->head."<br/>\nYou've been invited by a friend to join them in celebrating the release of Firefox 2. Simply <a href=\"".$params['link']."\">click here</a> to confirm or cancel this invitation. If you don't already have an account, you'll need to create one.\n
|
||||
If you're unable to use the link above, simply paste the following URL into your browser: ".$params['link'].$this->foot;
|
||||
break;
|
||||
|
||||
case 'cancel':
|
||||
$this->message = $this->head."<br/>\nThe party you were attending has been canceled. For more information, please <a href=\"".$params['link']."\">click here</a>, or see the link below.\n ".$params['link'].$this->foot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function make_headers($type='html') {
|
||||
$headers = '';
|
||||
|
||||
switch($type) {
|
||||
case 'html':
|
||||
$headers .= 'MIME-Version: 1.0' . "\r\n";
|
||||
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($this->from)) {
|
||||
$headers .= "From: {$this->from}\r\n";
|
||||
|
||||
if (!empty($this->reply))
|
||||
$headers .= "Reply-To: {$this->reply}\r\n";
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
|
||||
function make_additional_parameters() {
|
||||
if (!empty($this->envelope)) {
|
||||
return '-f'.$this->envelope;
|
||||
}
|
||||
}
|
||||
|
||||
function send() {
|
||||
mail($this->to, $this->subject, $this->message, $this->make_headers(), $this->make_additional_parameters());
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
vendor('webServices');
|
||||
class FeedsController extends AppController {
|
||||
var $name = 'Feeds';
|
||||
var $components = array('Unicode');
|
||||
|
||||
function index() {
|
||||
header('Content-type: application/rss+xml');
|
||||
$this->layout = 'ajax';
|
||||
$this->set('count', $this->Feed->findCount());
|
||||
}
|
||||
|
||||
function latest() {
|
||||
header('Content-type: application/rss+xml');
|
||||
$this->layout = 'ajax';
|
||||
$this->set('latest', $this->Feed->findAll('', '', 'id DESC', 10, 1));
|
||||
}
|
||||
|
||||
function users() {
|
||||
header('Content-type: application/rss+xml');
|
||||
$this->layout = 'ajax';
|
||||
$this->set('count', $this->Feed->getUserCount());
|
||||
}
|
||||
|
||||
function comments($id = null) {
|
||||
$this->layout = 'ajax';
|
||||
header('Content-type: application/rss+xml');
|
||||
if (!is_numeric($id))
|
||||
return;
|
||||
|
||||
$this->set('comments', $this->Feed->getComments($id));
|
||||
$this->set('pid', $id);
|
||||
}
|
||||
|
||||
function photos($id = null) {
|
||||
$this->layout = 'ajax';
|
||||
header('Content-type: application/atom+xml');
|
||||
if (!is_numeric($id))
|
||||
return;
|
||||
|
||||
$party = $this->Feed->findById($id);
|
||||
$this->set('party', $party);
|
||||
|
||||
if (FLICKR_API_KEY != null && !$party['Feeds']['canceled']) {
|
||||
if ($party['Feeds']['useflickr'] == 1) {
|
||||
$data = array('type' => 'flickr', 'userid' => $party['Feeds']['flickrid'], 'randomize' => false);
|
||||
$flickr = new webServices($data);
|
||||
$photoset = $flickr->fetchPhotos(FLICKR_TAG_PREFIX.$id, 30, !$party['Feeds']['flickrperms']);
|
||||
$this->set('flickr', $photoset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function upcoming($limit = null) {
|
||||
$this->layout = 'ajax';
|
||||
header('Content-type: application/rss+xml');
|
||||
|
||||
($limit == null) ? $limit = 25 : $limit = intval($limit);
|
||||
|
||||
$this->set('latest', $this->Feed->findAll('WHERE date > '. time(), '', 'date ASC', $limit, 1));
|
||||
}
|
||||
|
||||
function ical() {
|
||||
$this->layout = 'ajax';
|
||||
header('Content-type: text/calendar');
|
||||
header("Content-Disposition: inline; filename=partylist.ics");
|
||||
$back = time() - 172800;
|
||||
$events = $this->Feed->findAll('WHERE date > '. $back, '', 'date ASC', null, 1);
|
||||
|
||||
$cal = array();
|
||||
|
||||
foreach($events as $event) {
|
||||
$event['Feeds']['name'] =
|
||||
preg_replace(array("/&#(\d{2,5});/e", "/(\n|\r|\f)/", "/\,/"),
|
||||
array('$this->Unicode->unicode2utf(${1})', ' ', '\,'),
|
||||
html_entity_decode($event['Feeds']['name']));
|
||||
$event['Feeds']['address'] =
|
||||
preg_replace(array("/&#(\d{2,5});/e", "/(\n|\r|\f)/", "/\,/"),
|
||||
array('$this->Unicode->unicode2utf(${1})', ' ', '\,'),
|
||||
html_entity_decode($event['Feeds']['address']));
|
||||
$event['Feeds']['notes'] =
|
||||
preg_replace(array("/&#(\d{2,5});/e", "/(\n|\r|\f)/", "/\,/"),
|
||||
array('$this->Unicode->unicode2utf(${1})', ' ', '\,'),
|
||||
html_entity_decode($event['Feeds']['notes']));
|
||||
array_push($cal, $event);
|
||||
}
|
||||
$this->set('events', $cal);
|
||||
}
|
||||
|
||||
function topguests($limit = null) {
|
||||
$this->layout = 'ajax';
|
||||
header('Content-type: application/rss+xml');
|
||||
|
||||
($limit == null) ? $limit = 25 : $limit = intval($limit);
|
||||
|
||||
$rv = $this->Feed->query("SELECT parties.name AS name,
|
||||
guests.pid AS id,
|
||||
COUNT(guests.pid) AS count
|
||||
FROM guests
|
||||
LEFT JOIN parties
|
||||
ON guests.pid = parties.id
|
||||
GROUP BY guests.pid
|
||||
ORDER BY count DESC
|
||||
LIMIT $limit");
|
||||
$this->set('items', $rv);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
uses('sanitize');
|
||||
class PagesController extends AppController {
|
||||
var $name = 'Pages';
|
||||
var $components = array('Unicode');
|
||||
|
||||
function display() {
|
||||
$this->pageTitle = 'Home';
|
||||
$this->set('current', 'home');
|
||||
$this->set('pcount', $this->Page->findCount());
|
||||
$this->set('ucount', $this->Page->getUsers());
|
||||
$text = $this->Page->query('SELECT text FROM pages WHERE id = 1');
|
||||
$time = $this->Page->query('SELECT text FROM pages WHERE id = 2');
|
||||
$this->set('time', $time[0]['pages']['text']);
|
||||
$this->set('front_text', preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($text[0]['pages']['text'])));
|
||||
}
|
||||
|
||||
function privacy() {
|
||||
$this->pageTitle = 'Privacy Policy';
|
||||
}
|
||||
|
||||
function edit() {
|
||||
if (isset($_SESSION['User']['id']) && $_SESSION['User']['role'] == 1) {
|
||||
if (empty($this->data)) {
|
||||
$text = $this->Page->query('SELECT text FROM pages WHERE id = 1');
|
||||
$time = $this->Page->query('SELECT text FROM pages WHERE id = 2');
|
||||
$this->data['Pages']['text'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($text[0]['pages']['text']));
|
||||
$this->set('selected', date('Y-m-d H:i:s', $time[0]['pages']['text']));
|
||||
}
|
||||
|
||||
else {
|
||||
// Paranoid? Nah...
|
||||
if ($_SESSION['User']['role'] == 1) {
|
||||
$clean = new Sanitize();
|
||||
$clean->cleanArray($this->data);
|
||||
$date = mktime($this->data['Pages']['date_hour'],
|
||||
$this->data['Pages']['date_min'],
|
||||
0,
|
||||
$this->data['Pages']['date_month'],
|
||||
$this->data['Pages']['date_day'],
|
||||
$this->data['Pages']['date_year']);
|
||||
|
||||
$this->Page->execute('UPDATE pages SET text = "'.$this->data['Pages']['text'].'" WHERE pages.id = 1');
|
||||
$this->Page->execute('UPDATE pages SET text = "'.$date.'" WHERE pages.id = 2');
|
||||
$this->redirect('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
die();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,472 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
uses('sanitize');
|
||||
vendor('webServices');
|
||||
class PartiesController extends AppController {
|
||||
var $name = 'Parties';
|
||||
var $uses = array('Party', 'Comment');
|
||||
var $helpers = array('Html', 'Form');
|
||||
var $components = array('Hash', 'Mail', 'Unicode');
|
||||
|
||||
function index() {
|
||||
$this->pageTitle = 'Party Map';
|
||||
$this->set('current', 'map');
|
||||
|
||||
if (!empty($this->data)) {
|
||||
$gcoder = new webServices(array('type' => 'geocode'));
|
||||
$loc = $gcoder->geocode($this->data['Party']['mloc']);
|
||||
|
||||
if ($loc)
|
||||
$this->set('map', 'initMashUp('.$loc['lat'].', '.$loc['lng'].');');
|
||||
|
||||
else
|
||||
$this->set('map', 'initMashUp();');
|
||||
}
|
||||
|
||||
else
|
||||
$this->set('map', 'initMashUp();');
|
||||
}
|
||||
|
||||
function add() {
|
||||
if (!$this->Session->check('User'))
|
||||
$this->redirect('/users/login');
|
||||
|
||||
$this->pageTitle = 'Create Party';
|
||||
$this->set('current', 'create');
|
||||
$this->set('map', 'mapInit()');
|
||||
|
||||
if(empty($this->data)) {
|
||||
$this->set('utz', $_SESSION['User']['tz']);
|
||||
$this->render();
|
||||
}
|
||||
|
||||
else {
|
||||
$temp = array('lat' => $this->data['Party']['lat'],
|
||||
'long' => $this->data['Party']['long'],
|
||||
'tz' => $this->data['Party']['tz']);
|
||||
|
||||
$clean = new Sanitize();
|
||||
$clean->cleanArray($this->data);
|
||||
|
||||
$this->data['Party']['lat'] = floatval($temp['lat']);
|
||||
$this->data['Party']['long'] = floatval($temp['long']);
|
||||
$this->data['Party']['tz'] = intval($temp['tz']);
|
||||
$this->set('utz', $this->data['Party']['tz']);
|
||||
|
||||
// Convert the selected time to GMT
|
||||
$secoffset = ($this->data['Party']['tz'] * 60 * 60);
|
||||
$offsetdate = gmmktime($this->data['Party']['hour_hour'],
|
||||
$this->data['Party']['minute_min'],
|
||||
0,
|
||||
$this->data['Party']['month_hour'],
|
||||
$this->data['Party']['day_day'],
|
||||
$this->data['Party']['year_year']);
|
||||
$this->data['Party']['date'] = ($offsetdate + $secoffset);
|
||||
$this->data['Party']['duration'] = intval($this->data['Party']['duration']);
|
||||
|
||||
$this->data['Party']['invitecode'] = $this->Hash->keygen(10);
|
||||
$this->data['Party']['owner'] = $_SESSION['User']['id'];
|
||||
|
||||
if (!preg_match("/^(http|https)\:\/\//i", $this->data['Party']['website']) &&
|
||||
!empty($this->data['Party']['website']))
|
||||
$this->Party->invalidate('website');
|
||||
|
||||
if ($this->Party->validates($this->data)) {
|
||||
if($this->Party->save($this->data)) {
|
||||
$this->Session->setFlash('Your party has been created!', 'infoFlash');
|
||||
$this->redirect('/parties/view/'.$this->Party->getLastInsertId());
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Session->setFlash('Please correct the errors below.', 'errorFlash');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->Party->id = $id;
|
||||
$party = $this->Party->read();
|
||||
$this->set('party', $party);
|
||||
$this->pageTitle = 'Edit Party';
|
||||
$this->set('current', 'create');
|
||||
|
||||
if (empty($_SESSION['User']['id']))
|
||||
$this->redirect('/users/login/');
|
||||
|
||||
if ($party['Party']['owner'] != $_SESSION['User']['id'])
|
||||
$this->redirect('/parties/view/'.$id);
|
||||
|
||||
else {
|
||||
if (empty($this->data)) {
|
||||
$this->data = $party;
|
||||
|
||||
$date = array('hour' => intval(date('h', $party['Party']['date'])),
|
||||
'min' => intval(date('i', $party['Party']['date'])),
|
||||
'mon' => intval(date('m', $party['Party']['date'])),
|
||||
'day' => intval(date('d', $party['Party']['date'])),
|
||||
'year' => intval(date('Y', $party['Party']['date'])),
|
||||
'tz' => $party['Party']['tz']);
|
||||
|
||||
$this->set('date', $date);
|
||||
$this->data['Party']['name'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['name']));
|
||||
$this->data['Party']['vname'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['vname']));
|
||||
$this->data['Party']['website'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['website']));
|
||||
$this->data['Party']['address'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['address']));
|
||||
$this->data['Party']['notes'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['notes']));
|
||||
$this->data['Party']['flickrusr'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['flickrusr']));
|
||||
|
||||
if (GMAP_API_KEY != null) {
|
||||
if ($this->data['Party']['lat'])
|
||||
$this->set('map', 'mapInit('.$this->data['Party']['lat'].','.$this->data['Party']['long'].','.$this->data['Party']['zoom'].')');
|
||||
else
|
||||
$this->set('map', 'mapInit()');
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$clean = new Sanitize();
|
||||
$temp = array('lat' => $clean->sql($this->data['Party']['lat']),
|
||||
'long' => $clean->sql($this->data['Party']['long']),
|
||||
'tz' => $clean->sql($this->data['Party']['tz']));
|
||||
|
||||
$clean->cleanArray($this->data);
|
||||
|
||||
$this->data['Party']['lat'] = floatval($temp['lat']);
|
||||
$this->data['Party']['long'] = floatval($temp['long']);
|
||||
$this->data['Party']['tz'] = intval($temp['tz']);
|
||||
|
||||
$secoffset = ($this->data['Party']['tz'] * 60 * 60);
|
||||
|
||||
$offsetdate = gmmktime($this->data['Party']['hour_hour'],
|
||||
$this->data['Party']['minute_min'],
|
||||
0,
|
||||
$this->data['Party']['month_hour'],
|
||||
$this->data['Party']['day_day'],
|
||||
$this->data['Party']['year_year']);
|
||||
|
||||
$this->data['Party']['date'] = ($offsetdate - $secoffset);
|
||||
$this->data['Party']['owner'] = $party['Party']['owner'];
|
||||
$this->data['Party']['duration'] = intval($this->data['Party']['duration']);
|
||||
|
||||
$date = array('hour' => intval(date('h', $party['Party']['date'])),
|
||||
'min' => intval(date('i', $party['Party']['date'])),
|
||||
'mon' => intval(date('m', $party['Party']['date'])),
|
||||
'day' => intval(date('d', $party['Party']['date'])),
|
||||
'year' => intval(date('Y', $party['Party']['date'])),
|
||||
'tz' => $party['Party']['tz']);
|
||||
$this->set('date', $date);
|
||||
|
||||
if (!preg_match("/^(http|https)\:\/\//i", $this->data['Party']['website']) &&
|
||||
!empty($this->data['Party']['website']))
|
||||
$this->Party->invalidate('website');
|
||||
|
||||
if ($this->data['Party']['flickrusr'] != $party['Party']['flickrusr']) {
|
||||
$params = array('type' => 'flickr', 'username' => $this->data['Party']['flickrusr']);
|
||||
$flick = new webServices($params);
|
||||
$this->data['Party']['flickrid'] = $flick->getFlickrId();
|
||||
}
|
||||
|
||||
if ($this->Party->validates($this->data)) {
|
||||
if ($this->Party->save($this->data)) {
|
||||
$this->Session->setFlash('Party edited successfully.', 'infoFlash');
|
||||
$this->redirect('parties/view/'.$id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function view($id = null, $page = null) {
|
||||
if ($id == 'all') {
|
||||
$this->pageTitle = 'All Parties';
|
||||
$this->set('current', 'parties');
|
||||
|
||||
//Paginate!
|
||||
$count = $this->Party->findCount();
|
||||
$pages = ceil($count/100);
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
if ($page > 1)
|
||||
$this->set('prev', $page - 1);
|
||||
if ($page < $pages)
|
||||
$this->set('next', $page + 1);
|
||||
|
||||
$deck = $this->Party->findAll(null, null, "id ASC", 100, $page);
|
||||
shuffle($deck);
|
||||
$this->set('parties', $deck);
|
||||
}
|
||||
|
||||
else if (is_numeric($id)) {
|
||||
$party = $this->Party->findById($id);
|
||||
if (empty($party['Party']['id']))
|
||||
$this->redirect('/parties/view/all');
|
||||
|
||||
$this->set('current', 'parties');
|
||||
$this->set('host', $this->Party->getHost($party['Party']['owner']));
|
||||
$this->set('party', $party);
|
||||
$this->set('isguest', $this->Party->isGuest($id, @$_SESSION['User']['id']));
|
||||
$this->pageTitle = $party['Party']['name'];
|
||||
$this->set('map', 'mapInit('.$party['Party']['lat'].','.$party['Party']['long'].
|
||||
','.$party['Party']['zoom'].',\'stationary\')');
|
||||
$this->set('guests', $this->Party->getGuests($party['Party']['id']));
|
||||
$this->set('comments', $this->Party->getComments($id));
|
||||
|
||||
if (FLICKR_API_KEY != null) {
|
||||
if ($party['Party']['useflickr'] == 1) {
|
||||
$data = array('type' => 'flickr', 'userid' => $party['Party']['flickrid'], 'randomize' => true);
|
||||
$flickr = new webServices($data);
|
||||
$photoset = $flickr->fetchPhotos(FLICKR_TAG_PREFIX.$party['Party']['id'], 15, (($party['Party']['flickrperms']) ? false : true));
|
||||
$this->set('flickr', array_slice($photoset, 0, 9));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
$this->redirect('/parties/view/all');
|
||||
}
|
||||
|
||||
function invite($id = null) {
|
||||
$this->pageTitle = "Invite a Guest";
|
||||
if (is_numeric($id)) {
|
||||
$party = $this->Party->findById($id);
|
||||
if (empty($party['Party']['id']) ||
|
||||
$party['Party']['owner'] != $_SESSION['User']['id'] ||
|
||||
$party['Party']['canceled'] == 1)
|
||||
$this->redirect('/parties/view/all');
|
||||
|
||||
else {
|
||||
$this->set('partyid', $party['Party']['id']);
|
||||
$this->set('inviteurl', APP_BASE.'/parties/invited/'.$party['Party']['invitecode']);
|
||||
|
||||
$clean = new Sanitize();
|
||||
$uid = $clean->sql($_SESSION['User']['id']);
|
||||
$email = $this->Party->query("SELECT email FROM users WHERE id = ".$uid);
|
||||
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Party->validates($this->data)) {
|
||||
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
|
||||
'envelope' => APP_EMAIL,
|
||||
'to' => $this->data['Party']['einvite'],
|
||||
'reply' => $email[0]['users']['email'],
|
||||
'subject' => 'You\'ve been invited to '.APP_NAME.'!',
|
||||
'link' => APP_BASE.'/parties/invited/'.$party['Party']['invitecode'],
|
||||
'type' => 'invite');
|
||||
|
||||
$this->Mail->mail($message);
|
||||
$this->Mail->send();
|
||||
|
||||
$this->Session->setFlash($this->data['Party']['einvite'].' has been
|
||||
invited. You can invite another guest below or <a href="'.APP_BASE.'/parties/view/'.$id.'/">click here</a>
|
||||
to return to your party.', 'infoFlash');
|
||||
$this->data['Party']['einvite'] = null;
|
||||
}
|
||||
else {
|
||||
$this->validateErrors($this->Party);
|
||||
$this->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function invited($icode = null, $conf = null) {
|
||||
$this->pageTitle = "Confirm Invite";
|
||||
if ($icode == 'cancel') {
|
||||
$this->Session->delete('invite');
|
||||
$this->Session->delete('invitestep');
|
||||
$this->redirect('/');
|
||||
}
|
||||
|
||||
else {
|
||||
$clean = new Sanitize();
|
||||
$icode = $clean->sql($icode);
|
||||
$party = $this->Party->findByInvitecode($icode);
|
||||
|
||||
if (empty($party['Party']['id'])) {
|
||||
$this->Session->setFlash('Could not find a party matching that invite code, please check it and try again.', 'errorFlash');
|
||||
}
|
||||
|
||||
else {
|
||||
if (!empty($_SESSION['User']['id']) && !empty($_SESSION['invitestep']) && $conf == 'confirm') {
|
||||
$this->Party->addGuest($_SESSION['User']['id'], $_SESSION['invite']);
|
||||
$this->Session->setFlash('You have been successfully added to this party.', 'infoFlash');
|
||||
$this->redirect('/parties/view/'.$party['Party']['id']);
|
||||
}
|
||||
|
||||
else if (!empty($_SESSION['User']['id'])) {
|
||||
$this->set('confirm_only', true);
|
||||
$this->set('party', $party);
|
||||
$this->set('icode', $icode);
|
||||
$this->Session->write('invitestep', 'true');
|
||||
$this->Session->write('invite', $icode);
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Session->write('invite', $icode);
|
||||
$this->set('party', $party);
|
||||
$this->set('icode', $icode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function rsvp($pid) {
|
||||
if (is_numeric($pid) && isset($_SESSION['User']['id'])) {
|
||||
$party = $this->Party->findById($pid);
|
||||
if (empty($party['Party']['id'])) {
|
||||
$this->Session->setFlash('Invalid party id.', 'errorFlash');
|
||||
$this->redirect('/parties/view/all');
|
||||
}
|
||||
|
||||
else {
|
||||
if ($party['Party']['inviteonly']) {
|
||||
$this->Session->setFlash('This party invite only, you\'ll need an
|
||||
invitation from the host to join in', 'errorFlash');
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Party->rsvp($pid, $_SESSION['User']['id']);
|
||||
$this->Session->setFlash('You have been successfully added to this party.', 'infoFlash');
|
||||
$this->redirect('/parties/view/'.$pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
$this->redirect('/parties/view/all');
|
||||
}
|
||||
|
||||
function unrsvp($pid) {
|
||||
if (is_numeric($pid) && isset($_SESSION['User']['id'])) {
|
||||
$party = $this->Party->findById($pid);
|
||||
if (empty($party['Party']['id'])) {
|
||||
$this->Session->setFlash('Invalid party id.', 'errorFlash');
|
||||
$this->redirect('/parties/view/all');
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Party->unrsvp($pid, $_SESSION['User']['id']);
|
||||
$this->Session->setFlash('You have been successfully removed from this party.', 'infoFlash');
|
||||
$this->redirect('/parties/view/'.$pid);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
$this->redirect('/parties/view/all');
|
||||
}
|
||||
|
||||
function cancel($pid) {
|
||||
$this->pageTitle = "Cancel Party";
|
||||
if (!is_numeric($pid) || !isset($_SESSION['User']['id']))
|
||||
$this->redirect('/');
|
||||
|
||||
else
|
||||
$this->set('pid', $pid);
|
||||
|
||||
$party = $this->Party->findById($pid);
|
||||
if ($_SESSION['User']['id'] != $party['Party']['owner'])
|
||||
die();
|
||||
|
||||
if (!empty($this->data) && $_SESSION['User']['id'] == $party['Party']['owner']) {
|
||||
if ($this->data['Party']['confcancel'] == 1) {
|
||||
$guests = $this->Party->getGuests($pid);
|
||||
$guest_count = count($guests);
|
||||
|
||||
foreach($guests as $guest) {
|
||||
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
|
||||
'envelope' => APP_EMAIL,
|
||||
'to' => $guest['users']['email'],
|
||||
'reply' => $_SESSION['User']['email'],
|
||||
'subject' => 'Party Cancellation Notice',
|
||||
'link' => APP_BASE.'/parties/view/'.$pid,
|
||||
'type' => 'cancel');
|
||||
|
||||
$this->Mail->mail($message);
|
||||
$this->Mail->send();
|
||||
}
|
||||
|
||||
$this->Party->query("DELETE FROM guests WHERE pid = $pid LIMIT $guest_count");
|
||||
$this->Party->query("UPDATE parties SET canceled = '1', invitecode = '0' WHERE parties.id = $pid LIMIT 1");
|
||||
|
||||
$this->redirect('/parties/view/'.$pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function uncancel($pid) {
|
||||
if (!is_numeric($pid) || !isset($_SESSION['User']['id']))
|
||||
$this->redirect('/');
|
||||
|
||||
$party = $this->Party->findById($pid);
|
||||
if ($_SESSION['User']['id'] != $party['Party']['owner'])
|
||||
die();
|
||||
|
||||
$key = $this->Hash->keygen(10);
|
||||
$this->Party->query("UPDATE parties SET canceled = '0', invitecode = '$key' WHERE parties.id = $pid LIMIT 1");
|
||||
$this->redirect('/parties/view/'.$pid);
|
||||
}
|
||||
|
||||
function js($type = null, $data = null) {
|
||||
$this->layout = 'ajax';
|
||||
|
||||
if ($type == 'html') {
|
||||
header('Content-type: text/plain');
|
||||
$party = $this->Party->findById($data);
|
||||
$this->set('party', $party);
|
||||
}
|
||||
|
||||
else {
|
||||
header('Content-type: text/javascript');
|
||||
$parties = $this->Party->findAll();
|
||||
$this->set('parties', $parties);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,437 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
uses('sanitize');
|
||||
class UsersController extends AppController {
|
||||
var $name = 'Users';
|
||||
var $uses = array('User', 'Party');
|
||||
var $helpers = array('Html', 'Form');
|
||||
var $components = array('Security', 'Hash', 'Mail');
|
||||
|
||||
function index() {
|
||||
if (!isset($_SESSION['User'])) {
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
|
||||
$this->pageTitle = 'My Profile';
|
||||
|
||||
$user = $this->Session->read('User');
|
||||
$this->set('parties', $this->User->memberOf($user['id']));
|
||||
$this->set('hparties', $this->User->hostOf($user['id']));
|
||||
$this->set('iparties', $this->User->invitedTo($user['id']));
|
||||
}
|
||||
|
||||
function register() {
|
||||
$this->pageTitle = 'Register';
|
||||
$this->set('map', 'mapInit()');
|
||||
|
||||
if(empty($this->data)) {
|
||||
$this->set('utz', '0');
|
||||
$this->render();
|
||||
}
|
||||
|
||||
else {
|
||||
if ($this->User->findByEmail($this->data['User']['email']))
|
||||
$this->User->invalidate('email');
|
||||
|
||||
if ($this->data['User']['email'] !== $this->data['User']['confemail'])
|
||||
$this->User->invalidate('confemail');
|
||||
|
||||
if (!preg_match("/^(http|https)\:\/\//i", $this->data['User']['website']) &&
|
||||
!empty($this->data['User']['website']))
|
||||
$this->User->invalidate('website');
|
||||
|
||||
if ($this->data['User']['password'] !== $this->data['User']['confpass'])
|
||||
$this->User->invalidate('confpass');
|
||||
|
||||
if (empty($this->data['User']['password']) || empty($this->data['User']['confpass']))
|
||||
$this->User->invalidate('password');
|
||||
|
||||
// Repopulate the timezone with right value in case there's a validation error
|
||||
$this->set('utz', $this->data['User']['tz']);
|
||||
|
||||
if ($this->User->validates($this->data)) {
|
||||
$clean = new Sanitize();
|
||||
// Generate and set the password, salt and activation key
|
||||
$pass = $this->Hash->password($this->data['User']['password'],
|
||||
$this->data['User']['email']);
|
||||
$this->data['User']['active'] = $this->Hash->keygen(10);
|
||||
$this->data['User']['password'] = $pass['pass'];
|
||||
$this->data['User']['salt'] = $pass['salt'];
|
||||
|
||||
// Save a few fields from the wrath of cleanArray()
|
||||
$temp = array('lat' => $this->data['User']['lat'],
|
||||
'long' => $this->data['User']['long'],
|
||||
'tz' => $this->data['User']['tz'],
|
||||
'email' => $this->data['User']['email']);
|
||||
// Scrub 'a dub
|
||||
$clean->cleanArray($this->data);
|
||||
$this->data['User']['email'] = $temp['email'];
|
||||
$this->data['User']['long'] = floatval($temp['long']);
|
||||
$this->data['User']['lat'] = floatval($temp['lat']);
|
||||
$this->data['User']['tz'] = intval($temp['tz']);
|
||||
$this->data['User']['role'] = 0;
|
||||
|
||||
if($this->User->save($this->data)) {
|
||||
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
|
||||
'envelope' => APP_EMAIL,
|
||||
'to' => $this->data['User']['email'],
|
||||
'subject' => 'Your '.APP_NAME.' Registration',
|
||||
'link' => APP_BASE.'/users/activate/'.$this->data['User']['active'],
|
||||
'type' => 'act');
|
||||
$this->Mail->mail($message);
|
||||
$this->Mail->send();
|
||||
|
||||
if (isset($_SESSION['invite']))
|
||||
$this->Party->addGuest($this->User->getLastInsertId(), $_SESSION['invite']);
|
||||
|
||||
$this->Session->setFlash('Thank you for registering! To login, you\'ll
|
||||
need to activate your account. Please check
|
||||
your email for your activation link.', 'infoFlash');
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
|
||||
else {
|
||||
$this->data['User']['password'] = null;
|
||||
$this->data['User']['confpass'] = null;
|
||||
$this->render();
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$this->data['User']['password'] = null;
|
||||
$this->data['User']['confpass'] = null;
|
||||
$this->Session->setFlash('There was an error in your submission. Please
|
||||
correct the errors shown below and try again.',
|
||||
'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function edit() {
|
||||
if (!isset($_SESSION['User'])) {
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
$this->set('error', false);
|
||||
$this->pageTitle = 'Edit My Account';
|
||||
if (empty($this->data)) {
|
||||
$this->User->id = $_SESSION['User']['id'];
|
||||
$this->data = $this->User->read();
|
||||
$this->data['User']['password'] = "";
|
||||
$this->set('utz', $this->data['User']['tz']);
|
||||
|
||||
$this->data['User']['name'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['User']['name']));
|
||||
$this->data['User']['website'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['User']['website']));
|
||||
$this->data['User']['location'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['User']['location']));
|
||||
|
||||
if (GMAP_API_KEY != null) {
|
||||
if ($this->data['User']['lat'])
|
||||
$this->set('map', 'mapInit('.$this->data['User']['lat'].','.$this->data['User']['long'].','.$this->data['User']['zoom'].')');
|
||||
else
|
||||
$this->set('map', 'mapInit()');
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$user = $this->User->findById($_SESSION['User']['id']);
|
||||
$this->User->id = $user['User']['id'];
|
||||
$this->set('utz', $user['User']['tz']);
|
||||
|
||||
$clean = new Sanitize();
|
||||
$temp = array('password' => $this->data['User']['password'],
|
||||
'confpassword' => $this->data['User']['confpassword'],
|
||||
'lat' => $clean->sql($this->data['User']['lat']),
|
||||
'long' => $clean->sql($this->data['User']['long']),
|
||||
'tz' => $clean->sql($this->data['User']['tz']));
|
||||
//Nuke everything else
|
||||
$clean->cleanArray($this->data);
|
||||
|
||||
$this->data['User']['email'] = $user['User']['email'];
|
||||
$this->data['User']['password'] = $temp['password'];
|
||||
$this->data['User']['confpassword'] = $temp['confpassword'];
|
||||
$this->data['User']['lat'] = floatval($temp['lat']);
|
||||
$this->data['User']['long'] = floatval($temp['long']);
|
||||
$this->data['User']['tz'] = intval($temp['tz']);
|
||||
$this->data['User']['role'] = $user['User']['role'];
|
||||
|
||||
if (!preg_match("/^(http|https)\:\/\//i", $this->data['User']['website']) &&
|
||||
!empty($this->data['User']['website']))
|
||||
$this->User->invalidate('website');
|
||||
|
||||
if ($this->data['User']['password'] === $this->data['User']['confpassword'] &&
|
||||
!empty($this->data['User']['password'])) {
|
||||
$pass = $this->Hash->password($this->data['User']['password'], $user['User']['email']);
|
||||
$this->data['User']['password'] = $pass['pass'];
|
||||
$this->data['User']['salt'] = $pass['salt'];
|
||||
}
|
||||
|
||||
else if (empty($this->data['User']['password']) && empty($this->data['User']['confpassword'])) {
|
||||
$this->data['User']['password'] = $user['User']['password'];
|
||||
$this->data['User']['salt'] = $user['User']['salt'];
|
||||
}
|
||||
|
||||
else {
|
||||
$this->set('error', true);
|
||||
$this->User->invalidate('password');
|
||||
$this->User->invalidate('confpassword');
|
||||
}
|
||||
|
||||
if ($this->User->validates($this->data)) {
|
||||
if ($this->User->save($this->data)) {
|
||||
$sess = $this->User->findById($user['User']['id']);
|
||||
$this->redirect('/users/');
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$this->validateErrors($this->User);
|
||||
$this->data['User']['password'] = null;
|
||||
$this->data['User']['confpassword'] = null;
|
||||
$this->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function login() {
|
||||
if ($this->Session->Check('User'))
|
||||
$this->redirect('/users');
|
||||
|
||||
$this->pageTitle = 'Login';
|
||||
if (!empty($this->data)) {
|
||||
if (empty($this->data['User']['email']) || empty($this->data['User']['password']))
|
||||
$this->render();
|
||||
|
||||
$user = $this->User->findByEmail($this->data['User']['email']);
|
||||
$pass = sha1($this->data['User']['password'].$user['User']['salt']);
|
||||
|
||||
if ($user['User']['password'] == $pass) {
|
||||
if ($user['User']['active'] != 1) {
|
||||
$this->Session->setFlash('Your account hasn\'t been activated yet. Please
|
||||
check your email (including junk/spam folders)
|
||||
for your activation link, or click <a href="'
|
||||
.APP_BASE.'/users/recover/activate">here</a> to
|
||||
resend your activation details.', 'infoFlash');
|
||||
$this->render();
|
||||
}
|
||||
|
||||
else {
|
||||
if (isset($_SESSION['invite']))
|
||||
$this->Party->addGuest($user['User']['id'], $_SESSION['invite']);
|
||||
|
||||
$this->Session->write('User', $user['User']);
|
||||
$this->redirect('/users/');
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Session->setFlash('The email address and password you supplied do
|
||||
not match. Please try again.', 'errorFlash');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!is_numeric($id))
|
||||
$this->redirect('/');
|
||||
|
||||
else {
|
||||
$user = $this->User->findById($id);
|
||||
$this->pageTitle = $user['User']['name'];
|
||||
$this->set('user', $user);
|
||||
if (GMAP_API_KEY != null && !empty($user['User']['lat']))
|
||||
$this->set('map', 'mapInit('.$user['User']['lat'].','.$user['User']['long'].','.$user['User']['zoom'].',\'stationary\');');
|
||||
|
||||
$this->Party->unbindModel(array('hasMany' => array('Comment')));
|
||||
$this->set('hparties', $this->User->hostOf($id));
|
||||
$att = $this->User->query('SELECT parties.id, parties.name
|
||||
FROM parties
|
||||
LEFT JOIN guests
|
||||
ON parties.id = guests.pid
|
||||
WHERE guests.uid = '.$id);
|
||||
$this->set('parties', $att);
|
||||
}
|
||||
}
|
||||
|
||||
function logout() {
|
||||
$this->Session->destroy();
|
||||
$this->Session->delete('User');
|
||||
$this->redirect('/');
|
||||
}
|
||||
|
||||
function recover($aType = null, $aCode = null, $aId = null) {
|
||||
switch ($aType) {
|
||||
case "password":
|
||||
$this->pageTitle = "Password Recovery";
|
||||
$this->set('atitle', 'Password Recovery');
|
||||
$this->set('hideInput', false);
|
||||
$this->set('url', 'password');
|
||||
|
||||
if (!empty($this->data)) {
|
||||
$user = $this->User->findByEmail($this->data['User']['email']);
|
||||
|
||||
if (!isset($user['User']['email'])) {
|
||||
$this->Session->setFlash('Could not find a user with that email address. Please check it and try again.', 'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
else {
|
||||
$code = md5($user['User']['salt'].$user['User']['email'].$user['User']['password']);
|
||||
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
|
||||
'envelope' => APP_EMAIL,
|
||||
'to' => $user['User']['email'],
|
||||
'subject' => APP_NAME.' Password Request',
|
||||
'link' => APP_BASE.'/users/recover/password/'.$code.'/'.$user['User']['id'],
|
||||
'type' => 'prec');
|
||||
|
||||
$this->Mail->mail($message);
|
||||
$this->Mail->send();
|
||||
$this->Session->setFlash('An email has been sent to '.$user['User']['email'].' with reset instructions.', 'errorFlash');
|
||||
$this->redirect('users/login');
|
||||
}
|
||||
}
|
||||
|
||||
if ($aCode !== null && $aId !== null) {
|
||||
$this->set('hideInput', true);
|
||||
$this->set('reset', false);
|
||||
$user = $this->User->findById($aId);
|
||||
|
||||
if (!$user) {
|
||||
$this->Session->setFlash('Invalid request. Please check the URL and try again.', 'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
|
||||
if ($aCode == md5($user['User']['salt'].$user['User']['email'].$user['User']['password'])) {
|
||||
$this->set('reset', true);
|
||||
$this->set('code', $aCode."/".$aId);
|
||||
$this->render();
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Session->setFlash('Invalid request. Please check the URL and try again.', 'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "activate":
|
||||
$this->pageTitle = 'Resend Activation Code';
|
||||
$this->set('atitle', 'Resend Activation Code');
|
||||
$this->set('hideInput', false);
|
||||
$this->set('url', 'activate');
|
||||
|
||||
if (!empty($this->data)) {
|
||||
$user = $this->User->findByEmail($this->data['User']['email']);
|
||||
|
||||
if (!$user) {
|
||||
$this->Session->setFlash('Could not find a user with that email address. Please check it and try again.', 'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
|
||||
if ($user['User']['active'] == 1)
|
||||
$this->redirect('/users/login');
|
||||
|
||||
else {
|
||||
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
|
||||
'envelope' => APP_EMAIL,
|
||||
'to' => $this->data['User']['email'],
|
||||
'subject' => 'Your '.APP_NAME.' Registration',
|
||||
'link' => APP_BASE.'/users/activate/'.$user['User']['active'],
|
||||
'type' => 'act');
|
||||
$this->Mail->mail($message);
|
||||
$this->Mail->send();
|
||||
$this->Session->setFlash('Your activation code has been resent.', 'infoFlash');
|
||||
$this->redirect('users/login');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "reset":
|
||||
if ($aCode !== null && $aId !== null) {
|
||||
if (!empty($this->data)) {
|
||||
$user = $this->User->findById($aId);
|
||||
if (!$user) {
|
||||
$this->Session->setFlash('Invalid request. Please check the URL and try again.', 'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
|
||||
if ($aCode == md5($user['User']['salt'].$user['User']['email'].$user['User']['password'])) {
|
||||
$string = $user['User']['email'] . uniqid(rand(), true) . $this->data['User']['password'];
|
||||
$this->data['User']['salt'] = substr(md5($string), 0, 9);
|
||||
$this->data['User']['password'] = sha1($this->data['User']['password'] . $this->data['User']['salt']);
|
||||
$this->data['User']['id'] = $aId;
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash('Your password has been reset.', 'infoFlash');
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->redirect('/');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function activate($aKey = null) {
|
||||
if ($aKey == null)
|
||||
$this->redirect('/');
|
||||
|
||||
else {
|
||||
$user = $this->User->findByActive($aKey);
|
||||
if (empty($user['User']['id'])) {
|
||||
$this->Session->setFlash('Your account could not be activated. Please make
|
||||
sure the URL entered is correct and try again.', 'errorFlash');
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
|
||||
else {
|
||||
$this->data = $user;
|
||||
$this->data['User']['active'] = 1;
|
||||
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash('Your account was successfully activated.', 'infoFlash');
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id: index.php,v 1.3 2006-10-08 03:39:21 reed%reedloden.com Exp $ */
|
||||
/**
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.app
|
||||
* @since CakePHP v 0.10.0.1076
|
||||
* @version $Revision: 1.3 $
|
||||
* @modifiedby $LastChangedBy: phpnut $
|
||||
* @lastmodified $Date: 2006-10-08 03:39:21 $
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
|
||||
?>
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Admin extends AppModel {
|
||||
var $name = 'Admin';
|
||||
var $useTable = "parties";
|
||||
}
|
||||
?>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Guest extends AppModel {
|
||||
var $name = 'Guest';
|
||||
}
|
||||
?>
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Page extends AppModel {
|
||||
var $name = 'Page';
|
||||
var $useTable = 'parties';
|
||||
|
||||
function getUsers() {
|
||||
$rv = $this->query("SELECT COUNT(*) FROM users");
|
||||
return $rv[0][0]["COUNT(*)"];
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Party extends AppModel {
|
||||
var $name = 'Party';
|
||||
var $validate = array(
|
||||
'name' => "/^\S/",
|
||||
'einvite' => VALID_EMAIL,
|
||||
'duration' => VALID_NUMBER
|
||||
);
|
||||
|
||||
function getComments($pid) {
|
||||
$rv = $this->query("SELECT users.id AS uid, users.name,
|
||||
comments.id AS cid, comments.time, comments.text
|
||||
FROM users, parties, comments
|
||||
WHERE comments.assoc = ".$pid."
|
||||
AND users.id = comments.owner
|
||||
AND parties.id = ".$pid."
|
||||
ORDER BY cid ASC");
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function getHost($uid) {
|
||||
$rv = $this->query("SELECT name FROM users WHERE id = ".$uid);
|
||||
return @$rv[0]['users']['name'];
|
||||
}
|
||||
|
||||
function isGuest($pid, $uid) {
|
||||
$rv = $this->query('SELECT id FROM guests WHERE uid = '.$uid.' AND pid = '.$pid);
|
||||
if (!empty($rv[0]['guests']['id']))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function getGuests($pid) {
|
||||
$rv = $this->query("SELECT users.id, users.name, users.email, guests.invited
|
||||
FROM users
|
||||
LEFT JOIN guests
|
||||
ON users.id = guests.uid
|
||||
WHERE guests.pid = ".$pid);
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function rsvp($pid, $uid) {
|
||||
$party = $this->findById($pid);
|
||||
if (!empty($party['Party']['id']) && !$this->isGuest($pid, $uid)) {
|
||||
$this->query("INSERT INTO guests (id, pid, uid, invited)
|
||||
VALUES (NULL, ".$party['Party']['id'].", ".$uid.", 0)");
|
||||
}
|
||||
}
|
||||
|
||||
function unrsvp($pid, $uid) {
|
||||
$party = $this->findById($pid);
|
||||
if (!empty($party['Party']['id']) && $this->isGuest($pid, $uid)) {
|
||||
$this->query('DELETE FROM guests WHERE uid = '.$uid.' AND pid = '.$pid);
|
||||
}
|
||||
}
|
||||
|
||||
function addGuest($uid, $icode) {
|
||||
$party = $this->findByInvitecode($icode);
|
||||
if (!empty($party['Party']['id'])) {
|
||||
$check = $this->query('SELECT uid FROM guests WHERE uid = '.$uid.'
|
||||
AND pid = '.$party['Party']['id']);
|
||||
if (empty($check[0]['guests']['uid']) && $uid != $party['Party']['owner']) {
|
||||
$this->query("INSERT INTO guests (id, pid, uid, invited)
|
||||
VALUES (NULL, ".$party['Party']['id'].", ".$uid.", 1)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findByInvitecode($icode) {
|
||||
$rv = $this->query('SELECT * FROM parties AS Party WHERE invitecode = "'.$icode.'" LIMIT 1');
|
||||
return @$rv[0];
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class User extends AppModel {
|
||||
var $name = 'User';
|
||||
var $validate = array(
|
||||
'email' => VALID_EMAIL,
|
||||
'name' => "/^\S/"
|
||||
);
|
||||
|
||||
function memberOf($uid) {
|
||||
$rv = $this->query('SELECT parties.id, parties.name FROM guests, parties WHERE guests.uid = '.$uid.' AND parties.id = guests.pid');
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function hostOf($uid) {
|
||||
$rv = $this->query('SELECT id, name FROM parties WHERE owner = '.$uid);
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function invitedTo($uid) {
|
||||
$rv = $this->query('SELECT parties.id, parties.name FROM guests, parties WHERE guests.uid = '.$uid.' AND parties.id = guests.pid AND guests.invited = 1');
|
||||
return $rv;
|
||||
}
|
||||
}
|
||||
?>
|
||||
199
mozilla/webtools/partytool/vendors/webServices.php
vendored
199
mozilla/webtools/partytool/vendors/webServices.php
vendored
@@ -1,199 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class webServices {
|
||||
|
||||
var $userid;
|
||||
var $host;
|
||||
var $randomize;
|
||||
|
||||
function webServices($data) {
|
||||
switch ($data['type']) {
|
||||
case "flickr":
|
||||
$this->host = "api.flickr.com";
|
||||
|
||||
if (array_key_exists('userid', $data))
|
||||
$this->userid = $data['userid'];
|
||||
|
||||
if (array_key_exists('randomize', $data))
|
||||
$this->randomize = $data['randomize'];
|
||||
|
||||
if (array_key_exists('username', $data)) {
|
||||
$head = "GET /services/rest/?method=flickr.people.findByUsername&api_key=".FLICKR_API_KEY."&username=".$data['username']." HTTP/1.1\r\n";
|
||||
$head .= "Host: ".$this->host."\r\n";
|
||||
$head .= "Connection: Close\r\n\r\n";
|
||||
|
||||
if ($results = $this->fetchResults($head)) {
|
||||
preg_match('/nsid=\"(.*)\"/', $results, $matches);
|
||||
if ($matches[1]) {
|
||||
$this->userid = $matches[1];
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "gsuggest":
|
||||
$this->host = "api.google.com";
|
||||
break;
|
||||
|
||||
case "geocode":
|
||||
$this->host = "maps.google.com";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function getFlickrId() {
|
||||
return $this->userid;
|
||||
}
|
||||
|
||||
function fetchPhotos($tags, $num_results, $single_user) {
|
||||
$params = array('api_key' => FLICKR_API_KEY,
|
||||
'method' => 'flickr.photos.search',
|
||||
'format' => 'php_serial',
|
||||
'tags' => $tags,
|
||||
'per_page' => $num_results);
|
||||
|
||||
if ($single_user)
|
||||
$params['user_id'] = $this->userid;
|
||||
|
||||
$encoded_params = array();
|
||||
foreach ($params as $k => $v)
|
||||
$encoded_params[] = urlencode($k).'='.urlencode($v);
|
||||
|
||||
$head = 'GET /services/rest/?'.implode('&', $encoded_params)." HTTP/1.1 \r\n";
|
||||
$head .= 'Host: '.$this->host."\r\n";
|
||||
$head .= "Connection: Close\r\n\r\n";
|
||||
|
||||
if ($results = $this->fetchResults($head)) {
|
||||
$resp = split("\r\n\r\n", $results);
|
||||
$data = unserialize($resp[1]);
|
||||
|
||||
if ($data['stat'] == 'ok') {
|
||||
$arr = array();
|
||||
for ($i = 0; $i < count($data['photos']['photo']); $i++) {
|
||||
$p = $data['photos']['photo'][$i];
|
||||
$arr[$i] = array('id' => $p['id'],
|
||||
'owner' => $p['owner'],
|
||||
'secret' => $p['secret'],
|
||||
'server' => $p['server'],
|
||||
'farm' => $p['farm'],
|
||||
'title' => $p['title']);
|
||||
}
|
||||
|
||||
if ($this->randomize) {
|
||||
// Randomize the results
|
||||
shuffle($arr);
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
function GSuggest($phrase) {
|
||||
$soapy = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>
|
||||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
||||
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
|
||||
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
|
||||
<SOAP-ENV:Body>
|
||||
<doSpellingSuggestion xmlns="urn:GoogleSearch">
|
||||
<key xsi:type="xsd:string">'.GSEARCH_API_KEY.'</key>
|
||||
<phrase xsi:type="xsd:string">'.$phrase.'</phrase>
|
||||
</doSpellingSuggestion>
|
||||
</SOAP-ENV:Body>
|
||||
</SOAP-ENV:Envelope>';
|
||||
|
||||
$head = "POST /search/beta2 HTTP/1.1\r\n";
|
||||
$head .= "Host: api.google.com\r\n";
|
||||
$head .= "MessageType: CALL\r\n";
|
||||
$head .= "Content-type: text/xml\r\n";
|
||||
$head .= "Content-length: ".strlen($soapy)."\r\n";
|
||||
$head .= "Connection: Close\r\n\r\n";
|
||||
$head .= $soapy;
|
||||
|
||||
if ($results = $this->fetchResults($head)) {
|
||||
if (preg_match('/return xsi:type="xsd:string">(.*)</', $results, $matches))
|
||||
return $matches[1];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function geocode($query) {
|
||||
$head = "GET /maps/geo?q=".urlencode($query)."&output=xml&key=".GMAP_API_KEY." HTTP/1.1\r\n";
|
||||
$head .= "Host: maps.google.com\r\n";
|
||||
$head .= "Connection: Close\r\n\r\n";
|
||||
|
||||
if ($results = $this->fetchResults($head)) {
|
||||
if (stristr($results, '<code>200</code>')) {
|
||||
preg_match('/coordinates>(.*)</', $results, $matches);
|
||||
$ll = explode(',', $matches[1]);
|
||||
$rv = array('lat' => $ll[1], 'lng' => $ll[0]);
|
||||
return $rv;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function fetchResults($headers) {
|
||||
$fs = fsockopen($this->host, 80, $errno, $errstr, 30);
|
||||
if (!$fs)
|
||||
return 0;
|
||||
|
||||
else {
|
||||
fwrite($fs, $headers);
|
||||
stream_set_timeout($fs, 2);
|
||||
|
||||
$buffer = null;
|
||||
while (!feof($fs))
|
||||
$buffer .= fgets($fs, 128);
|
||||
|
||||
fclose($fs);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,18 +0,0 @@
|
||||
<h1>Comments</h1>
|
||||
<p>Switch view to: <a href="<?php echo $html->url('/admin/'); ?>">Parties»</a> <a href="<?php echo $html->url('/admin/users'); ?>">Users»</a></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>Text</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach($comments as $comment): ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo $html->url('/parties/view/'.$comment['Comment']['assoc'].'#c'.$comment['Comment']['id']); ?>"><?php echo $comment['Comment']['id']; ?></a></td>
|
||||
<td><?php echo $comment['Comment']['text']; ?></td>
|
||||
<td><a href="<?php echo $html->url('/admin/edit/comment/'.$comment['Comment']['id']); ?>">Edit</a></td>
|
||||
<td><a href="<?php echo $html->url('/admin/delete/comment/'.$comment['Comment']['id']); ?>" onclick="return confirm('Delete comment <?php echo $comment['Comment']['id']; ?>?')">Delete</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
@@ -1,128 +0,0 @@
|
||||
<?php if (isset($user)): ?>
|
||||
<h1><?php echo $user['User']['name'].' (<a href="'.$html->url('/users/view/'.$user['User']['id']).'">'.$user['User']['id']; ?></a>)</h1>
|
||||
<form class="fxform" action="<?php echo $html->url('/admin/edit/user/'.$user['User']['id']); ?>" method="post">
|
||||
<div>
|
||||
<label for="UserName" class="label-large">Name:</label>
|
||||
<?php echo $html->input('User/name', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserRole" class="label-large">Admin privileges:</label>
|
||||
<?php echo $html->checkbox('User/role'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserEmail" class="label-large">Email address:</label>
|
||||
<?php echo $html->input('User/email', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserWebsite" class="label-large">Website:</label>
|
||||
<?php echo $html->input('User/website', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserActive" class="label-large">Activation code:</label>
|
||||
<?php echo $html->input('User/active', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="location" class="label-large">Location:</label>
|
||||
<?php echo $html->input('User/location', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserShowemail" class="label-large">Show email:</label>
|
||||
<?php echo $html->checkbox('User/showemail'); ?><br/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserShowloc" class="label-large">Show location:</label>
|
||||
<?php echo $html->checkbox('User/showloc'); ?><br/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserShowmap" class="label-large">Show map:</label>
|
||||
<?php echo $html->checkbox('User/showmap'); ?><br/>
|
||||
</div>
|
||||
<?php echo $html->hidden('User/id', array('value' => $user['User']['id'])).$html->submit('Submit'); ?>
|
||||
</form>
|
||||
|
||||
<?php endif; if (isset($party)): ?>
|
||||
<h1><?php echo $party['Party']['name'].' (<a href="'.$html->url('/parties/view/'.$party['Party']['id']).'">'.$party['Party']['id']; ?></a>)</h1>
|
||||
<form class="fxform" action="<?php echo $html->url('/admin/edit/party/'.$party['Party']['id']); ?>" method="post">
|
||||
<div>
|
||||
<label for="PartyOwner" class="label-large">Party Owner:</label>
|
||||
<?php echo $html->input('Party/owner', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyName" class="label-large">Party Name:</label>
|
||||
<?php echo $html->input('Party/name', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyVname" class="label-large">Venue Name:</label>
|
||||
<?php echo $html->input('Party/vname', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyWebsite" class="label-large">Web site:</label>
|
||||
<?php echo $html->input('Party/website', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyAddress" class="label-large">Address:</label>
|
||||
<?php echo $html->input('Party/address', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyDate" class="label-large">Date:</label>
|
||||
<?php echo $html->input('Party/date', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyNotes" class="label-large">Additional Notes:</label>
|
||||
<?php echo $html->textarea('Party/notes', array('rows' => 10, 'cols' => 50)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyConfirmed" class="label-large">Time:</label>
|
||||
<?php echo $html->radio('Party/confirmed', array(0 => 'Tentative', 1 => 'Confirmed')); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyDuration" class="label-large">Duration (in hours):</label>
|
||||
<?php echo $html->input('Party/duration', array('size' => 5)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyCanceled" class="label-large">Canceled:</label>
|
||||
<?php echo $html->checkbox('Party/canceled'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyUseflickr" class="label-large">Use Flickr:</label>
|
||||
<?php echo $html->checkbox('Party/useflickr'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyFlickrperms" class="label-large">Show:</label>
|
||||
<?php echo $html->radio('Party/flickrperms', array(0 => 'Only my photos', 1 => 'Anyone\'s photos')); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyFlickrusr" class="label-large">Flickr username:</label>
|
||||
<?php echo $html->input('Party/flickrusr', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyFlickrusr" class="label-large">Flickr id:</label>
|
||||
<?php echo $html->input('Party/flickrid', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyInviteonly" class="label-large">Invite only:</label>
|
||||
<?php echo $html->checkbox('Party/inviteonly'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyGuestcomments" class="label-large">Limit comments to party guests only:</label>
|
||||
<?php echo $html->checkbox('Party/guestcomments'); ?>
|
||||
</div>
|
||||
<br/>
|
||||
<?php echo $html->hidden('Party/id', array('value' => $party['Party']['id'])).$html->submit('Submit'); ?>
|
||||
</form>
|
||||
|
||||
<?php endif; if(isset($comment)): ?>
|
||||
<h1>Comment <?php echo '<a href="'.$html->url('/parties/view/'.$comment['Comment']['assoc'].'#c'.$comment['Comment']['id']).'">#'.$comment['Comment']['id']; ?></a> by <?php echo '<a href="'.$html->url('/users/view/'.$comment['Comment']['owner']).'">'.$owner; ?></a></h1>
|
||||
<form class="fxform" action="<?php echo $html->url('/admin/edit/comment/'.$comment['Comment']['id']); ?>" method="post">
|
||||
<div>
|
||||
<label for="CommentAssoc" class="label-large">Party:</label>
|
||||
<?php echo $html->input('Comment/assoc', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="CommentText" class="label-large">Text:</label>
|
||||
<?php echo $html->textarea('Comment/text', array('rows' => 10, 'cols' => 50)); ?>
|
||||
</div>
|
||||
<?php echo $html->hidden('Comment/id', array('value' => $comment['Comment']['id'])).$html->submit('Submit'); ?>
|
||||
</form>
|
||||
|
||||
<?php endif; ?>
|
||||
@@ -1,18 +0,0 @@
|
||||
<h1>Parties</h1>
|
||||
<p>Switch view to: <a href="<?php echo $html->url('/admin/users'); ?>">Users»</a> <a href="<?php echo $html->url('/admin/comments'); ?>">Comments»</a></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>Name</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach($parties as $party): ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo $html->url('/parties/view/'.$party['Party']['id']); ?>"><?php echo $party['Party']['id']; ?></a></td>
|
||||
<td><?php echo $party['Party']['name']; ?></td>
|
||||
<td><a href="<?php echo $html->url('/admin/edit/party/'.$party['Party']['id']); ?>">Edit</a></td>
|
||||
<td><a href="<?php echo $html->url('/admin/delete/party/'.$party['Party']['id']); ?>" onclick="return confirm('Delete party <?php echo $party['Party']['id']; ?>?')">Delete</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
@@ -1,18 +0,0 @@
|
||||
<h1>Users</h1>
|
||||
<p>Switch view to: <a href="<?php echo $html->url('/admin/'); ?>">Parties»</a> <a href="<?php echo $html->url('/admin/comments'); ?>">Comments»</a></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>Name</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach($users as $user): ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo $html->url('/users/view/'.$user['User']['id']); ?>"><?php echo $user['User']['id']; ?></a></td>
|
||||
<td><?php echo $user['User']['name']; ?></td>
|
||||
<td><a href="<?php echo $html->url('/admin/edit/user/'.$user['User']['id']); ?>">Edit</a></td>
|
||||
<td><a href="<?php echo $html->url('/admin/delete/user/'.$user['User']['id']); ?>" onclick="return confirm('Delete user <?php echo $user['User']['id']; ?>?')">Delete</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php if(!isset($_SESSION['User'])): ?>
|
||||
<strong>Welcome, Guest!</strong>
|
||||
<a href="<?php echo $html->url('/users/login'); ?>">Login</a> | <a href="<?php echo $html->url('/users/register'); ?>">Register</a>
|
||||
<?php else: ?>
|
||||
<strong>Welcome, <?php echo $_SESSION['User']['name']; ?>!</strong>
|
||||
<a href="<?php echo $html->url('/users'); ?>">My Account</a> | <a href="<?php echo $html->url('/users/logout'); ?>">Logout</a>
|
||||
<?php endif; ?>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Latest Comments"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/'.$pid); ?></link>
|
||||
<title><?php echo APP_NAME." - Latest Comments"; ?></title>
|
||||
<?php foreach($comments as $comment): ?>
|
||||
<item>
|
||||
<title><![CDATA[<?php echo substr($comment['comments']['text'], 0, 25).'...'; ?>]]></title>
|
||||
<description><?php echo $comment['comments']['text'] ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/'.$comment['comments']['assoc'].'#c'.$comment['comments']['id']); ?></link>
|
||||
</item>
|
||||
<?php endforeach; ?>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,22 +0,0 @@
|
||||
BEGIN:VCALENDAR
|
||||
X-WR-CALNAME:<?php echo APP_NAME."\n"; ?>
|
||||
X-WR-CALDESC:Upcoming Parties
|
||||
PRODID:-//MozillaPartyTool//calendar//EN
|
||||
VERSION:2.0
|
||||
CALSCALE:GREGORIAN
|
||||
METHOD:PUBLISH
|
||||
<?php foreach($events as $event):
|
||||
if ($event['Feeds']['canceled']) continue; ?>
|
||||
BEGIN:VEVENT
|
||||
UID:<?php echo APP_BASE.$html->url('/parties/view/'.$event['Feeds']['id'])."\n"; ?>
|
||||
DTSTAMP:<?php echo gmdate('Ymd\This\Z', $event['Feeds']['date'])."\n"; ?>
|
||||
LOCATION:<?php echo $event['Feeds']['lat'].'\, '.$event['Feeds']['long'].'('.$event['Feeds']['address'].")\n"; ?>
|
||||
SUMMARY:<?php echo $event['Feeds']['name']."\n"; ?>
|
||||
DTSTART:<?php echo gmdate('Ymd\This', $event['Feeds']['date'])."\n"; ?>
|
||||
DURATION:PT<?php echo $event['Feeds']['duration']; ?>H
|
||||
URL:<?php echo APP_BASE.$html->url('/parties/view/'.$event['Feeds']['id'])."\n"; ?>
|
||||
STATUS:<?php echo (($event['Feeds']['confirmed'] == 1) ? "CONFIRMED" : "TENTATIVE")."\n"; ?>
|
||||
DESCRIPTION: <?php echo $event['Feeds']['name'].'\n '.$event['Feeds']['address'].'\n '.date('h:ia', $event['Feeds']['date']).'\n '.$event['Feeds']['notes'].'\n'."\n"; ?>
|
||||
END:VEVENT
|
||||
<?php endforeach; ?>
|
||||
END:VCALENDAR
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Party Count"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/'); ?></link>
|
||||
<title><?php echo APP_NAME." - Party Count"; ?></title>
|
||||
<item>
|
||||
<title><?php echo $count; ?></title>
|
||||
<description>Total Parties</description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/all/'); ?></link>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Latest Parties"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/'); ?></link>
|
||||
<title><?php echo APP_NAME." - Latest Parties"; ?></title>
|
||||
<?php foreach($latest as $party):
|
||||
if ($party['Feeds']['canceled']) continue; ?>
|
||||
<item>
|
||||
<title><?php echo $party['Feeds']['name'] ?></title>
|
||||
<description><?php echo $party['Feeds']['vname'] ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/'.$party['Feeds']['id']); ?></link>
|
||||
</item>
|
||||
<?php endforeach; ?>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; ?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title><?php echo $party['Feeds']['name']; ?></title>
|
||||
<id>tag:<?php echo APP_BASE; ?>,2006:/parties/view/<?php echo $party['Feeds']['id']; ?></id>
|
||||
<subtitle><?php echo APP_NAME; ?> Photostream</subtitle>
|
||||
<updated><?php echo date('Y-m-d\TH:i:s\Z'); ?></updated>
|
||||
<generator uri="http://www.screwedbydesign.com/software/partytool">Mozilla Party Tool</generator>
|
||||
|
||||
<?php foreach ($flickr as $pic): ?>
|
||||
<entry>
|
||||
<title><?php echo $pic['title']; ?></title>
|
||||
<link rel="alternate" type="text/html" href="http://www.flickr.com/photos/<?php echo $pic['owner']."/".$pic['id']."/"; ?>"/>
|
||||
<id>tag:flickr.com,2005:/photo/<?php echo $pic['id']; ?></id>
|
||||
<published><?php echo date('Y-m-d\TH:i:s\Z'); ?></published>
|
||||
<updated><?php echo date('Y-m-d\TH:i:s\Z'); ?></updated>
|
||||
<content type="html"><a href="http://www.flickr.com/photos/<?php echo $pic['owner']."/".$pic['id']."/" ?>"> <img src="http://static.flickr.com/<?php echo $pic['server']."/".$pic['id']."_".$pic['secret']."_m.jpg" ?>" title="<?php echo $pic['title']; ?>"/></a></content>
|
||||
<author>
|
||||
<name><?php echo $pic['owner']; ?></name>
|
||||
<uri>http://www.flickr.com/people/<?php echo $pic['owner']; ?>/</uri>
|
||||
</author>
|
||||
</entry>
|
||||
<?php endforeach; ?>
|
||||
</feed>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Top Guests"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/all'); ?></link>
|
||||
<title><?php echo APP_NAME." - Top Guests"; ?></title>
|
||||
<?php foreach($items as $item):?>
|
||||
<item>
|
||||
<title><?php echo $item['parties']['name'].' ('.$item[0]['count'].')'; ?></title>
|
||||
<description><?php echo $item['parties']['name'].' - '.$item[0]['count'].' guest'.(($item[0]['count'] != 1) ? 's' : ''); ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/'.$item['guests']['id']); ?></link>
|
||||
</item>
|
||||
<?php endforeach; ?>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Upcoming Parties"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/'); ?></link>
|
||||
<title><?php echo APP_NAME." - Upcoming Parties"; ?></title>
|
||||
<?php foreach($latest as $party):
|
||||
if ($party['Feeds']['canceled']) continue; ?>
|
||||
<item>
|
||||
<title><![CDATA[<?php echo $party['Feeds']['name'] ?>]]></title>
|
||||
<description><?php echo date('Y-m-d H:i', $party['Feeds']['date']); ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/'.$party['Feeds']['id']); ?></link>
|
||||
</item>
|
||||
<?php endforeach; ?>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Total Users"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/'); ?></link>
|
||||
<title><?php echo APP_NAME." - Total Users"; ?></title>
|
||||
<item>
|
||||
<title><?php echo $count; ?></title>
|
||||
<description>Total Users</description>
|
||||
<link><?php echo APP_BASE.$html->url('/'); ?></link>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title><?php echo APP_NAME." - ".$title_for_layout?></title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="<?php echo $html->url('/favicon.ico'); ?>"/>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $html->url('/css/main.css'); ?>"/>
|
||||
<link rel="alternate" type="application/rss+xml" href="<?php echo $html->url('/feeds/latest'); ?>"/>
|
||||
</head>
|
||||
<body<?php echo (isset($map)) ? ' onload="'.$map.'" onunload="GUnload()"' : '';?>>
|
||||
<div id="container">
|
||||
<p class="skipLink"><a href="#content" accesskey="2">Skip to main content</a></p>
|
||||
<div id="mozilla-com"><a href="http://www.mozilla.com/">Visit Mozilla.com</a></div>
|
||||
<div id="header">
|
||||
<div id="key-title">
|
||||
<h1><a href="<?php echo $html->url('/'); ?>" title="Return to home page" accesskey="1"><img src="<?php echo $html->url('/img/firefox-title.png'); ?>" width="276" height="54" alt="Firefox Party"/></a></h1>
|
||||
<div id="user"><?php echo $this->renderElement('user_options'); ?></div>
|
||||
</div>
|
||||
<div id="key-menu">
|
||||
<ul id="menu-firefox">
|
||||
<li<?php echo (@$current == 'home') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/'); ?>">Home</a></li>
|
||||
<li<?php echo (@$current == 'map') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/parties/'); ?>">View Map</a></li>
|
||||
<li<?php echo (@$current == 'parties') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/parties/view/all/'); ?>">View Parties</a></li>
|
||||
<li<?php echo (@$current == 'create') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/parties/add/'); ?>">Create Party</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<?php $this->controller->Session->flash(); ?>
|
||||
|
||||
<?php echo $content_for_layout; ?>
|
||||
</div>
|
||||
<div id="footer">
|
||||
Copyright © <?php echo date('Y'); ?> Mozilla<br/>
|
||||
<a href="<?php echo $html->url('/privacy-policy'); ?>">Privacy Policy</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +0,0 @@
|
||||
<div id='flash' class='error'><?php echo $content_for_layout ?></div>
|
||||
@@ -1 +0,0 @@
|
||||
<div id='flash' class='info'><?php echo $content_for_layout ?></div>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
$difference = $time - time();
|
||||
$days_left = floor($difference/60/60/24);
|
||||
?>
|
||||
<div id="f-left">
|
||||
<?php echo $front_text;
|
||||
if (@$_SESSION['User']['role'] == 1): ?>
|
||||
<a href="<?php echo $html->url('/pages/edit'); ?>">Edit</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div id="f-right">
|
||||
<div class="cbox">
|
||||
<span class="ctxt"><?php echo $pcount."</span><br/>".(($pcount == 1) ? ' Party' : ' Parties'); ?>
|
||||
<div class="ifeed">
|
||||
<a style="padding-right: 2px;" title="Party Calendar" href="<?php echo $html->url('/feeds/ical'); ?>"><img src="<?php echo $html->url('/img/ical.png'); ?>" alt="iCAL"/></a><a title="Party Count Feed" href="<?php echo $html->url('/feeds/'); ?>"><img src="<?php echo $html->url('/img/feed16.png'); ?>" alt="RSS"/></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbox">
|
||||
<span class="ctxt"><?php echo $ucount."</span><br/>".(($ucount == 1) ? ' Partygoer' : ' Partygoers'); ?>
|
||||
<div class="cfeed">
|
||||
<a title="User Count Feed" href="<?php echo $html->url('/feeds/users/'); ?>"><img src="<?php echo $html->url('/img/feed16.png'); ?>" alt="RSS"/></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($days_left > 0): ?>
|
||||
<div class="cbox">
|
||||
<span class="ctxt"><?php echo $days_left."</span><br/>".(($days_left == 1) ? ' Day' : ' Days'); ?> until we party!
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
@@ -1,6 +0,0 @@
|
||||
<form action="<?php echo $html->url('/pages/edit'); ?>" method="post">
|
||||
<h1>Front Page Text</h1>
|
||||
<?php echo $html->textarea('Pages/text', array('rows' => 35, 'cols' => 80)); ?>
|
||||
<h1>Countdown Timer</h1>
|
||||
<?php echo $html->dateTimeOptionTag('Pages/date', 'YMD', 24, $selected).'<br/><br/>'.$html->submit('Submit'); ?>
|
||||
</form>
|
||||
@@ -1,42 +0,0 @@
|
||||
<h2>Mozilla Privacy Policy</h2>
|
||||
|
||||
<h3>Website Visitors</h3>
|
||||
|
||||
<p>Except as described below, the Mozilla Foundation and the Mozilla Corporation (collectively "Mozilla") do not collect or require visitors to its Web sites to furnish personally-identifying information such as names, email addresses and phone numbers. Like most Web site operators, Mozilla does collect non-personally-identifying information of the sort that web browsers and servers typically make available, such as the browser type, language preference, referring site, and date and time of each visitor request. Mozilla also collects potentially personally-identifying information like Internet Protocol (IP) addresses, which are non-personally-identifying in and of themselves but could be used in conjunction with other information to personally identify users.</p>
|
||||
|
||||
<p>Mozilla's purpose in collecting this information is to better understand how Mozilla's visitors use its Web sites. To that end, Mozilla may share potentially personally-identifying information with its employees, contractors and affiliated organizations. Mozilla may also release non-personally-identifying information about visitors, e.g. by publishing a report on Web site usage trends. Otherwise, Mozilla will not publicly release potentially personally-identifying information except under the same circumstances as Mozilla releases personally-identifying information. Those circumstances are explained in detail below.</p>
|
||||
|
||||
<h3>Community Members</h3>
|
||||
|
||||
<p>Certain members of the Mozilla community (contributors, customers, etc.) choose to interact with Mozilla in ways that require Mozilla and others to know more about them. The amount and type of information that Mozilla gathers from those members depends on the nature of the interaction. For example, members who wish to post content to certain portions of Mozilla's Web sites are asked to provide usernames that identify that content as having been posted by a particular member. Developers, by comparison, are asked to provide contact information, up to and sometimes including telephone or fax numbers, so that they can be contacted as necessary. Customers of the Mozilla store are asked to provide even more information, including billing and shipping addresses and credit card or similar information. In each case, Mozilla collects personally-identifying information only insofar as is necessary to fulfill the purpose of the community member's interaction with Mozilla.</p>
|
||||
|
||||
<p>Mozilla is an open organization that believes in sharing as much information as possible about its products, its operations and its associations. Accordingly, community members should assume - as should most folks who interact with Mozilla - that any personally-identifying information provided to Mozilla will be made available to the public. There are three broad exceptions to that rule:</p>
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mozilla does not publicly release information gathered in connection with commercial transactions (i.e., transactions involving money), including transactions conducted through the Mozilla Store.</li>
|
||||
<li>Mozilla does not make publicly available information that is used to authenticate users the publication of which would compromise the security of Mozilla's Web sites (e.g., passwords).</li>
|
||||
<li>Mozilla does not make publicly available information that it specifically promises at the time of collection to maintain in confidence.</li>
|
||||
</ol>
|
||||
|
||||
<p>Outside those three contexts, users should assume that personally-identifying information provided through Mozilla's Web sites will be made available to the public.</p>
|
||||
|
||||
<h3>Interactive Product Features</h3>
|
||||
|
||||
<p>Certain Mozilla products contain features that report, or that permit users to report, the user's usage patterns and problems - whether caused by Mozilla's software, third party software, or third-party Web sites - to Mozilla. The reports generated by these features typically include non-personally-identifying information such as the configuration of the user's computer and the code running at the time the problem occurred. Some of these features give users the option of providing personally-identifying information, though none of these features require it. Some Mozilla software features that do permit users to provide personally-identifying information advise in advance that such information will not be made publicly available. Mozilla analyzes the information provided by these interactive product features to develop a better understanding of how its products are performing and being used. It does not use the information to track the usage of its products by identifiable individuals.</p>
|
||||
|
||||
<h3>Cookies</h3>
|
||||
|
||||
<p>A cookie is a string of information that a Web site stores on a visitor's computer, and that the visitor's browser provides to the Web site each time the visitor returns. Mozilla's Web sites use cookies to help Mozilla identify and track visitors, their usage of Mozilla Web sites, and their Web site access preferences across multiple requests and visits to Mozilla's Web sites. It is possible to link cookies to personally-identifying information, thereby permitting Web site operators to track the online movements of particular individuals. Mozilla, however, does not do so. Instead, it uses the information provided by cookies to develop a better understanding of how Mozilla's visitors use, and to facilitate those visitors' interactions with, Mozilla's Web sites. Mozilla visitors who do not wish to have cookies placed on their computers by Mozilla or its contractors should set their browsers to refuse cookies before linking to Mozilla's Web sites. Certain features of Mozilla's Web sites may not function properly without the aid of cookies.</p>
|
||||
|
||||
<h3>Protection of Certain Personally-Identifying Information</h3>
|
||||
|
||||
<p>Where Mozilla has collected personally-identifying information subject to one of the three exceptions described in the Contributors and Customers section, above, it discloses that information only to those of its employees, contractors and affiliated organizations that need to know that information in order to process it on Mozilla's behalf and that have agreed not to disclose it to others. Some of those employees, contractors and affiliated organizations may be located outside of your home country; by using Mozilla's Web sites, you consent to the transfer of your information to them. Mozilla does not rent or sell such information to anyone. Other than to its employees, contractors and affiliated organizations, as described above, Mozilla discloses such information only when required to do so by law, or when Mozilla believes in good faith that disclosure is reasonably necessary to protect the property or rights of Mozilla, members of the Mozilla community, or the public at large. Mozilla takes all measures reasonably necessary to protect against the unauthorized access, use, alteration or destruction of such information</p>
|
||||
|
||||
<h3>Updating of Personally-Identifying Information</h3>
|
||||
|
||||
<p>Mozilla permits users to freely update and correct their personally-identifying information as maintained by Mozilla. To do so, users need only look for the links and other tools available on Mozilla's Web sites or contact Mozilla by email.</p>
|
||||
|
||||
<h3>Privacy Policy Changes</h3>
|
||||
|
||||
<p>Although changes are likely to be minor, Mozilla may change its Privacy Policy from time to time. Any and all changes will be reflected on this page. Substantive changes will also be announced through the standard mechanisms through which Mozilla communicates with the Mozilla community, including Mozilla's "mozilla-announce" mailing lists.</p>
|
||||
@@ -1,109 +0,0 @@
|
||||
<h1>Create a Party</h1>
|
||||
<form class="fxform" action="<?php echo $html->url('/parties/add'); ?>" method="post">
|
||||
<div>
|
||||
<label for="PartyName" class="label-large">Party Name<span class="required">*</span>:</label>
|
||||
<?php echo $html->input('Party/name', array('size' => 40)); ?>
|
||||
<?php echo $html->tagErrorMsg('Party/name', 'Please enter a party name.')?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyVname" class="label-large">Venue Name:</label>
|
||||
<?php echo $html->input('Party/vname', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyAddress" class="label-large">Address:</label>
|
||||
<?php echo $html->input('Party/address', array('size' => 40, 'id' => 'location', 'onkeypress' => 'capture(event)', 'onblur' => 'update()')); ?>
|
||||
<div id="locerr" class="info" style="display: none">Did you mean: <a id="locerrlink" onclick="geocode_suggest()" href="#"></a>? <a href="#" onclick="shide()"><span style="font-size: x-small">(close)</span></a></div>
|
||||
</div>
|
||||
<p>Enter your party's time and date (in your local time) here. If you're not ready to commit to a specific time or date, select the 'Tentative'
|
||||
radio button. Otherwise select 'Confirmed'.</p>
|
||||
<div>
|
||||
<label for="PartyYear" class="label-large">Date:</label>
|
||||
<?php echo $html->yearOptionTag('Party/year', null, date('Y'), MAX_YEAR, date('Y'), null, null, false); ?>-<?php echo $html->hourOptionTag('Party/month', null, false, date('m')); ?>-<?php echo $html->dayOptionTag('Party/day', null, date('d'), null, false); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyHour" class="label-large">Time:</label>
|
||||
<?php echo $html->hourOptionTag('Party/hour', null, true);?>:<?php echo $html->minuteOptionTag('Party/minute');?>
|
||||
<?php echo $html->radio('Party/confirmed', array(0 => 'Tentative', 1 => 'Confirmed')); ?><br/>
|
||||
</div>
|
||||
<p>The timezone is used to calculate the appropriate GMT time from the local time specified above. This is done to show
|
||||
the party in the local time of the person viewing it.</p>
|
||||
<div>
|
||||
<label for="PartyTz" class="label-large">Timezone<span class="required">*</span>:</label>
|
||||
<?php
|
||||
$tzs = array('-12' => 'GMT-12',
|
||||
'-11' => 'GMT-11',
|
||||
'-10' => 'GMT-10',
|
||||
'-9' => 'GMT-9',
|
||||
'-8' => 'GMT-8',
|
||||
'-7' => 'GMT-7',
|
||||
'-6' => 'GMT-6',
|
||||
'-5' => 'GMT-5',
|
||||
'-4' => 'GMT-4',
|
||||
'-3' => 'GMT-3',
|
||||
'-2' => 'GMT-2',
|
||||
'-1' => 'GMT-1',
|
||||
'0' => 'GMT+0',
|
||||
'1' => 'GMT+1',
|
||||
'2' => 'GMT+2',
|
||||
'3' => 'GMT+3',
|
||||
'4' => 'GMT+4',
|
||||
'5' => 'GMT+5',
|
||||
'6' => 'GMT+6',
|
||||
'7' => 'GMT+7',
|
||||
'8' => 'GMT+8',
|
||||
'9' => 'GMT+9',
|
||||
'10' => 'GMT+10',
|
||||
'11' => 'GMT+11',
|
||||
'12' => 'GMT+12',
|
||||
'13' => 'GMT+13');
|
||||
echo $html->selectTag('Party/tz', $tzs, $utz, null, null, false);
|
||||
?>
|
||||
(this page was loaded at <?php echo gmdate("Y-m-d H:i:s"); ?> GMT)
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyDuration" class="label-large">Duration (in hours):</label>
|
||||
<?php echo $html->input('Party/duration', array('size' => 5)); ?>
|
||||
</div>
|
||||
<p>Enter a website (complete with http://) that guests can visit to learn more about your party. If you don't have one, simply leave it blank.</p>
|
||||
<div>
|
||||
<label for="PartyWebsite" class="label-large">Web site:</label>
|
||||
<?php echo $html->input('Party/website', array('size' => 40)); ?>
|
||||
<?php echo $html->tagErrorMsg('Party/website', 'Invalid URL.')?>
|
||||
</div>
|
||||
<p>If you choose to make your party invite only, you will have to send guests an invite containing a random invite code to allow them to join your party.</p>
|
||||
<div>
|
||||
<label for="PartyInviteonly" class="label-large">Invite only</label>
|
||||
<?php echo $html->checkbox('Party/inviteonly'); ?>
|
||||
</div>
|
||||
<?php if(GMAP_API_KEY != null): ?>
|
||||
<script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo GMAP_API_KEY; ?>"
|
||||
type="text/javascript"></script>
|
||||
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function update() {
|
||||
var loc = document.getElementById("location").value;
|
||||
geocode(loc);
|
||||
}
|
||||
|
||||
function capture(event) {
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
update();
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<p>Drag the map or the marker to specify a location. Set the zoom by using the '+' or '-' buttons on the left.</p>
|
||||
<p id="map" class="med-map-r"></p>
|
||||
<?php echo $html->hidden('Party/lat', array('id' => 'lat'));
|
||||
echo $html->hidden('Party/long', array('id' => 'long'));
|
||||
echo $html->hidden('Party/zoom', array('id' => 'zoom'));
|
||||
echo $html->hidden('Party/geocoded', array('id' => 'geocoded', 'value' => 0)); ?>
|
||||
<?php endif; ?>
|
||||
<div>
|
||||
<label for="PartyNotes" class="label-large">Additional Notes</label>
|
||||
<?php echo $html->textarea('Party/notes', array('rows' => 10, 'cols' => 50)); ?>
|
||||
</div>
|
||||
<?php echo $html->submit('Create Party'); ?>
|
||||
</form>
|
||||
@@ -1,7 +0,0 @@
|
||||
<h1>Cancel Party</h1>
|
||||
<div class="error">Warning! Canceling your party will remove all guests and send them a cancellation notice.</div>
|
||||
<p>If you're sure you want to cancel your party simply hit the button below. Otherwise,
|
||||
<a href="<?php echo $html->url('/parties/view/'.$pid); ?>">click here</a> to return to your party.</p>
|
||||
<form action="<?php echo $html->url('/parties/cancel/'.$pid); ?>" method="post">
|
||||
<?php echo $html->hidden('Party/confcancel', array('value' => 1)).$html->submit('Cancel Party'); ?>
|
||||
</form>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user