summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-10-13 15:46:45 -0700
committerBrion Vibber <brion@pobox.com>2010-10-13 15:46:45 -0700
commit4101de7dd7cf059816c29c666c816f260a84c252 (patch)
treedce4b95ec0270ec2cf4dfc357229ee569e1a48f0 /lib
parent621233e1ad6956cfb543042a1493a04b243e92ca (diff)
parentf79dbaf9a76c10969dbc45fd43a0bb26f5f64ed4 (diff)
Merge branch '1.0.x' into schema-x
Diffstat (limited to 'lib')
-rw-r--r--lib/deletegroupform.php123
-rw-r--r--lib/installer.php6
-rw-r--r--lib/right.php1
-rw-r--r--lib/router.php7
-rw-r--r--lib/statusnet.php7
-rw-r--r--lib/util.php7
6 files changed, 146 insertions, 5 deletions
diff --git a/lib/deletegroupform.php b/lib/deletegroupform.php
new file mode 100644
index 000000000..9d8012d33
--- /dev/null
+++ b/lib/deletegroupform.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Form for joining a group
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Form
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Sarven Capadisli <csarven@status.net>
+ * @author Brion Vibber <brion@status.net>
+ * @copyright 2009, 2010 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+/**
+ * Form for deleting a group
+ *
+ * @category Form
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Sarven Capadisli <csarven@status.net>
+ * @author Brion Vibber <brion@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ *
+ * @see UnsubscribeForm
+ * @fixme merge a bunch of this stuff with similar form types to reduce boilerplate
+ */
+
+class DeleteGroupForm extends Form
+{
+ /**
+ * group for user to delete
+ */
+
+ var $group = null;
+
+ /**
+ * Constructor
+ *
+ * @param HTMLOutputter $out output channel
+ * @param group $group group to join
+ */
+
+ function __construct($out=null, $group=null)
+ {
+ parent::__construct($out);
+
+ $this->group = $group;
+ }
+
+ /**
+ * ID of the form
+ *
+ * @return string ID of the form
+ */
+
+ function id()
+ {
+ return 'group-delete-' . $this->group->id;
+ }
+
+ /**
+ * class of the form
+ *
+ * @return string of the form class
+ */
+
+ function formClass()
+ {
+ return 'form_group_delete';
+ }
+
+ /**
+ * Action of the form
+ *
+ * @return string URL of the action
+ */
+
+ function action()
+ {
+ return common_local_url('deletegroup',
+ array('id' => $this->group->id));
+ }
+
+ function formData()
+ {
+ $this->out->hidden($this->id() . '-returnto-action', 'groupbyid', 'returnto-action');
+ $this->out->hidden($this->id() . '-returnto-id', $this->group->id, 'returnto-id');
+ }
+
+ /**
+ * Action elements
+ *
+ * @return void
+ */
+
+ function formActions()
+ {
+ $this->out->submit('submit', _('Delete'));
+ }
+}
diff --git a/lib/installer.php b/lib/installer.php
index 2eff2d85a..c046eadea 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -85,7 +85,11 @@ abstract class Installer
$config = INSTALLDIR.'/config.php';
if (file_exists($config)) {
if (!is_writable($config) || filesize($config) > 0) {
- $this->warning('Config file "config.php" already exists.');
+ if (filesize($config) == 0) {
+ $this->warning('Config file "config.php" already exists and is empty, but is not writable.');
+ } else {
+ $this->warning('Config file "config.php" already exists.');
+ }
$pass = false;
}
}
diff --git a/lib/right.php b/lib/right.php
index deb451fde..bacbea5f2 100644
--- a/lib/right.php
+++ b/lib/right.php
@@ -60,5 +60,6 @@ class Right
const MAKEGROUPADMIN = 'makegroupadmin';
const GRANTROLE = 'grantrole';
const REVOKEROLE = 'revokerole';
+ const DELETEGROUP = 'deletegroup';
}
diff --git a/lib/router.php b/lib/router.php
index 3bbb4a044..54d3d0f68 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -278,7 +278,7 @@ class Router
$m->connect('group/new', array('action' => 'newgroup'));
- foreach (array('edit', 'join', 'leave') as $v) {
+ foreach (array('edit', 'join', 'leave', 'delete') as $v) {
$m->connect('group/:nickname/'.$v,
array('action' => $v.'group'),
array('nickname' => '[a-zA-Z0-9]+'));
@@ -322,6 +322,11 @@ class Router
// statuses API
+ $m->connect('api',
+ array('action' => 'Redirect',
+ 'nextAction' => 'doc',
+ 'args' => array('title' => 'api')));
+
$m->connect('api/statuses/public_timeline.:format',
array('action' => 'ApiTimelinePublic',
'format' => '(xml|json|rss|atom)'));
diff --git a/lib/statusnet.php b/lib/statusnet.php
index ff0502915..39f90a506 100644
--- a/lib/statusnet.php
+++ b/lib/statusnet.php
@@ -341,8 +341,11 @@ class StatusNet
foreach ($config_files as $_config_file) {
if (@file_exists($_config_file)) {
- include($_config_file);
- self::$have_config = true;
+ // Ignore 0-byte config files
+ if (filesize($_config_file) > 0) {
+ include($_config_file);
+ self::$have_config = true;
+ }
}
}
diff --git a/lib/util.php b/lib/util.php
index df339d4b1..85d7c72f4 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -946,7 +946,12 @@ function common_shorten_links($text, $always = false)
function common_validate_utf8($str)
{
// preg_replace will return NULL on invalid UTF-8 input.
- return preg_replace('//u', '', $str);
+ //
+ // Note: empty regex //u also caused NULL return on some
+ // production machines, but none of our test machines.
+ //
+ // This should be replaced with a more reliable check.
+ return preg_replace('/\x00/u', '', $str);
}
/**