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
45 /* the code below is auto generated do not remove the above tag */
47 var $__table = 'cms_comments'; // table name
48 var $id; // int(11) not_null primary_key auto_increment
49 var $entry_id; // int(10) not_null unsigned
50 var $ontable; // text not_null
51 var $posted; // int(10) unsigned
52 var $title; // string(150)
53 var $author; // string(80)
54 var $email; // string(200)
55 var $url; // string(200)
56 var $ip; // string(15)
57 var $body; // blob(65535) multiple_key blob
58 var $type; // string(100)
59 var $wikifile; // varchar(128)
60 var $subscribed; // string(5) not_null enum
63 /* the code above is auto generated do not remove the tag below */
66 function sendToEntryAuthor($template = 'blogemail.txt')
68 $a = DB_DataObject::factory('core_person');
69 if ($this->entry_id) {
70 $e = DB_DataObject::factory('cms_page');
71 $e->get($this->entry_id);
73 $a->get($e->author_id);
75 $a->get('email','alan@akbkhome.com');
80 //return $a->sendComment($this,$template);
88 $p = htmlspecialchars($this->body);
89 $lr = "#((http://|https://|mailto:)[^\s\[\]\'\"\)]+)#";
90 $p = preg_replace($lr,'<a target="_new" href="\1">\1</a>', $p);
91 if ($this->title == "Example Code") {
93 return "<code class=\"phpcode\">" . nl2br($p) . "</code>";
101 return date("d M Y, H:i",$this->timestamp);
108 if (!strlen(trim($this->url))) {
111 if (preg_match('#^http://#',$this->url)) {
114 return 'http://' . $this->url;
119 function setTitle($str)
121 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
128 function setURL($str) {
130 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
136 function setBody($str)
140 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
143 $x = explode('http://', $str);
152 function posted($format = 'd/M/Y')
154 return date($format, strtotime($this->posted));
157 function replace($find = ' ', $replace = '-', $field)
159 if(empty($this->{$field})){
162 return str_replace($find, $replace, $this->{$field});
165 function addPoints($type, $person, $roo)
168 $enum = DB_DataObject::factory('core_enum');
169 $enum->setFrom(array(
170 'etype' => 'social_points_reason',
174 if(!$enum->find(true)){
175 $roo->jerr("Missing type - {$type}?!");
178 $social_points = DB_DataObject::factory('social_points');
179 $social_points->_join .= "
181 cms_comments AS join_cms_comments
183 join_cms_comments.id = social_points.onid
186 $social_points->setFrom(array(
187 'person_id' => $person->id,
188 'reason_id' => $enum->id,
191 $social_points->whereAdd("
192 join_cms_comments.entry_id = $this->entry_id
195 if($social_points->find(true)){
199 $points = (int) array_pop(explode('_', $enum->name));
201 $social_points->onid = $this->id;
202 $social_points->points = $points;
203 $social_points->act_when = $social_points->sqlValue("NOW()");
205 $social_points->insert();
207 $social_points->onInsert(array(), $roo);
213 $person = DB_DataObject::factory('core_person');
214 if(!$person->get('email', $this->email)){