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
48 /* the code below is auto generated do not remove the above tag */
50 var $__table = 'cms_comments'; // table name
51 var $id; // int(11) not_null primary_key auto_increment
52 var $entry_id; // int(10) not_null unsigned
53 var $ontable; // text not_null
54 var $posted; // int(10) unsigned
55 var $title; // string(150)
56 var $author; // string(80)
57 var $email; // string(200)
58 var $url; // string(200)
59 var $ip; // string(15)
60 var $body; // blob(65535) multiple_key blob
61 var $type; // string(100)
62 var $wikifile; // varchar(128)
63 var $subscribed; // string(5) not_null enum
66 /* the code above is auto generated do not remove the tag below */
69 function sendToEntryAuthor($template = 'blogemail.txt')
71 $a = DB_DataObject::factory('core_person');
72 if ($this->entry_id) {
73 $e = DB_DataObject::factory('cms_page');
74 $e->get($this->entry_id);
76 $a->get($e->author_id);
78 $a->get('email','alan@akbkhome.com');
83 //return $a->sendComment($this,$template);
91 $p = htmlspecialchars($this->body);
92 $lr = "#((http://|https://|mailto:)[^\s\[\]\'\"\)]+)#";
93 $p = preg_replace($lr,'<a target="_new" href="\1">\1</a>', $p);
94 if ($this->title == "Example Code") {
96 return "<code class=\"phpcode\">" . nl2br($p) . "</code>";
104 return date("d M Y, H:i",$this->timestamp);
111 if (!strlen(trim($this->url))) {
114 if (preg_match('#^http://#',$this->url)) {
117 return 'http://' . $this->url;
122 function setTitle($str)
124 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
131 function setURL($str) {
133 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
139 function setBody($str)
143 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
146 $x = explode('http://', $str);
155 function posted($format = 'd/M/Y')
157 return date($format, strtotime($this->posted));
160 function replace($find = ' ', $replace = '-', $field)
162 if(empty($this->{$field})){
165 return str_replace($find, $replace, $this->{$field});
168 function addPoints($type, $person, $roo)
171 $enum = DB_DataObject::factory('core_enum');
172 $enum->setFrom(array(
173 'etype' => 'social_points_reason',
177 if(!$enum->find(true)){
178 $roo->jerr("Missing type - {$type}?!");
181 $social_points = DB_DataObject::factory('social_points');
182 $social_points->_join .= "
184 cms_comments AS join_cms_comments
186 join_cms_comments.id = social_points.onid
189 $social_points->setFrom(array(
190 'person_id' => $person->id,
191 'reason_id' => $enum->id,
194 $social_points->whereAdd("
195 join_cms_comments.entry_id = $this->entry_id
198 if($social_points->find(true)){
202 $points = (int) array_pop(explode('_', $enum->name));
204 $social_points->onid = $this->id;
205 $social_points->points = $points;
206 $social_points->act_when = $social_points->sqlValue("NOW()");
208 $social_points->insert();
210 $social_points->onInsert(array(), $roo);
216 $person = DB_DataObject::factory('core_person');
217 if(!$person->get('email', $this->email)){