/** * getListMemberEmails * * gets user data of people in the mailing list * * @param string $type * object type * @param int $oid * object id * * @return array * an array of contact data items */ function getListMemberEmails($type, $oid) { $dbobjname = EasyContactFormsDB::getTableName($type . '_MailingLists'); $query = "SELECT Contacts FROM {$dbobjname} WHERE {$type}='{$oid}'"; $rs = EasyContactFormsDB::getObjects($query); $result = array(); foreach ($rs as $item) { $user = $this->getSenderData($item->Contacts); if (!is_null($user)) { $result[$user->email] = $user->email; } } $dbobjname = EasyContactFormsDB::getTableName($type); $query = "SELECT ObjectOwner FROM {$dbobjname} WHERE id='{$oid}'"; $ooid = EasyContactFormsDB::getValue($query); $user = $this->getSenderData($ooid); if (!is_null($user)) { $result[$user->email] = $user->email; } return $result; }
/** * getStatusFilter * * sets a status filter, filtering out objects having the skip in * reporting flag set * * @param string $type * a name a type to set a status filter for * * @return object * the predefined filter object */ function getStatusFilter($type) { $query = 'SELECT id FROM ' . EasyContactFormsDB::getTableName($type) . ' WHERE SkipInReporting = TRUE'; $result = EasyContactFormsDB::select($query); $values = array(0); foreach ($result as $rec) { $values[] = $rec->id; } return (object) array('sign' => '12', 'values' => $values); }
/** * processHistory * * performs status/comment/history processing * * @param array $fieldvalues * request field data * @param string $type * object type * @param int $oid * object id * @param int $uid * current user id */ function processHistory($fieldvalues, $type, $oid, $uid) { $object = EasyContactFormsClassLoader::getObject($type, TRUE, $oid); $is_st_changed = isset($fieldvalues->Status) && $fieldvalues->Status != $object->get('Status'); $not_on_sn_chng_var = $type . '_NotifyOnStatusChange'; $not_on_st_change = EasyContactFormsApplicationSettings::getInstance()->get($not_on_sn_chng_var); $is_n_comment = isset($fieldvalues->Comment) && !empty($fieldvalues->Comment); $not_on_new_comment_var = $type . '_NotifyOnNewComment'; $not_on_new_comment = EasyContactFormsApplicationSettings::getInstance()->get($not_on_new_comment_var); $send_message = $is_n_comment && $not_on_new_comment || $is_st_changed && $not_on_st_change; if (!$is_st_changed && !$is_n_comment) { return $fieldvalues; } $type_status_map = array(); $objname = EasyContactFormsDB::getTableName($type_status_map[$type]); $status = ''; if (isset($objname)) { $sid = $is_st_changed ? intval($fieldvalues->Status) : $object->get('Status'); $status = EasyContactFormsDB::getValue("SELECT Description FROM {$objname} WHERE id='{$sid}'"); $status .= ' -- '; } $user = EasyContactFormsDB::getValue("SELECT CONCAT(Description,' ',Name) FROM #wp__easycontactforms_users WHERE id='{$uid}'"); $text = (object) array('body' => '', 'subject' => ''); $comment = ''; $delimeter = '-- ' . $user . ' -- ' . $status . date(EasyContactFormsT::get('DateTimeFormat')) . ' --<br/>'; if ($is_n_comment) { $comment = $fieldvalues->Comment; unset($fieldvalues->Comment); $text->body = $comment; $stemplate = EasyContactFormsApplicationSettings::getInstance()->get('NewCommentSubject'); $text->subject = sprintf($stemplate, $type, $object->get('Description'), $status); } if ($is_st_changed) { $stemplate = EasyContactFormsApplicationSettings::getInstance()->get('StatusChangeSubject'); $text->subject = sprintf($stemplate, $type, $object->get('Description'), $status); } $history = $delimeter . $text->body . '<br/>' . $object->get('History'); $fieldvalues->History = $history; if ($send_message) { $this->sendNotification($uid, $type, $oid, $text); } return $fieldvalues; }
/** * getStdList * * creates a simple list of records * * @param string $obj * the object type to select * @param string $fld * a optional field to order by * * @return array * an array containing object records */ function getStdList($obj, $fld = NULL) { $orderby = isset($fld) ? $fld : 'Description'; $tablename = EasyContactFormsDB::getTableName($obj); $query = "SELECT id, Description FROM {$tablename} ORDER BY {$orderby}"; return $this->getList($query); }
/** * getFirst * * selects a first record in an object table * * @param string $type * a type of object to look up * @param boolean $lp * indicates a way of object ordering * * @return int * a found object id */ function getFirst($type, $lp = FALSE) { $orderby = $lp ? 'ListPosition' : 'Description'; $tablename = EasyContactFormsDB::getTableName($type); $query = 'SELECT id FROM ' . $tablename . ' ORDER BY ' . $orderby . ' LIMIT 1'; $result = EasyContactFormsDB::getValue($query); return $result; }