function onDelete($item_id)
 {
     //trigger_error( "Binder onDelete( $item_id )" );
     $bilink_handler =& xoonips_getormhandler('xnpbinder', 'binder_item_link');
     $criteria = new Criteria('item_id', $item_id);
     $bilinks =& $bilink_handler->getObjects($criteria);
     if (!$bilinks) {
         return;
     }
     foreach ($bilinks as $bilink) {
         $child_items =& $bilink_handler->getObjects(new Criteria('binder_id', $bilink->get('binder_id')));
         if (!$child_items) {
             continue;
         }
         $index_item_link_handler =& xoonips_getormhandler('xoonips', 'index_item_link');
         $join = new XooNIpsJoinCriteria('xoonips_index', 'index_id', 'index_id');
         $criteria = new CriteriaCompo(new Criteria('open_level', OL_PUBLIC));
         $criteria->add(new Criteria('certify_state', CERTIFIED));
         $criteria->add(new Criteria('item_id', $bilink->get('binder_id')));
         $index_item_links =& $index_item_link_handler->getObjects($criteria, false, '', false, $join);
         if (empty($index_item_links)) {
             continue;
         }
         if (count($child_items) == 1) {
             $item_handler =& xoonips_getormcompohandler('xnpbinder', 'item');
             $binder = $item_handler->get($bilink->get('binder_id'));
             $basic = $binder->getVar('basic');
             // define tags here for notification message
             $tags = xoonips_notification_get_item_tags($basic->get('item_id'));
             $mhandler =& xoops_gethandler('module');
             $module = $mhandler->getByDirName('xnpbinder');
             $nhandler =& xoonips_gethandler('xoonips', 'notification');
             $nhandler->triggerEvent2('user', 0, 'item_updated', _MD_XNPBINDER_USER_CONTENT_EMPTY_NOTIFYSBJ, $nhandler->getTemplateDirByMid($module->mid()), 'user_content_empty_notify', $tags, array($basic->get('uid')));
         }
         if (!$bilink_handler->delete($bilink)) {
             die('cannnot remove a deleted item from a binder.');
         }
     }
 }
function xoonips_notification_user_file_downloaded($file_id, $downloader_uid)
{
    $file_handler =& xoonips_getormhandler('xoonips', 'file');
    $file = $file_handler->get($file_id);
    $user_handler =& xoops_gethandler('user');
    $user = $user_handler->get($downloader_uid);
    $item_basic_handler =& xoonips_getormhandler('xoonips', 'item_basic');
    $item_basic = $item_basic_handler->get($file->get('item_id'));
    $tags = xoonips_notification_get_item_tags($file->get('item_id'));
    $tags['DOWNLOAD_TIMESTAMP'] = date('Y/m/d H:i:s');
    $tags['ORIGINAL_FILE_NAME'] = $file->get('original_file_name');
    $tags['UNAME'] = $user->getVar('uname');
    $nhandler =& xoonips_gethandler('xoonips', 'notification');
    $nhandler->triggerEvent2('user', 0, 'file_downloaded', _MD_XOONIPS_USER_FILE_DOWNLOADED_NOTIFYSBJ, $nhandler->getTemplateDirByMid(), 'user_file_downloaded_notify', $tags, array($item_basic->get('uid')));
}