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(
43 /* the code below is auto generated do not remove the above tag */
45 var $__table = 'cms_comments'; // table name
46 var $id; // int(11) not_null primary_key auto_increment
47 var $entry_id; // int(10) not_null unsigned
48 var $ontable; // text not_null
49 var $posted; // int(10) unsigned
50 var $title; // string(150)
51 var $author; // string(80)
52 var $email; // string(200)
53 var $url; // string(200)
54 var $ip; // string(15)
55 var $body; // blob(65535) multiple_key blob
56 var $type; // string(100)
57 var $wikifile; // varchar(128)
58 var $subscribed; // string(5) not_null enum
61 /* the code above is auto generated do not remove the tag below */
64 function sendToEntryAuthor($template = 'blogemail.txt')
66 $a = DB_DataObject::factory('core_person');
67 if ($this->entry_id) {
68 $e = DB_DataObject::factory('cms_page');
69 $e->get($this->entry_id);
71 $a->get($e->author_id);
73 $a->get('email','alan@akbkhome.com');
78 //return $a->sendComment($this,$template);
86 $p = htmlspecialchars($this->body);
87 $lr = "#((http://|https://|mailto:)[^\s\[\]\'\"\)]+)#";
88 $p = preg_replace($lr,'<a target="_new" href="\1">\1</a>', $p);
89 if ($this->title == "Example Code") {
91 return "<code class=\"phpcode\">" . nl2br($p) . "</code>";
99 return date("d M Y, H:i",$this->timestamp);
106 if (!strlen(trim($this->url))) {
109 if (preg_match('#^http://#',$this->url)) {
112 return 'http://' . $this->url;
117 function setTitle($str)
119 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
126 function setURL($str) {
128 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
134 function setBody($str)
138 if (preg_match('/('.implode('|', self::$_regex). ')/i',$str)) {
141 $x = explode('http://', $str);
150 function posted($format = 'd/M/Y')
152 return date($format, strtotime($this->posted));
155 function replace($find = ' ', $replace = '-', $field)
157 if(empty($this->{$field})){
160 return str_replace($find, $replace, $this->{$field});
163 function addPoints($type, $person, $roo)
166 $enum = DB_DataObject::factory('core_enum');
167 $enum->setFrom(array(
168 'etype' => 'social_points_reason',
172 if(!$enum->find(true)){
173 $roo->jerr("Missing type - {$type}?!");
176 $social_points = DB_DataObject::factory('social_points');
177 $social_points->_join .= "
179 cms_comments AS join_cms_comments
181 join_cms_comments.id = social_points.onid
184 $social_points->setFrom(array(
185 'person_id' => $person->id,
186 'reason_id' => $enum->id,
189 $social_points->whereAdd("
190 join_cms_comments.entry_id = $this->entry_id
193 if($social_points->find(true)){
197 $points = (int) array_pop(explode('_', $enum->name));
199 $social_points->onid = $this->id;
200 $social_points->points = $points;
201 $social_points->act_when = $social_points->sqlValue("NOW()");
203 $social_points->insert();
205 $social_points->onInsert(array(), $roo);
211 $person = DB_DataObject::factory('core_person');
212 if(!$person->get('email', $this->email)){