/**
  * hasPermission
  * 
  * @param	void
  * 
  * @return	bool
  **/
 public function hasPermission()
 {
     if ($this->mObject->isMember(Legacy_Utils::getUid(), Lenum_GroupRank::OWNER)) {
         return true;
     }
     return false;
 }
 /**
  * prepare
  * 
  * @param   XCube_PageNavigator  &$navi
  * @param   XoopsObjectGenericHandler  &$handler
  * 
  * @return  void
 **/
 public function prepare(/*** XCube_PageNavigator ***/ &$navi,/*** XoopsObjectGenericHandler ***/ &$handler)
 {
     $this->mFields = xoops_getmodulehandler('definitions', 'profile')->getFields4DataShow(Legacy_Utils::getUid());
 
     $this->_addSortKeys();
     parent::prepare($navi,$handler);
 }
 /**
  * preprare
  * 
  * @param   void
  * 
  * @return  bool
  **/
 public function prepare()
 {
     $this->mPermit = Legacy_Utils::getModuleHandler('permit', $this->mAsset->mDirname)->create();
     //for Permissions
     $this->mPermit->set('cat_id', 0);
     $this->_setupActionForm();
 }
 /**
  * executeViewSuccess
  * 
  * @param    XCube_RenderTarget    &$render
  * 
  * @return    void
  **/
 public function executeViewSuccess(&$render)
 {
     $render->setTemplateName($this->mAsset->mDirname . '_group_view.html');
     $render->setAttribute('object', $this->mObject);
     $render->setAttribute('image', $this->mObject->getImage());
     $render->setAttribute('dirname', $this->mAsset->mDirname);
     $clientList = array();
     $dataList = array('template_name' => array(), 'title' => array(), 'data' => array(), 'dirname' => array(), 'dataname' => array());
     if ($this->_checkPublicity()) {
         $clientList = Legroup_Utils::getClientList($this->mAsset->mDirname);
         foreach ($clientList as $client) {
             $dataList = $this->mObject->getClientData($dataList, $client);
         }
         foreach (array_keys($dataList['data']) as $key) {
             $check = false;
             XCube_DelegateUtils::call('Legacy_Group.' . $this->mAsset->mDirname . '.HasPermission', new XCube_Ref($check), $this->mAsset->mDirname, $this->mObject->get('group_id'), $dataList['dirname'][$key], $dataList['dataname'][$key], 'edit');
             $dataList['isEditor'][$key] = $check;
             unset($check);
         }
     }
     $render->setAttribute('clientList', $clientList);
     $render->setAttribute('clients', $dataList);
     $render->setAttribute('isEditor', $this->mObject->isMember(Legacy_Utils::getUid(), Lenum_GroupRank::OWNER));
     //breadcrumb
     $breadcrumbs = array();
     XCube_DelegateUtils::call('Module.' . $this->mAsset->mDirname . '.Global.Event.GetBreadcrumbs', new XCube_Ref($breadcrumbs), $this->mAsset->mDirname, $this->mObject);
     $render->setAttribute('xoops_breadcrumbs', $breadcrumbs);
 }
Example #5
0
 /**
  * @public
  */
 public function getFields4DataShow($uid = 0)
 {
     $uid = $uid > 0 ? $uid : Legacy_Utils::getUid();
     $lHandler =& xoops_getmodulehandler('groups_users_link', 'user');
     $criteria = new CriteriaCompo();
     $criteria->setSort('weight');
     $fieldArr = $this->getObjects($criteria);
     foreach (array_keys($fieldArr) as $keyF) {
         $flag = false;
         $accessArr = explode(',', $fieldArr[$keyF]->get('access'));
         if ($uid === 0) {
             //guest
             if (in_array(XOOPS_GROUP_ANONYMOUS, $accessArr)) {
                 $flag = true;
             }
         } else {
             foreach (array_keys($accessArr) as $keyA) {
                 if ($lHandler->isUserOfGroup($uid, $accessArr[$keyA])) {
                     $flag = true;
                 }
             }
         }
         if (!$flag) {
             unset($fieldArr[$keyF]);
         }
     }
     return $fieldArr;
 }
 /**
  * hasPermission
  * 
  * @param	void
  * 
  * @return	bool
  **/
 public function hasPermission()
 {
     $catId = $this->_getCatId();
     if ($catId > 0) {
         //is Manager ?
         $check = $this->mAccessController['main']->check($catId, Xupdatemaster_AbstractAccessController::MANAGE, 'item');
         if ($check == true) {
             return true;
         }
         //is new post and has post permission ?
         $check = $this->mAccessController['main']->check($catId, Xupdatemaster_AbstractAccessController::POST, 'item');
         if ($check == true && $this->mObject->isNew()) {
             return true;
         }
         //is old post and your post ?
         if ($check == true && !$this->mObject->isNew() && $this->mObject->get('uid') == Legacy_Utils::getUid() && $this->mObject->get('uid') > 0) {
             return true;
         }
     } else {
         $idList = array();
         $idList = $this->mAccessController['main']->getPermittedIdList(Xupdatemaster_AbstractAccessController::POST, $this->_getCatId());
         if (count($idList) > 0 || $this->mAccessController['main']->getAccessControllerType() == 'none') {
             return true;
         }
     }
     return false;
 }
 /**
  * prepare
  *
  * @param	void
  *
  * @return	bool
  **/
 public function prepare()
 {
     parent::prepare();
     $topic_id = (int) $this->mRoot->mContext->mRequest->getRequest('topic_id');
     $handler =& $this->mAsset->getObject('handler', 'Posts', false);
     //$handler = Legacy_Utils::getModuleHandler('posts', $this->mAsset->mDirname);
     $criteria = new criteriacompo();
     $criteria->add(new criteria('topic_id', $topic_id));
     $criteria->addSort('post_time', 'ASC');
     // TODO: other sorts
     $this->mPostsObj = $handler->getObjects($criteria);
     if (is_object($this->mObject)) {
         $this->forum_id = (int) $this->mObject->get('forum_id');
         $handler = Legacy_Utils::getModuleHandler('forums', $this->mAsset->mDirname);
         $this->mForumObj = $handler->get($this->forum_id);
         //adump($this->mForumObj);
         $this->ext_link_id = $this->mObject->get('topic_external_link_id');
         //adump($external_link_id);
         if ($this->ext_link_id > 0) {
             $mExtHandler =& $this->mAsset->getObject('handler', 'Topics', false);
             $criteria = new criteriacompo();
             $criteria->add(new criteria('topic_external_link_id', $this->ext_link_id));
             $this->mTopics_ExtObj = $mExtHandler->getObjects($criteria);
         }
         //adump($this->mTopics_ExtObj);
         return true;
     }
     return false;
 }
 function setupBlock()
 {
     $showFlag = 0;
     $mid = 0;
     if ($this->mController->mRoot->mContext->mModule != null) {
         $showFlag = preg_match("/index\\.php\$/i", xoops_getenv('PHP_SELF')) && $this->mController->mRoot->mContext->mXoopsConfig['startpage'] == $this->mController->mRoot->mContext->mXoopsModule->get('dirname');
         $mid = $this->mController->mRoot->mContext->mXoopsModule->get('mid');
     } else {
         //
         // If you does not have module_contoller, this request is to toppage or other pages of toppage.
         //
         // $mid = preg_match("/index\.php$/i", xoops_getenv('PHP_SELF')) ? -1 : 0;
         $pathArray = parse_url(!empty($_SERVER['PATH_INFO']) ? substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO'])) : $_SERVER['PHP_SELF']);
         $mid = preg_match("#(/index\\.php|/)\$#i", @$pathArray['path']) ? -1 : 0;
     }
     $blockHandler =& xoops_gethandler('block');
     $showCenterFlag = SHOW_CENTERBLOCK_LEFT | SHOW_CENTERBLOCK_CENTER | SHOW_CENTERBLOCK_RIGHT;
     $showRightFlag = SHOW_SIDEBLOCK_RIGHT;
     $showFlag = SHOW_SIDEBLOCK_LEFT | $showRightFlag | $showCenterFlag;
     $groups = is_object($this->mController->mRoot->mContext->mXoopsUser) ? $this->mController->mRoot->mContext->mXoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
     $blockObjects =& $blockHandler->getBlocks($groups, $mid, $showFlag);
     foreach ($blockObjects as $blockObject) {
         $block =& Legacy_Utils::createBlockProcedure($blockObject);
         if ($block->prepare() !== false) {
             $this->mController->_mBlockChain[] =& $block;
         }
         unset($block);
         unset($blockObject);
     }
 }
 /**
  * hasPermission
  * 
  * @param	void
  * 
  * @return	bool
  **/
 public function hasPermission()
 {
     if ($this->mObject->mLink->get('uid') != Legacy_Utils::getUid()) {
         return false;
     }
     return $this->mRoot->mContext->mUser->isInRole('Site.RegisteredUser') ? true : false;
 }
Example #10
0
 /**
  * executeViewInput
  * 
  * @param	XCube_RenderTarget	&$render
  * 
  * @return	void
  **/
 public function executeViewSuccess(&$render)
 {
     $render->setTemplateName('order_show.html');
     $render->setAttribute('dirname', $this->mAsset->mDirname);
     $render->setAttribute('definitions', Legacy_Utils::getModuleHandler('definition', $this->mAsset->mDirname)->getFields());
     $render->setAttribute('xcckConfigs', $this->mRoot->mContext->mModuleConfig);
 }
Example #11
0
 /**
  * loadGroup
  * 
  * @param	void
  * 
  * @return	void
  */
 public function loadGroup()
 {
     if ($this->_mGroupLoadedFlag == false) {
         $handler = Legacy_Utils::getModuleHandler('group', $this->getDirname());
         $this->mGroup =& $handler->get($this->get('group_id'));
         $this->_mGroupLoadedFlag = true;
     }
 }
 /**
  * getDataIdListByTags
  *
  * @param int[]		$list
  * @param string	$tDirname	//Legacy_Tag module's dirname
  * @param string[]	$tagArr
  * @param string	$dirname
  * @param string	$dataname
  */
 public static function getDataIdListByTags(&$list, $tDirname, $tagArr, $dirname, $dataname)
 {
     if (count($tagArr) === 0) {
         return;
     }
     $handler = Legacy_Utils::getModuleHandler('tag', $tDirname);
     $list = $handler->getDataIdListByTags($tagArr, $dirname, $dataname);
 }
Example #13
0
 /**
  * _setupObject
  *
  * @param	void
  *
  * @return	void
  **/
 protected function _setupObject()
 {
     $id = $this->_getId();
     $this->mObjectHandler =& $this->_getHandler();
     $revisionHandler = Legacy_Utils::getModuleHandler('revision', $this->mAsset->mDirname);
     $revision = $revisionHandler->getLatestRevision($id, Lenum_Status::REJECTED);
     $this->mObject = Xcck_Utils::setupPageByRevision($revision);
 }
Example #14
0
	/**
	 * @public
	 */
	function executeViewIndex(&$render)
	{
		$render->setTemplateName("profile_data_list.html");
		$render->setAttribute('objects', $this->mObjects);
		$render->setAttribute('pageNavi', $this->mFilter->mNavi);
		$handler = Legacy_Utils::getModuleHandler('definitions', 'profile');
		$render->setAttribute('definitions', $handler->getFields4DataShow(Legacy_Utils::getUid()));
	}
Example #15
0
 /**
  * executeViewInput
  * 
  * @param	XCube_RenderTarget	&$render
  * 
  * @return	void
  **/
 public function executeViewInput(&$render)
 {
     $render->setTemplateName($this->mAsset->mDirname . '_conv_edit.html');
     $render->setAttribute('actionForm', $this->mActionForm);
     $render->setAttribute('object', $this->mObject);
     $render->setAttribute('Pref_idTree', $this->mCategoryManager['pref_id']->getTree(Playermap_CategoryManager::VIEW));
     $myGroupIds = Legacy_Utils::getModuleHandler('member', $this->mAsset->mDirname)->getMyGroupIdList();
     $render->setAttribute('myGroups', Legacy_Utils::getModuleHandler('group', $this->mAsset->mDirname)->getGroupListByIds($myGroupIds));
 }
 /**
  * getImageObjects
  *
  * @param Legacy_AbstractImageObject[]	&$objects
  * @param string	$dirname
  * @param string	$dataname
  * @param int		$dataId
  * @param int		$num
  * @param int		$limit
  * @param int		$start
  *
  * @return	void
  */
 public static function getImageObjects(&$objects, $dirname, $dataname, $dataId = 0, $num = 0, $limit = 10, $start = 0)
 {
     XCube_Root::getSingleton()->mLanguageManager->loadModuleMessageCatalog(LEGACY_IMAGE_DIRNAME);
     $handler = Legacy_Utils::getModuleHandler('image', LEGACY_IMAGE_DIRNAME);
     $images = $handler->getImageObjects($dirname, $dataname, $dataId, $num, $limit, $start);
     foreach ($images as $image) {
         $objects[$image->getShow('num')] = $image;
     }
 }
Example #17
0
 function execute()
 {
     $root =& XCube_Root::getSingleton();
     // load message catalog of legacy for _AD_LEGACY_LANG_NO_SETTING, even if the current module is not Legacy.
     $root->mLanguageManager->loadModuleAdminMessageCatalog('legacy');
     //
     $root->mLanguageManager->loadModinfoMessageCatalog('legacy');
     $controller =& $root->mController;
     $user =& $root->mController->mRoot->mContext->mXoopsUser;
     $render =& $this->getRenderTarget();
     $render->setAttribute('legacy_module', 'legacy');
     $this->mCurrentModule =& $controller->mRoot->mContext->mXoopsModule;
     if ($this->mCurrentModule->get('dirname') == 'legacy') {
         if (xoops_getrequest('action') == "help") {
             $moduleHandler =& xoops_gethandler('module');
             $t_module =& $moduleHandler->getByDirname(xoops_gethandler('dirname'));
             if (is_object($t_module)) {
                 $this->mCurrentModule =& $t_module;
             }
         }
     }
     $db =& $controller->getDB();
     $mod = $db->prefix("modules");
     $perm = $db->prefix("group_permission");
     $groups = implode(",", $user->getGroups());
     //
     // Users who are belong to ADMIN GROUP have every permissions, so we have to prepare two kinds of SQL.
     //
     if ($root->mContext->mUser->isInRole('Site.Owner')) {
         $sql = "SELECT DISTINCT mid FROM {$mod} WHERE isactive=1 AND hasadmin=1 ORDER BY weight, mid";
     } else {
         $sql = "SELECT DISTINCT {$mod}.mid FROM {$mod},{$perm} " . "WHERE {$mod}.isactive=1 AND {$mod}.mid={$perm}.gperm_itemid AND {$perm}.gperm_name='module_admin' AND {$perm}.gperm_groupid IN ({$groups}) " . "AND {$mod}.hasadmin=1 " . "ORDER BY {$mod}.weight, {$mod}.mid";
     }
     $result = $db->query($sql);
     $handler =& xoops_gethandler('module');
     while ($row = $db->fetchArray($result)) {
         $xoopsModule =& $handler->get($row['mid']);
         $module =& Legacy_Utils::createModule($xoopsModule);
         $this->mModules[] =& $module;
         unset($module);
     }
     //
     $tpl = $db->prefix("tplfile");
     $tpl_modules = array();
     $sql = "SELECT DISTINCT tpl_module FROM {$tpl}";
     $result = $db->query($sql);
     while ($row = $db->fetchArray($result)) {
         $tpl_modules[] = $row['tpl_module'];
     }
     $render->setAttribute('tplmodules', $tpl_modules);
     //
     $render->setTemplateName('legacy_admin_block_sidemenu.html');
     $render->setAttribute('modules', $this->mModules);
     $render->setAttribute('currentModule', $this->mCurrentModule);
     $renderSystem =& $root->getRenderSystem($this->getRenderSystemName());
     $renderSystem->renderBlock($render);
 }
Example #18
0
 /**
  * @public
  */
 public function Profile_DataObject()
 {
     $handler = Legacy_Utils::getModuleHandler('definitions', 'profile');
     $this->mDef = $handler->getDefinitions(false);
     $this->initVar('uid', XOBJ_DTYPE_INT, '', false);
     foreach (array_keys($this->mDef) as $key) {
         $this->mDef[$key]->mFieldType->setInitVar($this, $this->mDef[$key]->getShow('field_name'), $this->mDef[$key]->getDefault());
     }
 }
Example #19
0
 /**
  *	@public
  */
 public function createBlogModule(&$module, &$log)
 {
     $handler = Legacy_Utils::getModuleHandler('definition', $dirname);
     $arr = self::_getFieldSetting();
     foreach ($arr as $field) {
         $obj = $handler->create();
         self::_setupObject($obj, $field);
         $handler->insert($obj, true);
     }
 }
 /**
  * getClientModules
  *
  * @param mixed[] &$list
  *
  * @return	void
  */
 public function getClientModules(&$list)
 {
     $dirnames = Legacy_Utils::getDirnameListByTrustDirname(basename(dirname(dirname(__FILE__))));
     foreach ($dirnames as $dirname) {
         $list[] = array('dirname' => $dirname, 'dataname' => 'rpg');
     }
     foreach ($dirnames as $dirname) {
         $list[] = array('dirname' => $dirname, 'dataname' => 'book');
     }
 }
Example #21
0
 /**
  * hasPermission
  * 
  * @param    void
  * 
  * @return    bool
  **/
 public function hasPermission()
 {
     if (!$this->mRoot->mContext->mUser->isInRole('Site.RegisteredUser')) {
         return false;
     }
     if (!$this->mObject->isNew()) {
         return $this->mObject->isMember(Legacy_Utils::getUid(), Lenum_GroupRank::OWNER) ? true : false;
     } else {
         return true;
     }
 }
function smarty_function_xoops_cooluri($params, &$smarty)
{
	if(! $params['dirname']) return;
	$dirname = $params['dirname'];
	$dataname = isset($params['dataname']) ? $params['dataname'] : null;
	$dataId = isset($params['data_id']) ? $params['data_id'] : 0;
	$action = isset($params['action']) ? $params['action'] : null;
	$query = isset($params['query']) ? $params['query'] : null;

	echo htmlspecialchars(Legacy_Utils::renderUri($dirname, $dataname, $dataId, $action, $query), ENT_QUOTES);
}
 function renderCell4BlockOptions($block_data)
 {
     if ($this->target_dirname && substr($this->target_dirname, 0, 1) != '_') {
         $langman =& D3LanguageManager::getInstance();
         $langman->read('admin.php', $this->target_dirname);
     }
     $bid = intval($block_data['bid']);
     $block = new XoopsBlock($bid);
     $legacy_block =& Legacy_Utils::createBlockProcedure($block);
     return $legacy_block->getOptionForm();
 }
Example #24
0
 public function updateStatus($pageId, $status)
 {
     $obj = $this->getLatestRevision($pageId);
     if (!$obj instanceof Xcck_RevisionObject) {
         return false;
     }
     $obj->set('status', $status);
     $handler = Legacy_Utils::getModuleHandler('page', $this->getDirname());
     $page = Xcck_Utils::setupPageByRevision($obj);
     return $handler->insert($page, true);
 }
 /**
  * getDefaultView
  * 
  * @param    void
  * 
  * @return    Enum
  **/
 public function getDefaultView()
 {
     $this->mFilter =& $this->_getFilterForm();
     $this->mFilter->fetch();
     $mHandler = Legacy_Utils::getModuleHandler('member', $this->mAsset->mDirname);
     $ids = $mHandler->getMyGroupIdList();
     $handler =& $this->_getHandler();
     $cri = $this->mFilter->getCriteria();
     $cri->add(new Criteria('group_id', $ids, 'IN'));
     $this->mObjects =& $handler->getObjects($cri);
     return LEGROUP_FRAME_VIEW_INDEX;
 }
 /**
  * getNormalUri
  *
  * @param string	$uri
  * @param string	$dirname
  * @param string	$dataname
  * @param int		$data_id
  * @param string	$action
  * @param string	$query
  *
  * @return	void
  */
 public function getNormalUri(&$uri, $dirname, $dataname = null, $data_id = 0, $action = null, $query = null)
 {
     $sUri = '/%s/index.php?action=%s%s';
     $lUri = '/%s/index.php?action=%s%s&%s=%d';
     switch ($dataname) {
         case null:
         case 'player':
             $key = 'uid';
             break;
         case 'circle':
             $key = 'group_id';
             break;
         default:
             $key = $dataname . '_id';
             break;
     }
     $table = isset($dataname) ? $dataname : 'player';
     if (isset($dataname)) {
         if ($data_id > 0) {
             if (isset($action)) {
                 $uri = sprintf($lUri, $dirname, ucfirst($dataname), ucfirst($action), $key, $data_id);
             } else {
                 $uri = sprintf($lUri, $dirname, ucfirst($dataname), 'View', $key, $data_id);
             }
         } else {
             if (isset($action)) {
                 $uri = sprintf($sUri, $dirname, ucfirst($dataname), ucfirst($action));
             } else {
                 $uri = sprintf($sUri, $dirname, ucfirst($dataname), 'List');
             }
         }
         $uri = isset($query) ? $uri . '&' . $query : $uri;
     } else {
         if ($data_id > 0) {
             if (isset($action)) {
                 die;
             } else {
                 $handler = Legacy_Utils::getModuleHandler($table, $dirname);
                 $key = $handler->mPrimary;
                 $uri = sprintf($lUri, $dirname, ucfirst($table), 'View', $key, $data_id);
             }
             $uri = isset($query) ? $uri . '&' . $query : $uri;
         } else {
             if (isset($action)) {
                 die;
             } else {
                 $uri = sprintf('/%s/', $dirname);
                 $uri = isset($query) ? $uri . 'index.php?' . $query : $uri;
             }
         }
     }
 }
Example #27
0
 /**
  * _getId
  * 
  * @param	void
  * 
  * @return	int
  **/
 protected function _getId()
 {
     $req = $this->mRoot->mContext->mRequest;
     $dataId = $req->getRequest(_REQUESTED_DATA_ID);
     $id = isset($dataId) ? intval($dataId) : intval($req->getRequest($this->_getHandler()->mPrimary));
     if (!isset($id)) {
         $objs = $this->_getHandler()->getObjects(new Criteria('uid', Legacy_Utils::getUid()));
         if (count($objs) > 0) {
             return $objs[0]->get('link_id');
         }
     }
     return $id;
 }
Example #28
0
 /**
  * getClientList
  *
  * @param mixed[]   &$list
  *  @list[]['dirname']
  *  @list[]['dataname']
  *
  * @return  void
  */
 public static function getClientList(&$list)
 {
     $dirnames = Legacy_Utils::getDirnameListByTrustDirname(basename(dirname(dirname(dirname(__FILE__)))));
     //don't call this method multiple times when site owner duplicate this module.
     static $isCalled = false;
     if ($isCalled === true) {
         return;
     }
     $list[] = array('dirname' => $dir, 'dataname' => 'forums');
     $list[] = array('dirname' => $dir, 'dataname' => 'topics');
     $list[] = array('dirname' => $dir, 'dataname' => 'posts');
     $isCalled = true;
 }
 /**
  * hasPermission
  * 
  * @param    void
  * 
  * @return    bool
  **/
 public function hasPermission()
 {
     if (!$this->mRoot->mContext->mUser->isInRole('Site.RegisteredUser')) {
         return false;
     }
     if ($this->mObject->mGroup->isMember(Legacy_Utils::getUid(), Lenum_GroupRank::STAFF)) {
         return true;
     }
     if ($this->mObject->get('uid') == Legacy_Utils::getUid()) {
         return true;
     }
     return false;
 }
 /**
  * prepare
  * 
  * @param	void
  * 
  * @return	bool
  **/
 public function prepare()
 {
     parent::prepare();
     $topic_id = (int) $this->mRoot->mContext->mRequest->getRequest('topic_id');
     $handler = Legacy_Utils::getModuleHandler('topics', $this->mAsset->mDirname);
     $this->mTopicObj = $handler->getObjects($topic_id);
     //adump($this->mTopicObj);
     $forum_id = $this->mTopicObj->getShow('forum_id');
     $handler = Legacy_Utils::getModuleHandler('forums', $this->mAsset->mDirname);
     $this->mForumObj = $handler->get($forum_id);
     //adump($this->mForumObj);
     // TODO: CATEGORY AND FORUM PERMISSION
     return true;
 }