Skip to content

Commit

Permalink
Added view saved but not submitted responses by GCI participant Aaron…
Browse files Browse the repository at this point in the history
… Schmitz

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11568 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Aaron Schmitz committed Dec 2, 2011
1 parent 246ba72 commit 44315b0
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 59 deletions.
5 changes: 3 additions & 2 deletions application/controllers/AdminController.php
Expand Up @@ -128,9 +128,10 @@ public function actions()
'translate' => 'application.controllers.admin.translate',
'labels' => 'application.controllers.admin.labels',
'templates' => 'application.controllers.admin.templates',
'user' => 'application.controllers.admin.useraction',
'user' => 'application.controllers.admin.useraction',
'participants' => 'application.controllers.admin.participantsaction',
'translate' => 'application.controllers.admin.translate'
'translate' => 'application.controllers.admin.translate',
'saved' => 'application.controllers.admin.saved'
);
}

Expand Down
88 changes: 44 additions & 44 deletions application/controllers/admin/saved.php
Expand Up @@ -22,34 +22,34 @@
* @version $Id: saved.php 11128 2011-10-08 22:23:24Z dionet $
* @access public
*/
class saved extends Survey_Common_Controller {

/**
* saved::__construct()
* Constructor
* @return
*/
function __construct()
{
parent::__construct();
}
class saved extends Survey_Common_Action {

/**
* saved::view()
* Load viewing of unsaved responses screen.
* @param mixed $surveyid
* @return
*/
function view($surveyid)

public function run($sa)
{
if ($sa == 'delete')
$this->route('delete', array());
$this->route('view', array());
}

public function view()
{
$surveyid = sanitize_int($surveyid);
self::_js_admin_includes(base_url().'scripts/jquery/jquery.tablesorter.min.js');
self::_js_admin_includes(base_url().'scripts/admin/saved.js');
self::_getAdminHeader();
@$surveyid = $_REQUEST['surveyid'];
if (!empty($_REQUEST['sid'])) $surveyid = (int)$_REQUEST['sid'];
$surveyid = sanitize_int($surveyid);
$this->_js_admin_includes(Yii::app()->baseUrl.'scripts/jquery/jquery.tablesorter.min.js');
$this->_js_admin_includes(Yii::app()->baseUrl.'scripts/admin/saved.js');
$this->getController()->_getAdminHeader();

if(bHasSurveyPermission($surveyid,'responses','read'))
{
$clang = $this->limesurvey_lang;
$clang = $this->getController()->lang;
$thissurvey=getSurveyInfo($surveyid);

$savedsurveyoutput = "<div class='menubar'>\n"
Expand All @@ -58,21 +58,21 @@ function view($surveyid)
. "<div class='menubar-main'>\n"
. "<div class='menubar-left'>\n";

$savedsurveyoutput .= self::_savedmenubar($surveyid);
$savedsurveyoutput .= $this->_savedmenubar($surveyid);

$savedsurveyoutput .= "</div></div></div>\n";

$savedsurveyoutput .= "<div class='header ui-widget-header'>".$clang->gT("Saved Responses:") . " ". getSavedCount($surveyid)."</div><p>";

$data['display'] = $savedsurveyoutput;
$this->load->view('survey_view',$data);
self::_showSavedList($surveyid);
$this->getController()->render('/survey_view',$data);
$this->_showSavedList($surveyid);
}

self::_loadEndScripts();
$this->getController()->_loadEndScripts();


self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));
$this->getController()->_getAdminFooter("http://docs.limesurvey.org", $this->getController()->lang->gT("LimeSurvey online manual"));


}
Expand All @@ -82,35 +82,35 @@ function view($surveyid)
* Function responsible to delete saved responses.
* @return
*/
function delete()
public function delete()
{
$surveyid=$this->input->post('sid');
$srid=$this->input->post('srid');
$scid=$this->input->post('scid');
$subaction=$this->input->post('subaction');
$surveytable = $this->db->dbprefix."survey_".$surveyid;
@$surveyid=$_REQUEST['sid'];
@$srid=$_REQUEST['srid'];
@$scid=$_REQUEST['scid'];
@$subaction=$_REQUEST['subaction'];
$surveytable = "{{survey_".$surveyid."}}";

if ($subaction == "delete" && $surveyid && $scid)
{
$query = "DELETE FROM ".$this->db->dbprefix."saved_control
$query = "DELETE FROM {{saved_control}}
WHERE scid=$scid
AND sid=$surveyid
";
$this->load->helper('database');
if ($result = db_execute_assosc($query))
Yii::app()->loadHelper('database');
if ($result = db_execute_assoc($query))
{
//If we were succesful deleting the saved_control entry,
//then delete the rest
$query = "DELETE FROM {$surveytable} WHERE id={$srid}";
$result = db_execute_assosc($query) or die("Couldn't delete");
$result = db_execute_assoc($query) or die("Couldn't delete");

}
else
{
show_error("Couldn't delete<br />$query<br />");
safe_error("Couldn't delete<br />$query<br />");
}
}
redirect("admin/saved/view/".$surveyid,'refresh');
$this->getController()->redirect("admin/saved/view/surveyid/".$surveyid,'refresh');
}

/**
Expand All @@ -119,23 +119,23 @@ function delete()
* @param mixed $surveyid
* @return
*/
function _showSavedList($surveyid)
private function _showSavedList($surveyid)
{
$this->load->helper('database');
Yii::app()->loadHelper('database');

$query = "SELECT scid, srid, identifier, ip, saved_date, email, access_code\n"
."FROM ".$this->db->dbprefix."saved_control\n"
."FROM {{saved_control}}\n"
."WHERE sid=$surveyid\n"
."ORDER BY saved_date desc";
$result = db_execute_assoc($query) or safe_die ("Couldn't summarise saved entries<br />$query<br />");
if ($result->num_rows() > 0)
if ($result->count() > 0)
{

$data['result'] = $result;
$data['clang'] = $clang;
$data['clang'] = $this->getController()->lang;
$data['surveyid'] = $surveyid;

$this->load->view('admin/saved/savedlist_view',$data);
$this->getController()->render('/admin/saved/savedlist_view',$data);
}
}

Expand All @@ -146,13 +146,13 @@ function _showSavedList($surveyid)
* @param mixed $surveyid
* @return
*/
function _savedmenubar($surveyid)
private function _savedmenubar($surveyid)
{
//BROWSE MENU BAR
$clang = $this->limesurvey_lang;
$clang = $this->getController()->lang;
if (!isset($surveyoptions)) {$surveyoptions="";}
$surveyoptions .= "<a href='".site_url('admin/survey/view/'.$surveyid)."' title='".$clang->gTview("Return to survey administration")."' >" .
"<img name='Administration' src='".$this->config->item('imageurl')."/home.png' alt='".$clang->gT("Return to survey administration")."' align='left'></a>\n";
$surveyoptions .= "<a href='".Yii::app()->baseUrl.'admin/survey/view/surveyid/'.$surveyid."' title='".$clang->gTview("Return to survey administration")."' >" .
"<img name='Administration' src='".Yii::app()->getConfig('imageurl')."/home.png' alt='".$clang->gT("Return to survey administration")."' align='left'></a>\n";

return $surveyoptions;
}
Expand Down
9 changes: 2 additions & 7 deletions application/helpers/common_helper.php
Expand Up @@ -2968,15 +2968,10 @@ function setuserrights($uid, $rights)
*/
function getSavedCount($surveyid)
{

$CI = &get_instance();
$surveyid=(int)$surveyid;

$CI->load->model('saved_control_model');



//$query = "SELECT COUNT(*) FROM ".db_table_name('saved_control')." WHERE sid=$surveyid";
$count=$CI->saved_control_model->getCountOfAll($surveyid);
$count=Saved_control::getCountOfAll($surveyid);
return $count;
}

Expand Down
79 changes: 79 additions & 0 deletions application/models/Saved_control.php
@@ -0,0 +1,79 @@
<?php if ( ! defined('BASEPATH')) die('No direct script access allowed');

class Saved_control extends CActiveRecord {
/**
* Returns the table's name
*
* @access public
* @return string
*/
public function tableName()
{
return '{{saved_control}}';
}

/**
* Returns the table's primary key
*
* @access public
* @return string
*/
public function primaryKey()
{
return 'sid';
}

/**
* Return the static model for this table
*
* @static
* @access public
* @return CActiveRecord
*/
public static function model()
{
return parent::model(__CLASS__);
}

function getAllRecords($condition=FALSE)
{
if ($condition != FALSE)
{
$this->db->where($condition);
}

$data = $this->db->get('saved_control');

return $data;
}

function getSomeRecords($fields,$condition=FALSE)
{
foreach ($fields as $field)
{
$this->db->select($field);
}
if ($condition != FALSE)
{
$this->db->where($condition);
}

$data = $this->db->get('saved_control');

return $data;
}

public function getCountOfAll($sid)
{
$data = Yii::app()->db->createCommand("SELECT COUNT(*) AS countall FROM {{saved_control}} WHERE sid=$sid")->query();
$row = $data->read();

return $row['countall'];
}

function insertRecords($data)
{
return $this->db->insert('saved_control', $data);
}

}
12 changes: 6 additions & 6 deletions application/views/admin/saved/savedlist_view.php
Expand Up @@ -6,26 +6,26 @@
<?php echo $clang->gT("Date Saved"); ?></th><th>
<?php echo $clang->gT("Email address"); ?></th>
</tr></thead><tbody>
<?php foreach($result->result_array() as $row)
<?php foreach($result->readAll() as $row)
{ ?>
<tr>
<td><?php echo $row['scid']; ?></td>
<td align='center'>

<?php if (bHasSurveyPermission($surveyid,'responses','update'))
{ ?>
<input style='height: 16; width: 16px; font-size: 8; font-family: verdana' type='image' src='<?php echo $this->config->item('imageurl'); ?>/token_edit.png' title='
<?php echo $clang->gT("Edit entry"); ?>' onclick="window.open('{$scriptname}?action=dataentry&amp;subaction=edit&amp;id={$row['srid']}&amp;sid={$surveyid}', '_top')" />
<input style='height: 16; width: 16px; font-size: 8; font-family: verdana' type='image' src='<?php echo Yii::app()->getConfig('imageurl'); ?>/token_edit.png' title='
<?php echo $clang->gT("Edit entry"); ?>' onclick="window.open('<?php echo $_SERVER['PHP_SELF']."?action=dataentry&amp;subaction=edit&amp;id={$row['srid']}&amp;sid={$surveyid}"?>', '_top')" />
<?php }
if (bHasSurveyPermission($surveyid,'responses','delete'))
{ ?>
<input style='height: 16; width: 16px; font-size: 8; font-family: verdana' type='image' src='<?php echo $this->config->item('imageurl'); ?>/token_delete.png' title='
<?php echo $clang->gT("Delete entry"); ?>' onclick="if (confirm('<?php echo $clang->gT("Are you sure you want to delete this entry?","js"); ?>')) { <?php echo get2post(site_url("admin/saved/delete")."?action=saved&amp;sid=$surveyid&amp;subaction=delete&amp;scid={$row['scid']}&amp;srid={$row['srid']}"); ?>}" />
<input style='height: 16; width: 16px; font-size: 8; font-family: verdana' type='image' src='<?php echo Yii::app()->getConfig('imageurl'); ?>/token_delete.png' title='
<?php echo $clang->gT("Delete entry"); ?>' onclick="if (confirm('<?php echo $clang->gT("Are you sure you want to delete this entry?","js"); ?>')) { <?php echo get2post($this->createUrl("admin/saved/sa/delete?action=saved&amp;sid=$surveyid&amp;subaction=delete&amp;scid={$row['scid']}&amp;srid={$row['srid']}")); ?>}" />
<?php } ?>

</td>
<td> <?php echo $row['identifier']; ?></td>
<td>".$row['ip']; ?></td>
<td> <?php echo $row['ip']; ?></td>
<td> <?php echo $row['saved_date']; ?></td>
<td><a href='mailto: <?php echo $row['email']; ?>'> <?php echo $row['email']; ?></td>

Expand Down

0 comments on commit 44315b0

Please sign in to comment.