public function checkPermission($permission) { global $master_account; //Grant access if master user $access = 0; foreach ($permission as $check) { if ($access == 0) { $query = UcUserPermissionMatchesQuery::create()->filterByUserId($this->user_id)->filterByPermissionId($check)->find(); if (count($query) > 0) { $access = 1; } } } if ($access == 1) { return true; } if ($this->user_id == $master_account) { return true; } else { return false; } }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(UcUserPermissionMatchesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = UcUserPermissionMatchesQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
function removePermission($permission, $user) { $i = 0; if (is_array($permission)) { foreach ($permission as $id) { $query = UcUserPermissionMatchesQuery::create()->filterByPermissionId($id)->filterByUserId($user)->delete(); $i++; } } elseif (is_array($user)) { foreach ($user as $id) { $query = UcUserPermissionMatchesQuery::create()->filterByPermissionId($permission)->filterByUserId($id)->delete(); $i++; } } else { $query = UcUserPermissionMatchesQuery::create()->filterByPermissionId($permission)->filterByUserId($user)->delete(); $i++; } return $i; }