FreenetIS
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
Vote_Model Class Reference
Inheritance diagram for Vote_Model:
ORM

Public Member Functions

 get_all_votes_by_work ($work_id)
 Get all wotes by work.
 has_user_voted_about ($user_id, $fk_id, $type)
 Check if user voted about object.
 get_all_items_user_can_vote ($user_id)
 Returns all items (works, work reports and requests) to which user can vote.
 remove_vote ($user_id, $type, $fk_id)
 Removes vote.

Static Public Member Functions

static get_vote_options ($type=NULL, $is_own=NULL, $none_item=FALSE)
 Returns vote options.
static get_vote_option_name ($option, $none_item=FALSE)
 Returns vote option name.
static get_states ()
 Returns all states.
static get_state_name ($state)
 Returns state name.
static get_state_color ($state)
 Returns state color.
static get_state ($object, $approval_type_id=NULL)
 Function to get state of work/work report/request approval from all votes by approval template and type.
static insert ($user_id, $type, $fk_id, $vote, $comment, $aro_group_id, $time=NULL)
 Inserts new vote.

Public Attributes

const WORK = 1
 Type of vote for a work.
const WORK_REPORT = 2
 Type of vote for work report.
const REQUEST = 3
 Type of vote to request.
const ABSTAIN = 0
 abstain
const AGREE = 1
 agree
const DISAGREE = -1
 disagree
const STATE_NEW = 0
 new item, one votes about it, can be edited
const STATE_OPEN = 1
 open item, approval already started, cannot be edited
const STATE_REJECTED = 2
 rejected item
const STATE_APPROVED = 3
 approved item

Protected Attributes

 $belongs_to = array('user')

Member Function Documentation

Vote_Model::get_all_items_user_can_vote (   $user_id)

Returns all items (works, work reports and requests) to which user can vote.

Author
Michal Kliment
Parameters
integer$user_id
Returns
array
Todo:
this is not working on hierarchical voting!!!!!!!!!!!!
Vote_Model::get_all_votes_by_work (   $work_id)

Get all wotes by work.

Parameters
integer$work_id
Returns
Mysql_Result
static Vote_Model::get_state (   $object,
  $approval_type_id = NULL 
)
static

Function to get state of work/work report/request approval from all votes by approval template and type.

Author
Michal Kliment, Ondřej Fibich
Parameters
object$object
integer$approval_type_idCheck only for a single approval type
Returns
integer
static Vote_Model::get_state_color (   $state)
static

Returns state color.

Author
Michal Kliment
Parameters
integer$option
Returns
string
static Vote_Model::get_state_name (   $state)
static

Returns state name.

Author
Michal Kliment
Parameters
integer$option
Returns
string
static Vote_Model::get_states ( )
static

Returns all states.

Author
Michal Kliment
Returns
array
static Vote_Model::get_vote_option_name (   $option,
  $none_item = FALSE 
)
static

Returns vote option name.

Author
Michal Kliment
Parameters
integer$option
bool$none_itemAdd NULL 'none' item as first empty vote?
Returns
string
static Vote_Model::get_vote_options (   $type = NULL,
  $is_own = NULL,
  $none_item = FALSE 
)
static

Returns vote options.

Author
Michal Kliment
Parameters
integer$typeType of item to vote
bool$is_ownWhether vote about own item (e.g. work)
bool$none_itemAdd NULL 'none' item as first empty vote?
Returns
array Vote options
Vote_Model::has_user_voted_about (   $user_id,
  $fk_id,
  $type 
)

Check if user voted about object.

Parameters
integer$user_idUser's ID
integer$fk_idID of object
integer$typeType of voted object
Returns
boolean
static Vote_Model::insert (   $user_id,
  $type,
  $fk_id,
  $vote,
  $comment,
  $aro_group_id,
  $time = NULL 
)
static

Inserts new vote.

Author
Michal Kliment
Parameters
integer$user_id
integer$type
integer$fk_id
integer$vote
string$comment
integer$aro_group_id
datetime$time
Returns
Vote_Model
Vote_Model::remove_vote (   $user_id,
  $type,
  $fk_id 
)

Removes vote.

Author
Michal Kliment
Parameters
integer$user_id
integer$type
integer$fk_id
Returns
type

The documentation for this class was generated from the following file: