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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 04:29:12
Script start
Timing: Jan 19 2025 04:29:12
Module start 'layout'
Timing: Jan 19 2025 04:29:12
Module start 'content'
Timing: Jan 19 2025 04:29:13
Module end 'content'
Timing: Jan 19 2025 04:29:13
Script end

Main resources:

Total runtime0.8192 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 589.0313152.6094
Module start 'layout' 0.00570.0024 741.640639.4141
Module start 'content' 0.00810.8097 781.0547597.7109
Module end 'content' 0.81780.0013 1,378.765620.1953
Script end 0.8191  1,398.9609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.3822160.0002
Check MTime0.00140.1675160.0001
Mysql Total
Database connection0.00090.114610.0009
Mysqli_queries0.758392.5732660.0115
Looping result0.00060.0695640.0000
Template Total0.790096.420.3950
Template load0.00200.241820.0010
Template processing0.788096.195520.3940
Template load and register function0.00010.011210.0001
states
state_id_array0.00070.091410.0007
state_identifier_array0.00100.127220.0005
Override
Cache load0.00170.2061310.0001
Sytem overhead
Fetch class attribute can translate value0.00050.056920.0002
Fetch class attribute name0.00120.147880.0002
XML
Image XML parsing0.00100.120720.0005
class_abstraction
Instantiating content class attribute0.00000.0032120.0000
General
dbfile0.00090.1129260.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs