Skip to content

Commit

Permalink
Fixed issue #10138: added bootstrap 'table' class to jqgrid
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Dec 15, 2015
2 parents df33faa + f91b4fa commit f95a01f
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 18 deletions.
32 changes: 32 additions & 0 deletions application/controllers/PluginsController.php
@@ -1,5 +1,8 @@
<?php

/**
* @todo Not used, copied to admin/pluginmanager.php. Delete this file?
*/
class PluginsController extends LSYii_Controller
{

Expand Down Expand Up @@ -27,6 +30,12 @@ public function _init()
Yii::app()->bootstrap->init(); // Make sure bootstrap css is rendered in time
}

/**
* Activates plugin with $id
*
* @param int $id
* @return void
*/
public function actionActivate($id)
{
if(!Permission::model()->hasGlobalPermission('settings','update'))
Expand Down Expand Up @@ -59,6 +68,12 @@ public function actionActivate($id)
$this->redirect(array('plugins/'));
}

/**
* Show configuration for plugin with $id
*
* @param int $id
* @return void
*/
public function actionConfigure($id)
{
if(!Permission::model()->hasGlobalPermission('settings','update'))
Expand Down Expand Up @@ -108,6 +123,12 @@ public function actionConfigure($id)
$this->render('/plugins/configure', array('settings' => $aSettings, 'plugin' => $arPlugin, 'properties' => $aPluginProp));
}

/**
* Deactivates plugin with $id
*
* @param int $id
* @return void
*/
public function actionDeactivate($id)
{
if(!Permission::model()->hasGlobalPermission('settings','update'))
Expand Down Expand Up @@ -138,6 +159,9 @@ public function actionDeactivate($id)
$this->redirect(array('plugins/'));
}

/**
* @todo Doc
*/
public function actionDirect($plugin, $function)
{
$oEvent = new PluginEvent('newDirectRequest');
Expand All @@ -161,6 +185,11 @@ public function actionDirect($plugin, $function)
}
}

/**
* Show list of plugins
*
* @return void
*/
public function actionIndex()
{
if(!Permission::model()->hasGlobalPermission('settings','read'))
Expand Down Expand Up @@ -217,6 +246,9 @@ public function actionIndex()
echo $this->render('/plugins/index', compact('data'));
}

/**
* @todo Doc
*/
public function filters()
{
$aFilters = array(
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/pluginmanager.php
Expand Up @@ -35,7 +35,7 @@ public function index()
}
}

$aoPlugins = Plugin::model()->findAll();
$aoPlugins = Plugin::model()->findAll(array('order' => 'name'));
$data = array();
foreach ($aoPlugins as $oPlugin)
{
Expand Down
4 changes: 4 additions & 0 deletions application/controllers/admin/questiongroups.php
Expand Up @@ -219,7 +219,9 @@ public function insert($surveyid)

$group = new QuestionGroup;
foreach ($aData as $k => $v)
{
$group->$k = $v;
}
$group->save();
$groupid = $group->gid;
$first = false;
Expand All @@ -239,7 +241,9 @@ public function insert($surveyid)

$group = new QuestionGroup;
foreach ($aData as $k => $v)
{
$group->$k = $v;
}
$group->save();
switchMSSQLIdentityInsert('groups',false);
}
Expand Down
23 changes: 23 additions & 0 deletions application/controllers/admin/questions.php
Expand Up @@ -812,6 +812,8 @@ public function newquestion($surveyid)
$aData['surveybar']['savebutton']['form'] = 'frmeditgroup';
$aData['surveybar']['closebutton']['url'] = 'admin/survey/sa/listquestions/surveyid/'.$surveyid;

$this->abortIfSurveyIsActive($surveyinfo);

Yii::app()->session['FileManagerContext'] = "create:question:{$surveyid}";

$questlangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
Expand Down Expand Up @@ -852,7 +854,9 @@ public function newquestion($surveyid)

$sumresult1 = Survey::model()->findByPk($surveyid);
if (is_null($sumresult1))
{
$this->getController()->error('Invalid Survey ID');
}

$surveyinfo = $sumresult1->attributes;
$surveyinfo = array_map('flattenText', $surveyinfo);
Expand Down Expand Up @@ -970,7 +974,9 @@ public function index($sa, $surveyid, $gid, $qid=null)
}

if (!$egresult)
{
$this->getController()->error('Invalid question id');
}

while (list($key, $value) = each($questlangs))
{
Expand Down Expand Up @@ -1069,7 +1075,9 @@ public function index($sa, $surveyid, $gid, $qid=null)

$sumresult1 = Survey::model()->findByPk($surveyid);
if (is_null($sumresult1))
{
$this->getController()->error('Invalid Survey ID');
}

$surveyinfo = $sumresult1->attributes;
$surveyinfo = array_map('flattenText', $surveyinfo);
Expand Down Expand Up @@ -1639,4 +1647,19 @@ protected function _renderWrappedTemplate($sAction = 'survey/Question', $aViewUr
{
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}

/**
* Show error and redirect back if survey is active
*
* @param array $surveyInfo
* @return void
*/
protected function abortIfSurveyIsActive(array $surveyInfo)
{
if ($surveyInfo['active'] !== 'N')
{
Yii::app()->user->setFlash('error', gT("Cannot add questions while the survey is active."));
$this->getController()->redirect(Yii::app()->request->urlReferrer);
}
}
}
3 changes: 3 additions & 0 deletions application/controllers/admin/usergroups.php
Expand Up @@ -173,15 +173,18 @@ public function add()
{
if (strlen($db_group_name) > 21) {
list($aViewUrls, $aData) = $this->index(false, array("type" => "warning", "message" => gT("Failed to add group! Group name length more than 20 characters.")));
Yii::app()->user->setFlash('error', gT("Failed to add group! Group name length more than 20 characters."));
}
elseif (UserGroup::model()->find("name=:groupName", array(':groupName'=>$db_group_name))) {
list($aViewUrls, $aData) = $this->index(false, array("type" => "warning", "message" => gT("Failed to add group! Group already exists.")));
Yii::app()->user->setFlash('error', gT("Failed to add group! Group already exists."));
}
else
{
$ugid = UserGroup::model()->addGroup($db_group_name, $db_group_description);
Yii::app()->session['flashmessage'] = gT("User group successfully added!");
list($aViewUrls, $aData) = $this->index($ugid, true);
$this->getController()->redirect(array('admin/usergroups/sa/view/ugid/' . $ugid));
}

$this->getController()->redirect(array('admin/usergroups'));
Expand Down
9 changes: 8 additions & 1 deletion application/core/Survey_Common_Action.php
Expand Up @@ -627,7 +627,11 @@ function _questionbar($aData)
}
}


/**
* Show admin menu for question group view
*
* @param array $aData ?
*/
function _nquestiongroupbar($aData)
{
if(isset($aData['questiongroupbar']))
Expand All @@ -639,6 +643,9 @@ function _nquestiongroupbar($aData)
$aData['gid'] = $_GET['gid'];
}
}

$aData['surveyIsActive'] = $aData['oSurvey']->active !== 'N';

$surveyid = $aData['surveyid'];
$gid = $aData['gid'];
$oSurvey = $aData['oSurvey'];
Expand Down
6 changes: 3 additions & 3 deletions application/models/Question.php
Expand Up @@ -66,9 +66,9 @@ public function relations()
$alias = $this->getTableAlias();
return array(

'groups' => array(self::BELONGS_TO, 'QuestionGroup', 'gid, language'),
'groups' => array(self::BELONGS_TO, 'QuestionGroup', 'gid, language'),

// Seriously ????
// Seriously ????
//'groups' => array(self::HAS_ONE, 'QuestionGroup', '', 'on' => "$alias.gid = groups.gid AND $alias.language = groups.language"),
'parents' => array(self::HAS_ONE, 'Question', '', 'on' => "$alias.parent_qid = parents.qid"),
'subquestions' => array(self::HAS_MANY, 'Question', 'parent_qid', 'on' => "$alias.language = subquestions.language")
Expand Down Expand Up @@ -815,7 +815,7 @@ public function search()
);

$criteria = new CDbCriteria;
$criteria->condition='t.sid=:surveyid AND t.language=:language AND parent_qid=""';
$criteria->condition="t.sid=:surveyid AND t.language=:language AND parent_qid=0";
$criteria->params=(array(':surveyid'=>$this->sid,':language'=>$this->language));
$criteria->join='LEFT JOIN {{groups}} AS groups ON ( groups.gid = t.gid AND t.language = groups.language )';

Expand Down
Expand Up @@ -231,7 +231,7 @@

</div>
<br/>
<table id="displayparticipants"></table>
<table id="displayparticipants" class="table"></table>
<div id="pager"></div>
<div id="fieldnotselected" title="<?php eT("Error") ?>" style="display:none">
<p>
Expand Down
7 changes: 3 additions & 4 deletions application/views/admin/pluginmanager/index.php
Expand Up @@ -31,14 +31,13 @@
'value' => function($data) {
if ($data['active'] == 0)
{
$output = CHtml::link(CHtml::image(App()->getConfig('adminimageurl') . 'active.png', gT('Activate'), array('width' => 16, 'height' => 16)), array("/admin/pluginmanager/sa/activate", "id" => $data['id']));
$output = "<a href='/index.php/admin/pluginmanager/sa/activate?id=" . $data["id"] . "' class='btn btn-default btn-xs btntooltip'><span class='fa fa-power-off'>&nbsp;</span>".gT('Activate')."</a>";
} else {
$output = CHtml::link(CHtml::image(App()->getConfig('adminimageurl') . 'inactive.png', gT('Deactivate'), array('width' => 16, 'height' => 16)), array("/admin/pluginmanager/sa/deactivate", "id" => $data['id']));
$output = "<a href='/index.php/admin/pluginmanager/sa/deactivate?id=" . $data["id"] . "'class='btn btn-warning btn-xs'><span class='fa fa-power-off'>&nbsp;</span>".gT('Deactivate')."</a>";
}
if(count($data['settings'])>0)
{
$output .= CHtml::link(CHtml::image(App()->getConfig('adminimageurl') . 'survey_settings.png', gT('Configure'), array('width' => 16, 'height' => 16, 'style' => 'margin-left: 8px;')), array("/admin/pluginmanager/sa/configure", "id" => $data['id']));
//$output .= CHtml::link(CHtml::image(App()->getConfig('adminimageurl') . 'survey_settings.png', gT('Configure'), array('width' => 16, 'height' => 16, 'style' => 'margin-left: 8px;')), array("/plugins/configure", "id" => $data['id']));
$output .= "&nbsp;<a href='/index.php/admin/pluginmanager/sa/configure?id=" . $data["id"] . "' class='btn btn-default btn-xs'><span class='icon-edit'>&nbsp;</span>" . gT('Configure') . "</a>";
}
return $output;
}
Expand Down
Expand Up @@ -99,10 +99,9 @@
<label class="col-sm-4 control-label" for="question_type_button">
<?php eT("Question Type:"); echo $eqrow['type'];?>
</label>

<?php $modulename = (isset($eqrow['modulename']))?$eqrow['modulename']:false;?>

<?php if($selectormodeclass!="none"): ?>
<?php if(isset($selectormodeclass) && $selectormodeclass != "none"): ?>
<?php
foreach (getQuestionTypeList($eqrow['type'], 'array') as $key=> $questionType)
{
Expand Down
Expand Up @@ -50,7 +50,7 @@
<div>
<div class="form-group">
<label class="col-sm-4 control-label" for='question_type_button'><?php eT("Question Type:"); ?></label>
<?php if($selectormodeclass!="none"): ?>
<?php if(isset($selectormodeclass) && $selectormodeclass != "none"): ?>
<?php
foreach (getQuestionTypeList($eqrow['type'], 'array') as $key=> $questionType)
{
Expand Down
Expand Up @@ -69,4 +69,4 @@

</div>
</div>
</div>
</div>
Expand Up @@ -3,6 +3,7 @@
* Question group bar
* Also used for Edit question
*/

?>

<!-- nquestiongroupbar -->
Expand All @@ -14,10 +15,12 @@
<?php if(isset($questiongroupbar['buttons']['view'])):?>
<!-- Buttons -->

<a class="btn btn-default" href="<?php echo $this->createUrl('admin/questions/sa/newquestion/surveyid/'.$surveyid.'/gid/'.$gid); ?>" role="button">
<span class="icon-add"></span>
<?php eT("Add new question to group");?>
</a>
<span class="btntooltip" data-toggle="tooltip" data-placement="bottom" title="<?php if ($surveyIsActive) { echo eT("Cannot add questions while the survey is active"); } ?>" >
<a class="btn btn-default <?php if ($surveyIsActive) { echo "disabled"; } ?>" href="<?php echo $this->createUrl('admin/questions/sa/newquestion/surveyid/'.$surveyid.'/gid/'.$gid); ?>" role="button">
<span class="icon-add"></span>
<?php eT("Add new question to group");?>
</a>
</span>

<?php if(Permission::model()->hasSurveyPermission($surveyid,'surveycontent','update')): ?>
<?php if (count($languagelist) > 1): ?>
Expand Down

0 comments on commit f95a01f

Please sign in to comment.