import v1.0.0-RC4 | 2009-05-20
This commit is contained in:
36
modules/default/controllers/AboutController.php
Normal file
36
modules/default/controllers/AboutController.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class AboutController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$scriptsDir = $this->view->getScriptPath('about');
|
||||
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
// render() changes _ to -
|
||||
$locale = str_replace('_', '-', $locale);
|
||||
$localeElements = explode('-', $locale);
|
||||
|
||||
if (file_exists("$scriptsDir/index-$locale.phtml")) {
|
||||
$view = "index-$locale";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists("$scriptsDir/index-".$localeElements[0].".phtml")) {
|
||||
$view = 'index-'.$localeElements[0];
|
||||
} else {
|
||||
$view = 'index-en';
|
||||
}
|
||||
|
||||
$this->render($view);
|
||||
}
|
||||
}
|
14
modules/default/controllers/ErrorController.php
Executable file
14
modules/default/controllers/ErrorController.php
Executable file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class ErrorController extends Monkeys_Controller_Error
|
||||
{
|
||||
}
|
111
modules/default/controllers/FeedbackController.php
Normal file
111
modules/default/controllers/FeedbackController.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class FeedbackController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->user->role != User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
return $this->_redirectForMaintenance();
|
||||
}
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->feedbackForm)) {
|
||||
$form = $appSession->feedbackForm;
|
||||
unset($appSession->feedbackForm);
|
||||
} else {
|
||||
$form = new FeedbackForm(null, $this->view->base);
|
||||
}
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function sendAction()
|
||||
{
|
||||
$form = new FeedbackForm(null, $this->view->base);
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->feedbackForm = $form;
|
||||
return $this->_forward('index', null, null);
|
||||
}
|
||||
|
||||
$mail = self::getMail(
|
||||
$form->getValue('name'),
|
||||
$form->getValue('email'),
|
||||
$form->getValue('feedback')
|
||||
);
|
||||
|
||||
try {
|
||||
$mail->send();
|
||||
$this->_helper->FlashMessenger->addMessage('Thank you for your interest. Your message has been routed.');
|
||||
} catch (Zend_Mail_Protocol_Exception $e) {
|
||||
$this->_helper->FlashMessenger->addMessage('Sorry, the feedback couldn\'t be delivered. Please try again later.');
|
||||
if ($this->_config->logging->level == Zend_Log::DEBUG) {
|
||||
$this->_helper->FlashMessenger->addMessage($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Zend_Mail
|
||||
* @throws Zend_Mail_Protocol_Exception
|
||||
*/
|
||||
public static function getMail($name, $email, $feedback)
|
||||
{
|
||||
// can't use $this-_config 'cause it's a static function
|
||||
$configEmail = Zend_Registry::get('config')->email;
|
||||
|
||||
switch (strtolower($configEmail->transport)) {
|
||||
case 'smtp':
|
||||
Zend_Mail::setDefaultTransport(
|
||||
new Zend_Mail_Transport_Smtp(
|
||||
$configEmail->host,
|
||||
$configEmail->toArray()
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'mock':
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
|
||||
break;
|
||||
default:
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
|
||||
}
|
||||
|
||||
$mail = new Zend_Mail();
|
||||
$mail->setBodyText(<<<EOD
|
||||
Dear Administrator,
|
||||
|
||||
The community-id feedback form has just been used to send you the following:
|
||||
|
||||
Name: $name
|
||||
E-mail: $email
|
||||
Feedback:
|
||||
$feedback
|
||||
EOD
|
||||
);
|
||||
$mail->setFrom('support@community-id.org');
|
||||
$mail->addTo($configEmail->supportemail);
|
||||
$mail->setSubject('Community-ID feedback form');
|
||||
|
||||
return $mail;
|
||||
}
|
||||
}
|
64
modules/default/controllers/HistoryController.php
Executable file
64
modules/default/controllers/HistoryController.php
Executable file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class HistoryController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function listAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$histories = new Histories();
|
||||
$historiesRows = $histories->get(
|
||||
$this->user,
|
||||
$this->_getParam('startIndex'),
|
||||
$this->_getParam('results')
|
||||
);
|
||||
|
||||
$jsonObj = new StdClass();
|
||||
$jsonObj->recordsReturned = count($historiesRows);
|
||||
$jsonObj->totalRecords = $histories->getNumHistories($this->user);
|
||||
$jsonObj->startIndex = $this->_getParam('startIndex');
|
||||
$jsonObj->sort = null;
|
||||
$jsonObj->dir = 'asc';
|
||||
$jsonObj->records = array();
|
||||
|
||||
foreach ($historiesRows as $history) {
|
||||
$jsonObjSite = new StdClass();
|
||||
$jsonObjSite->id = $history->id;
|
||||
$jsonObjSite->date = $history->date;
|
||||
$jsonObjSite->site = $history->site;
|
||||
$jsonObjSite->ip = $history->ip;
|
||||
$jsonObjSite->result = $history->result;
|
||||
|
||||
$jsonObj->records[] = $jsonObjSite;
|
||||
}
|
||||
|
||||
echo Zend_Json::encode($jsonObj);
|
||||
}
|
||||
|
||||
public function clearAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$histories = new Histories();
|
||||
$histories->clear($this->user);
|
||||
|
||||
$json = new StdClass();
|
||||
$json->code = 200;
|
||||
|
||||
echo Zend_Json::encode($json);
|
||||
}
|
||||
}
|
58
modules/default/controllers/IdentityController.php
Normal file
58
modules/default/controllers/IdentityController.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class IdentityController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
throw new Monkeys_BadUrlException($this->getRequest()->getRequestUri());
|
||||
}
|
||||
|
||||
public function idAction()
|
||||
{
|
||||
$currentUrl = Zend_OpenId::selfURL();
|
||||
|
||||
if ($this->_config->subdomain->enabled) {
|
||||
$protocol = $this->_getProtocol();
|
||||
preg_match('#(.*)\.'.$this->_config->subdomain->hostname.'#', $currentUrl, $matches);
|
||||
|
||||
$this->view->headLink()->headLink(array(
|
||||
'rel' => 'openid.server',
|
||||
'href' => "$protocol://"
|
||||
. ($this->_config->subdomain->use_www? 'www.' : '')
|
||||
. $this->_config->subdomain->hostname
|
||||
. '/openid/provider'
|
||||
));
|
||||
$this->view->headLink()->headLink(array(
|
||||
'rel' => 'openid2.provider',
|
||||
'href' => "$protocol://"
|
||||
. ($this->_config->subdomain->use_www? 'www.' : '')
|
||||
. $this->_config->subdomain->hostname
|
||||
. '/openid/provider'
|
||||
));
|
||||
} else {
|
||||
preg_match('#(.*)/identity/#', $currentUrl, $matches);
|
||||
|
||||
$this->view->headLink()->headLink(array(
|
||||
'rel' => 'openid.server',
|
||||
'href' => $matches[1] . '/openid/provider',
|
||||
));
|
||||
$this->view->headLink()->headLink(array(
|
||||
'rel' => 'openid2.provider',
|
||||
'href' => $matches[1] . '/openid/provider',
|
||||
));
|
||||
}
|
||||
|
||||
$this->view->idUrl = $currentUrl;
|
||||
}
|
||||
}
|
87
modules/default/controllers/IndexController.php
Normal file
87
modules/default/controllers/IndexController.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class IndexController extends Monkeys_Controller_Action
|
||||
{
|
||||
const NEWS_CONTENT_MAX_LENGTH = 100;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$scriptsDir = $this->view->getScriptPaths();
|
||||
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
// render() changes _ to -
|
||||
$locale = str_replace('_', '-', $locale);
|
||||
$localeElements = explode('-', $locale);
|
||||
|
||||
$view = false;
|
||||
foreach ($scriptsDir as $scriptDir) {
|
||||
if (file_exists($scriptDir."index/subheader-$locale.phtml")) {
|
||||
$view = "subheader-$locale";
|
||||
break;
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists($scriptDir."index/subheader-".$localeElements[0].".phtml")) {
|
||||
$view = 'subheader-'.$localeElements[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$view) {
|
||||
$view = 'subheader-en';
|
||||
}
|
||||
|
||||
$this->getResponse()->insert('subHeader', $this->view->render("index/$view.phtml"));
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
|
||||
try {
|
||||
$feed = Zend_Feed::import($this->_config->news_feed->url);
|
||||
} catch (Zend_Exception $e) {
|
||||
// feed import failed
|
||||
$obj = new StdClass();
|
||||
$obj->link = array('href' => '');
|
||||
$obj->title = $this->view->translate('Could not retrieve news items');
|
||||
$obj->updated = '';
|
||||
$obj->content = '';
|
||||
$feed = array($obj);
|
||||
}
|
||||
|
||||
$this->view->news = array();
|
||||
$i = 0;
|
||||
foreach ($feed as $item) {
|
||||
if ($i++ >= $this->_config->news_feed->num_items) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen($item->content) > self::NEWS_CONTENT_MAX_LENGTH) {
|
||||
$item->content = substr($item->content, 0, self::NEWS_CONTENT_MAX_LENGTH)
|
||||
. '...<br /><a class="readMore" href="'.$item->link['href'].'">' . $this->view->translate('Read More') . '</a>';
|
||||
}
|
||||
$this->view->news[] = $item;
|
||||
}
|
||||
|
||||
$view = false;
|
||||
foreach ($scriptsDir as $scriptDir) {
|
||||
if (file_exists($scriptDir."index/index-$locale.phtml")) {
|
||||
$view = "index-$locale";
|
||||
break;
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists($scriptDir."index/index-".$localeElements[0].".phtml")) {
|
||||
$view = 'index-'.$localeElements[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$view) {
|
||||
$view = 'index-en';
|
||||
}
|
||||
|
||||
$this->render($view);
|
||||
}
|
||||
}
|
37
modules/default/controllers/LearnmoreController.php
Normal file
37
modules/default/controllers/LearnmoreController.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class LearnmoreController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$scriptsDir = $this->view->getScriptPath('learnmore');
|
||||
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
// render() changes _ to -
|
||||
$locale = str_replace('_', '-', $locale);
|
||||
$localeElements = explode('-', $locale);
|
||||
|
||||
if (file_exists("$scriptsDir/index-$locale.phtml")) {
|
||||
$view = "index-$locale";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists("$scriptsDir/index-".$localeElements[0].".phtml")) {
|
||||
$view = 'index-'.$localeElements[0];
|
||||
} else {
|
||||
$view = 'index-en';
|
||||
}
|
||||
|
||||
$this->render($view);
|
||||
}
|
||||
}
|
||||
|
35
modules/default/controllers/MaintenancemodeController.php
Normal file
35
modules/default/controllers/MaintenancemodeController.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class MaintenancemodeController extends Monkeys_Controller_Action
|
||||
{
|
||||
private $_settings;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->_settings = new Settings();
|
||||
}
|
||||
|
||||
public function enableAction()
|
||||
{
|
||||
$this->_settings->set(Settings::MAINTENANCE_MODE, 1);
|
||||
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
public function disableAction()
|
||||
{
|
||||
$this->_settings->set(Settings::MAINTENANCE_MODE, 0);
|
||||
|
||||
$this->_redirect('');
|
||||
}
|
||||
}
|
130
modules/default/controllers/MessageusersController.php
Normal file
130
modules/default/controllers/MessageusersController.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class MessageusersController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->messageUsersForm)) {
|
||||
$this->view->messageUsersForm = $appSession->messageUsersForm;
|
||||
unset($appSession->messageUsersForm);
|
||||
} else {
|
||||
$this->view->messageUsersForm = new MessageUsersForm();
|
||||
}
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function sendAction()
|
||||
{
|
||||
$form = new MessageUsersForm();
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
return $this->_redirectFaultyForm($form);
|
||||
}
|
||||
|
||||
$cc = $form->getValue('cc');
|
||||
$ccArr = array();
|
||||
if (trim($cc) != '') {
|
||||
$validator = new Zend_Validate_EmailAddress();
|
||||
$ccArr = explode(',', $cc);
|
||||
for ($i = 0; $i < count($ccArr); $i++) {
|
||||
$ccArr[$i] = trim($ccArr[$i]);
|
||||
if (!$validator->isValid($ccArr[$i])) {
|
||||
foreach ($validator->getMessages() as $messageId => $message) {
|
||||
$form->cc->addError($this->view->translate('CC field must be a comma-separated list of valid E-mails'));
|
||||
return $this->_redirectFaultyForm($form);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mail = self::getMail(
|
||||
$form->getValue('subject'),
|
||||
$this->_getParam('messageType'),
|
||||
$this->_getParam('messageType') == 'plain'?
|
||||
$form->getValue('bodyPlain')
|
||||
: $form->getValue('bodyHTML')
|
||||
);
|
||||
|
||||
$mail->setSubject($form->getValue('subject'));
|
||||
if ($this->_getParam('messageType') == 'plain') {
|
||||
$mail->setBodyText($form->getValue('bodyPlain'));
|
||||
} else {
|
||||
$mail->setBodyHtml($form->getValue('bodyHTML'));
|
||||
}
|
||||
|
||||
$users = new Users();
|
||||
foreach ($users->getUsers() as $user) {
|
||||
$mail->addTo($user->email);
|
||||
}
|
||||
|
||||
foreach ($ccArr as $cc) {
|
||||
$mail->addCC($cc);
|
||||
}
|
||||
|
||||
try {
|
||||
$mail->send();
|
||||
$this->_helper->FlashMessenger->addMessage('Message has been sent');
|
||||
} catch (Zend_Mail_Protocol_Exception $e) {
|
||||
$this->_helper->FlashMessenger->addMessage('There was an error trying to send the message');
|
||||
if ($this->_config->logging->level == Zend_Log::DEBUG) {
|
||||
$this->_helper->FlashMessenger->addMessage($e->getMessage());
|
||||
|
||||
return $this->_redirectFaultyForm($form);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
private function _redirectFaultyForm(Zend_Form $form)
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->messageUsersForm = $form;
|
||||
|
||||
return $this->_forward('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Zend_Mail
|
||||
* @throws Zend_Mail_Protocol_Exception
|
||||
*/
|
||||
public static function getMail()
|
||||
{
|
||||
// can't use $this->_config 'cause we're in a static function
|
||||
$configEmail = Zend_Registry::get('config')->email;
|
||||
switch (strtolower($configEmail->transport)) {
|
||||
case 'smtp':
|
||||
Zend_Mail::setDefaultTransport(
|
||||
new Zend_Mail_Transport_Smtp(
|
||||
$configEmail->host,
|
||||
$configEmail->toArray()
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'mock':
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
|
||||
break;
|
||||
default:
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
|
||||
}
|
||||
|
||||
$mail = new Zend_Mail('UTF-8');
|
||||
$mail->setFrom('support@community-id.org');
|
||||
|
||||
return $mail;
|
||||
}
|
||||
}
|
||||
|
178
modules/default/controllers/OpenidController.php
Normal file
178
modules/default/controllers/OpenidController.php
Normal file
@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class OpenidController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function providerAction()
|
||||
{
|
||||
if (isset($_POST['action']) && $_POST['action'] == 'proceed') {
|
||||
return $this->_proceed();
|
||||
} else {
|
||||
Zend_OpenId::$exitOnRedirect = false;
|
||||
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$server = $this->_getOpenIdProvider();
|
||||
$response = new Zend_Controller_Response_Http();
|
||||
$ret = $server->handle(null, new Zend_OpenId_Extension_Sreg(), $response);
|
||||
Zend_Registry::get('logger')->log("RET: ".print_r($ret, true), Zend_Log::DEBUG);
|
||||
Zend_Registry::get('logger')->log("RESPONSE: ".print_r($response->getHeaders(), true), Zend_Log::DEBUG);
|
||||
if (is_string($ret)) {
|
||||
echo $ret;
|
||||
} else if ($ret !== true) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
Zend_Registry::get('logger')->log("OpenIdController::providerAction: FORBIDDEN", Zend_Log::DEBUG);
|
||||
echo 'Forbidden';
|
||||
} elseif ($ret === true
|
||||
// Zend_OpenId is messy and can change the type of the response I initially sent >:|
|
||||
&& is_a($response, 'Zend_Controller_Response_Http'))
|
||||
|
||||
{
|
||||
$headers = $response->getHeaders();
|
||||
if (isset($headers[0]['name']) && $headers[0]['name'] == 'Location'
|
||||
// redirection to the Trust page is not logged
|
||||
&& strpos($headers[0]['value'], '/openid/trust') === false
|
||||
&& strpos($headers[0]['value'], '/openid/login') === false)
|
||||
{
|
||||
if (strpos($headers[0]['value'], 'openid.mode=cancel') !== false) {
|
||||
$this->_saveHistory($server, History::DENIED);
|
||||
} else {
|
||||
$this->_saveHistory($server, History::AUTHORIZED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function loginAction()
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->openidLoginForm)) {
|
||||
$this->view->form = $appSession->openidLoginForm;
|
||||
unset($appSession->openidLoginForm);
|
||||
} else {
|
||||
$this->view->form = new OpenidLoginForm();
|
||||
}
|
||||
$this->view->form->openIdIdentity->setValue(htmlspecialchars($_GET['openid_identity']));
|
||||
|
||||
$this->view->queryString = $_SERVER['QUERY_STRING'];
|
||||
}
|
||||
|
||||
public function authenticateAction()
|
||||
{
|
||||
$form = new OpenidLoginForm();
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->openidLoginForm = $form;
|
||||
return $this->_forward('login', null, null);
|
||||
}
|
||||
|
||||
$server = $this->_getOpenIdProvider();
|
||||
$server->login($form->getValue('openIdIdentity'), $form->getValue('password'));
|
||||
|
||||
// needed for unit tests
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
Zend_OpenId::redirect($this->view->base . '/openid/provider', $_GET);
|
||||
}
|
||||
|
||||
public function trustAction()
|
||||
{
|
||||
$server = $this->_getOpenIdProvider();
|
||||
$this->view->siteRoot = $server->getSiteRoot($_GET);
|
||||
$this->view->identityUrl = $server->getLoggedInUser($_GET);
|
||||
$this->view->queryString = $_SERVER['QUERY_STRING'];
|
||||
|
||||
$sreg = new Zend_OpenId_Extension_Sreg();
|
||||
$sreg->parseRequest($_GET);
|
||||
|
||||
$this->view->fields = array();
|
||||
$this->view->policyUrl = false;
|
||||
|
||||
$props = $sreg->getProperties();
|
||||
if (is_array($props) && count($props) > 0) {
|
||||
$personalInfoForm = new PersonalInfoForm(null, $this->user, $props);
|
||||
$this->view->fields = $personalInfoForm->getElements();
|
||||
|
||||
$policy = $sreg->getPolicyUrl();
|
||||
if (!empty($policy)) {
|
||||
$this->view->policyUrl = $policy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _proceed()
|
||||
{
|
||||
// needed for unit tests
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$server = $this->_getOpenIdProvider();
|
||||
|
||||
$sreg = new Zend_OpenId_Extension_Sreg();
|
||||
$sreg->parseRequest($_GET);
|
||||
$props = $sreg->getProperties();
|
||||
|
||||
$personalInfoForm = new PersonalInfoForm(null, $this->user, $props);
|
||||
$formData = $this->_request->getPost();
|
||||
$personalInfoForm->populate($formData);
|
||||
|
||||
// not planning on validating stuff here yet, but I call this
|
||||
// for the date element to be filled properly
|
||||
$personalInfoForm->isValid($formData);
|
||||
|
||||
$sreg->parseResponse($personalInfoForm->getValues());
|
||||
if (isset($_POST['allow'])) {
|
||||
if (isset($_POST['forever'])) {
|
||||
$server->allowSite($server->getSiteRoot($_GET), $sreg);
|
||||
}
|
||||
unset($_GET['openid_action']);
|
||||
|
||||
$this->_saveHistory($server, History::AUTHORIZED);
|
||||
|
||||
$server->respondToConsumer($_GET, $sreg);
|
||||
} else if (isset($_POST['deny'])) {
|
||||
if (isset($_POST['forever'])) {
|
||||
$server->denySite($server->getSiteRoot($_GET));
|
||||
}
|
||||
|
||||
$this->_saveHistory($server, History::DENIED);
|
||||
|
||||
Zend_OpenId::redirect($_GET['openid_return_to'], array('openid.mode'=>'cancel'));
|
||||
}
|
||||
}
|
||||
private function _saveHistory(Zend_OpenId_Provider $server, $result)
|
||||
{
|
||||
$histories = new Histories();
|
||||
$history = $histories->createRow();
|
||||
$history->user_id = $this->user->id;
|
||||
$history->date = date('Y-m-d H:i:s');
|
||||
$history->site = $server->getSiteRoot($_GET);
|
||||
$history->ip = $_SERVER['REMOTE_ADDR'];
|
||||
$history->result = $result;
|
||||
$history->save();
|
||||
}
|
||||
|
||||
private function _getOpenIdProvider()
|
||||
{
|
||||
$server = new Zend_OpenId_Provider($this->view->base . '/openid/login',
|
||||
$this->view->base . '/openid/trust',
|
||||
new OpenIdUser(),
|
||||
new Monkeys_OpenId_Provider_Storage_Database());
|
||||
|
||||
return $server;
|
||||
}
|
||||
}
|
32
modules/default/controllers/PrivacyController.php
Normal file
32
modules/default/controllers/PrivacyController.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class PrivacyController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
|
||||
if (file_exists(APP_DIR . "/resources/$locale/privacy.txt")) {
|
||||
$file = APP_DIR . "/resources/$locale/privacy.txt";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/privacy.txt")) {
|
||||
$file = APP_DIR . "/resources/".$localeElements[0]."/privacy.txt";
|
||||
} else {
|
||||
$file = APP_DIR . "/resources/en/privacy.txt";
|
||||
}
|
||||
|
||||
$this->view->privacyPolicy = nl2br(file_get_contents($file));
|
||||
}
|
||||
}
|
121
modules/default/controllers/SitesController.php
Normal file
121
modules/default/controllers/SitesController.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class SitesController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function listAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$fields = new Fields();
|
||||
$sites = new Sites();
|
||||
$sitesRows = $sites->get(
|
||||
$this->user,
|
||||
$this->_getParam('startIndex'),
|
||||
$this->_getParam('results')
|
||||
);
|
||||
|
||||
$jsonObj = new StdClass();
|
||||
$jsonObj->recordsReturned = count($sitesRows);
|
||||
$jsonObj->totalRecords = $sites->getNumSites($this->user);
|
||||
$jsonObj->startIndex = $this->_getParam('startIndex');
|
||||
$jsonObj->sort = null;
|
||||
$jsonObj->dir = 'asc';
|
||||
$jsonObj->records = array();
|
||||
|
||||
foreach ($sitesRows as $site) {
|
||||
$jsonObjSite = new StdClass();
|
||||
$jsonObjSite->id = $site->id;
|
||||
$jsonObjSite->site = $site->site;
|
||||
|
||||
$trusted = unserialize($site->trusted);
|
||||
$jsonObjSite->trusted = (is_bool($trusted) && $trusted) || is_array($trusted);
|
||||
|
||||
if (is_array($trusted)
|
||||
&& isset($trusted['Zend_OpenId_Extension_Sreg'])
|
||||
&& count($trusted['Zend_OpenId_Extension_Sreg']) > 0)
|
||||
{
|
||||
$translatedTrusted = array();
|
||||
foreach ($trusted['Zend_OpenId_Extension_Sreg'] as $identifier => $value) {
|
||||
$translatedTrusted[$this->view->translate($fields->getFieldName($identifier))] = $value;
|
||||
}
|
||||
$jsonObjSite->infoExchanged = $translatedTrusted;
|
||||
} else {
|
||||
$jsonObjSite->infoExchanged = false;
|
||||
}
|
||||
|
||||
$jsonObj->records[] = $jsonObjSite;
|
||||
}
|
||||
|
||||
echo Zend_Json::encode($jsonObj);
|
||||
}
|
||||
|
||||
public function denyAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$sites = new Sites();
|
||||
$site = $sites->getRowInstance($this->_getParam('id'));
|
||||
if ($site->user_id != $this->user->id) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$site->trusted = serialize(false);
|
||||
$site->save();
|
||||
|
||||
$json = new StdClass();
|
||||
$json->code = 200;
|
||||
|
||||
echo Zend_Json::encode($json);
|
||||
}
|
||||
|
||||
public function allowAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$sites = new Sites();
|
||||
$site = $sites->getRowInstance($this->_getParam('id'));
|
||||
if ($site->user_id != $this->user->id) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$site->trusted = serialize(true);
|
||||
$site->save();
|
||||
|
||||
$json = new StdClass();
|
||||
$json->code = 200;
|
||||
|
||||
echo Zend_Json::encode($json);
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$sites = new Sites();
|
||||
$site = $sites->getRowInstance($this->_getParam('id'));
|
||||
if ($site->user_id != $this->user->id) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$site->delete();
|
||||
|
||||
$json = new StdClass();
|
||||
$json->code = 200;
|
||||
|
||||
echo Zend_Json::encode($json);
|
||||
}
|
||||
}
|
25
modules/default/forms/ErrorMessages.php
Normal file
25
modules/default/forms/ErrorMessages.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is never called. It's only a placeholder for form error messages wrapped in translate(),
|
||||
* so that Poedit (or any other message catalogs editor) can catalog these messages for translation
|
||||
*/
|
||||
class ErrorMessages
|
||||
{
|
||||
private function _messages()
|
||||
{
|
||||
translate('Value is empty, but a non-empty value is required');
|
||||
translate('\'%value%\' is not a valid email address in the basic format local-part@hostname');
|
||||
translate('Captcha value is wrong');
|
||||
translate('Password confirmation does not match');
|
||||
}
|
||||
}
|
61
modules/default/forms/FeedbackForm.php
Normal file
61
modules/default/forms/FeedbackForm.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class FeedbackForm extends Zend_Form
|
||||
{
|
||||
private $_baseWebDir;
|
||||
|
||||
public function __construct($options = null, $baseWebDir = null)
|
||||
{
|
||||
$this->_baseWebDir = $baseWebDir;
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$name = new Monkeys_Form_Element_Text('name');
|
||||
translate('Enter your name');
|
||||
$name->setLabel('Enter your name')
|
||||
->setRequired(true);
|
||||
|
||||
$email = new Monkeys_Form_Element_Text('email');
|
||||
translate('Enter your E-mail');
|
||||
$email->setLabel('Enter your E-mail')
|
||||
->addFilter('StringToLower')
|
||||
->setRequired(true)
|
||||
->addValidator('EmailAddress');
|
||||
|
||||
$feedback = new Monkeys_Form_Element_Textarea('feedback');
|
||||
translate('Enter your questions or comments');
|
||||
$feedback->setLabel('Enter your questions or comments')
|
||||
->setRequired(true)
|
||||
->setAttrib('cols', 60)
|
||||
->setAttrib('rows', 4);
|
||||
|
||||
// ZF has some bugs when using mutators here, so I have to use the config array
|
||||
translate('Please enter the text below');
|
||||
$captcha = new Monkeys_Form_Element_Captcha('captcha', array(
|
||||
'label' => 'Please enter the text below',
|
||||
'captcha' => array(
|
||||
'captcha' => 'Image',
|
||||
'sessionClass' => get_class(Zend_Registry::get('appSession')),
|
||||
'font' => APP_DIR . '/libs/Monkeys/fonts/Verdana.ttf',
|
||||
'imgDir' => APP_DIR . '/webdir/captchas',
|
||||
'imgUrl' => $this->_baseWebDir . '/captchas',
|
||||
'wordLen' => 4,
|
||||
'fontSize' => 30,
|
||||
'timeout' => 300,
|
||||
)
|
||||
));
|
||||
|
||||
$this->addElements(array($name, $email, $feedback, $captcha));
|
||||
}
|
||||
}
|
34
modules/default/forms/MessageUsersForm.php
Normal file
34
modules/default/forms/MessageUsersForm.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class MessageUsersForm extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$subject = new Zend_Form_Element_Text('subject');
|
||||
translate('Subject:');
|
||||
$subject->setLabel('Subject:')
|
||||
->setRequired(true);
|
||||
|
||||
$cc = new Zend_Form_Element_Text('cc');
|
||||
translate('CC:');
|
||||
$cc->setLabel('CC:');
|
||||
|
||||
$bodyPlain = new Zend_Form_Element_Textarea('bodyPlain');
|
||||
translate('Body:');
|
||||
$bodyPlain->setLabel('Body:');
|
||||
|
||||
$bodyHTML = new Zend_Form_Element_Textarea('bodyHTML');
|
||||
$bodyHTML->setLabel('Body:');
|
||||
|
||||
$this->addElements(array($subject, $cc, $bodyPlain, $bodyHTML));
|
||||
}
|
||||
}
|
28
modules/default/forms/OpenidLoginForm.php
Normal file
28
modules/default/forms/OpenidLoginForm.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class OpenIdLoginForm extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$openIdIdentity = new Zend_Form_Element_Text('openIdIdentity');
|
||||
translate('Username');
|
||||
$openIdIdentity->setLabel('Username')
|
||||
->setRequired(true);
|
||||
|
||||
$password = new Zend_Form_Element_Password('password');
|
||||
translate('Password');
|
||||
$password->setLabel('Password')
|
||||
->setRequired(true);
|
||||
|
||||
$this->addElements(array($openIdIdentity, $password));
|
||||
}
|
||||
}
|
15
modules/default/models/Association.php
Normal file
15
modules/default/models/Association.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Association extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
}
|
26
modules/default/models/Associations.php
Normal file
26
modules/default/models/Associations.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Associations extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'associations';
|
||||
protected $_primary = 'handle';
|
||||
protected $_rowClass = 'Association';
|
||||
|
||||
public function getAssociationGivenHandle($handle)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('handle=?', $handle);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
}
|
68
modules/default/models/Field.php
Normal file
68
modules/default/models/Field.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Field extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
const TYPE_TEXT = 1;
|
||||
const TYPE_DATE = 2;
|
||||
const TYPE_GENDER = 3;
|
||||
const TYPE_COUNTRY = 4;
|
||||
const TYPE_LANGUAGE = 5;
|
||||
const TYPE_TIMEZONE = 6;
|
||||
const TYPE_EMAIL = 7;
|
||||
|
||||
public function getFormElement()
|
||||
{
|
||||
$varname = 'field_' . $this->id;
|
||||
|
||||
switch ($this->type) {
|
||||
case self::TYPE_TEXT:
|
||||
$el = new Monkeys_Form_Element_Text($varname);
|
||||
break;
|
||||
case self::TYPE_DATE:
|
||||
$el = new Monkeys_Form_Element_Date($varname);
|
||||
$el->addValidator('date')
|
||||
->setShowEmptyValues(true)
|
||||
->setStartEndYear(1900, date('Y') - 7)
|
||||
->setReverseYears(true);
|
||||
break;
|
||||
case self::TYPE_GENDER:
|
||||
translate('Male');
|
||||
translate('Female');
|
||||
$el = new Monkeys_Form_Element_Radio($varname);
|
||||
$el->setSeparator('  ')
|
||||
->addMultiOption('M', 'Male')
|
||||
->addMultiOption('F', 'Female');
|
||||
break;
|
||||
case self::TYPE_COUNTRY:
|
||||
$el = new Monkeys_Form_Element_Country($varname);
|
||||
break;
|
||||
case self::TYPE_LANGUAGE:
|
||||
$el = new Monkeys_Form_Element_Language($varname);
|
||||
break;
|
||||
case self::TYPE_TIMEZONE:
|
||||
$el = new Monkeys_Form_Element_Timezone($varname);
|
||||
break;
|
||||
case self::TYPE_EMAIL:
|
||||
$el = new Monkeys_Form_Element_Text($varname);
|
||||
$el->addValidator('EmailAddress');
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Unknown field type: ' . $this->type);
|
||||
break;
|
||||
}
|
||||
$el->setLabel($this->name);
|
||||
$el->setValue($this->value);
|
||||
|
||||
return $el;
|
||||
}
|
||||
}
|
55
modules/default/models/Fields.php
Normal file
55
modules/default/models/Fields.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Fields extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'fields';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'Field';
|
||||
|
||||
private $_fieldsNames= array();
|
||||
|
||||
public function getValues(User $user)
|
||||
{
|
||||
$userId = (int)$user->id;
|
||||
$select = $this->select()
|
||||
->setIntegrityCheck(false)
|
||||
->from('fields')
|
||||
->joinLeft('fields_values', "fields_values.field_id=fields.id AND fields_values.user_id=".$user->id);
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getFieldName($fieldIdentifier)
|
||||
{
|
||||
if (!$this->_fieldsNames) {
|
||||
foreach ($this->fetchAll($this->select()) as $field) {
|
||||
$this->_fieldsNames[$field->openid] = $field->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_fieldsNames[$fieldIdentifier];
|
||||
}
|
||||
|
||||
private function _translationPlaceholders()
|
||||
{
|
||||
translate('Nickname');
|
||||
translate('E-mail');
|
||||
translate('Full Name');
|
||||
translate('Date of Birth');
|
||||
translate('Gender');
|
||||
translate('Postal Code');
|
||||
translate('Country');
|
||||
translate('Language');
|
||||
translate('Time Zone');
|
||||
}
|
||||
}
|
15
modules/default/models/FieldsValue.php
Normal file
15
modules/default/models/FieldsValue.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class FieldsValue extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
}
|
24
modules/default/models/FieldsValues.php
Normal file
24
modules/default/models/FieldsValues.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class FieldsValues extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'fields_values';
|
||||
protected $_primary = array('user_id', 'field_id');
|
||||
protected $_rowClass = 'FieldsValue';
|
||||
|
||||
public function deleteForUser(User $user)
|
||||
{
|
||||
$where = $this->getAdapter()->quoteInto('user_id=?', $user->id);
|
||||
$this->delete($where);
|
||||
}
|
||||
}
|
51
modules/default/models/Histories.php
Executable file
51
modules/default/models/Histories.php
Executable file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Histories extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'history';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'History';
|
||||
|
||||
public function get(User $user, $startIndex, $results)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('user_id=?', $user->id);
|
||||
|
||||
if ($startIndex !== false && $results !== false) {
|
||||
$select = $select->limit($results, $startIndex);
|
||||
}
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getNumHistories(User $user)
|
||||
{
|
||||
$sites = $this->get($user, false, false);
|
||||
|
||||
return count($sites);
|
||||
}
|
||||
|
||||
public function clear(User $user)
|
||||
{
|
||||
$where = $this->getAdapter()->quoteInto('user_id=?', $user->id);
|
||||
$this->delete($where);
|
||||
}
|
||||
|
||||
public function clearOldEntries()
|
||||
{
|
||||
$days = Zend_Registry::get('config')->environment->keep_history_days;
|
||||
|
||||
$where = $this->getAdapter()->quoteInto('date < ?', date('Y-m-d', time() - $days * 86400));
|
||||
$this->delete($where);
|
||||
}
|
||||
}
|
17
modules/default/models/History.php
Executable file
17
modules/default/models/History.php
Executable file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class History extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
const DENIED = 0;
|
||||
const AUTHORIZED = 1;
|
||||
}
|
38
modules/default/models/Settings.php
Normal file
38
modules/default/models/Settings.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Settings extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'settings';
|
||||
protected $_primary = 'name';
|
||||
|
||||
const MAINTENANCE_MODE = 'maintenance_mode';
|
||||
|
||||
public function get($name)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('name=?', $name);
|
||||
|
||||
$row = $this->fetchRow($select);
|
||||
|
||||
return $row->value;
|
||||
}
|
||||
|
||||
public function set($name, $value)
|
||||
{
|
||||
$this->update(array('value' => $value), $this->getAdapter()->quoteInto('name=?', $name));
|
||||
}
|
||||
|
||||
public function isMaintenanceMode()
|
||||
{
|
||||
return $this->get(self::MAINTENANCE_MODE);
|
||||
}
|
||||
}
|
15
modules/default/models/Site.php
Normal file
15
modules/default/models/Site.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Site extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
}
|
52
modules/default/models/Sites.php
Normal file
52
modules/default/models/Sites.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Sites extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'sites';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'Site';
|
||||
|
||||
public function deleteForUserSite(User $user, $site)
|
||||
{
|
||||
$where1 = $this->getAdapter()->quoteInto('user_id=?',$user->id);
|
||||
$where2 = $this->getAdapter()->quoteInto('site=?', $site);
|
||||
$this->delete("$where1 AND $where2");
|
||||
}
|
||||
|
||||
public function get(User $user, $startIndex, $results)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('user_id=?', $user->id);
|
||||
|
||||
if ($startIndex !== false && $results !== false) {
|
||||
$select = $select->limit($results, $startIndex);
|
||||
}
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getNumSites(User $user)
|
||||
{
|
||||
$sites = $this->get($user, false, false);
|
||||
|
||||
return count($sites);
|
||||
}
|
||||
|
||||
public function getTrusted(User $user)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('user_id=?', $user->id);
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
}
|
22
modules/default/views/scripts/about/index-de.phtml
Normal file
22
modules/default/views/scripts/about/index-de.phtml
Normal file
@ -0,0 +1,22 @@
|
||||
<p>
|
||||
Community-ID ist ein Service, zur Verfügung gestellt mit freundlicher Unterstützung von Keyboard Monkeys Ltd., Community as a Service ™.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Keyboard Monkeys Ltd. konzentriert sich auf Open-Source-Lösungen und Produkte zur Bildung von Communities über das Internet. Wie bieten auch Consulting so wie ein breites Spektrum an Unterstützung für Open-Source-Technologien aber speziell bieten wir Community-basierte Lösungen und Produkte.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Weitere Produkte oder Services welche wir zur Zeit anbieten oder welche sich in der Planung befinden:
|
||||
<ul>
|
||||
<li>
|
||||
<b><a href="http://sourceforge.net/projects/sciret">Sciret</a></b> - Enterprise Knowledge Base System
|
||||
</li>
|
||||
<li>
|
||||
<b><a href="http://sourceforge.net/projects/textroller">TextRoller</a></b> - Blogging Platform
|
||||
</li>
|
||||
<li>
|
||||
<b>Community Solutions</b> - Open Source Project Collaboration (Zur Zeit unter interner Entwicklung)
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
22
modules/default/views/scripts/about/index-en.phtml
Normal file
22
modules/default/views/scripts/about/index-en.phtml
Normal file
@ -0,0 +1,22 @@
|
||||
<p>
|
||||
Community-ID is a service brought to you by Keyboard Monkeys Ltd., Community as a Service ™.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Keyboard Monkeys Ltd. focuses on providing open source solutions and products aimed at empowering communities accross the Internet. We also do private consulting, providing a wide range of support for open source technologies, but specially we are offering community based solutions and products.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
These are other services and products currently offered, or under planning:
|
||||
<ul>
|
||||
<li>
|
||||
<b><a href="http://sourceforge.net/projects/sciret">Sciret</a></b> - Enterprise Knowledge Base System
|
||||
</li>
|
||||
<li>
|
||||
<b><a href="http://sourceforge.net/projects/textroller">TextRoller</a></b> - Blogging platform
|
||||
</li>
|
||||
<li>
|
||||
<b>Community Solutions</b> - Open Source Project Collaboration (Currently under initial development stages)
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
22
modules/default/views/scripts/about/index-es.phtml
Normal file
22
modules/default/views/scripts/about/index-es.phtml
Normal file
@ -0,0 +1,22 @@
|
||||
<p>
|
||||
Community-ID es un servicio traído a ustedes por Keyboard Monkeys Ltd., Community as a Service ™.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Keyboard Monkeys Ltd. está enfocada en proveer productos y soluciones Open Source dirijidas a la potenciación de comunidades a través de Internet. También hacemos consultoría privada, proporcionando un amplio rango de soporte a tecnologías Open Source, pero especialmente ofreciendo productos y soluciones basados en comunidades.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Estos son otros productos y servicio actualmente ofrecidos, o en desarrollo:
|
||||
<ul>
|
||||
<li>
|
||||
<b><a href="http://sourceforge.net/projects/sciret">Sciret</a></b> - Sistema Empresarial de Base de Conocimientos
|
||||
</li>
|
||||
<li>
|
||||
<b><a href="http://sourceforge.net/projects/textroller">TextRoller</a></b> - Plataforma de Blogging
|
||||
</li>
|
||||
<li>
|
||||
<b>Community Solutions</b> - Open Source Project Collaboration (actualmente bajo desarrollo)
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
22
modules/default/views/scripts/about/index.phtml
Normal file
22
modules/default/views/scripts/about/index.phtml
Normal file
@ -0,0 +1,22 @@
|
||||
<p>
|
||||
Community-ID is a service brought to you by Keyboard Monkeys Ltd., Community as a Service ™.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Keyboard Monkeys Ltd. focuses on providing open source solutions and products aimed at empowering communities accross the Internet. We also do private consulting, providing a wide range of support for open source technologies, but specially we are offering community based solutions and products.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
These are other services and products currently offered, or under planning:
|
||||
<ul>
|
||||
<li>
|
||||
<b><a href="http://sourceforge.net/projects/sciret">Sciret</a></b> - Enterprise Knowledge Base System
|
||||
</li>
|
||||
<li>
|
||||
<b><a href="http://sourceforge.net/projects/textroller">TextRoller</a></b> - Blogging platform
|
||||
</li>
|
||||
<li>
|
||||
<b>Community Solutions</b> - Open Source Project Collaboration (Currently under initial development stages)
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
18
modules/default/views/scripts/error/error.phtml
Executable file
18
modules/default/views/scripts/error/error.phtml
Executable file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Error</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>An error occurred</h2>
|
||||
<strong><?= $this->message ?></strong>
|
||||
<? if ($this->trace): ?>
|
||||
<pre>
|
||||
Stack Trace:
|
||||
<?= $this->trace ?>
|
||||
</pre>
|
||||
<? endif ?>
|
||||
</body>
|
||||
</html>
|
||||
|
11
modules/default/views/scripts/feedback/index.phtml
Normal file
11
modules/default/views/scripts/feedback/index.phtml
Normal file
@ -0,0 +1,11 @@
|
||||
<h3><?= $this->translate('In order to serve you better, we have provided the form below for your questions and comments') ?></h3>
|
||||
<form id="feedbackForm" method="post" action="<?= $this->base ?>/feedback/send" class="formGrid">
|
||||
<?= $this->form->name ?>
|
||||
<?= $this->form->email ?>
|
||||
<?= $this->form->feedback ?>
|
||||
<?= $this->form->captcha ?>
|
||||
<input type="submit" id="send" value="<?= $this->translate('Send') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("send");
|
||||
</script>
|
||||
</form>
|
25
modules/default/views/scripts/history/index.phtml
Executable file
25
modules/default/views/scripts/history/index.phtml
Executable file
@ -0,0 +1,25 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["datasource", "datatable", "paginator", "json", "connection", "dragdrop", "animation", "container"],
|
||||
COMMID.historyList.init,
|
||||
COMMID.historyList
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<div id="paging"></div>
|
||||
<div id="dt"></div>
|
||||
<div id="clearHistory">
|
||||
<input type="button" id="clearHistoryBtn" value="<?= $this->translate('Clear History') ?>" onclick="COMMID.historyList.clearEntries()" />
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"clearHistoryBtn",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.historyList.clearEntries, scope: COMMID.historyList}
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</div>
|
4
modules/default/views/scripts/identity/id.phtml
Normal file
4
modules/default/views/scripts/identity/id.phtml
Normal file
@ -0,0 +1,4 @@
|
||||
<div id="article">
|
||||
This is the identity page for the Community-ID user identified with:
|
||||
<h2 style="text-align:center"><?= $this->idUrl ?></h2>
|
||||
</div>
|
40
modules/default/views/scripts/index/index-de.phtml
Normal file
40
modules/default/views/scripts/index/index-de.phtml
Normal file
@ -0,0 +1,40 @@
|
||||
<div id="home">
|
||||
<h2>
|
||||
Community ID: Freie OpenID Authentifizierung<br />
|
||||
100% basierend auf Open Source Technologie
|
||||
</h2>
|
||||
<div class="yui-g">
|
||||
<div class="yui-u first">
|
||||
<p>
|
||||
Von beginn an wurde Community-ID entwickelt mit Sicherheit als wichtigem Ziel. Jede Komponente in unserem Technologie-Stack wurde ausgewählt nachdem die Sicherheits Historie begutachtet wurde und am wichtigsten, alles was verwendet wurde ist Open Source.
|
||||
</p>
|
||||
<p>
|
||||
Das heißt, die ganze Welt kann sehen was wir machen. Es ist eine erwiesene Tatsache das Sicherheit durch Verschleiern nicht funktioniert und wenn Sie ein Produkt auswählen wo der darunterliegende Mechanismus als Geheimnis behandelt wird setzen Sie ihre Daten (und hiermit sich selbst) einer großen Gefahr aus.
|
||||
</p>
|
||||
<p style="font-weight: bold; text-align:center">
|
||||
Auf was warten Sie noch?<br />
|
||||
Vereinfachen Sie Ihr Leben und verringern das Risiko.<br /><br />
|
||||
<a href="<?= $this->base ?>/users/register">ERÖFFNEN SIE JETZT EIN KONTO</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<div id="homeNews">
|
||||
<h3>Letzte News</h3>
|
||||
<ul>
|
||||
<? foreach ($this->news as $item): ?>
|
||||
<li>
|
||||
<div>
|
||||
<a href="<?= $item->link['href'] ?>"><?= $item->title ?></a>
|
||||
</div>
|
||||
<div class="newsExcerpt">
|
||||
<?= $item->content ?>
|
||||
</div>
|
||||
</li>
|
||||
<? endforeach ?>
|
||||
</ul> <!-- FF bug -->
|
||||
</div>
|
||||
<div class="borderFadingLeft">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
40
modules/default/views/scripts/index/index-en.phtml
Normal file
40
modules/default/views/scripts/index/index-en.phtml
Normal file
@ -0,0 +1,40 @@
|
||||
<div id="home">
|
||||
<h2>
|
||||
Community ID: Free OpenID Authentication<br />
|
||||
Backed 100% with Open Source Technologies
|
||||
</h2>
|
||||
<div class="yui-g">
|
||||
<div class="yui-u first">
|
||||
<p>
|
||||
Since its inception Community-ID has been built with security as the foremost concern. Every element in our technology stack has been chosen looking at its security record, and most importantly, everything is Open Source.
|
||||
</p>
|
||||
<p>
|
||||
This means we're open to scrutiny by the entire world. It is already a proven fact that security by obscurity doesn't work, and when you use a product or service whose underlying mechanism is kept as a secret, you're putting your data (and therefore yourself) into great risk.
|
||||
</p>
|
||||
<p style="font-weight: bold; text-align:center">
|
||||
What are you waiting for?<br />
|
||||
Simplify your life and reduce your risk exposure.<br /><br />
|
||||
<a href="<?= $this->base ?>/users/register">OPEN AN ACCOUNT NOW</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<div id="homeNews">
|
||||
<h3>Latest News</h3>
|
||||
<ul>
|
||||
<? foreach ($this->news as $item): ?>
|
||||
<li>
|
||||
<div>
|
||||
<a href="<?= $item->link['href'] ?>"><?= $item->title ?></a>
|
||||
</div>
|
||||
<div class="newsExcerpt">
|
||||
<?= $item->content ?>
|
||||
</div>
|
||||
</li>
|
||||
<? endforeach ?>
|
||||
</ul> <!-- FF bug -->
|
||||
</div>
|
||||
<div class="borderFadingLeft">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
40
modules/default/views/scripts/index/index-es.phtml
Normal file
40
modules/default/views/scripts/index/index-es.phtml
Normal file
@ -0,0 +1,40 @@
|
||||
<div id="home">
|
||||
<h2>
|
||||
Community ID: Autenticación OpenID gratis<br />
|
||||
Respaldada al 100% con Tecnologías Open Source
|
||||
</h2>
|
||||
<div class="yui-g">
|
||||
<div class="yui-u first">
|
||||
<p>
|
||||
Desde su inicio Community-ID has sido construída con la seguridad como su fundamento más importante. Cada elemento en nuestra pila de tecnologías ha sido escogida de acuerdo a su historial de seguridad. Y lo más importante: todo es Open Source.
|
||||
</p>
|
||||
<p>
|
||||
Esto significa que estamos abiertos al escrutinio del mundo entero. Es ya un hecho provado que la seguridad por obscuridad no funciona, y cuando usted usa un producto o servicio cuyo mecanismo subyacente es guardado como un secreto, está poniendo sus datos (y por ende a usted mismo) bajo un gran riesgo.
|
||||
</p>
|
||||
<p style="font-weight: bold; text-align:center">
|
||||
¿Qué está esperando?<br />
|
||||
Simplifique su vida y reduzca su exposición al riesgo.<br /><br />
|
||||
<a href="<?= $this->base ?>/users/register">ABRA UNA CUENTA AHORA</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<div id="homeNews">
|
||||
<h3>Ultimas Noticias</h3>
|
||||
<ul>
|
||||
<? foreach ($this->news as $item): ?>
|
||||
<li>
|
||||
<div>
|
||||
<a href="<?= $item->link['href'] ?>"><?= $item->title ?></a>
|
||||
</div>
|
||||
<div class="newsExcerpt">
|
||||
<?= $item->content ?>
|
||||
</div>
|
||||
</li>
|
||||
<? endforeach ?>
|
||||
</ul> <!-- FF bug -->
|
||||
</div>
|
||||
<div class="borderFadingLeft">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
1
modules/default/views/scripts/index/subheader-de.phtml
Executable file
1
modules/default/views/scripts/index/subheader-de.phtml
Executable file
@ -0,0 +1 @@
|
||||
<!-- placeholder for home subheader -->
|
1
modules/default/views/scripts/index/subheader-en.phtml
Executable file
1
modules/default/views/scripts/index/subheader-en.phtml
Executable file
@ -0,0 +1 @@
|
||||
<!-- placeholder for home subheader -->
|
1
modules/default/views/scripts/index/subheader-es.phtml
Executable file
1
modules/default/views/scripts/index/subheader-es.phtml
Executable file
@ -0,0 +1 @@
|
||||
<!-- placeholder for home subheader -->
|
54
modules/default/views/scripts/messageusers/index.phtml
Normal file
54
modules/default/views/scripts/messageusers/index.phtml
Normal file
@ -0,0 +1,54 @@
|
||||
<!--[if IE]>
|
||||
<style>
|
||||
/* avoid IE jumping when clearing float here */
|
||||
#messageUsersForm #textareasWrapper dd {
|
||||
clear : none;
|
||||
}
|
||||
</style>
|
||||
<![endif]-->
|
||||
<em><?= $this->translate('This message will be sent to all registered Community-ID users') ?></em>
|
||||
<form id="messageUsersForm" name="messageUsersForm" method="post" action="<?= $this->base ?>/messageusers/send">
|
||||
<input type="hidden" name="messageType" value="rich" />
|
||||
<dl class="shortLabelsForm">
|
||||
<?= $this->messageUsersForm->subject ?>
|
||||
<?= $this->messageUsersForm->cc ?>
|
||||
</dl>
|
||||
<div id="textareasWrapper">
|
||||
<div id="linkSwitchToPlain">
|
||||
<a href="#" onclick="COMMID.messageUsers.switchToPlainText()"><?= $this->translate('switch to Plain-Text') ?></a>
|
||||
</div>
|
||||
<div id="linkSwitchToRich">
|
||||
<a href="#" onclick="COMMID.messageUsers.switchToRichText()"><?= $this->translate('switch to Rich-Text (HTML)') ?></a>
|
||||
</div>
|
||||
<dl class="shortLabelsForm">
|
||||
<!-- can't use the Zend_Form here in order to overcome an IE bug -->
|
||||
<dt id="bodyPlainDt">
|
||||
<label for="bodyPlain" class="optional"><?= $this->translate('Body:') ?></label>
|
||||
</dt>
|
||||
<dd id="bodyPlainDd">
|
||||
<textarea name="bodyPlain" id="bodyPlain" rows="24" cols="80"><?= $this->messageUsersForm->bodyPlain->getValue() ?></textarea>
|
||||
</dd>
|
||||
<dt id="bodyHTMLDt">
|
||||
<label for="bodyHTML" class="optional"><?= $this->translate('Body:') ?></label>
|
||||
</dt>
|
||||
<dd id="bodyHTMLDd">
|
||||
<textarea name="bodyHTML" id="bodyHTML" rows="24" cols="80"><?= $this->messageUsersForm->bodyHTML->getValue() ?></textarea>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<input type="submit" id="send" value="<?= $this->translate('Send') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("send");
|
||||
</script>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady(function() {
|
||||
COMMID.loader.insert(
|
||||
["resize", "menu", "editor"],
|
||||
function() {
|
||||
COMMID.editor.init('100%','500px', 'bodyHTML');
|
||||
$("messageUsersForm").onsubmit = COMMID.messageUsers.send;
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
10
modules/default/views/scripts/openid/login.phtml
Normal file
10
modules/default/views/scripts/openid/login.phtml
Normal file
@ -0,0 +1,10 @@
|
||||
<div id="article">
|
||||
<form action="authenticate?<?= $this->queryString ?>" method="post">
|
||||
<?= $this->form->openIdIdentity ?>
|
||||
<?= $this->form->password ?>
|
||||
<input type="submit" id="login" value="<?= $this->translate('Login') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("login");
|
||||
</script>
|
||||
</form>
|
||||
</div>
|
35
modules/default/views/scripts/openid/trust.phtml
Normal file
35
modules/default/views/scripts/openid/trust.phtml
Normal file
@ -0,0 +1,35 @@
|
||||
<div id="article">
|
||||
<div>
|
||||
<?= $this->translate('A site identifying as %s has asked for confirmation that %s is your identity URL.', '<a href="' . $this->siteRoot . '">' . $this->siteRoot . '</a>', '<a href="' . $this->identityUrl . '">' . $this->identityUrl . '</a>') ?>
|
||||
</div>
|
||||
<form method="post" action="provider?<?= $this->queryString ?>" class="formGrid">
|
||||
<input type="hidden" name="action" value="proceed">
|
||||
<? if ($this->fields): ?>
|
||||
<br />
|
||||
<?= $this->translate('It also requests this additional information about you:') ?><br /><br />
|
||||
<?= $this->translate('Fields are automatically filled according to the personal info stored in your community-id account.') ?><br />
|
||||
<?= $this->translate('Fields marked with * are required.') ?>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<? foreach ($this->fields as $field): ?>
|
||||
<?= $field ?>
|
||||
<? endforeach ?>
|
||||
<? if ($this->policyUrl): ?>
|
||||
<?= $this->translate('The private policy can be found at %s',
|
||||
'<a href="'.$this->policyUrl.'">'.$this->policyUrl.'</a>'); ?><br /><br />
|
||||
<? endif ?>
|
||||
<? endif ?>
|
||||
<div style="margin-top:20px">
|
||||
<input type="checkbox" name="forever" style="top:0" /> <?= $this->translate('Forever') ?>
|
||||
</div>
|
||||
<div style="margin-top:20px">
|
||||
<input type="submit" id="allow" name="allow" value="<?= $this->translate('Allow') ?>" />
|
||||
<input type="submit" id="deny" name="deny" value="<?= $this->translate('Deny') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton1 = new YAHOO.widget.Button("allow");
|
||||
var oButton2 = new YAHOO.widget.Button("deny");
|
||||
</script>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
4
modules/default/views/scripts/privacy/index.phtml
Normal file
4
modules/default/views/scripts/privacy/index.phtml
Normal file
@ -0,0 +1,4 @@
|
||||
<h2><?= $this->translate('Privacy Policy') ?></h2>
|
||||
<div>
|
||||
<?= $this->privacyPolicy ?>
|
||||
</div>
|
35
modules/default/views/scripts/sites/index.phtml
Normal file
35
modules/default/views/scripts/sites/index.phtml
Normal file
@ -0,0 +1,35 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["datasource", "datatable", "paginator", "json", "connection", "dragdrop", "animation", "container"],
|
||||
function() {
|
||||
COMMID.sitesList.init();
|
||||
COMMID.sitesList.initTable();
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<div id="paging"></div>
|
||||
<div id="dt"></div>
|
||||
<div id="fieldsDialog">
|
||||
<div class="hd"><?= $this->translate('Information Exchanged') ?></div>
|
||||
<div class="bd">
|
||||
<?= $this->translate('Information exchanged with:') ?><br />
|
||||
<span id="fieldsDialogSite"></span>
|
||||
<div id="fieldsDialogDl" class="formGrid"></div>
|
||||
<div style="text-align:right">
|
||||
<input type="button" id="closeDialog" value="<?= $this->translate('OK') ?>" onclick="COMMID.sitesList.closeDialog()" />
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"closeDialog",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.sitesList.closeDialog}
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
19
modules/install/controllers/CompleteController.php
Normal file
19
modules/install/controllers/CompleteController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Install_CompleteController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
}
|
||||
}
|
205
modules/install/controllers/CredentialsController.php
Normal file
205
modules/install/controllers/CredentialsController.php
Normal file
@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Install_CredentialsController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
if ($errors = $this->_getErrors()) {
|
||||
return $this->_forward('index', 'permissions', null, array('errors' => $errors));
|
||||
}
|
||||
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->installForm)) {
|
||||
$this->view->form = $appSession->installForm;
|
||||
unset($appSession->installForm);
|
||||
} else {
|
||||
$this->view->form = new InstallForm();
|
||||
}
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$form = new InstallForm();
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
return $this->_forwardFormError($form);
|
||||
}
|
||||
|
||||
if (!$this->_connectToDbEngine($form)) {
|
||||
$this->_helper->FlashMessenger->addMessage('We couldn\'t connect to the database using those credentials.');
|
||||
$this->_helper->FlashMessenger->addMessage('Please verify and try again.');
|
||||
return $this->_forwardFormError($form);
|
||||
}
|
||||
|
||||
if (!$this->_createDbIfMissing($form)) {
|
||||
$this->_helper->FlashMessenger->addMessage(
|
||||
'The connection to the database engine worked, but the database "' . $form->getValue('dbname') . '" doesn\'t exist or the provided user doesn\'t have access to it. An attempt was made to create it, but the provided user doesn\'t have permissions to do so either. Please create it yourself and try again.');
|
||||
return $this->_forwardFormError($form);
|
||||
}
|
||||
|
||||
$this->_importDb();
|
||||
|
||||
if (!$this->_writeConfig($form)) {
|
||||
throw new Exception('Couldn\'t write to config file file ' . APP_DIR . DIRECTORY_SEPARATOR . 'config.php');
|
||||
}
|
||||
|
||||
$this->_forward('index', 'complete');
|
||||
}
|
||||
|
||||
private function _connectToDbEngine(InstallForm $form)
|
||||
{
|
||||
$this->_config->database->params->host = $form->getValue('hostname');
|
||||
$this->_config->database->params->username = $form->getValue('dbusername');
|
||||
$this->_config->database->params->password = $form->getValue('dbpassword');
|
||||
|
||||
// setting dbname to null makes Zend_Db::getConnection() try to connect to the db engine
|
||||
// without attempting to connect to the dbname
|
||||
$this->_config->database->params->dbname = null;
|
||||
|
||||
return Setup::setDatabase();
|
||||
}
|
||||
|
||||
private function _createDbIfMissing(InstallForm $form)
|
||||
{
|
||||
$this->_config->database->params->host = $form->getValue('hostname');
|
||||
$this->_config->database->params->username = $form->getValue('dbusername');
|
||||
$this->_config->database->params->password = $form->getValue('dbpassword');
|
||||
|
||||
$this->_config->database->params->dbname = $form->getValue('dbname');
|
||||
|
||||
if (!Setup::setDatabase()) {
|
||||
try {
|
||||
$this->_config->database->params->dbname = null;
|
||||
Setup::setDatabase();
|
||||
|
||||
// binding doesn't work here for some reason
|
||||
Zend_Registry::get('db')->getConnection()->query("CREATE DATABASE `" . $form->getValue('dbname') . "`");
|
||||
$this->_config->database->params->dbname = $form->getValue('dbname');
|
||||
Setup::setDatabase();
|
||||
} catch (PDOException $e) { // when using PDO, it throws this exception, not Zend's
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _writeConfig(InstallForm $form)
|
||||
{
|
||||
$this->_config->environment->installed = true;
|
||||
$this->_config->email->supportemail = $form->getValue('supportemail');
|
||||
|
||||
$configTemplate = file_get_contents(APP_DIR . DIRECTORY_SEPARATOR . 'config.template.php');
|
||||
$replace = array(
|
||||
'{environment.installed}' => $this->_config->environment->installed? 'true' : 'false',
|
||||
'{environment.session_name}' => $this->_config->environment->session_name,
|
||||
'{environment.production}' => $this->_config->environment->production? 'true' : 'false',
|
||||
'{environment.YDN}' => $this->_config->environment->YDN? 'true' : 'false',
|
||||
'{environment.ajax_slowdown}' => $this->_config->environment->ajax_slowdown,
|
||||
'{environment.keep_history_days}' => $this->_config->environment->keep_history_days,
|
||||
'{environment.registrations_enabled}' => $this->_config->environment->registrations_enabled? 'true' : 'false',
|
||||
'{environment.locale}' => $this->_config->environment->locale,
|
||||
'{environment.template}' => $this->_config->environment->template,
|
||||
'{news_feed.url}' => $this->_config->news_feed->url,
|
||||
'{news_feed.num_items}' => $this->_config->news_feed->num_items,
|
||||
'{logging.location}' => $this->_config->logging->location,
|
||||
'{logging.level}' => $this->_config->logging->level,
|
||||
'{subdomain.enabled}' => $this->_config->subdomain->enabled? 'true' : 'false',
|
||||
'{subdomain.hostname}' => $this->_config->subdomain->hostname,
|
||||
'{subdomain.use_www}' => $this->_config->subdomain->use_www? 'true' : 'false',
|
||||
'{SSL.enable_mixed_mode}' => $this->_config->SSL->enable_mixed_mode? 'true' : 'false',
|
||||
'{database.adapter}' => $this->_config->database->adapter,
|
||||
'{database.params.host}' => $this->_config->database->params->host,
|
||||
'{database.params.dbname}' => $this->_config->database->params->dbname,
|
||||
'{database.params.username}' => $this->_config->database->params->username,
|
||||
'{database.params.password}' => $this->_config->database->params->password,
|
||||
'{email.supportemail}' => $this->_config->email->supportemail,
|
||||
'{email.adminemail}' => $this->_config->email->adminemail,
|
||||
'{email.transport}' => $this->_config->email->transport,
|
||||
'{email.host}' => $this->_config->email->host,
|
||||
'{email.auth}' => $this->_config->email->auth,
|
||||
'{email.username}' => $this->_config->email->username,
|
||||
'{email.password}' => $this->_config->email->password,
|
||||
);
|
||||
$configTemplate = str_replace(array_keys($replace), array_values($replace), $configTemplate);
|
||||
|
||||
return @file_put_contents(APP_DIR . DIRECTORY_SEPARATOR . 'config.php', $configTemplate);
|
||||
}
|
||||
|
||||
private function _importDb()
|
||||
{
|
||||
$this->_runSqlFILE('final.sql');
|
||||
}
|
||||
|
||||
function _runSqlFile($fileName) {
|
||||
$fp = fopen(APP_DIR . DIRECTORY_SEPARATOR . "/setup/$fileName", 'r');
|
||||
$query = '';
|
||||
$db = Zend_Registry::get('db');
|
||||
while (!feof($fp)) {
|
||||
$line = trim(fgets($fp));
|
||||
|
||||
// skip SQL comments
|
||||
if (substr($line, 0, 2) == '--') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$query .= $line;
|
||||
if ((substr($line, -1, 1) == ';' || feof($fp)) && $query != '') {
|
||||
// I had to resort to a direct call because regexes inside the Zend Framework are segfaulting with the long queries in sampleData.sql
|
||||
//$this->db->query($query);
|
||||
$db->getConnection()->query($query);
|
||||
|
||||
$query = '';
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
private function _forwardFormError(InstallForm $form)
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->installForm = $form;
|
||||
$this->_redirect('/install/credentials');
|
||||
return;
|
||||
}
|
||||
|
||||
private function _getErrors()
|
||||
{
|
||||
$errors = array();
|
||||
$webServerUser = $this->_getProcessUser();
|
||||
|
||||
if (!is_writable(APP_DIR) && !is_writable(APP_DIR . '/config.php')) {
|
||||
$errors[] = $this->view->translate('The directory where Community-ID is installed must be writable by the web server user (%s). Another option is to create an EMPTY config.php file that is writable by that user.', $webServerUser);
|
||||
}
|
||||
if (!is_writable(WEB_DIR . '/captchas')) {
|
||||
$errors[] = $this->view->translate('The directory "captchas" under the web directory for Community-ID must be writable by the web server user (%s)', $webServerUser);
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
private function _getProcessUser()
|
||||
{
|
||||
if (!function_exists('posix_getpwuid')) {
|
||||
// we're on windows
|
||||
return getenv('USERNAME');
|
||||
}
|
||||
|
||||
$processUser = posix_getpwuid(posix_geteuid());
|
||||
|
||||
return $processUser['name'];
|
||||
}
|
||||
}
|
19
modules/install/controllers/IndexController.php
Normal file
19
modules/install/controllers/IndexController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Install_IndexController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
}
|
||||
}
|
20
modules/install/controllers/PermissionsController.php
Normal file
20
modules/install/controllers/PermissionsController.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Install_PermissionsController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->errors = $this->_getParam('errors');
|
||||
}
|
||||
}
|
44
modules/install/forms/InstallForm.php
Normal file
44
modules/install/forms/InstallForm.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class InstallForm extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$hostname = new Zend_Form_Element_Text('hostname');
|
||||
$hostname->setLabel('Hostname:')
|
||||
->setDescription('usually localhost')
|
||||
->setRequired(true)
|
||||
->setValue('localhost');
|
||||
|
||||
$dbname = new Zend_Form_Element_Text('dbname');
|
||||
$dbname->setLabel('Database name:')
|
||||
->setRequired(true)
|
||||
->setValue(Zend_Registry::get('config')->database->params->dbname);
|
||||
|
||||
$dbusername = new Zend_Form_Element_Text('dbusername');
|
||||
$dbusername->setLabel('Database username:')
|
||||
->setRequired(true);
|
||||
|
||||
$dbpassword = new Zend_Form_Element_Password('dbpassword');
|
||||
$dbpassword->setLabel('Database password:');
|
||||
|
||||
$supportemail = new Zend_Form_Element_Text('supportemail');
|
||||
$supportemail->setLabel('Support E-mail:')
|
||||
->setDescription('Will be used as the sender for any message sent by the system, and as the recipient for user feedback')
|
||||
->addFilter('StringToLower')
|
||||
->addValidator('EmailAddress')
|
||||
->setRequired(true);
|
||||
|
||||
$this->addElements(array($hostname, $dbname, $dbusername, $dbpassword, $supportemail));
|
||||
}
|
||||
}
|
20
modules/install/views/scripts/complete/index.phtml
Normal file
20
modules/install/views/scripts/complete/index.phtml
Normal file
@ -0,0 +1,20 @@
|
||||
<h3>
|
||||
<?= $this->translate('The installation was performed successfully') ?>
|
||||
</h3>
|
||||
<div style="margin-top:20px">
|
||||
<div>
|
||||
You can login as the administrator with the username "admin" and the password "admin"<br />
|
||||
Please note that this user is only meant for administrative tasks, and cannot have an OpenID credential.
|
||||
</div>
|
||||
<div style="margin-top:20px">
|
||||
<input type="button" id="start" value="<?= $this->translate('Finish') ?>" />
|
||||
<div>
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"start",
|
||||
{
|
||||
onclick: {fn: function() {location.href="<?= $this->base ?>"}}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</div>
|
16
modules/install/views/scripts/credentials/index.phtml
Normal file
16
modules/install/views/scripts/credentials/index.phtml
Normal file
@ -0,0 +1,16 @@
|
||||
<h3>
|
||||
<?= $this->translate('Database and E-mail information') ?>
|
||||
</h3>
|
||||
<form name="installform" method="post" action="<?= $this->base ?>/install/credentials/save" class="longLabelsForm">
|
||||
<dl>
|
||||
<?= $this->form->hostname ?>
|
||||
<?= $this->form->dbname ?>
|
||||
<?= $this->form->dbusername ?>
|
||||
<?= $this->form->dbpassword ?>
|
||||
<?= $this->form->supportemail ?>
|
||||
</dl>
|
||||
<input type="submit" id="send" value="<?= $this->translate('Send') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("send");
|
||||
</script>
|
||||
</form>
|
14
modules/install/views/scripts/index/index.phtml
Normal file
14
modules/install/views/scripts/index/index.phtml
Normal file
@ -0,0 +1,14 @@
|
||||
<h3>
|
||||
<?= $this->translate('This Community-ID instance hasn\'t been installed yet') ?>
|
||||
</h3>
|
||||
<div style="margin-top:20px">
|
||||
<input type="button" id="start" value="<?= $this->translate('Proceed with installation')?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"start",
|
||||
{
|
||||
onclick: {fn: function() {location.href="<?= $this->base ?>/install/credentials"}}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</div>
|
19
modules/install/views/scripts/permissions/index.phtml
Normal file
19
modules/install/views/scripts/permissions/index.phtml
Normal file
@ -0,0 +1,19 @@
|
||||
<h3>
|
||||
<?= $this->translate('Please correct the following problems before proceeding:') ?>
|
||||
</h3>
|
||||
<ul>
|
||||
<? foreach ($this->errors as $error): ?>
|
||||
<li style="list-style-type:circle"><?= $error ?></li>
|
||||
<? endforeach ?>
|
||||
</ul>
|
||||
<div style="margin-top:20px">
|
||||
<input type="button" id="check" value="<?= $this->translate('Check again')?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"check",
|
||||
{
|
||||
onclick: {fn: function() {location.href="<?= $this->base ?>/install/credentials"}}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</div>
|
106
modules/stats/controllers/AuthorizationsController.php
Normal file
106
modules/stats/controllers/AuthorizationsController.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_AuthorizationsController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->weekSelected = '';
|
||||
$this->view->yearSelected = '';
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'year':
|
||||
$this->view->yearSelected = 'selected="true"';
|
||||
$this->view->type = 'year';
|
||||
break;
|
||||
default:
|
||||
$this->view->weekSelected = 'selected="true"';
|
||||
$this->view->type = 'week';
|
||||
}
|
||||
|
||||
$this->view->rand = rand(0, 1000);
|
||||
}
|
||||
|
||||
public function graphAction()
|
||||
{
|
||||
require_once 'libs/jpgraph/jpgraph.php';
|
||||
require_once 'libs/jpgraph/jpgraph_bar.php';
|
||||
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
$this->_helper->layout->disableLayout();
|
||||
|
||||
$graph = new Graph(300,200 ,'auto');
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetFrame(false);
|
||||
$graph->SetScale("textlin");
|
||||
$graph->img->SetMargin(0,30,20,40);
|
||||
$graph->yaxis->scale->SetGrace(20);
|
||||
$graph->yaxis->HideLabels();
|
||||
$graph->yaxis->HideTicks();
|
||||
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5');
|
||||
|
||||
$labelsy = array();
|
||||
$datay = array();
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'year':
|
||||
$this->_populateYearData($labelsy, $datay);
|
||||
break;
|
||||
default:
|
||||
$this->_populateWeekData($labelsy, $datay);
|
||||
}
|
||||
|
||||
$graph->xaxis->SetTickLabels($labelsy);
|
||||
$bplot = new BarPlot($datay);
|
||||
|
||||
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDVER);
|
||||
$bplot->value->Show();
|
||||
$bplot->value->SetFormat('%d');
|
||||
$graph->Add($bplot);
|
||||
|
||||
$graph->Stroke();
|
||||
}
|
||||
|
||||
private function _populateWeekData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$authorizations = $stats->getNumAuthorizationsDays(strtotime('-1 week'), time());
|
||||
|
||||
for ($i = -7; $i < 0; $i++) {
|
||||
$time = strtotime("$i days");
|
||||
$date = date('Y-m-d', $time);
|
||||
$labelsy[] = Stats::$weekDays[date('w', $time)];
|
||||
if (isset($authorizations[$date])) {
|
||||
$datay[] = $authorizations[$date]['entry'];
|
||||
} else {
|
||||
$datay[] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _populateYearData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$firstDayOfMonth = date('Y-' . date('m') . '-01');
|
||||
$authorizations = $stats->getNumAuthorizationsYear(strtotime('-11 months', strtotime($firstDayOfMonth)), time());
|
||||
|
||||
for ($i = -11; $i <= 0; $i++) {
|
||||
$time = strtotime("$i months");
|
||||
$monthNumber = date('n', $time);
|
||||
$labelsy[] = Stats::$months[$monthNumber];
|
||||
if (isset($authorizations[$monthNumber])) {
|
||||
$datay[] = $authorizations[$monthNumber]['entry'];
|
||||
} else {
|
||||
$datay[] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
19
modules/stats/controllers/IndexController.php
Normal file
19
modules/stats/controllers/IndexController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_IndexController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
}
|
||||
}
|
130
modules/stats/controllers/RegistrationsController.php
Normal file
130
modules/stats/controllers/RegistrationsController.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_RegistrationsController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->weekSelected = '';
|
||||
$this->view->yearSelected = '';
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'month':
|
||||
$this->view->monthSelected = 'selected="true"';
|
||||
$this->view->type = 'month';
|
||||
break;
|
||||
case 'year':
|
||||
$this->view->yearSelected = 'selected="true"';
|
||||
$this->view->type = 'year';
|
||||
break;
|
||||
default:
|
||||
$this->view->weekSelected = 'selected="true"';
|
||||
$this->view->type = 'week';
|
||||
}
|
||||
|
||||
$this->view->rand = rand(0, 1000);
|
||||
}
|
||||
|
||||
public function graphAction()
|
||||
{
|
||||
require_once 'libs/jpgraph/jpgraph.php';
|
||||
require_once 'libs/jpgraph/jpgraph_bar.php';
|
||||
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
$this->_helper->layout->disableLayout();
|
||||
|
||||
$graph = new Graph($this->_getParam('type') == 'month'? 400 : 300, 200 ,'auto');
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetFrame(false);
|
||||
$graph->SetScale("textlin");
|
||||
$graph->img->SetMargin(0,30,20,40);
|
||||
$graph->yaxis->scale->SetGrace(20);
|
||||
$graph->yaxis->HideLabels();
|
||||
$graph->yaxis->HideTicks();
|
||||
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5');
|
||||
|
||||
$labelsy = array();
|
||||
$datay = array();
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'month':
|
||||
$this->_populateMonthData($labelsy, $datay);
|
||||
break;
|
||||
case 'year':
|
||||
$this->_populateYearData($labelsy, $datay);
|
||||
break;
|
||||
default:
|
||||
$this->_populateWeekData($labelsy, $datay);
|
||||
}
|
||||
|
||||
$graph->xaxis->SetTickLabels($labelsy);
|
||||
$bplot = new BarPlot($datay);
|
||||
|
||||
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDVER);
|
||||
$bplot->value->Show();
|
||||
$bplot->value->SetFormat('%d');
|
||||
$graph->Add($bplot);
|
||||
|
||||
$graph->Stroke();
|
||||
}
|
||||
|
||||
private function _populateWeekData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$registeredUsers = $stats->getNumRegisteredUsersDays(strtotime('-1 week'), time());
|
||||
|
||||
for ($i = -7; $i < 0; $i++) {
|
||||
$time = strtotime("$i days");
|
||||
$date = date('Y-m-d', $time);
|
||||
$labelsy[] = Stats::$weekDays[date('w', $time)];
|
||||
if (isset($registeredUsers[$date])) {
|
||||
$datay[] = $registeredUsers[$date]['users'];
|
||||
} else {
|
||||
$datay[] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _populateMonthData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$registeredUsers = $stats->getNumRegisteredUsersDays(strtotime('-30 days'), strtotime('-1 week'));
|
||||
|
||||
for ($i = -30; $i < -7; $i++) {
|
||||
$time = strtotime("$i days");
|
||||
$date = date('Y-m-d', $time);
|
||||
$labelsy[] = date('j', $time);
|
||||
if (isset($registeredUsers[$date])) {
|
||||
$datay[] = $registeredUsers[$date]['users'];
|
||||
} else {
|
||||
$datay[] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _populateYearData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$firstDayOfMonth = date('Y-' . date('m') . '-01');
|
||||
$registeredUsers = $stats->getNumRegisteredUsersYear(strtotime('-11 months', strtotime($firstDayOfMonth)), time());
|
||||
|
||||
for ($i = -11; $i <= 0; $i++) {
|
||||
$time = strtotime("$i months");
|
||||
$monthNumber = date('n', $time);
|
||||
$labelsy[] = Stats::$months[$monthNumber];
|
||||
if (isset($registeredUsers[$monthNumber])) {
|
||||
$datay[] = $registeredUsers[$monthNumber]['users'];
|
||||
} else {
|
||||
$datay[] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
168
modules/stats/controllers/SitesController.php
Normal file
168
modules/stats/controllers/SitesController.php
Normal file
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_SitesController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->weekSelected = '';
|
||||
$this->view->yearSelected = '';
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'year':
|
||||
$this->view->yearSelected = 'selected="true"';
|
||||
$this->view->type = 'year';
|
||||
break;
|
||||
default:
|
||||
$this->view->weekSelected = 'selected="true"';
|
||||
$this->view->type = 'week';
|
||||
}
|
||||
|
||||
$this->view->rand = rand(0, 1000);
|
||||
}
|
||||
|
||||
public function graphAction()
|
||||
{
|
||||
require_once 'libs/jpgraph/jpgraph.php';
|
||||
require_once 'libs/jpgraph/jpgraph_bar.php';
|
||||
require_once 'libs/jpgraph/jpgraph_line.php';
|
||||
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
$this->_helper->layout->disableLayout();
|
||||
|
||||
$graph = new Graph(300,200 ,'auto');
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetFrame(false);
|
||||
$graph->SetScale("textlin");
|
||||
$graph->SetY2Scale("lin");
|
||||
$graph->img->SetMargin(0,30,20,50);
|
||||
$graph->yaxis->HideLabels();
|
||||
$graph->yaxis->HideTicks();
|
||||
$graph->yaxis->scale->SetGrace(20);
|
||||
$graph->y2axis->SetColor("black","red");
|
||||
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5');
|
||||
|
||||
$labelsy = array();
|
||||
$datay = array();
|
||||
$datay2 = array();
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'year':
|
||||
$this->_populateYearData($labelsy, $datay, $datay2);
|
||||
break;
|
||||
default:
|
||||
$this->_populateWeekData($labelsy, $datay, $datay2);
|
||||
}
|
||||
|
||||
$graph->xaxis->SetTickLabels($labelsy);
|
||||
|
||||
$bplot = new BarPlot($datay);
|
||||
$bplot->setLegend(utf8_decode($this->view->translate('Trusted sites')));
|
||||
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDVER);
|
||||
$bplot->value->Show();
|
||||
$bplot->value->SetFormat('%d');
|
||||
|
||||
$p1 = new LinePlot($datay2);
|
||||
$p1->SetColor("red");
|
||||
$p1->SetLegend(utf8_decode($this->view->translate('Sites per user')));
|
||||
|
||||
$graph->Add($bplot);
|
||||
$graph->AddY2($p1);
|
||||
|
||||
$graph->legend->SetLayout(LEGEND_HOR);
|
||||
$graph->legend->Pos(0.5,0.99,"center","bottom");
|
||||
|
||||
$graph->Stroke();
|
||||
}
|
||||
|
||||
private function _populateWeekData(&$labelsy, &$datay, &$datay2)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$initialTrustedSites = $stats->getNumTrustedSites(strtotime('-1 week'));
|
||||
$initialRegisteredUsers = $stats->getNumRegisteredUsers(strtotime('-1 week'));
|
||||
|
||||
$sites = $stats->getNumTrustedSitesDays(strtotime('-1 week'), time());
|
||||
$numUsers = $stats->getNumRegisteredUsersDays(strtotime('-1 week'), time());
|
||||
|
||||
for ($i = -7; $i < 0; $i++) {
|
||||
$time = strtotime("$i days");
|
||||
$date = date('Y-m-d', $time);
|
||||
$labelsy[] = Stats::$weekDays[date('w', $time)];
|
||||
|
||||
if (isset($sites[$date])) {
|
||||
$sitesPeriod = $sites[$date]['site'];
|
||||
} else {
|
||||
$sitesPeriod = 0;
|
||||
}
|
||||
|
||||
if (isset($numUsers[$date])) {
|
||||
$usersPeriod = $numUsers[$date]['users'];
|
||||
} else {
|
||||
$usersPeriod = 0;
|
||||
}
|
||||
|
||||
if ($i > -7) {
|
||||
$datay[] = $datay[$i + 6] + $sitesPeriod;
|
||||
$datay2[] = $datay2[$i + 6] + $usersPeriod;
|
||||
} else {
|
||||
$datay[] = $initialTrustedSites + $sitesPeriod;
|
||||
$datay2[] = $initialRegisteredUsers + $usersPeriod;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($datay2); $i++) {
|
||||
$datay2[$i] = round($datay[$i] / $datay2[$i], 2);
|
||||
}
|
||||
}
|
||||
|
||||
private function _populateYearData(&$labelsy, &$datay, &$datay2)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$initialTrustedSites = $stats->getNumTrustedSites(strtotime('-1 week'));
|
||||
$initialRegisteredUsers = $stats->getNumRegisteredUsers(strtotime('-1 week'));
|
||||
|
||||
$firstDayOfMonth = date('Y-' . date('m') . '-01');
|
||||
|
||||
$sites = $stats->getNumTrustedSitesYear(strtotime('-11 months', strtotime($firstDayOfMonth)), time());
|
||||
$numUsers = $stats->getNumRegisteredUsersYear(strtotime('-1 week'), time());
|
||||
|
||||
for ($i = -11; $i <= 0; $i++) {
|
||||
$time = strtotime("$i months");
|
||||
$monthNumber = date('n', $time);
|
||||
$labelsy[] = Stats::$months[$monthNumber];
|
||||
|
||||
if (isset($sites[$monthNumber])) {
|
||||
$sitesPeriod = $sites[$monthNumber]['site'];
|
||||
} else {
|
||||
$sitesPeriod = 0;
|
||||
}
|
||||
|
||||
if (isset($numUsers[$monthNumber])) {
|
||||
$usersPeriod = $numUsers[$monthNumber]['users'];
|
||||
} else {
|
||||
$usersPeriod = 0;
|
||||
}
|
||||
|
||||
if ($i > -11) {
|
||||
$datay[] = $datay[$i + 10] + $sitesPeriod;
|
||||
$datay2[] = $datay2[$i + 10] + $usersPeriod;
|
||||
} else {
|
||||
$datay[] = $initialTrustedSites + $sitesPeriod;
|
||||
$datay2[] = $initialRegisteredUsers + $usersPeriod;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($datay2); $i++) {
|
||||
$datay2[$i] = round($datay[$i] / $datay2[$i], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
modules/stats/controllers/TopController.php
Normal file
19
modules/stats/controllers/TopController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_TopController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$stats = new Stats();
|
||||
$this->view->sites = $stats->getTopTenSites();
|
||||
}
|
||||
}
|
161
modules/stats/models/Stats.php
Normal file
161
modules/stats/models/Stats.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Stats
|
||||
{
|
||||
private $_db;
|
||||
|
||||
static public $weekDays = array('S', 'M', 'T', 'W', 'T', 'F', 'S');
|
||||
static public $months = array(1 => 'J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D');
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_db = Zend_Registry::get('db');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumRegisteredUsersDays($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('users', array('registration_date' => 'registration_date', 'users' => 'COUNT(registration_date)'))
|
||||
->where('registration_date >= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('registration_date < ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('registration_date')
|
||||
->order('registration_date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumRegisteredUsersYear($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('users', array('registration_date' => 'MONTH(registration_date)', 'users' => 'COUNT(MONTH(registration_date))'))
|
||||
->where('registration_date >= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('registration_date <= ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('MONTH(registration_date)')
|
||||
->order('registration_date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNumRegisteredUsers($unixDate)
|
||||
{
|
||||
$select = $this->_db->select()->from('users')
|
||||
->where('registration_date < ?', strftime('%Y-%m-%d', $unixDate));
|
||||
|
||||
|
||||
$statement = $this->_db->prepare($select);
|
||||
$statement->execute();
|
||||
|
||||
return $statement->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getAllTestUsersIds()
|
||||
{
|
||||
$select = $this->_db->select()->from('users', 'id');
|
||||
|
||||
return $this->_db->fetchAll($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumAuthorizationsDays($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('history', array('date' => 'DATE(date)', 'entry' => 'COUNT(DATE(date))'))
|
||||
->where('date>= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('date< ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('DATE(date)')
|
||||
->order('date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumAuthorizationsYear($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('history', array('date' => 'MONTH(date)', 'entry' => 'COUNT(MONTH(date))'))
|
||||
->where('date>= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('date<= ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('MONTH(date)')
|
||||
->order('date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNumTrustedSites($unixDate)
|
||||
{
|
||||
$select = $this->_db->select()->from('sites')
|
||||
->where('creation_date < ?', strftime('%Y-%m-%d', $unixDate));
|
||||
|
||||
|
||||
$statement = $this->_db->prepare($select);
|
||||
$statement->execute();
|
||||
|
||||
return $statement->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumTrustedSitesDays($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('sites', array('creation_date' => 'creation_date', 'site' => 'COUNT(creation_date)'))
|
||||
->where('creation_date>= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('creation_date< ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('creation_date')
|
||||
->order('creation_date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumTrustedSitesYear($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('sites', array('creation_date' => 'MONTH(creation_date)', 'site' => 'COUNT(MONTH(creation_date))'))
|
||||
->where('creation_date>= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('creation_date<= ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('MONTH(creation_date)')
|
||||
->order('creation_date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getTopTenSites()
|
||||
{
|
||||
$select = $this->_db->select()->from('sites', array('num' => 'COUNT(site)', 'site' => 'site'))
|
||||
->group('site')
|
||||
->order('num DESC')
|
||||
->limit(10);
|
||||
|
||||
return $this->_db->fetchAll($select);
|
||||
}
|
||||
}
|
10
modules/stats/views/scripts/authorizations/index.phtml
Normal file
10
modules/stats/views/scripts/authorizations/index.phtml
Normal file
@ -0,0 +1,10 @@
|
||||
<h3><?= $this->translate('Authorizations per day') ?></h3>
|
||||
<div>
|
||||
<?= $this->translate('Select view') ?>:
|
||||
<select name="view" onchange="COMMID.stats.loadReport('authorizations', 'statsAuths', 'type=' + this.value)">
|
||||
<option value="week" <?= $this->weekSelected ?>><?= $this->translate('Last Week') ?></option>
|
||||
<option value="year" <?= $this->yearSelected ?>><?= $this->translate('Last Year') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<img src="<?= $this->base ?>/stats/authorizations/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
||||
|
24
modules/stats/views/scripts/index/index.phtml
Normal file
24
modules/stats/views/scripts/index/index.phtml
Normal file
@ -0,0 +1,24 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["connection"],
|
||||
function() {
|
||||
COMMID.stats.loadReport("registrations", "statsRegs");
|
||||
COMMID.stats.loadReport("authorizations", "statsAuths");
|
||||
COMMID.stats.loadReport("sites", "statsNumTrustedSites");
|
||||
COMMID.stats.loadReport("top", "statsTopTen");
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="yui-g">
|
||||
<div class="yui-u first">
|
||||
<div id="statsRegs"></div>
|
||||
<div id="statsNumTrustedSites"></div>
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<div id="statsAuths"></div>
|
||||
<div id="statsTopTen"></div>
|
||||
</div>
|
||||
</div>
|
10
modules/stats/views/scripts/registrations/index.phtml
Normal file
10
modules/stats/views/scripts/registrations/index.phtml
Normal file
@ -0,0 +1,10 @@
|
||||
<h3><?= $this->translate('Registrations per day') ?></h3>
|
||||
<div>
|
||||
<?= $this->translate('Select view') ?>:
|
||||
<select name="view" onchange="COMMID.stats.loadReport('registrations', 'statsRegs', 'type=' + this.value)">
|
||||
<option value="week" <?= $this->weekSelected ?>><?= $this->translate('Last Week') ?></option>
|
||||
<option value="month" <?= $this->monthSelected ?>><?= $this->translate('Last Month') ?></option>
|
||||
<option value="year" <?= $this->yearSelected ?>><?= $this->translate('Last Year') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<img src="<?= $this->base ?>/stats/registrations/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
9
modules/stats/views/scripts/sites/index.phtml
Normal file
9
modules/stats/views/scripts/sites/index.phtml
Normal file
@ -0,0 +1,9 @@
|
||||
<h3><?= $this->translate('Trusted Sites') ?></h3>
|
||||
<div>
|
||||
<?= $this->translate('Select view') ?>:
|
||||
<select name="view" onchange="COMMID.stats.loadReport('sites', 'statsNumTrustedSites', 'type=' + this.value)">
|
||||
<option value="week" <?= $this->weekSelected ?>><?= $this->translate('Last Week') ?></option>
|
||||
<option value="year" <?= $this->yearSelected ?>><?= $this->translate('Last Year') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<img src="<?= $this->base ?>/stats/sites/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
10
modules/stats/views/scripts/top/index.phtml
Normal file
10
modules/stats/views/scripts/top/index.phtml
Normal file
@ -0,0 +1,10 @@
|
||||
<h3><?= $this->translate('Top 10 Trusted Sites') ?></h3>
|
||||
<table id="topTenTable">
|
||||
<? foreach ($this->sites as $num => $siteInfo): ?>
|
||||
<tr>
|
||||
<td><?= $num + 1 ?></td>
|
||||
<td><?= $siteInfo['site'] ?></td>
|
||||
<td>(<?= $this->translate('%s users', $siteInfo['num']) ?>)</td>
|
||||
</tr>
|
||||
<? endforeach ?>
|
||||
</table>
|
89
modules/users/controllers/LoginController.php
Executable file
89
modules/users/controllers/LoginController.php
Executable file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_LoginController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$settings = new Settings();
|
||||
$this->view->maintenanceEnabled = $settings->isMaintenanceMode();
|
||||
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->loginForm)) {
|
||||
$this->view->loginForm = $appSession->loginForm;
|
||||
unset($appSession->loginForm);
|
||||
} else {
|
||||
$this->view->loginForm = new LoginForm();
|
||||
}
|
||||
|
||||
if ($this->_config->SSL->enable_mixed_mode) {
|
||||
$this->view->loginTargetBase = 'https://' . $_SERVER['HTTP_HOST'] . $this->view->base;
|
||||
} else {
|
||||
$this->view->loginTargetBase = $this->view->base;
|
||||
}
|
||||
|
||||
$this->_helper->viewRenderer->setResponseSegment('sidebar');
|
||||
}
|
||||
|
||||
public function authenticateAction()
|
||||
{
|
||||
$auth = Zend_Auth::getInstance();
|
||||
|
||||
$form = new LoginForm();
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession->loginForm = $form;
|
||||
$this->_redirectToNormalConnection('');
|
||||
}
|
||||
|
||||
$db = Zend_Db::factory($this->_config->database);
|
||||
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password', 'MD5(CONCAT(openid, ?))');
|
||||
$authAdapter->setIdentity($this->_request->getPost('username'));
|
||||
$authAdapter->setCredential($this->_request->getPost('password'));
|
||||
|
||||
$result = $auth->authenticate($authAdapter);
|
||||
|
||||
if ($result->isValid()) {
|
||||
$users = new Users();
|
||||
$user = $users->getUser($result->getIdentity());
|
||||
|
||||
// $user might not exist when the openid validation passed, but there's no
|
||||
// user in the system with that openid identity
|
||||
if (!$user) {
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid credentials');
|
||||
} else {
|
||||
$auth->getStorage()->write($user);
|
||||
|
||||
if ($user->role != User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
|
||||
return $this->_redirectForMaintenance(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid credentials');
|
||||
$appSession->loginForm = $form;
|
||||
}
|
||||
|
||||
$this->_redirectToNormalConnection('');
|
||||
}
|
||||
|
||||
public function logoutAction()
|
||||
{
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
|
||||
$this->_redirect('');
|
||||
}
|
||||
}
|
33
modules/users/controllers/ManageusersController.php
Normal file
33
modules/users/controllers/ManageusersController.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_ManageusersController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$this->targetUser->delete();
|
||||
echo $this->view->translate('User has been deleted successfully');
|
||||
}
|
||||
|
||||
public function deleteunconfirmedAction()
|
||||
{
|
||||
$users = new Users();
|
||||
$users->deleteUnconfirmed();
|
||||
}
|
||||
}
|
72
modules/users/controllers/PersonalinfoController.php
Normal file
72
modules/users/controllers/PersonalinfoController.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_PersonalinfoController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function showAction()
|
||||
{
|
||||
$fields = new Fields();
|
||||
$this->view->fields = $fields->getValues($this->user);
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->personalInfoForm)) {
|
||||
$this->view->fields = $appSession->personalInfoForm->getElements();
|
||||
unset($appSession->personalInfoForm);
|
||||
} else {
|
||||
$personalInfoForm = new PersonalInfoForm(null, $this->user);
|
||||
$this->view->fields = $personalInfoForm->getElements();
|
||||
}
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$form = new PersonalInfoForm(null, $this->user);
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->personalInfoForm = $form;
|
||||
$this->_forward('edit');
|
||||
return;
|
||||
}
|
||||
|
||||
$fieldsValues = new FieldsValues();
|
||||
$fieldsValues->deleteForUser($this->user);
|
||||
|
||||
foreach ($form->getValues() as $fieldName => $fieldValue) {
|
||||
if (!$fieldValue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fieldsValue = $fieldsValues->createRow();
|
||||
$fieldsValue->user_id = $this->user->id;
|
||||
|
||||
list(, $fieldId) = explode('_', $fieldName);
|
||||
$fieldsValue->field_id = $fieldId;
|
||||
|
||||
$fieldsValue->value = $fieldValue;
|
||||
|
||||
$fieldsValue->save();
|
||||
}
|
||||
|
||||
|
||||
$this->_forward('show');
|
||||
}
|
||||
}
|
22
modules/users/controllers/ProfileController.php
Executable file
22
modules/users/controllers/ProfileController.php
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_ProfileController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (!$this->targetUser->id && $this->user->role != User::ROLE_ADMIN) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
}
|
307
modules/users/controllers/ProfilegeneralController.php
Normal file
307
modules/users/controllers/ProfilegeneralController.php
Normal file
@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_ProfilegeneralController extends Monkeys_Controller_Action
|
||||
{
|
||||
private $_users;
|
||||
|
||||
public function preDispatch()
|
||||
{
|
||||
if ($this->user->role != User::ROLE_ADMIN
|
||||
&& $this->targetUser->id != $this->user->id)
|
||||
{
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
}
|
||||
|
||||
public function accountinfoAction()
|
||||
{
|
||||
}
|
||||
|
||||
public function editaccountinfoAction()
|
||||
{
|
||||
if ($this->targetUser->id != $this->user->id
|
||||
// this condition checks for an non-admin trying to add a new user
|
||||
&& ($this->targetUser->id != 0 || $this->user->role != User::ROLE_ADMIN))
|
||||
{
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->accountInfoForm)) {
|
||||
$this->view->accountInfoForm = $appSession->accountInfoForm;
|
||||
unset($appSession->accountInfoForm);
|
||||
} else {
|
||||
$this->view->accountInfoForm = new AccountInfoForm(null, $this->targetUser);
|
||||
$this->view->accountInfoForm->populate(array(
|
||||
'username' => $this->targetUser->username,
|
||||
'firstname' => $this->targetUser->firstname,
|
||||
'lastname' => $this->targetUser->lastname,
|
||||
'email' => $this->targetUser->email,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function saveaccountinfoAction()
|
||||
{
|
||||
$isNewUser = is_null($this->targetUser->id)? true : false;
|
||||
|
||||
if (!$isNewUser && $this->targetUser->id != $this->user->id) {
|
||||
// admins can add new users, but not edit existing ones
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$form = new AccountInfoForm(null, $this->targetUser);
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
return $this->_redirectInvalidForm($form);
|
||||
}
|
||||
|
||||
$existingUsernameOrEmail = false;
|
||||
$newUsername = $form->getValue('username');
|
||||
if (($isNewUser && $this->_usernameAlreadyExists($newUsername))
|
||||
|| (!$isNewUser && ($this->targetUser->username != $newUsername)
|
||||
&& $this->_usernameAlreadyExists($newUsername)))
|
||||
{
|
||||
$form->username->addError($this->view->translate('This username is already in use'));
|
||||
$existingUsernameOrEmail = true;
|
||||
}
|
||||
|
||||
$newEmail = $form->getValue('email');
|
||||
if (($isNewUser && $this->_emailAlreadyExists($newEmail))
|
||||
|| (!$isNewUser && ($this->targetUser->email != $newEmail)
|
||||
&& $this->_emailAlreadyExists($newEmail)))
|
||||
{
|
||||
$form->email->addError($this->view->translate('This E-mail is already in use'));
|
||||
$existingUsernameOrEmail = true;
|
||||
}
|
||||
|
||||
if ($existingUsernameOrEmail) {
|
||||
return $this->_redirectInvalidForm($form);
|
||||
}
|
||||
|
||||
$this->targetUser->username = $newUsername;
|
||||
$this->targetUser->firstname = $form->getValue('firstname');
|
||||
$this->targetUser->lastname = $form->getValue('lastname');
|
||||
$this->targetUser->email = $newEmail;
|
||||
if ($isNewUser) {
|
||||
$this->targetUser->accepted_eula = 1;
|
||||
$this->targetUser->registration_date = date('Y-m-d');
|
||||
$this->targetUser->openid = $this->_generateOpenId($this->targetUser->username);
|
||||
$this->targetUser->role = User::ROLE_REGISTERED;
|
||||
$this->targetUser->setClearPassword($form->getValue('password1'));
|
||||
}
|
||||
$this->targetUser->save();
|
||||
|
||||
/**
|
||||
* When the form is submitted through a YUI request using a file, an iframe is used,
|
||||
* so the framework doesn't detected it as ajax, so we have to manually ensure the
|
||||
* layout is not shown.
|
||||
*/
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_forward('accountinfo', null , null, array('userid' => $this->targetUser->id));
|
||||
}
|
||||
|
||||
private function _usernameAlreadyExists($username)
|
||||
{
|
||||
$users = $this->_getUsers();
|
||||
return $users->getUser($username);
|
||||
}
|
||||
|
||||
private function _emailAlreadyExists($email)
|
||||
{
|
||||
$users = $this->_getUsers();
|
||||
return $users->getUserWithEmail($email);
|
||||
}
|
||||
|
||||
private function _redirectInvalidForm(Zend_Form $form)
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->accountInfoForm = $form;
|
||||
|
||||
/**
|
||||
* When the form is submitted through a YUI request using a file, an iframe is used,
|
||||
* so the framework doesn't detected it as ajax, so we have to manually ensure the
|
||||
* layout is not shown.
|
||||
*/
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_forward('editaccountinfo', null , null, array('userid' => $this->targetUser->id));
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only the users themselves can change their passwords
|
||||
*/
|
||||
public function changepasswordAction()
|
||||
{
|
||||
if ($this->targetUser->id != $this->user->id)
|
||||
{
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->changePasswordForm)) {
|
||||
$this->view->changePasswordForm = $appSession->changePasswordForm;
|
||||
unset($appSession->changePasswordForm);
|
||||
} else {
|
||||
$this->view->changePasswordForm = new ChangePasswordForm();
|
||||
}
|
||||
}
|
||||
|
||||
public function savepasswordAction()
|
||||
{
|
||||
if ($this->targetUser->id != $this->user->id)
|
||||
{
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$form = new ChangePasswordForm();
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->changePasswordForm = $form;
|
||||
return $this->_forward('changepassword', null , null, array('userid' => $this->targetUser->id));
|
||||
}
|
||||
|
||||
$this->targetUser->setClearPassword($form->getValue('password1'));
|
||||
$this->targetUser->save();
|
||||
|
||||
return $this->_forward('accountinfo', null , null, array('userid' => $this->targetUser->id));
|
||||
}
|
||||
|
||||
public function confirmdeleteAction()
|
||||
{
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$mail = self::getMail();
|
||||
$mail->setFrom('support@community-id.org');
|
||||
$mail->addTo($this->_config->email->supportemail);
|
||||
$mail->setSubject('Community-ID user deletion');
|
||||
|
||||
$userFullname = $this->user->getFullName();
|
||||
|
||||
$reasonsChecked = array();
|
||||
if ($this->_getParam('reason_test')) {
|
||||
$reasonsChecked[] = 'This was just a test account';
|
||||
}
|
||||
if ($this->_getParam('reason_foundbetter')) {
|
||||
$reasonsChecked[] = 'I found a better service';
|
||||
}
|
||||
if ($this->_getParam('reason_lackedfeatures')) {
|
||||
$reasonsChecked[] = 'Service lacked some key features I needed';
|
||||
}
|
||||
if ($this->_getParam('reason_none')) {
|
||||
$reasonsChecked[] = 'No particular reason';
|
||||
}
|
||||
|
||||
if ($reasonsChecked) {
|
||||
$reasonsChecked = implode("\r\n", $reasonsChecked);
|
||||
} else {
|
||||
$reasonsChecked = 'None (no checkbox was ticked).';
|
||||
}
|
||||
|
||||
$comment = $this->_getParam('reason_comments');
|
||||
|
||||
$body = <<<EOT
|
||||
Dear Admin:
|
||||
|
||||
The user $userFullname has deleted his account, giving the following feedback:
|
||||
|
||||
Reasons checked:
|
||||
$reasonsChecked
|
||||
|
||||
Comment:
|
||||
$comment
|
||||
EOT;
|
||||
$mail->setBodyText($body);
|
||||
try {
|
||||
$mail->send();
|
||||
} catch (Zend_Mail_Protocol_Exception $e) {
|
||||
if ($this->_config->logging->level == Zend_Log::DEBUG) {
|
||||
$this->_helper->FlashMessenger->addMessage('Account was deleted, but feedback form couldn\'t be sent to admins');
|
||||
}
|
||||
}
|
||||
|
||||
$users = $this->_getUsers();
|
||||
$users->deleteUser($this->user);
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Your acccount has been successfully deleted'));
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
private function _generateOpenId($username)
|
||||
{
|
||||
$selfUrl = Zend_OpenId::selfUrl();
|
||||
if (!preg_match('#(.*)/users/profile.*#', $selfUrl, $matches)) {
|
||||
throw new Exception('Couldn\'t retrieve current URL');
|
||||
}
|
||||
|
||||
if ($this->_config->subdomain->enabled) {
|
||||
$openid = $this->_getProtocol() . '://' . $username . '.' . $this->_config->subdomain->hostname;
|
||||
} else {
|
||||
$openid = $matches[1] . "/identity/$username";
|
||||
}
|
||||
|
||||
if ($this->_config->SSL->enable_mixed_mode) {
|
||||
$openid = str_replace('http://', 'https://', $openid);
|
||||
}
|
||||
|
||||
Zend_OpenId::normalizeUrl($openid);
|
||||
|
||||
return $openid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Zend_Mail
|
||||
* @throws Zend_Mail_Protocol_Exception
|
||||
*/
|
||||
public static function getMail()
|
||||
{
|
||||
// can't use $this->_config 'cause it's a static function
|
||||
$configEmail = Zend_Registry::get('config')->email;
|
||||
|
||||
switch (strtolower($configEmail->transport)) {
|
||||
case 'smtp':
|
||||
Zend_Mail::setDefaultTransport(
|
||||
new Zend_Mail_Transport_Smtp(
|
||||
$configEmail->host,
|
||||
$configEmail->toArray()
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'mock':
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
|
||||
break;
|
||||
default:
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
|
||||
}
|
||||
|
||||
$mail = new Zend_Mail();
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
private function _getUsers()
|
||||
{
|
||||
if (!isset($this->_users)) {
|
||||
$this->_users = new Users();
|
||||
}
|
||||
|
||||
return $this->_users;
|
||||
}
|
||||
}
|
141
modules/users/controllers/RecoverpasswordController.php
Executable file
141
modules/users/controllers/RecoverpasswordController.php
Executable file
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_RecoverpasswordController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->user->role != User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
return $this->_redirectForMaintenance();
|
||||
}
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->recoverPasswordForm)) {
|
||||
$this->view->form = $appSession->recoverPasswordForm;
|
||||
unset($appSession->recoverPasswordForm);
|
||||
} else {
|
||||
$this->view->form = new RecoverPasswordForm();
|
||||
}
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function sendAction()
|
||||
{
|
||||
$form = new RecoverPasswordForm();
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->recoverPasswordForm = $form;
|
||||
return $this->_forward('index');
|
||||
}
|
||||
|
||||
$users = new Users();
|
||||
$user = $users->getUserWithEmail($form->getValue('email'));
|
||||
if (!$user) {
|
||||
$form->email->addError($this->view->translate('This E-mail is not registered in the system'));
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->recoverPasswordForm = $form;
|
||||
return $this->_forward('index');
|
||||
}
|
||||
|
||||
$user->token = User::generateToken();
|
||||
$user->save();
|
||||
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
if (file_exists(APP_DIR . "/resources/$locale/passwordreset_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/$locale/passwordreset_mail.txt";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/passwordreset_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/".$localeElements[0]."/passwordreset_mail.txt";
|
||||
} else {
|
||||
$file = APP_DIR . "/resources/en/passwordreset_mail.txt";
|
||||
}
|
||||
|
||||
$emailTemplate = file_get_contents($file);
|
||||
$emailTemplate = str_replace('{userName}', $user->getFullName(), $emailTemplate);
|
||||
$emailTemplate = str_replace('{IP}', $_SERVER['REMOTE_ADDR'], $emailTemplate);
|
||||
|
||||
// $_SERVER['SCRIPT_URI'] is not always available
|
||||
$URI = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
preg_match('#(.*)/users/recoverpassword#', $URI, $matches);
|
||||
$emailTemplate = str_replace('{passwordResetURL}',
|
||||
$matches[1] . '/users/recoverpassword/reset?token=' . $user->token,
|
||||
$emailTemplate);
|
||||
|
||||
$this->_sendMail($user->email, $this->view->translate('Community-ID password reset'), $emailTemplate);
|
||||
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Password reset E-mail has been sent'));
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
public function resetAction()
|
||||
{
|
||||
$users = new Users();
|
||||
$user = $users->getUserWithToken($this->_getParam('token'));
|
||||
if (!$user) {
|
||||
$this->_helper->FlashMessenger->addMessage('Wrong Token');
|
||||
$this->_redirect('');
|
||||
return;
|
||||
}
|
||||
|
||||
$newPassword = $user->generateRandomPassword();
|
||||
$user->setClearPassword($newPassword);
|
||||
|
||||
// reset token
|
||||
$user->token = User::generateToken();
|
||||
|
||||
$user->save();
|
||||
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
if (file_exists(APP_DIR . "/resources/$locale/passwordreset2_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/$locale/passwordreset2_mail.txt";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/passwordreset2_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/".$localeElements[0]."/passwordreset2_mail.txt";
|
||||
} else {
|
||||
$file = APP_DIR . "/resources/en/passwordreset2_mail.txt";
|
||||
}
|
||||
|
||||
$emailTemplate = file_get_contents($file);
|
||||
$emailTemplate = str_replace('{userName}', $user->getFullName(), $emailTemplate);
|
||||
$emailTemplate = str_replace('{password}', $newPassword, $emailTemplate);
|
||||
|
||||
$this->_sendMail($user->email, $this->view->translate('Community-ID password reset'), $emailTemplate);
|
||||
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('You\'ll receive your new password via E-mail'));
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
private function _sendMail($to, $subject, $body)
|
||||
{
|
||||
if (strtolower($this->_config->email->transport) == 'smtp') {
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($this->_config->email->host, $this->_config->email->toArray()));
|
||||
} else {
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
|
||||
}
|
||||
$mail = new Zend_Mail('utf-8');
|
||||
$mail->setBodyText($body);
|
||||
$mail->setFrom($this->_config->email->supportemail);
|
||||
$mail->addTo($to);
|
||||
$mail->setSubject($subject);
|
||||
$mail->send();
|
||||
}
|
||||
}
|
227
modules/users/controllers/RegisterController.php
Executable file
227
modules/users/controllers/RegisterController.php
Executable file
@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_RegisterController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->user->role != User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
return $this->_redirectForMaintenance();
|
||||
}
|
||||
|
||||
if (!$this->_config->environment->registrations_enabled) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate(
|
||||
'Sorry, registrations are currently disabled'
|
||||
));
|
||||
return $this->_redirect('');
|
||||
}
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->registerForm)) {
|
||||
$form = $appSession->registerForm;
|
||||
unset($appSession->registerForm);
|
||||
} else {
|
||||
$form = new RegisterForm(null, $this->view->base);
|
||||
}
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$form = new RegisterForm(null, $this->view->base);
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->registerForm = $form;
|
||||
return $this->_forward('index', null, null);
|
||||
}
|
||||
|
||||
$users = new Users();
|
||||
|
||||
if ($users->getUser($form->getValue('username'))) {
|
||||
$form->username->addError($this->view->translate('This username is already in use'));
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->registerForm = $form;
|
||||
return $this->_forward('index', null, null);
|
||||
}
|
||||
|
||||
if ($users->getUserWithEmail($form->getValue('email'))) {
|
||||
$form->email->addError($this->view->translate('This E-mail is already in use'));
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->registerForm = $form;
|
||||
return $this->_forward('index', null, null);
|
||||
}
|
||||
|
||||
$user = $users->createRow();
|
||||
|
||||
$user->firstname = $form->getValue('firstname');
|
||||
$user->lastname = $form->getValue('lastname');
|
||||
$user->email = $form->getValue('email');
|
||||
$user->username = $form->getValue('username');
|
||||
|
||||
$currentUrl = Zend_OpenId::selfURL();
|
||||
preg_match('#(.*)/users/register/save#', $currentUrl, $matches);
|
||||
if ($this->_config->subdomain->enabled) {
|
||||
$openid = $this->_getProtocol() . '://' . $user->username . '.' . $this->_config->subdomain->hostname;
|
||||
} else {
|
||||
$openid = $matches[1] . '/identity/' . $user->username;
|
||||
}
|
||||
|
||||
if ($this->_config->SSL->enable_mixed_mode) {
|
||||
$openid = str_replace('http://', 'https://', $openid);
|
||||
}
|
||||
Zend_OpenId::normalizeUrl($openid);
|
||||
$user->openid = $openid;
|
||||
|
||||
$user->setClearPassword($form->getValue('password1'));
|
||||
$user->role = User::ROLE_GUEST;
|
||||
$registrationToken = User::generateToken();
|
||||
$user->token = $registrationToken;
|
||||
$user->accepted_eula = 0;
|
||||
$user->registration_date = date('Y-m-d');
|
||||
$user->save();
|
||||
|
||||
$mail = $this->getMail($user);
|
||||
try {
|
||||
$mail->send();
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Thank you.'));
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('You will receive an E-mail with instructions to activate the account.'));
|
||||
} catch (Zend_Mail_Protocol_Exception $e) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('The account was created but the E-mail could not be sent'));
|
||||
if ($this->_config->logging->level == Zend_Log::DEBUG) {
|
||||
$this->_helper->FlashMessenger->addMessage($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
public function eulaAction()
|
||||
{
|
||||
$users = new Users();
|
||||
if ($this->_request->getParam('token') == ''
|
||||
|| !($user = $users->getUserWithToken($this->_request->getParam('token')))) {
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid token');
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
$this->view->token = $user->token;
|
||||
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
|
||||
if (file_exists(APP_DIR . "/resources/$locale/eula.txt")) {
|
||||
$file = APP_DIR . "/resources/$locale/eula.txt";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/eula.txt")) {
|
||||
$file = APP_DIR . "/resources/".$localeElements[0]."/eula.txt";
|
||||
} else {
|
||||
$file = APP_DIR . "/resources/en/eula.txt";
|
||||
}
|
||||
|
||||
$this->view->eula = file_get_contents($file);
|
||||
}
|
||||
|
||||
public function declineeulaAction()
|
||||
{
|
||||
$users = new Users();
|
||||
if (!($user = $users->getUserWithToken($this->_request->getParam('token'))) || $this->_request->getParam('token') == '') {
|
||||
Zend_Registry::get('logger')->log('invalid token', Zend_Log::DEBUG);
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid token');
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
$user->delete();
|
||||
$this->_helper->FlashMessenger->addMessage('Your account has been deleted');
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
public function accepteulaAction()
|
||||
{
|
||||
$users = new Users();
|
||||
if (!($user = $users->getUserWithToken($this->_request->getParam('token'))) || $this->_request->getParam('token') == '') {
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid token');
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
$user->role = User::ROLE_REGISTERED;
|
||||
$user->accepted_eula = 1;
|
||||
$user->registration_date = date('Y-m-d');
|
||||
$user->token = '';
|
||||
$user->save();
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$auth->getStorage()->write($user);
|
||||
|
||||
$this->_redirect('/users/profile');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Zend_Mail
|
||||
* @throws Zend_Mail_Protocol_Exception
|
||||
*/
|
||||
public function getMail(User $user)
|
||||
{
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
if (file_exists(APP_DIR . "/resources/$locale/registration_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/$locale/registration_mail.txt";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/registration_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/".$localeElements[0]."/registration_mail.txt";
|
||||
} else {
|
||||
$file = APP_DIR . "/resources/en/registration_mail.txt";
|
||||
}
|
||||
|
||||
$emailTemplate = file_get_contents($file);
|
||||
$emailTemplate = str_replace('{userName}', $user->getFullName(), $emailTemplate);
|
||||
|
||||
$currentUrl = Zend_OpenId::selfURL();
|
||||
preg_match('#(.*)/register/save#', $currentUrl, $matches);
|
||||
$emailTemplate = str_replace('{registrationURL}', $matches[1] . '/register/eula?token=' . $user->token, $emailTemplate);
|
||||
|
||||
// can't use $this-_config 'cause it's a static function
|
||||
$configEmail = Zend_Registry::get('config')->email;
|
||||
|
||||
switch (strtolower($configEmail->transport)) {
|
||||
case 'smtp':
|
||||
Zend_Mail::setDefaultTransport(
|
||||
new Zend_Mail_Transport_Smtp(
|
||||
$configEmail->host,
|
||||
$configEmail->toArray()
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'mock':
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
|
||||
break;
|
||||
default:
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
|
||||
}
|
||||
|
||||
$mail = new Zend_Mail();
|
||||
$mail->setBodyText($emailTemplate);
|
||||
$mail->setFrom('support@community-id.org');
|
||||
$mail->addTo($user->email);
|
||||
$mail->setSubject($this->view->translate('Community-ID registration confirmation'));
|
||||
|
||||
return $mail;
|
||||
}
|
||||
}
|
67
modules/users/controllers/UserslistController.php
Executable file
67
modules/users/controllers/UserslistController.php
Executable file
@ -0,0 +1,67 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_UserslistController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$users = new Users();
|
||||
|
||||
switch($this->_getParam('filter')) {
|
||||
case 'confirmed':
|
||||
$where = "accepted_eula=1 AND role != '".User::ROLE_ADMIN."'";
|
||||
break;
|
||||
case 'unconfirmed':
|
||||
$where = "accepted_eula=0 AND role != '".User::ROLE_ADMIN."'";
|
||||
break;
|
||||
default:
|
||||
$where = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$usersRows = $users->getUsers(
|
||||
$this->_getParam('startIndex'),
|
||||
$this->_getParam('results'),
|
||||
$this->_getParam('sort', 'registration'),
|
||||
$this->_getParam('dir', Users::DIR_DESC),
|
||||
$where);
|
||||
|
||||
$jsonObj = new StdClass();
|
||||
$jsonObj->recordsReturned = count($usersRows);
|
||||
$jsonObj->totalRecords = $users->getNumUsers($where);
|
||||
$jsonObj->totalUnconfirmedUsers = $users->getNumUnconfirmedUsers();
|
||||
$jsonObj->startIndex = $_GET['startIndex'];
|
||||
$jsonObj->sort = $this->_getParam('sort');
|
||||
$jsonObj->dir = $this->_getParam('dir');
|
||||
$jsonObj->records = array();
|
||||
|
||||
foreach ($usersRows as $user) {
|
||||
if ($user->role == User::ROLE_ADMIN) {
|
||||
$status = $this->view->translate('admin');
|
||||
} else if ($user->accepted_eula) {
|
||||
$status = $this->view->translate('confirmed');
|
||||
} else {
|
||||
$status = $this->view->translate('unconfirmed');
|
||||
}
|
||||
$jsonObjUser = new StdClass();
|
||||
$jsonObjUser->id = $user->id;
|
||||
$jsonObjUser->name = $user->getFullName();
|
||||
$jsonObjUser->registration = $user->registration_date;
|
||||
$jsonObjUser->role = $user->role;
|
||||
$jsonObjUser->status = $status;
|
||||
$jsonObj->records[] = $jsonObjUser;
|
||||
}
|
||||
|
||||
echo Zend_Json::encode($jsonObj);
|
||||
}
|
||||
}
|
63
modules/users/forms/AccountInfoForm.php
Normal file
63
modules/users/forms/AccountInfoForm.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class AccountInfoForm extends Zend_Form
|
||||
{
|
||||
private $_targetUser;
|
||||
|
||||
public function __construct($options = null, $user = null)
|
||||
{
|
||||
$this->_targetUser = $user;
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$username = new Monkeys_Form_Element_Text('username');
|
||||
translate('Username');
|
||||
$username->setLabel('Username');
|
||||
|
||||
$firstname = new Monkeys_Form_Element_Text('firstname');
|
||||
translate('First Name');
|
||||
$firstname->setLabel('First Name')
|
||||
->setRequired(true);
|
||||
|
||||
$lastname = new Monkeys_Form_Element_Text('lastname');
|
||||
translate('Last Name');
|
||||
$lastname->setLabel('Last Name')
|
||||
->setRequired(true);
|
||||
|
||||
$email = new Monkeys_Form_Element_Text('email');
|
||||
translate('E-mail');
|
||||
$email->setLabel('E-mail')
|
||||
->addFilter('StringToLower')
|
||||
->setRequired(true)
|
||||
->addValidator('EmailAddress');
|
||||
|
||||
$this->addElements(array($username, $firstname, $lastname, $email));
|
||||
|
||||
if (!$this->_targetUser->id) {
|
||||
$password1 = new Monkeys_Form_Element_Password('password1');
|
||||
translate('Enter password');
|
||||
$password1->setLabel('Enter password')
|
||||
->setRequired(true)
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation());
|
||||
|
||||
$password2 = new Monkeys_Form_Element_Password('password2');
|
||||
translate('Enter password again');
|
||||
$password2->setLabel('Enter password again')
|
||||
->setRequired(true);
|
||||
|
||||
$this->addElements(array($password1, $password2));
|
||||
}
|
||||
}
|
||||
}
|
30
modules/users/forms/ChangePasswordForm.php
Normal file
30
modules/users/forms/ChangePasswordForm.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class ChangePasswordForm extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$password1 = new Monkeys_Form_Element_Password('password1');
|
||||
translate('Enter password');
|
||||
$password1->setLabel('Enter password')
|
||||
->setRequired(true)
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation());
|
||||
|
||||
$password2 = new Monkeys_Form_Element_Password('password2');
|
||||
translate('Enter password again');
|
||||
$password2->setLabel('Enter password again')
|
||||
->setRequired(true);
|
||||
|
||||
$this->addElements(array($password1, $password2));
|
||||
}
|
||||
}
|
22
modules/users/forms/LoginForm.php
Executable file
22
modules/users/forms/LoginForm.php
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class LoginForm extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$username = new Zend_Form_Element_Text('username');
|
||||
translate('USERNAME');
|
||||
$username->setLabel('USERNAME')
|
||||
->setRequired(true);
|
||||
|
||||
$password = new Zend_Form_Element_Password('password');
|
||||
translate('PASSWORD');
|
||||
$password->setLabel('PASSWORD')
|
||||
->setRequired(true);
|
||||
|
||||
$rememberme = new Zend_Form_Element_Checkbox('rememberme');
|
||||
$rememberme->setLabel('Remember me');
|
||||
|
||||
$this->addElements(array($username, $password, $rememberme));
|
||||
}
|
||||
}
|
65
modules/users/forms/PersonalInfoForm.php
Normal file
65
modules/users/forms/PersonalInfoForm.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class PersonalInfoForm extends Zend_Form
|
||||
{
|
||||
private $_sregProps;
|
||||
private $_formElements = array();
|
||||
|
||||
public function __construct($options = null, $user = null, $sregProps = null)
|
||||
{
|
||||
$this->_sregProps = $sregProps;
|
||||
|
||||
$fields = new Fields();
|
||||
$fieldsArr = $fields->getValues($user);
|
||||
for ($i = 0; $i < count($fieldsArr); $i++) {
|
||||
$this->_formElements[$fieldsArr[$i]->openid] = array(
|
||||
'field' => $fieldsArr[$i],
|
||||
'element' => $fieldsArr[$i]->getFormElement(),
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
if ($this->_sregProps) {
|
||||
foreach ($this->_sregProps as $fieldName => $mandatory) {
|
||||
if (isset($this->_formElements[$fieldName])) {
|
||||
$element = $this->_formElements[$fieldName]['element'];
|
||||
if ($mandatory) {
|
||||
// override label
|
||||
$element->setLabel($this->_formElements[$fieldName]['field']->name);
|
||||
$element->setRequired(true);
|
||||
}
|
||||
} else {
|
||||
$element = new Monkeys_Form_Element_Text("openid.sreg.$fieldName");
|
||||
$element->setLabel($fieldName);
|
||||
if ($mandatory) {
|
||||
$element->setRequired(true);
|
||||
}
|
||||
}
|
||||
|
||||
// user openid standard notation for the field names, instead of
|
||||
// our field IDs.
|
||||
$element->setName('openid_sreg_' . $fieldName);
|
||||
|
||||
$this->addElement($element);
|
||||
}
|
||||
} else {
|
||||
foreach ($this->_formElements as $formElement) {
|
||||
$this->addElement($formElement['element']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
modules/users/forms/RecoverPasswordForm.php
Normal file
25
modules/users/forms/RecoverPasswordForm.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class RecoverPasswordForm extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$email = new Zend_Form_Element_Text('email');
|
||||
$email->setLabel('')
|
||||
->addFilter('StringToLower')
|
||||
->setRequired(true)
|
||||
->addValidator('EmailAddress');
|
||||
|
||||
$this->addElement($email);
|
||||
}
|
||||
}
|
76
modules/users/forms/RegisterForm.php
Executable file
76
modules/users/forms/RegisterForm.php
Executable file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class RegisterForm extends Zend_Form
|
||||
{
|
||||
private $_baseWebDir;
|
||||
|
||||
public function __construct($options = null, $baseWebDir = null)
|
||||
{
|
||||
$this->_baseWebDir = $baseWebDir;
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$firstName = new Monkeys_Form_Element_Text('firstname');
|
||||
translate('First Name');
|
||||
$firstName->setLabel('First Name')
|
||||
->setRequired(true);
|
||||
|
||||
$lastName = new Monkeys_Form_Element_Text('lastname');
|
||||
translate('Last Name');
|
||||
$lastName->setLabel('Last Name')
|
||||
->setRequired(true);
|
||||
|
||||
$email = new Monkeys_Form_Element_Text('email');
|
||||
translate('E-mail');
|
||||
$email->setLabel('E-mail')
|
||||
->addFilter('StringToLower')
|
||||
->setRequired(true)
|
||||
->addValidator('EmailAddress');
|
||||
|
||||
$username = new Monkeys_Form_Element_Text('username');
|
||||
translate('Username');
|
||||
$username->setLabel('Username')
|
||||
->setRequired(true);
|
||||
|
||||
$password1 = new Monkeys_Form_Element_Password('password1');
|
||||
translate('Enter desired password');
|
||||
$password1->setLabel('Enter desired password')
|
||||
->setRequired(true)
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation());
|
||||
|
||||
$password2 = new Monkeys_Form_Element_Password('password2');
|
||||
translate('Enter password again');
|
||||
$password2->setLabel('Enter password again')
|
||||
->setRequired(true);
|
||||
|
||||
// ZF has some bugs when using mutators here, so I have to use the config array
|
||||
translate('Please enter the text below');
|
||||
$captcha = new Monkeys_Form_Element_Captcha('captcha', array(
|
||||
'label' => 'Please enter the text below',
|
||||
'captcha' => array(
|
||||
'captcha' => 'Image',
|
||||
'sessionClass' => get_class(Zend_Registry::get('appSession')),
|
||||
'font' => APP_DIR . '/libs/Monkeys/fonts/Verdana.ttf',
|
||||
'imgDir' => WEB_DIR. '/captchas',
|
||||
'imgUrl' => $this->_baseWebDir . '/captchas',
|
||||
'wordLen' => 4,
|
||||
'fontSize' => 30,
|
||||
'timeout' => 300,
|
||||
)
|
||||
));
|
||||
|
||||
$this->addElements(array($firstName, $lastName, $email, $username, $password1, $password2, $captcha));
|
||||
}
|
||||
}
|
53
modules/users/models/OpenIdUser.php
Normal file
53
modules/users/models/OpenIdUser.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class OpenIdUser extends Zend_OpenId_Provider_User
|
||||
{
|
||||
private $_auth;
|
||||
private $_user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_auth = Zend_Auth::getInstance();
|
||||
}
|
||||
|
||||
public function setLoggedInUser($id)
|
||||
{
|
||||
|
||||
$users = new Users();
|
||||
$this->_user = $users->getuserWithOpenId($id);
|
||||
$this->_auth->getStorage()->write($this->_user);
|
||||
}
|
||||
|
||||
public function getLoggedInUser()
|
||||
{
|
||||
$users = new Users();
|
||||
if ($this->_auth->hasIdentity()) {
|
||||
$user = $this->_auth->getStorage()->read();
|
||||
$user->init();
|
||||
|
||||
// reactivate row as live data
|
||||
$user->setTable($users);
|
||||
|
||||
return $user->openid;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delLoggedInUser()
|
||||
{
|
||||
$this->_auth->clearIdentity();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
59
modules/users/models/User.php
Executable file
59
modules/users/models/User.php
Executable file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class User extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
const ROLE_GUEST = 'guest';
|
||||
const ROLE_REGISTERED = 'registered';
|
||||
const ROLE_ADMIN = 'admin';
|
||||
|
||||
/**
|
||||
* To identify the app that owns the user obj in the session.
|
||||
* Useful when sharing the user between apps.
|
||||
*/
|
||||
|
||||
public function getFullName()
|
||||
{
|
||||
return $this->firstname . ' ' . $this->lastname;
|
||||
}
|
||||
|
||||
public function generateRandomPassword()
|
||||
{
|
||||
return substr(md5($this->getFullName() . time()), 0, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Password is stored using md5($this->openid.$password) because
|
||||
* that's what's used in Zend_OpenId
|
||||
*/
|
||||
public function setClearPassword($password)
|
||||
{
|
||||
$this->password = md5($this->openid.$password);
|
||||
$this->password_changed = date('Y-m-d');
|
||||
}
|
||||
|
||||
public function isAllowed($resource, $privilege)
|
||||
{
|
||||
$acl = Zend_Registry::get('acl');
|
||||
return $acl->isAllowed($this->role, $resource, $privilege);
|
||||
}
|
||||
|
||||
public static function generateToken()
|
||||
{
|
||||
$token = '';
|
||||
for ($i = 0; $i < 50; $i++) {
|
||||
$token .= chr(rand(48, 122));
|
||||
}
|
||||
|
||||
return md5($token.time());
|
||||
}
|
||||
}
|
347
modules/users/models/Users.php
Executable file
347
modules/users/models/Users.php
Executable file
@ -0,0 +1,347 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Users extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'users';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'User';
|
||||
|
||||
const DIR_ASC = 0;
|
||||
const DIR_DESC = 1;
|
||||
|
||||
private $_sortFields = array(
|
||||
'name' => array('firstname', 'lastname'),
|
||||
'registration' => array('registration_date', 'firstname', 'lastname'),
|
||||
'status' => array('accepted_eula', 'registration_date', 'firstname', 'lastname'),
|
||||
);
|
||||
|
||||
public function createRow()
|
||||
{
|
||||
return parent::createRow(array(
|
||||
'openid' => '',
|
||||
'password_changed' => '0000-00-00',
|
||||
'role' => User::ROLE_GUEST,
|
||||
'passwordreset_token' => '',
|
||||
));
|
||||
}
|
||||
|
||||
public function getUsers($startIndex = false, $results = false, $sort = false, $dir = false, $where = false)
|
||||
{
|
||||
$select = $this->select();
|
||||
|
||||
if ($startIndex !== false && $results !== false) {
|
||||
$select = $select->limit($results, $startIndex);
|
||||
}
|
||||
|
||||
if ($sort && isset($this->_sortFields[$sort])) {
|
||||
$dir = ($dir == self::DIR_ASC? 'ASC' : 'DESC');
|
||||
$sortSql = array();
|
||||
foreach ($this->_sortFields[$sort] as $field) {
|
||||
$sortSql[] = "$field $dir";
|
||||
}
|
||||
|
||||
$select = $select->order($sortSql);
|
||||
}
|
||||
|
||||
if ($where) {
|
||||
$select = $select->where($where);
|
||||
}
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getNumUsers($where = false)
|
||||
{
|
||||
$users = $this->getUsers(false, false, false, false, $where);
|
||||
|
||||
return count($users);
|
||||
}
|
||||
|
||||
public function getNumUnconfirmedUsers()
|
||||
{
|
||||
$users = $this->getUsers(false, false, false, false, "accepted_eula=0 AND role != '".User::ROLE_ADMIN."'");
|
||||
|
||||
return count($users);
|
||||
}
|
||||
|
||||
public function getUserWithToken($token)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('token=?', $token);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function getUserWithEmail($email)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('email=?', $email);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function getUserWithOpenId($openid)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('openid=?', $openid);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function getUser($identity)
|
||||
{
|
||||
$select = $this->select()->where('username=?', $identity);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function deleteUser(User $user)
|
||||
{
|
||||
$where = $this->getAdapter()->quoteInto('id=?', $user->id);
|
||||
$this->delete($where);
|
||||
}
|
||||
|
||||
public function deleteTestEntries()
|
||||
{
|
||||
$this->delete('test=1');
|
||||
}
|
||||
|
||||
public function deleteUnconfirmed()
|
||||
{
|
||||
$this->delete("accepted_eula=0 AND role = '".User::ROLE_GUEST."'");
|
||||
}
|
||||
|
||||
protected $_metadata = array(
|
||||
'id' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'id',
|
||||
'COLUMN_POSITION' => 1,
|
||||
'DATA_TYPE' => 'int',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => NULL,
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => true,
|
||||
'PRIMARY_POSITION' => 1,
|
||||
'IDENTITY' => true,
|
||||
),
|
||||
'test' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'test',
|
||||
'COLUMN_POSITION' => 2,
|
||||
'DATA_TYPE' => 'tinyint',
|
||||
'DEFAULT' => '0',
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => NULL,
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'username' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'username',
|
||||
'COLUMN_POSITION' => 3,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '50',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'openid' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'openid',
|
||||
'COLUMN_POSITION' => 4,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '100',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'accepted_eula' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'accepted_eula',
|
||||
'COLUMN_POSITION' => 5,
|
||||
'DATA_TYPE' => 'tinyint',
|
||||
'DEFAULT' => '0',
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => NULL,
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'registration_date' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'registration_date',
|
||||
'COLUMN_POSITION' => 6,
|
||||
'DATA_TYPE' => 'date',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => NULL,
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'password' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'password',
|
||||
'COLUMN_POSITION' => 7,
|
||||
'DATA_TYPE' => 'char',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '40',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'password_changed' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'password_changed',
|
||||
'COLUMN_POSITION' => 8,
|
||||
'DATA_TYPE' => 'date',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => NULL,
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'firstname' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'firstname',
|
||||
'COLUMN_POSITION' => 9,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '50',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'lastname' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'lastname',
|
||||
'COLUMN_POSITION' => 10,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '50',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'email' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'email',
|
||||
'COLUMN_POSITION' => 11,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '50',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'role' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'role',
|
||||
'COLUMN_POSITION' => 12,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '50',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'token' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'token',
|
||||
'COLUMN_POSITION' => 13,
|
||||
'DATA_TYPE' => 'char',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '32',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
);
|
||||
}
|
79
modules/users/views/scripts/login/index.phtml
Executable file
79
modules/users/views/scripts/login/index.phtml
Executable file
@ -0,0 +1,79 @@
|
||||
<? if ($this->user->role != User::ROLE_GUEST ): ?>
|
||||
<h3>
|
||||
<?= $this->translate('Hello, %s', Zend_Filter::get($this->user->username, 'HtmlEntities')) ?>
|
||||
</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/profile"><?= $this->translate('Account') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/personalinfo"><?= $this->translate('Personal Info') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/sites"><?= $this->translate('Sites database') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/history"><?= $this->translate('History Log') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/login/logout"><?= $this->translate('Logout') ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
<? if ($this->user->role == User::ROLE_ADMIN): ?>
|
||||
<hr />
|
||||
<h3><?= $this->translate('Admin options') ?></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/manageusers"><?= $this->translate('Manage Users') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/messageusers"><?= $this->translate('Message Users') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<? if ($this->maintenanceEnabled): ?>
|
||||
<a href="<?= $this->base ?>/maintenancemode/disable"><?= $this->translate('Disable Maintenance Mode') ?></a>
|
||||
<? else: ?>
|
||||
<a href="<?= $this->base ?>/maintenancemode/enable"><?= $this->translate('Enable Maintenance Mode') ?></a>
|
||||
<? endif ?>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/stats"><?= $this->translate('Statistics') ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
<? endif ?>
|
||||
<? else: ?>
|
||||
<? if ($this->underMaintenance): ?>
|
||||
<div class="messages_small">
|
||||
<?= $this->translate('User access is currently disabled for system maintenance.<br />Please try again later') ?>
|
||||
</div>
|
||||
<? endif ?>
|
||||
<form id="loginForm" action="<?= $this->loginTargetBase ?>/users/login/authenticate" method="post">
|
||||
<dl id="credentials">
|
||||
<?= $this->loginForm->username ?>
|
||||
<?= $this->loginForm->password ?>
|
||||
</dl>
|
||||
<dl id="rememberMe">
|
||||
<!-- to hard to do in the ZF -->
|
||||
<input type="checkbox" name="rememberme" style="top:0" />
|
||||
<label><?= $this->translate('Remember me') ?></label>
|
||||
</dl>
|
||||
<div id="loginButton">
|
||||
<input type="submit" id="login" value="<?= $this->translate('Log in') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("login");
|
||||
</script>
|
||||
</div>
|
||||
<p>
|
||||
<a href="<?= $this->base ?>/users/recoverpassword" class="panel_link"><?= $this->translate('Forgot you password?') ?></a>
|
||||
</p>
|
||||
</form>
|
||||
<hr/>
|
||||
<div id="registerNow">
|
||||
<p>
|
||||
<?= $this->translate('You don\'t have an account?') ?>
|
||||
<div>
|
||||
<a href="<?= $this->base ?>/users/register"><?= $this->translate('REGISTER NOW!') ?></a>
|
||||
</div>
|
||||
</p> <!-- safari bug workaround -->
|
||||
</div>
|
||||
<? endif; ?>
|
53
modules/users/views/scripts/manageusers/index.phtml
Normal file
53
modules/users/views/scripts/manageusers/index.phtml
Normal file
@ -0,0 +1,53 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["datasource", "datatable", "paginator", "json", "connection", "dragdrop"],
|
||||
function() {COMMID.usersList.init('all')}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<div class="links_topright">
|
||||
<a href="#" id="links_topright_all" onclick="COMMID.usersList.init('all'); return false;">
|
||||
<?= $this->translate('All') ?>
|
||||
</a>
|
||||
| <a href="#" id="links_topright_confirmed" onclick="COMMID.usersList.init('confirmed'); return false;">
|
||||
<?= $this->translate('Confirmed') ?>
|
||||
</a>
|
||||
| <a href="#" id="links_topright_unconfirmed" onclick="COMMID.usersList.init('unconfirmed'); return false;">
|
||||
<?= $this->translate('Unconfirmed') ?>
|
||||
</a>
|
||||
</div>
|
||||
<div id="paging"></div>
|
||||
<div id="dt"></div>
|
||||
<? if ($this->user->role == User::ROLE_ADMIN): ?>
|
||||
<div style="margin-top:10px">
|
||||
<?= $this->translate('Total users:') ?> <span id="totalUsers"></span><br />
|
||||
<?= $this->translate('Total confirmed users:') ?> <span id="totalConfirmedUsers"></span><br />
|
||||
<?= $this->translate('Total unconfirmed users:') ?> <span id="totalUnconfirmedUsers"></span><br />
|
||||
</div>
|
||||
<div style="margin-top:10px">
|
||||
<input type="button" id="addUser" value="<?= $this->translate('Add User') ?>" onclick="location.href='<?= $this->base ?>/users/profile?userid=0'" />
|
||||
<span id="deleteUnconfirmedSpan">
|
||||
<input type="button" id="deleteUnconfirmed" value="<?= $this->translate('Delete Unconfirmed Users') ?>" />
|
||||
</span>
|
||||
<script type="text/javascript">
|
||||
new YAHOO.widget.Button(
|
||||
"addUser",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {
|
||||
location.href='<?= $this->base ?>/users/profile?userid=0'
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
new YAHOO.widget.Button(
|
||||
"deleteUnconfirmed",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {COMMID.usersList.deleteUnconfirmed()}}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</div>
|
||||
<? endif ?>
|
60
modules/users/views/scripts/personalinfo/edit.phtml
Normal file
60
modules/users/views/scripts/personalinfo/edit.phtml
Normal file
@ -0,0 +1,60 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["connection"],
|
||||
null
|
||||
);
|
||||
});
|
||||
|
||||
COMMID.editPersonalInfo = function() {
|
||||
|
||||
return {
|
||||
save: function() {
|
||||
YAHOO.util.Connect.setForm("personalInfoForm");
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
'POST',
|
||||
'personalinfo/save',
|
||||
{
|
||||
success: function (responseObj) {COMMID.utils.replaceContent(responseObj, "personalInfo")},
|
||||
failure: COMMID.utils.asyncFailed
|
||||
},
|
||||
null
|
||||
);
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
var transaction = YAHOO.util.Connect.asyncRequest(
|
||||
'GET',
|
||||
'personalinfo/show',
|
||||
{
|
||||
success: function (responseObj) {COMMID.utils.replaceContent(responseObj, "personalInfo")},
|
||||
failure: COMMID.utils.asyncFailed
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
}();
|
||||
</script>
|
||||
<form name="personalInfoForm" class="formGrid" >
|
||||
<? foreach ($this->fields as $field): ?>
|
||||
<?= $field ?>
|
||||
<? endforeach ?><br />
|
||||
<input type="button" id="save" value="<?= $this->translate('Save') ?>" onclick="COMMID.editPersonalInfo.save()" />
|
||||
<input type="button" id="cancel" value="<?= $this->translate('Cancel') ?>" onclick="COMMID.editPersonalInfo.cancel()" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"save",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.editPersonalInfo.save}
|
||||
}
|
||||
);
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.editPersonalInfo.cancel}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</form>
|
28
modules/users/views/scripts/personalinfo/index.phtml
Normal file
28
modules/users/views/scripts/personalinfo/index.phtml
Normal file
@ -0,0 +1,28 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
// "connection" is required by COMMID.personalInfo.edit()
|
||||
["connection"],
|
||||
null
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<div id="article">
|
||||
<div id="generalTab" class="dataSection">
|
||||
<div class="formHeader">
|
||||
<h2><?= $this->translate('Personal Info') ?></h2>
|
||||
<div>
|
||||
<a href="javascript:void(0);" onclick="COMMID.personalInfo.edit();">
|
||||
<?= $this->translate('Edit') ?>
|
||||
</a>
|
||||
<img id="loadingEditPersonalInfo" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin:10px 0">
|
||||
<em><?= $this->translate('This information will be used to automatically populate registration fields to any OpenID transaction that requires so') ?></em>
|
||||
</div>
|
||||
<div id="personalInfo">
|
||||
<?= $this->action('show', 'personalinfo', 'users', array('userid' => $this->targetUser->id)) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
12
modules/users/views/scripts/personalinfo/show.phtml
Normal file
12
modules/users/views/scripts/personalinfo/show.phtml
Normal file
@ -0,0 +1,12 @@
|
||||
<div class="formGrid">
|
||||
<? foreach ($this->fields as $field): ?>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate($field->name) ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= is_null($field->value)? $this->translate('Not Entered') : $field->value ?>
|
||||
</div>
|
||||
</div>
|
||||
<? endforeach ?>
|
||||
</div>
|
44
modules/users/views/scripts/profile/index.phtml
Executable file
44
modules/users/views/scripts/profile/index.phtml
Executable file
@ -0,0 +1,44 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
// "connection" is required by COMMID.general methods
|
||||
["connection"],
|
||||
null
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="accountForm">
|
||||
<div>
|
||||
<h2><?= $this->translate('Account info') ?></h2>
|
||||
<? if ($this->targetUser->id == $this->user->id): ?>
|
||||
<div class="profileLinks">
|
||||
<a href="javascript:void(0);" onclick="COMMID.general.editAccountInfo();">
|
||||
<?= $this->translate('Edit') ?>
|
||||
</a> |
|
||||
<a href="javascript:void(0);" onclick="COMMID.general.changePassword()" >
|
||||
<?= $this->translate('Change Password') ?>
|
||||
</a>
|
||||
<img id="loadingAccountInfo" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" />
|
||||
</div>
|
||||
<? endif ?>
|
||||
</div>
|
||||
<div id="accountInfo">
|
||||
<? if ($this->targetUser->id) {
|
||||
echo $this->action('accountinfo', 'profilegeneral', 'users', array('userid' => $this->targetUser->id));
|
||||
} else {
|
||||
// user id == 0 means we're entering info for a new user
|
||||
echo $this->action('editaccountinfo', 'profilegeneral', 'users', array('userid' => $this->targetUser->id));
|
||||
} ?>
|
||||
</div>
|
||||
<? if ($this->targetUser->id && $this->targetUser->id == $this->user->id): ?>
|
||||
<div class="accountForm">
|
||||
<div class="profileLinks" >
|
||||
<a href="<?= $this->base ?>/users/profilegeneral/confirmdelete">
|
||||
<?= $this->translate('Delete Account') ?>
|
||||
</a>
|
||||
<img id="loadingAccountInfoDummy" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" /><!-- just for layout -->
|
||||
</div>
|
||||
</div>
|
||||
<? endif ?>
|
||||
</div>
|
34
modules/users/views/scripts/profilegeneral/accountinfo.phtml
Normal file
34
modules/users/views/scripts/profilegeneral/accountinfo.phtml
Normal file
@ -0,0 +1,34 @@
|
||||
<div class="formGrid">
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('Username') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->username ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('Name') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->getfullName() ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('E-mail') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->email ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('OpenID') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->openid ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,56 @@
|
||||
<script>
|
||||
COMMID.changePassword = function() {
|
||||
return {
|
||||
save: function() {
|
||||
YAHOO.util.Connect.setForm("changePasswordForm");
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
"POST",
|
||||
"profilegeneral/savepassword?userid=<?= $this->targetUser->id ?>",
|
||||
{
|
||||
success: function (responseObj) {COMMID.utils.replaceContent(responseObj, "accountInfo")},
|
||||
failure: COMMID.utils.asyncFailed
|
||||
},
|
||||
null
|
||||
);
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
var transaction = YAHOO.util.Connect.asyncRequest(
|
||||
'GET',
|
||||
'profilegeneral/accountinfo?userid=' + <?= $this->targetUser->id ?>,
|
||||
{
|
||||
success: function (responseObj) {COMMID.utils.replaceContent(responseObj, "accountInfo")},
|
||||
failure: COMMID.utils.asyncFailed
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}();
|
||||
</script>
|
||||
<form name="changePasswordForm" class="formGrid" >
|
||||
<?= $this->changePasswordForm->password1 ?>
|
||||
<?= $this->changePasswordForm->password2 ?>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first"> </div>
|
||||
<div class="yui-u">
|
||||
<input type="button" id="save" value="<?= $this->translate('Save') ?>" onclick="COMMID.changePassword.save()" />
|
||||
<input type="button" id="cancel" value="<?= $this->translate('Cancel') ?>" onclick="COMMID.changePassword.cancel()" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"save",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.changePassword.save}
|
||||
}
|
||||
);
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.changePassword.cancel}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
37
modules/users/views/scripts/profilegeneral/confirmdelete.phtml
Executable file
37
modules/users/views/scripts/profilegeneral/confirmdelete.phtml
Executable file
@ -0,0 +1,37 @@
|
||||
<form id="confirmDeleteForm" method="post" action="<?= $this->base ?>/users/profilegeneral/delete">
|
||||
<p>
|
||||
<?= $this->translate('Why do you want to delete your Community-ID account?') ?><br />
|
||||
<?= $this->translate('Please check all that apply:') ?>
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<input type="checkbox" name="reason_test" style="top:0" /><?= $this->translate('This was just a test account') ?>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="reason_foundbetter" style="top:0" /><?= $this->translate('I found a better service') ?>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="reason_lackedfeatures" style="top:0" /><?= $this->translate('Service lacked some key features I needed') ?>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="reason_none" style="top:0" /><?= $this->translate('No particular reason') ?>
|
||||
</li>
|
||||
</ul>
|
||||
<label for="reason_comments"><?= $this->translate('Additional comments:') ?></label>
|
||||
<textarea id="reason_comments" name="reason_comments"></textarea><br />
|
||||
<input type="submit" id="delete" value="<?= $this->translate('Delete Account') ?>" />
|
||||
<input type="button" id="cancel" value="<?= $this->translate('Cancel') ?>" onclick="location.href='<?= $this->base ?>/users/profile'" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("delete");
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {
|
||||
location.href='<?= $this->base ?>/users/profile'
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</form>
|
@ -0,0 +1,35 @@
|
||||
<form name="accountInfoForm" class="formGrid">
|
||||
<?= $this->accountInfoForm->username ?>
|
||||
<?= $this->accountInfoForm->firstname ?>
|
||||
<?= $this->accountInfoForm->lastname ?>
|
||||
<?= $this->accountInfoForm->email ?>
|
||||
<? if (!$this->targetUser->id) {
|
||||
echo $this->accountInfoForm->password1;
|
||||
echo $this->accountInfoForm->password2;
|
||||
} ?>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first"> </div>
|
||||
<div class="yui-u">
|
||||
<input type="button" id="save" value="<?= $this->translate('Save') ?>" onclick="COMMID.editAccountInfo.save()" />
|
||||
<input type="button" id="cancel" value="<?= $this->translate('Cancel') ?>" onclick="COMMID.editAccountInfo.cancel()" />
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
new YAHOO.widget.Button(
|
||||
"save",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {COMMID.editAccountInfo.save()}}
|
||||
}
|
||||
);
|
||||
new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {COMMID.editAccountInfo.cancel()}}
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
8
modules/users/views/scripts/recoverpassword/index.phtml
Executable file
8
modules/users/views/scripts/recoverpassword/index.phtml
Executable file
@ -0,0 +1,8 @@
|
||||
<?= $this->translate('Please enter your E-mail below to receive a link to reset your password') ?>
|
||||
<form method="post" action="<?= $this->base ?>/users/recoverpassword/send">
|
||||
<?= $this->form->email ?>
|
||||
<input type="submit" id="send" value="<?= $this->translate('Send') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("send");
|
||||
</script>
|
||||
</form>
|
30
modules/users/views/scripts/register/eula.phtml
Executable file
30
modules/users/views/scripts/register/eula.phtml
Executable file
@ -0,0 +1,30 @@
|
||||
<h2><?= $this->translate('Please read the following EULA in order to continue') ?></h2>
|
||||
<form name="eulaForm" action="accepteula" method="post">
|
||||
<input type="hidden" name="token" value="<?= $this->token ?>" />
|
||||
<div>
|
||||
<textarea rows="30" style="width:700px"><?= $this->eula ?></textarea>
|
||||
</div>
|
||||
<div style="margin-top:20px">
|
||||
<input type="submit" id="agree" value="<?= $this->translate('I AGREE') ?>" />
|
||||
<input type="submit" id="disagree" value="<?= $this->translate('I DISAGREE') ?>" onclick="this.form.action='declineeula'; return true" />
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["button"],
|
||||
function() {
|
||||
new YAHOO.widget.Button("disagree", {
|
||||
type: "push",
|
||||
label: "I DISAGREE",
|
||||
onclick : {fn: function(){
|
||||
document.eulaForm.action = 'declineeula';
|
||||
document.eulaForm.submit();
|
||||
}}
|
||||
});
|
||||
new YAHOO.widget.Button("disagree");
|
||||
new YAHOO.widget.Button("agree");
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</form>
|
14
modules/users/views/scripts/register/index.phtml
Executable file
14
modules/users/views/scripts/register/index.phtml
Executable file
@ -0,0 +1,14 @@
|
||||
<h2><?= $this->translate('Registration Form') ?></h2>
|
||||
<form name="registration" method="post" action="<?= $this->base ?>/users/register/save" class="formGrid" >
|
||||
<?= $this->form->firstname ?>
|
||||
<?= $this->form->lastname ?>
|
||||
<?= $this->form->email ?>
|
||||
<?= $this->form->username ?>
|
||||
<?= $this->form->password1 ?>
|
||||
<?= $this->form->password2 ?>
|
||||
<?= $this->form->captcha ?>
|
||||
<input type="submit" id="send" value="<?= $this->translate('Send') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("send");
|
||||
</script>
|
||||
</form>
|
Reference in New Issue
Block a user