/** * Is form already folded by sender * * @access public * @return array of CMS_forms_action */ function isAlreadyFolded($sender) { if (!is_a($sender, 'CMS_forms_sender')) { $sender = CMS_forms_sender::getSenderForContext(); } //get number of responses for sender for this form if (!$this->getAttribute('responses')) { return false; } else { //get count of responses for sender $sql = "\n\t\t\t\tselect\n\t\t\t\t\tdistinct id_snd\n\t\t\t\tfrom\n\t\t\t\t\tmod_cms_forms_fields,\n\t\t\t\t\tmod_cms_forms_records,\n\t\t\t\t\tmod_cms_forms_senders\n\t\t\t\twhere\n\t\t\t\t\tform_fld = '" . $this->getID() . "'\n\t\t\t\t\tand id_fld = field_rec\n\t\t\t\t\tand sending_rec = id_snd \n\t\t\t\t\tand sessionID_snd = '" . sensitiveIO::sanitizeSQLString($sender->getAttribute('sessionID')) . "'\n\t\t\t"; $q = new CMS_query($sql); return $q->getNumRows() >= $this->getAttribute('responses'); } }
/** * Factory, instanciate a sender from current context * * @return CMS_forms_sender */ function getSenderForContext() { //sender does not exists in DB so create a new one*/ $obj = new CMS_forms_sender(); $obj->setAttribute('sessionID', Zend_Session::getId()); if (io::isPositiveInteger(CMS_session::getUserID())) { $obj->setAttribute('userID', CMS_session::getUserID()); } $obj->setAttribute('clientIP', @$_SERVER["REMOTE_ADDR"]); if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) { $obj->setAttribute('languages', @$_SERVER["HTTP_ACCEPT_LANGUAGE"]); } $obj->setAttribute('userAgent', @$_SERVER["HTTP_USER_AGENT"]); return $obj; }