Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

Commit

Permalink
oe 2.2 ,menu,add act,mt labels translate
Browse files Browse the repository at this point in the history
  • Loading branch information
Hmayak Tigranyan committed Oct 4, 2013
1 parent f12415f commit 1caf6ca
Show file tree
Hide file tree
Showing 8 changed files with 875 additions and 133 deletions.
14 changes: 11 additions & 3 deletions data/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ public function __construct($table = false, $pkeyarr=false, $db=false, $options=
parent::__construct('audit_log', $pkey ,$db , $options);
}

public static function saveLogDetails($entity, $record_number , $action , $description = null , $query=null ){
public static function saveLogDetails($entity, $record_number , $action , $description = null , $query=null ,$module = null ,$username = null){
$log = new Log();
$log->log_record_number = shn_create_uuid('log');
$log->entity = $entity;
$log->module = $_GET['mod'];
if($module){
$log->module = $module;
}else{
$log->module = $_GET['mod'];
}
//var_dump($_GET);
if( isset($_GET['eid']) ){
$mrn = $_GET['eid'];
Expand All @@ -72,7 +76,11 @@ public static function saveLogDetails($entity, $record_number , $action , $desc
$log->action = $action;
$log->description = $description;
$log->query = $query;
$log->username = $_SESSION['username'];
if($username){
$log->username = $username;
}else{
$log->username = $_SESSION['username'];
}

$log->Save();
}
Expand Down
10 changes: 8 additions & 2 deletions inc/security/handler_auth.inc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ if (isset($_POST['login']) && 'login' == $_POST['login']) {
$user = UserHelper::loadFromUsername($username);
if ($captchavalid) {
if ($user == null) {
Log::saveLogDetails('login', $_SERVER['REMOTE_ADDR'], "NOTOK", "NOTOK",null,'login',$username);
$global['nouser'] = _t('USER_NOT_FOUND__INVALID_USERNAME_OR_PASSWORD__PLEASE_TRY_AGAIN_');
} else if ($user->status != 'active') {
Log::saveLogDetails('login', $_SERVER['REMOTE_ADDR'], "NOTOK", "NOTOK",null,'login',$username);
$global['loginerror'] = _t('INVALID_USERNAME_OR_PASSWORD__PLEASE_TRY_AGAIN_');
} else {
if ($user->isPasswordMatch($password)) {
Log::saveLogDetails('login', $_SERVER['REMOTE_ADDR'], "OK", "OK",null,'login',$username);
//if so registor the user in the session.
//MUST REMEMBER ALLWAYS REGENERATE SESSION ID WHEN PERMISSION LEVEL CHANGES *******
if (!isset($_COOKIE['cookie-check'])) {
Expand All @@ -52,8 +55,10 @@ if (isset($_POST['login']) && 'login' == $_POST['login']) {
}
}
}
else
else{
Log::saveLogDetails('login', $_SERVER['REMOTE_ADDR'], "NOTOK", "NOTOK",null,'login',$username);
$global['loginerror'] = _t('INVALID_USER_ID_OR_PASSWORD__PLEASE_TRY_AGAIN_');
}
}
}
}elseif( !empty($_SESSION['check_TSV']) && !empty($_POST['code']) ){
Expand Down Expand Up @@ -93,7 +98,7 @@ if ($_GET['act'] == 'logout') {
}
}


if($_GET['mod'] != 'home' || $_GET['act'] !='download' ){
//check if the user session exists
if (!isset($_SESSION['username']) || $_SESSION['check_TSV']) {
//normal auth
Expand All @@ -108,4 +113,5 @@ if (!isset($_SESSION['username']) || $_SESSION['check_TSV']) {
//if exists set the global username
$global['username'] = $_SESSION['username'];
}
}
?>
92 changes: 39 additions & 53 deletions inc/shnFrontController.class.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* shnFrontController is the main Controler of the system which is
* responsible for
Expand Down Expand Up @@ -31,25 +32,21 @@
* @package Framework
*
*/
class shnFrontController {

class shnFrontController
{
//no need to hide the following these should be accessible throughout the system.
public
$request = NULL,
$module = NULL,
$view = NULL,
$action = NULL;

public
$request = NULL,
$module = NULL,
$view = NULL,
$action = NULL;
//member to hold the instance of controler
private static $controller;

public function __construct()
{
public function __construct() {
$this->request = shnRequest::getRequest();
}


/**
* getController return an instance of controler class. This function follows singleton
* pattern
Expand All @@ -58,8 +55,7 @@ public function __construct()
* @access public
* @return void
*/
static public function getController()
{
static public function getController() {
if (!isset(self::$controller)) {
self::$controller = new shnFrontController();
}
Expand All @@ -74,34 +70,29 @@ static public function getController()
* @access public
* @return void
*/
static public function getView()
{
return self::$controller->view;
static public function getView() {
return self::$controller->view;
}


/**
* getModule return an instance of the module
*
* @static
* @access public
* @return void
*/
static public function getModule()
{
return self::$controller->module;
static public function getModule() {
return self::$controller->module;
}


/**
* setDefaultModule set the module to default within the controler
*
* @static
* @access public
* @return void
*/
static public function loadDefaultModule()
{
static public function loadDefaultModule() {
$module = new shnModule();
self::$controller->module = $module;
}
Expand All @@ -113,15 +104,12 @@ static public function loadDefaultModule()
* @access public
* @return void
*/
static public function loadDefaultView()
{
static public function loadDefaultView() {
$view = new shnView_HTML();
self::$controller->view = $view;
}


public function setAction($action = null)
{
public function setAction($action = null) {
$this->action = $action;
}

Expand All @@ -131,31 +119,29 @@ public function setAction($action = null)
* @access public
* @return void
*/
public function loadRequestModule()
{
public function loadRequestModule() {
$module = $this->request->module;
$file = APPROOT."mod/$module/{$module}Module.class.php";
if(!file_exists($file))
$file = APPROOT . "mod/$module/{$module}Module.class.php";
if (!file_exists($file))
throw new shn404Exception();

include_once($file);

//check and create an instance of the module action class
$class = $module.'Module';
if(!class_exists($class))
$class = $module . 'Module';
if (!class_exists($class))
throw new shn404Exception();

$instance = new $class();

//check if the module action class is an instance of shnModule
if(!($instance instanceof shnModule))
if (!($instance instanceof shnModule))
throw new shn404Exception();

//load the instance to controler
$this->module = $instance;
$this->module = $instance;
}


/**
* _load_view() will load the view object to the controler.
* Function follows the singleton pattern since we do not need
Expand All @@ -164,22 +150,21 @@ public function loadRequestModule()
* @access protected
* @return void
*/
protected function loadRequestView()
{
protected function loadRequestView() {
$view = $this->request->view;
//load the view class to match the stream type
$class = "shnView_".strtoupper($view);
if(!class_exists($class))
$class = "shnView_" . strtoupper($view);
if (!class_exists($class))
throw new shn404Exception();

$instance = new $class($this);

//check if the class is a view instance
if(!($instance instanceof shnView))
if (!($instance instanceof shnView))
throw new shn404Exception();

//load the instance to controler
$this->view = $instance;
$this->view = $instance;
}

/**
Expand All @@ -188,9 +173,8 @@ protected function loadRequestView()
* @access public
* @return void
*/
public function dispatch()
{
global $global ;
public function dispatch() {
global $global;

//load request module
$this->loadRequestModule();
Expand All @@ -202,17 +186,18 @@ public function dispatch()
$this->view->setTemplate($this->request->tpl);

//wait a minit before we dispatch lets check for permissions
include_once APPROOT.'inc/security/lib_acl.inc';
acl_mod_allowed( $this->request->module );

include_once APPROOT . 'inc/security/lib_acl.inc';

if ($this->request->module != 'home' || $this->request->action != 'download') {
acl_mod_allowed($this->request->module);
}
$this->sendResponce();
}

public function sendResponce()
{
$action = 'act_'.$this->action;
public function sendResponce() {
$action = 'act_' . $this->action;
//check if the method exists
if(!method_exists($this->module,$action))
if (!method_exists($this->module, $action))
throw new shn404Exception();
//execute the action and change the module state
$this->module->$action();
Expand All @@ -223,4 +208,5 @@ public function sendResponce()
//render data
$this->view->render();
}

}
25 changes: 20 additions & 5 deletions mod/events/eventsModule.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function __construct() {
global $messages;
global $event;
$this->load_related_event();
if (isset($_GET['act']) && !in_array($_GET['act'], array('new_event', 'browse', 'geocode', 'browse_act', 'browse_intervention','add_act_full'))) {
if (isset($_GET['act']) && !in_array($_GET['act'], array('new_event', 'browse', 'geocode', 'browse_act', 'browse_intervention', 'add_act_full'))) {
$_GET['eid'] = (isset($_GET['eid'])) ? $_GET['eid'] : $_SESSION['eid'];
if (!isset($_GET['eid'])) {
shnMessageQueue::addInformation($messages['select_event']);
Expand Down Expand Up @@ -596,20 +596,35 @@ function act_add_act_full() {
'validation' => array(0 => '', 1 => 'notnull',),
'required' => true, 'help' => '2203',)));

if (isset($_GET['event_id'])) {
if (isset($_GET['event_id'])) {
$_SESSION['eid'] = $_GET['event_id'];
set_redirect_header('events', 'add_victim', null, array('eid' => $_SESSION['eid'],'view'=>'search_victim'));
set_redirect_header('events', 'add_victim', null, array('eid' => $_SESSION['eid'], 'view' => 'search_victim'));
}

$this->events_form = $events_form;
}

public function act_add_act() {

if (isset($_REQUEST['acts'])) {
$_SESSION['eid'] = $_GET['eid'];
$acts = $_REQUEST['acts'];

$act_id = $acts[0];
$act = new Act();
$act->LoadFromRecordNumber($act_id);
$act->LoadRelationships();
$victim = $act->victim;
$_SESSION['vp']['victim'] = $victim;

} else {
$victim = $_REQUEST['victim'];
}
//fetch the victim
$this->victim = new Person();
$this->victim->LoadFromRecordNumber($_REQUEST['victim']);
$this->victim->LoadFromRecordNumber($victim);

$this->set_victim_dob($_REQUEST['victim']);
$this->set_victim_dob($victim);
//if action is not set
$this->act_form = act_form('new');
if (isset($_POST['save']) || isset($_POST['add_ad']) || isset($_POST['save_without'])) {
Expand Down
Loading

0 comments on commit 1caf6ca

Please sign in to comment.