Permalink
Browse files

Finished QSTAT development

  • Loading branch information...
sirshurf committed Jan 27, 2012
1 parent 24430bf commit 9dc7b2172883cf8fbec03c7f9a7196937b2b03fd
View
@@ -14,7 +14,7 @@ protected function _initAuthentication ()
$fc->registerPlugin($objUserAuthPlugin);
$objView = $this->getApplication()->view;
- $objView->getHelper('navigation')->setDefaultAcl($objUserAuthPlugin->getAcl());
+ $objView->getHelper('navigation')->setDefaultAcl(User_Model_Acl::getInstance());
}
View
@@ -158,6 +158,30 @@
<required>true</required>
</options>
</lastname>
+ <phone>
+ <type>text</type>
+ <options>
+ <label>LBL_PHONE</label>
+ <size>40</size>
+ <validators>
+ <notempty>
+ <validator>NotEmpty</validator>
+ <options>
+ <messages>
+ <isEmpty>Your phone is required</isEmpty>
+ </messages>
+ </options>
+ </notempty>
+ </validators>
+ <filters>
+ <trim>
+ <filter>StringTrim</filter>
+ </trim>
+ </filters>
+ <class></class>
+ <required>true</required>
+ </options>
+ </phone>
<id_roles>
<type>DbSelect</type>
<options>
@@ -1,19 +1,30 @@
<?php
-class User_AuthenticationController extends Zend_Controller_Action {
- public function selfonlyAction () {
+
+class User_AuthenticationController extends Zend_Controller_Action
+{
+
+ public function selfonlyAction ()
+ {
// Empty Action, only view
}
- public function unauthorizedAction () {
+
+ public function unauthorizedAction ()
+ {
// Empty Action, only view
}
+
/**
* Standart logout, clears all ident data
*/
- public function logoutAction () {
+ public function logoutAction ()
+ {
+ $this->view->strMsgLogout = $this->view->translate('LBL_TEXT_LOGOUT');
Zend_Auth::getInstance()->clearIdentity();
Zend_Session::destroy(TRUE);
}
- public function loginAction () {
+
+ public function loginAction ()
+ {
// First check if you have Identity... If you do redirecto to home
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
@@ -24,19 +35,9 @@ public function loginAction () {
if ($objForm->isValid($this->_request->getPost())) {
$username = trim($objForm->getValue(User_Model_Db_Users::COL_LOGIN));
$password = trim($objForm->getValue('password'));
- // ...or configure the instance with setter methods
- $authAdapter = new Zend_Auth_Adapter_DbTable();
- $authAdapter->setTableName(User_Model_Db_Users::TBL_NAME)
- ->setIdentityColumn(User_Model_Db_Users::COL_LOGIN)
- ->setCredentialColumn(User_Model_Db_Users::COL_PWD)
- ->setCredentialTreatment('md5(?)')
- ->setIdentity($username)
- ->setCredential($password);
// Remove it from Array...
- $result = $auth->authenticate($authAdapter);
+ $result = User_Model_User::makeLogin($username, $password);
if ($result->isValid()) {
- $session = new Zend_Session_Namespace("user");
- $session->userDetails = $authAdapter->getResultRowObject();
$session = new Zend_Session_Namespace("uri");
if (! empty($session->url['params'])) {
$strUrl = $this->view->url($session->url['params']);
@@ -47,13 +48,15 @@ public function loginAction () {
} else {
$arrMessages = $result->getMessages();
$objForm->addError($arrMessages[0]);
+ $objForm->setDecorators(array('FormElements', 'FormErrors', 'Form'));
}
}
}
$this->view->objForm = $objForm;
-
- $arrButtons[] = array('module' => 'user', 'controller' => 'index', "action" => "edit", "onClick" => '$("#' . $objForm->getAttrib('id') . '").submit();', "name" => 'LBL_BUTTON_USER_LOGIN');
+ $arrButtons[] = array('module' => 'user', 'controller' => 'authentication', "action" => "login", "onClick" => '$("#' . $objForm->getAttrib('id') . '").submit();',
+ "name" => 'LBL_BUTTON_USER_LOGIN');
$arrButtons[] = array('module' => 'user', 'controller' => 'index', "action" => "forgot-password", "name" => 'LBL_BUTTON_USER_FORGOT_PASSWORD');
$this->view->arrActions = $arrButtons;
}
-}
+
+}
@@ -22,7 +22,7 @@ public function forgotPasswordAction ()
}
// render
$this->view->objForm = $objForm;
- $arrButtons[] = array('module' => 'user', 'controller' => 'index', "action" => "edit", "onClick" => '$("#' . $objForm->getAttrib('id') . '").submit();', "name" => 'LBL_BUTTON_USER_PASSWORD_NEW');
+ $arrButtons[] = array('module' => 'user', 'controller' => 'index', "action" => "forgot-password", "onClick" => '$("#' . $objForm->getAttrib('id') . '").submit();', "name" => 'LBL_BUTTON_USER_PASSWORD_NEW');
$this->view->arrActions = $arrButtons;
}
@@ -38,6 +38,25 @@ public function indexAction ()
$grid->addColumn(new Ingot_JQuery_JqGrid_Column(User_Model_Db_Users::COL_FIRST_NAME));
$grid->addColumn(new Ingot_JQuery_JqGrid_Column(User_Model_Db_Users::COL_LAST_NAME));
$grid->addColumn(new Ingot_JQuery_JqGrid_Column_Decorator_Link(new Ingot_JQuery_JqGrid_Column(User_Model_Db_Users::COL_EMAIL), array('link' => 'mailto:%s')));
+
+ $grid->addColumn(new Ingot_JQuery_JqGrid_Column(User_Model_Db_Users::COL_PHONE));
+
+ Ingot_JQuery_JqGrid_Column_DoubleColumn::createSelectColumn($grid, 'Roles');
+
+ $objSites = new Qstat_Db_Table_Sites();
+ $objSitesSelect = $objSites->getPairSelect();
+ $arrPairs = $objSites->getAdapter()->fetchPairs($objSitesSelect);
+ $column = new Ingot_JQuery_JqGrid_Column_Decorator_Search_Select(new Ingot_JQuery_JqGrid_Column('sites', array('useHaving'=>true, 'customField' => User_Model_Db_Users::COL_EXTRA_DATA)), array("value" => $arrPairs));
+ $grid->addColumn(new Qstat_JQuery_JqGrid_Column_Decorator_UserExtra($column, array('values' => $arrPairs)));
+
+ $objSites = new Qstat_Db_Table_Groups();
+ $objSitesSelect = $objSites->getPairSelect();
+ $arrPairs = $objSites->getAdapter()->fetchPairs($objSitesSelect);
+ $column = new Ingot_JQuery_JqGrid_Column_Decorator_Search_Select(new Ingot_JQuery_JqGrid_Column('groups', array('useHaving'=>true, 'customField' => User_Model_Db_Users::COL_EXTRA_DATA)), array("value" => $arrPairs));
+ $grid->addColumn(new Qstat_JQuery_JqGrid_Column_Decorator_UserExtra($column, array('values' => $arrPairs)));
+
+
+
$grid->registerPlugin(new Ingot_JQuery_JqGrid_Plugin_ToolbarFilter());
$this->view->grid = $grid->render();
$arrActions = array();
@@ -72,11 +91,16 @@ public function editAction ()
$objExtraData = new $strExtraDataClass();
if ($objExtraData instanceof User_Model_User_Extra_Interface) {
$objExtraData->setMainRow($objUserRow);
- $objForm->addSubForm($objExtraData->getForm($this->getRequest()
- ->getParams()), $objExtraData->getFormName());
+
+ $objSubForm = $objExtraData->getForm($this->getRequest()
+ ->getParams());
+
+ $objExtraData->validateElements($objSubForm);
+ $objForm->addSubForm($objSubForm, $objExtraData->getFormName());
$objForm->populate($objExtraData->getData());
}
}
+ $objForm->validateElements();
$objForm->populate($objUserRow->toArray());
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
@@ -14,10 +14,14 @@ public function indexAction ()
$objGrid->setIdCol(User_Model_Db_Resources::COL_ID_RESOURCES);
$objGrid->setLocalEdit();
- $objGrid->addColumn(new Ingot_JQuery_JqGrid_Column(User_Model_Db_Resources::COL_MODULE));
- $objGrid->addColumn(new Ingot_JQuery_JqGrid_Column(User_Model_Db_Resources::COL_CONTROLLER));
-
- $objGrid->addColumn(new Ingot_JQuery_JqGrid_Column(User_Model_Db_Resources::COL_IS_VIRTUAL));
+ $objGrid->addColumn(new Ingot_JQuery_JqGrid_Column(User_Model_Db_Resources::COL_MODULE, array('editable' => true)));
+ $objGrid->addColumn(new Ingot_JQuery_JqGrid_Column(User_Model_Db_Resources::COL_CONTROLLER, array('editable' => true)));
+
+ $objGrid->addColumn(new Ingot_JQuery_JqGrid_Column(User_Model_Db_Resources::COL_IS_VIRTUAL, array('editable' => true)));
+
+ $objGridPager = $objGrid->getPager ();
+ $objGridPager->setDefaultAdd ();
+ $objGrid->setDblClkEdit(TRUE);
$objGrid->registerPlugin(new Ingot_JQuery_JqGrid_Plugin_ToolbarFilter());
$this->view->grid = $objGrid->render();
View
@@ -1,24 +1,22 @@
<?php
class User_Form_UserDetails extends ZendX_JQuery_Form
{
- public function init ()
- {
- $this->addPrefixPath('Bf_Form_Element_', 'Bf/Form/Element/', Zend_Form::ELEMENT);
-
- /* Form Elements & Other Definitions Here ... */
- $objOptions = new Zend_Config_Xml(
- dirname(__FILE__) . '/../configs/forms/forms.xml');
- $this->setConfig($objOptions->profile);
- // Check if global file exists....
- // If exists, add it as sub form...
- if (is_readable(
- APPLICATION_PATH . '/configs/forms/user.xml')) {
- $objSubOptions = new Zend_Config_Xml(
- APPLICATION_PATH . '/configs/forms/user.xml');
- // $objSubForm = new ZendX_JQuery_Form($objSubOptions->profile);
- // $this->addSubForm($objSubForm, 'subformUserDetails');
- }
- /*
+
+ public function init () {
+ $this->addPrefixPath('Bf_Form_Element_', 'Bf/Form/Element/', Zend_Form::ELEMENT);
+
+ /* Form Elements & Other Definitions Here ... */
+ $objOptions = new Zend_Config_Xml(dirname(__FILE__) . '/../configs/forms/forms.xml');
+ $this->setConfig($objOptions->profile);
+ // Check if global file exists....
+ // If exists, add it as sub form...
+ if (is_readable(APPLICATION_PATH . '/configs/forms/user.xml')) {
+ $objSubOptions = new Zend_Config_Xml(APPLICATION_PATH . '/configs/forms/user.xml');
+
+ // $objSubForm = new ZendX_JQuery_Form($objSubOptions->profile);
+ // $this->addSubForm($objSubForm, 'subformUserDetails');
+ }
+ /*
$this->setName('LogIn');
$this->setMethod('post');
@@ -37,6 +35,32 @@ public function init ()
$this->addElement($login);
*/
- }
+
+ // Check permissions...
+
+
+ $objUserSessionData = new Zend_Session_Namespace('user');
+ $objUserDetails = $objUserSessionData->userDetails;
+
+ if (! empty($objUserDetails->{User_Model_Db_Users::COL_ID_ROLE})) {
+ switch ($objUserDetails->{User_Model_Db_Users::COL_ID_ROLE}) {
+ case 4: // Group Member
+ case 5: // Group Manager
+ case 6: // Site Manager
+ // They can only see the current level, not change it.
+ $this->getElement(User_Model_Db_Users::COL_ID_ROLE)->setAttrib('disabled', 'disabled');
+ break;
+ default:
+ break;
+
+ }
+ }
+ }
+
+ public function validateElements(){
+ if ('disabled' == $this->getElement(User_Model_Db_Users::COL_ID_ROLE)->getAttrib('disabled')){
+ $this->removeElement($this->getElement(User_Model_Db_Users::COL_ID_ROLE)->getName());
+ }
+ }
}
Oops, something went wrong.

0 comments on commit 9dc7b21

Please sign in to comment.