function &execute(&$controller, &$request, &$user)
 {
     $objs =& $request->getAttribute('questions');
     $questions = array();
     foreach ($objs as $obj) {
         $arr =& $obj->getStructure();
         $arr['size_str'] = @sprintf(_MD_PLZXOO_FORMAT_ANSWERS_COUNT, $arr['size']);
         $questions[] =& $arr;
         unset($arr);
     }
     $listController =& $request->getAttribute('listController');
     $renderer = new mojaLE_XoopsTplRenderer($controller, $request, $user);
     $renderer->setTemplate('plzxoo_index.html');
     $renderer->setAttribute('questions', $questions);
     $renderer->setAttribute('listController', $listController->getStructure());
     exFrame::init(EXFRAME_PERM);
     $renderer->setAttribute('enable_post_question', exPerm::isPerm('post_question'));
     $cat_handler =& plzXoo::getHandler('category');
     $cat_obj =& $cat_handler->get(intval(@$_GET['cid']));
     if (is_object($cat_obj)) {
         $cat_arr = $cat_obj->getStructure();
         $renderer->setAttribute('category', $cat_arr);
         $renderer->setAttribute('xoops_pagetitle', $cat_arr['name']);
     } else {
         $renderer->setAttribute('category', array('children' => plzXooCategoryObject::getChildren(0), 'cid' => 0));
         $renderer->setAttribute('searchtxt4disp', htmlspecialchars($listController->filter_->txt_, ENT_QUOTES));
     }
     /*
     		echo "<pre>" ;
     		var_dump( $cat_obj->getStructure() ) ;
     		exit ;*/
     return $renderer;
 }
 function execute(&$controller, &$request, &$user)
 {
     exFrame::init(EXFRAME_PERM);
     // 閲覧権限のチェック
     exPerm::GuardRedirect('view_detail', 'index.php', _MD_PLZXOO_ERROR_PERMISSION);
     $id = isset($_REQUEST['qid']) ? intval($_REQUEST['qid']) : 0;
     $handler =& plzXoo::getHandler('question');
     $question =& $handler->get($id);
     if (!is_object($question)) {
         return VIEW_ERROR;
     }
     // ステータスが1,2と異なるものは管理者以外キック
     if (!in_array($question->getVar('status'), array(1, 2))) {
         if (!is_object($GLOBALS['xoopsUser']) || !$GLOBALS['xoopsUser']->isAdmin()) {
             return VIEW_ERROR;
         }
     }
     $handler =& plzXoo::getHandler('answer');
     $criteria = new Criteria('qid', $id);
     $criteria->setSort('input_date');
     $criteria->setOrder('DESC');
     $answers =& $handler->getObjects($criteria);
     $request->setAttribute('question', $question);
     $request->setAttribute('answers', $answers);
     return VIEW_SUCCESS;
 }
 /**
 @brief 削除権限があるかどうか
 */
 function isEnableDelete(&$user)
 {
     exFrame::init(EXFRAME_PERM);
     $uid = is_object($user) ? $user->uid() : 0;
     $flag = false;
     if ($this->getVar('uid') == $uid) {
         $flag = exPerm::isPerm('delete_my_answer');
     } else {
         $flag = exPerm::isPerm('delete_other_answer');
     }
     if (!$flag) {
         $handler =& plzXoo::getHandler('question');
         $question =& $handler->get($this->getVar('qid'));
         if ($question->getVar('uid') == $uid) {
             return exPerm::isPerm('delete_myposts_answer');
         } else {
             return false;
         }
     }
     return true;
 }
 /**
 @brief 削除権限があるかどうか
 */
 function isEnableDelete(&$user)
 {
     exFrame::init(EXFRAME_PERM);
     $uid = is_object($user) ? $user->uid() : 0;
     if ($this->getVar('uid') == $uid) {
         return exPerm::isPerm('delete_my_question');
     } else {
         return exPerm::isPerm('delete_other_question');
     }
 }
Esempio n. 5
0
<?php

require_once "../../mainfile.php";
require_once XOOPS_ROOT_PATH . "/header.php";
require_once XOOPS_ROOT_PATH . "/modules/exFrame/frameloader.php";
require_once "./class/global.class.php";
exFrame::init(EXFRAME_MOJALE);
// mojaLE を使用
$module = "default";
// 決め打ち
$action = isset($_REQUEST['action']) ? trim($_REQUEST['action']) : "";
$controller = new SimpleFrontController($module, $action, XOOPS_ROOT_PATH . "/modules/plzXoo");
$controller->setVarbose();
$controller->dispatch();
require_once XOOPS_ROOT_PATH . "/footer.php";
 function execute(&$controller, &$request, &$user)
 {
     exFrame::init(EXFRAME_PERM);
     // 回答権限のチェック
     exPerm::GuardRedirect('post_answer', 'index.php', _MD_PLZXOO_ERROR_PERMISSION);
     $qid = isset($_REQUEST['qid']) ? intval($_REQUEST['qid']) : 0;
     $qHandler =& plzXoo::getHandler('question');
     // ここで qid を確認
     $question =& $qHandler->get($qid);
     if (!is_object($question)) {
         $request->setAttribute('error_message', _MD_PLZXOO_ERROR_QUESTION_NOT_EXISTS);
         return VIEW_ERROR;
     } elseif ($question->getVar('status') != 1) {
         $request->setAttribute('error_message', _MD_PLZXOO_ERROR_QUESTION_CLOSED);
         return VIEW_ERROR;
     } elseif (is_object($user) && $question->getVar('uid') == $user->uid()) {
         exPerm::GuardRedirect('post_answer_myself', 'index.php', _MD_PLZXOO_ERROR_PERMISSION);
         // GIJ
     }
     $id = isset($_REQUEST['aid']) ? intval($_REQUEST['aid']) : 0;
     $handler =& plzXoo::getHandler('answer');
     $obj =& $handler->get($id);
     if (!is_object($obj)) {
         $is_new = true;
         $obj =& $handler->create();
         $obj->setVar('uid', $user->uid());
         $obj->setVar('qid', $qid);
     } else {
         $is_new = false;
         // 権限の確認
         if (!$obj->isEnableEdit($user)) {
             $request->setAttribute('error_message', _MD_PLZXOO_ERROR_PERMISSION);
             return VIEW_ERROR;
         }
     }
     $editform =& new EditAnswerForm();
     if ($editform->init($obj) == ACTIONFORM_POST_SUCCESS) {
         $editform->update($obj);
         // 入力内容をオブジェクトに受け取る
         $request->setAttribute('question', $question);
         $obj->setVar('modified_date', time());
         if ($handler->insert($obj)) {
             // update size of question
             $question->updateSize();
             $question->setVar('modified_date', time());
             $qHandler->insert($question);
             // notifications
             $notification_handler =& xoops_gethandler('notification');
             if ($is_new) {
                 // trigger notification of question:newa
                 $notification_handler->triggerEvent('question', $question->getVar('qid'), 'newa', array('QUESTION_SUBJECT' => $question->getVar('subject'), 'ANSWER_UNAME' => $user->getVar('uname'), 'CONDITION' => _MD_PLZXOO_LANG_NOTIFY_NEWA, 'QUESTION_URI' => XOOPS_URL . "/modules/plzXoo/index.php?action=detail&amp;qid=" . $question->getVar('qid')));
                 // trigger notification of question:updt
                 $notification_handler->triggerEvent('question', $question->getVar('qid'), 'updt', array('QUESTION_SUBJECT' => $question->getVar('subject'), 'UNAME' => $user->getVar('uname'), 'CONDITION' => _MD_PLZXOO_LANG_NOTIFY_NEWA, 'QUESTION_URI' => XOOPS_URL . "/modules/plzXoo/index.php?action=detail&amp;qid=" . $question->getVar('qid')));
                 // auto register a notification question:updt into answerer
                 if (!empty($GLOBALS['xoopsModuleConfig']['autonotify_answerer'])) {
                     $notification_handler->subscribe('question', $question->getVar('qid'), 'updt');
                 }
             } else {
                 // trigger notification of question:updt
                 $notification_handler->triggerEvent('question', $question->getVar('qid'), 'updt', array('QUESTION_SUBJECT' => $question->getVar('subject'), 'UNAME' => $user->getVar('uname'), 'CONDITION' => _MD_PLZXOO_LANG_NOTIFY_MODA, 'QUESTION_URI' => XOOPS_URL . "/modules/plzXoo/index.php?action=detail&amp;qid=" . $question->getVar('qid')));
             }
             return VIEW_SUCCESS;
         } else {
             return VIEW_ERROR;
         }
     }
     $handler =& plzXoo::getHandler('category');
     $category =& $handler->get($question->getVar('cid'));
     $request->setAttribute('editform', $editform);
     $request->setAttribute('category', $category);
     $request->setAttribute('question', $question);
     $request->setAttribute('answer', $obj);
     return VIEW_INPUT;
 }
 function execute(&$controller, &$request, &$user)
 {
     exFrame::init(EXFRAME_PERM);
     // 投函権限のチェック
     exPerm::GuardRedirect('post_question', 'index.php', _MD_PLZXOO_ERROR_PERMISSION);
     $id = isset($_REQUEST['qid']) ? intval($_REQUEST['qid']) : 0;
     $handler =& plzXoo::getHandler('question');
     $obj = null;
     if ($id) {
         $obj =& $handler->get($id);
     }
     if (!is_object($obj)) {
         $is_new = true;
         $obj =& $handler->create();
         $obj->setVar('uid', $user->uid());
         // 自動承認がなければ、承認待ちへ
         if (!exPerm::isPerm('post_question_auto_approve')) {
             $obj->setVar('status', 4);
             $is_need_approve = true;
             $is_new = false;
         }
     } else {
         $is_new = false;
         // 編集権限の確認
         if (!$obj->isEnableEdit($user)) {
             $request->setAttribute('message', _MD_PLZXOO_ERROR_PERMISSION);
             return VIEW_ERROR;
         }
         // ステータスが無効のものは管理者以外編集不能
         if ($obj->getVar('status') == 3) {
             if (!is_object($GLOBALS['xoopsUser']) || !$GLOBALS['xoopsUser']->isAdmin()) {
                 return VIEW_ERROR;
             }
         }
     }
     $prev_status = $obj->getVar('status');
     $editform =& new EditQuestionForm();
     if ($editform->init($obj) == ACTIONFORM_POST_SUCCESS) {
         $editform->update($obj);
         // 入力内容をオブジェクトに受け取る
         // 承認処理のチェック
         $obj->setVar('modified_date', time());
         if ($handler->insert($obj)) {
             // update size of category
             $category_handler =& plzXoo::getHandler('category');
             $category =& $category_handler->get($obj->getVar('cid'));
             $category->updateSize();
             $category_handler->insert($category);
             // notifications
             $notification_handler =& xoops_gethandler('notification');
             if ($is_new || $prev_status == 4 && $obj->getVar('status') == 1) {
                 // 新規または承認後の通知処理
                 // trigger notification of global:newq
                 $notification_handler->triggerEvent('global', 0, 'newq', array('QUESTION_SUBJECT' => $obj->getVar('subject'), 'QUESTION_UNAME' => $user->getVar('uname'), 'CONDITION' => _MD_PLZXOO_LANG_NOTIFY_NEWQ, 'QUESTION_URI' => XOOPS_URL . "/modules/plzXoo/index.php?action=detail&amp;qid=" . $obj->getVar('qid')));
                 // trigger notification of category:newq
                 $notification_handler->triggerEvent('category', $obj->getVar('cid'), 'newq', array('QUESTION_SUBJECT' => $obj->getVar('subject'), 'QUESTION_UNAME' => $user->getVar('uname'), 'CONDITION' => _MD_PLZXOO_LANG_NOTIFY_NEWQ, 'CATEGORY_NAME' => $category->getVar('name'), 'QUESTION_URI' => XOOPS_URL . "/modules/plzXoo/index.php?action=detail&amp;qid=" . $obj->getVar('qid')));
                 // auto register a notification question:newa into questioner
                 if (!empty($GLOBALS['xoopsModuleConfig']['autonotify_questioner'])) {
                     $notification_handler->subscribe('question', $obj->getVar('qid'), 'newa', null, null, $obj->getVar('uid'));
                 }
             } else {
                 if ($is_need_approve) {
                     // 承認待ちの通知処理 (waiting)
                     // trigger notification of global:neww
                     $notification_handler->triggerEvent('global', 0, 'neww', array('QUESTION_SUBJECT' => $obj->getVar('subject'), 'QUESTION_UNAME' => $user->getVar('uname'), 'CONDITION' => _MD_PLZXOO_LANG_NOTIFY_NEWW, 'QUESTION_URI' => XOOPS_URL . "/modules/plzXoo/index.php?action=detail&amp;qid=" . $obj->getVar('qid')));
                 } else {
                     // trigger notification of question:updt
                     $notification_handler->triggerEvent('question', $obj->getVar('qid'), 'updt', array('QUESTION_SUBJECT' => $obj->getVar('subject'), 'UNAME' => $user->getVar('uname'), 'CONDITION' => _MD_PLZXOO_LANG_NOTIFY_MODQ, 'QUESTION_URI' => XOOPS_URL . "/modules/plzXoo/index.php?action=detail&amp;qid=" . $obj->getVar('qid')));
                 }
             }
             // message
             if (empty($is_need_approve)) {
                 $request->setAttribute('success_message', _MD_PLZXOO_MESSAGE_POSTQ_AUTO_APPROVED);
             } else {
                 $request->setAttribute('success_message', _MD_PLZXOO_MESSAGE_POSTQ_NEED_APPROVE);
             }
             return VIEW_SUCCESS;
         } else {
             return VIEW_ERROR;
         }
     }
     // カテゴリ一覧を取得
     $cHandler =& plzXoo::getHandler('category');
     $categories =& $cHandler->getObjects();
     $request->setAttribute('editform', $editform);
     $request->setAttribute('question', $obj);
     $request->setAttribute('categories', $categories);
     return VIEW_INPUT;
 }
Esempio n. 8
0
<?php

/**
@brief 簡易説明書(実験)
@version $Id$
*/
include_once "../../../mainfile.php";
include_once XOOPS_ROOT_PATH . "/include/cp_header.php";
require_once XOOPS_ROOT_PATH . "/modules/exFrame/frameloader.php";
xoops_cp_header();
include_once "head.php";
if (isset($xoopsConfig['language'])) {
    $file = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/howto.txt";
    if (file_exists($file)) {
        $ts =& MyTextSanitizer::getInstance();
        $text = exFrame::file_get_contents($file);
        print $ts->displayTarea($text);
    } else {
        print "Sorry, manual not exist.";
    }
} else {
    print "Sorry, manual not exist.";
}
xoops_cp_footer();