/**
  * hasPermission
  * 
  * @param	void
  * 
  * @return	bool
  **/
 public function hasPermission()
 {
     if ($this->mObject->isMember(Legacy_Utils::getUid(), Lenum_GroupRank::OWNER)) {
         return true;
     }
     return false;
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
 /**
  * hasPermission
  * 
  * @param    void
  * 
  * @return    bool
  **/
 public function hasPermission()
 {
     if ($this->mObjectHandler->isMember($this->mObject->get('group_id'), Legacy_Utils::getUid(), Lenum_GroupRank::STAFF)) {
         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);
 }
 /**
  * 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 #7
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;
 }
	/**
	 * @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()));
	}
 /**
  * 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;
     }
 }
Example #10
0
 /**
  * hasPermission
  * 
  * @param   void
  * 
  * @return  bool
  **/
 public function hasPermission()
 {
     if ($this->mObject->get('uid') == Legacy_Utils::getUid()) {
         return true;
     }
     if ($this->mObject->get('status') == Lenum_Status::PUBLISHED && $this->mObject->isOpen() === true) {
         $check = $this->mCategoryManager->check($this->_getCatId(), 'view', 'page');
     } else {
         $check = $this->mCategoryManager->check($this->_getCatId(), 'review', 'page');
     }
     return $check;
 }
 /**
  * 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;
 }
Example #12
0
 /**
  * getMyRating
  * 
  * @param	void
  * 
  * @return	int
  */
 public function getMyRating()
 {
     $uid = Legacy_Utils::getUid();
     if ($uid == 0) {
         return 0;
     }
     $handler = Legacy_Utils::getModuleHandler('favrpg', PLAYERMAP_DIRNAME);
     $cri = new CriteriaCompo();
     $cri->add(new Criteria('rpg_id', $this->get('rpg_id')));
     $cri->add(new Criteria('uid', $uid));
     $objs = $handler->getObjects($cri);
     return count($objs) > 0 ? array_shift($objs)->getShow('rating') : 0;
 }
Example #13
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;
 }
 /**
  * prepare
  * 
  * @param	void
  * 
  * @return	bool
  **/
 public function prepare()
 {
     $this->mObjectHandler =& $this->_getHandler();
     //in this action, _getId means get rpg_id
     $uid = Legacy_Utils::getUid();
     $cri = new CriteriaCompo();
     $cri->add(new Criteria('conne_uid', $this->_getTargetId()));
     $cri->add(new Criteria('uid', $uid));
     $objs = $this->mObjectHandler->getObjects($cri);
     $this->mObject = count($objs) > 0 ? array_shift($objs) : $this->mObjectHandler->create();
     if ($this->mObject->isNew()) {
         $this->mObject->set('uid', $uid);
         $this->mObject->set('conne_uid', $this->_getTargetId());
     }
     return true;
 }
Example #15
0
 /**
  * getPermittedIdList
  * 
  * @param   string  $dirname
  * @param   string  $action
  * @param   int     $categeoryId
  * 
  * @return  XoopsObjectHandler
  **/
 public static function getPermittedIdList($dirname, $action = null, $categoryId = 0)
 {
     $action = isset($action) ? $action : Af_dmm_AuthType::VIEW;
     $accessController = self::getAccessControllerModule($dirname);
     if (!is_object($accessController)) {
         return;
     }
     $role = $accessController->get('role');
     $idList = array();
     if ($role == 'cat') {
         $delegateName = 'Legacy_Category.' . $accessController->dirname() . '.GetPermittedIdList';
         XCube_DelegateUtils::call($delegateName, new XCube_Ref($idList), $accessController->dirname(), self::getActor($dirname, Af_dmm_AuthType::VIEW), Legacy_Utils::getUid(), $categoryId);
     } elseif ($role == 'group') {
         $delegateName = 'Legacy_Group.' . $accessController->dirname() . '.GetGroupIdListByAction';
         XCube_DelegateUtils::call($delegateName, new XCube_Ref($idList), $accessController->dirname(), $dirname, 'page', Af_dmm_AuthType::VIEW);
     } else {
         //has user group permission ?
         ///TODO
     }
     return $idList;
 }
Example #16
0
 /**
  * hasPermission
  *
  * @param   void
  *
  * @return  bool
  **/
 public function hasPermission()
 {
     $catId = $this->_getCatId();
     $uid = Legacy_Utils::getUid();
     //is Manager ?
     if ($this->mCategoryManager->check($catId, Xcck_AuthType::MANAGE, 'page') == true) {
         return true;
     }
     //if poster himself ?
     if ($this->mObject->get('uid') == $uid) {
         return true;
     }
     //if subtable and parent table's poster ?
     if ($this->_isSubtable() && $this->mRoot->mContext->mModuleConfig['subtable_parent_auth'] === 'parent_is_manager') {
         $this->mObject->loadMaintable();
         if ($this->mObject->mMaintable->get('uid') == $uid) {
             return true;
         }
     }
     return false;
 }
function smarty_function_legacy_profile($params, &$smarty)
{
    $uid = isset($params['uid']) ? intval($params['uid']) : Legacy_Utils::getUid();
    if ($uid === 0) {
        return;
    }
    $profileActionForm = isset($params['actionForm']) ? $params['actionForm'] : null;
    $action = isset($params['action']) ? $params['action'] : 'view';
    $template = isset($params['template']) ? $params['template'] : 'profile_inc_data_view.html';
    $defArr = null;
    XCube_DelegateUtils::call('Legacy_Profile.GetDefinition', new XCube_Ref($defArr), $action);
    $profile = null;
    XCube_DelegateUtils::call('Legacy_Profile.GetProfile', new XCube_Ref($profile), $uid);
    //render template
    $render = new XCube_RenderTarget();
    $render->setTemplateName($template);
    $render->setAttribute('legacy_buffertype', XCUBE_RENDER_TARGET_TYPE_MAIN);
    $render->setAttribute('profileForm', $profileActionForm);
    $render->setAttribute('profile', $profile);
    $render->setAttribute('defArr', $defArr);
    XCube_Root::getSingleton()->getRenderSystem('Legacy_RenderSystem')->render($render);
    echo $render->getResult();
}
 /**
  * getChildren		Legacy_Category.GetChildren
  * get the child category objects. Be careful that you can get only children objects, excluded the given category itself.
  *
  * @param Legacy_AbstractCategoryObject[] &$children
  * @param string	$catDir	category module's directory name
  * @param int		$catId	the parent's category id
  * @param string	$authType	ex) viewer, editor, manager
  * @param string	$module	 module confinement
  *
  * @return	void
  */
 public static function getChildren(&$children, $catDir, $catId, $authType, $module = null)
 {
     $handler = Legacy_Utils::getModuleHandler('cat', $catDir);
     $cat = $handler->get($catId);
     if ($cat) {
         $cat->loadChildren($module);
         foreach (array_keys($cat->mChildren) as $key) {
             $children['catObj'][$key] = $cat->mChildren[$key];
             if ($authType) {
                 if ($cat->mChildren[$key]->checkPermitByUserId($authType, Legacy_Utils::getUid() == 'true')) {
                     $children['permit'][$key] = 1;
                 } else {
                     $children['permit'][$key] = 0;
                 }
             } else {
                 $children['permit'][$key] = 1;
             }
         }
     }
 }
Example #19
0
 /**
  * getMyRpg
  * 
  * @param	int		$fNum
  * @param	int		$lNum
  * 
  * @return	Trpg_RpgObject[]
  **/
 public static function getMyRpg($fNum = 5, $lNum = 5)
 {
     $uid = Legacy_Utils::getUid();
     $handler = Legacy_Utils::getModuleHandler('favrpg', PLAYERMAP_DIRNAME);
     $cri = new CriteriaCompo();
     $cri->add(new Criteria('uid', $uid));
     $cri->add(new Criteria('rating', Pmenum_Rating::RATE3, '>='));
     $cri->setSort('rating', 'DESC');
     $favrpg = $handler->getObjects($cri, $fNum, 0);
     $rpgIds = array();
     foreach ($favrpg as $objF) {
         $rpgIds[] = $objF->get('rpg_id');
     }
     $handler = Legacy_Utils::getModuleHandler('entry', PLAYERMAP_DIRNAME);
     $entry = $handler->getObjects(new Criteria('uid', $uid));
     $logIds = array();
     foreach ($entry as $objE) {
         $logIds[$objE->get('log_id')]++;
     }
     arsort($logIds);
     $i = 0;
     $handler = Legacy_Utils::getModuleHandler('log', PLAYERMAP_DIRNAME);
     $log = $handler->getObjects(new Criteria('log_id', $logIds, 'IN'));
     foreach ($log as $objL) {
         if ($i <= $lNum && !in_array($objL->get('rpg_id'), $rpgIds)) {
             $rpgIds[] = $objL->get('rpg_id');
             $i++;
         }
     }
     $handler = Legacy_Utils::getModuleHandler('rpg', TRPG_DIRNAME);
     return $handler->getObjects(new Criteria('rpg_id', $rpgIds, 'IN'));
 }
 /**
  * isEditor
  * 
  * @param	int		$categoryId
  * @param	int		$posterUid
  * 
  * @return	bool
  **/
 public function isEditor($categoryId, $posterUid)
 {
     $uid = Legacy_Utils::getUid();
     //is Manager ?
     if ($this->check($categoryId, Xcck_AuthType::MANAGE, 'page') === true) {
         return true;
     }
     //is old post and your post ?
     if ($posterUid == $uid && $uid > 0) {
         return true;
     }
     return false;
 }
Example #21
0
 /**
  * checkedAsConne
  * 
  * @param	void
  * 
  * @return	Enum	Pmenum_Cstat
  */
 public function checkedAsConne()
 {
     $uid = Legacy_Utils::getUid();
     $handler = Legacy_Utils::getModuleHandler('conne', $this->getDirname());
     $uidList = $handler->getFriendIdList($uid, Pmenum_Cstat::ONEWAY);
     return in_array($this->get('uid'), $uidList) ? true : false;
 }
 /**
  * _saveImage
  * 
  * @param	void
  * 
  * @return	Enum
  **/
 protected function _saveImage($dataname, $title, $formName, $num = 1)
 {
     $primaryKey = $this->_getHandler()->mPrimary;
     $imageObjs = array();
     XCube_DelegateUtils::call('Legacy_ImageManager.GetImageObjects', new XCube_Ref($imageObjs), $this->mAsset->mDirname, $dataname, $this->mObject->get($primaryKey));
     if (count($imageObjs) > 0) {
         $image = array_shift($imageObjs);
     } else {
         $image = null;
         XCube_DelegateUtils::call('Legacy_ImageManager.CreateImageObject', new XCube_Ref($image));
         $image->set('title', $title);
         $image->set('uid', Legacy_Utils::getUid());
         $image->set('dirname', $this->mAsset->mDirname);
         $image->set('dataname', $dataname);
         $image->set('data_id', $this->mObject->get($primaryKey));
         $image->set('num', $num);
     }
     $ret = false;
     XCube_DelegateUtils::call('Legacy_ImageManager.SaveImage', new XCube_Ref($ret), $_FILES[$formName], $image);
     return $ret;
 }
 /**
  * _getPageTitle
  * 
  * @param	void
  * 
  * @return	string
  **/
 protected function _getPagetitle()
 {
     return Legacy_Utils::getUserName(Legacy_Utils::getUid());
 }
Example #24
0
 /**
  * Setup Image Objects linked to this object
  * 
  * @param   bool	$isPost
  * 
  * @return  void
  **/
 public function setupImages($isPost = true)
 {
     if (count($this->mImage) > 0) {
         return;
     }
     $handler = Legacy_Utils::getModuleHandler($this->getDataname(), $this->getDirname());
     $n = $this->getImageNumber();
     if ($n === 0) {
         return;
     }
     $this->mImage = $this->getImages();
     $originalImage = array();
     XCube_DelegateUtils::call('Legacy_Image.CreateImageObject', new XCube_Ref($originalImage));
     $originalImage->set('title', $this->get($handler->getClientField('title')));
     $originalImage->set('uid', Legacy_Utils::getUid());
     $originalImage->set('dirname', $this->getDirname());
     $originalImage->set('dataname', $this->getDataname());
     $originalImage->set('data_id', $this->get($this->getPrimary()));
     for ($i = 1; $i <= $n; $i++) {
         if (!isset($this->mImage[$i])) {
             $this->mImage[$i] = clone $originalImage;
             $this->mImage[$i]->set('num', $i);
         }
         if ($isPost === true) {
             $this->mImage[$i]->setupPostData($i);
         }
     }
 }
 /**
  * getPermittedIdList
  * 
  * @param	string	$type
  * @param	int		$catId
  * 
  * @return	int[]
  **/
 public function getPermittedIdList($type, $catId = 0)
 {
     $idList = array();
     XCube_DelegateUtils::call('Legacy_Category.GetPermittedIdList', new XCube_Ref($idList), $this->_mSetId, $this->_getAuthType($type), Legacy_Utils::getUid(), $catId);
     return $idList;
 }
Example #26
0
 /**
  * updateTags
  * 
  * @param	string	$dirname
  * @param	string  $dataname
  * @param	int		$dataId
  * @param	string[]	$tagArr
  * @param	int		$posttime
  * 
  * @return	bool
  **/
 public function updateTags($dirname, $dataname, $dataId, $tagArr, $posttime)
 {
     $flag = true;
     //result flag for database delete/insert
     $oldTagArr = array();
     $tagArr = array_unique($tagArr);
     $uid = Legacy_Utils::getUid();
     if (!$dirname || !$dataname || !$dataId) {
         $flag = false;
         return;
     }
     $cri = new CriteriaCompo();
     $cri->add(new Criteria('dirname', $dirname));
     $cri->add(new Criteria('dataname', $dataname));
     $cri->add(new Criteria('data_id', $dataId));
     $objs = $this->getObjects($cri);
     foreach (array_keys($objs) as $key) {
         $oldTagArr[] = $objs[$key]->get('tag');
     }
     //remove deleted tags
     $deleteTags = array_diff($oldTagArr, $tagArr);
     $delCri = new CriteriaCompo();
     $delCri->add(new Criteria('dirname', $dirname));
     $delCri->add(new Criteria('dataname', $dataname));
     $delCri->add(new Criteria('data_id', $dataId));
     $delCri->add(new Criteria('tag', $deleteTags, 'IN'));
     if (!$this->deleteAll($delCri, true)) {
         $flag = false;
     }
     //insert additional tags
     $addTags = array_diff($tagArr, $oldTagArr);
     foreach ($addTags as $newTag) {
         $newTagObj = $this->create();
         $newTagObj->set('tag', trim($newTag));
         $newTagObj->set('dirname', $dirname);
         $newTagObj->set('dataname', $dataname);
         $newTagObj->set('data_id', $dataId);
         $newTagObj->set('uid', $uid);
         $newTagObj->set('posttime', $posttime);
         if (trim($newTag) && !$this->insert($newTagObj, true)) {
             $flag = false;
         }
     }
     return $flag;
 }
 /**
  * hasPermission
  *
  * @param bool	 &$check
  * @param string $gDirname
  * @param int	 $groupId
  * @param string $dirname
  * @param string $dataname
  * @param string $action
  *
  * @return	void
  */
 public static function hasPermission(&$check, $gDirname, $groupId, $dirname, $dataname, $action)
 {
     $rank = Legacy_Utils::getModuleHandler('policy', $gDirname)->getRankByPolicy($groupId, $dirname, $dataname, $action);
     $check = Legacy_Utils::getModuleHandler('member', $gDirname)->isMember($groupId, Legacy_Utils::getUid(), $rank);
 }
Example #28
0
 /**
  * getMyGroupIdList
  * 
  * @param	Enum	$rank	Lenum_GroupRank
  * 
  * @return	int[]
  **/
 public function getMyGroupIdList($rank = Lenum_GroupRank::REGULAR, $authType = Pmenum_Permission::READ)
 {
     $uid = Legacy_Utils::getUid();
     $cri = new CriteriaCompo();
     $cri->add(new Criteria('uid', $uid));
     $cri->add(new Criteria('rank', $rank, '>='));
     $cri->add(new Criteria('status', Lenum_ProgressStatus::FINISHED));
     $cri->setSort('posttime', 'DESC');
     $objs = $this->getObjects($cri);
     foreach (array_keys($objs) as $key) {
         $ret[] = $objs[$key]->get('group_id');
     }
     return $ret;
 }
 /**
  * executeViewIndex
  * 
  * @param    XCube_RenderTarget    &$render
  * 
  * @return    void
  **/
 public function executeViewIndex(&$render)
 {
     $render->setTemplateName($this->mAsset->mDirname . '_member_list.html');
     $render->setAttribute('objects', $this->mObjects);
     $render->setAttribute('group', $this->mGroup);
     $render->setAttribute('dirname', $this->mAsset->mDirname);
     $render->setAttribute('dataname', 'member');
     $render->setAttribute('pageNavi', $this->mFilter->mNavi);
     //set this user's rank
     $cri = new CriteriaCompo();
     $cri->add(new Criteria('uid', Legacy_Utils::getUid()));
     $cri->add(new Criteria('group_id', $this->_getGroupId()));
     $members = $this->_getHandler()->getObjects($cri);
     if (count($members) > 0) {
         $myrank = array_shift($members)->get('rank');
     }
     $render->setAttribute('myrank', $myrank ? $myrank : 0);
     //breadcrumb
     $breadcrumbs = array();
     XCube_DelegateUtils::call('Module.' . $this->mAsset->mDirname . '.Global.Event.GetBreadcrumbs', new XCube_Ref($breadcrumbs), $this->mAsset->mDirname, $this->mGroup);
     $render->setAttribute('xoops_breadcrumbs', $breadcrumbs);
 }
 /**
  * getPermittedIdList
  * 
  * @param	string	$action
  * @param	int		$categoryId
  * 
  * @return	int[]
  **/
 public function getPermittedIdList($action, $categoryId = 0)
 {
     $idList = array();
     XCube_DelegateUtils::call('Legacy_Category.' . $this->_mCategoryDir . '.GetPermittedIdList', new XCube_Ref($idList), $this->_mCategoryDir, $this->_getAuthType($action), Legacy_Utils::getUid(), $categoryId);
     return $idList;
 }