/** * Check if there is no user in system before run install */ private function checkinstallrequirement() { $needInstall = false; //Check User tables exists if (!$this->usertablesExists()) { $needInstall = true; } else { $userCount = \Model\User::getUsers(array(), '', '', '', true); if ($userCount > 0) { $needInstall = false; } else { $needInstall = true; } } return $needInstall; }
public function jsondataAction() { $formData = array(); $this->registry->session->set('securityToken', Helper::getSecurityToken()); //Token $page = $this->getCurrentPage(); $emailFilter = (string) $this->postBag->get('email'); $groupidFilter = (int) $this->postBag->get('groupid'); $regionFilter = (int) $this->postBag->get('region'); $genderFilter = (int) $this->postBag->get('gender'); $idFilter = (int) $this->postBag->get('id'); $keywordFilter = Helper::plaintext($this->postBag->get('keyword')); $searchKeywordIn = (string) $this->postBag->get('searchin'); //check sort column condition $sortby = $this->postBag->get('sortby'); if ($sortby == '') { $sortby = 'id'; } $formData['sortby'] = $sortby; $sorttype = $this->postBag->get('sorttype'); if (strtoupper($sorttype) != 'ASC') { $sorttype = 'DESC'; } $formData['sorttype'] = $sorttype; if ($emailFilter != "") { $formData['femail'] = $emailFilter; } if ($groupidFilter > 0) { $formData['fgroupid'] = $groupidFilter; } if ($regionFilter > 0) { $formData['fregion'] = $regionFilter; } if ($genderFilter > 0) { $formData['fgender'] = $genderFilter; } if ($idFilter > 0) { $formData['fid'] = $idFilter; } if (strlen($keywordFilter) > 0) { if ($searchKeywordIn == 'screenname') { } elseif ($searchKeywordIn == 'fullname') { } $formData['fkeyword'] = $formData['fkeywordFilter'] = $keywordFilter; $formData['fsearchin'] = $formData['fsearchKeywordIn'] = $searchKeywordIn; } //tim tong so $total = \Model\User::getUsers($formData, $sortby, $sorttype, 0, true); //get latest account $Users = \Model\User::getUsers($formData, $sortby, $sorttype, ($page - 1) * $this->recordPerPage . ',' . $this->recordPerPage); $jsondata = array(); $jsondata['total'] = (int) $total; $jsondata['totalpage'] = (int) ceil($total / $this->recordPerPage); $jsondata['page'] = (int) $page; $jsondata['token'] = (string) $this->registry->session->get('securityToken'); $jsondata['sortby'] = (string) $sortby; $jsondata['sorttype'] = (string) $sorttype; $jsondata['primaryproperty'] = 'id'; $jsondata['editurlprefix'] = $this->registry->conf['rooturl_admin'] . $this->registry->controller . '/edit/id/'; $jsondata['deleteurlprefix'] = $this->registry->conf['rooturl_admin'] . $this->registry->controller . '/delete/id/'; $jsondata['items'] = array(); foreach ($Users as $myUser) { $jsondata['items'][] = array('id' => (int) $myUser->id, 'email' => (string) $myUser->email, 'fullname' => (string) $myUser->fullname, 'groupid' => (string) $myUser->getGroupName(), 'gender' => (string) $myUser->getGenderText(), 'region' => (string) $myUser->getRegionName(), 'datecreated' => date('d/m/Y', $myUser->datecreated), 'datelastaction' => date('H:i:s, d/m/Y', $myUser->datelastaction)); } $this->registry->response->headers->set('Content-type', 'text/json'); $contents = json_encode($jsondata); $this->registry->response->setContent($contents); }
protected function submitValidate($formData, &$error) { $pass = true; //check form token if ($formData['ftoken'] != $this->registry->session->get('forgotpassToken')) { $pass = false; $error[] = $this->registry->lang['default']['securityTokenInvalid']; } //check spam $forgotpassExpire = 10; //seconds if ($this->registry->session->has('forgotpassSpam') && time() - $this->registry->session->get('forgotpassSpam') < $forgotpassExpire) { $error[] = $this->registry->lang['controller']['errSpam']; $pass = false; } //check email length if (!\Litpi\Helper::validateEmail($formData['femail'])) { $error[] = $this->registry->lang['controller']['errInvalidEmail']; $pass = false; } else { $myUser = \Model\User::getUsers(array('femail' => $formData['femail'])); if ($myUser[0]->id == 0) { $error[] = $this->registry->lang['controller']['errAccountInvalid']; $pass = false; } } return $pass; }