function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $sess_handler =& XsnsSessionHandler::getInstance(); $commu_temp = $sess_handler->getVar('community'); $sess_handler->clearVars(); $ts =& XsnsTextSanitizer::getInstance(); $default = array( 'name' => isset($commu_temp['name']) ? $ts->makeTboxData4PreviewInForm($commu_temp['name']) : '', 'info' => isset($commu_temp['info']) ? $ts->makeTareaData4PreviewInForm($commu_temp['info']) : '', 'cat_id' => isset($commu_temp['cat_id']) ? intval($commu_temp['cat_id']) : 0, 'public_id' => isset($commu_temp['public_id']) ? intval($commu_temp['public_id']) : 1, ); $image_handler =& XsnsImageHandler::getInstance(); $image_handler->deleteImageTemp(); $category_handler =& XsnsCategoryHandler::getInstance(); $category_selector = $category_handler->getSelectorHtml('category', $default['cat_id'], _MD_XSNS_SELBOX_DEFAULT); $public_id = $default['public_id']; $default['public'.$public_id] = ' checked'; $this->context->setAttribute('category_selector', $category_selector); $this->context->setAttribute('default', $default); }
function dispatch() { if($this->isGuest() || !$this->validateToken('COMMUNITY_EDIT')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $cid = $this->getIntRequest('cid'); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $perm = XSNS_AUTH_XOOPS_ADMIN | XSNS_AUTH_ADMIN; $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority($perm)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // 入力データのチェック $name = $this->getTextRequest('name'); $info = $this->getTextRequest('info'); $cat_id = $this->getIntRequest('category'); $public_id = $this->getIntRequest('public'); if(!$commu_handler->checkParams($cid, $name, $info, $cat_id, $public_id)){ $errors = $commu_handler->getErrors(); if(count($errors) > 0){ $msg = ""; foreach($errors as $err){ $msg .= $err."<br>"; } redirect_header(XSNS_URL_COMMU.'?'.XSNS_ACTION_ARG.'=edit&cid='.$cid, 3, $msg); } } $old_name = $community->getVar('name'); // コミュニティ情報の更新 $community->setVar('name', $name); $community->setVar('info', $info); $community->setVar('c_commu_category_id', $cat_id); $community->setVar('public_flag', $public_id); $category_handler =& XsnsCategoryHandler::getInstance(); if(($cid = $commu_handler->insert($community)) && $category_handler->updateSelector()){ // 画像のアップロード $image_handler =& XsnsImageHandler::getInstance(); $image_handler->setFormLimit(1); if($image_handler->uploadImageTemp('image')){ $image_handler->uploadImage('c', 1, $cid); } redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, sprintf(_MD_XSNS_INDEX_EDIT_OK, $old_name)); } redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, _MD_XSNS_INDEX_EDIT_NG); }
function dispatch() { global $xoopsUser; if($this->isGuest() || !$this->validateToken('COMMUNITY_ADD')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $sess_handler =& XsnsSessionHandler::getInstance(); $commu = $sess_handler->getVar('community'); $commu_handler =& XsnsCommunityHandler::getInstance(); if(!$commu_handler->checkParams(0, $commu['name'], $commu['info'], $commu['cat_id'], $commu['public_id'])){ redirect_header(XOOPS_URL, 2, _NOPERM); } $new_community =& $commu_handler->create(); $new_community->setVars(array( 'name' => $commu['name'], 'uid_admin' => $own_uid, 'uid_sub_admin' => 0, 'info' => $commu['info'], 'c_commu_category_id' => $commu['cat_id'], 'r_datetime' => date('Y-m-d H:i:s'), 'r_date' => date('Y-m-d'), 'public_flag' => $commu['public_id'], )); $category_handler =& XsnsCategoryHandler::getInstance(); if(($cid = $commu_handler->insert($new_community)) && $category_handler->updateSelector()){ // 作成したコミュニティに対して画像を追加 $image_handler =& XsnsImageHandler::getInstance(); $image_handler->setFormLimit(1); $image_handler->uploadImage('c', 1, $cid); // コミュニティの作成者をメンバーに追加 $c_member_handler =& XsnsMemberHandler::getInstance(); $new_member =& $c_member_handler->create(); $new_member->setVars(array( 'uid' => $own_uid, 'c_commu_id' => $cid, 'r_datetime' => date('Y-m-d H:i:s'), )); if($c_member_handler->insert($new_member)){ $sess_handler->clearVars(); redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, _MD_XSNS_INDEX_ADD_OK); } } redirect_header(XSNS_URL_COMMU.'?'.XSNS_ACTION_ARG.'=add', 2, _MD_XSNS_INDEX_ADD_NG); }
function dispatch() { $cat_handler =& XsnsCategoryHandler::getInstance(); $cat_parent_handler =& XsnsCategoryParentHandler::getInstance(); $msg_ok = _AM_XSNS_CATEGORY_DEL_OK; $msg_ng = _AM_XSNS_CATEGORY_DEL_NG; $mode = $this->getTextRequest('mode'); $id = ($mode=='parent') ? $this->getIntRequest('pid') : $this->getIntRequest('id'); $title = $this->getTextRequest('title'.$id); if(empty($title)){ redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_NAME_NG); } $order = $this->getIntRequest('order'.$id); if($order < 0){ redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_ORDER_NG); } if($mode=='parent'){ $cat_parent =& $cat_parent_handler->get($id); if(!is_object($cat_parent)){ redirect_header(XSNS_URL_ADMIN, 2, _NOPERM); } // 中カテゴリの削除 $criteria = new Criteria('c_commu_category_parent_id', $id); $cat_obj_list =& $cat_handler->getObjects($criteria); foreach($cat_obj_list as $cat_obj){ // 小カテゴリの削除 $cat_handler->delete($cat_obj); } $ret = $cat_parent_handler->delete($cat_parent); } else{ $cat =& $cat_handler->get($id); if(!is_object($cat)){ redirect_header(XSNS_URL_ADMIN, 2, _NOPERM); } // 小カテゴリの削除 $ret = $cat_handler->delete($cat); } if($ret && $cat_handler->updateSelector()){ redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, $msg_ok); } redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, $msg_ng); }
function dispatch() { if($this->isGuest() || !$this->validateToken('COMMUNITY_DELETE')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $cid = $this->getIntRequest('cid'); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $perm = XSNS_AUTH_XOOPS_ADMIN | XSNS_AUTH_ADMIN; $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority($perm) || $community->getTopicCount() > 0){ redirect_header(XOOPS_URL, 2, _NOPERM); } $old_name = $community->getVar('name'); if($commu_handler->delete($community)){ $category_handler =& XsnsCategoryHandler::getInstance(); if($category_handler->updateSelector()){ $criteria = new Criteria('c_commu_id', $cid); // 所属メンバーデータの削除 $c_member_handler =& XsnsMemberHandler::getInstance(); $c_member_handler->deleteObjects($criteria); // 依頼データの削除 $confirm_handler =& XsnsConfirmHandler::getInstance(); $confirm_handler->deleteObjects($criteria); // アクセスログの削除 $access_log_handler =& XsnsAccessLogHandler::getInstance(); $access_log_handler->deleteObjects($criteria); // 画像の削除 $image_criteria = new CriteriaCompo(new Criteria('target', 1)); $image_criteria->add(new Criteria('target_id', $cid)); $image_handler =& XsnsImageHandler::getInstance(); $image_handler->deleteObjects($image_criteria); redirect_header(XSNS_URL_COMMU, 2, sprintf(_MD_XSNS_INDEX_DEL_OK, $old_name)); } } redirect_header(XSNS_URL_COMMU, 2, _MD_XSNS_INDEX_DEL_NG); }
function dispatch() { $cat_handler =& XsnsCategoryHandler::getInstance(); $cat_parent_handler =& XsnsCategoryParentHandler::getInstance(); $title = $this->getTextRequest('title'); if(empty($title)){ redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_NAME_NG); } $order = $this->getIntRequest('order'); if($order < 0){ redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_ORDER_NG); } $mode = $this->getTextRequest('mode'); if($mode=='parent'){ // 中カテゴリの作成 $cat_parent =& $cat_parent_handler->create(); $cat_parent->setVars(array( 'name' => $title, 'sort_order' => $order, 'selector' => '<span></span>' // NOT NULL )); $ret = $cat_parent_handler->insert($cat_parent); } else{ $pid = $this->getIntRequest('pid'); if($pid < 0){ redirect_header(XSNS_URL_ADMIN, 2, _AM_XSNS_CATEGORY_ADD_NG); } // 小カテゴリの作成 $cat =& $cat_handler->create(); $cat->setVars(array( 'name' => $title, 'sort_order' => $order, 'c_commu_category_parent_id' => $pid, )); $ret = $cat_handler->insert($cat); } if($ret && $cat_handler->updateSelector()){ redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_ADD_OK); } redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_ADD_NG); }
function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $token_handler = new XoopsMultiTokenHandler(); $token = new XoopsFormToken($token_handler->create('COMMUNITY_EDIT')); // Hidden $token_tag = '<input type="hidden" name="'.$token->_name.'" value="'.$token->_value.'">'; $this->context->setAttribute('token_tag', $token_tag); $cid = $this->getIntRequest('cid', XSNS_REQUEST_GET); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $perm = XSNS_AUTH_XOOPS_ADMIN | XSNS_AUTH_ADMIN; $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority($perm)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_data = array( 'id' => $cid, 'name' => $community->getVar('name', 'e'), 'info' => $community->getVar('info', 'e'), 'del_enabled' => ($community->getTopicCount()==0)? true : false, 'image' => $community->getImage(XSNS_IMAGE_SIZE_S), ); $category_handler =& XsnsCategoryHandler::getInstance(); $category_selector = $category_handler->getSelectorHtml('category', $community->getVar('c_commu_category_id')); $this->context->setAttribute('commu', $commu_data); $this->context->setAttribute('public_flag', $community->getVar('public_flag')); $this->context->setAttribute('category_selector', $category_selector); }
function dispatch() { $err = $this->checkPermission(); if(!is_array($err) || count($err) > 0){ $this->context->setAttribute('perm_error', $err); return "default"; } $category_p = $category = array(); $criteria = new CriteriaCompo(); $criteria->setSort('sort_order'); $category_p_handler =& XsnsCategoryParentHandler::getInstance(); $category_p_obj_list =& $category_p_handler->getObjects($criteria); foreach($category_p_obj_list as $category_p_obj){ if(is_object($category_p_obj)){ $category_p[] = $category_p_obj->getVarsArray(); } } unset($criteria); $criteria = new CriteriaCompo(); $criteria->setSort('c_commu_category_parent_id,sort_order'); $category_handler =& XsnsCategoryHandler::getInstance(); $category_obj_list =& $category_handler->getObjects($criteria); foreach($category_obj_list as $category_obj){ if(is_object($category_obj)){ $pid = $category_obj->getVar('c_commu_category_parent_id'); $category[$pid][] = $category_obj->getVarsArray(); } } $this->context->setAttribute('category_p', $category_p); $this->context->setAttribute('category', $category); }
function &getList($criteria = NULL) { $limit = $start = 0; $ret = array(); $sql = "SELECT cc.*,COUNT(ccm.uid) AS member_count FROM ". $this->prefix($this->table_name)." cc". " LEFT JOIN ".$this->prefix('c_commu_member')." ccm". " ON cc.c_commu_id=ccm.c_commu_id"; $sql_order = ""; if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql_where = $criteria->render(); if(!empty($sql_where)){ $sql .= " WHERE ".$sql_where; } $limit = $criteria->getLimit(); $start = $criteria->getStart(); if ($criteria->getSort() != '') { $sql_order .= " ORDER BY ".$criteria->getSort()." ".$criteria->getOrder(); } } $sql .= " GROUP BY ccm.c_commu_id". $sql_order; $result = $this->db->query($sql, $limit, $start); if (!$result) { return $ret; } $obj_list = array(); $cids = array(); $cat_ids = array(); $image_handler =& XsnsImageHandler::getInstance(); $image_handler->setFormLimit(1); $category_handler =& XsnsCategoryHandler::getInstance(); while ($row = $this->db->fetchArray($result)) { $obj = new $this->obj_class(); $obj->assignVars($row); $cid = $obj->getVar('c_commu_id'); $obj_list[$cid] = $obj; $cids[] = $cid; } $image_list =& $image_handler->getListByIds(1, $cids, XSNS_IMAGE_SIZE_S); $category_list =& $category_handler->getNameList(); foreach($obj_list as $cid => $obj){ if(!is_object($obj)){ continue; } $cat_id = $obj->getVar('c_commu_category_id'); $ret[] = array( 'c_commu_id' => $cid, 'name' => $obj->getVar('name'), // 'info' => $obj->getVar('info', 'x'), // stripXoopsCode 'info' => strip_tags($obj->getVar('info')), // naao 'category_name' => isset($category_list[$cat_id]) ? $category_list[$cat_id] : "", 'member_count' => $obj->getMemberCount(), // != $row['member_count'] 'page_url' => XSNS_BASE_URL.'/?cid='.$cid, 'image' => isset($image_list[$cid][0]) ? $image_list[$cid][0] : array(), ); } return $ret; }
function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $token_handler = new XoopsMultiTokenHandler(); $token = new XoopsFormToken($token_handler->create('COMMUNITY_ADD')); // Hidden $token_tag = '<input type="hidden" name="'.$token->_name.'" value="'.$token->_value.'">'; $this->context->setAttribute('token_tag', $token_tag); $name = $this->getTextRequest('name'); $cat_id = $this->getIntRequest('category'); $public_id = $this->getIntRequest('public'); $info = $this->getTextRequest('info'); $errors = array(); $commu_handler =& XsnsCommunityHandler::getInstance(); if(!$commu_handler->checkParams(0, $name, $info, $cat_id, $public_id)){ $errors = $commu_handler->getErrors(); } if($public_id < 1 || $public_id > 3){ $public_id = 1; } $new_community =& $commu_handler->create(); $new_community->setVars(array( 'name' => $name, 'info' => $info, )); $sess_handler =& XsnsSessionHandler::getInstance(); $commu_vars_temp = array( 'name' => $name, 'cat_id' => $cat_id, 'public_id' => $public_id, 'info' => $info, ); $sess_handler->setVar('community', $commu_vars_temp); $category_handler =& XsnsCategoryHandler::getInstance(); // check input : NG if(count($errors) > 0){ $default = array( 'name' => $new_community->getVar('name', 'f'), 'info' => $new_community->getVar('info', 'f'), 'public'.$public_id => ' checked', ); $category_selector = $category_handler->getSelectorHtml('category', $cat_id, _MD_XSNS_SELBOX_DEFAULT); $this->context->setAttribute('category_selector', $category_selector); $this->context->setAttribute('default', $default); $this->context->setAttribute('errors', $errors); return "add"; // �� index/addView.php } // check input : OK $image_handler =& XsnsImageHandler::getInstance(); $image_handler->setFormLimit(1); $public_desc = array( '1' => _MD_XSNS_INDEX_PUBLIC_L1, '2' => _MD_XSNS_INDEX_PUBLIC_L2, '3' => _MD_XSNS_INDEX_PUBLIC_L3, ); $category =& $category_handler->get($cat_id); $commu_vars = array( 'name' => $new_community->getVar('name', 'p'), 'category_id' => $cat_id, 'category' => $category->getVar('name', 'p'), 'public_id' => $public_id, 'public' => $public_desc[$public_id], 'info' => $new_community->getVar('info', 'p'), 'image' => $image_handler->uploadImageTemp('image'), ); $this->context->setAttribute('commu', $commu_vars); }
function dispatch() { $limit = 10; $sess_handler =& XsnsSessionHandler::getInstance(); $sess_handler->clearVars(); $cid = $this->getIntRequest('cid', XSNS_REQUEST_GET); if($cid > 0){ $commu_detail = $this->getCommunityDetail($cid); $this->context->setAttribute('commu', $commu_detail); return "detail"; } $start = $this->getIntRequest('s', XSNS_REQUEST_GET); if(!isset($start) || $start<0){ $start = 0; } $cat_id = $this->getIntRequest('cat_id', XSNS_REQUEST_GET); $keyword = $this->getTextRequest('keyword', XSNS_REQUEST_GET); $sort_method = $this->getTextRequest('sort', XSNS_REQUEST_GET); $commu_handler =& XsnsCommunityHandler::getInstance(); $criteria = new CriteriaCompo(); $criteria->setLimit($limit); $criteria->setStart($start); if($cat_id > 0){ $criteria->add(new Criteria('c_commu_category_id', $cat_id)); } if($keyword != ''){ $kw_criteria = new CriteriaCompo(new Criteria('name', '%'.$keyword.'%', 'LIKE')); $kw_criteria->add(new Criteria('info', '%'.$keyword.'%', 'LIKE'), 'OR'); $criteria->add($kw_criteria); } switch($sort_method){ case 'date': default: $criteria->setSort('cc.r_datetime'); $criteria->setOrder('DESC'); break; case 'member': $criteria->setSort('member_count'); $criteria->setOrder('DESC'); break; case 'pop': $criteria->setSort('cc.popularity'); $criteria->setOrder('DESC'); break; case 'up': $criteria->setSort('cc.update_freq'); $criteria->setOrder('DESC'); break; } $commu_list =& $commu_handler->getList($criteria); $commu_total = $commu_handler->getCount($criteria); $base_url = XSNS_URL_COMMU.'?'; if($cat_id > 0){ $base_url .= "&cat_id=".$cat_id; } if($keyword != ''){ $base_url .= "&keyword=".rawurlencode($keyword); } if($sort_method=='member' || $sort_method=='date' || $sort_method=='pop' || $sort_method=='up'){ $base_url .= '&sort='.$sort_method; } $category_handler =& XsnsCategoryHandler::getInstance(); $category_parent_handler =& XsnsCategoryParentHandler::getInstance(); $category_selector = $category_handler->getSelectorHtml('cat_id', 0, _MD_XSNS_INDEX_CATEGORY_NO); $category_list =& $category_parent_handler->getList(); $pager = $this->getPageSelector($base_url, $start, $limit, count($commu_list), $commu_total); if(count($commu_list)==0){ $pager['description'] = _MD_XSNS_INDEX_COMMU_COUNT0; } $keyword_option = empty($keyword)? '' : '&keyword='.rawurlencode($keyword); $cat_id_option = empty($cat_id)? '' : '&cat_id='.$cat_id; $url = array( 'sort_member' => XSNS_URL_COMMU.'?sort=member'. $keyword_option. $cat_id_option, 'sort_date' => XSNS_URL_COMMU.'?sort=date'. $keyword_option. $cat_id_option, 'sort_pop' => XSNS_URL_COMMU.'?sort=pop'. $keyword_option. $cat_id_option, 'sort_up' => XSNS_URL_COMMU.'?sort=up'. $keyword_option. $cat_id_option, ); $this->context->setAttribute('is_guest', $this->isGuest()); $this->context->setAttribute('keyword', $keyword); $this->context->setAttribute('url', $url); $this->context->setAttribute('category_selector', $category_selector); $this->context->setAttribute('category_list', $category_list); $this->context->setAttribute('pager', $pager); $this->context->setAttribute('commu_list', $commu_list); }