Skip to content

Commit

Permalink
Dev: Mostly working draft
Browse files Browse the repository at this point in the history
Created database based menus. Bound surveymodel with the surveymenu model
Refactored some templates and partials to be called correctly
  • Loading branch information
lacrioque committed Jun 28, 2017
1 parent 263338b commit 099326a
Show file tree
Hide file tree
Showing 20 changed files with 1,160 additions and 446 deletions.
9 changes: 4 additions & 5 deletions application/config/internal.php
Expand Up @@ -64,11 +64,10 @@

'modules'=>array(
'gii'=>array(
//'class'=>'system.gii.GiiModule',
//'password'=>'toto',
// 'ipFilters'=>array(...a list of IPs...),
// 'newFileMode'=>0666,
// 'newDirMode'=>0777,
'class'=>'system.gii.GiiModule',
'password'=>'toto',
'newFileMode'=>0666,
'newDirMode'=>0777,
),
),

Expand Down
36 changes: 36 additions & 0 deletions application/controllers/admin/SurveymenuController.php
@@ -0,0 +1,36 @@
<?php

class SurveymenuController extends Controller
{
public function actionIndex()
{
$this->render('index');
}

// Uncomment the following methods and override them if needed
/*
public function filters()
{
// return the filter configuration for this controller, e.g.:
return array(
'inlineFilterName',
array(
'class'=>'path.to.FilterClass',
'propertyName'=>'propertyValue',
),
);
}
public function actions()
{
// return external action classes, e.g.:
return array(
'action1'=>'path.to.ActionClass',
'action2'=>array(
'class'=>'path.to.AnotherActionClass',
'propertyName'=>'propertyValue',
),
);
}
*/
}
36 changes: 36 additions & 0 deletions application/controllers/admin/SurveymenuEntryController.php
@@ -0,0 +1,36 @@
<?php

class SurveymenuEntryController extends Controller
{
public function actionIndex()
{
$this->render('index');
}

// Uncomment the following methods and override them if needed
/*
public function filters()
{
// return the filter configuration for this controller, e.g.:
return array(
'inlineFilterName',
array(
'class'=>'path.to.FilterClass',
'propertyName'=>'propertyValue',
),
);
}
public function actions()
{
// return external action classes, e.g.:
return array(
'action1'=>'path.to.ActionClass',
'action2'=>array(
'class'=>'path.to.AnotherActionClass',
'propertyName'=>'propertyValue',
),
);
}
*/
}
138 changes: 104 additions & 34 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -491,12 +491,8 @@ public function getAjaxMenuArray($surveyid){
$iSurveyID = sanitize_int($surveyid);
$survey = Survey::model()->findByPk($iSurveyID);
$baselang = $survey->language;
//$menu_items = $this->_collectMenuItems($currentMenu);

return Yii::app()->getController()->renderPartial(
'/admin/super/_renderJson',
array(
'data' => array(
$menus = $survey->getSurveyMenus();
$propArray = array(
'menuEntries' => [
[
'active' => false,
Expand All @@ -516,7 +512,12 @@ public function getAjaxMenuArray($surveyid){
'name' => gT('Language'),
'link' => $this->getController()->createUrl("admin/survey/sa/editlanguagesettings",['surveyid' => $surveyid])
],
],
]);
return Yii::app()->getController()->renderPartial(
'/admin/super/_renderJson',
array(
'data' => [
'menues'=> $menus,
'settings' => array(
'extrasettings' => false,
'parseHTML' => false,
Expand All @@ -530,7 +531,7 @@ public function getAjaxMenuArray($surveyid){
// $setting_entry,
// $lastquestiongroup
// ]
)
]
),
false,
false
Expand Down Expand Up @@ -926,23 +927,83 @@ public function editSurvey_json()
}

/**
* Edit surveytexts and general settings
* New system of rendering content
* Based on yii submenu rendering
*
* @param [int] $iSurveyID
* @param [string] $subaction
* @return void
*/
public function rendersidemenulink($iSurveyID, $subaction){
$aViewUrls = $aData = $activePanels = [];
$menuaction = (String) $subaction;
$iSurveyID = sanitize_int($iSurveyID);

public function surveygeneralsettings($iSurveyID){
$aViewUrls = $aData = $activePanels = array();
//Get all languages
$grplangs = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$baselang = Survey::model()->findByPk($iSurveyID)->language;
array_unshift($grplangs, $baselang);

//Get surveyinfo
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;

$pageTitle=gT("Edit survey text elements and settings");
if (Permission::model()->hasSurveyPermission($iSurveyID, 'surveylocale', 'read') && !Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'read'))
//@TODO add language checks here
$menuEntry = SurveymenuEntries::model()->find(['condition' => 'name="'.$menuaction.'"']);

$esrow = self::_fetchSurveyInfo('editsurvey', $iSurveyID);

if (!(Permission::model()->hasSurveyPermission($iSurveyID, $menuEntry->permission, $menuEntry->permission_grade)))
{
$pageTitle=gT("Edit survey text elements");
Yii::app()->setFlashMessage(gT("You do not have permission to access this page."),'error');
$this->getController()->redirect(array('admin/survey','sa'=>'view','surveyid'=>$iSurveyID));
Yii::app()->end();
}
elseif (!Permission::model()->hasSurveyPermission($iSurveyID, 'surveylocale', 'read') && Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'read'))

if( empty($menuEntry->data))
{
$templateData = call_user_func_array(array($this,$menuEntry->getdatamethod), array('surveyid'=> $iSurveyID, 'esrow' => $esrow));
}
else
{
$pageTitle=gT("Edit survey settings");
$templateData = $menuEntry->data;
}

$templateData = array_merge($this->_getGeneralTemplateData($iSurveyID), $templateData);

$this->_registerScriptFiles();
Yii::app()->loadHelper("admin/htmleditor");

//Start collecting aData
$aData['surveyid'] = $iSurveyID;
$aData['menuaction'] = $menuaction;
$aData['template'] = $menuEntry->template;
$aData['templateData'] = $templateData;
$aData['surveyls_language'] = $baselang;
$aData['action'] = $menuEntry->action;
$aData['entryData'] = $menuEntry->attributes;
$aData['dateformatdetails'] = getDateFormatData(Yii::app()->session['dateformat']);
$aData['display']['menu_bars']['surveysummary'] = $menuEntry->title;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title']." (".gT("ID").":".$iSurveyID.")";
$aData['surveybar']['savebutton']['form'] = 'globalsetting';
$aData['surveybar']['savebutton']['useformid'] = 'true';
$aData['surveybar']['saveandclosebutton']['form'] = true;
$aData['surveybar']['closebutton']['url'] = $this->getController()->createUrl("'admin/survey/sa/view/",['surveyid' => $iSurveyID]); // Close button

$aViewUrls[] = $menuEntry->template;

$this->_renderWrappedTemplate('survey', $aViewUrls, $aData);
}

/**
* Edit surveytexts and general settings
*/

public function surveygeneralsettings($iSurveyID){
$aViewUrls = $aData = $activePanels = array();
$aData['surveyid'] = $iSurveyID = sanitize_int($iSurveyID);



if (!(Permission::model()->hasSurveyPermission($iSurveyID, 'surveylocale', 'read') || Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'read')))
{
Yii::app()->setFlashMessage(gT("You do not have permission to access this page."),'error');
Expand All @@ -962,7 +1023,7 @@ public function surveygeneralsettings($iSurveyID){
$grplangs = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$baselang = Survey::model()->findByPk($iSurveyID)->language;
array_unshift($grplangs, $baselang);

###
Yii::app()->loadHelper("admin/htmleditor");

$aData['scripts'] = PrepareEditorScript(false, $this->getController());
Expand Down Expand Up @@ -1555,17 +1616,8 @@ private function _generalTabNewSurvey()
return $aData;
}

/**
* survey::_generalTabEditSurvey()
* Load "General" tab of edit survey screen.
* @param mixed $iSurveyID
* @param mixed $esrow
* @return
*/
private function _generalTabEditSurvey($iSurveyID, $esrow)
{
$aData['action'] = "editsurveysettings";
$aData['esrow'] = $esrow;
private function _getGeneralTemplateData($iSurveyID){
//$aData['action'] = "editsurveysettings";
$aData['surveyid'] = $iSurveyID;

// Get users, but we only need id and name (NOT password etc)
Expand All @@ -1577,6 +1629,24 @@ private function _generalTabEditSurvey($iSurveyID, $esrow)
}
// Sort users by name
asort($aData['users']);
return $aData;
}

private function _getTextEditData($iSurveyID, $esrow){

}

/**
* survey::_generalTabEditSurvey()
* Load "General" tab of edit survey screen.
* @param mixed $iSurveyID
* @param mixed $esrow
* @return
*/
private function _generalTabEditSurvey($iSurveyID, $esrow)
{
$aData['esrow'] = $esrow;

$beforeSurveySettings = new PluginEvent('beforeSurveySettings');
$beforeSurveySettings->set('survey', $iSurveyID);
App()->getPluginManager()->dispatchEvent($beforeSurveySettings);
Expand All @@ -1590,7 +1660,7 @@ private function _generalTabEditSurvey($iSurveyID, $esrow)
* @param mixed $esrow
* @return
*/
private function _tabPresentationNavigation($esrow)
private function _tabPresentationNavigation($iSurveyID, $esrow)
{
global $showxquestions, $showgroupinfo, $showqnumcode;

Expand All @@ -1613,7 +1683,7 @@ private function _tabPresentationNavigation($esrow)
* @param mixed $esrow
* @return
*/
private function _tabPublicationAccess($esrow)
private function _tabPublicationAccess($iSurveyID, $esrow)
{
$aDateFormatDetails = getDateFormatData(Yii::app()->session['dateformat']);
$startdate = '';
Expand Down Expand Up @@ -1644,7 +1714,7 @@ private function _tabPublicationAccess($esrow)
* @param mixed $esrow
* @return
*/
private function _tabNotificationDataManagement($esrow)
private function _tabNotificationDataManagement($iSurveyID, $esrow)
{
$aData['esrow'] = $esrow;
return $aData;
Expand All @@ -1656,14 +1726,14 @@ private function _tabNotificationDataManagement($esrow)
* @param mixed $esrow
* @return
*/
private function _tabTokens($esrow)
private function _tabTokens($iSurveyID, $esrow)
{
$aData = array();
$aData['esrow'] = $esrow;
return $aData;
}

private function _tabPanelIntegration($esrow)
private function _tabPanelIntegration($iSurveyID, $esrow)
{
$aData = array();
return $aData;
Expand All @@ -1675,7 +1745,7 @@ private function _tabPanelIntegration($esrow)
* @param mixed $iSurveyID
* @return
*/
private function _tabResourceManagement($iSurveyID)
private function _tabResourceManagement($iSurveyID, $esrow)
{
global $sCKEditorURL;

Expand Down

0 comments on commit 099326a

Please sign in to comment.