Enhance poll v.2

https://github.com/xetown/xe-core/issues/24
- multilangual support
- methods names
- some enhancements
This commit is contained in:
MinSoo Kim 2016-01-04 14:23:46 +09:00
parent 563ba0f753
commit f870b768ac
6 changed files with 54 additions and 16 deletions

View file

@ -115,12 +115,18 @@ class poll extends ModuleObject
{
}
function isCangetMemberInfo($type)
/**
* @brief Check if this poll could display member information
*/
function checkMemberInfo($type)
{
return ($type==1 || $type==3);
}
function isCanAddItem($type)
/**
* @brief Check if the items of this poll could be added by members.
*/
function isAbletoAddItem($type)
{
return ($type==2 || $type==3);
}

View file

@ -118,7 +118,6 @@ class pollController extends poll
$poll_args->poll_type = $vars->show_vote + $vars->add_item;
$output = executeQuery('poll.insertPoll', $poll_args);
debugPrint($output);
if(!$output->toBool())
{
$oDB->rollback();
@ -190,7 +189,7 @@ class pollController extends poll
if(!$output->data) return new Object(-1,"poll_no_poll_or_deleted_poll");
$type = $output->data->poll_type;
if(!$this->isCanAddItem($type)) return new Object(-1,"msg_cannot_add_item");
if(!$this->isAbletoAddItem($type)) return new Object(-1,"msg_cannot_add_item");
if($logged_info->is_admin != 'Y')
{

View file

@ -65,7 +65,7 @@ class pollModel extends poll
}
$poll->poll_srl = $poll_srl;
$caniadditem = $this->isCanAddItem($poll->poll_type) && !!$logged_info->member_srl;
$caniadditem = $this->isAbletoAddItem($poll->poll_type) && !!$logged_info->member_srl;
$oPollModel = getModel('poll');
if($oPollModel->isPolled($poll_srl)) $poll->is_polled = 1;
@ -96,7 +96,7 @@ class pollModel extends poll
$poll = new stdClass();
if($this->isCangetMemberInfo($type))
if($this->checkMemberInfo($type))
{
$pollvar = new stdClass;
$pollvar->poll_srl = $poll_srl;
@ -123,18 +123,18 @@ class pollModel extends poll
{
if(Context::get('logged_info')->is_admin === "Y")
{
$ip = (int) str_replace(".","",$value->ip_address);
$ip = md5($value->ip_address);
$poll->member[$ip] = new stdClass();
$poll->member[$ip]->member_srl = 0;
$poll->member[$ip]->nick_name = $value->ip_address;
$poll->member[$ip]->nick_name = Context::getLang("anonymous") . ' IP: ' . $value->ip_address;
$poll->member[$ip]->profile_image = "";
}
else
{
$ip = md5(str_replace(".","",$value->ip_address));
$ip = md5($value->ip_address);
$poll->member[$ip] = new stdClass();
$poll->member[$ip]->member_srl = 0;
$poll->member[$ip]->nick_name = "Anonymous";
$poll->member[$ip]->nick_name = Context::getLang("anonymous");
$poll->member[$ip]->profile_image = "";
}
}