* @return User_greeting_count object found, or null for no hits
*
*/
-
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Poll', $k, $v);
* @return Bookmark object found, or null for no hits
*
*/
-
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Poll', $kv);
*
* @return Poll found poll or null
*/
-
function getByNotice($notice)
{
return self::staticGet('uri', $notice->uri);
*
* @return Notice saved notice
*/
-
static function saveNew($profile, $question, $opts, $options=null)
{
if (empty($options)) {
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class PollPlugin extends MicroAppPlugin
{
const VERSION = '0.1';
*
* @return boolean hook value; true means continue processing, false means stop.
*/
-
function onCheckSchema()
{
$schema = Schema::get();
*
* @return boolean hook value
*/
-
function onEndShowStyles($action)
{
$action->cssLink($this->path('poll.css'));
*
* @return boolean hook value; true means continue processing, false means stop.
*/
-
function onAutoload($cls)
{
$dir = dirname(__FILE__);
*
* @return boolean hook value; true means continue processing, false means stop.
*/
-
function onRouterInitialized($m)
{
$m->connect('main/poll/new',
*
* @return value
*/
-
function onPluginVersion(&$versions)
{
$versions[] = array('name' => 'Poll',
*
* @return boolean hook value
*/
-
function deleteRelated($notice)
{
$p = Poll::getByNotice($notice);
*
* @return Notice resulting notice
*/
-
function saveNoticeFromActivity($activity, $profile, $options=array())
{
// @fixme
*
* @see DB_DataObject
*/
-
class Poll_response extends Managed_DataObject
{
public $__table = 'poll_response'; // table name
* @return User_greeting_count object found, or null for no hits
*
*/
-
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Poll_response', $k, $v);
* @return Bookmark object found, or null for no hits
*
*/
-
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Poll_response', $kv);
*
* @return Poll_response found response or null
*/
-
function getByNotice($notice)
{
return self::staticGet('uri', $notice->uri);
*
* @return Notice saved notice
*/
-
static function saveNew($profile, $poll, $selection, $options=null)
{
if (empty($options)) {
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class NewPollAction extends Action
{
protected $user = null;
*
* @return string Action title
*/
-
function title()
{
return _('New poll');
*
* @return boolean true
*/
-
function prepare($argarray)
{
parent::prepare($argarray);
$this->user = common_current_user();
if (empty($this->user)) {
- throw new ClientException(_("Must be logged in to post a poll."),
+ throw new ClientException(_("You must be logged in to post a poll."),
403);
}
*
* @return void
*/
-
function handle($argarray=null)
{
parent::handle($argarray);
*
* @return void
*/
-
function newPoll()
{
if ($this->boolean('ajax')) {
$saved = Poll::saveNew($this->user->getProfile(),
$this->question,
$this->options);
-
} catch (ClientException $ce) {
$this->error = $ce->getMessage();
$this->showPage();
*
* @return void
*/
-
function showContent()
{
if (!empty($this->error)) {
*
* @return boolean is read only action?
*/
-
function isReadOnly($args)
{
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class NewpollForm extends Form
{
-
protected $question = null;
protected $options = array();
*
* @return void
*/
-
function __construct($out=null, $question=null, $options=null)
{
parent::__construct($out);
*
* @return int ID of the form
*/
-
function id()
{
return 'newpoll-form';
*
* @return string class of the form
*/
-
function formClass()
{
return 'form_settings ajax-notice';
*
* @return string URL of the action
*/
-
function action()
{
return common_local_url('newpoll');
*
* @return void
*/
-
function formData()
{
$this->out->elementStart('fieldset', array('id' => 'newpoll-data'));
*
* @return void
*/
-
function formActions()
{
$this->out->submit('submit', _m('BUTTON', 'Save'));
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class PollResponseForm extends Form
{
protected $poll;
*
* @return void
*/
-
function __construct(Poll $poll, HTMLOutputter $out)
{
parent::__construct($out);
*
* @return int ID of the form
*/
-
function id()
{
return 'pollresponse-form';
*
* @return string class of the form
*/
-
function formClass()
{
return 'form_settings ajax';
*
* @return string URL of the action
*/
-
function action()
{
return common_local_url('respondpoll', array('id' => $this->poll->id));
*
* @return void
*/
-
function formData()
{
$poll = $this->poll;
*
* @return void
*/
-
function formActions()
{
$this->out->submit('submit', _m('BUTTON', 'Submit'));
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class PollResultForm extends Form
{
protected $poll;
*
* @return void
*/
-
function __construct(Poll $poll, HTMLOutputter $out)
{
parent::__construct($out);
*
* @return int ID of the form
*/
-
function id()
{
return 'pollresult-form';
*
* @return string class of the form
*/
-
function formClass()
{
return 'form_settings ajax';
*
* @return string URL of the action
*/
-
function action()
{
return common_local_url('respondpoll', array('id' => $this->poll->id));
*
* @return void
*/
-
function formData()
{
$poll = $this->poll;
*
* @return void
*/
-
function formActions()
{
}
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class RespondPollAction extends Action
{
protected $user = null;
*
* @return string Action title
*/
-
function title()
{
return _m('Poll response');
*
* @return boolean true
*/
-
function prepare($argarray)
{
parent::prepare($argarray);
$this->user = common_current_user();
if (empty($this->user)) {
- throw new ClientException(_m("Must be logged in to respond to a poll."),
+ throw new ClientException(_m("You must be logged in to respond to a poll."),
403);
}
*
* @return void
*/
-
function handle($argarray=null)
{
parent::handle($argarray);
*
* @return void
*/
-
function respondPoll()
{
try {
*
* @return void
*/
-
function showContent()
{
if (!empty($this->error)) {
*
* @return boolean is read only action?
*/
-
function isReadOnly($args)
{
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class ShowPollAction extends ShownoticeAction
{
protected $poll = null;
*
* @return boolean true
*/
-
function prepare($argarray)
{
OwnerDesignAction::prepare($argarray);
*
* @return string page tile
*/
-
function title()
{
return sprintf(_('%s\'s poll: %s'),
{
return Action::etag();
}
-
}