示例#1
0
 public static function create($params, $currentUser, $con)
 {
     // check role's permission
     $permission = RolePermissionQuery::create()->select('create_role')->findOneById($currentUser->role_id, $con);
     if (!$permission || $permission != 1) {
         throw new \Exception('Akses ditolak. Anda tidak mempunyai izin untuk melakukan operasi ini.');
     }
     // check whether role is already exist
     $role = RoleQuery::create()->filterByStatus('Active')->filterByName($params->name)->count($con);
     if ($role != 0) {
         throw new \Exception('Jabatan ' . $params->name . ' sudah ada dalam data');
     }
     // create new role
     $role = new Role();
     $role->setName($params->name)->save($con);
     // create new role permission with default value
     $rolePermission = new RolePermission();
     $rolePermission->setId($role->getId())->save($con);
     // log history
     $rowHistory = new RowHistory();
     $rowHistory->setRowId($role->getId())->setData('role')->setTime(time())->setOperation('create')->setUserId($currentUser->id)->save($con);
     $params->id = $role->getId();
     $results['success'] = true;
     $results['data'] = $params;
     return $results;
 }
示例#2
0
 /**
  * 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->aRole) {
         $this->aRole->removeNotificationOption($this);
     }
     $this->id = null;
     $this->type = null;
     $this->role_id = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
示例#3
0
文件: User.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->aRole) {
         $this->aRole->removeUser($this);
     }
     $this->id = null;
     $this->user = null;
     $this->password = null;
     $this->role_id = null;
     $this->status = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
 /**
  * Filter the query by a related \ORM\Role object
  *
  * @param \ORM\Role|ObjectCollection $role The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildNotificationOptionQuery The current query, for fluid interface
  */
 public function filterByRole($role, $comparison = null)
 {
     if ($role instanceof \ORM\Role) {
         return $this->addUsingAlias(NotificationOptionTableMap::COL_ROLE_ID, $role->getId(), $comparison);
     } elseif ($role instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(NotificationOptionTableMap::COL_ROLE_ID, $role->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByRole() only accepts arguments of type \\ORM\\Role or Collection');
     }
 }
示例#5
0
 /**
  * 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->aRole) {
         $this->aRole->removePermission($this);
     }
     $this->id = null;
     $this->pay_credit = null;
     $this->read_credit = null;
     $this->pay_debit = null;
     $this->read_debit = null;
     $this->create_product = null;
     $this->read_product = null;
     $this->update_product = null;
     $this->destroy_product = null;
     $this->create_purchase = null;
     $this->read_purchase = null;
     $this->update_purchase = null;
     $this->destroy_purchase = null;
     $this->create_role = null;
     $this->read_role = null;
     $this->update_role = null;
     $this->destroy_role = null;
     $this->create_sales = null;
     $this->read_sales = null;
     $this->update_sales = null;
     $this->destroy_sales = null;
     $this->create_second_party = null;
     $this->read_second_party = null;
     $this->update_second_party = null;
     $this->destroy_second_party = null;
     $this->create_stock = null;
     $this->read_stock = null;
     $this->update_stock = null;
     $this->destroy_stock = null;
     $this->create_unit = null;
     $this->read_unit = null;
     $this->update_unit = null;
     $this->destroy_unit = null;
     $this->create_user = null;
     $this->read_user = null;
     $this->update_user = null;
     $this->destroy_user = null;
     $this->reset_pass_user = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
示例#6
0
 /**
  * Exclude object from result
  *
  * @param   ChildRole $role Object to remove from the list of results
  *
  * @return $this|ChildRoleQuery The current query, for fluid interface
  */
 public function prune($role = null)
 {
     if ($role) {
         $this->addUsingAlias(RoleTableMap::COL_ID, $role->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }