Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into cint
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 17, 2016
2 parents 8dbc657 + 2b52cf0 commit 9802409
Show file tree
Hide file tree
Showing 132 changed files with 48,146 additions and 1,892 deletions.
6 changes: 3 additions & 3 deletions application/controllers/admin/participantsaction.php
Expand Up @@ -350,13 +350,13 @@ public function getShareInfo_json()
$iShareUserId = $row['share_uid'];
if ($iShareUserId != 0) {
$oShared = User::model()->getName($iShareUserId);
$sSharename = $oShared[0]['full_name'];
$sSharename = $oShared['full_name'];
} else {
$sSharename = 'All users';
}
$owner = User::model()->getName($row['owner_uid']);
$aData->rows[$i]['id'] = $row['participant_id']."--".$row['share_uid']; //This is the unique combination per record
$aData->rows[$i]['cell'] = array($row['firstname'], $row['lastname'], $row['email'], $sSharename, $row['share_uid'], $owner[0]['full_name'], $row['date_added'], $row['can_edit']);
$aData->rows[$i]['cell'] = array($row['firstname'], $row['lastname'], $row['email'], $sSharename, $row['share_uid'], $owner['full_name'], $row['date_added'], $row['can_edit']);
$i++;
}

Expand All @@ -375,7 +375,7 @@ public function getShareInfo_json()
$iShareUserId = $row['share_uid'];//for conversion of uid to human readable names
if ($iShareUserId != 0) {
$oShared = User::model()->getName($iShareUserId);
$sSharename = $oShared[0]['full_name'];
$sSharename = $oShared['full_name'];
} else {
$sSharename = 'All users';
}
Expand Down
13 changes: 7 additions & 6 deletions application/controllers/admin/responses.php
Expand Up @@ -405,7 +405,7 @@ public function browse($iSurveyId)
{
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'listresponse.js');
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'tokens.js');

// Basic datas for the view
$aData = $this->_getData($iSurveyId);
$aData['surveyid'] = $iSurveyId;
Expand All @@ -424,7 +424,7 @@ public function browse($iSurveyId)
$model = SurveyDynamic::model($iSurveyId);

// Page size
if (!empty(Yii::app()->request->getParam('pageSize')))
if (Yii::app()->request->getParam('pageSize'))
{
Yii::app()->user->setState('pageSize',(int)Yii::app()->request->getParam('pageSize'));
}
Expand All @@ -434,7 +434,7 @@ public function browse($iSurveyId)
// So we pass over the safe validation and directly set attributes (second parameter of setAttributes to false).
// see: http://www.yiiframework.com/wiki/161/understanding-safe-validation-rules/
// see: http://www.yiiframework.com/doc/api/1.1/CModel#setAttributes-detail
if(!empty(Yii::app()->request->getParam('SurveyDynamic')))
if(Yii::app()->request->getParam('SurveyDynamic'))
{
$model->setAttributes(Yii::app()->request->getParam('SurveyDynamic'),false);
}
Expand All @@ -445,9 +445,10 @@ public function browse($iSurveyId)
// @see: http://www.yiiframework.com/wiki/281/searching-and-sorting-by-related-model-in-cgridview/
$aVirtualFilters = array('completed_filter', 'firstname_filter', 'lastname_filter', 'email_filter');
foreach($aVirtualFilters as $sFilterName)
if(!empty(Yii::app()->request->getParam('SurveyDynamic')[$sFilterName]))
$aParam=Yii::app()->request->getParam('SurveyDynamic');
if(!empty($aParam[$sFilterName]))
{
$model->$sFilterName = Yii::app()->request->getParam('SurveyDynamic')[$sFilterName];
$model->$sFilterName = $aParam[$sFilterName];
}

// rendering
Expand Down Expand Up @@ -1056,7 +1057,7 @@ public function time($iSurveyID)
*/

// Set number of page
if (!empty(Yii::app()->request->getParam('pageSize')))
if (Yii::app()->request->getParam('pageSize'))
{
Yii::app()->user->setState('pageSize',(int)Yii::app()->request->getParam('pageSize'));
}
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/useraction.php
Expand Up @@ -58,11 +58,11 @@ public function index()

$aData = array();
// Page size
if (!empty(Yii::app()->request->getParam('pageSize')))
if (Yii::app()->request->getParam('pageSize'))
{
Yii::app()->user->setState('pageSize',(int)Yii::app()->request->getParam('pageSize'));
}
else
else
{
Yii::app()->user->setState('pageSize',(int)Yii::app()->params['defaultPageSize']);
}
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/statistics_helper.php
Expand Up @@ -2126,7 +2126,7 @@ protected function displaySimpleResults($outputs, $results, $rt, $outputType, $s
$statisticsoutput .= Yii::app()->getController()->renderPartial('/admin/export/generatestats/simplestats/_statisticsoutput_answer', $aData, true);

} //end while
$statisticsoutput .= '</table>';
//$statisticsoutput .= '</table>';
$aData['showaggregateddata'] = false;

//only show additional values when this setting is enabled
Expand Down
134 changes: 70 additions & 64 deletions application/models/User.php
Expand Up @@ -19,7 +19,7 @@ class User extends LSActiveRecord
*/
public $lang='auto';


/**
* Returns the static model of Settings table
*
Expand Down Expand Up @@ -92,8 +92,8 @@ public function getAllRecords($condition=FALSE)
return $data;
}
/**
*
*
*
*
* @param mixed $postuserid
*/
function parentAndUser($postuserid)
Expand Down Expand Up @@ -186,12 +186,12 @@ public function beforeSave()
// Postgres delivers bytea fields as streams :-o - if this is not done it looks like Postgres saves something unexpected
if (gettype($this->password)=='resource')
{
$this->password=stream_get_contents($this->password,-1,0);
$this->password=stream_get_contents($this->password,-1,0);
}
return parent::beforeSave();
}


/**
* Delete user
*
Expand Down Expand Up @@ -227,17 +227,17 @@ public function getShareSetting()
public function getName($userid)
{
static $aOwnerCache = array();

if (array_key_exists($userid, $aOwnerCache)) {
$result = $aOwnerCache[$userid];
} else {
$result = Yii::app()->db->createCommand()->select('full_name')->from('{{users}}')->where("uid = :userid")->bindParam(":userid", $userid, PDO::PARAM_INT)->queryAll();
$result = Yii::app()->db->createCommand()->select('full_name')->from('{{users}}')->where("uid = :userid")->bindParam(":userid", $userid, PDO::PARAM_INT)->queryRow();
$aOwnerCache[$userid] = $result;
}

return $result;
}

public function getuidfromparentid($parentid)
{
return Yii::app()->db->createCommand()->select('uid')->from('{{users}}')->where('parent_id = :parent_id')->bindParam(":parent_id", $parentid, PDO::PARAM_INT)->queryRow();
Expand All @@ -261,7 +261,7 @@ public function getID($sUserName)

/**
* Updates user password hash
*
*
* @param int $iUserID The User ID
* @param string $sPassword The clear text password
*/
Expand Down Expand Up @@ -314,101 +314,107 @@ public function getSuperAdmins()
$users = $this->findAll($criteria);
return $users;
}
/**
* Gets the buttons for the GridView

/**
* Gets the buttons for the GridView
*/
public function getButtons(){
$editUser = "";
$deleteUser = "";
$setPermissionsUser = "";
$setTemplatePermissionUser = "";
$changeOwnership = "";

$editUrl = Yii::app()->getController()->createUrl('admin/user/sa/modifyuser');
$setPermissionsUrl = Yii::app()->getController()->createUrl('admin/user/sa/setuserpermissions');
$setTemplatePermissionsUrl = Yii::app()->getController()->createUrl('admin/user/sa/setusertemplates');
$changeOwnershipUrl = Yii::app()->getController()->createUrl('admin/user/sa/setasadminchild');

$oUser = $this->getName($this->uid);
if($this->uid == Yii::app()->user->getId())
{
$editUser = "<button
data-toggle='tooltip'
title='".gT("Edit this user")."'
data-url='".$editUrl."'
data-uid='".$this->uid."'
data-user='".$this->getName($this->uid)[0]['full_name']."'
data-action='modifyuser'
$editUser = "<button
data-toggle='tooltip'
title='".gT("Edit this user")."'
data-url='".$editUrl."'
data-uid='".$this->uid."'
data-user='".$oUser['full_name']."'
data-action='modifyuser'
class='btn btn-default btn-xs action_usercontrol_button'>
<span class='fa fa-pencil text-success'></span>
</button>";
if ($this->parent_id != 0 && Permission::model()->hasGlobalPermission('users','delete') )
if ($this->parent_id != 0 && Permission::model()->hasGlobalPermission('users','delete') )
{
$deleteUser = "<button
data-toggle='modal'
data-href='#'
data-onclick='$.post(".$deleteUrl.",
{action: \"deluser\", uid:\"".$this->uid."\", user: \"".htmlspecialchars($this->getName($this->uid)[0]['full_name'])."\"});'
data-target='#confirmation-modal'
data-uid='".$this->uid."'
data-action='deluser'
data-message='".gT("Delete this user")."'
$deleteUrl = Yii::app()->getController()->createUrl('admin/user/sa/deluser', array(
"action"=> "deluser",
"uid"=>$this->uid,
"user" => htmlspecialchars(Yii::app()->user->getId())
));
$deleteUser = "<button
data-toggle='modal'
data-href='#'
data-onclick='$.post(".$deleteUrl.",
{action: \"deluser\", uid:\"".$this->uid."\", user: \"".htmlspecialchars($oUser['full_name'])."\"});'
data-target='#confirmation-modal'
data-uid='".$this->uid."'
data-action='deluser'
data-message='".gT("Delete this user")."'
class='btn btn-default btn-xs'>
<span class='fa fa-trash text-danger'></span>
</button>";
}
} else {
if (Permission::model()->hasGlobalPermission('superadmin','read')
|| $this->uid == Yii::app()->session['loginID']
|| (Permission::model()->hasGlobalPermission('users','update')
&& $this->parent_id == Yii::app()->session['loginID']))
if (Permission::model()->hasGlobalPermission('superadmin','read')
|| $this->uid == Yii::app()->session['loginID']
|| (Permission::model()->hasGlobalPermission('users','update')
&& $this->parent_id == Yii::app()->session['loginID']))
{
$editUser = "<button data-toggle='tooltip' data-url='".$editUrl."' data-user='".$this->getName($this->uid)[0]['full_name']."' data-uid='".$this->uid."' data-action='modifyuser' title='".gT("Edit this user")."' type='submit' class='btn btn-default btn-xs action_usercontrol_button'><span class='fa fa-pencil text-success'></span></button>";
$editUser = "<button data-toggle='tooltip' data-url='".$editUrl."' data-user='".htmlspecialchars($oUser['full_name'])."' data-uid='".$this->uid."' data-action='modifyuser' title='".gT("Edit this user")."' type='submit' class='btn btn-default btn-xs action_usercontrol_button'><span class='fa fa-pencil text-success'></span></button>";
}

if (((Permission::model()->hasGlobalPermission('superadmin','read') &&
$this->uid != Yii::app()->session['loginID'] ) ||
(Permission::model()->hasGlobalPermission('users','update') &&
$this->parent_id == Yii::app()->session['loginID'])) && $this->uid!=1)
{
$this->parent_id == Yii::app()->session['loginID'])) && $this->uid!=1)
{
//'admin/user/sa/setuserpermissions'
$setPermissionsUser = "<button data-toggle='tooltip' data-user='".$this->getName($this->uid)[0]['full_name']."' data-url='".$setPermissionsUrl."' data-uid='".$this->uid."' data-action='setuserpermissions' title='".gT("Set global permissions for this user")."' type='submit' class='btn btn-default btn-xs action_usercontrol_button'><span class='icon-security text-success'></span></button>";
$setPermissionsUser = "<button data-toggle='tooltip' data-user='".htmlspecialchars($oUser['full_name'])."' data-url='".$setPermissionsUrl."' data-uid='".$this->uid."' data-action='setuserpermissions' title='".gT("Set global permissions for this user")."' type='submit' class='btn btn-default btn-xs action_usercontrol_button'><span class='icon-security text-success'></span></button>";
}
if ((Permission::model()->hasGlobalPermission('superadmin','read')
|| Permission::model()->hasGlobalPermission('templates','read'))
&& $this->uid!=1)
{
if ((Permission::model()->hasGlobalPermission('superadmin','read')
|| Permission::model()->hasGlobalPermission('templates','read'))
&& $this->uid!=1)
{
//'admin/user/sa/setusertemplates')
$setTemplatePermissionUser = "<button type='submit' data-user='".$this->getName($this->uid)[0]['full_name']."' data-url='".$setTemplatePermissionsUrl."' data-uid='".$this->uid."' data-action='setusertemplates' data-toggle='tooltip' title='".gT("Set template permissions for this user")."' class='btn btn-default btn-xs action_usercontrol_button'><span class='icon-templatepermissions text-success'></span></button>";
$setTemplatePermissionUser = "<button type='submit' data-user='".htmlspecialchars($oUser['full_name'])."' data-url='".$setTemplatePermissionsUrl."' data-uid='".$this->uid."' data-action='setusertemplates' data-toggle='tooltip' title='".gT("Set template permissions for this user")."' class='btn btn-default btn-xs action_usercontrol_button'><span class='icon-templatepermissions text-success'></span></button>";
}
if ((Permission::model()->hasGlobalPermission('superadmin','read')
|| (Permission::model()->hasGlobalPermission('users','delete')
&& $this->parent_id == Yii::app()->session['loginID'])) && $this->uid!=1)
{
if ((Permission::model()->hasGlobalPermission('superadmin','read')
|| (Permission::model()->hasGlobalPermission('users','delete')
&& $this->parent_id == Yii::app()->session['loginID'])) && $this->uid!=1)
{
$deleteUrl = Yii::app()->getController()->createUrl('admin/user/sa/deluser', array(
"action"=> "deluser",
"uid"=>$this->uid,
"action"=> "deluser",
"uid"=>$this->uid,
"user" => htmlspecialchars(Yii::app()->user->getId())
));
//'admin/user/sa/deluser'
$deleteUser = "<button
id='delete_user_".$this->uid."'
data-toggle='modal'
data-target='#confirmation-modal'
data-url='".$deleteUrl."'
data-uid='".$this->uid."'
data-user='".$this->getName($this->uid)[0]['full_name']."'
data-action='deluser'
data-onclick='triggerRunAction($(\"#delete_user_".$this->uid."\"))'
data-message='".gT("Delete this user")."'
$deleteUser = "<button
id='delete_user_".$this->uid."'
data-toggle='modal'
data-target='#confirmation-modal'
data-url='".$deleteUrl."'
data-uid='".$this->uid."'
data-user='".htmlspecialchars($oUser['full_name'])."'
data-action='deluser'
data-onclick='triggerRunAction($(\"#delete_user_".$this->uid."\"))'
data-message='".gT("Do you want to delete this user?")."'
class='btn btn-default btn-xs '>
<span class='fa fa-trash text-danger'></span>
</button>";
}
if (Yii::app()->session['loginID'] == "1" && $this->parent_id !=1 ) {
//'admin/user/sa/setasadminchild'
$changeOwnership = "<button data-toggle='tooltip' data-url='".$changeOwnershipUrl."' data-user='".$this->getName($this->uid)[0]['full_name']."' data-uid='".$this->uid."' data-action='setasadminchild' title='".gT("Take ownership")."' class='btn btn-default btn-sm action_usercontrol_button' type='submit'><span class='icon-takeownership text-success'></span></button>";
$changeOwnership = "<button data-toggle='tooltip' data-url='".$changeOwnershipUrl."' data-user='".htmlspecialchars($oUser['full_name'])."' data-uid='".$this->uid."' data-action='setasadminchild' title='".gT("Take ownership")."' class='btn btn-default btn-sm action_usercontrol_button' type='submit'><span class='icon-takeownership text-success'></span></button>";
}
}
return "<div>"
Expand All @@ -421,7 +427,7 @@ class='btn btn-default btn-xs '>
}

public function getColums(){
$cols = array(
$cols = array(
array(
"name" => 'buttons',
"type" => 'raw',
Expand Down

0 comments on commit 9802409

Please sign in to comment.