Skip to content

Commit

Permalink
Dev: Refactor the 'participantsaction' admin controller - GCI Task #7…
Browse files Browse the repository at this point in the history
…247202 by gautamgupta

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11743 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
GautamGupta committed Dec 23, 2011
1 parent 888498c commit 8e63b9d
Show file tree
Hide file tree
Showing 17 changed files with 2,978 additions and 2,877 deletions.
1,125 changes: 575 additions & 550 deletions application/controllers/admin/participantsaction.php

Large diffs are not rendered by default.

2,680 changes: 1,347 additions & 1,333 deletions application/models/Participants.php

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions application/models/Survey_links.php
@@ -0,0 +1,61 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* 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: Survey_links.php -1 $
* Files Purpose: lots of common functions
*/

class Survey_links extends CActiveRecord
{

/**
* Returns the static model of Settings table
*
* @static
* @access public
* @return CActiveRecord
*/
public static function model()
{
return parent::model(__CLASS__);
}

/**
* Returns the setting's table name to be used by the model
*
* @access public
* @return string
*/
public function tableName()
{
return '{{survey_links}}';
}

/**
* Returns the primary key of this table
*
* @access public
* @return string
*/
public function primaryKey()
{
return array('participant_id', 'token_id', 'survey_id');
}

function getLinkInfo($participantid)
{
return self::model()->findAllByAttributes(array('participant_id' => $participantid));
}

}

?>
47 changes: 25 additions & 22 deletions application/models/Tokens_dynamic.php
Expand Up @@ -10,7 +10,7 @@
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: common_helper.php 11335 2011-11-08 12:06:48Z c_schmitz $
* $Id$
* Files Purpose: lots of common functions
*/

Expand Down Expand Up @@ -39,8 +39,11 @@ public static function sid($sid)
* @param int $surveyid
* @return CActiveRecord
*/
public static function model()
public static function model($sid)
{
if (!is_null($sid))
self::sid($sid);

return parent::model(__CLASS__);
}

Expand Down Expand Up @@ -154,7 +157,7 @@ function createTokens($iSurveyID)
// an alternative way to get tokenlength... told to me by GautamGupta1: :)
//$tokenlength = Yii::app()->db->createCommand()->select('tokenlength')->from('{{surveys}}')->where('sid='.$surveyid)->query()->readColumn(0);
$iTokenLength = $tlrow[0]['tokenlength'];


//if tokenlength is not set or there are other problems use the default value (15)
if(!isset($iTokenLength) || $iTokenLength == '')
Expand Down Expand Up @@ -194,18 +197,18 @@ public function getSomeRecords($fields,$condition=FALSE)
$criteria = new CDbCriteria;

if ($condition != FALSE)
{
{
foreach ($condition as $item => $value)
{
$criteria->addCondition($item.'="'.$value.'"');
}
}

$data = $this->findAll($criteria);

return $data;
}

public function search()
{
// Warning: Please modify the following code to remove attributes that
Expand All @@ -232,9 +235,9 @@ public function search()
'criteria'=>$criteria,
));
}

function getSearch($condition,$page,$limit)
{
{
$start = $limit*$page - $limit;
if($condition[1]=='equal')
{
Expand All @@ -246,7 +249,7 @@ function getSearch($condition,$page,$limit)
else
{
$data = $command->select('*')->from(Tokens_dynamic::tableName())->limit($limit,$start)->queryAll();
}
}
return $data;
}
else if($condition[1]=='contains')
Expand All @@ -260,7 +263,7 @@ function getSearch($condition,$page,$limit)
else
{
$data = $command->limit($limit,$start)->queryAll();
}
}
return $data;
}
else if($condition[1]=='notequal')
Expand All @@ -273,7 +276,7 @@ function getSearch($condition,$page,$limit)
else
{
$data = $command->limit($limit,$start)->queryAll();
}
}
return $data;
}
else if($condition[1]=='notcontains')
Expand All @@ -287,7 +290,7 @@ function getSearch($condition,$page,$limit)
else
{
$data = $command->limit($limit,$start)->queryAll();
}
}
return $data;
}
else if($condition[1]=='greaterthan')
Expand All @@ -300,34 +303,34 @@ function getSearch($condition,$page,$limit)
else
{
$data = $command->limit($limit,$start)->queryAll();
}
}
return $data;
}
else if($condition[1]=='lessthan')
{
$command = Yii::app()->db->createCommand()->select('*')->from(Tokens_dynamic::tableName())->where($condition[0].' < "'.$condition[2].'"');
$command = Yii::app()->db->createCommand()->select('*')->from(Tokens_dynamic::tableName())->where($condition[0].' < "'.$condition[2].'"');
if($page == 0 && $limit == 0)
{
$data= $command->queryAll();
}
else
{
$data = $command->limit($limit,$start)->queryAll();
}
}
return $data;
}
}

function getSearchMultiple($condition,$page,$limit)
{
$i=0;
$j=1;
$tobedonelater =array();
$start = $limit*$page - $limit;
$start = $limit*$page - $limit;
$command = new CDbCriteria;
$command->condition = '';
$con= count($condition);
while($i < $con){
while($i < $con){
if($i<3){
$i+=3;
if($condition[1]=='equal')
Expand Down Expand Up @@ -372,7 +375,7 @@ function getSearchMultiple($condition,$page,$limit)
{
if($condition[$i]=='and')
{

$command->addCondition($condition[$i+1].' LIKE "%'.$condition[$i+3].'%"');
}
else
Expand Down Expand Up @@ -428,7 +431,7 @@ function getSearchMultiple($condition,$page,$limit)
}
else{$i=$i+4;}
}

if($page == 0 && $limit == 0)
{
$arr = Tokens_dynamic::model()->findAll($command);
Expand All @@ -448,8 +451,8 @@ function getSearchMultiple($condition,$page,$limit)
{
$data[$t->tid] = $t->attributes;
}
}
}

return $data;
}
function deleteToken($tokenid)
Expand Down

0 comments on commit 8e63b9d

Please sign in to comment.