コード例 #1
0
ファイル: Users.php プロジェクト: iHunt101/POS-ws-server
 public static function create($params, $currentUser, $con)
 {
     // check role's permission
     $permission = RolePermissionQuery::create()->select('create_user')->findOneById($currentUser->role_id, $con);
     if (!$permission || $permission != 1) {
         throw new \Exception('Akses ditolak. Anda tidak mempunyai izin untuk melakukan operasi ini.');
     }
     // check if picked username is already used by anyone
     $user = UserQuery::create()->filterByUser($params->user)->count($con);
     if ($user != 0) {
         throw new \Exception('User ID sudah terpakai. Pilih User ID lainnya.');
     }
     // create new user
     $user = new User();
     $user->setUser($params->user)->setPassword(hash('sha512', $params->user))->setRoleId($params->role_id)->setStatus('Active')->save($con);
     // create user detail
     $userDetail = new UserDetail();
     $userDetail->setId($user->getId())->setName($params->name)->setAddress($params->address)->setPhone($params->phone)->save($con);
     // insert into row_history table
     $rowHistory = new RowHistory();
     $rowHistory->setRowId($user->getId())->setData('user')->setTime(time())->setOperation('create')->setUserId($currentUser->id)->save($con);
     $results['success'] = true;
     $results['id'] = $user->getId();
     return $results;
 }
コード例 #2
0
ファイル: NotificationOnUser.php プロジェクト: AlvaCorp/POS-2
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aUser) {
         $this->aUser->removeNotification($this);
     }
     if (null !== $this->aNotification) {
         $this->aNotification->removeOnUser($this);
     }
     $this->id = null;
     $this->user_id = null;
     $this->notification_id = null;
     $this->status = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
コード例 #3
0
ファイル: RoleQuery.php プロジェクト: AlvaCorp/POS-2
 /**
  * Filter the query by a related \ORM\User object
  *
  * @param \ORM\User|ObjectCollection $user  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildRoleQuery The current query, for fluid interface
  */
 public function filterByUser($user, $comparison = null)
 {
     if ($user instanceof \ORM\User) {
         return $this->addUsingAlias(RoleTableMap::COL_ID, $user->getRoleId(), $comparison);
     } elseif ($user instanceof ObjectCollection) {
         return $this->useUserQuery()->filterByPrimaryKeys($user->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByUser() only accepts arguments of type \\ORM\\User or Collection');
     }
 }
コード例 #4
0
ファイル: Role.php プロジェクト: AlvaCorp/POS-2
 /**
  * @param ChildUser $user The ChildUser object to add.
  */
 protected function doAddUser(ChildUser $user)
 {
     $this->collUsers[] = $user;
     $user->setRole($this);
 }
コード例 #5
0
ファイル: UserDetail.php プロジェクト: AlvaCorp/POS-2
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aUser) {
         $this->aUser->removeDetail($this);
     }
     $this->id = null;
     $this->name = null;
     $this->address = null;
     $this->phone = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
コード例 #6
0
ファイル: UserDetailQuery.php プロジェクト: AlvaCorp/POS-2
 /**
  * Filter the query by a related \ORM\User object
  *
  * @param \ORM\User|ObjectCollection $user The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildUserDetailQuery The current query, for fluid interface
  */
 public function filterByUser($user, $comparison = null)
 {
     if ($user instanceof \ORM\User) {
         return $this->addUsingAlias(UserDetailTableMap::COL_ID, $user->getId(), $comparison);
     } elseif ($user instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(UserDetailTableMap::COL_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByUser() only accepts arguments of type \\ORM\\User or Collection');
     }
 }
コード例 #7
0
ファイル: UserQuery.php プロジェクト: AlvaCorp/POS-2
 /**
  * Exclude object from result
  *
  * @param   ChildUser $user Object to remove from the list of results
  *
  * @return $this|ChildUserQuery The current query, for fluid interface
  */
 public function prune($user = null)
 {
     if ($user) {
         $this->addUsingAlias(UserTableMap::COL_ID, $user->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }