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
50 /* the code below is auto generated do not remove the above tag */
52 var $__table = 'cms_comments'; // table name
53 var $id; // int(11) not_null primary_key auto_increment
54 var $entry_id; // int(10) not_null unsigned
55 var $ontable; // text not_null
56 var $posted; // int(10) unsigned
57 var $title; // string(150)
58 var $author; // string(80)
59 var $email; // string(200)
60 var $url; // string(200)
61 var $ip; // string(15)
62 var $body; // blob(65535) multiple_key blob
63 var $type; // string(100)
64 var $wikifile; // varchar(128)
65 var $subscribed; // string(5) not_null enum
68 /* the code above is auto generated do not remove the tag below */
71 function sendToEntryAuthor($template = 'blogemail.txt')
73 $a = DB_DataObject::factory('core_person');
74 if ($this->entry_id) {
75 $e = DB_DataObject::factory('cms_page');
76 $e->get($this->entry_id);
78 $a->get($e->author_id);
80 $a->get('email','alan@akbkhome.com');
85 //return $a->sendComment($this,$template);
93 $p = htmlspecialchars($this->body);
94 $lr = "#((http://|https://|mailto:)[^\s\[\]\'\"\)]+)#";
95 $p = preg_replace($lr,'<a target="_new" href="\1">\1</a>', $p);
96 if ($this->title == "Example Code") {
98 return "<code class=\"phpcode\">" . nl2br($p) . "</code>";
106 return date("d M Y, H:i",$this->timestamp);
113 if (!strlen(trim($this->url))) {
116 if (preg_match('#^http://#',$this->url)) {
119 return 'http://' . $this->url;
124 function setTitle($str)
126 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
133 function setURL($str) {
135 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
141 function setBody($str)
145 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
148 $x = explode('http://', $str);
157 function posted($format = 'd/M/Y')
159 return date($format, strtotime($this->posted));
162 function replace($find = ' ', $replace = '-', $field)
164 if(empty($this->{$field})){
167 return str_replace($find, $replace, $this->{$field});
170 function addPoints($type, $person, $roo)
173 $enum = DB_DataObject::factory('core_enum');
174 $enum->setFrom(array(
175 'etype' => 'social_points_reason',
179 if(!$enum->find(true)){
180 $roo->jerr("Missing type - {$type}?!");
183 $social_points = DB_DataObject::factory('social_points');
184 $social_points->_join .= "
186 cms_comments AS join_cms_comments
188 join_cms_comments.id = social_points.onid
191 $social_points->setFrom(array(
192 'person_id' => $person->id,
193 'reason_id' => $enum->id,
196 $social_points->whereAdd("
197 join_cms_comments.entry_id = $this->entry_id
200 if($social_points->find(true)){
204 $points = (int) array_pop(explode('_', $enum->name));
206 $social_points->onid = $this->id;
207 $social_points->points = $points;
208 $social_points->act_when = $social_points->sqlValue("NOW()");
210 $social_points->insert();
212 $social_points->onInsert(array(), $roo);
218 $person = DB_DataObject::factory('core_person');
219 if(!$person->get('email', $this->email)){