function editprofileAction() { $r = $this->getRequest(); $auth = Zend_Auth::getInstance(); if (!$auth->hasIdentity()) { $this->_redirect(KUTU_ROOT_URL . '/helper/sso/login' . '?returnTo=' . $sReturn); } else { $username = $auth->getIdentity()->username; //echo $auth->getIdentity()->guid; //die(); $this->view->username = $username; } $tblUser = new Kutu_Core_Orm_Table_User(); $row = $tblUser->fetchRow("username='******'"); $modDir = $this->getFrontController()->getModuleDirectory(); require_once $modDir . '/components/MyAccount/Menu.php'; $w = new MyAccount_Menu(); $this->view->widget1 = $w; $this->view->row = $row; $this->view->message = ""; if ($r->isPost()) { $aData = $r->getParams(); //below is for security purpose. Making sure that the GUID being edited is the GUID of the logged in user $aData['guid'] = $auth->getIdentity()->guid; try { $bpm = new Kutu_Core_Bpm_User(); $row = $bpm->editProfileByUser($aData); $this->view->row = $row; $this->view->message = "Data has been successfully saved."; } catch (Zend_Exception $e) { $this->view->message = $e->getMessage(); } } }
public function save($aData) { $guid = $aData['kopel']; //if not empty, there are 2 possibilities $tblUser = new Kutu_Core_Orm_Table_User(); $row = $tblUser->fetchRow("kopel='{$guid}'"); if (isset($aData['email'])) { $row->email = $aData['email']; } if (isset($aData['fullName'])) { $row->fullName = $aData['fullName']; } if (isset($aData['chkGender'])) { $row->gender = $aData['chkGender'] == 1 ? 'L' : 'P'; } if (isset($aData['year'])) { $row->birthday = $aData['year'] . '-' . $aData['month'] . '-' . $aData['day']; } if (isset($aData['education'])) { $row->educationId = $aData['education']; } if (isset($aData['expense'])) { $row->expenseId = $aData['expense']; } if (isset($aData['company'])) { $row->company = $aData['company']; } if (isset($aData['businessType'])) { $row->businessTypeId = $aData['businessType']; } if (isset($aData['phone'])) { $row->phone = $aData['phone']; } if (isset($aData['fax'])) { $row->phone = $aData['fax']; } if (isset($aData['packageId'])) { $row->packageId = $aData['packageId']; } if (isset($aData['newArticle']) && $aData['newArticle'] == 1) { $row->newArticle = 'Y'; } else { if (!isset($aData['email']) && !isset($aData['username'])) { $row->newArticle = 'N'; } } if (isset($aData['newRegulation']) && $aData['newRegulation'] == 1) { $row->monthlyList = 'Y'; } else { if (!isset($aData['email']) && !isset($aData['username'])) { $row->monthlyList = 'N'; } } if (isset($aData['newWeeklyRegulation']) && $aData['newWeeklyRegulation'] == 1) { $row->weeklyList = 'Y'; } else { if (!isset($aData['email']) && !isset($aData['username'])) { $row->weeklyList = 'N'; } } $row->save(); return $row; }
function getMeEmailAction() { $this->_helper->layout()->disableLayout(); $request = $this->getRequest(); $email = $request->getParam('email') ? $request->getParam('email') : ''; $response = array(); if ($email == "undefined") { $response['failure'] = true; $response['message'] = 'Email is Empty'; } else { $tableUser = new Kutu_Core_Orm_Table_User(); $rowUser = $tableUser->fetchRow("email='" . $email . "'"); if (!empty($rowUser->email)) { $response['failure'] = true; $response['message'] = '<i><b>' . $email . '</b></i> is not available'; } else { $response['success'] = true; $response['message'] = '<i><b>' . $email . '</b></i> is available'; } } echo Zend_Json::encode($response); }
function checkUserEmail($email) { $tbluser = new Kutu_Core_Orm_Table_User(); $where = $tbluser->getAdapter()->quoteInto("email=?", $email); $rowset = $tbluser->fetchRow($where); if ($rowset) { $response['failure'] = true; $response['message'] = "Your email {$email} is not available"; echo Zend_Json::encode($response); exit; } }
public function save($aData) { if (isset($aData['fullname']) && !empty($aData['fullname'])) { $aData['firstname'] = $aData['fullname']; } if (empty($aData['firstname'])) { throw new Zend_Exception('Firstname can not be EMPTY!'); } $tblUser = new Kutu_Core_Orm_Table_User(); $gman = new Kutu_Core_Guid(); $guid = isset($aData['guid']) && !empty($aData['guid']) ? $aData['guid'] : $gman->generateGuid(); //if not empty, there are 2 possibilities $tblUser = new Kutu_Core_Orm_Table_User(); $row = $tblUser->fetchRow("guid='{$guid}'"); if (empty($row)) { if (empty($aData['username'])) { throw new Zend_Exception('Username can not be EMPTY!'); } if (empty($aData['password'])) { throw new Zend_Exception('Password can not be EMPTY!'); } $row = $tblUser->createRow(); if (isset($aData['username']) && !empty($aData['username'])) { //check if username was already taken $username = $aData['username']; $tblUser = new Kutu_Core_Orm_Table_User(); $rowUsername = $tblUser->fetchRow("username='******'"); if ($rowUsername) { throw new Zend_Exception('Username exists'); } $row->username = $aData['username']; } if (isset($aData['password']) && !empty($aData['password'])) { $password = $aData['password']; $crypt = new Kutu_Crypt_Password(); $password = $crypt->encryptPassword($password); $row->password = $password; } } if (isset($aData['firstname'])) { $row->firstname = $aData['firstname']; } if (isset($aData['lastname'])) { $row->lastname = $aData['lastname']; } if (isset($aData['email'])) { $row->email = $aData['email']; } if (isset($aData['bbPin'])) { $row->bbPin = $aData['bbPin']; } if (isset($aData['clientId'])) { $row->clientId = $aData['clientId']; } if (isset($aData['mainAddress'])) { $row->mainAddress = $aData['mainAddress']; } if (isset($aData['city'])) { $row->city = $aData['city']; } if (isset($aData['state'])) { $row->state = $aData['state']; } if (isset($aData['zip'])) { $row->zip = $aData['zip']; } if (isset($aData['phone'])) { $row->phone = $aData['phone']; } if (isset($aData['fax'])) { $row->fax = $aData['fax']; } if (isset($aData['url'])) { $row->url = $aData['url']; } if (isset($aData['countryId'])) { $row->countryId = $aData['countryId']; } if (isset($aData['company'])) { $row->company = $aData['company']; } if (isset($aData['companySizeId'])) { $row->companySizeId = $aData['companySizeId']; } if (isset($aData['jobId'])) { $row->jobId = $aData['jobId']; } if (isset($aData['industryId'])) { $row->industryId = $aData['industryId']; } if (isset($aData['isActive'])) { $row->isActive = $aData['isActive']; } if (isset($aData['registrationDate'])) { $row->registrationDate = $aData['registrationDate']; } if (isset($aData['activationDate'])) { $row->activationDate = $aData['activationDate']; } if (isset($aData['activationCode'])) { $row->activationCode = $aData['activationCode']; } if (isset($aData['expirationDate'])) { $row->expirationDate = $aData['expirationDate']; } $row->save(); return $row; }
public function loginAction() { //$this->_helper->layout->disableLayout(); $this->_helper->layout()->setLayout('layout-lgs'); $r = $this->getRequest(); //$returnTo = $r->getParam('returnTo'); //$this->view->returnTo = urlencode($returnTo); if ($r->isPost()) { $returnTo = $r->getParam('returnTo'); $this->view->returnTo = $returnTo; Zend_Session::rememberMe(86400); $saveHandler = Zend_Session::getSaveHandler(); $saveHandler->setLifetime(87500)->setOverrideLifetime(true); Zend_Session::start(); $username = $r->getParam('username'); $password = $r->getParam('password'); $registry = Zend_Registry::getInstance(); $application = $registry->get('application'); //ensure resource Session has/is initialized; //$application->getBootstrap()->bootstrap('identity'); $identity = $application->getBootstrap()->getResource('identity'); $authAdapter = $identity->authAdapter; $authAdapter->setIdentity($username)->setCredential($password); $auth = Zend_Auth::getInstance(); $authResult = $auth->authenticate($authAdapter); if ($authResult->isValid()) { Zend_Session::regenerateId(); // success : store database row to auth's storage $data = $authAdapter->getResultRowObject(); $auth->getStorage()->write($data); if (strpos($returnTo, '?')) { $sAddition = '&'; } else { $sAddition = '?'; } //[TODO] update last login date in tbl User //[TODO] update last login IP in tbl User $tblUser = new Kutu_Core_Orm_Table_User(); $row = $tblUser->fetchRow($tblUser->select()->where('username = ?', $username)); $ip = $this->real_ip_address(); $row->lastLoginIp = $ip; $today = date('Y-m-d h:i:s'); $row->lastLoginDate = $today; $row->save(); header("location: " . $returnTo . $sAddition . "PHPSESSID=" . Zend_Session::getId()); } else { if ($authResult->getCode() != -51) { // failure : clear database row from session Zend_Auth::getInstance()->clearIdentity(); } $this->view->errorMessage = "Login GAGAL"; } } else { Zend_Session::start(); $returnTo = $r->getParam('returnTo'); if (!empty($returnTo)) { $returnTo = urldecode($returnTo); $this->view->returnTo = $returnTo; } else { //$returnTo = KUTU_ROOT_URL.'/identity/account'; $returnTo = KUTU_ROOT_URL . '/pages'; $this->view->returnTo = $returnTo; } //check sudah login belum $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { //echo "punya identitas"; if (strpos($returnTo, '?')) { $sAddition = '&'; } else { $sAddition = '?'; } header("location: " . $returnTo . $sAddition . "PHPSESSID=" . Zend_Session::getId()); } } }
static function get_user_id($username) { $tblUser = new Kutu_Core_Orm_Table_User(); $rowUser = $tblUser->fetchRow("username='******'"); return $rowUser->kopel; }
function checkemailAction() { $this->_helper->viewRenderer->setNoRender(TRUE); $email = $this->_getParam('email') ? $this->_getParam('email') : ''; $modelUser = new Kutu_Core_Orm_Table_User(); $rowset = $modelUser->fetchRow("email='{$email}'"); if ($rowset) { $valid = 'false'; } else { $valid = 'true'; } echo $valid; die; }
function migrationUser() { $data = $this->transformMigrationUser($_POST); /* echo '<pre>'; print_r($data); echo '</pre>'; * */ $modelUser = new Kutu_Core_Orm_Table_User(); $rowUser = $modelUser->fetchRow("username='******'username'] . "'"); if (!$rowUser) { $modelUser->insert($data); $this->updateKopel(); $groupName = $this->getGroupName($_POST['packageId']); $acl = new Kutu_Acl_Adapter_Local(); //$acl->addUser($_POST['username'],$groupName); $acl->addUserToGroup($_POST['username'], $groupName); } }