import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class AboutController extends Monkeys_Controller_Action
|
||||
class AboutController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
|
54
modules/default/controllers/CidController.php
Normal file
54
modules/default/controllers/CidController.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?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 CidController extends CommunityID_Controller_Action
|
||||
{
|
||||
const NEWS_CONTENT_MAX_LENGTH = 100;
|
||||
const NEWS_NUM_ITEMS = 6;
|
||||
|
||||
protected $_numCols = 2;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->version = Application::VERSION;
|
||||
|
||||
try {
|
||||
$feed = Zend_Feed::import('http://source.keyboard-monkeys.org/projects/communityid/news?format=atom');
|
||||
} 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++ >= self::NEWS_NUM_ITEMS) {
|
||||
break;
|
||||
}
|
||||
|
||||
// ATOM uses <link href="foo" />, while RSS uses <link>foo</link>
|
||||
$item->link = $item->link['href']? $item->link['href'] : $item->link;
|
||||
|
||||
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.'">' . $this->view->translate('Read More') . '</a>';
|
||||
}
|
||||
$this->view->news[] = $item;
|
||||
}
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class FeedbackController extends Monkeys_Controller_Action
|
||||
class FeedbackController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
@ -17,7 +17,7 @@ class FeedbackController extends Monkeys_Controller_Action
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->user->role != User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
if ($this->user->role != Users_Model_User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
return $this->_redirectForMaintenance();
|
||||
}
|
||||
}
|
||||
@ -29,14 +29,14 @@ class FeedbackController extends Monkeys_Controller_Action
|
||||
$form = $appSession->feedbackForm;
|
||||
unset($appSession->feedbackForm);
|
||||
} else {
|
||||
$form = new FeedbackForm(null, $this->view->base);
|
||||
$form = new Form_Feedback(null, $this->view->base);
|
||||
}
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function sendAction()
|
||||
{
|
||||
$form = new FeedbackForm(null, $this->view->base);
|
||||
$form = new Form_Feedback(null, $this->view->base);
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
|
||||
@ -102,7 +102,7 @@ Feedback:
|
||||
$feedback
|
||||
EOD
|
||||
);
|
||||
$mail->setFrom($this->_config->email->supportemail);
|
||||
$mail->setFrom($configEmail->supportemail);
|
||||
$mail->addTo($configEmail->supportemail);
|
||||
$mail->setSubject('Community-ID feedback form');
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class HistoryController extends Monkeys_Controller_Action
|
||||
class HistoryController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
@ -20,11 +20,13 @@ class HistoryController extends Monkeys_Controller_Action
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$histories = new Histories();
|
||||
$histories = new Model_Histories();
|
||||
$historiesRows = $histories->get(
|
||||
$this->user,
|
||||
$this->_getParam('startIndex'),
|
||||
$this->_getParam('results')
|
||||
$this->_getParam('results'),
|
||||
$this->_getParam('sort', 'date'),
|
||||
$this->_getParam('dir', Model_Histories::DIR_DESC)
|
||||
);
|
||||
|
||||
$jsonObj = new StdClass();
|
||||
@ -53,7 +55,7 @@ class HistoryController extends Monkeys_Controller_Action
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$histories = new Histories();
|
||||
$histories = new Model_Histories();
|
||||
$histories->clear($this->user);
|
||||
|
||||
$json = new StdClass();
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class IdentityController extends Monkeys_Controller_Action
|
||||
class IdentityController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
@ -20,39 +20,15 @@ class IdentityController extends Monkeys_Controller_Action
|
||||
|
||||
public function idAction()
|
||||
{
|
||||
$currentUrl = Zend_OpenId::selfURL();
|
||||
$this->view->headLink()->headLink(array(
|
||||
'rel' => 'openid.server',
|
||||
'href' => $this->_helper->ProviderUrl($this->_config)
|
||||
));
|
||||
$this->view->headLink()->headLink(array(
|
||||
'rel' => 'openid2.provider',
|
||||
'href' => $this->_helper->ProviderUrl($this->_config)
|
||||
));
|
||||
|
||||
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;
|
||||
$this->view->idUrl = urldecode(Zend_OpenId::selfURL());
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class IndexController extends Monkeys_Controller_Action
|
||||
class IndexController extends CommunityID_Controller_Action
|
||||
{
|
||||
const NEWS_CONTENT_MAX_LENGTH = 100;
|
||||
const NEWS_NUMBER = 4;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
@ -41,31 +41,8 @@ class IndexController extends Monkeys_Controller_Action
|
||||
|
||||
$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;
|
||||
}
|
||||
$news = new News_Model_News();
|
||||
$this->view->news = $news->getLatest(self::NEWS_NUMBER, $this->user);
|
||||
|
||||
$view = false;
|
||||
foreach ($scriptsDir as $scriptDir) {
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class LearnmoreController extends Monkeys_Controller_Action
|
||||
class LearnmoreController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
|
@ -9,26 +9,18 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class MaintenancemodeController extends Monkeys_Controller_Action
|
||||
class MaintenancemodeController extends CommunityID_Controller_Action
|
||||
{
|
||||
private $_settings;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->_settings = new Settings();
|
||||
}
|
||||
|
||||
public function enableAction()
|
||||
{
|
||||
$this->_settings->set(Settings::MAINTENANCE_MODE, 1);
|
||||
$this->_settings->set(Model_Settings::MAINTENANCE_MODE, 1);
|
||||
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
public function disableAction()
|
||||
{
|
||||
$this->_settings->set(Settings::MAINTENANCE_MODE, 0);
|
||||
$this->_settings->set(Model_Settings::MAINTENANCE_MODE, 0);
|
||||
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class MessageusersController extends Monkeys_Controller_Action
|
||||
class MessageusersController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
@ -18,7 +18,7 @@ class MessageusersController extends Monkeys_Controller_Action
|
||||
$this->view->messageUsersForm = $appSession->messageUsersForm;
|
||||
unset($appSession->messageUsersForm);
|
||||
} else {
|
||||
$this->view->messageUsersForm = new MessageUsersForm();
|
||||
$this->view->messageUsersForm = new Form_MessageUsers();
|
||||
}
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
@ -26,7 +26,7 @@ class MessageusersController extends Monkeys_Controller_Action
|
||||
|
||||
public function sendAction()
|
||||
{
|
||||
$form = new MessageUsersForm();
|
||||
$form = new Form_MessageUsers();
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
@ -35,13 +35,13 @@ class MessageusersController extends Monkeys_Controller_Action
|
||||
}
|
||||
|
||||
$cc = $form->getValue('cc');
|
||||
$ccArr = array();
|
||||
$bccArr = 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])) {
|
||||
$bccArr = explode(',', $cc);
|
||||
for ($i = 0; $i < count($bccArr); $i++) {
|
||||
$bccArr[$i] = trim($bccArr[$i]);
|
||||
if (!$validator->isValid($bccArr[$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);
|
||||
@ -65,13 +65,17 @@ class MessageusersController extends Monkeys_Controller_Action
|
||||
$mail->setBodyHtml($form->getValue('bodyHTML'));
|
||||
}
|
||||
|
||||
$users = new Users();
|
||||
$users = new Users_Model_Users();
|
||||
foreach ($users->getUsers() as $user) {
|
||||
$mail->addTo($user->email);
|
||||
if ($user->role == ROLE_ADMIN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mail->addBcc($user->email);
|
||||
}
|
||||
|
||||
foreach ($ccArr as $cc) {
|
||||
$mail->addCC($cc);
|
||||
foreach ($bccArr as $bcc) {
|
||||
$mail->addBcc($bcc);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -122,7 +126,10 @@ class MessageusersController extends Monkeys_Controller_Action
|
||||
}
|
||||
|
||||
$mail = new Zend_Mail('UTF-8');
|
||||
$mail->setFrom($this->_config->email->supportemail);
|
||||
$mail->setFrom($configEmail->supportemail);
|
||||
|
||||
// all recipients will be in BCC, but I need at least one in the To header
|
||||
$mail->addTo($configEmail->supportemail);
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
@ -9,167 +9,292 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class OpenidController extends Monkeys_Controller_Action
|
||||
class OpenidController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function providerAction()
|
||||
{
|
||||
if (isset($_POST['action']) && $_POST['action'] == 'proceed') {
|
||||
return $this->_proceed();
|
||||
} else {
|
||||
Zend_OpenId::$exitOnRedirect = false;
|
||||
$server = $this->_getOpenIdProvider();
|
||||
$request = $server->decodeRequest();
|
||||
$sites = new Model_Sites();
|
||||
|
||||
$this->_helper->layout->disableLayout();
|
||||
if (!$request) {
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
Zend_Registry::get('logger')->log("OpenIdController::providerAction: FORBIDDEN", Zend_Log::DEBUG);
|
||||
echo 'Forbidden';
|
||||
return;
|
||||
}
|
||||
|
||||
$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'))
|
||||
// association and other transactions, handled automatically by the framework
|
||||
if (!in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) {
|
||||
return $this->_sendResponse($server, $server->handleRequest($request));
|
||||
}
|
||||
|
||||
{
|
||||
$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);
|
||||
// can't process immediate requests if user is not logged in
|
||||
if ($request->immediate && $this->user->role == Users_Model_User::ROLE_GUEST) {
|
||||
return $this->_sendResponse($server, $request->answer(false));
|
||||
}
|
||||
|
||||
if ($request->idSelect()) {
|
||||
if ($this->user->role == Users_Model_User::ROLE_GUEST) {
|
||||
$this->_forward('login');
|
||||
} else {
|
||||
if ($sites->isTrusted($this->user, $request->trust_root)) {
|
||||
$this->_forward('proceed', null, null, array('allow' => true));
|
||||
} elseif ($sites->isNeverTrusted($this->user, $request->trust_root)) {
|
||||
$this->_forward('proceed', null, null, array('allow' => false));
|
||||
} else {
|
||||
if ($request->immediate) {
|
||||
return $this->_sendResponse($server, $request->answer(false));
|
||||
}
|
||||
|
||||
$this->_forward('trust');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!$request->identity) {
|
||||
die('No identifier sent by OpenID relay');
|
||||
}
|
||||
|
||||
if ($this->user->role == Users_Model_User::ROLE_GUEST) {
|
||||
$this->_forward('login');
|
||||
} else {
|
||||
// user is logged-in already. Check the requested identity is his
|
||||
if ($this->user->openid != $request->identity) {
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
if ($this->immediate) {
|
||||
return $this->_sendResponse($server, $request->answer(false));
|
||||
}
|
||||
|
||||
$this->_forward('login');
|
||||
} else {
|
||||
if ($sites->isTrusted($this->user, $request->trust_root)) {
|
||||
$this->_forward('proceed', null, null, array('allow' => true));
|
||||
} elseif ($sites->isNeverTrusted($this->user, $request->trust_root)) {
|
||||
$this->_forward('proceed', null, null, array('deny' => true));
|
||||
} else {
|
||||
$this->_saveHistory($server, History::AUTHORIZED);
|
||||
$this->_forward('trust');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We don't use the session with the login form to simplify the dynamic appearance of the captcha
|
||||
*/
|
||||
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']));
|
||||
$server = $this->_getOpenIdProvider();
|
||||
$request = $server->decodeRequest();
|
||||
|
||||
$this->view->queryString = $_SERVER['QUERY_STRING'];
|
||||
$authAttempts = new Users_Model_AuthAttempts();
|
||||
$attempt = $authAttempts->get();
|
||||
$this->view->useCaptcha = $attempt && $attempt->surpassedMaxAllowed();
|
||||
$this->view->form = new Form_OpenidLogin(null, $this->view->base, $attempt && $attempt->surpassedMaxAllowed());
|
||||
|
||||
if (!$request->idSelect()) {
|
||||
$this->view->form->openIdIdentity->setValue(htmlspecialchars($request->identity));
|
||||
}
|
||||
|
||||
$this->view->queryString = $this->_queryString();
|
||||
}
|
||||
|
||||
public function authenticateAction()
|
||||
{
|
||||
$form = new OpenidLoginForm();
|
||||
$server = $this->_getOpenIdProvider();
|
||||
$request = $server->decodeRequest();
|
||||
|
||||
$authAttempts = new Users_Model_AuthAttempts();
|
||||
$attempt = $authAttempts->get();
|
||||
|
||||
$form = new Form_OpenidLogin(null, $this->view->base, $attempt && $attempt->surpassedMaxAllowed());
|
||||
$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);
|
||||
$this->_forward('login');
|
||||
return;
|
||||
}
|
||||
|
||||
$server = $this->_getOpenIdProvider();
|
||||
$server->login($form->getValue('openIdIdentity'), $form->getValue('password'));
|
||||
$users = new Users_Model_Users();
|
||||
$result = $users->authenticate($form->getValue('openIdIdentity'),
|
||||
$form->getValue('password'), true);
|
||||
|
||||
// needed for unit tests
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
Zend_OpenId::redirect($this->view->base . '/openid/provider', $_GET);
|
||||
if ($result) {
|
||||
if ($attempt) {
|
||||
$attempt->delete();
|
||||
}
|
||||
$sites = new Model_Sites();
|
||||
if ($sites->isTrusted($users->getUser(), $request->trust_root)) {
|
||||
$this->_forward('proceed', null, null, array('allow' => true));
|
||||
} elseif ($sites->isNeverTrusted($users->getUser(), $request->trust_root)) {
|
||||
$this->_forward('proceed', null, null, array('deny' => true));
|
||||
} else {
|
||||
$this->_forward('trust');
|
||||
}
|
||||
} else {
|
||||
if (!$attempt) {
|
||||
$authAttempts->create();
|
||||
} else {
|
||||
$attempt->addFailure();
|
||||
$attempt->save();
|
||||
}
|
||||
$this->_forward('login');
|
||||
}
|
||||
}
|
||||
|
||||
public function trustAction()
|
||||
{
|
||||
$server = $this->_getOpenIdProvider();
|
||||
$this->view->siteRoot = $server->getSiteRoot($_GET);
|
||||
$this->view->identityUrl = $server->getLoggedInUser($_GET);
|
||||
$this->view->queryString = $_SERVER['QUERY_STRING'];
|
||||
$request = $server->decodeRequest();
|
||||
|
||||
$sreg = new Zend_OpenId_Extension_Sreg();
|
||||
$sreg->parseRequest($_GET);
|
||||
$this->view->siteRoot = $request->trust_root;
|
||||
$this->view->identityUrl = $this->user->openid;
|
||||
$this->view->queryString = $this->_queryString();
|
||||
|
||||
$this->view->fields = array();
|
||||
$this->view->policyUrl = false;
|
||||
|
||||
$props = $sreg->getProperties();
|
||||
// The class Auth_OpenID_SRegRequest is included in the following file
|
||||
require 'libs/Auth/OpenID/SReg.php';
|
||||
|
||||
$sregRequest = Auth_OpenID_SRegRequest::fromOpenIDRequest($request);
|
||||
$props = $sregRequest->allRequestedFields();
|
||||
$args = $sregRequest->getExtensionArgs();
|
||||
if (isset($args['required'])) {
|
||||
$required = explode(',', $args['required']);
|
||||
} else {
|
||||
$required = false;
|
||||
}
|
||||
|
||||
if (is_array($props) && count($props) > 0) {
|
||||
$personalInfoForm = new PersonalInfoForm(null, $this->user, $props);
|
||||
$sregProps = array();
|
||||
foreach ($props as $field) {
|
||||
$sregProps[$field] = $required && in_array($field, $required);
|
||||
}
|
||||
|
||||
$personalInfoForm = new Users_Form_PersonalInfo(null, $this->user, $sregProps);
|
||||
$this->view->fields = $personalInfoForm->getElements();
|
||||
|
||||
$policy = $sreg->getPolicyUrl();
|
||||
if (!empty($policy)) {
|
||||
$this->view->policyUrl = $policy;
|
||||
if (isset($args['policy_url'])) {
|
||||
$this->view->policyUrl = $args['policy_url'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _proceed()
|
||||
public function proceedAction()
|
||||
{
|
||||
if ($this->user->role == User::ROLE_GUEST) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
// needed for unit tests
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$server = $this->_getOpenIdProvider();
|
||||
$request = $server->decodeRequest();
|
||||
|
||||
$sreg = new Zend_OpenId_Extension_Sreg();
|
||||
$sreg->parseRequest($_GET);
|
||||
$props = $sreg->getProperties();
|
||||
if ($request->idSelect()) {
|
||||
$id = $this->user->openid;
|
||||
} else {
|
||||
$id = null;
|
||||
}
|
||||
|
||||
$personalInfoForm = new PersonalInfoForm(null, $this->user, $props);
|
||||
$formData = $this->_request->getPost();
|
||||
$personalInfoForm->populate($formData);
|
||||
$response = $request->answer(true, null, $id);
|
||||
|
||||
// not planning on validating stuff here yet, but I call this
|
||||
// for the date element to be filled properly
|
||||
$personalInfoForm->isValid($formData);
|
||||
// The class Auth_OpenID_SRegRequest is included in the following file
|
||||
require 'libs/Auth/OpenID/SReg.php';
|
||||
|
||||
$sreg->parseResponse($personalInfoForm->getValues());
|
||||
if (isset($_POST['allow'])) {
|
||||
if (isset($_POST['forever'])) {
|
||||
$server->allowSite($server->getSiteRoot($_GET), $sreg);
|
||||
}
|
||||
unset($_GET['openid_action']);
|
||||
$sregRequest = Auth_OpenID_SRegRequest::fromOpenIDRequest($request);
|
||||
$props = $sregRequest->allRequestedFields();
|
||||
$args = $sregRequest->getExtensionArgs();
|
||||
if (isset($args['required'])) {
|
||||
$required = explode(',', $args['required']);
|
||||
} else {
|
||||
$required = false;
|
||||
}
|
||||
|
||||
$this->_saveHistory($server, History::AUTHORIZED);
|
||||
|
||||
$server->respondToConsumer($_GET, $sreg);
|
||||
} else if (isset($_POST['deny'])) {
|
||||
if (isset($_POST['forever'])) {
|
||||
$server->denySite($server->getSiteRoot($_GET));
|
||||
if (is_array($props) && count($props) > 0) {
|
||||
$sregProps = array();
|
||||
foreach ($props as $field) {
|
||||
$sregProps[$field] = $required && in_array($field, $required);
|
||||
}
|
||||
|
||||
$this->_saveHistory($server, History::DENIED);
|
||||
$personalInfoForm = new Users_Form_PersonalInfo(null, $this->user, $sregProps);
|
||||
$formData = $this->_request->getPost();
|
||||
$personalInfoForm->populate($formData);
|
||||
|
||||
Zend_OpenId::redirect($_GET['openid_return_to'], array('openid.mode'=>'cancel'));
|
||||
// not planning on validating stuff here yet, but I call this
|
||||
// for the date element to be filled properly
|
||||
$personalInfoForm->isValid($formData);
|
||||
|
||||
$sregResponse = Auth_OpenID_SRegResponse::extractResponse($sregRequest,
|
||||
$personalInfoForm->getUnqualifiedValues());
|
||||
$sregResponse->toMessage($response->fields);
|
||||
}
|
||||
|
||||
if ($this->_getParam('allow')) {
|
||||
if ($this->_getParam('forever')) {
|
||||
|
||||
$sites = new Model_Sites();
|
||||
$sites->deleteForUserSite($this->user, $request->trust_root);
|
||||
|
||||
$siteObj = $sites->createRow();
|
||||
$siteObj->user_id = $this->user->id;
|
||||
$siteObj->site = $request->trust_root;
|
||||
$siteObj->creation_date = date('Y-m-d');
|
||||
|
||||
if (isset($personalInfoForm)) {
|
||||
$trusted = array();
|
||||
// using this key name for BC pre 1.1 when we used Zend_OpenId
|
||||
$trusted['Zend_OpenId_Extension_Sreg'] = $personalInfoForm->getUnqualifiedValues();
|
||||
} else {
|
||||
$trusted = true;
|
||||
}
|
||||
$siteObj->trusted = serialize($trusted);
|
||||
|
||||
$siteObj->save();
|
||||
}
|
||||
|
||||
$this->_saveHistory($request->trust_root, Model_History::AUTHORIZED);
|
||||
|
||||
$webresponse = $server->encodeResponse($response);
|
||||
|
||||
foreach ($webresponse->headers as $k => $v) {
|
||||
header("$k: $v");
|
||||
}
|
||||
|
||||
header('Connection: close');
|
||||
echo $webresponse->body;
|
||||
} elseif ($this->_getParam('deny')) {
|
||||
if ($this->_getParam('forever')) {
|
||||
$sites = new Model_Sites();
|
||||
$sites->deleteForUserSite($this->user, $request->trust_root);
|
||||
|
||||
$siteObj = $sites->createRow();
|
||||
$siteObj->user_id = $this->user->id;
|
||||
$siteObj->site = $request->trust_root;
|
||||
$siteObj->creation_date = date('Y-m-d');
|
||||
$siteObj->trusted = serialize(false);
|
||||
$siteObj->save();
|
||||
}
|
||||
|
||||
$this->_saveHistory($request->trust_root, Model_History::DENIED);
|
||||
|
||||
header('HTTP/1.1 302 Found');
|
||||
header('Content-Type: text/plain; charset=us-ascii');
|
||||
header('Connection: close');
|
||||
header('Location: ' . $request->getCancelUrl());
|
||||
}
|
||||
}
|
||||
private function _saveHistory(Zend_OpenId_Provider $server, $result)
|
||||
{
|
||||
// only log if user exists
|
||||
if ($this->user->role == User::ROLE_GUEST) {
|
||||
return;
|
||||
}
|
||||
|
||||
$histories = new Histories();
|
||||
private function _saveHistory($site, $result)
|
||||
{
|
||||
$histories = new Model_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->site = $site;
|
||||
$history->ip = $_SERVER['REMOTE_ADDR'];
|
||||
$history->result = $result;
|
||||
$history->save();
|
||||
@ -177,11 +302,64 @@ class OpenidController extends Monkeys_Controller_Action
|
||||
|
||||
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());
|
||||
$connection = new CommunityID_OpenId_DatabaseConnection(Zend_Registry::get('db'));
|
||||
$store = new Auth_OpenID_MySQLStore($connection, 'associations', 'nonces');
|
||||
$server = new Auth_OpenID_Server($store, $this->_helper->ProviderUrl($this->_config));
|
||||
|
||||
return $server;
|
||||
}
|
||||
|
||||
private function _sendResponse(Auth_OpenID_Server $server, Auth_OpenID_ServerResponse $response)
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$webresponse = $server->encodeResponse($response);
|
||||
|
||||
if ($webresponse->code != AUTH_OPENID_HTTP_OK) {
|
||||
header(sprintf("HTTP/1.1 %d ", $webresponse->code), true, $webresponse->code);
|
||||
}
|
||||
|
||||
foreach ($webresponse->headers as $k => $v) {
|
||||
header("$k: $v");
|
||||
}
|
||||
|
||||
header('Connection: close');
|
||||
|
||||
echo $webresponse->body;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Circumvent PHP's automatic replacement of dots by underscore in var names in $_GET and $_POST
|
||||
*/
|
||||
private function _queryString()
|
||||
{
|
||||
$unfilteredVars = array_merge($_GET, $_POST);
|
||||
$varsTemp = array();
|
||||
$vars = array();
|
||||
$extensions = array();
|
||||
foreach ($unfilteredVars as $key => $value) {
|
||||
if (substr($key, 0, 10) == 'openid_ns_') {
|
||||
$extensions[] = substr($key, 10);
|
||||
$varsTemp[str_replace('openid_ns_', 'openid.ns.', $key)] = $value;
|
||||
} else {
|
||||
$varsTemp[str_replace('openid_', 'openid.', $key)] = $value;
|
||||
}
|
||||
}
|
||||
foreach ($extensions as $extension) {
|
||||
foreach ($varsTemp as $key => $value) {
|
||||
if (strpos($key, "openid.$extension") === 0) {
|
||||
$prefix = "openid.$extension.";
|
||||
$key = $prefix . substr($key, strlen($prefix));
|
||||
}
|
||||
$vars[$key] = $value;
|
||||
}
|
||||
}
|
||||
if (!$extensions) {
|
||||
$vars = $varsTemp;
|
||||
}
|
||||
|
||||
return '?' . http_build_query($vars);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class PrivacyController extends Monkeys_Controller_Action
|
||||
class PrivacyController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class SitesController extends Monkeys_Controller_Action
|
||||
class SitesController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
@ -20,8 +20,8 @@ class SitesController extends Monkeys_Controller_Action
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$fields = new Fields();
|
||||
$sites = new Sites();
|
||||
$fields = new Model_Fields();
|
||||
$sites = new Model_Sites();
|
||||
$sitesRows = $sites->get(
|
||||
$this->user,
|
||||
$this->_getParam('startIndex'),
|
||||
@ -67,7 +67,7 @@ class SitesController extends Monkeys_Controller_Action
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$sites = new Sites();
|
||||
$sites = new Model_Sites();
|
||||
$site = $sites->getRowInstance($this->_getParam('id'));
|
||||
if ($site->user_id != $this->user->id) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
@ -86,7 +86,7 @@ class SitesController extends Monkeys_Controller_Action
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$sites = new Sites();
|
||||
$sites = new Model_Sites();
|
||||
$site = $sites->getRowInstance($this->_getParam('id'));
|
||||
if ($site->user_id != $this->user->id) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
@ -105,7 +105,7 @@ class SitesController extends Monkeys_Controller_Action
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$sites = new Sites();
|
||||
$sites = new Model_Sites();
|
||||
$site = $sites->getRowInstance($this->_getParam('id'));
|
||||
if ($site->user_id != $this->user->id) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
|
@ -4,8 +4,8 @@
|
||||
* @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
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
* 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
|
||||
class Form_ErrorMessages
|
||||
{
|
||||
private function _messages()
|
||||
{
|
||||
@ -24,5 +24,6 @@ class ErrorMessages
|
||||
translate('\'%value%\' appears to be a local network name but local network names are not allowed');
|
||||
translate('Captcha value is wrong');
|
||||
translate('Password confirmation does not match');
|
||||
translate('Username can only contain US-ASCII alphanumeric characters, plus any of the symbols $-_.+!*\'(), and "');
|
||||
}
|
||||
}
|
||||
|
61
modules/default/forms/Feedback.php
Normal file
61
modules/default/forms/Feedback.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 Form_Feedback 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/MessageUsers.php
Normal file
34
modules/default/forms/MessageUsers.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 Form_MessageUsers extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$subject = new Monkeys_Form_Element_Text('subject');
|
||||
translate('Subject:');
|
||||
$subject->setLabel('Subject')
|
||||
->setRequired(true);
|
||||
|
||||
$cc = new Monkeys_Form_Element_Text('cc');
|
||||
translate('CC:');
|
||||
$cc->setLabel('CC');
|
||||
|
||||
$bodyPlain = new Monkeys_Form_Element_Textarea('bodyPlain');
|
||||
$bodyPlain->setDecoratorOptions(array('separateLine' => true));
|
||||
|
||||
$bodyHTML= new Monkeys_Form_Element_Richtextarea('bodyHTML');
|
||||
$bodyHTML->setDecoratorOptions(array('separateLine' => true))
|
||||
->setAttrib('width', '510px');
|
||||
|
||||
$this->addElements(array($subject, $cc, $bodyPlain, $bodyHTML));
|
||||
}
|
||||
}
|
63
modules/default/forms/OpenidLogin.php
Normal file
63
modules/default/forms/OpenidLogin.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 Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Form_OpenIdLogin extends Zend_Form
|
||||
{
|
||||
private $_baseWebDir;
|
||||
private $_useCaptcha;
|
||||
|
||||
public function __construct($options = null, $baseWebDir = null, $useCaptcha= false)
|
||||
{
|
||||
$this->_baseWebDir = $baseWebDir;
|
||||
$this->_useCaptcha = $useCaptcha;
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$openIdIdentity = new Monkeys_Form_Element_Text('openIdIdentity');
|
||||
translate('OpenID URL');
|
||||
$openIdIdentity->setLabel('OpenID URL')
|
||||
->setDecoratorOptions(array('dontMarkRequired' => true))
|
||||
->setAttrib('style', 'width:300px')
|
||||
->setRequired(true);
|
||||
|
||||
$password = new Monkeys_Form_Element_Password('password');
|
||||
translate('Password');
|
||||
$password->setLabel('Password')
|
||||
->setDecoratorOptions(array('dontMarkRequired' => true))
|
||||
->setAttrib('style', 'width:300px')
|
||||
->setRequired(true);
|
||||
|
||||
$this->addElements(array($openIdIdentity, $password));
|
||||
|
||||
if ($this->_useCaptcha) {
|
||||
$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,
|
||||
)
|
||||
));
|
||||
$captcha->setDecoratorOptions(array(
|
||||
'dontMarkRequired' => true,
|
||||
));
|
||||
|
||||
$this->addElement($captcha);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,6 @@
|
||||
*/
|
||||
|
||||
|
||||
class Association extends Zend_Db_Table_Row_Abstract
|
||||
class Model_Association extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
}
|
||||
|
@ -10,11 +10,11 @@
|
||||
*/
|
||||
|
||||
|
||||
class Associations extends Monkeys_Db_Table_Gateway
|
||||
class Model_Associations extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'associations';
|
||||
protected $_primary = 'handle';
|
||||
protected $_rowClass = 'Association';
|
||||
protected $_rowClass = 'Model_Association';
|
||||
|
||||
public function getAssociationGivenHandle($handle)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
|
||||
class Field extends Zend_Db_Table_Row_Abstract
|
||||
class Model_Field extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
const TYPE_TEXT = 1;
|
||||
const TYPE_DATE = 2;
|
||||
|
@ -10,15 +10,15 @@
|
||||
*/
|
||||
|
||||
|
||||
class Fields extends Monkeys_Db_Table_Gateway
|
||||
class Model_Fields extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'fields';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'Field';
|
||||
protected $_rowClass = 'Model_Field';
|
||||
|
||||
private $_fieldsNames= array();
|
||||
|
||||
public function getValues(User $user)
|
||||
public function getValues(Users_Model_User $user)
|
||||
{
|
||||
$userId = (int)$user->id;
|
||||
$select = $this->select()
|
||||
|
@ -10,6 +10,6 @@
|
||||
*/
|
||||
|
||||
|
||||
class FieldsValue extends Zend_Db_Table_Row_Abstract
|
||||
class Model_FieldsValue extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
}
|
||||
|
@ -10,13 +10,13 @@
|
||||
*/
|
||||
|
||||
|
||||
class FieldsValues extends Monkeys_Db_Table_Gateway
|
||||
class Model_FieldsValues extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'fields_values';
|
||||
protected $_primary = array('user_id', 'field_id');
|
||||
protected $_rowClass = 'FieldsValue';
|
||||
protected $_rowClass = 'Model_FieldsValue';
|
||||
|
||||
public function deleteForUser(User $user)
|
||||
public function deleteForUser(Users_Model_User $user)
|
||||
{
|
||||
$where = $this->getAdapter()->quoteInto('user_id=?', $user->id);
|
||||
$this->delete($where);
|
||||
|
@ -10,17 +10,37 @@
|
||||
*/
|
||||
|
||||
|
||||
class Histories extends Monkeys_Db_Table_Gateway
|
||||
class Model_Histories extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
const DIR_ASC = 0;
|
||||
const DIR_DESC = 1;
|
||||
|
||||
private $_sortFields = array(
|
||||
'date' => array('date', 'site', 'ip', 'result'),
|
||||
'site' => array('site', 'date', 'ip', 'result'),
|
||||
'ip' => array('ip', 'date', 'site', 'result'),
|
||||
'result' => array('result', 'date', 'site', 'ip'),
|
||||
);
|
||||
|
||||
protected $_name = 'history';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'History';
|
||||
protected $_rowClass = 'Model_History';
|
||||
|
||||
public function get(User $user, $startIndex, $results)
|
||||
public function get(Users_Model_User $user, $startIndex = false, $results = false, $sort = false, $dir = false)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('user_id=?', $user->id);
|
||||
|
||||
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 ($startIndex !== false && $results !== false) {
|
||||
$select = $select->limit($results, $startIndex);
|
||||
}
|
||||
@ -28,14 +48,14 @@ class Histories extends Monkeys_Db_Table_Gateway
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getNumHistories(User $user)
|
||||
public function getNumHistories(Users_Model_User $user)
|
||||
{
|
||||
$sites = $this->get($user, false, false);
|
||||
$sites = $this->get($user);
|
||||
|
||||
return count($sites);
|
||||
}
|
||||
|
||||
public function clear(User $user)
|
||||
public function clear(Users_Model_User $user)
|
||||
{
|
||||
$where = $this->getAdapter()->quoteInto('user_id=?', $user->id);
|
||||
$this->delete($where);
|
||||
|
@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
|
||||
class History extends Zend_Db_Table_Row_Abstract
|
||||
class Model_History extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
const DENIED = 0;
|
||||
const AUTHORIZED = 1;
|
||||
|
@ -9,12 +9,13 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Settings extends Monkeys_Db_Table_Gateway
|
||||
class Model_Settings extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'settings';
|
||||
protected $_primary = 'name';
|
||||
|
||||
const MAINTENANCE_MODE = 'maintenance_mode';
|
||||
const VERSION = 'version';
|
||||
|
||||
public function get($name)
|
||||
{
|
||||
@ -23,6 +24,10 @@ class Settings extends Monkeys_Db_Table_Gateway
|
||||
|
||||
$row = $this->fetchRow($select);
|
||||
|
||||
if (!$row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $row->value;
|
||||
}
|
||||
|
||||
@ -35,4 +40,9 @@ class Settings extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
return $this->get(self::MAINTENANCE_MODE);
|
||||
}
|
||||
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->get(self::VERSION);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,6 @@
|
||||
*/
|
||||
|
||||
|
||||
class Site extends Zend_Db_Table_Row_Abstract
|
||||
class Model_Site extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
}
|
||||
|
@ -10,20 +10,34 @@
|
||||
*/
|
||||
|
||||
|
||||
class Sites extends Monkeys_Db_Table_Gateway
|
||||
class Model_Sites extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'sites';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'Site';
|
||||
protected $_rowClass = 'Model_Site';
|
||||
|
||||
public function deleteForUserSite(User $user, $site)
|
||||
private $_userSites = array();
|
||||
|
||||
public function deleteForUserSite(Users_Model_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)
|
||||
public function getSites(Users_Model_User $user)
|
||||
{
|
||||
if (!isset($this->_userSites[$user->username])) {
|
||||
$select = $this->select()
|
||||
->where('user_id=?', $user->id);
|
||||
|
||||
$this->_userSites[$user->username] = $this->fetchAll($select);
|
||||
}
|
||||
|
||||
return $this->_userSites[$user->username];
|
||||
}
|
||||
|
||||
public function get(Users_Model_User $user, $startIndex, $results)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('user_id=?', $user->id);
|
||||
@ -35,18 +49,32 @@ class Sites extends Monkeys_Db_Table_Gateway
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getNumSites(User $user)
|
||||
public function getNumSites(Users_Model_User $user)
|
||||
{
|
||||
$sites = $this->get($user, false, false);
|
||||
|
||||
return count($sites);
|
||||
}
|
||||
|
||||
public function getTrusted(User $user)
|
||||
public function isTrusted(Users_Model_User $user, $site)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('user_id=?', $user->id);
|
||||
foreach ($this->getSites($user) as $userSite) {
|
||||
if ($userSite->site == $site && $userSite->trusted != 'b:0;') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->fetchAll($select);
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isNeverTrusted(Users_Model_User $user, $site)
|
||||
{
|
||||
foreach ($this->getSites($user) as $userSite) {
|
||||
if ($userSite->site == $site && $userSite->trusted == 'b:0;') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
22
modules/default/views/scripts/cid/index.phtml
Normal file
22
modules/default/views/scripts/cid/index.phtml
Normal file
@ -0,0 +1,22 @@
|
||||
<h2><?php echo $this->translate('About Community-id') ?></h2>
|
||||
<div>
|
||||
<label><?php echo $this->translate('Version installed:') ?></label>
|
||||
<?php echo $this->version ?>
|
||||
</div>
|
||||
<div style="margin:20px 0 10px">
|
||||
<label>
|
||||
<?php echo $this->translate('Latest news from Community-ID:') ?>
|
||||
</label>
|
||||
</div>
|
||||
<ul>
|
||||
<?php foreach ($this->news as $item): ?>
|
||||
<li>
|
||||
<div>
|
||||
<a href="<?php echo $item->link ?>"><?= $item->title ?></a>
|
||||
</div>
|
||||
<div class="newsExcerpt">
|
||||
<?php echo $item->content ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
@ -6,13 +6,13 @@
|
||||
</head>
|
||||
<body>
|
||||
<h2>An error occurred</h2>
|
||||
<strong><?= $this->message ?></strong>
|
||||
<? if ($this->trace): ?>
|
||||
<strong><?php echo $this->message ?></strong>
|
||||
<?php if ($this->trace): ?>
|
||||
<pre>
|
||||
Stack Trace:
|
||||
<?= $this->trace ?>
|
||||
<?php echo $this->trace ?>
|
||||
</pre>
|
||||
<? endif ?>
|
||||
<?php endif ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
<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') ?>" />
|
||||
<h3><?php echo $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="<?php echo $this->base ?>/feedback/send" class="formGrid">
|
||||
<?php echo $this->form->name ?>
|
||||
<?php echo $this->form->email ?>
|
||||
<?php echo $this->form->feedback ?>
|
||||
<?php echo $this->form->captcha ?>
|
||||
<input type="submit" id="send" value="<?php echo $this->translate('Send') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("send");
|
||||
</script>
|
||||
|
@ -10,7 +10,7 @@ YAHOO.util.Event.onDOMReady(function () {
|
||||
<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()" />
|
||||
<input type="button" id="clearHistoryBtn" value="<?php echo $this->translate('Clear History') ?>" onclick="COMMID.historyList.clearEntries()" />
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
|
@ -1,4 +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>
|
||||
<h2 style="text-align:center"><?php echo $this->idUrl ?></h2>
|
||||
</div>
|
||||
|
@ -14,24 +14,43 @@
|
||||
<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>
|
||||
<a href="<?php echo $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): ?>
|
||||
<?php foreach ($this->news as $item): ?>
|
||||
<li>
|
||||
<div>
|
||||
<a href="<?= $item->link['href'] ?>"><?= $item->title ?></a>
|
||||
<a href="<?php echo $this->base . '/news/' . $item->id ?>"><?= $item->title ?></a>
|
||||
</div>
|
||||
<div class="newsExcerpt">
|
||||
<?= $item->content ?>
|
||||
<?php echo $item->excerpt ?>
|
||||
<div>
|
||||
<a class="readMore" href="<?php echo $this->base . '/news/' . $item->id ?>"><?php echo $this->translate('Read More') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<? endforeach ?>
|
||||
<?php endforech ?>
|
||||
<?php if (count($this->news) == 0): ?>
|
||||
<div>
|
||||
<?php echo $this->translate('There are no news articles yet') ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</ul> <!-- FF bug -->
|
||||
<div style="position:relative">
|
||||
<div class="linksTopRight">
|
||||
<?php if (count($this->news) > 0): ?>
|
||||
<a href="<?php echo $this->base ?>/news"><?php echo $this->translate('View All') ?></a>
|
||||
<?php endif ?>
|
||||
<?php if ($this->user->role == Users_Model_User::ROLE_ADMIN): ?>
|
||||
|
|
||||
<a href="<?php echo $this->base ?>/news/edit/add"><?php echo $this->translate('Add New Article') ?></a>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="borderFadingLeft">
|
||||
</div>
|
||||
|
@ -14,24 +14,43 @@
|
||||
<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>
|
||||
<a href="<?php echo $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): ?>
|
||||
<?php foreach ($this->news as $item): ?>
|
||||
<li>
|
||||
<div>
|
||||
<a href="<?= $item->link['href'] ?>"><?= $item->title ?></a>
|
||||
<a href="<?php echo $this->base . '/news/' . $item->id ?>"><?= $item->title ?></a>
|
||||
</div>
|
||||
<div class="newsExcerpt">
|
||||
<?= $item->content ?>
|
||||
<?php echo $item->excerpt ?>
|
||||
<div>
|
||||
<a class="readMore" href="<?php echo $this->base . '/news/' . $item->id ?>"><?php echo $this->translate('Read More') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<? endforeach ?>
|
||||
<?php endforeach ?>
|
||||
<?php if (count($this->news) == 0): ?>
|
||||
<div>
|
||||
<?php echo $this->translate('There are no news articles yet') ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</ul> <!-- FF bug -->
|
||||
<div style="position:relative">
|
||||
<div class="linksTopRight">
|
||||
<?php if (count($this->news) > 0): ?>
|
||||
<a href="<?php echo $this->base ?>/news"><?php echo $this->translate('View All') ?></a>
|
||||
<?php endif ?>
|
||||
<?php if ($this->user->role == Users_Model_User::ROLE_ADMIN): ?>
|
||||
|
|
||||
<a href="<?php echo $this->base ?>/news/edit/add"><?php echo $this->translate('Add New Article') ?></a>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="borderFadingLeft">
|
||||
</div>
|
||||
|
@ -14,24 +14,41 @@
|
||||
<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>
|
||||
<a href="<?php echo $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>
|
||||
<?php foreach ($this->news as $item): ?>
|
||||
<div>
|
||||
<a href="<?= $item->link['href'] ?>"><?= $item->title ?></a>
|
||||
<a href="<?php echo $this->base . '/news/' . $item->id ?>"><?= $item->title ?></a>
|
||||
</div>
|
||||
<div class="newsExcerpt">
|
||||
<?= $item->content ?>
|
||||
<?php echo $item->excerpt ?>
|
||||
<div>
|
||||
<a class="readMore" href="<?php echo $this->base . '/news/' . $item->id ?>"><?php echo $this->translate('Read More') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<? endforeach ?>
|
||||
<?php endforeach ?>
|
||||
<?php if (count($this->news) == 0): ?>
|
||||
<div>
|
||||
<?php echo $this->translate('There are no news articles yet') ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</ul> <!-- FF bug -->
|
||||
<div style="position:relative">
|
||||
<div class="linksTopRight">
|
||||
<?php if (count($this->news) > 0): ?>
|
||||
<a href="<?php echo $this->base ?>/news"><?php echo $this->translate('View All') ?></a>
|
||||
<?php endif ?>
|
||||
<?php if ($this->user->role == Users_Model_User::ROLE_ADMIN): ?>
|
||||
|
|
||||
<a href="<?php echo $this->base ?>/news/edit/add"><?php echo $this->translate('Add New Article') ?></a>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="borderFadingLeft">
|
||||
</div>
|
||||
|
@ -24,24 +24,43 @@
|
||||
<p style="font-weight: bold; text-align:center">
|
||||
Vad väntar du på?<br />
|
||||
Förenkla livet och minska riskerna.<br /><br />
|
||||
<a href="<?= $this->base ?>/users/register">SKAFFA GRATIS OpenID NU</a>
|
||||
<a href="<?php echo $this->base ?>/users/register">SKAFFA GRATIS OpenID NU</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<div id="homeNews">
|
||||
<h3>Senaste nytt</h3>
|
||||
<ul>
|
||||
<? foreach ($this->news as $item): ?>
|
||||
<?php foreach ($this->news as $item): ?>
|
||||
<li>
|
||||
<div>
|
||||
<a href="<?= $item->link['href'] ?>"><?= $item->title ?></a>
|
||||
<a href="<?php echo $this->base . '/news/' . $item->id ?>"><?= $item->title ?></a>
|
||||
</div>
|
||||
<div class="newsExcerpt">
|
||||
<?= $item->content ?>
|
||||
<?php echo $item->excerpt ?>
|
||||
<div>
|
||||
<a class="readMore" href="<?php echo $this->base . '/news/' . $item->id ?>"><?php echo $this->translate('Read More') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<? endforeach ?>
|
||||
<?php endforeach ?>
|
||||
<?php if (count($this->news) == 0): ?>
|
||||
<div>
|
||||
<?php echo $this->translate('There are no news articles yet') ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</ul> <!-- FF bug -->
|
||||
<div style="position:relative">
|
||||
<div class="linksTopRight">
|
||||
<?php if (count($this->news) > 0): ?>
|
||||
<a href="<?php echo $this->base ?>/news"><?php echo $this->translate('View All') ?></a>
|
||||
<?php endif ?>
|
||||
<?php if ($this->user->role == Users_Model_User::ROLE_ADMIN): ?>
|
||||
|
|
||||
<a href="<?php echo $this->base ?>/news/edit/add"><?php echo $this->translate('Add New Article') ?></a>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="borderFadingLeft">
|
||||
</div>
|
||||
|
@ -6,49 +6,33 @@
|
||||
}
|
||||
</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">
|
||||
<em><?php echo $this->translate('This message will be sent to all registered Community-ID users') ?></em>
|
||||
<form id="messageUsersForm" name="messageUsersForm" method="post" action="<?php echo $this->base ?>/messageusers/send" class="formGrid">
|
||||
<input type="hidden" name="messageType" value="rich" />
|
||||
<dl class="shortLabelsForm">
|
||||
<?= $this->messageUsersForm->subject ?>
|
||||
<?= $this->messageUsersForm->cc ?>
|
||||
</dl>
|
||||
<?php echo $this->messageUsersForm->subject ?>
|
||||
<?php echo $this->messageUsersForm->cc ?>
|
||||
<div id="textareasWrapper">
|
||||
<div id="linkSwitchToPlain">
|
||||
<a href="#" onclick="COMMID.messageUsers.switchToPlainText()"><?= $this->translate('switch to Plain-Text') ?></a>
|
||||
<a href="#" onclick="COMMID.messageUsers.switchToPlainText()"><?php echo $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>
|
||||
<a href="#" onclick="COMMID.messageUsers.switchToRichText()"><?php echo $this->translate('switch to Rich-Text (HTML)') ?></a>
|
||||
</div>
|
||||
<br />
|
||||
<div id="bodyPlainWrapper">
|
||||
<?php echo $this->messageUsersForm->bodyPlain ?>
|
||||
</div>
|
||||
<div id="bodyHTMLWrapper">
|
||||
<?php echo $this->messageUsersForm->bodyHTML ?>
|
||||
</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') ?>" />
|
||||
<input type="submit" id="send" value="<?php echo $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;
|
||||
}
|
||||
);
|
||||
});
|
||||
YAHOO.util.Event.onDOMReady(function() {
|
||||
$("messageUsersForm").onsubmit = COMMID.messageUsers.send;
|
||||
});
|
||||
</script>
|
||||
|
@ -1,10 +1,16 @@
|
||||
<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>
|
||||
<form action="authenticate<?php echo $this->queryString ?>" method="post" class="formGrid">
|
||||
<?php echo $this->form->openIdIdentity ?>
|
||||
<?php echo $this->form->password ?>
|
||||
<?php if ($this->useCaptcha): ?>
|
||||
<?php echo $this->form->captcha ?>
|
||||
<?php endif ?>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<input type="submit" id="login" value="<?php echo $this->translate('Login') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("login");
|
||||
</script>
|
||||
</div>
|
||||
<div class="yui-u"> </div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -1,31 +1,31 @@
|
||||
<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>') ?>
|
||||
<?php echo $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">
|
||||
<form method="post" action="proceed<?php echo $this->queryString ?>" class="formGrid">
|
||||
<input type="hidden" name="action" value="proceed">
|
||||
<? if ($this->fields): ?>
|
||||
<?php 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.') ?>
|
||||
<?php echo $this->translate('It also requests this additional information about you:') ?><br /><br />
|
||||
<?php echo $this->translate('Fields are automatically filled according to the personal info stored in your community-id account.') ?><br />
|
||||
<?php echo $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',
|
||||
<?php foreach ($this->fields as $field): ?>
|
||||
<?php echo $field ?>
|
||||
<?php endforeach ?>
|
||||
<?php if ($this->policyUrl): ?>
|
||||
<?php echo $this->translate('The private policy can be found at %s',
|
||||
'<a href="'.$this->policyUrl.'">'.$this->policyUrl.'</a>'); ?><br /><br />
|
||||
<? endif ?>
|
||||
<? endif ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<div style="margin-top:20px">
|
||||
<input type="checkbox" name="forever" style="top:0" /> <?= $this->translate('Forever') ?>
|
||||
<input type="checkbox" name="forever" style="top:0" /> <?php echo $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') ?>" />
|
||||
<input type="submit" id="allow" name="allow" value="<?php echo $this->translate('Allow') ?>" />
|
||||
<input type="submit" id="deny" name="deny" value="<?php echo $this->translate('Deny') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton1 = new YAHOO.widget.Button("allow");
|
||||
var oButton2 = new YAHOO.widget.Button("deny");
|
||||
|
@ -1,4 +1,4 @@
|
||||
<h2><?= $this->translate('Privacy Policy') ?></h2>
|
||||
<h2><?php echo $this->translate('Privacy Policy') ?></h2>
|
||||
<div>
|
||||
<?= $this->privacyPolicy ?>
|
||||
<?php echo $this->privacyPolicy ?>
|
||||
</div>
|
||||
|
@ -12,13 +12,13 @@ YAHOO.util.Event.onDOMReady(function () {
|
||||
<div id="paging"></div>
|
||||
<div id="dt"></div>
|
||||
<div id="fieldsDialog">
|
||||
<div class="hd"><?= $this->translate('Information Exchanged') ?></div>
|
||||
<div class="hd"><?php echo $this->translate('Information Exchanged') ?></div>
|
||||
<div class="bd">
|
||||
<?= $this->translate('Information exchanged with:') ?><br />
|
||||
<?php echo $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()" />
|
||||
<input type="button" id="closeDialog" value="<?php echo $this->translate('OK') ?>" onclick="COMMID.sitesList.closeDialog()" />
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Install_CompleteController extends Monkeys_Controller_Action
|
||||
class Install_CompleteController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Install_CredentialsController extends Monkeys_Controller_Action
|
||||
class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
@ -24,13 +24,13 @@ class Install_CredentialsController extends Monkeys_Controller_Action
|
||||
$this->view->form = $appSession->installForm;
|
||||
unset($appSession->installForm);
|
||||
} else {
|
||||
$this->view->form = new InstallForm();
|
||||
$this->view->form = new Install_Form_Install();
|
||||
}
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$form = new InstallForm();
|
||||
$form = new Install_Form_Install();
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
@ -53,13 +53,13 @@ class Install_CredentialsController extends Monkeys_Controller_Action
|
||||
$this->_importDb();
|
||||
|
||||
if (!$this->_writeConfig($form)) {
|
||||
throw new Exception('Couldn\'t write to config file file ' . APP_DIR . DIRECTORY_SEPARATOR . 'config.php');
|
||||
throw new Exception('Couldn\'t write to config file ' . APP_DIR . DIRECTORY_SEPARATOR . 'config.php');
|
||||
}
|
||||
|
||||
$this->_forward('index', 'complete');
|
||||
}
|
||||
|
||||
private function _connectToDbEngine(InstallForm $form)
|
||||
private function _connectToDbEngine(Install_Form_Install $form)
|
||||
{
|
||||
$this->_config->database->params->host = $form->getValue('hostname');
|
||||
$this->_config->database->params->username = $form->getValue('dbusername');
|
||||
@ -69,10 +69,10 @@ class Install_CredentialsController extends Monkeys_Controller_Action
|
||||
// without attempting to connect to the dbname
|
||||
$this->_config->database->params->dbname = null;
|
||||
|
||||
return Setup::setDatabase();
|
||||
return Application::setDatabase();
|
||||
}
|
||||
|
||||
private function _createDbIfMissing(InstallForm $form)
|
||||
private function _createDbIfMissing(Install_Form_Install $form)
|
||||
{
|
||||
$this->_config->database->params->host = $form->getValue('hostname');
|
||||
$this->_config->database->params->username = $form->getValue('dbusername');
|
||||
@ -80,15 +80,15 @@ class Install_CredentialsController extends Monkeys_Controller_Action
|
||||
|
||||
$this->_config->database->params->dbname = $form->getValue('dbname');
|
||||
|
||||
if (!Setup::setDatabase()) {
|
||||
if (!Application::setDatabase()) {
|
||||
try {
|
||||
$this->_config->database->params->dbname = null;
|
||||
Setup::setDatabase();
|
||||
Application::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();
|
||||
Application::setDatabase();
|
||||
} catch (PDOException $e) { // when using PDO, it throws this exception, not Zend's
|
||||
return false;
|
||||
}
|
||||
@ -97,7 +97,7 @@ class Install_CredentialsController extends Monkeys_Controller_Action
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _writeConfig(InstallForm $form)
|
||||
private function _writeConfig(Install_Form_Install $form)
|
||||
{
|
||||
$this->_config->environment->installed = true;
|
||||
$this->_config->email->supportemail = $form->getValue('supportemail');
|
||||
@ -113,8 +113,6 @@ class Install_CredentialsController extends Monkeys_Controller_Action
|
||||
'{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',
|
||||
@ -168,7 +166,7 @@ class Install_CredentialsController extends Monkeys_Controller_Action
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
private function _forwardFormError(InstallForm $form)
|
||||
private function _forwardFormError(Install_Form_Install $form)
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->installForm = $form;
|
||||
@ -181,7 +179,7 @@ class Install_CredentialsController extends Monkeys_Controller_Action
|
||||
$errors = array();
|
||||
$webServerUser = $this->_getProcessUser();
|
||||
|
||||
if (!is_writable(APP_DIR) && !is_writable(APP_DIR . '/config.php')) {
|
||||
if (!is_writable(APP_DIR) && !is_writable(APP_DIR . DIRECTORY_SEPARATOR . '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')) {
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Install_IndexController extends Monkeys_Controller_Action
|
||||
class Install_IndexController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Install_PermissionsController extends Monkeys_Controller_Action
|
||||
class Install_PermissionsController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
|
125
modules/install/controllers/UpgradeController.php
Normal file
125
modules/install/controllers/UpgradeController.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?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_UpgradeController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
// double check upgrade is necessary in case someone access this action directly
|
||||
if (!$this->_needsUpgrade()) {
|
||||
$this->_redirect('');
|
||||
return;
|
||||
}
|
||||
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->loginForm)) {
|
||||
$this->view->loginForm = $appSession->loginForm;
|
||||
unset($appSession->loginForm);
|
||||
} else {
|
||||
$this->view->loginForm = new Install_Form_UpgradeLogin();
|
||||
}
|
||||
}
|
||||
|
||||
public function proceedAction()
|
||||
{
|
||||
// double check upgrade is necessary in case someone access this action directly
|
||||
if (!$this->_needsUpgrade()) {
|
||||
$this->_redirect('');
|
||||
return;
|
||||
}
|
||||
|
||||
$form = new Install_Form_UpgradeLogin();
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->loginForm = $form;
|
||||
$this->_forward('index');
|
||||
return;
|
||||
}
|
||||
|
||||
$users = new Users_Model_Users();
|
||||
$result = $users->authenticate($this->_request->getPost('username'),
|
||||
$this->_request->getPost('password'));
|
||||
|
||||
if (!$result) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials'));
|
||||
$this->_redirect('index');
|
||||
return;
|
||||
}
|
||||
|
||||
$user = $users->getUser();
|
||||
if ($user->role != Users_Model_User::ROLE_ADMIN) {
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials'));
|
||||
$this->_redirect('index');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_runUpgrades(true);
|
||||
$upgradedVersion = $this->_runUpgrades(false);
|
||||
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Upgrade was successful. You are now on version %s', $upgradedVersion));
|
||||
$this->_redirect('/');
|
||||
}
|
||||
|
||||
private function _runUpgrades($onlyCheckFiles = true)
|
||||
{
|
||||
require 'setup/versions.php';
|
||||
|
||||
$includeFiles = false;
|
||||
$db = Zend_Registry::get('db');
|
||||
foreach ($versions as $version) {
|
||||
if ($version == $this->_getDbVersion()) {
|
||||
$includeFiles = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$includeFiles) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fileName = APP_DIR . '/setup/upgrade_'.$version.'.sql';
|
||||
|
||||
if ($onlyCheckFiles) {
|
||||
if (!file_exists($fileName)) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Correct before upgrading: File %s is required to proceed', $fileName));
|
||||
$this->_redirect('index');
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$query = '';
|
||||
$lines = file($fileName);
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
if ($line != '') {
|
||||
$query .= $line;
|
||||
}
|
||||
if (substr($line, -1) == ';') {
|
||||
try {
|
||||
$db->query($query);
|
||||
} catch (Zend_Db_Statement_Mysqli_Exception $e) {
|
||||
Zend_Registry::get('logger')->log("Error in this query: $query", Zend_Log::ERR);
|
||||
throw $e;
|
||||
}
|
||||
$query = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
}
|
44
modules/install/forms/Install.php
Normal file
44
modules/install/forms/Install.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 CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Install_Form_Install 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));
|
||||
}
|
||||
}
|
29
modules/install/forms/UpgradeLogin.php
Normal file
29
modules/install/forms/UpgradeLogin.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?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 CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Install_Form_UpgradeLogin extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$username = new Monkeys_Form_Element_Text('username');
|
||||
translate('Username');
|
||||
$username->setLabel('Username')
|
||||
->addValidator(new Monkeys_Validate_Username())
|
||||
->setRequired(true);
|
||||
|
||||
$password = new Monkeys_Form_Element_Password('password');
|
||||
$password->setLabel('Password')
|
||||
->setRequired(true);
|
||||
|
||||
$this->addElements(array($username, $password));
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<h3>
|
||||
<?= $this->translate('The installation was performed successfully') ?>
|
||||
<?php echo $this->translate('The installation was performed successfully') ?>
|
||||
</h3>
|
||||
<div style="margin-top:20px">
|
||||
<div>
|
||||
@ -7,13 +7,13 @@
|
||||
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') ?>" />
|
||||
<input type="button" id="start" value="<?php echo $this->translate('Finish') ?>" />
|
||||
<div>
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"start",
|
||||
{
|
||||
onclick: {fn: function() {location.href="<?= $this->base ?>"}}
|
||||
onclick: {fn: function() {location.href="<?php echo $this->base ?>"}}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
@ -1,15 +1,15 @@
|
||||
<h3>
|
||||
<?= $this->translate('Database and E-mail information') ?>
|
||||
<?php echo $this->translate('Database and E-mail information') ?>
|
||||
</h3>
|
||||
<form name="installform" method="post" action="<?= $this->base ?>/install/credentials/save" class="longLabelsForm">
|
||||
<form name="installform" method="post" action="<?php echo $this->base ?>/install/credentials/save" class="longLabelsForm">
|
||||
<dl>
|
||||
<?= $this->form->hostname ?>
|
||||
<?= $this->form->dbname ?>
|
||||
<?= $this->form->dbusername ?>
|
||||
<?= $this->form->dbpassword ?>
|
||||
<?= $this->form->supportemail ?>
|
||||
<?php echo $this->form->hostname ?>
|
||||
<?php echo $this->form->dbname ?>
|
||||
<?php echo $this->form->dbusername ?>
|
||||
<?php echo $this->form->dbpassword ?>
|
||||
<?php echo $this->form->supportemail ?>
|
||||
</dl>
|
||||
<input type="submit" id="send" value="<?= $this->translate('Send') ?>" />
|
||||
<input type="submit" id="send" value="<?php echo $this->translate('Send') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("send");
|
||||
</script>
|
||||
|
@ -1,13 +1,13 @@
|
||||
<h3>
|
||||
<?= $this->translate('This Community-ID instance hasn\'t been installed yet') ?>
|
||||
<?php echo $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')?>" />
|
||||
<input type="button" id="start" value="<?php echo $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"}}
|
||||
onclick: {fn: function() {location.href="<?php echo $this->base ?>/install/credentials"}}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
@ -1,18 +1,18 @@
|
||||
<h3>
|
||||
<?= $this->translate('Please correct the following problems before proceeding:') ?>
|
||||
<?php echo $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 ?>
|
||||
<?php foreach ($this->errors as $error): ?>
|
||||
<li style="list-style-type:circle"><?php echo $error ?></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<div style="margin-top:20px">
|
||||
<input type="button" id="check" value="<?= $this->translate('Check again')?>" />
|
||||
<input type="button" id="check" value="<?php echo $this->translate('Check again')?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"check",
|
||||
{
|
||||
onclick: {fn: function() {location.href="<?= $this->base ?>/install/credentials"}}
|
||||
onclick: {fn: function() {location.href="<?php echo $this->base ?>/install/credentials"}}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
15
modules/install/views/scripts/upgrade/index.phtml
Normal file
15
modules/install/views/scripts/upgrade/index.phtml
Normal file
@ -0,0 +1,15 @@
|
||||
<h2><?php echo $this->translate('New version detected') ?></h2>
|
||||
<div>
|
||||
<?php echo $this->translate('Enter the administrator credentials to proceed with the upgrade:') ?>
|
||||
</div>
|
||||
<div>
|
||||
<em><?php echo $this->translate('Make sure you make a copy of the database before, just in case') ?></em>
|
||||
</div>
|
||||
<form action="<?php echo $this->base ?>/install/upgrade/proceed" method="post" class="formGrid" style="margin-top:30px">
|
||||
<?php echo $this->loginForm->username ?>
|
||||
<?php echo $this->loginForm->password ?>
|
||||
<input type="submit" id="send" value="<?php echo $this->translate('Send') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("send");
|
||||
</script>
|
||||
</form>
|
98
modules/news/controllers/EditController.php
Normal file
98
modules/news/controllers/EditController.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?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 News_EditController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 2;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->articleForm)) {
|
||||
$this->view->articleForm = $appSession->articleForm;
|
||||
unset($appSession->articleForm);
|
||||
} else {
|
||||
$this->view->articleForm = new News_Form_Article();
|
||||
$news = new News_Model_News();
|
||||
if ($this->_getParam('id') && ($article = $news->getRowInstance($this->_getParam('id')))) {
|
||||
$this->view->articleForm->populate(array(
|
||||
'title' => $article->title,
|
||||
'date' => $article->date,
|
||||
'excerpt' => $article->excerpt,
|
||||
'content' => $article->content,
|
||||
));
|
||||
$this->view->articleId = $article->id;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function addAction()
|
||||
{
|
||||
$this->_forward('index');
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$form = new News_Form_Article();
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->articleForm = $form;
|
||||
$this->_forward('index');
|
||||
return;
|
||||
}
|
||||
|
||||
$news = new News_Model_News();
|
||||
if ($this->_getParam('id')) {
|
||||
if (!$article = $news->getRowInstance($this->_getParam('id'))) {
|
||||
$this->_helper->FlashMessenger->addMessage('Article doesn\'t exist.');
|
||||
$this->_redirect('/news');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$article = $news->createRow();
|
||||
}
|
||||
|
||||
|
||||
require_once 'htmlpurifier/library/HTMLPurifier.auto.php';
|
||||
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$purifier = new HTMLPurifier($config);
|
||||
$cleanHtml = $purifier->purify($form->getValue('content'));
|
||||
|
||||
$article->title = $form->getValue('title');
|
||||
$article->date = $form->getValue('date');
|
||||
$article->excerpt = $form->getValue('excerpt');
|
||||
$article->content = $cleanHtml;
|
||||
$article->save();
|
||||
|
||||
$this->_helper->FlashMessenger->addMessage('The article has been saved.');
|
||||
|
||||
$this->_redirect('/news');
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$news = new News_Model_News();
|
||||
if (!$article = $news->getRowInstance($this->_getParam('id'))) {
|
||||
$this->_helper->FlashMessenger->addMessage('The article doesn\'t exist.');
|
||||
} else {
|
||||
$article->delete();
|
||||
$this->_helper->FlashMessenger->addMessage('The article has been deleted.');
|
||||
}
|
||||
|
||||
$this->_redirect('/news');
|
||||
}
|
||||
}
|
23
modules/news/controllers/IndexController.php
Normal file
23
modules/news/controllers/IndexController.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?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 News_IndexController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$news = new News_Model_News();
|
||||
|
||||
$this->view->paginator = $news->getArticlesPaginator(News_Model_News::RECORDS_PER_PAGE,
|
||||
$this->_getParam('page', 0), $this->user);
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
}
|
25
modules/news/controllers/ViewController.php
Normal file
25
modules/news/controllers/ViewController.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 Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class News_ViewController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$news = new News_Model_News();
|
||||
$this->view->article = $news->getRowInstance($this->_getParam('id'));
|
||||
|
||||
if ($this->view->article->date > date('Y-m-d H:i:s') && $this->user->role != Users_Model_User::ROLE_ADMIN) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
}
|
44
modules/news/forms/Article.php
Normal file
44
modules/news/forms/Article.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 CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class News_Form_Article extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$title = new Monkeys_Form_Element_Text('title');
|
||||
translate('Title');
|
||||
$title->setLabel('Title')
|
||||
->setRequired(true)
|
||||
->setAttrib('style', 'width:350px');
|
||||
|
||||
$date = new Monkeys_Form_Element_DateTime('date');
|
||||
translate('Publication date');
|
||||
$date->setLabel('Publication date')
|
||||
->setShowEmptyValues(false)
|
||||
->setStartEndYear(1900, date('Y') + 1)
|
||||
->setReverseYears(true)
|
||||
->setValue(date('Y-m-d H:i'));
|
||||
|
||||
$excerpt = new Monkeys_Form_Element_Textarea('excerpt');
|
||||
translate('Excerpt');
|
||||
$excerpt->setLabel('Excerpt')
|
||||
->setAttrib('style', 'width:350px')
|
||||
->setAttrib('rows', 4);
|
||||
|
||||
$content = new Monkeys_Form_Element_Richtextarea('content');
|
||||
$content->setDecoratorOptions(array('separateLine' => true))
|
||||
->setAttrib('width', '510px')
|
||||
->setRequired(true);
|
||||
|
||||
$this->addElements(array($title, $date, $excerpt, $content));
|
||||
}
|
||||
}
|
58
modules/news/models/News.php
Normal file
58
modules/news/models/News.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 Monkeys Ltd.
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class News_Model_News extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
const RECORDS_PER_PAGE = 5;
|
||||
|
||||
protected $_name = 'news';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'News_Model_NewsArticle';
|
||||
|
||||
private $_sortFields = array(
|
||||
'date' => array('date', 'title'),
|
||||
'title' => array('title', 'date')
|
||||
);
|
||||
|
||||
public function getArticlesPaginator($limit = self::RECORDS_PER_PAGE, $page = 0, Users_Model_User $user)
|
||||
{
|
||||
$select = $this->select()->order('date DESC');
|
||||
|
||||
if ($user->role != Users_Model_User::ROLE_ADMIN) {
|
||||
$select = $select->where('date <= ?', date('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbTableSelect($select));
|
||||
$paginator->setItemCountPerPage($limit);
|
||||
$paginator->setCurrentPageNumber($page);
|
||||
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
public function getLatest($numItems, Users_Model_User $user)
|
||||
{
|
||||
$select = $this->select()
|
||||
->order('date DESC')
|
||||
->limit($numItems);
|
||||
|
||||
if ($user->role != Users_Model_User::ROLE_ADMIN) {
|
||||
$select = $select->where('date <= ?', date('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function deleteTestEntries()
|
||||
{
|
||||
$this->delete('test=1');
|
||||
}
|
||||
}
|
14
modules/news/models/NewsArticle.php
Normal file
14
modules/news/models/NewsArticle.php
Normal 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 Monkeys Ltd.
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class News_Model_NewsArticle extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
}
|
28
modules/news/views/scripts/edit/index.phtml
Normal file
28
modules/news/views/scripts/edit/index.phtml
Normal file
@ -0,0 +1,28 @@
|
||||
<form method="post" action="<?php echo $this->base ?>/news/edit/save" class="formGrid">
|
||||
<input type="hidden" name="id" value="<?= $this->articleId ?>" />
|
||||
<?php echo $this->articleForm->title ?>
|
||||
<?php echo $this->articleForm->excerpt ?>
|
||||
<?php echo $this->articleForm->date ?>
|
||||
<?php echo $this->articleForm->content ?>
|
||||
<div>
|
||||
<input type="submit" id="save" value="<?php echo $this->translate('Save') ?>" />
|
||||
<input type="button" id="cancel" value="<?php echo $this->translate('Cancel') ?>" />
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
new YAHOO.widget.Button(
|
||||
"save",
|
||||
{
|
||||
type : "submit"
|
||||
}
|
||||
);
|
||||
new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {COMMID.editArticle.cancel(<?php echo $this->articleId ?>)}}
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</form>
|
34
modules/news/views/scripts/index/index.phtml
Normal file
34
modules/news/views/scripts/index/index.phtml
Normal file
@ -0,0 +1,34 @@
|
||||
<?php if ($this->user->role == Users_Model_User::ROLE_ADMIN): ?>
|
||||
<div class="linksTopRightContainer">
|
||||
<h2><?php echo $this->translate('Latest News') ?></h2>
|
||||
<div class="linksTopRight">
|
||||
<a href="<?php echo $this->base ?>/news/edit/add"><?php echo $this->translate('Add New Article') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php if (count($this->paginator) == 0): ?>
|
||||
<div><?= $this->translate('There are no news articles yet') ?></div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($this->paginator as $article): ?>
|
||||
<div class="post">
|
||||
<h3><a href="<?php echo $this->base . '/news/' . $article->id ?>"><?php echo $article->title ?></a></h3>
|
||||
<div class="article_date">
|
||||
<?php echo $this->translate("Published on %s", $article->date) ?>
|
||||
</div>
|
||||
<p><?php echo $article->excerpt ?></p>
|
||||
<p class="more">
|
||||
<a href="<?php echo $this->base . '/news/' . $article->id ?>">
|
||||
<?php echo $this->translate('read more') ?>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif ?>
|
||||
<?php if ($this->paginator->count() > 1): ?>
|
||||
<?php echo $this->paginationControl($this->paginator,
|
||||
'Sliding',
|
||||
'index/pagination.phtml',
|
||||
array(
|
||||
'base' => $this->base
|
||||
)) ?>
|
||||
<?php endif ?>
|
36
modules/news/views/scripts/index/pagination.phtml
Normal file
36
modules/news/views/scripts/index/pagination.phtml
Normal file
@ -0,0 +1,36 @@
|
||||
<!--
|
||||
See http://developer.yahoo.com/ypatterns/pattern.php?pattern=searchpagination
|
||||
-->
|
||||
|
||||
<?php if ($this->pageCount): ?>
|
||||
<div class="paginationControl">
|
||||
<!-- Previous page link -->
|
||||
<?php if (isset($this->previous)): ?>
|
||||
<a href="<?php echo $this->base . '/news?page=' . $this->previous ?>">
|
||||
< <?php echo $this->translate('Previous') ?>
|
||||
</a> |
|
||||
<?php else: ?>
|
||||
<span class="disabled">< <?php echo $this->translate('Previous') ?></span> |
|
||||
<?php endif ?>
|
||||
|
||||
<!-- Numbered page links -->
|
||||
<?php foreach ($this->pagesInRange as $page): ?>
|
||||
<?php if ($page != $this->current): ?>
|
||||
<a href="<?php echo $this->base . '/news?page=' . $page ?>">
|
||||
<?php echo $page; ?>
|
||||
</a> |
|
||||
<?php else: ?>
|
||||
<?php echo $page; ?> |
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
|
||||
<!-- Next page link -->
|
||||
<?php if (isset($this->next)): ?>
|
||||
<a href="<?php echo $this->base . '/news?page=' . $this->next ?>">
|
||||
<?php echo $this->translate('Next') ?> >
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span class="disabled"><?php echo $this->translate('Next') ?> ></span>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php endif ?>
|
15
modules/news/views/scripts/view/index.phtml
Normal file
15
modules/news/views/scripts/view/index.phtml
Normal file
@ -0,0 +1,15 @@
|
||||
<h2><?= $this->escape($this->article->title) ?></h2>
|
||||
<div class="article_date">
|
||||
<?php echo $this->translate('Published on %s', $this->article->date) ?>
|
||||
<?php if ($this->user->role == Users_Model_User::ROLE_ADMIN): ?>
|
||||
<div class="linksTopRight">
|
||||
<a href="<?php echo $this->base . '/news/edit/index/id/' . $this->article->id ?>"><?php echo $this->translate('Edit Article') ?></a> |
|
||||
<a href="#" onclick="COMMID.editArticle.remove(<?php echo $this->article->id ?>);return false;"><?php echo $this->translate('Delete Article') ?></a>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<p><?= $this->escape($this->article->excerpt) ?></p>
|
||||
<hr />
|
||||
<div>
|
||||
<?php echo $this->article->content ?>
|
||||
</div>
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_AuthorizationsController extends Monkeys_Controller_Action
|
||||
class Stats_AuthorizationsController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
@ -71,13 +71,13 @@ class Stats_AuthorizationsController extends Monkeys_Controller_Action
|
||||
|
||||
private function _populateWeekData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$stats = new Stats_Model_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)];
|
||||
$labelsy[] = Stats_Model_Stats::$weekDays[date('w', $time)];
|
||||
if (isset($authorizations[$date])) {
|
||||
$datay[] = $authorizations[$date]['entry'];
|
||||
} else {
|
||||
@ -88,14 +88,14 @@ class Stats_AuthorizationsController extends Monkeys_Controller_Action
|
||||
|
||||
private function _populateYearData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$stats = new Stats_Model_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];
|
||||
$labelsy[] = Stats_Model_Stats::$months[$monthNumber];
|
||||
if (isset($authorizations[$monthNumber])) {
|
||||
$datay[] = $authorizations[$monthNumber]['entry'];
|
||||
} else {
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_IndexController extends Monkeys_Controller_Action
|
||||
class Stats_IndexController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_RegistrationsController extends Monkeys_Controller_Action
|
||||
class Stats_RegistrationsController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
@ -78,13 +78,13 @@ class Stats_RegistrationsController extends Monkeys_Controller_Action
|
||||
|
||||
private function _populateWeekData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$stats = new Stats_Model_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)];
|
||||
$labelsy[] = Stats_Model_Stats::$weekDays[date('w', $time)];
|
||||
if (isset($registeredUsers[$date])) {
|
||||
$datay[] = $registeredUsers[$date]['users'];
|
||||
} else {
|
||||
@ -95,7 +95,7 @@ class Stats_RegistrationsController extends Monkeys_Controller_Action
|
||||
|
||||
private function _populateMonthData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$stats = new Stats_Model_Stats();
|
||||
$registeredUsers = $stats->getNumRegisteredUsersDays(strtotime('-30 days'), strtotime('-1 week'));
|
||||
|
||||
for ($i = -30; $i < -7; $i++) {
|
||||
@ -112,14 +112,14 @@ class Stats_RegistrationsController extends Monkeys_Controller_Action
|
||||
|
||||
private function _populateYearData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$stats = new Stats_Model_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];
|
||||
$labelsy[] = Stats_Model_Stats::$months[$monthNumber];
|
||||
if (isset($registeredUsers[$monthNumber])) {
|
||||
$datay[] = $registeredUsers[$monthNumber]['users'];
|
||||
} else {
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_SitesController extends Monkeys_Controller_Action
|
||||
class Stats_SitesController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
@ -85,7 +85,7 @@ class Stats_SitesController extends Monkeys_Controller_Action
|
||||
|
||||
private function _populateWeekData(&$labelsy, &$datay, &$datay2)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$stats = new Stats_Model_Stats();
|
||||
$initialTrustedSites = $stats->getNumTrustedSites(strtotime('-1 week'));
|
||||
$initialRegisteredUsers = $stats->getNumRegisteredUsers(strtotime('-1 week'));
|
||||
|
||||
@ -95,7 +95,7 @@ class Stats_SitesController extends Monkeys_Controller_Action
|
||||
for ($i = -7; $i < 0; $i++) {
|
||||
$time = strtotime("$i days");
|
||||
$date = date('Y-m-d', $time);
|
||||
$labelsy[] = Stats::$weekDays[date('w', $time)];
|
||||
$labelsy[] = Stats_Model_Stats::$weekDays[date('w', $time)];
|
||||
|
||||
if (isset($sites[$date])) {
|
||||
$sitesPeriod = $sites[$date]['site'];
|
||||
@ -125,7 +125,7 @@ class Stats_SitesController extends Monkeys_Controller_Action
|
||||
|
||||
private function _populateYearData(&$labelsy, &$datay, &$datay2)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$stats = new Stats_Model_Stats();
|
||||
$initialTrustedSites = $stats->getNumTrustedSites(strtotime('-1 week'));
|
||||
$initialRegisteredUsers = $stats->getNumRegisteredUsers(strtotime('-1 week'));
|
||||
|
||||
@ -137,7 +137,7 @@ class Stats_SitesController extends Monkeys_Controller_Action
|
||||
for ($i = -11; $i <= 0; $i++) {
|
||||
$time = strtotime("$i months");
|
||||
$monthNumber = date('n', $time);
|
||||
$labelsy[] = Stats::$months[$monthNumber];
|
||||
$labelsy[] = Stats_Model_Stats::$months[$monthNumber];
|
||||
|
||||
if (isset($sites[$monthNumber])) {
|
||||
$sitesPeriod = $sites[$monthNumber]['site'];
|
||||
|
@ -9,11 +9,11 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_TopController extends Monkeys_Controller_Action
|
||||
class Stats_TopController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$stats = new Stats();
|
||||
$stats = new Stats_Model_Stats();
|
||||
$this->view->sites = $stats->getTopTenSites();
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,13 @@
|
||||
* @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
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Stats
|
||||
class Stats_Model_Stats
|
||||
{
|
||||
private $_db;
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
<h3><?= $this->translate('Authorizations per day') ?></h3>
|
||||
<h3><?php echo $this->translate('Authorizations per day') ?></h3>
|
||||
<div>
|
||||
<?= $this->translate('Select view') ?>:
|
||||
<?php echo $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>
|
||||
<option value="week" <?php echo $this->weekSelected ?>><?= $this->translate('Last Week') ?></option>
|
||||
<option value="year" <?php echo $this->yearSelected ?>><?= $this->translate('Last Year') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<img src="<?= $this->base ?>/stats/authorizations/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
||||
<img src="<?php echo $this->base ?>/stats/authorizations/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
<h3><?= $this->translate('Registrations per day') ?></h3>
|
||||
<h3><?php echo $this->translate('Registrations per day') ?></h3>
|
||||
<div>
|
||||
<?= $this->translate('Select view') ?>:
|
||||
<?php echo $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>
|
||||
<option value="week" <?php echo $this->weekSelected ?>><?= $this->translate('Last Week') ?></option>
|
||||
<option value="month" <?php echo $this->monthSelected ?>><?= $this->translate('Last Month') ?></option>
|
||||
<option value="year" <?php echo $this->yearSelected ?>><?= $this->translate('Last Year') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<img src="<?= $this->base ?>/stats/registrations/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
||||
<img src="<?php echo $this->base ?>/stats/registrations/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
||||
|
@ -1,9 +1,9 @@
|
||||
<h3><?= $this->translate('Trusted Sites') ?></h3>
|
||||
<h3><?php echo $this->translate('Trusted Sites') ?></h3>
|
||||
<div>
|
||||
<?= $this->translate('Select view') ?>:
|
||||
<?php echo $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>
|
||||
<option value="week" <?php echo $this->weekSelected ?>><?= $this->translate('Last Week') ?></option>
|
||||
<option value="year" <?php echo $this->yearSelected ?>><?= $this->translate('Last Year') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<img src="<?= $this->base ?>/stats/sites/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
||||
<img src="<?php echo $this->base ?>/stats/sites/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
||||
|
@ -1,10 +1,10 @@
|
||||
<h3><?= $this->translate('Top 10 Trusted Sites') ?></h3>
|
||||
<h3><?php echo $this->translate('Top 10 Trusted Sites') ?></h3>
|
||||
<table id="topTenTable">
|
||||
<? foreach ($this->sites as $num => $siteInfo): ?>
|
||||
<?php foreach ($this->sites as $num => $siteInfo): ?>
|
||||
<tr>
|
||||
<td><?= $num + 1 ?></td>
|
||||
<td><?= $siteInfo['site'] ?></td>
|
||||
<td>(<?= $this->translate('%s users', $siteInfo['num']) ?>)</td>
|
||||
<td><?php echo $num + 1 ?></td>
|
||||
<td><?php echo $siteInfo['site'] ?></td>
|
||||
<td>(<?php echo $this->translate('%s users', $siteInfo['num']) ?>)</td>
|
||||
</tr>
|
||||
<? endforeach ?>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
|
@ -9,20 +9,20 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_LoginController extends Monkeys_Controller_Action
|
||||
/**
|
||||
* We don't use the session with the login form to simplify the dynamic appearance of the captcha
|
||||
*/
|
||||
class Users_LoginController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$settings = new Settings();
|
||||
$settings = new Model_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();
|
||||
}
|
||||
$authAttempts = new Users_Model_AuthAttempts();
|
||||
$attempt = $authAttempts->get();
|
||||
$this->view->useCaptcha = $attempt && $attempt->surpassedMaxAllowed();
|
||||
$this->view->loginForm = new Users_Form_Login(null, $this->view->base, $this->view->useCaptcha);
|
||||
|
||||
if ($this->_config->SSL->enable_mixed_mode) {
|
||||
$this->view->loginTargetBase = 'https://' . $_SERVER['HTTP_HOST'] . $this->view->base;
|
||||
@ -35,46 +35,43 @@ class Users_LoginController extends Monkeys_Controller_Action
|
||||
|
||||
public function authenticateAction()
|
||||
{
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$authAttempts = new Users_Model_AuthAttempts();
|
||||
$attempt = $authAttempts->get();
|
||||
|
||||
$form = new LoginForm();
|
||||
$form = new Users_Form_Login(null, $this->view->base, $attempt && $attempt->surpassedMaxAllowed());
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession->loginForm = $form;
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials'));
|
||||
$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'));
|
||||
$users = new Users_Model_Users();
|
||||
$result = $users->authenticate($this->_request->getPost('username'),
|
||||
$this->_request->getPost('password'));
|
||||
|
||||
$result = $auth->authenticate($authAdapter);
|
||||
if ($result) {
|
||||
$user = $users->getUser();
|
||||
|
||||
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) {
|
||||
if ($attempt) {
|
||||
$attempt = $authAttempts->delete();
|
||||
}
|
||||
|
||||
if ($user->role != Users_Model_User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
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);
|
||||
}
|
||||
return $this->_redirectForMaintenance(true);
|
||||
}
|
||||
} else {
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid credentials');
|
||||
$appSession->loginForm = $form;
|
||||
if (!$attempt) {
|
||||
$authAttempts->create();
|
||||
} else {
|
||||
$attempt->addFailure();
|
||||
$attempt->save();
|
||||
}
|
||||
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials'));
|
||||
}
|
||||
|
||||
$this->_redirectToNormalConnection('');
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_ManageusersController extends Monkeys_Controller_Action
|
||||
class Users_ManageusersController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
@ -27,7 +27,76 @@ class Users_ManageusersController extends Monkeys_Controller_Action
|
||||
|
||||
public function deleteunconfirmedAction()
|
||||
{
|
||||
$users = new Users();
|
||||
$users->deleteUnconfirmed();
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$users = new Users_Model_Users();
|
||||
$users->deleteUnconfirmed($this->_getParam('olderthan'));
|
||||
}
|
||||
|
||||
public function sendreminderAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$users = new Users_Model_Users();
|
||||
foreach ($users->getUnconfirmedUsers($this->_getParam('olderthan')) as $user) {
|
||||
$mail = self::getMail($user, $this->view->translate('Community-ID registration reminder'));
|
||||
try {
|
||||
$mail->send();
|
||||
} catch (Zend_Mail_Protocol_Exception $e) {
|
||||
Zend_Registry::get('logger')->log($e->getMessage(), Zend_Log::ERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Zend_Mail
|
||||
* @throws Zend_Mail_Protocol_Exception
|
||||
*/
|
||||
public static function getMail(User $user, $subject)
|
||||
{
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
if (file_exists(APP_DIR . "/resources/$locale/reminder_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/$locale/reminder_mail.txt";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/reminder_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/".$localeElements[0]."/reminder_mail.txt";
|
||||
} else {
|
||||
$file = APP_DIR . "/resources/en/reminder_mail.txt";
|
||||
}
|
||||
|
||||
$emailTemplate = file_get_contents($file);
|
||||
$emailTemplate = str_replace('{userName}', $user->getFullName(), $emailTemplate);
|
||||
|
||||
$currentUrl = Zend_OpenId::selfURL();
|
||||
preg_match('#(.*)/manageusers/sendreminder#', $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('UTF-8');
|
||||
$mail->setBodyText($emailTemplate);
|
||||
$mail->setFrom($configEmail->supportemail);
|
||||
$mail->addTo($user->email);
|
||||
$mail->setSubject($subject);
|
||||
|
||||
return $mail;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_PersonalinfoController extends Monkeys_Controller_Action
|
||||
class Users_PersonalinfoController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
@ -18,7 +18,7 @@ class Users_PersonalinfoController extends Monkeys_Controller_Action
|
||||
|
||||
public function showAction()
|
||||
{
|
||||
$fields = new Fields();
|
||||
$fields = new Model_Fields();
|
||||
$this->view->fields = $fields->getValues($this->user);
|
||||
}
|
||||
|
||||
@ -29,14 +29,14 @@ class Users_PersonalinfoController extends Monkeys_Controller_Action
|
||||
$this->view->fields = $appSession->personalInfoForm->getElements();
|
||||
unset($appSession->personalInfoForm);
|
||||
} else {
|
||||
$personalInfoForm = new PersonalInfoForm(null, $this->user);
|
||||
$personalInfoForm = new Users_Form_PersonalInfo(null, $this->user);
|
||||
$this->view->fields = $personalInfoForm->getElements();
|
||||
}
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$form = new PersonalInfoForm(null, $this->user);
|
||||
$form = new Users_Form_PersonalInfo(null, $this->user);
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
@ -47,7 +47,7 @@ class Users_PersonalinfoController extends Monkeys_Controller_Action
|
||||
return;
|
||||
}
|
||||
|
||||
$fieldsValues = new FieldsValues();
|
||||
$fieldsValues = new Model_FieldsValues();
|
||||
$fieldsValues->deleteForUser($this->user);
|
||||
|
||||
foreach ($form->getValues() as $fieldName => $fieldValue) {
|
||||
|
@ -9,11 +9,11 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_ProfileController extends Monkeys_Controller_Action
|
||||
class Users_ProfileController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (!$this->targetUser->id && $this->user->role != User::ROLE_ADMIN) {
|
||||
if (!$this->targetUser->id && $this->user->role != Users_Model_User::ROLE_ADMIN) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
|
@ -9,13 +9,13 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_ProfilegeneralController extends Monkeys_Controller_Action
|
||||
class Users_ProfilegeneralController extends CommunityID_Controller_Action
|
||||
{
|
||||
private $_users;
|
||||
|
||||
public function preDispatch()
|
||||
{
|
||||
if ($this->user->role != User::ROLE_ADMIN
|
||||
if ($this->user->role != Users_Model_User::ROLE_ADMIN
|
||||
&& $this->targetUser->id != $this->user->id)
|
||||
{
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
@ -30,7 +30,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
|
||||
{
|
||||
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))
|
||||
&& ($this->targetUser->id != 0 || $this->user->role != Users_Model_User::ROLE_ADMIN))
|
||||
{
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
@ -40,7 +40,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
|
||||
$this->view->accountInfoForm = $appSession->accountInfoForm;
|
||||
unset($appSession->accountInfoForm);
|
||||
} else {
|
||||
$this->view->accountInfoForm = new AccountInfoForm(null, $this->targetUser);
|
||||
$this->view->accountInfoForm = new Users_Form_AccountInfo(null, $this->targetUser);
|
||||
$this->view->accountInfoForm->populate(array(
|
||||
'username' => $this->targetUser->username,
|
||||
'firstname' => $this->targetUser->firstname,
|
||||
@ -59,7 +59,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$form = new AccountInfoForm(null, $this->targetUser);
|
||||
$form = new Users_Form_AccountInfo(null, $this->targetUser);
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
@ -98,7 +98,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
|
||||
$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->role = Users_Model_User::ROLE_REGISTERED;
|
||||
$this->targetUser->setClearPassword($form->getValue('password1'));
|
||||
}
|
||||
$this->targetUser->save();
|
||||
@ -115,7 +115,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
|
||||
private function _usernameAlreadyExists($username)
|
||||
{
|
||||
$users = $this->_getUsers();
|
||||
return $users->getUser($username);
|
||||
return $users->getUserWithUsername($username);
|
||||
}
|
||||
|
||||
private function _emailAlreadyExists($email)
|
||||
@ -154,7 +154,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
|
||||
$this->view->changePasswordForm = $appSession->changePasswordForm;
|
||||
unset($appSession->changePasswordForm);
|
||||
} else {
|
||||
$this->view->changePasswordForm = new ChangePasswordForm();
|
||||
$this->view->changePasswordForm = new Users_Form_ChangePassword();
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$form = new ChangePasswordForm();
|
||||
$form = new Users_Form_ChangePassword();
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
@ -252,7 +252,7 @@ EOT;
|
||||
}
|
||||
|
||||
if ($this->_config->subdomain->enabled) {
|
||||
$openid = $this->_getProtocol() . '://' . $username . '.' . $this->_config->subdomain->hostname;
|
||||
$openid = $this->getProtocol() . '://' . $username . '.' . $this->_config->subdomain->hostname;
|
||||
} else {
|
||||
$openid = $matches[1] . "/identity/$username";
|
||||
}
|
||||
@ -299,7 +299,7 @@ EOT;
|
||||
private function _getUsers()
|
||||
{
|
||||
if (!isset($this->_users)) {
|
||||
$this->_users = new Users();
|
||||
$this->_users = new Users_Model_Users();
|
||||
}
|
||||
|
||||
return $this->_users;
|
||||
|
@ -9,13 +9,13 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_RecoverpasswordController extends Monkeys_Controller_Action
|
||||
class Users_RecoverpasswordController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->user->role != User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
if ($this->user->role != Users_Model_User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
return $this->_redirectForMaintenance();
|
||||
}
|
||||
}
|
||||
@ -27,7 +27,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
|
||||
$this->view->form = $appSession->recoverPasswordForm;
|
||||
unset($appSession->recoverPasswordForm);
|
||||
} else {
|
||||
$this->view->form = new RecoverPasswordForm();
|
||||
$this->view->form = new Users_Form_RecoverPassword();
|
||||
}
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
@ -35,7 +35,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
|
||||
|
||||
public function sendAction()
|
||||
{
|
||||
$form = new RecoverPasswordForm();
|
||||
$form = new Users_Form_RecoverPassword();
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
@ -45,7 +45,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
|
||||
return $this->_forward('index');
|
||||
}
|
||||
|
||||
$users = new Users();
|
||||
$users = new Users_Model_Users();
|
||||
$user = $users->getUserWithEmail($form->getValue('email'));
|
||||
if (!$user) {
|
||||
$form->email->addError($this->view->translate('This E-mail is not registered in the system'));
|
||||
@ -54,7 +54,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
|
||||
return $this->_forward('index');
|
||||
}
|
||||
|
||||
$user->token = User::generateToken();
|
||||
$user->token = Users_Model_User::generateToken();
|
||||
$user->save();
|
||||
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
@ -87,7 +87,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
|
||||
|
||||
public function resetAction()
|
||||
{
|
||||
$users = new Users();
|
||||
$users = new Users_Model_Users();
|
||||
$user = $users->getUserWithToken($this->_getParam('token'));
|
||||
if (!$user) {
|
||||
$this->_helper->FlashMessenger->addMessage('Wrong Token');
|
||||
@ -99,7 +99,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
|
||||
$user->setClearPassword($newPassword);
|
||||
|
||||
// reset token
|
||||
$user->token = User::generateToken();
|
||||
$user->token = Users_Model_User::generateToken();
|
||||
|
||||
$user->save();
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_RegisterController extends Monkeys_Controller_Action
|
||||
class Users_RegisterController extends CommunityID_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
@ -17,7 +17,7 @@ class Users_RegisterController extends Monkeys_Controller_Action
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->user->role != User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
if ($this->user->role != Users_Model_User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
return $this->_redirectForMaintenance();
|
||||
}
|
||||
|
||||
@ -36,14 +36,14 @@ class Users_RegisterController extends Monkeys_Controller_Action
|
||||
$form = $appSession->registerForm;
|
||||
unset($appSession->registerForm);
|
||||
} else {
|
||||
$form = new RegisterForm(null, $this->view->base);
|
||||
$form = new Users_Form_Register(null, $this->view->base);
|
||||
}
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$form = new RegisterForm(null, $this->view->base);
|
||||
$form = new Users_Form_Register(null, $this->view->base);
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
|
||||
@ -53,9 +53,9 @@ class Users_RegisterController extends Monkeys_Controller_Action
|
||||
return $this->_forward('index', null, null);
|
||||
}
|
||||
|
||||
$users = new Users();
|
||||
$users = new Users_Model_Users();
|
||||
|
||||
if ($users->getUser($form->getValue('username'))) {
|
||||
if ($users->getUserWithUsername($form->getValue('username'))) {
|
||||
$form->username->addError($this->view->translate('This username is already in use'));
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->registerForm = $form;
|
||||
@ -79,7 +79,7 @@ class Users_RegisterController extends Monkeys_Controller_Action
|
||||
$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;
|
||||
$openid = $this->getProtocol() . '://' . $user->username . '.' . $this->_config->subdomain->hostname;
|
||||
} else {
|
||||
$openid = $matches[1] . '/identity/' . $user->username;
|
||||
}
|
||||
@ -91,14 +91,14 @@ class Users_RegisterController extends Monkeys_Controller_Action
|
||||
$user->openid = $openid;
|
||||
|
||||
$user->setClearPassword($form->getValue('password1'));
|
||||
$user->role = User::ROLE_GUEST;
|
||||
$registrationToken = User::generateToken();
|
||||
$user->role = Users_Model_User::ROLE_GUEST;
|
||||
$registrationToken = Users_Model_User::generateToken();
|
||||
$user->token = $registrationToken;
|
||||
$user->accepted_eula = 0;
|
||||
$user->registration_date = date('Y-m-d');
|
||||
$user->save();
|
||||
|
||||
$mail = $this->getMail($user);
|
||||
$mail = self::getMail($user, $this->view->translate('Community-ID registration confirmation'));
|
||||
try {
|
||||
$mail->send();
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Thank you.'));
|
||||
@ -115,7 +115,7 @@ class Users_RegisterController extends Monkeys_Controller_Action
|
||||
|
||||
public function eulaAction()
|
||||
{
|
||||
$users = new Users();
|
||||
$users = new Users_Model_Users();
|
||||
if ($this->_request->getParam('token') == ''
|
||||
|| !($user = $users->getUserWithToken($this->_request->getParam('token')))) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid token'));
|
||||
@ -141,7 +141,7 @@ class Users_RegisterController extends Monkeys_Controller_Action
|
||||
|
||||
public function declineeulaAction()
|
||||
{
|
||||
$users = new Users();
|
||||
$users = new Users_Model_Users();
|
||||
|
||||
if ($this->_request->getParam('token') == ''
|
||||
|| !($user = $users->getUserWithToken($this->_request->getParam('token')))) {
|
||||
@ -157,14 +157,14 @@ class Users_RegisterController extends Monkeys_Controller_Action
|
||||
|
||||
public function accepteulaAction()
|
||||
{
|
||||
$users = new Users();
|
||||
$users = new Users_Model_Users();
|
||||
if ($this->_request->getParam('token') == ''
|
||||
|| !($user = $users->getUserWithToken($this->_request->getParam('token')))) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid token'));
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
$user->role = User::ROLE_REGISTERED;
|
||||
$user->role = Users_Model_User::ROLE_REGISTERED;
|
||||
$user->accepted_eula = 1;
|
||||
$user->registration_date = date('Y-m-d');
|
||||
$user->token = '';
|
||||
@ -180,7 +180,7 @@ class Users_RegisterController extends Monkeys_Controller_Action
|
||||
* @return Zend_Mail
|
||||
* @throws Zend_Mail_Protocol_Exception
|
||||
*/
|
||||
public function getMail(User $user)
|
||||
public static function getMail(Users_Model_User $user, $subject)
|
||||
{
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
@ -221,9 +221,9 @@ class Users_RegisterController extends Monkeys_Controller_Action
|
||||
|
||||
$mail = new Zend_Mail('UTF-8');
|
||||
$mail->setBodyText($emailTemplate);
|
||||
$mail->setFrom($this->_config->email->supportemail);
|
||||
$mail->setFrom($configEmail->supportemail);
|
||||
$mail->addTo($user->email);
|
||||
$mail->setSubject($this->view->translate('Community-ID registration confirmation'));
|
||||
$mail->setSubject($subject);
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
@ -9,20 +9,20 @@
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_UserslistController extends Monkeys_Controller_Action
|
||||
class Users_UserslistController extends CommunityID_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$users = new Users();
|
||||
$users = new Users_Model_Users();
|
||||
|
||||
switch($this->_getParam('filter')) {
|
||||
case 'confirmed':
|
||||
$where = "accepted_eula=1 AND role != '".User::ROLE_ADMIN."'";
|
||||
$where = "accepted_eula=1 AND role != '".Users_Model_User::ROLE_ADMIN."'";
|
||||
break;
|
||||
case 'unconfirmed':
|
||||
$where = "accepted_eula=0 AND role != '".User::ROLE_ADMIN."'";
|
||||
$where = "accepted_eula=0 AND role != '".Users_Model_User::ROLE_ADMIN."'";
|
||||
break;
|
||||
default:
|
||||
$where = false;
|
||||
@ -33,20 +33,22 @@ class Users_UserslistController extends Monkeys_Controller_Action
|
||||
$this->_getParam('startIndex'),
|
||||
$this->_getParam('results'),
|
||||
$this->_getParam('sort', 'registration'),
|
||||
$this->_getParam('dir', Users::DIR_DESC),
|
||||
$where);
|
||||
$this->_getParam('dir', Users_Model_Users::DIR_DESC),
|
||||
$where,
|
||||
trim($this->_getParam('search')));
|
||||
|
||||
$jsonObj = new StdClass();
|
||||
$jsonObj->recordsReturned = count($usersRows);
|
||||
$jsonObj->totalRecords = $users->getNumUsers();
|
||||
$jsonObj->totalRecords = $users->getNumUsers($where, trim($this->_getParam('search')));
|
||||
$jsonObj->totalUsers = $users->getNumUsers();
|
||||
$jsonObj->totalUnconfirmedUsers = $users->getNumUnconfirmedUsers();
|
||||
$jsonObj->startIndex = $_GET['startIndex'];
|
||||
$jsonObj->startIndex = $this->_getParam('startIndex');
|
||||
$jsonObj->sort = $this->_getParam('sort');
|
||||
$jsonObj->dir = $this->_getParam('dir');
|
||||
$jsonObj->records = array();
|
||||
|
||||
foreach ($usersRows as $user) {
|
||||
if ($user->role == User::ROLE_ADMIN) {
|
||||
if ($user->role == Users_Model_User::ROLE_ADMIN) {
|
||||
$status = $this->view->translate('admin');
|
||||
} else if ($user->accepted_eula) {
|
||||
$status = $this->view->translate('confirmed');
|
||||
|
65
modules/users/forms/AccountInfo.php
Normal file
65
modules/users/forms/AccountInfo.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 CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Users_Form_AccountInfo 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')
|
||||
->addValidator(new Monkeys_Validate_Username())
|
||||
->setRequired(true);
|
||||
|
||||
$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/ChangePassword.php
Normal file
30
modules/users/forms/ChangePassword.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 CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Users_Form_ChangePassword 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));
|
||||
}
|
||||
}
|
62
modules/users/forms/Login.php
Executable file
62
modules/users/forms/Login.php
Executable file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
class Users_Form_Login extends Zend_Form
|
||||
{
|
||||
private $_baseWebDir;
|
||||
private $_useCaptcha;
|
||||
|
||||
public function __construct($options = null, $baseWebDir = null, $useCaptcha= false)
|
||||
{
|
||||
$this->_baseWebDir = $baseWebDir;
|
||||
$this->_useCaptcha = $useCaptcha;
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$username = new Monkeys_Form_Element_Text('username');
|
||||
translate('USERNAME');
|
||||
$username->setLabel('USERNAME')
|
||||
->setDecoratorOptions(array(
|
||||
'separateLine' => true,
|
||||
'dontMarkRequired' => true,
|
||||
))
|
||||
->setRequired(true);
|
||||
|
||||
$password = new Monkeys_Form_Element_Password('password');
|
||||
translate('PASSWORD');
|
||||
$password->setLabel('PASSWORD')
|
||||
->setDecoratorOptions(array(
|
||||
'separateLine' => true,
|
||||
'dontMarkRequired' => true,
|
||||
))
|
||||
->setRequired(true);
|
||||
|
||||
$rememberme = new Monkeys_Form_Element_Checkbox('rememberme');
|
||||
$rememberme->setLabel('Remember me');
|
||||
|
||||
$this->addElements(array($username, $password, $rememberme));
|
||||
|
||||
if ($this->_useCaptcha) {
|
||||
$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,
|
||||
)
|
||||
));
|
||||
$captcha->setDecoratorOptions(array(
|
||||
'separateLine' => true,
|
||||
'dontMarkRequired' => true,
|
||||
));
|
||||
|
||||
$this->addElement($captcha);
|
||||
}
|
||||
}
|
||||
}
|
78
modules/users/forms/PersonalInfo.php
Normal file
78
modules/users/forms/PersonalInfo.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?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 CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Users_Form_PersonalInfo extends Zend_Form
|
||||
{
|
||||
private $_sregProps;
|
||||
private $_formElements = array();
|
||||
|
||||
public function __construct($options = null, $user = null, $sregProps = null)
|
||||
{
|
||||
$this->_sregProps = $sregProps;
|
||||
|
||||
$fields = new Model_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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This removes the "openid_sreg_" prefix from the field names
|
||||
*/
|
||||
public function getUnqualifiedValues()
|
||||
{
|
||||
$values = array();
|
||||
foreach ($this->getValues() as $key => $value) {
|
||||
$values[substr($key, 12)] = $value;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
25
modules/users/forms/RecoverPassword.php
Normal file
25
modules/users/forms/RecoverPassword.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 CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Users_Form_RecoverPassword extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$email = new Zend_Form_Element_Text('email');
|
||||
$email->setLabel('')
|
||||
->addFilter('StringToLower')
|
||||
->setRequired(true)
|
||||
->addValidator('EmailAddress');
|
||||
|
||||
$this->addElement($email);
|
||||
}
|
||||
}
|
77
modules/users/forms/Register.php
Executable file
77
modules/users/forms/Register.php
Executable file
@ -0,0 +1,77 @@
|
||||
<?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 CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Users_Form_Register 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')
|
||||
->addValidator(new Monkeys_Validate_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));
|
||||
}
|
||||
}
|
29
modules/users/models/AuthAttempt.php
Normal file
29
modules/users/models/AuthAttempt.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?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 CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Users_Model_AuthAttempt extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
const MAX_ATTEMPTS_ALLOWED = 3;
|
||||
const MIN_MINUTES_BETWEEN_ATTEMPTS = 30;
|
||||
|
||||
public function addFailure()
|
||||
{
|
||||
$this->failed_attempts++;
|
||||
$this->last_attempt = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function surpassedMaxAllowed()
|
||||
{
|
||||
return ($this->failed_attempts >= self::MAX_ATTEMPTS_ALLOWED)
|
||||
&& $this->last_attempt > date('Y-m-d H:i:s', time() - self::MIN_MINUTES_BETWEEN_ATTEMPTS * 60);
|
||||
}
|
||||
}
|
51
modules/users/models/AuthAttempts.php
Normal file
51
modules/users/models/AuthAttempts.php
Normal 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 Monkeys Ltd.
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Users_Model_AuthAttempts extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'auth_attempts';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'Users_Model_AuthAttempt';
|
||||
|
||||
/**
|
||||
* This method first searches for a match on the session_id.
|
||||
* If nothing is found, it searches for a match on the IP.
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$ip = @$_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$select = $this->select()
|
||||
->where('session_id=?', session_id());
|
||||
|
||||
$row = $this->fetchRow($select);
|
||||
if ($row) {
|
||||
return $row;
|
||||
}
|
||||
|
||||
$select = $select->where('IP=?', $ip);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$ip = @$_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$attempt = $this->createRow();
|
||||
$attempt->IP = $ip;
|
||||
$attempt->session_id = session_id();
|
||||
$attempt->failed_attempts = 1;
|
||||
$attempt->last_attempt = date('Y-m-d H:i:s');
|
||||
$attempt->save();
|
||||
}
|
||||
}
|
@ -4,13 +4,13 @@
|
||||
* @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
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class User extends Zend_Db_Table_Row_Abstract
|
||||
class Users_Model_User extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
const ROLE_GUEST = 'guest';
|
||||
const ROLE_REGISTERED = 'registered';
|
||||
|
@ -4,21 +4,23 @@
|
||||
* @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
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Users extends Monkeys_Db_Table_Gateway
|
||||
class Users_Model_Users extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'users';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'User';
|
||||
|
||||
const DIR_ASC = 0;
|
||||
const DIR_DESC = 1;
|
||||
|
||||
protected $_name = 'users';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'Users_Model_User';
|
||||
|
||||
private $_user;
|
||||
|
||||
private $_sortFields = array(
|
||||
'name' => array('firstname', 'lastname'),
|
||||
'registration' => array('registration_date', 'firstname', 'lastname'),
|
||||
@ -30,12 +32,74 @@ class Users extends Monkeys_Db_Table_Gateway
|
||||
return parent::createRow(array(
|
||||
'openid' => '',
|
||||
'password_changed' => '0000-00-00',
|
||||
'role' => User::ROLE_GUEST,
|
||||
'role' => Users_Model_User::ROLE_GUEST,
|
||||
'passwordreset_token' => '',
|
||||
));
|
||||
}
|
||||
|
||||
public function getUsers($startIndex = false, $results = false, $sort = false, $dir = false, $where = false)
|
||||
/**
|
||||
* In CID we chose from the beginning not to use SET NAMES, and instead leave the charset encodings configurations
|
||||
* to remain in the database server side (my.cnf).
|
||||
*
|
||||
* CID's strings are UTF8. If character_set_client is not UTF8 but latin1 for example (unfortunatly that's the common case), non-latin1
|
||||
* characters will appear garbled when manually browsing the db, but they should show OK in CID's web pages.
|
||||
*
|
||||
* When authenticating below, we use MySQL's MD5 function. From my tests, it looks like the argument of this function
|
||||
* gets automatically converted to the charset of that field. Sorta like if we had implicitly MD5(CONVERT(arg using charset)).
|
||||
* When the tables are build during setup, the charset of string fields are set accordingly to the my.cnf directives
|
||||
* character-set-server and collation-server.
|
||||
* If those directives don't match character_set_client, the conversion inside MD5 will in fact transform the string, and we'll
|
||||
* get the MD5 of a different string than what we had intended (well, only if the string contains non-latin1 characters).
|
||||
* For this reason we have to override that conversion, converting to the charset specified in character_set_client, as shown below.
|
||||
*
|
||||
* @return Zend_Auth_Result
|
||||
*/
|
||||
public function authenticate($identity, $password, $isOpenId = false)
|
||||
{
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$db = $this->getAdapter();
|
||||
|
||||
$result = $db->query("SHOW VARIABLES LIKE 'character_set_client'")->fetch();
|
||||
$clientCharset = $result['Value'];
|
||||
if ($isOpenId) {
|
||||
if (!Zend_OpenId::normalize($identity)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'openid', 'password',
|
||||
'MD5(CONCAT(CONVERT(openid using ' . $clientCharset . '), CONVERT(? using ' . $clientCharset . ')))');
|
||||
} else {
|
||||
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password',
|
||||
'MD5(CONCAT(CONVERT(openid using ' . $clientCharset . '), CONVERT(? using ' . $clientCharset . ')))');
|
||||
}
|
||||
|
||||
$authAdapter->setIdentity($identity);
|
||||
$authAdapter->setCredential($password);
|
||||
|
||||
$result = $auth->authenticate($authAdapter);
|
||||
|
||||
if ($result->isValid()) {
|
||||
if ($isOpenId) {
|
||||
$this->_user = $this->getUserWithOpenId($identity);
|
||||
} else {
|
||||
$this->_user = $this->getUserWithUsername($identity);
|
||||
}
|
||||
|
||||
$auth->getStorage()->write($this->_user);
|
||||
Zend_Registry::set('user', $this->_user);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
return $this->_user;
|
||||
}
|
||||
|
||||
public function getUsers($startIndex = false, $results = false, $sort = false, $dir = false, $where = false, $search = false)
|
||||
{
|
||||
$select = $this->select();
|
||||
|
||||
@ -57,19 +121,23 @@ class Users extends Monkeys_Db_Table_Gateway
|
||||
$select = $select->where($where);
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$select = $select->where('firstname LIKE ? OR lastname LIKE ?', "%$search%", "%$search%");
|
||||
}
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getNumUsers($where = false)
|
||||
public function getNumUsers($where = false, $search = false)
|
||||
{
|
||||
$users = $this->getUsers(false, false, false, false, $where);
|
||||
$users = $this->getUsers(false, false, false, false, $where, $search);
|
||||
|
||||
return count($users);
|
||||
}
|
||||
|
||||
public function getNumUnconfirmedUsers()
|
||||
{
|
||||
$users = $this->getUsers(false, false, false, false, "accepted_eula=0 AND role != '".User::ROLE_ADMIN."'");
|
||||
$users = $this->getUsers(false, false, false, false, "accepted_eula=0 AND role != '".Users_Model_User::ROLE_ADMIN."'");
|
||||
|
||||
return count($users);
|
||||
}
|
||||
@ -90,6 +158,14 @@ class Users extends Monkeys_Db_Table_Gateway
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function getUserWithUsername($username)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('username=?', $username);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function getUserWithOpenId($openid)
|
||||
{
|
||||
$select = $this->select()
|
||||
@ -98,11 +174,14 @@ class Users extends Monkeys_Db_Table_Gateway
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function getUser($identity)
|
||||
public function getUnconfirmedUsers($olderThanDays)
|
||||
{
|
||||
$select = $this->select()->where('username=?', $identity);
|
||||
$date = date('Y-m-d', strtotime("$olderThanDays days ago"));
|
||||
$select = $this->select()
|
||||
->where('accepted_eula=0')
|
||||
->where('registration_date < ?', $date);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function deleteUser(User $user)
|
||||
@ -116,9 +195,11 @@ class Users extends Monkeys_Db_Table_Gateway
|
||||
$this->delete('test=1');
|
||||
}
|
||||
|
||||
public function deleteUnconfirmed()
|
||||
public function deleteUnconfirmed($olderThanDays)
|
||||
{
|
||||
$this->delete("accepted_eula=0 AND role = '".User::ROLE_GUEST."'");
|
||||
$olderThanDays = (int) $olderThanDays;
|
||||
$date = date('Y-m-d', strtotime("$olderThanDays days ago"));
|
||||
$this->delete("accepted_eula=0 AND role = '".Users_Model_User::ROLE_GUEST."' AND registration_date < '$date'");
|
||||
}
|
||||
|
||||
protected $_metadata = array(
|
||||
|
@ -1,79 +1,85 @@
|
||||
<? if ($this->user->role != User::ROLE_GUEST ): ?>
|
||||
<?php if ($this->user->role != Users_Model_User::ROLE_GUEST ): ?>
|
||||
<h3>
|
||||
<?= $this->translate('Hello, %s', Zend_Filter::get($this->user->username, 'HtmlEntities')) ?>
|
||||
<?php echo $this->translate('Hello, %s', $this->escape($this->user->username)) ?>
|
||||
</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/profile"><?= $this->translate('Account') ?></a>
|
||||
<a href="<?php echo $this->base ?>/users/profile"><?= $this->translate('Account') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/personalinfo"><?= $this->translate('Personal Info') ?></a>
|
||||
<a href="<?php echo $this->base ?>/users/personalinfo"><?= $this->translate('Personal Info') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/sites"><?= $this->translate('Sites database') ?></a>
|
||||
<a href="<?php echo $this->base ?>/sites"><?= $this->translate('Sites database') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/history"><?= $this->translate('History Log') ?></a>
|
||||
<a href="<?php echo $this->base ?>/history"><?= $this->translate('History Log') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/login/logout"><?= $this->translate('Logout') ?></a>
|
||||
<a href="<?php echo $this->base ?>/users/login/logout"><?= $this->translate('Logout') ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
<? if ($this->user->role == User::ROLE_ADMIN): ?>
|
||||
<?php if ($this->user->role == Users_Model_User::ROLE_ADMIN): ?>
|
||||
<hr />
|
||||
<h3><?= $this->translate('Admin options') ?></h3>
|
||||
<h3><?php echo $this->translate('Admin options') ?></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/manageusers"><?= $this->translate('Manage Users') ?></a>
|
||||
<a href="<?php echo $this->base ?>/users/manageusers"><?= $this->translate('Manage Users') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/messageusers"><?= $this->translate('Message Users') ?></a>
|
||||
<a href="<?php echo $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 ?>
|
||||
<?php if ($this->maintenanceEnabled): ?>
|
||||
<a href="<?php echo $this->base ?>/maintenancemode/disable"><?= $this->translate('Disable Maintenance Mode') ?></a>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo $this->base ?>/maintenancemode/enable"><?= $this->translate('Enable Maintenance Mode') ?></a>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/stats"><?= $this->translate('Statistics') ?></a>
|
||||
<a href="<?php echo $this->base ?>/stats"><?= $this->translate('Statistics') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo $this->base ?>/cid"><?= $this->translate('About Community-ID') ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
<? endif ?>
|
||||
<? else: ?>
|
||||
<? if ($this->underMaintenance): ?>
|
||||
<?php endif ?>
|
||||
<?php else: ?>
|
||||
<?php if ($this->underMaintenance): ?>
|
||||
<div class="messages_small">
|
||||
<?= $this->translate('User access is currently disabled for system maintenance.<br />Please try again later') ?>
|
||||
<?php echo $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">
|
||||
<?php endif ?>
|
||||
<form id="loginForm" action="<?php echo $this->loginTargetBase ?>/users/login/authenticate" method="post" class="formGrid">
|
||||
<div id="credentials">
|
||||
<?php echo $this->loginForm->username ?>
|
||||
<?php echo $this->loginForm->password ?>
|
||||
<?php if ($this->useCaptcha): ?>
|
||||
<?php echo $this->loginForm->captcha ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div id="rememberMe">
|
||||
<!-- to hard to do in the ZF -->
|
||||
<input type="checkbox" name="rememberme" style="top:0" />
|
||||
<label><?= $this->translate('Remember me') ?></label>
|
||||
</dl>
|
||||
<input type="checkbox" name="rememberme" style="top:0; width:15px" />
|
||||
<label><?php echo $this->translate('Remember me') ?></label>
|
||||
</div>
|
||||
<div id="loginButton">
|
||||
<input type="submit" id="login" value="<?= $this->translate('Log in') ?>" />
|
||||
<input type="submit" id="login" value="<?php echo $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>
|
||||
<a href="<?php echo $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?') ?>
|
||||
<?php echo $this->translate('You don\'t have an account?') ?>
|
||||
<div>
|
||||
<a href="<?= $this->base ?>/users/register"><?= $this->translate('REGISTER NOW!') ?></a>
|
||||
<a href="<?php echo $this->base ?>/users/register"><?= $this->translate('REGISTER NOW!') ?></a>
|
||||
</div>
|
||||
</p> <!-- safari bug workaround -->
|
||||
</div>
|
||||
<? endif; ?>
|
||||
<?php endif; ?>
|
||||
|
@ -6,29 +6,37 @@ YAHOO.util.Event.onDOMReady(function () {
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<div class="links_topright">
|
||||
<a href="#" id="links_topright_all" onclick="COMMID.usersList.init('all'); return false;">
|
||||
<?= $this->translate('All') ?>
|
||||
<div class="links_topleft">
|
||||
<div>
|
||||
<input type="text" id="search" name="search" value="<?php echo $this->translate('Enter search string') ?>" onclick="(function () {COMMID.usersList.clickOnSearch()})()" />
|
||||
<input type="button" id="goSearch" value="<?php echo $this->translate('Go') ?>" />
|
||||
<input type="button" id="clearSearch" value="<?php echo $this->translate('Clear') ?>" />
|
||||
</div>
|
||||
<a href="#" id="links_topleft_all" onclick="COMMID.usersList.init('all'); return false;">
|
||||
<?php echo $this->translate('All') ?>
|
||||
</a>
|
||||
| <a href="#" id="links_topright_confirmed" onclick="COMMID.usersList.init('confirmed'); return false;">
|
||||
<?= $this->translate('Confirmed') ?>
|
||||
| <a href="#" id="links_topleft_confirmed" onclick="COMMID.usersList.init('confirmed'); return false;">
|
||||
<?php echo $this->translate('Confirmed') ?>
|
||||
</a>
|
||||
| <a href="#" id="links_topright_unconfirmed" onclick="COMMID.usersList.init('unconfirmed'); return false;">
|
||||
<?= $this->translate('Unconfirmed') ?>
|
||||
| <a href="#" id="links_topleft_unconfirmed" onclick="COMMID.usersList.init('unconfirmed'); return false;">
|
||||
<?php echo $this->translate('Unconfirmed') ?>
|
||||
</a>
|
||||
</div>
|
||||
<div id="paging"></div>
|
||||
<div id="dt"></div>
|
||||
<? if ($this->user->role == User::ROLE_ADMIN): ?>
|
||||
<?php if ($this->user->role == Users_Model_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 />
|
||||
<?php echo $this->translate('Total users:') ?> <span id="totalUsers"></span><br />
|
||||
<?php echo $this->translate('Total confirmed users:') ?> <span id="totalConfirmedUsers"></span><br />
|
||||
<?php echo $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'" />
|
||||
<input type="button" id="addUser" value="<?php echo $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') ?>" />
|
||||
<input type="button" id="deleteUnconfirmed" value="<?php echo $this->translate('Delete Unconfirmed Users') ?>" />
|
||||
</span>
|
||||
<span id="sendReminderSpan">
|
||||
<input type="button" id="sendReminder" value="<?php echo $this->translate('Send Reminder') ?>" />
|
||||
</span>
|
||||
<script type="text/javascript">
|
||||
new YAHOO.widget.Button(
|
||||
@ -36,7 +44,7 @@ YAHOO.util.Event.onDOMReady(function () {
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {
|
||||
location.href='<?= $this->base ?>/users/profile?userid=0'
|
||||
location.href='<?php echo $this->base ?>/users/profile?userid=0'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,6 +56,27 @@ YAHOO.util.Event.onDOMReady(function () {
|
||||
onclick : {fn: function() {COMMID.usersList.deleteUnconfirmed()}}
|
||||
}
|
||||
);
|
||||
new YAHOO.widget.Button(
|
||||
"sendReminder",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {COMMID.usersList.sendReminder()}}
|
||||
}
|
||||
);
|
||||
new YAHOO.widget.Button(
|
||||
"goSearch",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {COMMID.usersList.submitSearch()}}
|
||||
}
|
||||
);
|
||||
new YAHOO.widget.Button(
|
||||
"clearSearch",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {COMMID.usersList.clearSearch()}}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</div>
|
||||
<? endif ?>
|
||||
<?php endif ?>
|
||||
|
@ -1,59 +1,29 @@
|
||||
<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
|
||||
},
|
||||
<form name="personalInfoForm" class="formGrid" >
|
||||
<?php foreach ($this->fields as $field): ?>
|
||||
<?php echo $field ?>
|
||||
<?php endforeach ?><br />
|
||||
<input type="button" id="save" value="<?php echo $this->translate('Save') ?>" onclick="COMMID.editPersonalInfo.save()" />
|
||||
<input type="button" id="cancel" value="<?php echo $this->translate('Cancel') ?>" onclick="COMMID.editPersonalInfo.cancel()" />
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["connection"],
|
||||
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}
|
||||
onclick : {fn: COMMID.personalInfo.save}
|
||||
}
|
||||
);
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.editPersonalInfo.cancel}
|
||||
onclick : {fn: COMMID.personalInfo.cancel}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
@ -10,19 +10,19 @@ YAHOO.util.Event.onDOMReady(function () {
|
||||
<div id="article">
|
||||
<div id="generalTab" class="dataSection">
|
||||
<div class="formHeader">
|
||||
<h2><?= $this->translate('Personal Info') ?></h2>
|
||||
<h2><?php echo $this->translate('Personal Info') ?></h2>
|
||||
<div>
|
||||
<a href="javascript:void(0);" onclick="COMMID.personalInfo.edit();">
|
||||
<?= $this->translate('Edit') ?>
|
||||
<?php echo $this->translate('Edit') ?>
|
||||
</a>
|
||||
<img id="loadingEditPersonalInfo" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" />
|
||||
<img id="loadingEditPersonalInfo" src="<?php echo $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>
|
||||
<em><?php echo $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)) ?>
|
||||
<?php echo $this->action('show', 'personalinfo', 'users', array('userid' => $this->targetUser->id)) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,12 +1,12 @@
|
||||
<div class="formGrid">
|
||||
<? foreach ($this->fields as $field): ?>
|
||||
<?php foreach ($this->fields as $field): ?>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate($field->name) ?>:
|
||||
<?php echo $this->translate($field->name) ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= is_null($field->value)? $this->translate('Not Entered') : $field->value ?>
|
||||
<?php echo is_null($field->value)? $this->translate('Not Entered') : $field->value ?>
|
||||
</div>
|
||||
</div>
|
||||
<? endforeach ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
@ -10,35 +10,35 @@ YAHOO.util.Event.onDOMReady(function () {
|
||||
|
||||
<div class="accountForm">
|
||||
<div>
|
||||
<h2><?= $this->translate('Account info') ?></h2>
|
||||
<? if ($this->targetUser->id == $this->user->id): ?>
|
||||
<div class="profileLinks">
|
||||
<h2><?php echo $this->translate('Account info') ?></h2>
|
||||
<?php if ($this->targetUser->id == $this->user->id): ?>
|
||||
<div class="linksTopRight">
|
||||
<a href="javascript:void(0);" onclick="COMMID.general.editAccountInfo();">
|
||||
<?= $this->translate('Edit') ?>
|
||||
<?php echo $this->translate('Edit') ?>
|
||||
</a> |
|
||||
<a href="javascript:void(0);" onclick="COMMID.general.changePassword()" >
|
||||
<?= $this->translate('Change Password') ?>
|
||||
<?php echo $this->translate('Change Password') ?>
|
||||
</a>
|
||||
<img id="loadingAccountInfo" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" />
|
||||
<img id="loadingAccountInfo" src="<?php echo $this->base ?>/images/progress.gif" style="visibility:hidden" />
|
||||
</div>
|
||||
<? endif ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div id="accountInfo">
|
||||
<? if ($this->targetUser->id) {
|
||||
<?php 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): ?>
|
||||
<?php 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') ?>
|
||||
<div class="linksTopRight" >
|
||||
<a href="<?php echo $this->base ?>/users/profilegeneral/confirmdelete">
|
||||
<?php echo $this->translate('Delete Account') ?>
|
||||
</a>
|
||||
<img id="loadingAccountInfoDummy" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" /><!-- just for layout -->
|
||||
<img id="loadingAccountInfoDummy" src="<?php echo $this->base ?>/images/progress.gif" style="visibility:hidden" /><!-- just for layout -->
|
||||
</div>
|
||||
</div>
|
||||
<? endif ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
@ -1,34 +1,34 @@
|
||||
<div class="formGrid">
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('Username') ?>:
|
||||
<?php echo $this->translate('Username') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->username ?>
|
||||
<?php echo $this->targetUser->username ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('Name') ?>:
|
||||
<?php echo $this->translate('Name') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->getfullName() ?>
|
||||
<?php echo $this->targetUser->getfullName() ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('E-mail') ?>:
|
||||
<?php echo $this->translate('E-mail') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->email ?>
|
||||
<?php echo $this->targetUser->email ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('OpenID') ?>:
|
||||
<?php echo $this->translate('OpenID') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->openid ?>
|
||||
<?php echo $this->targetUser->openid ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,53 +1,24 @@
|
||||
<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 ?>
|
||||
<?php echo $this->changePasswordForm->password1 ?>
|
||||
<?php echo $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()" />
|
||||
<input type="button" id="save" value="<?php echo $this->translate('Save') ?>" onclick="COMMID.changePassword.save()" />
|
||||
<input type="button" id="cancel" value="<?php echo $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}
|
||||
onclick : {fn: function() {COMMID.changePassword.save(<?php echo $this->targetUser->id ?>)}}
|
||||
}
|
||||
);
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.changePassword.cancel}
|
||||
onclick : {fn: function() {COMMID.changePassword.cancel(<?php echo $this->targetUser->id ?>)}}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
@ -1,26 +1,26 @@
|
||||
<form id="confirmDeleteForm" method="post" action="<?= $this->base ?>/users/profilegeneral/delete">
|
||||
<form id="confirmDeleteForm" method="post" action="<?php echo $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:') ?>
|
||||
<?php echo $this->translate('Why do you want to delete your Community-ID account?') ?><br />
|
||||
<?php echo $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') ?>
|
||||
<input type="checkbox" name="reason_test" style="top:0" /><?php echo $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') ?>
|
||||
<input type="checkbox" name="reason_foundbetter" style="top:0" /><?php echo $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') ?>
|
||||
<input type="checkbox" name="reason_lackedfeatures" style="top:0" /><?php echo $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') ?>
|
||||
<input type="checkbox" name="reason_none" style="top:0" /><?php echo $this->translate('No particular reason') ?>
|
||||
</li>
|
||||
</ul>
|
||||
<label for="reason_comments"><?= $this->translate('Additional comments:') ?></label>
|
||||
<label for="reason_comments"><?php echo $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'" />
|
||||
<input type="submit" id="delete" value="<?php echo $this->translate('Delete Account') ?>" />
|
||||
<input type="button" id="cancel" value="<?php echo $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(
|
||||
@ -28,7 +28,7 @@
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {
|
||||
location.href='<?= $this->base ?>/users/profile'
|
||||
location.href='<?php echo $this->base ?>/users/profile'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user