Example #1
0
 public static function category_update($in_category_id, $in_that, $in_topic)
 {
     /* check inputs and apply defaults */
     if (trim($in_that) == '') {
         $in_that = '*';
     }
     if (trim($in_topic) == '') {
         $in_topic = '*';
     }
     /* update the main category record */
     $stmt = JxBotDB::$db->prepare('UPDATE category SET that=?, topic=? WHERE id=?');
     $stmt->execute(array($in_that, $in_topic, $in_category_id));
     /* ! NOTE:  unlike a standard AIML interpreter, JxBot allows multiple patterns 
     		for each category - see file ENGINEERING for more information */
     /* re-add all the patterns, whose that & topic values will have changed;
     		this is not efficient for AIML load but necessary for some admin operations,
     		thus AIML load should collate patterns, that and topic and only add at completion
     		of a category. */
     $stmt = JxBotDB::$db->prepare('SELECT that,topic FROM category WHERE id=?');
     $stmt->execute(array($in_category_id));
     $row = $stmt->fetchAll(PDO::FETCH_NUM)[0];
     $that = $row[0];
     $topic = $row[1];
     $stmt = JxBotDB::$db->prepare('SELECT id,value FROM pattern WHERE category=?');
     $stmt->execute(array($in_category_id));
     $patterns = $stmt->fetchAll(PDO::FETCH_NUM);
     foreach ($patterns as $row) {
         $text = $row[1];
         $pattern = $row[0];
         /* remove the pattern */
         JxBotNLData::pattern_delete($pattern);
         /* reinsert the pattern */
         JxBotNLData::pattern_add($in_category_id, $text, $that, $topic);
     }
     return $in_category_id;
 }
Example #2
0
function do_del_pat()
{
    $inputs = JxBotUtil::inputs('pat-id');
    $category_id = JxBotNLData::pattern_delete($inputs['pat-id']);
    page_edit($category_id);
}