Ejemplo n.º 1
0
 public function beforeAction($handlerAdapter)
 {
     parent::beforeAction($handlerAdapter);
     $spaceUid = (int) $this->getInput('uid', 'get');
     if ($spaceUid < 1) {
         $userName = $this->getInput('username', 'get');
         $user = Wekit::load('user.PwUser')->getUserByName($userName);
         $spaceUid = isset($user['uid']) ? $user['uid'] : 0;
     }
     if ($spaceUid < 1) {
         $this->forwardRedirect(WindUrlHelper::createUrl('u/login/run/'));
     }
     $this->space = new PwSpaceBo($spaceUid);
     if (!$this->space->space['uid']) {
         $user = Wekit::load('user.PwUser')->getUserByUid($spaceUid);
         if ($user) {
             Wekit::load('space.dm.PwSpaceDm');
             $dm = new PwSpaceDm($spaceUid);
             $dm->setVisitCount(0);
             Wekit::load('space.PwSpace')->addInfo($dm);
             $this->space = new PwSpaceBo($spaceUid);
         } else {
             $this->forwardRedirect(WindUrlHelper::createUrl('u/login/run/'));
         }
     }
     $this->space->setTome($spaceUid, $this->loginUser->uid);
     $this->space->setVisitUid($this->loginUser->uid);
     $this->setTheme('space', null);
     if ($this->space->allowView('space')) {
         $this->forwardRedirect(WindUrlHelper::createUrl('space/index/run', array('uid' => $spaceUid)));
     }
 }
Ejemplo n.º 2
0
 /**
  * 更新我的脚印
  * 
  * @param int $spaceUid
  * @param int $visitUid
  */
 public function signToVisitor($spaceUid, $visitUid)
 {
     if ($spaceUid < 1 || $visitUid < 1) {
         return false;
     }
     if ($spaceUid == $visitUid) {
         return false;
     }
     $time = Pw::getTime();
     $space = $this->_getSpaceDs()->getSpace($visitUid);
     $tovisitors = unserialize($space['tovisitors']);
     $tovisitors = is_array($tovisitors) ? $tovisitors : array();
     if (array_key_exists($spaceUid, $tovisitors)) {
         $keys = array_keys($tovisitors);
         if (array_shift($keys) == $spaceUid) {
             return false;
         }
         //如果是第一个不需要更新
         unset($tovisitors[$spaceUid]);
     }
     $tovisitors = array($spaceUid => $time) + $tovisitors;
     if (count($tovisitors) > 20) {
         $tovisitors = array_slice($tovisitors, 0, 20, true);
     }
     Wekit::load('space.dm.PwSpaceDm');
     $dm = new PwSpaceDm($visitUid);
     $dm->setTovisitors($tovisitors);
     return $this->_getSpaceDs()->updateInfo($dm);
 }
Ejemplo n.º 3
0
 /**
  * (non-PHPdoc)
  * @see src/library/base/PwBaseController::beforeAction()
  */
 public function beforeAction($handlerAdapter)
 {
     parent::beforeAction($handlerAdapter);
     $spaceUid = $this->getInput('uid', 'get');
     if ($spaceUid === '0') {
         $this->showError('SPACE:space.guest');
     }
     $spaceUid = intval($spaceUid);
     if ($spaceUid < 1) {
         if ($userName = $this->getInput('username', 'get')) {
             $user = Wekit::load('user.PwUser')->getUserByName($userName);
             $spaceUid = isset($user['uid']) ? $user['uid'] : 0;
         } elseif ($this->loginUser->uid > 0) {
             $spaceUid = $this->loginUser->uid;
         } else {
             $this->showError('SPACE:space.not.exist');
         }
     }
     $this->space = new PwSpaceModel($spaceUid);
     if (!$this->space->space['uid']) {
         $user = Wekit::load('user.PwUser')->getUserByUid($spaceUid);
         if ($user) {
             Wekit::load('space.dm.PwSpaceDm');
             $dm = new PwSpaceDm($spaceUid);
             $dm->setVisitCount(0);
             Wekit::load('space.PwSpace')->addInfo($dm);
             $this->space = new PwSpaceModel($spaceUid);
         } else {
             //$this->forwardRedirect(WindUrlHelper::createUrl('u/login/run/'));
             $this->showError('SPACE:space.not.exist');
         }
     }
     $this->space->setTome($spaceUid, $this->loginUser->uid);
     $this->space->setVisitUid($this->loginUser->uid);
     if (!$this->space->allowView('space')) {
         $this->forwardRedirect(WindUrlHelper::createUrl('space/ban/run', array('uid' => $spaceUid)));
     }
 }
Ejemplo n.º 4
0
 /**
  * 空间背景设置
  * Enter description here ...
  */
 public function doEditBackgroundAction()
 {
     $repeat = $this->getInput('repeat', 'post');
     $fixed = $this->getInput('fixed', 'post');
     $align = $this->getInput('align', 'post');
     $background = $this->getInput('background', 'post');
     $upload = $this->_uploadImage();
     $image = isset($upload['path']) ? $upload['path'] : '';
     $this->spaceBo = new PwSpaceBo($this->loginUser->uid);
     if (!$image) {
         //list($image, $_repeat, $_fixed, $_align) = $this->spaceBo->space['back_image'];
         if (!$background) {
             $image = $repeat = $fixed = $align = '';
         } else {
             $image = $background;
         }
     }
     Wind::import('SRV:space.dm.PwSpaceDm');
     $dm = new PwSpaceDm($this->loginUser->uid);
     $dm->setBackImage($image, $repeat, $fixed, $align);
     $resource = $this->_getSpaceDs()->updateInfo($dm);
     if ($resource instanceof PwError) {
         $this->showError($resource->getError());
     }
     $this->showMessage("MEDAL:success");
 }