Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ldap #174

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Ldap #174

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions application/configs/application.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ resources.db.params.password = SENTRIFUGO_PASSWORD
resources.db.params.dbname = SENTRIFUGO_DBNAME
resources.db.isDefaultTableAdapter = true

;Typical options for OpenLDAP
ldap.server1.host = LDAP_HOST
ldap.server1.port = LDAP_PORT
ldap.server1.accountFilterFormat = LDAP_ACCOUNTFILTERFORMAT
ldap.server1.accountDomainName = LDAP_ACCOUNTDOMAINNAME
ldap.server1.accountDomainNameShort = LDAP_ACCOUNTDOMAINNAMESHORT
ldap.server1.accountCanonicalForm = LDAP_ACCOUNTCANONICALFORM
ldap.server1.username = LDAP_USERNAME
ldap.server1.password = LDAP_PASSWORD
ldap.server1.baseDn = LDAP_BASEDN


[staging : production]
Expand Down
25 changes: 21 additions & 4 deletions application/modules/default/controllers/EmployeeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ public function addorganisationhead($loginUserId)
$msgarray['employeeNumId'] = "Employee ID already exists. Please try again.";
$flag = 'false';
}
$username = trim($this->_request->getParam('username_orghead',null));
$isusernameexist = $employeeModal->checkusernameexist($username,$where_condition);
if($isusernameexist)
{
$msgarray['username_orghead'] = "Employee username already exists. Please try again.";
$flag = 'false';
}

if($flag != 'false')
{
Expand All @@ -313,7 +320,8 @@ public function addorganisationhead($loginUserId)
$user_data = array(
'emprole' => $emprole,
'firstname' => $first_name,
'lastname' => $last_name,
'lastname' => $last_name,
'username' => $username,
'userfullname' => $userfullname,
'emailaddress' => $emailaddress,
'jobtitle_id'=> $jobtitle_id,
Expand Down Expand Up @@ -1823,6 +1831,14 @@ public function save($employeeform)
$msgarray['employeeNumId'] = "Employee ID already exists. Please try again.";
$errorflag = 'false';
}

$username = trim($this->_getParam('username', null));
$isusernameexist = $employeeModal->checkusernameexist($username,$where_condition);
if($isusernameexist)
{
$msgarray['username'] = "Employee username already exists. Please try again.";
$errorflag = 'false';
}

$isvalidorgstartdate = $orgInfoModel->validateEmployeeJoiningDate($date_of_joining,$unitid,$deptid);
if(!empty($isvalidorgstartdate))
Expand Down Expand Up @@ -1853,9 +1869,9 @@ public function save($employeeform)
$modeofentry = $this->_getParam('modeofentry',null);
$hid_modeofentry = $this->_getParam('hid_modeofentry',null);
$other_modeofentry = $this->_getParam('other_modeofentry',null);
$firstname = trim($this->_getParam('firstname',null));
$lastname = trim($this->_getParam('lastname',null));

$firstname = trim($this->_getParam('firstname',null));
$lastname = trim($this->_getParam('lastname',null));
$userfullname = $firstname.' '.$lastname;
$candidatereferredby = $this->_getParam('candidatereferredby',null);
$rccandidatename = $this->_getParam('rccandidatename',null);
Expand Down Expand Up @@ -1911,6 +1927,7 @@ public function save($employeeform)
'emprole' =>$emproleStr,
'firstname' => ($firstname!='')?$firstname:NULL,
'lastname' => ($lastname!='')?$lastname:NULL,
'username' => ($username!='')?$username:NULL,
$candidate_key => $candidate_value,
'emailaddress' => $emailaddress,
'jobtitle_id'=> $jobtitle_id,
Expand Down
17 changes: 16 additions & 1 deletion application/modules/default/forms/Organisationhead.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function init()

$firstname_orghead = new Zend_Form_Element_Text('firstname_orghead');
$firstname_orghead->setAttrib('maxLength', 50);
$firstname_orghead->setAttrib('onchange', 'onfieldchanged_orghead()');
$firstname_orghead->addFilter(new Zend_Filter_StringTrim());
$firstname_orghead->setRequired(true);
$firstname_orghead->addValidator('NotEmpty', false, array('messages' => 'Please enter first name of organization head.'));
Expand All @@ -49,6 +50,7 @@ public function init()
));
$lastname_orghead = new Zend_Form_Element_Text('lastname_orghead');
$lastname_orghead->setAttrib('maxLength', 50);
$lastname_orghead->setAttrib('onchange', 'onfieldchanged_orghead()');
$lastname_orghead->addFilter(new Zend_Filter_StringTrim());
$lastname_orghead->setRequired(true);
$lastname_orghead->addValidator('NotEmpty', false, array('messages' => 'Please enter last name of organization head.'));
Expand All @@ -59,6 +61,19 @@ public function init()
'regexNotMatch'=>'Please enter valid last name.'
)
));

$username_orghead = new Zend_Form_Element_Text('username_orghead');
$username_orghead->setAttrib('maxLength', 50);
$username_orghead->addFilter(new Zend_Filter_StringTrim());
$username_orghead->setRequired(true);
$username_orghead->addValidator('NotEmpty', false, array('messages' => 'Please enter username of organization head.'));
$username_orghead->addValidator("regex",true,array(
'pattern'=>'/^[a-zA-Z.\- ?]+$/',
'messages'=>array(

'regexNotMatch'=>'Please enter valid last name.'
)
));

$designation = new Zend_Form_Element_Text('designation');
$designation->setAttrib('maxLength', 50);
Expand Down Expand Up @@ -156,7 +171,7 @@ public function init()
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');

$this->addElements(array($id,$description,$lastname_orghead,$firstname_orghead,$designation,$employeeId,$prefix_id,$emprole,$emailaddress,$jobtitle,$position,$date_of_joining,$submit,$employeeNumId));//$email,$secondaryemail,
$this->addElements(array($id,$description,$lastname_orghead,$username_orghead,$firstname_orghead,$designation,$employeeId,$prefix_id,$emprole,$emailaddress,$jobtitle,$position,$date_of_joining,$submit,$employeeNumId));//$email,$secondaryemail,

$this->setElementDecorators(array('ViewHelper'));
$this->setElementDecorators(array('File'),array('org_image'));
Expand Down
25 changes: 23 additions & 2 deletions application/modules/default/forms/employee.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,18 @@ public function init()
$first_name->setLabel("First Name");
$first_name->setAttrib("class", "formDataElement");
$first_name->setAttrib('maxlength', 50);
$first_name->setAttrib('onchange', 'onfieldchanged()');

$last_name = new Zend_Form_Element_Text("lastname");
$last_name->setLabel("Last Name");
$last_name->setAttrib("class", "formDataElement");
$last_name->setAttrib('maxlength', 50);
$last_name->setAttrib('onchange', 'onfieldchanged()');

$username = new Zend_Form_Element_Text("username");
$username->setLabel("Username");
$username->setAttrib("class", "formDataElement");
$username->setAttrib('maxlength', 50);

$other_modeofentry = new Zend_Form_Element_Text("other_modeofentry");
$other_modeofentry->setLabel("Mode of Employment(Other)");
Expand Down Expand Up @@ -300,6 +307,7 @@ public function init()

$last_name->setRequired(true);
$last_name->addValidator('NotEmpty', false, array('messages' => 'Please enter last name.'));

}
else if($modeofentry_val == 'Other' || $hid_modeofentry_val == 'Direct')
{
Expand Down Expand Up @@ -334,6 +342,9 @@ public function init()

$last_name->setRequired(true);
$last_name->addValidator('NotEmpty', false, array('messages' => 'Please enter last name.'));

$username->setRequired(true);
$username->addValidator('NotEmpty', false, array('messages' => 'Please enter username.'));
}
/*$userfullname->addValidator("regex",true,array(
'pattern'=>'/^([a-zA-Z.]+ ?)+$/',
Expand All @@ -357,7 +368,17 @@ public function init()

'regexNotMatch'=>'Please enter only alphabets.'
)
));
));
$username->setRequired(true);
$username->addValidator('NotEmpty', false, array('messages' => 'Please enter username.'));

$username->addValidator("regex",true,array(
'pattern'=>'/^([a-zA-Z.]+ ?)+$/',
'messages'=>array(

'regexNotMatch'=>'Please enter only alphabets.'
)
));

$other_modeofentry->addValidator("regex",true,array(
'pattern'=>'/^([a-zA-Z.]+ ?)+$/',
Expand Down Expand Up @@ -427,7 +448,7 @@ public function init()
$position,$prefix_id,$extension_number,$office_number,$office_faxnumber,$yearsofexp,$date_of_joining,$date_of_leaving,$submit,$employeeId,
$modeofentry,$candidatereferredby,$rccandidatename,$emailaddress,
$emprole,$hid_modeofentry,$hid_rccandidatename,$other_modeofentry,$act_inact,
$disp_requi,$first_name,$last_name,$employeeNumId,$final_emp_id));
$disp_requi,$first_name,$last_name,$username,$employeeNumId,$final_emp_id));
$this->setElementDecorators(array('ViewHelper'));
$this->setElementDecorators(array(
'UiWidgetElement',
Expand Down
2 changes: 1 addition & 1 deletion application/modules/default/models/Businessunits.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getBusinessUnitsData($sort, $by, $pageNo, $perPage,$searchQuery)

$businessunitsdata = $this->select()
->setIntegrityCheck(false)
->from(array('b' => 'main_businessunits'),array('id'=>'distinct(b.id)','isactive'=>'b.isactive','unitcode'=>'b.unitcode','address1'=>'b.address1','unitname'=>'b.unitname','unithead'=>'b.unithead','startdate'=>'DATE_FORMAT(b.startdate,"'.DATEFORMAT_MYSQL.'")'))
->from(array('b' => 'main_businessunits'),array('id'=>'b.id','isactive'=>'b.isactive','unitcode'=>'b.unitcode','address1'=>'b.address1','unitname'=>'b.unitname','unithead'=>'b.unithead','startdate'=>'DATE_FORMAT(b.startdate,"'.DATEFORMAT_MYSQL.'")'))
->joinLeft(array('c'=>'main_cities'),'b.city=c.city_org_id',array('city'=>'c.city'))
->joinLeft(array('s'=>'main_states'),' s.state_id_org = b.state',array('state'=>'s.state'))
->joinLeft(array('cn'=>'main_countries'),' cn.country_id_org = b.country',array('country'=>'cn.country'))
Expand Down
10 changes: 10 additions & 0 deletions application/modules/default/models/Employee.php
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,16 @@ public function checkemployeeidexist($employeeId,$where_condition)
$data = $result->fetch();
return $data['emp_count'];
}

public function checkusernameexist($username,$where_condition)
{
$db = Zend_Db_Table::getDefaultAdapter();
$query = "select count(id) as emp_count from main_users where username='".$username."' $where_condition ";
$result = $db->query($query);
$data = $result->fetch();
return $data['emp_count'];
}

// to get hr employees
public function getHrEmployees()
{
Expand Down
12 changes: 6 additions & 6 deletions application/modules/default/models/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Default_Model_Users extends Zend_Db_Table_Abstract
* @return boolean
*/
public function isLdapUser($username) {
return false;

return LDAP_ENABLED == 'true';
}

public function getUserObject($username)
Expand All @@ -51,7 +51,7 @@ public function getUserObject($username)
array('group_id'=>'r.group_id'))
->joinLeft(array('e'=>'main_employees'),"e.user_id = u.id",array('e.reporting_manager','e.is_orghead','e.businessunit_id','e.department_id','e.jobtitle_id','e.position_id'))
//->where("(u.employeeId = '".$username."' OR u.emailaddress = '".$username."') and u.isactive = 1");
->where("u.isactive = 1 and (u.employeeId = ? OR u.emailaddress = ?)",array($username));
->where("u.isactive = 1 and (u.employeeId = ? OR u.emailaddress = ? OR u.username = ?)",array($username));

$result_one = $this->fetchAll($query);

Expand Down Expand Up @@ -96,7 +96,7 @@ public function isActiveUser($corpEmail){
$userData = $db->select()
->from(array('a' => 'main_users'),array('aid' => 'a.id'))
->joinInner(array('r'=>'main_roles'), 'r.id=a.emprole',array("def_status" => "if(r.group_id in (1,5) and a.userstatus = 'new','old',a.userstatus)"))
->where("a.isactive = 1 AND r.isactive = 1 AND a.emptemplock = 0 AND (a.employeeId = ? OR a.emailaddress = ?)",array($corpEmail));
->where("a.isactive = 1 AND r.isactive = 1 AND a.emptemplock = 0 AND (a.employeeId = ? OR a.emailaddress = ? OR a.username = ?)",array($corpEmail));

$new_userdata = $db->select()
->from(array('ac'=>$userData),array('count'=>'count(*)'))
Expand All @@ -118,7 +118,7 @@ public function getActiveStatus($corpEmail)
$userData = $this->select()->setIntegrityCheck(false)
->from(array('u' => 'main_users'),array('status' => 'u.isactive','isaccountlock' =>'u.emptemplock'))

->where("u.employeeId = ? OR u.emailaddress = ?",array($corpEmail));
->where("u.employeeId = ? OR u.emailaddress = ? OR u.username",array($corpEmail));

}
catch(Exception $e)
Expand All @@ -135,7 +135,7 @@ public function getUserDateOfJoining($corpEmail)
$userData = $this->select()->setIntegrityCheck(false)
->from(array('u' => 'main_users'),array())
->joinInner(array('e'=>'main_employees'), 'e.user_id=u.id',array('date_of_joining',"doj" => "if(e.date_of_joining <= CURDATE(),1,0)"))
->where("u.employeeId = ? OR u.emailaddress = ?",array($corpEmail));
->where("u.employeeId = ? OR u.emailaddress = ? OR u.username",array($corpEmail));

}
catch(Exception $e)
Expand Down
12 changes: 10 additions & 2 deletions application/modules/default/views/scripts/employee/add.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,16 @@ if(!empty($this->msgarray) && isset($this->msgarray))
<?php echo $this->form->lastname; ?>
</div>
<span id="errors-<?php echo $this->form->lastname->getId(); ?>" class="errors"><?php echo isset($this->msgarray['lastname'])?$this->msgarray['lastname']:"";?></span>
</div>
</div>
</div>

</div>
<div class="new-form-ui" >
<label class="required"><?php echo $this->form->username->getLabel(); ?></label>
<div class="division">
<?php echo $this->form->username; ?>
</div>
<span id="errors-<?php echo $this->form->username->getId(); ?>" class="errors"><?php echo isset($this->msgarray['username'])?$this->msgarray['username']:"";?></span>
</div>
<div class="new-form-ui" id="iddiv_referredby" style="display:none;">
<label><?php echo $this->form->candidatereferredby->getLabel(); ?></label>
<div class="division"><?php echo $this->form->candidatereferredby; ?></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,20 @@
</div>
<div class="new-form-ui">
<label class="required">Last Name </label>
<div class="division"><?php echo $this->form->lastname_orghead; ?>
<div class="division"><?php echo $this->form->lastname_orghead; ?>
<?php if(isset($this->msgarray['lastname_orghead'])){?>
<span class="errors" id="errors-<?php echo $this->form->lastname_orghead->getId(); ?>"><?php echo $this->msgarray['lastname_orghead'];?></span>
<?php }?>
</div>
<?php }?>
</div>
</div>
<div class="new-form-ui">
<label class="required">Username </label>
<div class="division"><?php echo $this->form->username_orghead; ?>
<?php if(isset($this->msgarray['username_orghead'])){?>
<span class="errors" id="errors-<?php echo $this->form->username_orghead->getId(); ?>"><?php echo $this->msgarray['username_orghead'];?></span>
<?php }?>
</div>
</div>

<div class="new-form-ui">
<label><?php echo $this->form->prefix_id->getLabel(); ;?> </label>
Expand Down
10 changes: 9 additions & 1 deletion application/modules/default/views/scripts/employee/edit.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,15 @@ $report_opt = $this->report_opt;
<?php echo $this->form->lastname; ?>
</div>
<span id="errors-<?php echo $this->form->lastname->getId(); ?>" class="errors"><?php echo isset($this->msgarray['lastname'])?$this->msgarray['lastname']:"";?></span>
</div>
</div>

<div class="new-form-ui" >
<label class="required"><?php echo $this->form->username->getLabel(); ?></label>
<div class="division">
<?php echo $this->form->username; ?>
</div>
<span id="errors-<?php echo $this->form->username->getId(); ?>" class="errors"><?php echo isset($this->msgarray['username'])?$this->msgarray['username']:"";?></span>
</div>
</div>
<div class="new-form-ui" id="iddiv_referredby" style="display:none;">
<label><?php echo $this->form->candidatereferredby->getLabel(); ?></label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ $data = $this->data;
sapp_Helper::viewBody('alt',$this->form->prefix_id->getLabel(),(!sapp_Helper::SappEmpty($this->data['prefix_id']))?$this->data['prefix_id']:"...",$this->form->firstname->getLabel(),(!sapp_Helper::SappEmpty($this->form->firstname->getValue()))?$this->form->firstname->getValue():"...");

sapp_Helper::viewBody('nor',$this->form->lastname->getLabel(),(!sapp_Helper::SappEmpty($this->form->lastname->getValue()))?$this->form->lastname->getValue():"...",$this->form->modeofentry->getLabel(),(!sapp_Helper::SappEmpty($this->form->modeofentry->getValue()))?$this->form->modeofentry->getValue():"...");
sapp_Helper::viewBody('nor',$this->form->username->getLabel(),(!sapp_Helper::SappEmpty($this->form->username->getValue()))?$this->form->username->getValue():"...",'','');

?>
<div id="iddiv_canditatename">
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
require_once 'public/email_constants.php';
require_once 'public/emptabconfigure.php';
require_once 'public/db_constants.php';
require_once 'public/ldap_constants.php';
require_once 'public/application_constants.php';
require_once 'public/mail_settings_constants.php';
require_once 'application/modules/default/library/sapp/Global.php';
Expand Down
Loading