示例#1
0
 /**
  * Returns account by user or create and save
  *
  * @param	RM_User_Object $obUser
  * @return	RM_Points_Account
  */
 public function loadAccountByUserOrCreate(RM_User_Object $obUser)
 {
     if (isNull($obAccount = $this->_storages['account']->loadObjectByKey('user_id', $obUser->id()))) {
         $obAccount = M('Points')->createAccount(array('user_id' => $obUser->id()));
         $obAccount->save();
     }
     return $obAccount;
 }
示例#2
0
 protected function _setStatus(RM_User_Object $user, $skipped, $create = FALSE)
 {
     $query = M('Db')->createQuery('rm_diary_alarm')->set('last_show', M('Date')->dbDate())->set('skipped', $skipped);
     if ($create) {
         $query->command('insert');
         $query->set('user_id', $user->id());
     } else {
         $query->command('update');
         $query->where('user_id=?', $user->id());
     }
     $query->execute();
 }
示例#3
0
 /**
  * Enter description here...
  *
  * @param RM_User_Object $obUser
  * @param array $data
  * @return RM_User_Family_Decorator_Pet | TRUE
  */
 public function editPet(RM_User_Object $obUser, &$data)
 {
     if (isNull($obPet = M('User')->loadPetById(@$data['id']))) {
         $obPet = M('User')->createPet(array());
         $obPet->user_id = $obUser->id();
     }
     try {
         if ($data['animal_type'] == 'other') {
             $obPet->setAvailableFieldsForOtherPets();
             $obPet->animal_type = M('User')->getAnimalTypeByPetName($data['animal_type']);
             // 3
             unset($data['id'], $data['animal_type']);
             $obPet->animal_descr = serialize(@$data);
             $n = 0;
             foreach ($data as $value) {
                 if (empty($value)) {
                     $n++;
                 }
             }
             if ($n == count($data)) {
                 $obPet->delete();
             }
         } else {
             $data['sex'] = @$data['sex'] ? $data['sex'] : NULL;
             $data['birthday'] = M('Date')->dbDate(@$data['birthday_year'] . '-' . @$data['birthday_month'] . date('-d'));
             $data['animal_certificate'] = @$data['animal_certificate'] ? 1 : 0;
             $data['animal_castrated'] = @$data['animal_castrated'] ? 1 : 0;
             $data['animal_type'] = M('User')->getAnimalTypeByPetName($data['animal_type']);
             unset($data['birthday_month'], $data['birthday_year']);
             foreach ($data as $name => $value) {
                 $obPet->{$name} = trim($value);
             }
         }
         $user = $obPet->user();
         $obPet->save();
         MC('Anketa')->clearAlertCache($user);
         return TRUE;
     } catch (RM_Validator_Exception $e) {
         $err = iterFirst($e->getResult()->getErrors());
         error(L('user.field') . ' "' . L('user._' . $err['place']) . '" ' . L('user.' . $err['code']));
         return $obPet;
     }
 }
示例#4
0
 /**
  *	Получить информацию о данном панелисте из отчета о панелистах
  *
  *	@param	RM_User_Object	$obUser
  *	@return array
  **/
 protected function _getInfo(RM_User_Object $obUser)
 {
     $result = array();
     $query = M('Db')->createQuery($this->_table)->where('user_id = ?', $obUser->id());
     foreach ($query->execute() as $result) {
         break;
     }
     return $result;
 }
示例#5
0
 /**
  * Retrievs list of shop links by user
  *
  * @param RM_User_Object $user
  *
  * @return RM_Store_iRequest<RM_Shop_Link>
  */
 public function getLinksByUser(RM_User_Object $user)
 {
     return $this->_mapper->_storage('link')->getObjectList()->filter('user_id = ?', $user->id());
 }
示例#6
0
 public function getPurchaseListForDiary(RM_User_Object $user, $date)
 {
     return $this->_mapper->storage('purchase')->getObjectList()->filter('user_id=? and bdate=? and is_deleted=0', $user->id(), M('Date')->dbDate($date));
 }
示例#7
0
 public function clearAlertCache(RM_User_Object $obUser)
 {
     M('Cache')->put($this->_alertCacheNs(), 'anketa-' . $obUser->id(), null);
     M('Cache')->put($this->_alertCacheNs(), 'pets-' . $obUser->id(), null);
 }
示例#8
0
 protected function _setAction(RM_User_Object $obUser, $bdate, $number)
 {
     $params = array('user_id' => $obUser->id(), 'date' => $bdate, 'number' => $number);
     $this->addToQueue($params);
 }
示例#9
0
 public function statusChanged(RM_User_Object $user, $oldStatus)
 {
     if (!($fp = fopen(M('User')->statusLogFile(date('Y.m.d')), 'a'))) {
         return FALSE;
     }
     $data = array(date('H:i:s'), me()->id(), $oldStatus, $user->status_id, $user->id());
     $mess = join("\t", $data) . "\n";
     fputs($fp, $mess);
     fclose($fp);
     return TRUE;
 }
示例#10
0
 public function addPurchasesMovementToLog($source, RM_Barcode_Object $obDestination, RM_User_Object $obUser)
 {
     $query = M('Db')->createQuery($this->_mapper->table('move_log'), 'insert')->set('barcode_source = ?', $source)->set('barcode_destination = ?', $obDestination->value)->set('coder_id = ?', $obUser->id())->set('coded_date = NOW()');
     $query->execute();
 }
示例#11
0
 /**
  * Enter description here...
  *
  * @param RM_User_Object $obUser
  * @return RM_Presents_Cart
  */
 public function getCartByUserOrCreate(RM_User_Object $obUser)
 {
     if (isNull($obCart = $this->_loadByKey('cart', 'user_id', $obUser->id()))) {
         $obCart = $this->createObject('cart', array('user_id' => $obUser->id()));
         $obCart->save();
     }
     return $obCart;
 }
示例#12
0
 /**
  *	Description...
  *
  *	@return void
  **/
 public function getUserShopList(RM_User_Object $user)
 {
     $q = $this->_storage('link')->createQuery('l');
     $q->what()->reset();
     $q->what('s.id as id, l.name as name, l.street as street, l.bld as bld, s.longitude as lon, s.latitude as lat, l.shop_type as type')->join('l', 'LEFT JOIN panelie_shop s on s.id=l.shop_id')->where('l.user_id=? and s.id is not null', $user->id());
     return M('Store')->requestQuery(M('Store')->factoryObject(), $q, qw2('id>s.id name>l.name street>l.street bld>l.bld lon>s.longitude lat>s.latitude type>l.shop_type'));
 }
示例#13
0
 /**
  * Enter description here...
  *
  * @param RM_User_Object $obUser
  */
 public function getPersonalHolderByUser(RM_User_Object $obUser)
 {
     return iterFirst($this->getHolderList()->filter('is_personal = 1 AND user_id = ?', $obUser->id()));
 }
示例#14
0
 public function checkAccessToLeaves($user_id, RM_User_Object $obUser)
 {
     if (!$obUser->id()) {
         return FALSE;
     }
     if ($user_id == $obUser->id()) {
         return TRUE;
     }
     if ($obUser->isAdmin()) {
         return TRUE;
     }
     $obCheckUser = M('User')->loadUserById($user_id);
     if (isNull($obCheckUser)) {
         return FALSE;
     }
     if ($obUser->isRegionAdmin() && $obUser->city_id == $obCheckUser->city_id) {
         return TRUE;
     }
     return FALSE;
 }