Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
James 2012-04-17 15:43:39 -04:00
commit 5df1fede9f
23 changed files with 239 additions and 115 deletions

View File

@ -144,7 +144,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
'password-change', 'password-change',
new Zend_Controller_Router_Route('password-change/:user_id/:token', array( new Zend_Controller_Router_Route('password-change/:user_id/:token', array(
'module' => 'default', 'module' => 'default',
'controller' => 'auth', 'controller' => 'login',
'action' => 'password-change', 'action' => 'password-change',
))); )));
} }

View File

@ -22,7 +22,6 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('dashboard')) ->add(new Zend_Acl_Resource('dashboard'))
->add(new Zend_Acl_Resource('preference')) ->add(new Zend_Acl_Resource('preference'))
->add(new Zend_Acl_Resource('showbuilder')) ->add(new Zend_Acl_Resource('showbuilder'))
->add(new Zend_Acl_Resource('auth'))
->add(new Zend_Acl_Resource('playouthistory')) ->add(new Zend_Acl_Resource('playouthistory'))
->add(new Zend_Acl_Resource('usersettings')) ->add(new Zend_Acl_Resource('usersettings'))
->add(new Zend_Acl_Resource('audiopreview')); ->add(new Zend_Acl_Resource('audiopreview'));
@ -33,7 +32,6 @@ $ccAcl->allow('G', 'index')
->allow('G', 'error') ->allow('G', 'error')
->allow('G', 'showbuilder') ->allow('G', 'showbuilder')
->allow('G', 'api') ->allow('G', 'api')
->allow('G', 'auth')
->allow('G', 'schedule') ->allow('G', 'schedule')
->allow('G', 'dashboard') ->allow('G', 'dashboard')
->allow('H', 'usersettings') ->allow('H', 'usersettings')

View File

@ -1,90 +0,0 @@
<?php
class AuthController extends Zend_Controller_Action
{
public function init()
{
}
public function passwordRestoreAction()
{
//uses separate layout without a navigation.
$this->_helper->layout->setLayout('bare');
$form = new Application_Form_PasswordRestore();
$request = $this->getRequest();
if ($request->isPost() && $form->isValid($request->getPost())) {
$user = CcSubjsQuery::create()
->filterByDbEmail($form->email->getValue())
->findOne();
if (!empty($user)) {
$auth = new Application_Model_Auth();
$auth->sendPasswordRestoreLink($user, $this->view);
$this->_helper->redirector('password-restore-after', 'auth');
}
else {
$form->email->addError($this->view->translate("Given email not found."));
}
}
$this->view->form = $form;
}
public function passwordRestoreAfterAction()
{
//uses separate layout without a navigation.
$this->_helper->layout->setLayout('bare');
}
public function passwordChangeAction()
{
//uses separate layout without a navigation.
$this->_helper->layout->setLayout('bare');
$request = $this->getRequest();
$token = $request->getParam("token", false);
$user_id = $request->getParam("user_id", 0);
$form = new Application_Form_PasswordChange();
$auth = new Application_Model_Auth();
$user = CcSubjsQuery::create()->findPK($user_id);
//check validity of token
if (!$auth->checkToken($user_id, $token, 'password.restore')) {
echo "token not valid";
$this->_helper->redirector('index', 'login');
}
if ($request->isPost() && $form->isValid($request->getPost())) {
$user->setDbPass(md5($form->password->getValue()));
$user->save();
$auth->invalidateTokens($user, 'password.restore');
$zend_auth = Zend_Auth::getInstance();
$zend_auth->clearIdentity();
$authAdapter = Application_Model_Auth::getAuthAdapter();
$authAdapter->setIdentity($user->getDbLogin())
->setCredential($form->password->getValue());
$result = $zend_auth->authenticate($authAdapter);
//all info about this user from the login table omit only the password
$userInfo = $authAdapter->getResultRowObject(null, 'password');
//the default storage is a session with namespace Zend_Auth
$authStorage = $zend_auth->getStorage();
$authStorage->write($userInfo);
$this->_helper->redirector('index', 'showbuilder');
}
$this->view->form = $form;
}
}

View File

@ -12,9 +12,9 @@ class LoginController extends Zend_Controller_Action
{ {
global $CC_CONFIG; global $CC_CONFIG;
if(Zend_Auth::getInstance()->hasIdentity()) if (Zend_Auth::getInstance()->hasIdentity())
{ {
$this->_redirect('Nowplaying'); $this->_redirect('Showbuilder');
} }
//uses separate layout without a navigation. //uses separate layout without a navigation.
@ -97,6 +97,87 @@ class LoginController extends Zend_Controller_Action
Zend_Auth::getInstance()->clearIdentity(); Zend_Auth::getInstance()->clearIdentity();
$this->_redirect('showbuilder/index'); $this->_redirect('showbuilder/index');
} }
public function passwordRestoreAction()
{
//uses separate layout without a navigation.
$this->_helper->layout->setLayout('login');
$form = new Application_Form_PasswordRestore();
$request = $this->getRequest();
if ($request->isPost() && $form->isValid($request->getPost())) {
$user = CcSubjsQuery::create()
->filterByDbEmail($form->email->getValue())
->findOne();
if (!empty($user)) {
$auth = new Application_Model_Auth();
$auth->sendPasswordRestoreLink($user, $this->view);
$this->_helper->redirector('password-restore-after', 'auth');
}
else {
$form->email->addError($this->view->translate("Given email not found."));
}
}
$this->view->form = $form;
}
public function passwordRestoreAfterAction()
{
//uses separate layout without a navigation.
$this->_helper->layout->setLayout('login');
}
public function passwordChangeAction()
{
//uses separate layout without a navigation.
$this->_helper->layout->setLayout('login');
$request = $this->getRequest();
$token = $request->getParam("token", false);
$user_id = $request->getParam("user_id", 0);
$form = new Application_Form_PasswordChange();
$auth = new Application_Model_Auth();
$user = CcSubjsQuery::create()->findPK($user_id);
//check validity of token
if (!$auth->checkToken($user_id, $token, 'password.restore')) {
echo "token not valid";
$this->_helper->redirector('index', 'login');
}
if ($request->isPost() && $form->isValid($request->getPost())) {
$user->setDbPass(md5($form->password->getValue()));
$user->save();
$auth->invalidateTokens($user, 'password.restore');
$zend_auth = Zend_Auth::getInstance();
$zend_auth->clearIdentity();
$authAdapter = Application_Model_Auth::getAuthAdapter();
$authAdapter->setIdentity($user->getDbLogin())
->setCredential($form->password->getValue());
$result = $zend_auth->authenticate($authAdapter);
//all info about this user from the login table omit only the password
$userInfo = $authAdapter->getResultRowObject(null, 'password');
//the default storage is a session with namespace Zend_Auth
$authStorage = $zend_auth->getStorage();
$authStorage->write($userInfo);
$this->_helper->redirector('index', 'showbuilder');
}
$this->view->form = $form;
}
} }

View File

@ -227,8 +227,7 @@ class ScheduleController extends Zend_Controller_Action
$showStartLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart()); $showStartLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart());
$showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd()); $showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd());
if ($epochNow < $showEndLocalDT->getTimestamp()) { if ($epochNow < $showStartLocalDT->getTimestamp()) {
if ( ($isAdminOrPM || $isDJ) if ( ($isAdminOrPM || $isDJ)
&& !$instance->isRecorded() && !$instance->isRecorded()
&& !$instance->isRebroadcast()) { && !$instance->isRebroadcast()) {
@ -239,7 +238,6 @@ class ScheduleController extends Zend_Controller_Action
$menu["clear"] = array("name"=> "Remove All Content", "icon" => "remove-all-content", $menu["clear"] = array("name"=> "Remove All Content", "icon" => "remove-all-content",
"url" => "/schedule/clear-show"); "url" => "/schedule/clear-show");
} }
} }
if (!$instance->isRecorded()) { if (!$instance->isRecorded()) {

View File

@ -9,6 +9,10 @@ class Application_Form_Login extends Zend_Form
// Set the method for the display form to POST // Set the method for the display form to POST
$this->setMethod('post'); $this->setMethod('post');
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/login.phtml'))
));
// Add username element // Add username element
$this->addElement('text', 'username', array( $this->addElement('text', 'username', array(
@ -19,9 +23,12 @@ class Application_Form_Login extends Zend_Form
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'validators' => array( 'validators' => array(
'NotEmpty', 'NotEmpty',
),
'decorators' => array(
'ViewHelper'
) )
)); ));
// Add password element // Add password element
$this->addElement('password', 'password', array( $this->addElement('password', 'password', array(
'label' => 'Password:', 'label' => 'Password:',
@ -31,6 +38,9 @@ class Application_Form_Login extends Zend_Form
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'validators' => array( 'validators' => array(
'NotEmpty', 'NotEmpty',
),
'decorators' => array(
'ViewHelper'
) )
)); ));
@ -47,7 +57,10 @@ class Application_Form_Login extends Zend_Form
$this->addElement('submit', 'submit', array( $this->addElement('submit', 'submit', array(
'ignore' => true, 'ignore' => true,
'label' => 'Login', 'label' => 'Login',
'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center' 'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center',
'decorators' => array(
'ViewHelper'
)
)); ));
} }

View File

@ -6,6 +6,10 @@ class Application_Form_PasswordChange extends Zend_Form
{ {
public function init() public function init()
{ {
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/password-change.phtml'))
));
$this->addElement('password', 'password', array( $this->addElement('password', 'password', array(
'label' => 'Password', 'label' => 'Password',
'required' => true, 'required' => true,
@ -13,10 +17,13 @@ class Application_Form_PasswordChange extends Zend_Form
'validators' => array( 'validators' => array(
array('stringLength', false, array(6, 80)), array('stringLength', false, array(6, 80)),
), ),
'decorators' => array(
'ViewHelper'
)
)); ));
$this->addElement('password', 'password_confirm', array( $this->addElement('password', 'password_confirm', array(
'label' => 'Password Confirmation', 'label' => 'Confirm new password',
'required' => true, 'required' => true,
'filters' => array('stringTrim'), 'filters' => array('stringTrim'),
'validators' => array( 'validators' => array(
@ -25,11 +32,18 @@ class Application_Form_PasswordChange extends Zend_Form
}), }),
), ),
'errorMessages' => array("Password confirmation does not match your password."), 'errorMessages' => array("Password confirmation does not match your password."),
'decorators' => array(
'ViewHelper'
)
)); ));
$this->addElement('submit', 'submit', array( $this->addElement('submit', 'submit', array(
'label' => 'Set password', 'label' => 'Get new password',
'ignore' => true, 'ignore' => true,
'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center',
'decorators' => array(
'ViewHelper'
)
)); ));
} }
} }

View File

@ -6,18 +6,28 @@ class Application_Form_PasswordRestore extends Zend_Form
{ {
public function init() public function init()
{ {
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/password-restore.phtml'))
));
$this->addElement('text', 'email', array( $this->addElement('text', 'email', array(
'label' => 'E-mail', 'label' => 'E-mail',
'required' => true, 'required' => true,
'filters' => array( 'filters' => array(
'stringTrim', 'stringTrim',
), ),
'decorators' => array(
'ViewHelper'
)
)); ));
$this->addElement('submit', 'submit', array( $this->addElement('submit', 'submit', array(
'label' => 'Restore password', 'label' => 'Restore password',
'ignore' => true, 'ignore' => true,
'class' => 'ui-button ui-state-default' 'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center',
'decorators' => array(
'ViewHelper'
)
)); ));
} }
} }

View File

@ -9,7 +9,13 @@
</head> </head>
<body> <body>
<div id="login-page"><?php echo $this->layout()->content ?></div> <div id="login-page">
<?php echo $this->layout()->content ?>
</div>
<div class="footer">
Airtime&nbsp;<?php echo $this->airtimeVersion ?>&nbsp;Copyright &copy; Sourcefabric o.p.s <?php echo $this->airtimeCopyright ?>. All rights reserved.<br/>
Maintained and distributed under GNU GPL v.3 by <a href="http://www.sourcefabric.org"> Sourcefabric o.p.s </a>
</div>
</body> </body>
</html> </html>

View File

@ -65,7 +65,8 @@ class Application_Model_PlayoutHistory {
$historyTable = "( $historyTable = "(
select count(schedule.file_id) as played, schedule.file_id as file_id select count(schedule.file_id) as played, schedule.file_id as file_id
from cc_schedule as schedule from cc_schedule as schedule
where schedule.starts >= '{$start}' and schedule.starts < '{$end}' where schedule.starts >= '{$start}' and schedule.starts < '{$end}'
and schedule.playout_status > 0 and schedule.media_item_played != FALSE
group by schedule.file_id group by schedule.file_id
) )
AS playout left join cc_files as file on (file.id = playout.file_id)"; AS playout left join cc_files as file on (file.id = playout.file_id)";

View File

@ -446,7 +446,7 @@ class Application_Model_Schedule {
Logging::debug("Get Schedule: Less than 3 results returned. Do another query in an attempt to get 3."); Logging::debug("Get Schedule: Less than 3 results returned. Do another query in an attempt to get 3.");
$dt = new DateTime("@".time()); $dt = new DateTime("@".time());
$dt->add(new DateInterval("PT30M")); $dt->add(new DateInterval("PT24H"));
$range_end = $dt->format("Y-m-d H:i:s"); $range_end = $dt->format("Y-m-d H:i:s");
$predicates = " WHERE st.ends > '$p_startTime'" $predicates = " WHERE st.ends > '$p_startTime'"

View File

@ -1 +0,0 @@
<div><?php echo $this->form ?></div>

View File

@ -1 +0,0 @@
<div>Email sent</div>

View File

@ -1 +0,0 @@
<div><?php echo $this->form ?></div>

View File

@ -0,0 +1,33 @@
<form enctype="application/x-www-form-urlencoded" method="post" action="">
<dl class="zend_form">
<dt id="username-label">
<label for="username" class="required">
<?php echo $this->element->getElement('username')->getLabel() ?>
</label>
</dt>
<dd id="username-element">
<?php echo $this->element->getElement('username') ?>
</dd>
<dt id="password-label">
<label for="password" class="required">
<?php echo $this->element->getElement('password')->getLabel() ?>
</label>
</dt>
<dd id="password-element">
<?php echo $this->element->getElement('password') ?>
</dd>
<dt id="reset-label" class="hidden">&nbsp;</dt>
<dd id="reset-element" class="text-right">
<a href="<?php echo $this->baseUrl('login/password-restore'); ?>" class="link reset">Reset password</a>
</dd>
<dt id="submit-label">&nbsp;</dt>
<dd id="submit-element">
<?php echo $this->element->getElement('submit') ?>
</dd>
</dl>
</form>

View File

@ -0,0 +1,25 @@
<form enctype="application/x-www-form-urlencoded" method="post" action="">
<dl class="zend_form">
<dt id="new-password-label">
<label for="new-password" class="required">
<?php echo $this->element->getElement('password')->getLabel() ?>
</label>
</dt>
<dd id="new-password-element">
<?php echo $this->element->getElement('password') ?>
</dd>
<dt id="confirm-password-label">
<label for="confirm-password" class="required">
<?php echo $this->element->getElement('password_confirm')->getLabel() ?>
</label>
</dt>
<dd id="confirm-password-element">
<?php echo $this->element->getElement('password_confirm') ?>
</dd>
<dt id="submit-label">&nbsp;</dt>
<dd id="submit-element">
<?php echo $this->element->getElement('submit') ?>
</dd>
</dl>
</form>

View File

@ -0,0 +1,18 @@
<form enctype="application/x-www-form-urlencoded" method="post" action="">
<dl class="zend_form">
<dt id="username-label">
<label for="username" class="required">
<?php echo $this->element->getElement('email')->getLabel() ?>
</label>
</dt>
<dd id="username-element">
<?php echo $this->element->getElement('email') ?>
</dd>
<dt id="submit-label">&nbsp;</dt>
<dd id="submit-element">
<?php echo $this->element->getElement('submit') ?>
</dd>
</dl>
</form>

View File

@ -9,5 +9,3 @@
<?php echo $this->form; ?> <?php echo $this->form; ?>
</div> </div>
</div> </div>
<div class="footer"> Airtime&nbsp;<?php echo $this->airtimeVersion ?>&nbsp;Copyright &copy; Sourcefabric o.p.s <?php echo $this->airtimeCopyright ?>. All rights reserved.<br/>
Maintained and distributed under GNU GPL v.3 by <a href="http://www.sourcefabric.org"> Sourcefabric o.p.s </a> </div>

View File

@ -0,0 +1,9 @@
<div class="login_box">
<div class="logobox">&nbsp;</div>
<h2>New password</h2>
<div id="login" class="login-content clearfix">
<p class="light">Please enter and confirm your new password in the fields below.</p>
<?php echo $this->form; ?>
</div>
</div>

View File

@ -0,0 +1,8 @@
<div class="login_box">
<div class="logobox">&nbsp;</div>
<h2>Email sent</h2>
<div id="login" class="login-content clearfix">
<p class="light">An email has been sent to <?php $this->form->email->getValue() ?></p>
</div>
</div>

View File

@ -0,0 +1,9 @@
<div class="login_box">
<div class="logobox">&nbsp;</div>
<h2>Reset password</h2>
<div id="login" class="login-content clearfix">
<p class="light">Please enter your account e-mail address. You will recieve a link to create a new password via e-mail.</p>
<?php echo $this->form; ?>
</div>
</div>

View File

@ -44,8 +44,6 @@ rabbitmq_vhost = '/'
############################################ ############################################
# pypo preferences # # pypo preferences #
############################################ ############################################
prepare_ahead = 24 #in hours
cache_for = 24 #how long to hold the cache, in hours
# Poll interval in seconds. # Poll interval in seconds.
# #

View File

@ -44,8 +44,6 @@ rabbitmq_vhost = '/'
############################################ ############################################
# pypo preferences # # pypo preferences #
############################################ ############################################
prepare_ahead = 24 #in hours
cache_for = 24 #how long to hold the cache, in hours
# Poll interval in seconds. # Poll interval in seconds.
# #