Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/Yii' into Yii
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Jul 28, 2012
2 parents f349d1e + 67c9baf commit 0a4079c
Show file tree
Hide file tree
Showing 98 changed files with 6,618 additions and 13,300 deletions.
4 changes: 2 additions & 2 deletions application/config/tcpdf.php
Expand Up @@ -75,8 +75,8 @@
* ADD TRAILING SLASH!
***********************************************************/

$tcpdf['image_directory'] = Yii::app()->getConfig('imagedir').DIRECTORY_SEPARATOR;

//$tcpdf['image_directory'] = Yii::app()->getConfig('imagedir').DIRECTORY_SEPARATOR;
$tcpdf['image_directory'] = Yii::app()->getConfig('rootdir').DIRECTORY_SEPARATOR.'styles'.DIRECTORY_SEPARATOR.Yii::app()->getConfig('admintheme').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;

/************************************************************
* TCPDF default (blank) image
Expand Down
1 change: 0 additions & 1 deletion application/controllers/InstallerController.php
Expand Up @@ -294,7 +294,6 @@ private function stepDatabaseConfiguration()
if ($bDBExists == true) {
try {
$this->connection->createCommand()->select()->from('{{surveys}}')->queryAll();
$bTablesDoNotExist = false;
} catch(Exception $e) {
$bTablesDoNotExist = true;
}
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/OptinController.php
Expand Up @@ -93,7 +93,7 @@ function actionLocal($surveyid, $token, $langcode = '')
//PRINT COMPLETED PAGE
if (!$thissurvey['templatedir'])
{
$thistpl=getTemplatePath($defaulttemplate);
$thistpl=getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/OptoutController.php
Expand Up @@ -96,7 +96,7 @@ function actiontokens()
//PRINT COMPLETED PAGE
if (!$thissurvey['templatedir'])
{
$thistpl=getTemplatePath($defaulttemplate);
$thistpl=getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
}
else
{
Expand Down Expand Up @@ -196,7 +196,7 @@ function actionparticipants()
//PRINT COMPLETED PAGE
if (!$thissurvey['templatedir'])
{
$thistpl=getTemplatePath($defaulttemplate);
$thistpl=getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/RegisterController.php
Expand Up @@ -29,9 +29,9 @@ function actionAJAXRegisterForm
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('replacements');
$redata = compact(array_keys(get_defined_vars()));
$thistpl = Yii::app()->getConfig("standardtemplaterootdir").'/default';
$surveyid = sanitize_int($surveyid);
$row = Survey::model()->find('sid=:sid',array(':sid' => $surveyid)) or show_error("Can't find survey data");
$thistpl=getTemplatePath(validateTemplateDir($row->template));
$data['sid'] = $surveyid;
$data['startdate'] = $row->startdate;
$data['enddate'] = $row->expires;
Expand Down
6 changes: 3 additions & 3 deletions application/controllers/admin/assessments.php
Expand Up @@ -116,7 +116,7 @@ private function _showAssessments($iSurveyID, $action, $surveyLanguage, Limesurv

private function _collectGroupData($iSurveyID)
{
$aData = array();
$aData = array();
$groups = Groups::model()->findAllByAttributes(array('sid' => $iSurveyID));
foreach ($groups as $group) {
$groupId = $group->attributes['gid'];
Expand Down Expand Up @@ -156,7 +156,7 @@ private function _add($iSurveyID)
if ($first == false) {
$aData['id'] = $assessmentId;
}
$assessment = Assessment::insertRecords($aData);
$assessment = Assessment::model()->insertRecords($aData);
if ($first == true) {
$first = false;
$assessmentId = $assessment->id;
Expand All @@ -177,7 +177,7 @@ private function _update($iSurveyID)
foreach ($languages as $language)
{
$aData = $this->_getAssessmentPostData($iSurveyID, $language);
Assessment::updateAssessment($aid, $language, $aData);
Assessment::model()->updateAssessment($aid, $language, $aData);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions application/controllers/admin/conditionsaction.php
Expand Up @@ -792,18 +792,18 @@ function index($subaction, $surveyid=null, $gid=null, $qid=null)
$x_axis[$frow['title']]=$frow['question'];
}

foreach ($y_axis_db->readAll() as $arow)
foreach ($y_axis_db->readAll() as $yrow)
{
foreach($x_axis as $key=>$val)
{
$shortquestion=$rows['title'].":{$arows['title']}:$key: [".strip_tags($arows['question']). "][" .strip_tags($val). "] " . flattenText($rows['question']);
$cquestions[]=array($shortquestion, $rows['qid'], $rows['type'], $rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title']."_".$key);
$shortquestion=$rows['title'].":{$yrow['title']}:$key: [".strip_tags($yrow['question']). "][" .strip_tags($val). "] " . flattenText($rows['question']);
$cquestions[]=array($shortquestion, $rows['qid'], $rows['type'], $rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$yrow['title']."_".$key);

if ($rows['type'] == ":")
{
for($ii=$minvalue; $ii<=$maxvalue; $ii+=$stepvalue)
{
$canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title']."_".$key, $ii, $ii);
$canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$yrow['title']."_".$key, $ii, $ii);
}
}
}
Expand Down
50 changes: 21 additions & 29 deletions application/controllers/admin/database.php
Expand Up @@ -64,11 +64,7 @@ function index($sa = null)
$baselang = Survey::model()->findByPk($surveyid)->language;
array_unshift($questlangs,$baselang);

$uqresult = Questions::model()->updateAll(array('same_default'=> Yii::app()->request->getPost('samedefault')?1:0), 'sid=:sid ANd qid=:qid', array(':sid'=>$surveyid, ':qid'=>$qid));
if (!$uqresult)
{
$databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Question could not be updated","js")."\n\")\n //-->\n</script>\n";
}
Questions::model()->updateAll(array('same_default'=> Yii::app()->request->getPost('samedefault')?1:0), 'sid=:sid ANd qid=:qid', array(':sid'=>$surveyid, ':qid'=>$qid));

$resrow = Questions::model()->findByAttributes(array('qid'=>$qid));
$questiontype = $resrow['type'];
Expand Down Expand Up @@ -116,9 +112,9 @@ function index($sa = null)
{
foreach ($questlangs as $language)
{
if (Yii::app()->request->getPost($_POST['defaultanswerscale_0_'.$language.'_0']))
if (Yii::app()->request->getPost('defaultanswerscale_0_'.$language.'_0'))
{
$this->_updateDefaultValues($postqid,0,0,'',$language,Yii::app()->request->getPost['defaultanswerscale_0_'.$language.'_0'],true);
$this->_updateDefaultValues($postqid,0,0,'',$language,Yii::app()->request->getPost('defaultanswerscale_0_'.$language.'_0'),true);
}
}
}
Expand Down Expand Up @@ -479,7 +475,7 @@ function index($sa = null)
if (returnGlobal('copysubquestions') == "Y")
{
$aSQIDMappings = array();
$r1 = Questions::getSubQuestions(returnGlobal('oldqid'));
$r1 = Questions::model()->getSubQuestions(returnGlobal('oldqid'));

while ($qr1 = $r1->read())
{
Expand All @@ -492,19 +488,19 @@ function index($sa = null)
unset($qr1['qid']);
}
$qr1['gid'] = $postgid;
$ir1 = Questions::insertRecords($qr1);
$iInsertID = Questions::model()->insertRecords($qr1);
if (!isset($qr1['qid']))
{
$aSQIDMappings[$oldqid] = Yii::app()->db->getLastInsertID('qid');
$aSQIDMappings[$oldqid] = $iInsertID;
}
}
}
if (returnGlobal('copyanswers') == "Y")
{
$r1 = Answers::getAnswers(returnGlobal('oldqid'));
$r1 = Answers::model()->getAnswers(returnGlobal('oldqid'));
while ($qr1 = $r1->read())
{
Answers::insertRecords(array(
Answers::model()->insertRecords(array(
'qid' => $qid,
'code' => $qr1['code'],
'answer' => $qr1['answer'],
Expand All @@ -516,14 +512,12 @@ function index($sa = null)
}
if (returnGlobal('copyattributes') == "Y")
{
$r1 = Question_attributes::getQuestionAttributes(returnGlobal('oldqid'));
$r1 = Question_attributes::model()->getQuestionAttributes(returnGlobal('oldqid'));
while($qr1 = $r1->read())
{
Question_attributes::insertRecords(array(
'qid' => $qid,
'attribute' => $qr1['attribute'],
'value' => $qr1['value']
));
$qr1['qid']=$qid;
unset($qr1['qaid']);
Question_attributes::model()->insertRecords($qr1);
}
}
} else {
Expand All @@ -539,7 +533,7 @@ function index($sa = null)
'attribute' => $validAttribute['name']
);

Question_attributes::insertRecords($data);
Question_attributes::model()->insertRecords($data);

}
}
Expand Down Expand Up @@ -851,7 +845,11 @@ function index($sa = null)
}
else
{
$this->getController()->redirect($this->getController()->createUrl('admin/survey/view/surveyid/'.$surveyid.'/gid/'.$gid.'/qid/'.$qid));
if(Yii::app()->request->getPost('newpage') == "return") {
$this->getController()->redirect($this->getController()->createUrl('admin/question/editquestion/surveyid/'.$surveyid.'/gid/'.$gid.'/qid/'.$qid));
} else {
$this->getController()->redirect($this->getController()->createUrl('admin/survey/view/surveyid/'.$surveyid.'/gid/'.$gid.'/qid/'.$qid));
}
}
}

Expand Down Expand Up @@ -1131,24 +1129,18 @@ function index($sa = null)
*/
function _updateDefaultValues($qid,$sqid,$scale_id,$specialtype,$language,$defaultvalue,$ispost)
{
//$this->load->helper('database');
if ($defaultvalue=='') // Remove the default value if it is empty
{
Defaultvalues::model()->deleteByPk(array('sqid'=>$sqid, 'qid'=>$qid, 'specialtype'=>$specialtype, 'scale_id'=>$scale_id, 'language'=>$language));
}
else
{
$res = Defaultvalues::model()->findByPk(array('sqid'=>$sqid, 'qid'=>$qid, 'specialtype'=>$specialtype, 'scale_id'=>$scale_id, 'language'=>$language));
$exists=count($res);
$arDefaultValue = Defaultvalues::model()->findByPk(array('sqid'=>$sqid, 'qid'=>$qid, 'specialtype'=>$specialtype, 'scale_id'=>$scale_id, 'language'=>$language));

if ($exists == 0)
if (is_null($arDefaultValue))
{
$data=array('sqid'=>$sqid, 'qid'=>$qid, 'specialtype'=>$specialtype, 'scale_id'=>$scale_id, 'language'=>$language, 'defaultvalue'=>$defaultvalue);

$value = new Defaultvalues;
foreach ($data as $k => $v)
$value->$k = $v;
$value->save();
Defaultvalues::model()->insertRecords($data);
}
else
{
Expand Down
10 changes: 6 additions & 4 deletions application/controllers/admin/dataentry.php
Expand Up @@ -1445,19 +1445,21 @@ public function editdata($subaction, $id, $surveyid, $language='')
*/
public function delete()
{
$subaction = Yii::app()->request->getPost('subaction');
$surveyid = $_REQUEST['surveyid'];
if (isset($_REQUEST['surveyid']) && !empty($_REQUEST['surveyid']))
{
$surveyid = $_REQUEST['surveyid'];
}
if (!empty($_REQUEST['sid'])) $surveyid = (int)$_REQUEST['sid'];

$surveyid = sanitize_int($surveyid);
$id = Yii::app()->request->getPost('id');
$id = $_REQUEST['id'];

$aData = array(
'surveyid' => $surveyid,
'id' => $id
);

if (hasSurveyPermission($surveyid, 'responses','read') && $subaction == "delete" && hasSurveyPermission($surveyid, 'responses', 'delete'))
if (hasSurveyPermission($surveyid, 'responses','read') && hasSurveyPermission($surveyid, 'responses', 'delete'))
{
$surveytable = "{{survey_".$surveyid.'}}';
$aData['thissurvey'] = getSurveyInfo($surveyid);
Expand Down
11 changes: 1 addition & 10 deletions application/controllers/admin/expressions.php
Expand Up @@ -24,16 +24,7 @@ function index()
<script src="<?php echo Yii::app()->getConfig('generalscripts') . 'jquery/jquery.js'; ?>"></script>
<script src="<?php echo Yii::app()->getConfig('generalscripts') . 'expressions/em_javascript.js'; ?>" /></script>
<script src="<?php echo Yii::app()->getConfig('generalscripts') . 'survey_runtime.js'; ?>" /></script>
<style type="text/css">
<!--
.error {
background-color: #ff0000;
}
.ok {
background-color: #00ff00
}
-->
</style>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->getConfig('adminstyleurl')."adminstyle.css"; ?>" />
</head>
<body <?php $this->_printOnLoad(Yii::app()->request->getQuery('sa', 'index'))?>>
<?php
Expand Down
3 changes: 0 additions & 3 deletions application/controllers/admin/labels.php
Expand Up @@ -12,8 +12,6 @@
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*/

/**
Expand All @@ -22,7 +20,6 @@
* @package LimeSurvey
* @author
* @copyright 2011
* @version $Id$
* @access public
*/
class labels extends Survey_Common_Action
Expand Down

0 comments on commit 0a4079c

Please sign in to comment.