src/Controller/PageHistoricController.php
public function savePageHistoricAction()
    {
        $responseData = $this->params()->fromRoute('datas', $this->params()->fromQuery('datas', ''));
        
    	$idPage = isset($responseData['idPage']) ? $responseData['idPage'] : (!empty($responseData[0]['idPage'])?($responseData[0]['idPage']):0);
        $isNew =  isset($responseData['isNew']) ? $responseData['isNew'] : (!empty($responseData[0]['isNew'])?($responseData[0]['isNew']):0);
        
        $response = array(
        		'idPage' => $idPage,
        		'isNew' => $isNew
        );
        $this->getEventManager()->trigger('meliscmspagehistoric_historic_save_start', $this, $response);
        
        $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth');
    	$melisPageHistoricTable = $this->getServiceLocator()->get('MelisPageHistoricTable');	

    	$pageAction = $this->params()->fromRoute('pageActionUsed', $this->params()->fromQuery('pageActionUsed',''));
    	$histDatas  = array();
    	
    	$container = new Container('meliscms');
    	$datas = array();
    	
    	if (isset($container['action-page-tmp']['success'])
    		&& $container['action-page-tmp']['success'] == 0)
    		return;
    	
    	// Update from the different save actions done
    	if (!empty($container['action-page-tmp']))
    	{
            if (!empty($container['action-page-tmp']['datas']))
                $datas = $container['action-page-tmp']['datas'];
    	}
    	
    	$description = '';

    	switch ($pageAction) {
    	    case 'Save':
    	        if ($isNew) {
    	            $description = 'tr_melispagehistoric_description_text_new';
    	        } else {
    	            $description = 'tr_melispagehistoric_description_text_save';
    	        }
	            break;
    	    case 'Publish':
    	        $description = 'tr_melispagehistoric_description_text_publish';
	            break;
    	    case 'Unpublish':
    	        $description = 'tr_melispagehistoric_description_text_unpublished';
	            break;
    	}

    	if ($idPage) {
    	    $userId = (int) null;
    	    $userAuthDatas =  $melisCoreAuth->getStorage()->read();

    	    if ($userAuthDatas)
    	       $userId = $userAuthDatas->usr_id;
    	     
    	    $histDatas = array(
    	        'hist_page_id' => $idPage,
    	        'hist_action'  => $pageAction,
    	        'hist_date'     => date('Y-m-d H:i:s'),
    	        'hist_user_id' => $userId,
    	        'hist_description' => $description
    	    );
    	    
    	    $melisPageHistoricTable->save($histDatas);
    	}

    	$this->getEventManager()->trigger('meliscmspagehistoric_historic_save_end', $this, $histDatas);
    }
public function savePageHistoricAction()
    {
        $responseData = $this->params()->fromRoute('datas', $this->params()->fromQuery('datas', ''));
        
    	$idPage = isset($responseData['idPage']) ? $responseData['idPage'] : (!empty($responseData[0]['idPage'])?($responseData[0]['idPage']):0);
        $isNew =  isset($responseData['isNew']) ? $responseData['isNew'] : (!empty($responseData[0]['isNew'])?($responseData[0]['isNew']):0);
        
        $response = array(
        		'idPage' => $idPage,
        		'isNew' => $isNew
        );
        $this->getEventManager()->trigger('meliscmspagehistoric_historic_save_start', $this, $response);
        
        $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth');
    	$melisPageHistoricTable = $this->getServiceLocator()->get('MelisPageHistoricTable');	

    	$pageAction = $this->params()->fromRoute('pageActionUsed', $this->params()->fromQuery('pageActionUsed',''));
    	$histDatas  = array();
    	
    	$container = new Container('meliscms');
    	$datas = array();
    	
    	if (isset($container['action-page-tmp']['success'])
    		&& $container['action-page-tmp']['success'] == 0)
    		return;
    	
    	// Update from the different save actions done
    	if (!empty($container['action-page-tmp']))
    	{
            if (!empty($container['action-page-tmp']['datas']))
                $datas = $container['action-page-tmp']['datas'];
    	}
    	
    	$description = '';

    	switch ($pageAction) {
    	    case 'Save':
    	        if ($isNew) {
    	            $description = 'tr_melispagehistoric_description_text_new';
    	        } else {
    	            $description = 'tr_melispagehistoric_description_text_save';
    	        }
	            break;
    	    case 'Publish':
    	        $description = 'tr_melispagehistoric_description_text_publish';
	            break;
    	    case 'Unpublish':
    	        $description = 'tr_melispagehistoric_description_text_unpublished';
	            break;
    	}

    	if ($idPage) {
    	    $userId = (int) null;
    	    $userAuthDatas =  $melisCoreAuth->getStorage()->read();

    	    if ($userAuthDatas)
    	       $userId = $userAuthDatas->usr_id;
    	     
    	    $histDatas = array(
    	        'hist_page_id' => $idPage,
    	        'hist_action'  => $pageAction,
    	        'hist_date'     => date('Y-m-d H:i:s'),
    	        'hist_user_id' => $userId,
    	        'hist_description' => $description
    	    );
    	    
    	    $melisPageHistoricTable->save($histDatas);
    	}

    	$this->getEventManager()->trigger('meliscmspagehistoric_historic_save_end', $this, $histDatas);
    }
public function savePageHistoricAction ( ) { $ responseData = $ this -> params ( ) -> fromRoute ( 'datas' , $ this -> params ( ) -> fromQuery ( 'datas' , '' ) ) ; $ idPage = isset ( $ responseData [ 'idPage' ] ) ? $ responseData [ 'idPage' ] : ( ! empty ( $ responseData [ 0 ] [ 'idPage' ] ) ? ( $ responseData [ 0 ] [ 'idPage' ] ) : 0 ) ; $ isNew = isset ( $ responseData [ 'isNew' ] ) ? $ responseData [ 'isNew' ] : ( ! empty ( $ responseData [ 0 ] [ 'isNew' ] ) ? ( $ responseData [ 0 ] [ 'isNew' ] ) : 0 ) ; $ response = array ( 'idPage' => $ idPage , 'isNew' => $ isNew ) ; $ this -> getEventManager ( ) -> trigger ( 'meliscmspagehistoric_historic_save_start' , $ this , $ response ) ; $ melisCoreAuth = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreAuth' ) ; $ melisPageHistoricTable = $ this -> getServiceLocator ( ) -> get ( 'MelisPageHistoricTable' ) ; $ pageAction = $ this -> params ( ) -> fromRoute ( 'pageActionUsed' , $ this -> params ( ) -> fromQuery ( 'pageActionUsed' , '' ) ) ; $ histDatas = array ( ) ; $ container = new Container ( 'meliscms' ) ; $ datas = array ( ) ; if ( isset ( $ container [ 'action-page-tmp' ] [ 'success' ] ) && $ container [ 'action-page-tmp' ] [ 'success' ] == 0 ) return ; // Update from the different save actions done if ( ! empty ( $ container [ 'action-page-tmp' ] ) ) { if ( ! empty ( $ container [ 'action-page-tmp' ] [ 'datas' ] ) ) $ datas = $ container [ 'action-page-tmp' ] [ 'datas' ] ; } $ description = '' ; switch ( $ pageAction ) { case 'Save' : if ( $ isNew ) { $ description = 'tr_melispagehistoric_description_text_new' ; } else { $ description = 'tr_melispagehistoric_description_text_save' ; } break ; case 'Publish' : $ description = 'tr_melispagehistoric_description_text_publish' ; break ; case 'Unpublish' : $ description = 'tr_melispagehistoric_description_text_unpublished' ; break ; } if ( $ idPage ) { $ userId = ( int ) null ; $ userAuthDatas = $ melisCoreAuth -> getStorage ( ) -> read ( ) ; if ( $ userAuthDatas ) $ userId = $ userAuthDatas -> usr_id ; $ histDatas = array ( 'hist_page_id' => $ idPage , 'hist_action' => $ pageAction , 'hist_date' => date ( 'Y-m-d H:i:s' ) , 'hist_user_id' => $ userId , 'hist_description' => $ description ) ; $ melisPageHistoricTable -> save ( $ histDatas ) ; } $ this -> getEventManager ( ) -> trigger ( 'meliscmspagehistoric_historic_save_end' , $ this , $ histDatas ) ; }
Saves the action taken from MelisCMS Page Actions
Saves the action taken from MelisCMS Page Actions