function &createChild()
 {
     $commentObject = new XoopsComment();
     $commentObject->setNew();
     $commentObject->set('com_pid', $this->get('com_id'));
     $commentObject->set('com_rootid', $this->get('com_rootid'));
     $commentObject->set('com_modid', $this->get('com_modid'));
     $commentObject->set('com_itemid', $this->get('com_itemid'));
     $commentObject->set('com_exparams', $this->get('com_exparams'));
     $title = $this->get('com_title');
     if (preg_match("/^Re:(.+)\$/", $title, $matches)) {
         $commentObject->set('com_title', "Re[2]: " . $matches[1]);
     } elseif (preg_match("/^Re\\[(\\d+)\\]:(.+)\$/", $title, $matches)) {
         $commentObject->set('com_title', "Re[" . ($matches[1] + 1) . "]: " . $matches[2]);
     }
     return $commentObject;
 }
Beispiel #2
0
 /**
  * Get some {@link XoopsComment}s 
  * 
  * @param   object  $criteria
  * @param   bool    $id_as_key  Use IDs as keys into the array?
  * 
  * @return  array   Array of {@link XoopsComment} objects
  **/
 function &getObjects($criteria = null, $id_as_key = false)
 {
     $ret = array();
     $limit = $start = 0;
     $sql = 'SELECT * FROM ' . $this->db->prefix('xoopscomments');
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $sql .= ' ' . $criteria->renderWhere();
         $sort = $criteria->getSort() != '' ? $criteria->getSort() : 'com_id';
         $sql .= ' ORDER BY ' . $sort . ' ' . $criteria->getOrder();
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
     }
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $comment = new XoopsComment();
         $comment->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] =& $comment;
         } else {
             $ret[$myrow['com_id']] =& $comment;
         }
         unset($comment);
     }
     return $ret;
 }
Beispiel #3
0
 /**
  * Update
  *
  * @param XoopsComment $comment    {@link XoopsComment} object
  * @param string $field_name  Name of the field
  * @param mixed  $field_value Value to write
  *
  * @return bool
  **/
 public function updateByField(XoopsComment $comment, $field_name, $field_value)
 {
     $comment->unsetNew();
     $comment->setVar($field_name, $field_value);
     return $this->insert($comment);
 }
Beispiel #4
0
 function getChildObjects(&$comment)
 {
     $ret = array();
     $table = $this->db->prefix("xoopscomments");
     $sql = "SELECT * FROM {$table} WHERE com_pid=" . $comment->getVar("com_id") . " AND com_id<>" . $comment->getVar("com_id");
     $result = $this->db->query($sql);
     while ($row = $this->db->fetchArray($result)) {
         $comment = new XoopsComment();
         $comment->assignVars($row);
         $ret[] =& $comment;
         unset($comment);
     }
     return $ret;
 }