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(
44 /* the code below is auto generated do not remove the above tag */
46 var $__table = 'cms_comments'; // table name
47 var $id; // int(11) not_null primary_key auto_increment
48 var $entry_id; // int(10) not_null unsigned
49 var $ontable; // text not_null
50 var $posted; // int(10) unsigned
51 var $title; // string(150)
52 var $author; // string(80)
53 var $email; // string(200)
54 var $url; // string(200)
55 var $ip; // string(15)
56 var $body; // blob(65535) multiple_key blob
57 var $type; // string(100)
58 var $wikifile; // varchar(128)
59 var $subscribed; // string(5) not_null enum
62 /* the code above is auto generated do not remove the tag below */
65 function sendToEntryAuthor($template = 'blogemail.txt')
67 $a = DB_DataObject::factory('core_person');
68 if ($this->entry_id) {
69 $e = DB_DataObject::factory('cms_page');
70 $e->get($this->entry_id);
72 $a->get($e->author_id);
74 $a->get('email','alan@akbkhome.com');
79 //return $a->sendComment($this,$template);
87 $p = htmlspecialchars($this->body);
88 $lr = "#((http://|https://|mailto:)[^\s\[\]\'\"\)]+)#";
89 $p = preg_replace($lr,'<a target="_new" href="\1">\1</a>', $p);
90 if ($this->title == "Example Code") {
92 return "<code class=\"phpcode\">" . nl2br($p) . "</code>";
100 return date("d M Y, H:i",$this->timestamp);
107 if (!strlen(trim($this->url))) {
110 if (preg_match('#^http://#',$this->url)) {
113 return 'http://' . $this->url;
118 function setTitle($str)
120 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
127 function setURL($str) {
129 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
135 function setBody($str)
139 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
142 $x = explode('http://', $str);
151 function posted($format = 'd/M/Y')
153 return date($format, strtotime($this->posted));
156 function replace($find = ' ', $replace = '-', $field)
158 if(empty($this->{$field})){
161 return str_replace($find, $replace, $this->{$field});
164 function addPoints($type, $person, $roo)
167 $enum = DB_DataObject::factory('core_enum');
168 $enum->setFrom(array(
169 'etype' => 'social_points_reason',
173 if(!$enum->find(true)){
174 $roo->jerr("Missing type - {$type}?!");
177 $social_points = DB_DataObject::factory('social_points');
178 $social_points->_join .= "
180 cms_comments AS join_cms_comments
182 join_cms_comments.id = social_points.onid
185 $social_points->setFrom(array(
186 'person_id' => $person->id,
187 'reason_id' => $enum->id,
190 $social_points->whereAdd("
191 join_cms_comments.entry_id = $this->entry_id
194 if($social_points->find(true)){
198 $points = (int) array_pop(explode('_', $enum->name));
200 $social_points->onid = $this->id;
201 $social_points->points = $points;
202 $social_points->act_when = $social_points->sqlValue("NOW()");
204 $social_points->insert();
206 $social_points->onInsert(array(), $roo);
212 $person = DB_DataObject::factory('core_person');
213 if(!$person->get('email', $this->email)){