Forums / Setup & design / poll locking

poll locking

Author Message

Marko Žmak

Saturday 27 November 2004 3:02:30 pm

I have several polls on my site and I would like to 'lock' some of them. So that users can vote only for polls that aren't locked but view results for all of them.

Is there any mechanism in eZ that provides that functionallity?

I know that it can be done by overriding some templates, but I want to know if there's a more generic eZ solution.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Marko Žmak

Tuesday 30 November 2004 4:05:34 pm

Does anyone have an answer to this?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Łukasz Serwatka

Tuesday 30 November 2004 10:31:00 pm

Hi,

Poll i normaly object so you can build templeate for for this class and add this to view results.

{set-block scope=global variable=title}{'Poll %pollname'|i18n('design/standard/content/poll',,hash('%pollname',$node.name))}{/set-block}


 <div class="folderTitle">Poll results</div><br />

<div style="padding-left: 4px">

{section loop=$node.object.contentobject_attributes}
    {section show=$:item.contentclass_attribute.is_information_collector}
	{let  attribute=$:item
	      contentobject_attribute_id=cond($attribute|get_class|eq('ezinformationcollectionattribute'),$attribute.contentobject_attribute_id,
                                     $attribute|get_class|eq('ezcontentobjectattribute'),$attribute.id)
     contentobject_attribute=cond($attribute|get_class|eq('ezinformationcollectionattribute'),$attribute.contentobject_attribute,
			          $attribute|get_class|eq('ezcontentobjectattribute'),$attribute)
     total_count=fetch('content','collected_info_count', hash( 'object_attribute_id', $contentobject_attribute_id ) )
     item_counts=fetch('content','collected_info_count_list', hash( 'object_attribute_id', $contentobject_attribute_id  ) ) }

<h3>{$contentobject_attribute.content.nazwa}</h3>

<table width="100%"border="0" cellspacing="0" cellpadding="0">
<tr>
{section name=Option loop=$contentobject_attribute.content.option_list}
    {let item_count=0}
    {section show=is_set($item_counts[$:item.id])}
        {set item_count=$item_counts[$:item.id]}
    {/section}
<td>

    </td>

    <td>
        <table width="250px" cellspacing="0" cellpadding="0" border="0">
  <tr>
<td colspan="2">
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="50%" align="left" height="23">{$:item.value}</td>
    <td width="50%" align="right"><strong>{div(mul($:item_count,100),$total_count)|l10n(number)} % </strong> ({$:item_count})
</td>
  </tr>
</table>
</td>
</tr>
        <tr>
            <td bgcolor="#890101" height="2" width="{div(mul($:item_count,250),$total_count)}"></td>
            <td bgcolor="#D9D9D9" height="2" width="{sub(250,div(mul($:item_count,250),$total_count))}"></td>
        </tr>
        </table>
    </td>
<td>
       
    </td>

    {/let}

    {delimiter}
</tr>
<tr>
    {/delimiter}

{/section}
</tr>
</table>

{/let}

    {section-else}

        {section show=$attribute_hide_list|contains($:item.contentclass_attribute.identifier)|not}
            <div class="object_title">{attribute_view_gui attribute=$:item}</div>
        {/section}

    {/section}

{/section}

<br/>

{"%count total votes"|i18n( 'design/standard/content/poll' ,,
                             hash( '%count', fetch( content, collected_info_count, hash( object_id, $node.object.id ) ) ) )}

</div>

Just paste it into new template thet display poll results. You will get only results so your users cant`t vote for it any more.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Marko Žmak

Wednesday 01 December 2004 11:28:10 am

As I mentioned before, I know that it can be done this way, but I was looking for another solution. Because in your solution the problem is just half solved, you only hide the form used for poll voting, but users can still vote for this poll by posting data in some other way.

The problem is in the template that processes the poll data, how do I make it to process only some polls?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Łukasz Serwatka

Thursday 02 December 2004 7:09:03 am

Because in your solution the problem is just half solved, 
you only hide the form used for poll voting, 
but users can still vote for this poll by posting data in some other way.

Who will be posting data in some other way? I closed poll by viewing only results of this poll and I`m sure that nobody post data using other way. I never vot for a poll using emulator of post method ;-)

I remember that closing poll was submited as a new suggestion.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Marko Žmak

Thursday 02 December 2004 3:40:00 pm

> Who will be posting data in some other way?

Then you are sure that you ore the people who you make this site for don't have any enemies who want to fake thei poll data. If so, your solution is O.K. but I don't want to exclude any possibility.

> I remember that closing poll was submited as a new suggestion.

What happened to that? Is it done in some new version? eZ crew?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth