summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/apigroupshow.php29
-rw-r--r--actions/apistatusesretweets.php15
-rw-r--r--actions/apitimelineretweetedbyme.php51
-rw-r--r--actions/apitimelineretweetedtome.php15
-rw-r--r--actions/apitimelineretweetsofme.php15
-rw-r--r--actions/doc.php152
-rw-r--r--actions/imsettings.php10
7 files changed, 192 insertions, 95 deletions
diff --git a/actions/apigroupshow.php b/actions/apigroupshow.php
index 7aa49b1bf..ef9cbf0e7 100644
--- a/actions/apigroupshow.php
+++ b/actions/apigroupshow.php
@@ -45,6 +45,7 @@ require_once INSTALLDIR . '/lib/apiprivateauth.php';
* @author Evan Prodromou <evan@status.net>
* @author Jeffery To <jeffery.to@gmail.com>
* @author Zach Copley <zach@status.net>
+ * @author Michele <macno@macno.org>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
@@ -68,6 +69,24 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
$this->group = $this->getTargetGroup($this->arg('id'));
+ if (empty($this->group)) {
+ $alias = Group_alias::staticGet(
+ 'alias',
+ common_canonical_nickname($this->arg('id'))
+ );
+ if (!empty($alias)) {
+ $args = array('id' => $alias->group_id, 'format' => $this->format);
+ common_redirect(common_local_url('ApiGroupShow', $args), 301);
+ } else {
+ $this->clientError(
+ _('Group not found!'),
+ 404,
+ $this->format
+ );
+ }
+ return;
+ }
+
return true;
}
@@ -85,15 +104,6 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
{
parent::handle($args);
- if (empty($this->group)) {
- $this->clientError(
- _('Group not found!'),
- 404,
- $this->format
- );
- return;
- }
-
switch($this->format) {
case 'xml':
$this->showSingleXmlGroup($this->group);
@@ -105,7 +115,6 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
$this->clientError(_('API method not found.'), 404, $this->format);
break;
}
-
}
/**
diff --git a/actions/apistatusesretweets.php b/actions/apistatusesretweets.php
index f7a3dd60a..a79d43168 100644
--- a/actions/apistatusesretweets.php
+++ b/actions/apistatusesretweets.php
@@ -113,4 +113,19 @@ class ApiStatusesRetweetsAction extends ApiAuthAction
break;
}
}
+
+ /**
+ * Return true if read only.
+ *
+ * MAY override
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean is read only action?
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
}
diff --git a/actions/apitimelineretweetedbyme.php b/actions/apitimelineretweetedbyme.php
index 88652c3fd..564e98619 100644
--- a/actions/apitimelineretweetedbyme.php
+++ b/actions/apitimelineretweetedbyme.php
@@ -69,58 +69,21 @@ class ApiTimelineRetweetedByMeAction extends ApiAuthAction
{
parent::prepare($args);
- $cnt = $this->int('count', self::DEFAULTCOUNT, self::MAXCOUNT, 1);
+ $this->serverError('Unimplemented', 503);
- $page = $this->int('page', 1, (self::MAXNOTICES/$this->cnt));
-
- $since_id = $this->int('since_id');
-
- $max_id = $this->int('max_id');
-
- return true;
+ return false;
}
/**
- * Handle the request
- *
- * show a timeline of the user's repeated notices
+ * Return true if read only.
*
- * @param array $args $_REQUEST data (unused)
+ * @param array $args other arguments
*
- * @return void
+ * @return boolean is read only action?
*/
- function handle($args)
+ function isReadOnly($args)
{
- parent::handle($args);
-
- $offset = ($this->page-1) * $this->cnt;
- $limit = $this->cnt;
-
- $strm = $this->auth_user->repeatedByMe($offset, $limit, $this->since_id, $this->max_id);
-
- switch ($this->format) {
- case 'xml':
- $this->showXmlTimeline($strm);
- break;
- case 'json':
- $this->showJsonTimeline($strm);
- break;
- case 'atom':
- $profile = $this->auth_user->getProfile();
-
- $title = sprintf(_("Repeated by %s"), $this->auth_user->nickname);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:RepeatedByMe:" . $this->auth_user->id;
- $link = common_local_url('showstream',
- array('nickname' => $this->auth_user->nickname));
-
- $this->showAtomTimeline($strm, $title, $id, $link);
- break;
-
- default:
- $this->clientError(_('API method not found.'), $code = 404);
- break;
- }
+ return true;
}
}
diff --git a/actions/apitimelineretweetedtome.php b/actions/apitimelineretweetedtome.php
index 113ab96d2..e47bc30b8 100644
--- a/actions/apitimelineretweetedtome.php
+++ b/actions/apitimelineretweetedtome.php
@@ -122,4 +122,19 @@ class ApiTimelineRetweetedToMeAction extends ApiAuthAction
break;
}
}
+
+ /**
+ * Return true if read only.
+ *
+ * MAY override
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean is read only action?
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
}
diff --git a/actions/apitimelineretweetsofme.php b/actions/apitimelineretweetsofme.php
index 6ca2c779c..e4b09e9bd 100644
--- a/actions/apitimelineretweetsofme.php
+++ b/actions/apitimelineretweetsofme.php
@@ -123,4 +123,19 @@ class ApiTimelineRetweetsOfMeAction extends ApiAuthAction
break;
}
}
+
+ /**
+ * Return true if read only.
+ *
+ * MAY override
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean is read only action?
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
}
diff --git a/actions/doc.php b/actions/doc.php
index 836f039d3..25d363472 100644
--- a/actions/doc.php
+++ b/actions/doc.php
@@ -45,11 +45,23 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
*/
class DocAction extends Action
{
- var $filename;
- var $title;
+ var $output = null;
+ var $filename = null;
+ var $title = null;
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->title = $this->trimmed('title');
+ $this->output = null;
+
+ $this->loadDoc();
+ return true;
+ }
/**
- * Class handler.
+ * Handle a request
*
* @param array $args array of arguments
*
@@ -58,51 +70,51 @@ class DocAction extends Action
function handle($args)
{
parent::handle($args);
-
- $this->title = $this->trimmed('title');
- $this->output = null;
-
- if (Event::handle('StartLoadDoc', array(&$this->title, &$this->output))) {
-
- $this->filename = INSTALLDIR.'/doc-src/'.$this->title;
- if (!file_exists($this->filename)) {
- $this->clientError(_('No such document.'));
- return;
- }
-
- $c = file_get_contents($this->filename);
- $this->output = common_markup_to_html($c);
-
- Event::handle('EndLoadDoc', array($this->title, &$this->output));
- }
-
$this->showPage();
}
- // overrrided to add entry-title class
- function showPageTitle() {
+ /**
+ * Page title
+ *
+ * Gives the page title of the document. Override default for hAtom entry.
+ *
+ * @return void
+ */
+
+ function showPageTitle()
+ {
$this->element('h1', array('class' => 'entry-title'), $this->title());
}
- // overrided to add hentry, and content-inner classes
+ /**
+ * Block for content.
+ *
+ * Overrides default from Action to wrap everything in an hAtom entry.
+ *
+ * @return void.
+ */
+
function showContentBlock()
- {
- $this->elementStart('div', array('id' => 'content', 'class' => 'hentry'));
- $this->showPageTitle();
- $this->showPageNoticeBlock();
- $this->elementStart('div', array('id' => 'content_inner',
- 'class' => 'entry-content'));
- // show the actual content (forms, lists, whatever)
- $this->showContent();
- $this->elementEnd('div');
- $this->elementEnd('div');
- }
+ {
+ $this->elementStart('div', array('id' => 'content', 'class' => 'hentry'));
+ $this->showPageTitle();
+ $this->showPageNoticeBlock();
+ $this->elementStart('div', array('id' => 'content_inner',
+ 'class' => 'entry-content'));
+ // show the actual content (forms, lists, whatever)
+ $this->showContent();
+ $this->elementEnd('div');
+ $this->elementEnd('div');
+ }
/**
* Display content.
*
- * @return nothing
+ * Shows the content of the document.
+ *
+ * @return void
*/
+
function showContent()
{
$this->raw($this->output);
@@ -111,6 +123,8 @@ class DocAction extends Action
/**
* Page title.
*
+ * Uses the title of the document.
+ *
* @return page title
*/
function title()
@@ -118,8 +132,74 @@ class DocAction extends Action
return ucfirst($this->title);
}
+ /**
+ * These pages are read-only.
+ *
+ * @param array $args unused.
+ *
+ * @return boolean read-only flag (false)
+ */
+
function isReadOnly($args)
{
return true;
}
+
+ function loadDoc()
+ {
+ if (Event::handle('StartLoadDoc', array(&$this->title, &$this->output))) {
+
+ $this->filename = $this->getFilename();
+
+ if (empty($this->filename)) {
+ throw new ClientException(sprintf(_('No such document "%s"'), $this->title), 404);
+ }
+
+ $c = file_get_contents($this->filename);
+
+ $this->output = common_markup_to_html($c);
+
+ Event::handle('EndLoadDoc', array($this->title, &$this->output));
+ }
+ }
+
+ function getFilename()
+ {
+ if (file_exists(INSTALLDIR.'/local/doc-src/'.$this->title)) {
+ $localDef = INSTALLDIR.'/local/doc-src/'.$this->title;
+ }
+
+ $local = glob(INSTALLDIR.'/local/doc-src/'.$this->title.'.*');
+
+ if (count($local) || isset($localDef)) {
+ return $this->negotiateLanguage($local, $localDef);
+ }
+
+ if (file_exists(INSTALLDIR.'/doc-src/'.$this->title)) {
+ $distDef = INSTALLDIR.'/doc-src/'.$this->title;
+ }
+
+ $dist = glob(INSTALLDIR.'/doc-src/'.$this->title.'.*');
+
+ if (count($dist) || isset($distDef)) {
+ return $this->negotiateLanguage($dist, $distDef);
+ }
+
+ return null;
+ }
+
+ function negotiateLanguage($filenames, $defaultFilename=null)
+ {
+ // XXX: do this better
+
+ $langcode = common_language();
+
+ foreach ($filenames as $filename) {
+ if (preg_match('/\.'.$langcode.'$/', $filename)) {
+ return $filename;
+ }
+ }
+
+ return $defaultFilename;
+ }
}
diff --git a/actions/imsettings.php b/actions/imsettings.php
index 751c6117c..af4915843 100644
--- a/actions/imsettings.php
+++ b/actions/imsettings.php
@@ -309,6 +309,8 @@ class ImsettingsAction extends ConnectSettingsAction
$confirm->address_type = 'jabber';
$confirm->user_id = $user->id;
$confirm->code = common_confirmation_code(64);
+ $confirm->sent = common_sql_now();
+ $confirm->claimed = common_sql_now();
$result = $confirm->insert();
@@ -318,11 +320,9 @@ class ImsettingsAction extends ConnectSettingsAction
return;
}
- if (!common_config('queue', 'enabled')) {
- jabber_confirm_address($confirm->code,
- $user->nickname,
- $jabber);
- }
+ jabber_confirm_address($confirm->code,
+ $user->nickname,
+ $jabber);
$msg = sprintf(_('A confirmation code was sent '.
'to the IM address you added. '.