From: <pan...@us...> - 2009-03-01 10:02:35
|
Revision: 513 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=513&view=rev Author: panzaboi Date: 2009-03-01 10:02:26 +0000 (Sun, 01 Mar 2009) Log Message: ----------- 1) Move from Dojo to JQuery 2) Basic functionality of Contest 3) Moved authorication out of ACM module into Default 4) Added Virtual Contest basic functionality 5) Admin Structure (proposal) 6) Configuration possibility to add helper paths 7) Added View Helpers for Text and TextArea to support languages tab. Modified Paths: -------------- website/application/layouts/layout.phtml website/application/models/Form/SmallLogin.php website/application/modules/acm/controllers/ContestController.php website/application/modules/acm/controllers/IndexController.php website/application/modules/acm/models/Archive.php website/application/modules/acm/models/Contest.php website/application/modules/acm/models/Form/Submit.php website/application/modules/acm/models/Table/Challenges.php website/application/modules/acm/models/Table/Contests.php website/application/modules/acm/views/scripts/contest/contest.phtml website/application/modules/acm/views/scripts/contest/index.phtml website/application/modules/admin/layouts/layout.phtml website/application/modules/admin/models/Form/Settings.php website/application/modules/admin/views/scripts/crud/list.phtml website/application/modules/default/controllers/IndexController.php website/application/modules/default/controllers/NewsController.php website/config/config.ini website/httpdocs/index.php website/httpdocs/scripts/main.js website/httpdocs/styles/style.css website/lang/en.csv website/lang/uk.csv website/library/Application.php website/library/Ostacium/Controller/Action/Crud.php website/library/Ostacium/Controller/Action.php website/library/Ostacium/Controller/Plugin/ErrorHandler.php website/library/Ostacium/Db/Table/Crud.php website/library/Ostacium/Db/Table.php Added Paths: ----------- website/application/models/Form/Login.php website/application/modules/acm/models/Form/Contest.php website/application/modules/acm/models/Form/ContestProblems.php website/application/modules/acm/models/Table/ContestsChallenges.php website/application/modules/acm/models/Table/ContestsLang.php website/application/modules/acm/views/scripts/contest/add.phtml website/application/modules/acm/views/scripts/contest/addproblems.phtml website/application/modules/acm/views/scripts/contest/problementry.phtml website/application/modules/admin/controllers/ProblemsController.php website/application/modules/admin/models/Form/Problems.php website/application/modules/admin/models/Table/Problems.php website/application/modules/admin/views/scripts/crud/new.phtml website/application/modules/default/models/Form/Register.php website/application/modules/default/models/Index.php website/httpdocs/images/acm/calendar.png website/httpdocs/styles/theme/ website/httpdocs/styles/theme/images/ website/httpdocs/styles/theme/images/ui-bg_diagonals-small_0_aaaaaa_40x40.png website/httpdocs/styles/theme/images/ui-bg_diagonals-thick_15_444444_40x40.png website/httpdocs/styles/theme/images/ui-bg_glass_100_f0f0f0_1x400.png website/httpdocs/styles/theme/images/ui-bg_glass_50_99c2ff_1x400.png website/httpdocs/styles/theme/images/ui-bg_glass_55_fbf5d0_1x400.png website/httpdocs/styles/theme/images/ui-bg_glass_80_e6e6e6_1x400.png website/httpdocs/styles/theme/images/ui-bg_glass_95_fef1ec_1x400.png website/httpdocs/styles/theme/images/ui-bg_highlight-hard_100_f9f9f9_1x100.png website/httpdocs/styles/theme/images/ui-bg_highlight-soft_100_e7eef3_1x100.png website/httpdocs/styles/theme/images/ui-icons_222222_256x240.png website/httpdocs/styles/theme/images/ui-icons_2694e8_256x240.png website/httpdocs/styles/theme/images/ui-icons_2e83ff_256x240.png website/httpdocs/styles/theme/images/ui-icons_72a7cf_256x240.png website/httpdocs/styles/theme/images/ui-icons_888888_256x240.png website/httpdocs/styles/theme/images/ui-icons_cd0a0a_256x240.png website/httpdocs/styles/theme/images/ui-icons_ffffff_256x240.png website/httpdocs/styles/theme/ui.accordion.css website/httpdocs/styles/theme/ui.all.css website/httpdocs/styles/theme/ui.base.css website/httpdocs/styles/theme/ui.core.css website/httpdocs/styles/theme/ui.datepicker.css website/httpdocs/styles/theme/ui.dialog.css website/httpdocs/styles/theme/ui.progressbar.css website/httpdocs/styles/theme/ui.resizable.css website/httpdocs/styles/theme/ui.slider.css website/httpdocs/styles/theme/ui.tabs.css website/httpdocs/styles/theme/ui.theme.css website/library/Ostacium/Form/Crud.php website/library/Ostacium/Form/Element/ website/library/Ostacium/Form/Element/Text.php website/library/Ostacium/Form/Element/Textarea.php website/library/Ostacium/View/Helper/FormText.php website/library/Ostacium/View/Helper/FormTextarea.php Removed Paths: ------------- website/application/modules/acm/models/Form/Login.php website/application/modules/acm/models/Form/Register.php website/application/modules/acm/models/Form/SmallLogin.php website/application/modules/acm/models/Index.php website/application/view/ website/library/Ostacium/Dojo/ Property Changed: ---------------- website/httpdocs/scripts/ Modified: website/application/layouts/layout.phtml =================================================================== --- website/application/layouts/layout.phtml 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/layouts/layout.phtml 2009-03-01 10:02:26 UTC (rev 513) @@ -1,26 +1,22 @@ <?php -$loggedin = Zend_Auth::getInstance()->getIdentity(); - -if ($loggedin) +if ($this->isLoggedIn()) { $form = $this->partial('logedin.phtml'); } -elseif (!$this->dojo()->hasDijit('loginform')) +else { $form = (new Form_SmallLogin()); $form = $form->render(); } -else $form = ''; ?> - <?= $this->doctype() ?> -<? $this->dojo()->enable() - ->setDjConfigOption('parseOnLoad', true) - ->registerModulePath('custom', '../custom/') - ->requireModule('dijit.form.FilteringSelect') +<? $this->jquery()->enable() + //->setDjConfigOption('parseOnLoad', true) + //->registerModulePath('custom', '../custom/') + //->requireModule('dijit.form.FilteringSelect') ->addOnLoad('init'); ?> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="description" content="Site description" /> <meta name="keywords" content="key, words" /> @@ -29,22 +25,26 @@ <?= $this->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8') ?> <?= $this->headLink()->appendStylesheet('/styles/style.css') ?> <?= $this->headLink()->appendStylesheet('/styles/prettify.css') ?> - <?= $this->headScript()->appendFile('/scripts/main.js') ?> + <? $this->headScript()->appendFile('/scripts/main.js') ?> <?= $this->headScript()->appendFile('/scripts/prettify.js') ?> <? - if ($this->dojo()->isEnabled()): - $this->dojo()->setLocalPath('/scripts/dojo/dojo.js') - ->addStyleSheetModule('dijit.themes.tundra'); + if ($this->jquery()->isEnabled()): + $this->jquery()->setLocalPath('/scripts/jquery/jquery-1.3.2.min.js') + ->setUiLocalPath('/scripts/jquery/jquery-ui-1.6rc6.min.js') + ->addStylesheet('/styles/theme/ui.all.css'); + //$this->dojo()->setLocalPath('/scripts/dojo/dojo/dojo.js') + /*$this->dojo()->setCdnBase(Zend_Dojo::CDN_BASE_GOOGLE) + ->setCdnVersion("1.2")*/ + // ->addStyleSheetModule('dijit.themes.nihilo'); - echo $this->dojo(); + echo $this->jquery(); endif; ?> - <base href="<?= 'http://' . $_SERVER["HTTP_HOST"] . $this->baseUrl() ?>/" /> </head> -<body class="tundra"> +<body> <div id="wrapper"> <div id="header"> <a href="<?= $this->url(array('module' => 'acm'), null, true) ?>"><img src="images/logo.png" id="logo" /></a> @@ -78,19 +78,9 @@ <li><a href="<?= $this->url(array('module' => 'acm', 'controller' => 'archive', 'action' => 'results'), null, true) ?>">Результати</a></li> </ul> </li> - <li> - <a href="<?= $this->url(array('module' => 'acm', 'controller' => 'contest', 'action' => 'index'), null, true) ?>">Контести</a> - </li> - <li> - <a href="#Archieve" onclick="return toggle('sub3');">Віртуальні Контести</a> - <ul id="sub3"> - <li><a href="#Problems">Створити</a></li> - <li><a href="#Problems">Зареєструватись</a></li> - <li><a href="#Problems">Набір Завдань</a></li> - <li><a href="#Results">Результати</a></li> - </ul> - </li> - <li><a href="#contact">Contact</a></li> + <li><a href="<?= $this->url(array('module' => 'acm', 'controller' => 'contest', 'action' => 'index'), null, true) ?>">Контести</a></li> + <li><a href="<?= $this->url(array('module' => 'acm', 'controller' => 'contest', 'action' => 'index', 'virtual' => '1'), null, true) ?>">Віртуальні Контести</a></li> + <li><a href="#contact">Контакти</a></li> </ul> <!--<div class="box2 c"> @@ -114,14 +104,14 @@ </div> </div> - <div id="clear"></div> + <div class="clear"></div> </div> <div id="footer"> <p> - Copyright 2009 ACM. Designed by <a href="#" rel="external">panza</a>. Valid <a href="http://jigsaw.w3.org/css-validator/check/referer" rel="external">CSS</a> & <a href="http://validator.w3.org/check?uri=referer" rel="external">XHTML</a> + Copyright 2009 ACM. Developed by <a href="http://panzaboi.com/">panza</a>. Valid <a href="http://jigsaw.w3.org/css-validator/check/referer" rel="external">CSS</a> & <a href="http://validator.w3.org/check?uri=referer" rel="external">XHTML</a> <br /> <!--<?= $this->debugInfo(true) ?>--> </p> Added: website/application/models/Form/Login.php =================================================================== --- website/application/models/Form/Login.php (rev 0) +++ website/application/models/Form/Login.php 2009-03-01 10:02:26 UTC (rev 513) @@ -0,0 +1,75 @@ +<?php + +class Form_Login extends ZendX_JQuery_Form +{ + public $elementDecorators = array( + 'ViewHelper', + 'Errors', + array('Label', array('class' => 'label')), + array('HtmlTag', array('tag' => 'div', 'class' => 'line')) + ); + + public $buttonDecorators = array( + 'ViewHelper', + array('HtmlTag', array('tag' => 'div', 'class' => 'line tr')) + ); + + public function init() + { + $translate = Zend_Registry::get('Zend_Translate'); + $router = Zend_Controller_Front::getInstance()->getRouter(); + + $this->setAction($router->assemble(array('module' => 'default', 'controller' => 'index', 'action' => 'login'), null, true)); + $this->setMethod('post'); + $this->setName('loginform'); + $this->setAttrib('class', 'form'); + + $this->addElement('text', 'username', array( + 'decorators' => $this->elementDecorators, + 'filters' => array('StringTrim', 'StringToLower'), + 'validators' => array( + 'Alnum', + array('StringLength', false, array(5, 50)), + ), + 'required' => true, + 'title' => $translate->_('username'), + 'label' => $translate->_('username').':', + 'class' => 'text', + )); + + $this->addElement('password', 'password', array( + 'decorators' => $this->elementDecorators, + 'filters' => array('StringTrim'), + 'validators' => array( + 'Alnum', + array('StringLength', false, array(5, 32)), + ), + 'required' => true, + 'title' => $translate->_('password'), + 'label' => $translate->_('password').':', + 'class' => 'text', + )); + + $this->addElement('submit', 'loginbutton', array( + 'decorators' => $this->buttonDecorators, + 'required' => false, + 'ignore' => true, + 'label' => $translate->_('login'), + 'class' => 'submit' + )); + } + + public function loadDefaultDecorators() + { + $this->addPrefixPath('Ostacium_Form_Decorator', 'Ostacium/Form/Decorator', 'Decorator'); + $translate = Zend_Registry::get('Zend_Translate'); + + $this->setDecorators(array( + 'FormElements', + 'Form', + array('Description', array('placement' => 'prepend', 'tag' => 'div', 'class' => 'error')), + array(array('h2' => 'HtmlTag'), array('tag' => 'h2', 'placement' => 'prepend', 'markup' => $translate->_('login'))), + array(array('div' => 'HtmlTag'), array('tag' => 'div', 'class' => 'box c')) + )); + } +} \ No newline at end of file Modified: website/application/models/Form/SmallLogin.php =================================================================== --- website/application/models/Form/SmallLogin.php 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/models/Form/SmallLogin.php 2009-03-01 10:02:26 UTC (rev 513) @@ -1,15 +1,15 @@ <?php -class Form_SmallLogin extends Zend_Dojo_Form +class Form_SmallLogin extends ZendX_JQuery_Form { public $elementDecorators = array( - 'DijitElement', + 'ViewHelper', array('Label', array('class' => 'label2')), array('HtmlTag', array('tag' => 'div', 'class' => 'line')) ); public $buttonDecorators = array( - 'DijitElement', + 'ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'line tr')) ); @@ -18,29 +18,25 @@ $translate = Zend_Registry::get('Zend_Translate'); $router = Zend_Controller_Front::getInstance()->getRouter(); - $this->setAction($router->assemble(array('action' => 'login', 'controller' => 'index'), null)); + $this->setAction($router->assemble(array('module' => 'default', 'controller' => 'index', 'action' => 'login'), null, true)); $this->setMethod('post'); $this->setName('loginform'); $this->setAttrib('class', 'form'); - $this->addElement('ValidationTextBox', 'username', array( + $this->addElement('text', 'username', array( 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array( - array('StringLength', false, array(5, 50)), + 'Alnum', + array('StringLength', false, array(5, 50)) ), 'required' => true, - 'maxlength' => 50, - 'trim' => true, - 'lowercase' => true, - 'regExp' => '[\w]{5,50}', - 'invalidMessage' => sprintf($translate->_('enter_username_between'), 5, 50), 'title' => $translate->_('username'), 'label' => $translate->_('username').':', 'class' => 'text', )); - $this->addElement('PasswordTextBox', 'password', array( + $this->addElement('password', 'password', array( 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array( @@ -48,24 +44,21 @@ array('StringLength', false, array(5, 32)), ), 'required' => true, - 'trim' => true, - 'regExp' => '[\S]{5,32}', - 'invalidMessage' => sprintf($translate->_('enter_password_between'), 5, 32), 'title' => $translate->_('password'), 'label' => $translate->_('password').':', 'class' => 'text', )); - $this->addElement('Button', 'signupbutton', array( + $this->addElement('button', 'signupbutton', array( 'decorators' => $this->buttonDecorators, 'required' => false, 'ignore' => true, 'label' => $translate->_('signup'), 'class' => 'signup2', - 'onclick' => 'return goToUrl("'.$router->assemble(array('action' => 'register', 'controller' => 'user'), null).'")' + 'onclick' => 'return goToUrl("'.$router->assemble(array('module' => 'default', 'controller' => 'user', 'action' => 'register'), null, true).'")' )); - $this->addElement('SubmitButton', 'loginbutton', array( + $this->addElement('submit', 'loginbutton', array( 'decorators' => $this->buttonDecorators, 'required' => false, 'ignore' => true, @@ -78,7 +71,7 @@ { $this->setDecorators(array( 'FormElements', - 'DijitForm', + 'Form', array('HtmlTag', array('tag' => 'div', 'class' => 'box2 c')) )); } Modified: website/application/modules/acm/controllers/ContestController.php =================================================================== --- website/application/modules/acm/controllers/ContestController.php 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/modules/acm/controllers/ContestController.php 2009-03-01 10:02:26 UTC (rev 513) @@ -1,46 +1,123 @@ <?php class Acm_ContestController extends Ostacium_Controller_Action -{ +{ + public function init($loadModel = true) + { + parent::init($loadModel); + + $ajaxContext = $this->_helper->getHelper('AjaxContext'); + $ajaxContext->addActionContext('addproblemAction', 'html') + ->addActionContext('delproblemAction', 'html') + ->initContext(); + } + public function indexAction() { - $contests = $this->_model->getContests(); + $virtual = (bool)$this->_getParam('virtual', false); + + $contests = $this->_model->getContests($virtual); + $paginator = Zend_Paginator::factory($contests); $paginator->setItemCountPerPage($this->_config->table->perpage); $paginator->setCurrentPageNumber($this->_getParam('page')); $this->view->contests = $paginator; + $this->view->virtual = $virtual; } - public function newAction() - { + public function addAction() + { + if (!$this->isAdminOrVirtual()) + return $this->_redirect($this->view->url(array('action' => 'index'), null)); + $this->view->form = new Form_Contest(); + + if (!$this->getRequest()->isPost()) + { + return; + } + + if (!$this->view->form->isValid($this->getRequest()->getPost())) + { + return; + } + + $values = $this->view->form->getValues(); + $values['virtual'] = (bool)$this->_getParam('virtual', false); + + $id = $this->_model->addContest($values); + return $this->_redirect($this->view->url(array('action' => 'addproblems', 'contestid' => $id, 'message' => 'successfully_added'), null)); } - public function addAction() + public function addproblemsAction() + { + $virtual = (bool)$this->_getParam('virtual', false); + $contestid = $this->_getParam('contestid'); + + if (!$this->isAdminOrVirtual() || !$contestid || !$this->_model->existsContest($contestid, $virtual)) + return $this->_redirect($this->view->url(array('action' => 'index'), null)); + + $this->view->form = new Form_ContestProblems(); + $this->view->problems = $this->_model->getChallenges($contestid, $virtual); + $this->view->contestid = $contestid; + $this->view->virtual = $virtual; + + if (!$this->getRequest()->isPost()) + return; + + if (!$this->view->form->isValid($this->getRequest()->getPost())) + return; + + $values = $this->view->form->getValues(); + } + + public function addproblemAction() { + $this->_helper->getHelper('viewRenderer')->setNoRender(true); + $id = $this->_getParam('id'); + $contestid = $this->_getParam('contestid'); + $virtual = $this->_getParam('virtual'); + + if (!$this->isAdminOrVirtual() || !$contestid || !$this->_model->existsContest($contestid, $virtual)) + return $this->_redirect($this->view->url(array('action' => 'index'), null)); + + if ($this->getRequest()->isXmlHttpRequest() || 1) + { + $add = $this->_model->addProblemToContest($id, $contestid); + + echo (int)$add; + exit; + } + else + { + + } } - /* - public function registerAction() + + public function delproblemAction() { - $contestid = $this->_getParam('contestid'); - - if (!$this->_model->isContestRunning($contestid)) - { - return $this->render('notrun'); - } + $id = $this->_getParam('id'); + $contestid = $this->_getParam('contestid'); + $virtual = $this->_getParam('virtual'); + + if (!$this->isAdminOrVirtual() || !$contestid || !$this->_model->existsContest($contestid, $virtual)) + return $this->_redirect($this->view->url(array('action' => 'index'), null)); + + if ($this->getRequest()->isXmlHttpRequest()) + { + $remove = $this->_model->removeProblemFromContest($id, $contestid); + + echo (int)$remove; + exit; + } + else + { + + } + } - if ($this->_model->isInContest($contestid)) - { - return $this->render('incontest'); - } - - $this->_model->registerUser($contestid); - - return $this->render('registered'); - } - */ public function viewAction() { $id = $this->_getParam('id'); @@ -69,14 +146,20 @@ public function problemsetAction() { + $virtual = (bool)$this->_getParam('virtual', false); $contestid = $this->_getParam('contestid'); - /*if (!$this->_model->isInContest($contestid)) - { - return $this->render('notincontest'); - }*/ - - $this->view->challenges = $this->_model->getChallenges($contestid); + $challenges = $this->_model->getChallenges($contestid, $virtual); + + if (!$challenges) + return $this->_forward('index', null, null, $this->_getAllParams() + array('message' => 'noProblem')); + + $paginator = Zend_Paginator::factory($challenges); + $paginator->setItemCountPerPage($this->_config->table->perpage); + $paginator->setCurrentPageNumber($this->_getParam('page')); + + $this->view->challenges = $paginator; + $this->view->virtual = $virtual; } public function submitAction() @@ -170,4 +253,12 @@ $this->view->challenges = $this->_model->getChallenges($contestid); $this->view->table = $this->_model->getTable($contestid); } + + protected function isAdminOrVirtual() + { + $virtual = (bool)$this->_getParam('virtual', false); + $user = Zend_Auth::getInstance()->getIdentity(); + + return ($user->role == 'admin' || $virtual == true); + } } \ No newline at end of file Modified: website/application/modules/acm/controllers/IndexController.php =================================================================== --- website/application/modules/acm/controllers/IndexController.php 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/modules/acm/controllers/IndexController.php 2009-03-01 10:02:26 UTC (rev 513) @@ -6,60 +6,4 @@ { var_dump('sadfasdf'); } - - public function loginAction() - { - $this->_helper->getHelper('viewRenderer')->setNoRender(true); - - $form = new Form_Login(); - if ($this->_getParam('message')) - { - $form->setDescription($this->view->translate($this->_getParam('message'))); - $this->view->message = null; - } - - if (!$this->getRequest()->isPost()) - { - echo $form; - - return; - } - - if (!$form->isValid($this->getRequest()->getPost())) - { - echo $form; - - return; - } - - $values = $form->getValues(); - - $result = $this->_model->authoricate($values); - - if (!$result) - { - $form->setDescription($this->view->translate('error_bad_login')); - echo $form; - - return; - } - - $redirect = new Zend_Session_Namespace('Redirect'); - if ($redirect->to) - { - $this->getRequest()->setParam('redirect', $redirect->to); - $redirect->unsetAll(); - } - else - { - return $this->_redirect('/acm/index/index'); - } - } - - public function logoutAction() - { - Zend_Auth::getInstance()->clearIdentity(); - - $this->_redirect('/acm/index/index'); - } } \ No newline at end of file Modified: website/application/modules/acm/models/Archive.php =================================================================== --- website/application/modules/acm/models/Archive.php 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/modules/acm/models/Archive.php 2009-03-01 10:02:26 UTC (rev 513) @@ -28,7 +28,7 @@ public function getStatus($id) { - $username = Zend_Auth::getInstance()->getStorage()->read()->username; + $username = Zend_Auth::getInstance()->getIdentity()->username; $archresults = new Table_ArchiveResults(); return $archresults->get(array($username, $id)); @@ -38,7 +38,7 @@ { $data = array( 'contestid' => 0, - 'username' => Zend_Auth::getInstance()->getStorage()->read()->username, + 'username' => Zend_Auth::getInstance()->getIdentity()->username, 'challengeid' => (int)$values['id'], 'codelangid' => $values['languageid'], 'firsttest' => $values['firsttest'], Modified: website/application/modules/acm/models/Contest.php =================================================================== --- website/application/modules/acm/models/Contest.php 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/modules/acm/models/Contest.php 2009-03-01 10:02:26 UTC (rev 513) @@ -15,40 +15,28 @@ $this->calc = $calc; } - public function getContests() + public function getContests($virtual) { $contests = new Table_Contests(); - return $contests->getAll(); + return $contests->getAll($virtual); } - /* - public function registerUser($id) - { - $username = Zend_Auth::getInstance()->getStorage()->read()->username; - - $ca = new Table_ContestsApplicants(); - $ca->insert(array('username' => $username, 'contestid' => $id)); - - return true; - } - */ + public function isContestRunning($contestid) { $contest = new Table_Contests(); return $contest->isRunning($contestid); } - /* - public function isInContest($contestid) + + public function existsContest($contestid, $virtual) { - $username = Zend_Auth::getInstance()->getStorage()->read()->username; $contest = new Table_Contests(); - - return $contest->isInContest($contestid, $username); + return $contest->exists($contestid, $virtual); } - */ - public function getChallenges($contestid) + + public function getChallenges($contestid, $virtual) { $challenges = new Table_Challenges(); - return $challenges->getAllFromContest($contestid); + return $challenges->getAllFromContest($contestid, $virtual); } public function getChallenge($id, $contestid) @@ -63,11 +51,54 @@ return $submits->getFromContest($id, $contestid); } + public function addContest($values) + { + $data = array( + 'start' => strtotime($values['start_date'].$values['start_time'].(Zend_Auth::getInstance()->getIdentity()->timeoffset)), + 'end' => strtotime($values['end_date'].$values['end_time'].(Zend_Auth::getInstance()->getIdentity()->timeoffset)), + 'enabled' => (int)$values['enabled'], + 'virtual' => (int)$values['virtual'], + 'author' => Zend_Auth::getInstance()->getIdentity()->username + ); + + $contest = new Table_Contests(); + $contestlang = new Table_ContestsLang(); + + $id = $contest->insert($data); + $languages = Zend_Registry::get('Zend_Translate')->getList(); + + foreach ($languages as $lang) + { + $langdata = array( + 'id' => $id, + 'langcode' => $lang, + 'name' => $values['name'][$lang], + 'description' => $values['description'][$lang] + ); + + $contestlang->insert($langdata); + } + + return $id; + } + + public function addProblemToContest($id, $contestid) + { + $contestsch = new Table_ContestsChallenges(); + return $contestsch->insert(array('contestid' => $contestid, 'challengeid' => $id)); + } + + public function removeProblemFromContest($id, $contestid) + { + $contestsch = new Table_ContestsChallenges(); + return $contestsch->delete(array('contestid' => $contestid, 'challengeid' => $id)); + } + public function addSubmit($values) { $data = array( 'contestid' => $values['contestid'], - 'username' => Zend_Auth::getInstance()->getStorage()->read()->username, + 'username' => Zend_Auth::getInstance()->getIdentity()->username, 'challengeid' => (int)$values['id'], 'codelangid' => $values['languageid'], 'firsttest' => $values['firsttest'], Added: website/application/modules/acm/models/Form/Contest.php =================================================================== --- website/application/modules/acm/models/Form/Contest.php (rev 0) +++ website/application/modules/acm/models/Form/Contest.php 2009-03-01 10:02:26 UTC (rev 513) @@ -0,0 +1,133 @@ +<?php + +class Form_Contest extends ZendX_JQuery_Form +{ + public $elementDecorators = array( + 'ViewHelper', + 'Errors', + array('Label', array('class' => 'label')), + array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer')) + ); + + public $buttonDecorators = array( + 'ViewHelper', + array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer tc')) + ); + + public function init() + { + $translate = Zend_Registry::get('Zend_Translate'); + $db = Zend_Registry::get('db'); + $router = Zend_Controller_Front::getInstance()->getRouter(); + + $this->setAction($router->assemble(array('action' => 'add'), null)); + $this->setMethod('post'); + $this->setName('registerform'); + $this->setAttrib('class', 'registerform c'); + + $this->addPrefixPath('Ostacium_Form_Element', 'Ostacium/Form/Element', Zend_Form::ELEMENT); + + $this->addElement('text', 'name', array( + 'decorators' => $this->elementDecorators, + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(5, 50)), + ), + 'required' => true, + //'invalidMessage' => sprintf($translate->_('enter_username_between'), 5, 50), + 'title' => $translate->_('username'), + 'label' => $translate->_('username').':', + 'class' => 'text', + 'useLanguages' => true, + )); + + $this->addElement('textarea', 'description', array( + 'decorators' => $this->elementDecorators, + 'filters' => array('StringTrim'), + 'required' => true, + 'title' => $translate->_('username'), + 'label' => $translate->_('username').':', + 'class' => 'text', + 'rows' => '10', + 'useLanguages' => true, + )); + + $this->addElement('DatePicker', 'start_date', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + //'invalidMessage' => $translate->_('invalidDate'), + 'title' => $translate->_('start_date'), + 'label' => $translate->_('start_date').': ', + 'dateFormat' => 'dd.mm.yy', + 'jQueryParams' => array( + 'appendText' => '(dd.mm.yyyy)', + 'showAnim' => 'slideDown', + 'speed' => 'fast', + 'minDate' => 0, + 'beforeShow' => 'customRange' + ) + //'locale' => Zend_Registry::get('Zend_Locale'), + )); + + $this->addElement('text', 'start_time', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + /*'invalidMessage' => $translate->_('invalidTime'), + 'visibleRange' => 'T10:00:00', + 'visibleIncrement' => 'T01:00:00', + 'clickableIncrement' => 'T01:00:00',*/ + 'title' => $translate->_('start_time'), + 'label' => $translate->_('start_time').': ', + )); + + $this->addElement('DatePicker', 'end_date', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + //'invalidMessage' => $translate->_('invalidDate'), + 'title' => $translate->_('end_date'), + 'label' => $translate->_('end_date').': ', + 'dateFormat' => 'dd.mm.yy', + 'jQueryParams' => array( + 'appendText' => '(dd.mm.yyyy)', + 'showAnim' => 'slideDown', + 'speed' => 'fast', + 'minDate' => 0, + 'beforeShow' => 'customRange' + ) + )); + + $this->addElement('text', 'end_time', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + /*'invalidMessage' => $translate->_('invalidTime'), + 'visibleRange' => 'T10:00:00', + 'visibleIncrement' => 'T01:00:00', + 'clickableIncrement' => 'T01:00:00',*/ + 'title' => $translate->_('end_time'), + 'label' => $translate->_('end_time').': ', + )); + + $this->addElement('checkbox', 'enabled', array( + 'decorators' => $this->elementDecorators, + 'title' => $translate->_('enabled'), + 'label' => $translate->_('enabled').': ', + 'multiOptions' => array($translate->_('no'), $translate->_('yes')), + )); + + $this->addElement('submit', 'createbutton', array( + 'decorators' => $this->buttonDecorators, + 'required' => false, + 'ignore' => true, + 'label' => $translate->_('add_contest'), + )); + } + + public function loadDefaultDecorators() + { + $this->setDecorators(array( + 'FormElements', + 'Form', + array('Description', array('placement' => 'prepend', 'tag' => 'div', 'class' => 'error')), + )); + } +} \ No newline at end of file Added: website/application/modules/acm/models/Form/ContestProblems.php =================================================================== --- website/application/modules/acm/models/Form/ContestProblems.php (rev 0) +++ website/application/modules/acm/models/Form/ContestProblems.php 2009-03-01 10:02:26 UTC (rev 513) @@ -0,0 +1,72 @@ +<?php + +class Form_ContestProblems extends ZendX_JQuery_Form +{ + public $elementDecorators = array( + 'ViewHelper', + 'Errors', + array('Label', array('class' => 'label')), + array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer')) + ); + + public $buttonDecorators = array( + 'ViewHelper', + array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer tc')) + ); + + public function init() + { + $translate = Zend_Registry::get('Zend_Translate'); + $db = Zend_Registry::get('db'); + $router = Zend_Controller_Front::getInstance()->getRouter(); + + $this->setAction($router->assemble(array('action' => 'index'), null)); + $this->setMethod('post'); + $this->setName('problemform'); + $this->setAttrib('class', 'problemform c'); + + $this->getView()->addHelperPath('Ostacium/Dojo/View/Helper', 'Ostacium_Dojo_View_Helper'); + $this->addPrefixPath('Ostacium_Dojo_Form_Element', 'Ostacium/Dojo/Form/Element', Zend_Form::ELEMENT); + + $table = new Table_Challenges(); + $virtual = (bool)$router->getParam('virtual'); + $challenges = $db->fetchPairs($table->getAllSelect($virtual)); + + $this->addElement('select', 'problem', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('problem'), + 'label' => $translate->_('problem').': ', + 'multiOptions' => $challenges, + )); + + $this->addElement('button', 'createbutton', array( + 'decorators' => $this->buttonDecorators, + 'required' => false, + 'ignore' => true, + 'label' => $translate->_('add_contest'), + 'onclick' => 'return addProblem();' + )); + + $this->addElement('submit', 'finishbutton', array( + 'decorators' => $this->buttonDecorators, + 'required' => false, + 'ignore' => true, + 'label' => $translate->_('finish_editing'), + )); + } + + public function loadDefaultDecorators() + { + $this->setDecorators(array( + 'FormElements', + 'Form', + array('Description', array('placement' => 'prepend', 'tag' => 'div', 'class' => 'error')), + )); + } + + /*protected function addIds(&$item, $key) + { + $item = $key . '. ' . $item; + }*/ +} \ No newline at end of file Deleted: website/application/modules/acm/models/Form/Login.php =================================================================== --- website/application/modules/acm/models/Form/Login.php 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/modules/acm/models/Form/Login.php 2009-03-01 10:02:26 UTC (rev 513) @@ -1,83 +0,0 @@ -<?php - -class Form_Login extends Zend_Dojo_Form -{ - public $elementDecorators = array( - 'DijitElement', - 'Errors', - array('Label', array('class' => 'label')), - array('HtmlTag', array('tag' => 'div', 'class' => 'line')) - ); - - public $buttonDecorators = array( - 'DijitElement', - array('HtmlTag', array('tag' => 'div', 'class' => 'line tr')) - ); - - public function init() - { - $translate = Zend_Registry::get('Zend_Translate'); - $router = Zend_Controller_Front::getInstance()->getRouter(); - - $this->setAction($router->assemble(array('action' => 'login', 'controller' => 'index'), null)); - $this->setMethod('post'); - $this->setName('loginform'); - $this->setAttrib('class', 'form'); - - $this->addElement('ValidationTextBox', 'username', array( - 'decorators' => $this->elementDecorators, - 'filters' => array('StringTrim', 'StringToLower'), - 'validators' => array( - array('StringLength', false, array(5, 50)), - ), - 'required' => true, - 'maxlength' => 50, - 'trim' => true, - 'lowercase' => true, - 'regExp' => '[\w]{5,50}', - 'invalidMessage' => sprintf($translate->_('wordErrorBetween'), 5, 50), - 'title' => $translate->_('username'), - 'label' => $translate->_('username').':', - 'class' => 'text', - )); - - $this->addElement('PasswordTextBox', 'password', array( - 'decorators' => $this->elementDecorators, - 'filters' => array('StringTrim'), - 'validators' => array( - 'Alnum', - array('StringLength', false, array(5, 32)), - ), - 'required' => true, - 'trim' => true, - 'regExp' => '[\S]{5,32}', - 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 32), - 'title' => $translate->_('password'), - 'label' => $translate->_('password').':', - 'class' => 'text', - )); - - $this->addElement('SubmitButton', 'loginbutton', array( - 'decorators' => $this->buttonDecorators, - 'required' => false, - 'ignore' => true, - 'label' => $translate->_('login'), - 'class' => 'submit' - )); - } - - public function loadDefaultDecorators() - { - //$this->addElementPrefixPath('Ostacium/Form/Decorator', 'Ostacium_Form_Decorator', 'Decorator'); - $this->addPrefixPath('Ostacium_Form_Decorator', 'Ostacium/Form/Decorator', 'Decorator'); - $translate = Zend_Registry::get('Zend_Translate'); - - $this->setDecorators(array( - 'FormElements', - 'DijitForm', - array('Description', array('placement' => 'prepend', 'tag' => 'div', 'class' => 'error')), - array(array('h2' => 'HtmlTag'), array('tag' => 'h2', 'placement' => 'prepend', 'markup' => $translate->_('login'))), - array(array('div' => 'HtmlTag'), array('tag' => 'div', 'class' => 'box c')) - )); - } -} \ No newline at end of file Deleted: website/application/modules/acm/models/Form/Register.php =================================================================== --- website/application/modules/acm/models/Form/Register.php 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/modules/acm/models/Form/Register.php 2009-03-01 10:02:26 UTC (rev 513) @@ -1,318 +0,0 @@ -<?php - -class Form_Register extends Zend_Dojo_Form -{ - public $elementDecorators = array( - 'DijitElement', - 'Errors', - array('Label', array('class' => 'label')), - array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer')) - ); - - public $simpleDecorators = array( - 'Errors', - array('Label', array('class' => 'label')), - array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer')) - ); - - public $buttonDecorators = array( - 'DijitElement', - array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer tc')) - ); - - public function init() - { - $translate = Zend_Registry::get('Zend_Translate'); - $db = Zend_Registry::get('db'); - $router = Zend_Controller_Front::getInstance()->getRouter(); - - $this->setAction($router->assemble(array('action' => 'register'), null)); - $this->setMethod('post'); - $this->setName('registerform'); - $this->setAttrib('class', 'registerform c'); - - $this->addElement('ValidationTextBox', 'username', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(5, 50)), - ), - 'maxlength' => 50, - 'trim' => true, - 'required' => true, - 'regExp' => '[\w]{5,50}', - 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 50), - 'title' => $translate->_('username'), - 'label' => $translate->_('username').': ', - 'id' => 'username_reg' - )); - - $this->addElement('PasswordTextBox', 'password', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(5, 32)), - ), - 'maxlength' => 32, - 'trim' => true, - 'required' => true, - 'regExp' => '[\S]{5,32}', - 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 32), - 'title' => $translate->_('password'), - 'label' => $translate->_('password').': ', - 'id' => 'password_reg' - )); - - $this->addElement('PasswordTextBox', 'cpassword', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(5, 32)), - ), - 'maxlength' => 32, - 'trim' => true, - 'propercase' => true, - 'required' => true, - 'regExp' => '[\S]{5,32}', - 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 32), - 'title' => $translate->_('confirm_password'), - 'label' => $translate->_('confirm_password').': ', - )); - - $this->addElement('ValidationTextBox', 'email', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - 'EmailAddress', - array('StringLength', false, 1) - ), - 'filters' => array('StringToLower'), - 'trim' => true, - 'lowercase' => true, - 'required' => true, - 'regExp' => '.{1,}', - 'invalidMessage' => $translate->_('errorEmpty'), - 'title' => $translate->_('email'), - 'label' => $translate->_('email').': ', - )); - - $this->addElement('Checkbox', 'hideemail', array( - 'decorators' => $this->elementDecorators, - 'required' => true, - 'title' => $translate->_('hide_email'), - 'label' => $translate->_('hide_email').': ', - 'multiOptions' => array($translate->_('no'), $translate->_('yes')), - )); - - $this->addElement('ValidationTextBox', 'name', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'maxlength' => 50, - 'trim' => true, - 'required' => false, - 'regExp' => '[\w ]{0,50}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 50), - 'title' => $translate->_('name'), - 'label' => $translate->_('name').': ', - )); - - $this->addElement('ValidationTextBox', 'surname', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'maxlength' => 50, - 'trim' => true, - 'required' => false, - 'regExp' => '[\w ]{0,50}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 50), - 'title' => $translate->_('surname'), - 'label' => $translate->_('surname').': ', - )); - - $this->addElement('ValidationTextBox', 'study', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'maxlength' => 50, - 'trim' => true, - 'required' => false, - 'regExp' => '[\w ]{0,50}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 50), - 'title' => $translate->_('edu_place'), - 'label' => $translate->_('edu_place').': ', - )); - - $this->addElement('DateTextBox', 'birthday', array( - 'decorators' => $this->elementDecorators, - 'required' => false, - 'invalidMessage' => $translate->_('invalidDate'), - 'title' => $translate->_('birthday'), - 'label' => $translate->_('birthday').': ', - 'formatLength' => 'short' - )); - - $this->addElement('ValidationTextBox', 'aim', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'maxlength' => 50, - 'trim' => true, - 'required' => false, - 'regExp' => '[\S]{0,50}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 50), - 'title' => $translate->_('aim'), - 'label' => $translate->_('aim').': ', - )); - - $this->addElement('ValidationTextBox', 'icq', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'maxlength' => 50, - 'trim' => true, - 'required' => false, - 'regExp' => '[\S]{0,50}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 50), - 'title' => $translate->_('icq_handle'), - 'label' => $translate->_('icq_handle').': ', - )); - - $this->addElement('ValidationTextBox', 'msn', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 100)), - ), - 'maxlength' => 100, - 'trim' => true, - 'required' => false, - 'regExp' => '[\S]{0,100}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 100), - 'title' => $translate->_('msn_handle'), - 'label' => $translate->_('msn_handle').': ', - )); - - $this->addElement('ValidationTextBox', 'skype', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'maxlength' => 50, - 'trim' => true, - 'required' => false, - 'regExp' => '[\S]{0,50}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 50), - 'title' => $translate->_('skype_handle'), - 'label' => $translate->_('skype_handle').': ', - )); - - $this->addElement('ValidationTextBox', 'yahoo', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'maxlength' => 50, - 'trim' => true, - 'required' => false, - 'regExp' => '[\S]{0,50}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 50), - 'title' => $translate->_('yahoo_handle'), - 'label' => $translate->_('yahoo_handle').': ', - )); - - $this->addElement('ValidationTextBox', 'web', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 100)), - ), - 'maxlength' => 200, - 'trim' => true, - 'required' => false, - 'regExp' => '[\S]{0,100}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 100), - 'title' => $translate->_('website'), - 'label' => $translate->_('website').': ', - )); - - $this->addElement('ValidationTextBox', 'topcoder', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'maxlength' => 50, - 'trim' => true, - 'required' => false, - 'regExp' => '[\S]{0,50}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 50), - 'title' => $translate->_('tc_handle'), - 'label' => $translate->_('tc_handle').': ', - )); - - $this->addElement('ValidationTextBox', 'timus', array( - 'decorators' => $this->elementDecorators, - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'maxlength' => 50, - 'trim' => true, - 'required' => false, - 'regExp' => '[\S]{0,50}', - 'invalidMessage' => sprintf($translate->_('errorMore'), 50), - 'title' => $translate->_('timus_handle'), - 'label' => $translate->_('timus_handle').': ', - )); - - $offset = array(-12 => -12, -11 => -11, -10 => -10, -9 => -9, -8 => -8, -7 => -7, -6 => -6, -5 => -5, -4 => -4, -3 => -3, -2 => -2, -1 => -1, 0 => 0, '+1' => '+1', '+2' => '+2', '+3' => '+3', '+4' => '+4', '+5' => '+5', '+6' => '+6', '+7' => '+7', '+8' => '+8', '+9' => '+9', '+10' => '+10', '+11' => '+11', '+12' => '+12', '+13' => '+13'); - - $this->addElement('FilteringSelect', 'timeoffset', array( - 'decorators' => $this->elementDecorators, - 'required' => true, - 'title' => $translate->_('timeoffset'), - 'label' => $translate->_('timeoffset').': ', - 'multiOptions' => $offset, - 'value' => 0 - )); - - $this->addElement('FilteringSelect', 'codelangid', array( - 'decorators' => $this->elementDecorators, - 'required' => true, - 'title' => $translate->_('code_language'), - 'label' => $translate->_('code_language').': ', - 'multiOptions' => $db->fetchPairs($db->select()->from('code_languages', array('id', 'name'))), - )); - - $this->addElement('FilteringSelect', 'language', array( - 'decorators' => $this->elementDecorators, - 'required' => true, - 'title' => $translate->_('language'), - 'label' => $translate->_('language').': ', - 'multiOptions' => $db->fetchPairs($db->select()->from('languages', array('code', 'name'))), - 'value' => Zend_Registry::get('config')->lang->default - )); - - $this->addElement('FilteringSelect', 'tshirtsize', array( - 'decorators' => $this->elementDecorators, - 'required' => true, - 'title' => $translate->_('tshirtsize'), - 'label' => $translate->_('tshirtsize').': ', - 'multiOptions' => array('S' => 'Small', 'M' => 'Medium', 'L' => 'Large'), - )); - - $this->addElement('SubmitButton', 'registerbutton', array( - 'decorators' => $this->buttonDecorators, - 'required' => false, - 'ignore' => true, - 'label' => $translate->_('register'), - )); - } - - public function loadDefaultDecorators() - { - $this->setDecorators(array( - 'FormElements', - 'DijitForm', - array('Description', array('placement' => 'prepend', 'tag' => 'div', 'class' => 'error')), - )); - } -} \ No newline at end of file Deleted: website/application/modules/acm/models/Form/SmallLogin.php =================================================================== --- website/application/modules/acm/models/Form/SmallLogin.php 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/modules/acm/models/Form/SmallLogin.php 2009-03-01 10:02:26 UTC (rev 513) @@ -1,85 +0,0 @@ -<?php - -class Form_SmallLogin extends Zend_Dojo_Form -{ - public $elementDecorators = array( - 'DijitElement', - array('Label', array('class' => 'label2')), - array('HtmlTag', array('tag' => 'div', 'class' => 'line')) - ); - - public $buttonDecorators = array( - 'DijitElement', - array('HtmlTag', array('tag' => 'div', 'class' => 'line tr')) - ); - - public function init() - { - $translate = Zend_Registry::get('Zend_Translate'); - $router = Zend_Controller_Front::getInstance()->getRouter(); - - $this->setAction($router->assemble(array('action' => 'login', 'controller' => 'index'), null)); - $this->setMethod('post'); - $this->setName('loginform'); - $this->setAttrib('class', 'form'); - - $this->addElement('ValidationTextBox', 'username', array( - 'decorators' => $this->elementDecorators, - 'filters' => array('StringTrim', 'StringToLower'), - 'validators' => array( - array('StringLength', false, array(5, 50)), - ), - 'required' => true, - 'maxlength' => 50, - 'trim' => true, - 'lowercase' => true, - 'regExp' => '[\w]{5,50}', - 'invalidMessage' => sprintf($translate->_('enter_username_between'), 5, 50), - 'title' => $translate->_('username'), - 'label' => $translate->_('username').':', - 'class' => 'text', - )); - - $this->addElement('PasswordTextBox', 'password', array( - 'decorators' => $this->elementDecorators, - 'filters' => array('StringTrim'), - 'validators' => array( - 'Alnum', - array('StringLength', false, array(5, 32)), - ), - 'required' => true, - 'trim' => true, - 'regExp' => '[\S]{5,32}', - 'invalidMessage' => sprintf($translate->_('enter_password_between'), 5, 32), - 'title' => $translate->_('password'), - 'label' => $translate->_('password').':', - 'class' => 'text', - )); - - $this->addElement('Button', 'signupbutton', array( - 'decorators' => $this->buttonDecorators, - 'required' => false, - 'ignore' => true, - 'label' => $translate->_('signup'), - 'class' => 'signup2', - 'onclick' => 'return goToUrl("'.$router->assemble(array('action' => 'register', 'controller' => 'user'), null).'")' - )); - - $this->addElement('SubmitButton', 'loginbutton', array( - 'decorators' => $this->buttonDecorators, - 'required' => false, - 'ignore' => true, - 'label' => $translate->_('login'), - 'class' => 'submit2' - )); - } - - public function loadDefaultDecorators() - { - $this->setDecorators(array( - 'FormElements', - 'DijitForm', - array('HtmlTag', array('tag' => 'div', 'class' => 'box2 c')) - )); - } -} \ No newline at end of file Modified: website/application/modules/acm/models/Form/Submit.php =================================================================== --- website/application/modules/acm/models/Form/Submit.php 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/modules/acm/models/Form/Submit.php 2009-03-01 10:02:26 UTC (rev 513) @@ -42,7 +42,7 @@ 'title' => $translate->_('language'), 'label' => $translate->_('language').': ', 'multiOptions' => $db->fetchPairs($db->select()->from('code_languages', array('id', 'name'))), - 'value' => (Zend_Auth::getInstance()->getStorage()->read()->codelangid) + 'value' => (Zend_Auth::getInstance()->getIdentity()->codelangid) )); $this->addElement('RadioButton', 'type', array( @@ -66,7 +66,7 @@ $this->addElement('File', 'codefile', array( 'decorators' => array_merge(array('File'), $this->simpleDecorators), 'validators' => array(array('Count', false, 1)), - 'destination' => Application::getDocRoot().'/other/uploads/', + 'destination' => Application::getDocRoot().'/other/uploads', 'label' => $translate->_('choose_file').': ', )); Deleted: website/application/modules/acm/models/Index.php =================================================================== --- website/application/modules/acm/models/Index.php 2009-02-27 23:53:06 UTC (rev 512) +++ website/application/modules/acm/models/Index.php 2009-03-01 10:02:26 UTC (rev 513) @@ -1,24 +0,0 @@ -<?php - -class Index extends Ostacium_Model -{ - public function authoricate($login) - { - $auth = Zend_Auth::getInstance(); - $adapter = Zend_Registry::get('auth'); - $acl = Zend_Registry::get('acl'); - - $adapter->setIdentity($login['username']) - ->setCredential($login['password']); - - $result = $adapter->authenticate(); - - if ($result->isValid()) { - $row = $adapter->getResultRowObject(); - - $auth->getStorage()->write($ro... [truncated message content] |