3 * Table Definition for cms_comments
5 class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
7 class Pman_Cms_DataObjects_Cms_comments extends DB_DataObject
10 // it would be nice to concatinate this... so it's no so huge...
11 static public $_regex = array(
37 'duraxoregi', // known spammer
55 /* the code below is auto generated do not remove the above tag */
57 var $__table = 'cms_comments'; // table name
58 var $id; // int(11) not_null primary_key auto_increment
59 var $entry_id; // int(10) not_null unsigned
60 var $ontable; // text not_null
61 var $posted; // int(10) unsigned
62 var $title; // string(150)
63 var $author; // string(80)
64 var $email; // string(200)
65 var $url; // string(200)
66 var $ip; // string(15)
67 var $body; // blob(65535) multiple_key blob
68 var $type; // string(100)
69 var $wikifile; // varchar(128)
70 var $subscribed; // string(5) not_null enum
73 /* the code above is auto generated do not remove the tag below */
76 function sendToEntryAuthor($template = 'blogemail.txt')
78 $a = DB_DataObject::factory('core_person');
79 if ($this->entry_id) {
80 $e = DB_DataObject::factory('cms_page');
81 $e->get($this->entry_id);
83 $a->get($e->author_id);
85 $a->get('email','alan@akbkhome.com');
90 //return $a->sendComment($this,$template);
98 $p = htmlspecialchars($this->body);
99 $lr = "#((http://|https://|mailto:)[^\s\[\]\'\"\)]+)#";
100 $p = preg_replace($lr,'<a target="_new" href="\1">\1</a>', $p);
101 if ($this->title == "Example Code") {
103 return "<code class=\"phpcode\">" . nl2br($p) . "</code>";
111 return date("d M Y, H:i",$this->timestamp);
118 if (!strlen(trim($this->url))) {
121 if (preg_match('#^http://#',$this->url)) {
124 return 'http://' . $this->url;
129 function setTitle($str)
131 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
138 function setURL($str) {
140 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
146 function setBody($str)
150 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
153 $x = explode('http://', $str);
162 function posted($format = 'd/M/Y')
164 return date($format, strtotime($this->posted));
167 function replace($find = ' ', $replace = '-', $field)
169 if(empty($this->{$field})){
172 return str_replace($find, $replace, $this->{$field});
175 function addPoints($type, $person, $roo)
178 $enum = DB_DataObject::factory('core_enum');
179 $enum->setFrom(array(
180 'etype' => 'social_points_reason',
184 if(!$enum->find(true)){
185 $roo->jerr("Missing type - {$type}?!");
188 $social_points = DB_DataObject::factory('social_points');
189 $social_points->_join .= "
191 cms_comments AS join_cms_comments
193 join_cms_comments.id = social_points.onid
196 $social_points->setFrom(array(
197 'person_id' => $person->id,
198 'reason_id' => $enum->id,
201 $social_points->whereAdd("
202 join_cms_comments.entry_id = $this->entry_id
205 if($social_points->find(true)){
209 $points = (int) array_pop(explode('_', $enum->name));
211 $social_points->onid = $this->id;
212 $social_points->points = $points;
213 $social_points->act_when = $social_points->sqlValue("NOW()");
215 $social_points->insert();
217 $social_points->onInsert(array(), $roo);
223 $person = DB_DataObject::factory('core_person');
224 if(!$person->get('email', $this->email)){