Skip to content

Commit

Permalink
Readd addusertogroup() in usergroups. To be refactored.
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11870 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
GautamGupta committed Jan 3, 2012
1 parent dd18509 commit 1bb7d9f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
52 changes: 52 additions & 0 deletions application/controllers/admin/usergroups.php
Expand Up @@ -362,6 +362,58 @@ public function index($ugid = false, $header = false)
}
}

function addusertogroup($ugid)
{
Yii::app()->loadHelper('database');
$clang = Yii::app()->lang;
$postuserid = CHttpRequest::getPost('uid');

$addsummary = "<div class=\"header\">".$clang->gT("Adding User to group")."...</div>\n";
$addsummary .= "<div class=\"messagebox\">\n";

if (Yii::app()->session['USER_RIGHT_SUPERADMIN'] == 1)
{
$query = "SELECT ugid, owner_id FROM {{user_groups}} WHERE ugid = " . $ugid . " AND owner_id = ".Yii::app()->session['loginID']." AND owner_id != ".$postuserid;
$result = db_execute_assoc($query); //Checked
if($result->count() > 0)
{
if($postuserid > 0)
{
$isrresult = User_in_groups::model()->insert(array('ugid' => $ugid, 'uid' => $postuserid)); //Checked

if($isrresult)
{
$addsummary .= "<div class=\"successheader\">".$clang->gT("User added.")."</div>\n";
}
else // ToDo: for this to happen the keys on the table must still be set accordingly
{
// Username already exists.
$addsummary .= "<div class=\"warningheader\">".$clang->gT("Failed to add user.")."</div>\n" . "<br />" . $clang->gT("Username already exists.")."<br />\n";
}
}
else
{
$addsummary .= "<div class=\"warningheader\">".$clang->gT("Failed to add user.")."</div>\n" . "<br />" . $clang->gT("No Username selected.")."<br />\n";
}
$addsummary .= "<br/><input type=\"submit\" onclick=\"window.location='" . $this->getController()->createUrl('admin/usergroups/view/ugid/') . '/' . $ugid . "'\" value=\"".$clang->gT("Continue")."\"/>\n";

}
else
{
die('access denied');
}
}
else
{
die('access denied');
}

$addsummary .= "</div>\n";
$aViewUrls['output'] = $addsummary;

$this->_renderWrappedTemplate($aViewUrls);
}

/**
* Renders template(s) wrapped in header and footer
*
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/usergroup/viewUserGroup_view.php
Expand Up @@ -74,7 +74,7 @@
if (!empty($useradddialog))
{
?>
<form action='<?php echo $this->createUrl('admin/usergroups/add'); ?>' method='post'>
<form action='<?php echo $this->createUrl("admin/usergroups/addusertogroup/ugid/{$ugid}"); ?>' method='post'>
<table class='users'><tbody><tr><td>&nbsp;</td>
<td>&nbsp;</td>
<td align='center'>
Expand Down

0 comments on commit 1bb7d9f

Please sign in to comment.