Skip to content

Commit

Permalink
Merge branch '2.05' of github.com:LimeSurvey/LimeSurvey into 2.05
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Mar 19, 2013
2 parents bfb53b8 + b8b4845 commit d5981dd
Show file tree
Hide file tree
Showing 187 changed files with 2,404 additions and 5,657 deletions.
6 changes: 3 additions & 3 deletions application/config/third_party.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
)
),

'jquery-qtip' => array(
'baseUrl' => 'third_party/jquery-qtip',
'qTip2' => array(
'baseUrl' => 'third_party/qTip2',
'js' => array(
'dist/jquery.qtip.js'
),
Expand All @@ -107,4 +107,4 @@
'jquery'
)
)
);
);
2 changes: 1 addition & 1 deletion application/config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

$config['versionnumber'] = "2.05";
$config['dbversionnumber'] = 165;
$config['dbversionnumber'] = 166;
$config['buildnumber'] = '';
$config['updatable'] = true;

Expand Down
15 changes: 1 addition & 14 deletions application/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,6 @@ public function _GetSessionUserRights($loginID)
{
$user = User::model()->findByPk($loginID);

if (!empty($user))
{
Yii::app()->session['USER_RIGHT_SUPERADMIN'] = $user->superadmin;
Yii::app()->session['USER_RIGHT_CREATE_SURVEY'] = ($user->create_survey || $user->superadmin);
Yii::app()->session['USER_RIGHT_PARTICIPANT_PANEL'] = ($user->participant_panel || $user->superadmin);
Yii::app()->session['USER_RIGHT_CONFIGURATOR'] = ($user->configurator || $user->superadmin);
Yii::app()->session['USER_RIGHT_CREATE_USER'] = ($user->create_user || $user->superadmin);
Yii::app()->session['USER_RIGHT_DELETE_USER'] = ($user->delete_user || $user->superadmin);
Yii::app()->session['USER_RIGHT_MANAGE_TEMPLATE'] = ($user->manage_template || $user->superadmin);
Yii::app()->session['USER_RIGHT_MANAGE_LABEL'] = ($user->manage_label || $user->superadmin);
}

// SuperAdmins
// * original superadmin with uid=1 unless manually changed and defined
// in config-defaults.php
Expand All @@ -261,7 +249,6 @@ public function _GetSessionUserRights($loginID)

if ($initialSuperadmin === true)
{
Yii::app()->session['USER_RIGHT_SUPERADMIN'] = 1;
Yii::app()->session['USER_RIGHT_INITIALSUPERADMIN'] = 1;
}
else
Expand Down Expand Up @@ -420,7 +407,7 @@ public function _showadminmenu($surveyid = false)
Yii::app()->session['flashmessage'] = $clang->gT("Warning: You are still using the default password ('password'). Please change your password and re-login again.");
}

$data['showupdate'] = (Yii::app()->session['USER_RIGHT_SUPERADMIN'] == 1 && getGlobalSetting("updatelastcheck")>0 && getGlobalSetting("updateavailable")==1 && Yii::app()->getConfig("updatable") );
$data['showupdate'] = (Permission::model()->hasGlobalPermission('global_superadmin','read') && getGlobalSetting("updatelastcheck")>0 && getGlobalSetting("updateavailable")==1 && Yii::app()->getConfig("updatable") );
$data['updateversion'] = getGlobalSetting("updateversion");
$data['updatebuild'] = getGlobalSetting("updatebuild");
$data['surveyid'] = $surveyid;
Expand Down
10 changes: 5 additions & 5 deletions application/controllers/admin/assessments.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function index($iSurveyID)
if ($action == "assessmentdelete")
$this->_delete($iSurveyID, $_POST['id']);

if (hasSurveyPermission($iSurveyID, 'assessments', 'read')) {
if (Permission::model()->hasSurveyPermission($iSurveyID, 'assessments', 'read')) {
$clang = $this->getController()->lang;

if ($iSurveyID == '') {
Expand Down Expand Up @@ -90,7 +90,7 @@ private function _showAssessments($iSurveyID, $action, $surveyLanguage, Limesurv
$aData['actionvalue'] = "assessmentadd";
$aData['editId'] = '';

if ($action == "assessmentedit" && hasSurveyPermission($iSurveyID, 'assessments', 'update')) {
if ($action == "assessmentedit" && Permission::model()->hasSurveyPermission($iSurveyID, 'assessments', 'update')) {
$aData = $this->_collectEditData($surveyLanguage, $aData, $clang);
}

Expand Down Expand Up @@ -144,7 +144,7 @@ private function _collectEditData($surveyLanguage, array $aData, Limesurvey_lang
*/
private function _add($iSurveyID)
{
if (hasSurveyPermission($iSurveyID, 'assessments', 'create')) {
if (Permission::model()->hasSurveyPermission($iSurveyID, 'assessments', 'create')) {
$first = true;
$assessmentId = -1;
$languages = Yii::app()->getConfig("assessmentlangs");
Expand All @@ -169,7 +169,7 @@ private function _add($iSurveyID)
*/
private function _update($iSurveyID)
{
if (hasSurveyPermission($iSurveyID, 'assessments', 'update') && isset($_POST['id'])) {
if (Permission::model()->hasSurveyPermission($iSurveyID, 'assessments', 'update') && isset($_POST['id'])) {

$aid = sanitize_int($_POST['id']);
$languages = Yii::app()->getConfig("assessmentlangs");
Expand All @@ -186,7 +186,7 @@ private function _update($iSurveyID)
*/
private function _delete($iSurveyID, $assessmentId)
{
if (hasSurveyPermission($iSurveyID, 'assessments', 'delete')) {
if (Permission::model()->hasSurveyPermission($iSurveyID, 'assessments', 'delete')) {
Assessment::model()->deleteAllByAttributes(array('id' => $assessmentId, 'sid' => $iSurveyID));
}
}
Expand Down
10 changes: 5 additions & 5 deletions application/controllers/admin/checkintegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct($controller, $id)
{
parent::__construct($controller, $id);

if (Yii::app()->session['USER_RIGHT_CONFIGURATOR'] != 1) {
if (!Permission::model()->hasGlobalPermission('global_settings','read')){
die();
}

Expand All @@ -45,7 +45,7 @@ public function fixredundancy()
$clang = Yii::app()->lang;
$oldsmultidelete=Yii::app()->request->getPost('oldsmultidelete', array());
$aData['messages'] = array();
if (Yii::app()->session['USER_RIGHT_CONFIGURATOR'] == 1 && Yii::app()->request->getPost('ok') == 'Y') {
if ( Permission::model()->hasGlobalPermission('global_settings','update') && Yii::app()->request->getPost('ok') == 'Y') {
$aDelete = $this->_checkintegrity();
if (isset($aDelete['redundanttokentables'])) {
foreach ($aDelete['redundanttokentables'] as $aTokenTable)
Expand Down Expand Up @@ -79,7 +79,7 @@ public function fixintegrity()
{
$aData = array();
$clang = Yii::app()->lang;
if (Yii::app()->session['USER_RIGHT_CONFIGURATOR'] == 1 && Yii::app()->request->getPost('ok') == 'Y') {
if (Permission::model()->hasGlobalPermission('global_settings','update') && Yii::app()->request->getPost('ok') == 'Y') {
$aDelete = $this->_checkintegrity();

// TMSW Conditions->Relevance: Update this to process relevance instead
Expand Down Expand Up @@ -342,7 +342,7 @@ protected function _checkintegrity()
foreach ($surveys as $survey) $sids[] = $survey['sid'];
$criteria->addNotInCondition('sid', $sids, 'OR');

Survey_permissions::model()->deleteAll($criteria);
Permission::model()->deleteAll($criteria);


// Deactivate surveys that have a missing response table
Expand All @@ -366,7 +366,7 @@ protected function _checkintegrity()
foreach ($aResult->readAll() as $aRow)
{
$sTableName = substr(reset($aRow), strlen($sDBPrefix));
if ($sTableName == 'survey_permissions' || $sTableName == 'survey_links' || $sTableName == 'survey_url_parameters') continue;
if ($sTableName == 'survey_links' || $sTableName == 'survey_url_parameters') continue;
$aTableName=explode('_',$sTableName);
if (isset($aTableName[1]) && ctype_digit($aTableName[1]))
{
Expand Down
18 changes: 9 additions & 9 deletions application/controllers/admin/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function index($sa = null)
$qid = returnGlobal('qid');
// if $action is not passed, check post data.

if(Yii::app()->getConfig('filterxsshtml') && Yii::app()->session['USER_RIGHT_SUPERADMIN'] != 1)
if(Yii::app()->getConfig('filterxsshtml') && !Permission::model()->hasGlobalPermission('global_superadmin','read'))
{
$filter = new CHtmlPurifier();
$filter->options = array('URI.AllowedSchemes'=>array(
Expand All @@ -54,7 +54,7 @@ function index($sa = null)
else
$xssfilter = false;

if ($action == "updatedefaultvalues" && hasSurveyPermission($surveyid, 'surveycontent','update'))
if ($action == "updatedefaultvalues" && Permission::model()->hasSurveyPermission($surveyid, 'surveycontent','update'))
{

$questlangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
Expand Down Expand Up @@ -129,7 +129,7 @@ function index($sa = null)
}


if ($action == "updateansweroptions" && hasSurveyPermission($surveyid, 'surveycontent','update'))
if ($action == "updateansweroptions" && Permission::model()->hasSurveyPermission($surveyid, 'surveycontent','update'))
{
Yii::app()->loadHelper('database');
$anslangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
Expand Down Expand Up @@ -227,7 +227,7 @@ function index($sa = null)
}


if ($action == "updatesubquestions" && hasSurveyPermission($surveyid, 'surveycontent','update'))
if ($action == "updatesubquestions" && Permission::model()->hasSurveyPermission($surveyid, 'surveycontent','update'))
{

Yii::app()->loadHelper('database');
Expand Down Expand Up @@ -357,7 +357,7 @@ function index($sa = null)
}
}

if (in_array($action, array('insertquestion', 'copyquestion')) && hasSurveyPermission($surveyid, 'surveycontent','create'))
if (in_array($action, array('insertquestion', 'copyquestion')) && Permission::model()->hasSurveyPermission($surveyid, 'surveycontent','create'))
{
$baselang = Survey::model()->findByPk($surveyid)->language;
if (strlen(Yii::app()->request->getPost('title')) < 1)
Expand Down Expand Up @@ -587,7 +587,7 @@ function index($sa = null)
}
}

if ($action == "updatequestion" && hasSurveyPermission($surveyid, 'surveycontent','update'))
if ($action == "updatequestion" && Permission::model()->hasSurveyPermission($surveyid, 'surveycontent','update'))
{
LimeExpressionManager::RevertUpgradeConditionsToRelevance($surveyid);

Expand Down Expand Up @@ -883,7 +883,7 @@ function index($sa = null)
}


if (($action == "updatesurveylocalesettings") && hasSurveyPermission($surveyid,'surveylocale','update'))
if (($action == "updatesurveylocalesettings") && Permission::model()->hasSurveyPermission($surveyid,'surveylocale','update'))
{
$languagelist = Survey::model()->findByPk($surveyid)->additionalLanguages;
$languagelist[]=Survey::model()->findByPk($surveyid)->language;
Expand Down Expand Up @@ -960,7 +960,7 @@ function index($sa = null)
}
}

if (($action == "updatesurveysettingsandeditlocalesettings" || $action == "updatesurveysettings") && hasSurveyPermission($surveyid,'surveysettings','update'))
if (($action == "updatesurveysettingsandeditlocalesettings" || $action == "updatesurveysettings") && Permission::model()->hasSurveyPermission($surveyid,'surveysettings','update'))
{
// Save plugin settings.
$pluginSettings = App()->request->getPost('plugin', array());
Expand Down Expand Up @@ -1013,7 +1013,7 @@ function index($sa = null)
fixLanguageConsistency($surveyid,Yii::app()->request->getPost('languageids'));
$template = Yii::app()->request->getPost('template');

if(Yii::app()->session['USER_RIGHT_SUPERADMIN'] != 1 && Yii::app()->session['USER_RIGHT_MANAGE_TEMPLATE'] != 1 && !hasTemplateManageRights(Yii::app()->session['loginID'], $template)) $template = "default";
if(!Permission::model()->hasGlobalPermission('global_superadmin','read') && !hasGlobalPermission('global_templates','read') && !hasTemplateManageRights(Yii::app()->session['loginID'], $template)) $template = "default";

$aURLParams=json_decode(Yii::app()->request->getPost('allurlparams'),true);
Survey_url_parameters::model()->deleteAllByAttributes(array('sid'=>$surveyid));
Expand Down
28 changes: 14 additions & 14 deletions application/controllers/admin/dataentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function vvimport()
$aData['surveyid'] = $surveyid;
$aData['clang'] = $this->getController()->lang;

if( hasSurveyPermission($surveyid,'responses','create') )
if( Permission::model()->hasSurveyPermission($surveyid,'responses','create') )
{
// First load the database helper
Yii::app()->loadHelper('database');
Expand Down Expand Up @@ -108,7 +108,7 @@ function iteratesurvey()
$aData['surveyid'] = $surveyid;
$aData['clang'] = $this->getController()->lang;
$aData['success'] = false;
if (hasSurveyPermission($surveyid,'surveyactivation','update'))
if (Permission::model()->hasSurveyPermission($surveyid,'surveyactivation','update'))
{
if (Yii::app()->request->getParam('unfinalizeanswers') == 'true')
{
Expand Down Expand Up @@ -351,7 +351,7 @@ function import($surveyid)
'surveyid' => $surveyid
);

if(hasSurveyPermission($surveyid,'responses','create'))
if(Permission::model()->hasSurveyPermission($surveyid,'responses','create'))
{
//if (!isset($surveyid)) $surveyid = $this->input->post('sid');
if (!isset($oldtable) && isset($_POST['oldtable']))
Expand Down Expand Up @@ -507,7 +507,7 @@ public function editdata($subaction, $id, $surveyid, $language='')
}

$surveyinfo = getSurveyInfo($surveyid);
if (hasSurveyPermission($surveyid, 'responses','update'))
if (Permission::model()->hasSurveyPermission($surveyid, 'responses','update'))
{
$surveytable = "{{survey_".$surveyid.'}}';
$aData['clang'] = $clang = $this->getController()->lang;
Expand Down Expand Up @@ -545,7 +545,7 @@ public function editdata($subaction, $id, $surveyid, $language='')

//SHOW INDIVIDUAL RECORD

if ($subaction == "edit" && hasSurveyPermission($surveyid,'responses','update'))
if ($subaction == "edit" && Permission::model()->hasSurveyPermission($surveyid,'responses','update'))
{
$idquery = "SELECT * FROM $surveytable WHERE id=$id";
$idresult = dbExecuteAssoc($idquery) or safeDie ("Couldn't get individual record<br />$idquery<br />");
Expand All @@ -554,7 +554,7 @@ public function editdata($subaction, $id, $surveyid, $language='')
$results[]=$idrow;
}
}
elseif ($subaction == "editsaved" && hasSurveyPermission($surveyid,'responses','update'))
elseif ($subaction == "editsaved" && Permission::model()->hasSurveyPermission($surveyid,'responses','update'))
{
if (isset($_GET['public']) && $_GET['public']=="true")
{
Expand Down Expand Up @@ -1329,16 +1329,16 @@ public function editdata($subaction, $id, $surveyid, $language='')

$aData['sDataEntryLanguage'] = $sDataEntryLanguage;

if (!hasSurveyPermission($surveyid, 'responses','update'))
if (!Permission::model()->hasSurveyPermission($surveyid, 'responses','update'))
{ // if you are not survey owner or super admin you cannot modify responses
$aDataentryoutput .= "<p><input type='button' value='".$clang->gT("Save")."' disabled='disabled'/></p>\n";
}
elseif ($subaction == "edit" && hasSurveyPermission($surveyid,'responses','update'))
elseif ($subaction == "edit" && Permission::model()->hasSurveyPermission($surveyid,'responses','update'))
{
$aData['part'] = 'edit';
$aDataentryoutput .= $this->getController()->render('/admin/dataentry/edit', $aData, TRUE);
}
elseif ($subaction == "editsaved" && hasSurveyPermission($surveyid,'responses','update'))
elseif ($subaction == "editsaved" && Permission::model()->hasSurveyPermission($surveyid,'responses','update'))
{
$aData['part'] = 'editsaved';
$aDataentryoutput .= $this->getController()->render('/admin/dataentry/edit', $aData, TRUE);
Expand Down Expand Up @@ -1372,7 +1372,7 @@ public function delete()
'id' => $id
);

if (hasSurveyPermission($surveyid, 'responses','read') && hasSurveyPermission($surveyid, 'responses', 'delete'))
if (Permission::model()->hasSurveyPermission($surveyid, 'responses','read') && Permission::model()->hasSurveyPermission($surveyid, 'responses', 'delete'))
{
$surveytable = "{{survey_".$surveyid.'}}';
$aData['thissurvey'] = getSurveyInfo($surveyid);
Expand Down Expand Up @@ -1400,7 +1400,7 @@ public function update()
$id = Yii::app()->request->getPost('id');
$lang = Yii::app()->request->getPost('lang');

if ($subaction == "update" && hasSurveyPermission($surveyid, 'responses', 'update'))
if ($subaction == "update" && Permission::model()->hasSurveyPermission($surveyid, 'responses', 'update'))
{

$baselang = Survey::model()->findByPk($surveyid)->language;
Expand Down Expand Up @@ -1523,9 +1523,9 @@ public function insert()
'clang' => $clang
);

if (hasSurveyPermission($surveyid, 'responses','create'))
if (Permission::model()->hasSurveyPermission($surveyid, 'responses','create'))
{
if ($subaction == "insert" && hasSurveyPermission($surveyid,'responses','create'))
if ($subaction == "insert" && Permission::model()->hasSurveyPermission($surveyid,'responses','create'))
{
$surveytable = "{{survey_{$surveyid}}}";
$thissurvey = getSurveyInfo($surveyid);
Expand Down Expand Up @@ -1902,7 +1902,7 @@ public function view($surveyid, $lang=NULL)
if(isset($lang)) $lang=sanitize_languagecode($lang);
$aViewUrls = array();

if (hasSurveyPermission($surveyid, 'responses', 'create'))
if (Permission::model()->hasSurveyPermission($surveyid, 'responses', 'create'))
{
$clang = Yii::app()->lang;

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/dumpdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function __construct($controller, $id)
{
parent::__construct($controller, $id);

if (Yii::app()->session['USER_RIGHT_SUPERADMIN'] != 1)
if (!Permission::model()->hasGlobalPermission('global_superadmin','read'))
{
die();
}
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/emailtemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function index($iSurveyId)
function update($iSurveyId)
{
$clang = $this->getController()->lang;
if (hasSurveyPermission($iSurveyId, 'surveylocale','update'))
if (Permission::model()->hasSurveyPermission($iSurveyId, 'surveylocale','update'))
{
$languagelist = Survey::model()->findByPk($iSurveyId)->additionalLanguages;
$languagelist[] = Survey::model()->findByPk($iSurveyId)->language;
Expand Down

0 comments on commit d5981dd

Please sign in to comment.