function onUpdate($mode, $link_id, $forum_id, $topic_id, $post_id = 0)
 {
     global $xoopsDB, $xoopsConfig, $xoopsUser;
     if ($mode != "newtopic" && $mode != "reply") {
         return true;
     }
     // non-module integration returns false quickly
     if (!is_object($this->module)) {
         return false;
     }
     $not_module =& $this->module;
     $not_modid = $this->module->getVar('mid');
     $not_catinfo =& notificationCommentCategoryInfo($not_modid);
     // module without 'comment' notification
     if (empty($not_catinfo)) {
         return false;
     }
     $mydirname = $this->mydirname;
     //get uname
     if (is_object($xoopsUser)) {
         $uname = $xoopsUser->getVar('uname');
         $name = $xoopsUser->getVar('name');
     }
     $notif_name = $this->mod_config['use_name'] == 1 ? $name : $uname;
     $openarea_entry = 0;
     //default
     //get entry's title, bid, uid
     $sql = "SELECT d.uid, d.cid, d.title, d.bid, d.openarea AS openarea, d.vgids AS vgids, d.vpids AS vpids, \n\t\t\tc.cid, c.openarea AS openarea_cat, c.vgids AS vgids_cat, c.vpids AS vpids_cat \n\t\t\tFROM " . $xoopsDB->prefix($mydirname . '_diary') . " d \n\t\t\tLEFT JOIN " . $xoopsDB->prefix($mydirname . '_category') . " c \n\t\t\tON ((c.uid=d.uid or c.uid='0') and d.cid=c.cid) \n\t\t\tWHERE bid = '" . intval($link_id) . "'";
     //$sql = "SELECT * FROM " . $xoopsDB->prefix($mydirname.'_diary') . " WHERE bid = '".intval($link_id)."'";
     $result = $xoopsDB->query($sql);
     while ($dbdat = $xoopsDB->fetchArray($result)) {
         $title = $dbdat['title'];
         $bid = intval($dbdat['bid']);
         $uid = intval($dbdat['uid']);
         $cid = intval($dbdat['cid']);
         $openarea_entry = intval($dbdat['openarea']);
         $openarea_cat = intval($dbdat['openarea_cat']);
         $vgids = intval($dbdat['vgids']);
         $vpids = intval($dbdat['vpids']);
         $vgids_cat = intval($dbdat['vgids_cat']);
         $vpids_cat = intval($dbdat['vpids_cat']);
     }
     //$openarea_cat = $this->d3dConf->func->get_openarea_cat($uid,$cid);
     // Trigger Notification
     $users2notify = $this->mPerm->get_users_can_read_entry($openarea, $openarea_entry, $openarea_cat, $vgids, $vpids, $vgids_cat, $vpids_cat);
     $not_handler =& D3NotificationHandler::getInstance();
     $comment_tags = array('ENTRY_TITLE' => $title, 'ENTRY_BLOGGER' => $notif_name, 'ENTRY_URI' => XOOPS_URL . "/modules/" . $mydirname . "/index.php?page=detail&bid=" . $link_id . "&req_uid=" . $uid . "#comment");
     $not_handler->triggerEvent($this->mydirname, 'd3diary', 'blogger', $uid, 'new_comment', $comment_tags, $users2notify);
     $not_category = $not_catinfo['name'];
     $not_itemid = $link_id;
     $not_handler->triggerEvent($this->mydirname, 'd3diary', $not_category, $not_itemid, 'comment', $comment_tags, $users2notify);
     return true;
 }
Exemplo n.º 2
0
 }
 // increment user post if needed
 $uid = $comment->getVar('com_uid');
 if ($uid > 0 && false != $add_userpost) {
     $member_handler =& xoops_gethandler('member');
     $poster =& $member_handler->getUser($uid);
     if (is_object($poster)) {
         $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') + 1);
     }
 }
 // RMV-NOTIFY
 // trigger notification event if necessary
 if ($notify_event) {
     $not_modid = $com_modid;
     include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
     $not_catinfo =& notificationCommentCategoryInfo($not_modid);
     $not_category = $not_catinfo['name'];
     $not_itemid = $com_itemid;
     $not_event = $notify_event;
     // Build an ABSOLUTE URL to view the comment.  Make sure we
     // point to a viewable page (i.e. not the system administration
     // module).
     $comment_tags = array();
     if ('system' == $xoopsModule->getVar('dirname')) {
         $module_handler =& xoops_gethandler('module');
         $not_module =& $module_handler->get($not_modid);
     } else {
         $not_module =& $xoopsModule;
     }
     if (!isset($comment_url)) {
         $com_config =& $not_module->getInfo('comments');
Exemplo n.º 3
0
 function _processSave(&$controller, &$xoopsUser)
 {
     $statusArr = $this->mActionForm->get('status');
     $comment_handler = xoops_gethandler('comment');
     foreach (array_keys($statusArr) as $cid) {
         $comment =& $comment_handler->get($cid);
         if (is_object($comment)) {
             $olddata['com_status'] = $comment->get('com_status');
             $newdata['com_status'] = $this->mActionForm->get('status', $cid);
             if (count(array_diff_assoc($olddata, $newdata)) > 0) {
                 $comment->set('com_status', $this->mActionForm->get('status', $cid));
                 if (!$comment_handler->insert($comment)) {
                     return LEGACY_FRAME_VIEW_ERROR;
                 }
                 $add_userpost = false;
                 $call_approvefunc = false;
                 $call_updatefunc = false;
                 $notify_event = false;
                 if (!empty($newdata['com_status']) && $newdata['com_status'] != XOOPS_COMMENT_PENDING) {
                     if (XOOPS_COMMENT_PENDING == $olddata['com_status']) {
                         $add_userpost = true;
                         if (XOOPS_COMMENT_ACTIVE == $newdata['com_status']) {
                             $call_updatefunc = true;
                             $call_approvefunc = true;
                             $notify_event = 'comment';
                         }
                     } elseif (XOOPS_COMMENT_HIDDEN == $olddata['com_status'] && XOOPS_COMMENT_ACTIVE == $newdata['com_status']) {
                         $call_updatefunc = true;
                     } elseif (XOOPS_COMMENT_ACTIVE == $olddata['com_status'] && XOOPS_COMMENT_HIDDEN == $newdata['com_status']) {
                         $call_updatefunc = true;
                     }
                 }
                 $comment_config = Legacy_CommentEditAction::loadCallbackFile($comment);
                 if ($comment_config && $call_approvefunc != false) {
                     $function = $comment_config['callback']['approve'];
                     if (function_exists($function)) {
                         call_user_func($function, $comment);
                     }
                 }
                 if ($comment_config && $call_updatefunc != false) {
                     $function = $comment_config['callback']['update'];
                     if (function_exists($function)) {
                         $criteria = new CriteriaCompo(new Criteria('com_modid', $comment->getVar('com_modid')));
                         $criteria->add(new Criteria('com_itemid', $comment->getVar('com_itemid')));
                         $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
                         $comment_count = $comment_handler->getCount($criteria);
                         call_user_func_array($function, array($comment->getVar('com_itemid'), $comment_count, $comment->getVar('com_id')));
                     }
                 }
                 $uid = $comment->getVar('com_uid');
                 if ($uid > 0 && false != $add_userpost) {
                     $member_handler =& xoops_gethandler('member');
                     $poster =& $member_handler->getUser($uid);
                     if (is_object($poster)) {
                         $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') + 1);
                     }
                 }
                 //notification
                 // RMV-NOTIFY
                 // trigger notification event if necessary
                 if ($notify_event) {
                     $not_modid = $comment->getVar('com_modid');
                     include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
                     $not_catinfo =& notificationCommentCategoryInfo($not_modid);
                     $not_category = $not_catinfo['name'];
                     $not_itemid = $comment->getVar('com_itemid');
                     $not_event = $notify_event;
                     $comment_tags = array();
                     $module_handler =& xoops_gethandler('module');
                     $not_module =& $module_handler->get($not_modid);
                     $com_config =& $not_module->getInfo('comments');
                     $comment_url = $com_config['pageName'] . '?';
                     //Umm....not use com_exparams(--;;Fix Me!)
                     //$extra_params = $comment->getVar('com_exparams');
                     //$comment_url .= $extra_params;
                     $comment_url .= $com_config['itemName'];
                     $comment_tags['X_COMMENT_URL'] = XOOPS_URL . '/modules/' . $not_module->getVar('dirname') . '/' . $comment_url . '=' . $comment->getVar('com_itemid') . '&com_id=' . $comment->getVar('com_id') . '&com_rootid=' . $comment->getVar('com_rootid') . '#comment' . $comment->getVar('com_id');
                     $notification_handler =& xoops_gethandler('notification');
                     $notification_handler->triggerEvent($not_category, $not_itemid, $not_event, $comment_tags, false, $not_modid);
                 }
                 //notify if
             }
             //count if
         }
         //object if
     }
     //foreach
     foreach (array_keys($statusArr) as $cid) {
         if ($this->mActionForm->get('delete', $cid) == 1) {
             $comment =& $comment_handler->get($cid);
             if (is_object($comment)) {
                 if (!$comment_handler->delete($comment)) {
                     return LEGACY_FRAME_VIEW_ERROR;
                 }
                 if ($comment->get('com_status') != 1 && $comment->get('com_uid') > 0) {
                     $memberhandler =& xoops_gethandler('member');
                     $user =& $memberhandler->getUser($comment->get('com_uid'));
                     if (is_object($user)) {
                         $count = $user->get('posts');
                         if ($count > 0) {
                             $memberhandler->updateUserByField($user, 'posts', $count - 1);
                         }
                     }
                 }
                 // get all comments posted later within the same thread
                 $thread_comments =& $comment_handler->getThread($comment->getVar('com_rootid'), $cid);
                 include_once XOOPS_ROOT_PATH . '/class/tree.php';
                 $xot = new XoopsObjectTree($thread_comments, 'com_id', 'com_pid', 'com_rootid');
                 $child_comments =& $xot->getFirstChild($cid);
                 // now set new parent ID for direct child comments
                 $new_pid = $comment->getVar('com_pid');
                 $errs = array();
                 foreach (array_keys($child_comments) as $i) {
                     $child_comments[$i]->setVar('com_pid', $new_pid);
                     // if the deleted comment is a root comment, need to change root id to own id
                     if (false != $comment->isRoot()) {
                         $new_rootid = $child_comments[$i]->getVar('com_id');
                         $child_comments[$i]->setVar('com_rootid', $child_comments[$i]->getVar('com_id'));
                         if (!$comment_handler->insert($child_comments[$i])) {
                             $errs[] = 'Could not change comment parent ID from <b>' . $cid . '</b> to <b>' . $new_pid . '</b>. (ID: ' . $new_rootid . ')';
                         } else {
                             // need to change root id for all its child comments as well
                             $c_child_comments =& $xot->getAllChild($new_rootid);
                             $cc_count = count($c_child_comments);
                             foreach (array_keys($c_child_comments) as $j) {
                                 $c_child_comments[$j]->setVar('com_rootid', $new_rootid);
                                 if (!$comment_handler->insert($c_child_comments[$j])) {
                                     $errs[] = 'Could not change comment root ID from <b>' . $cid . '</b> to <b>' . $new_rootid . '</b>.';
                                 }
                             }
                         }
                     } else {
                         if (!$comment_handler->insert($child_comments[$i])) {
                             $errs[] = 'Could not change comment parent ID from <b>' . $cid . '</b> to <b>' . $new_pid . '</b>.';
                         }
                     }
                 }
                 if (count($errs) > 0) {
                     return LEGACY_FRAME_VIEW_ERROR;
                 }
                 //
                 // callback
                 //
                 $comment_config = Legacy_CommentEditAction::loadCallbackFile($comment);
                 if ($comment_config) {
                     $function = $comment_config['callback']['update'];
                     if (function_exists($function)) {
                         $criteria = new CriteriaCompo(new Criteria('com_modid', $comment->getVar('com_modid')));
                         $criteria->add(new Criteria('com_itemid', $comment->getVar('com_itemid')));
                         $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
                         $comment_count = $comment_handler->getCount($criteria);
                         call_user_func_array($function, array($comment->getVar('com_itemid'), $comment_count, $comment->getVar('com_id')));
                     }
                 }
             }
             //if object
         }
         //if
     }
     //foreach
     return LEGACY_FRAME_VIEW_SUCCESS;
 }
Exemplo n.º 4
0
 function processCommentNotifications($mode, $link_id, $forum_id, $topic_id, $post_id)
 {
     // non-module integration returns false quickly
     if (!is_object($this->module)) {
         return false;
     }
     $not_module =& $this->module;
     $not_modid = $this->module->getVar('mid');
     $not_catinfo =& notificationCommentCategoryInfo($not_modid);
     // module without 'comment' notification
     if (empty($not_catinfo)) {
         return false;
     }
     $not_category = $not_catinfo['name'];
     $not_itemid = $link_id;
     $not_event = 'comment';
     // 'comment_submit'?
     $comment_tags = array('X_COMMENT_URL' => XOOPS_URL . '/modules/' . $this->d3forum_dirname . '/index.php?post_id=' . intval($post_id));
     $users2notify = d3forum_get_users_can_read_forum($this->d3forum_dirname, $forum_id);
     if (empty($users2notify)) {
         $users2notify = array(0);
     }
     $not_handler =& D3NotificationHandler::getInstance();
     $not_handler->triggerEvent($this->mydirname, $this->mytrustdirname, $not_category, $not_itemid, $not_event, $comment_tags, $users2notify);
 }