Check if a user owns a publication
548727
def get_pub_id_owner(self, pub_id):
        """"""
        con = self.connection or self._connect()
        cur = con.cursor()

        cur.execute(
            """SELECT distinct username from upload.reaction
            WHERE pub_id = '{pub_id}'"""
            .format(pub_id=pub_id))

        username = cur.fetchall()[0][0]

        return username
732996
def check_read_permission(self, user_id, do_raise=True):
        
        if _is_admin(user_id):
            return True

        if int(self.created_by) == int(user_id):
            return True

        for owner in self.owners:
            if int(owner.user_id) == int(user_id):
                if owner.view == 'Y':
                    break
        else:
            if do_raise is True:
                raise PermissionError("Permission denied. User %s does not have read"
                             " access on network %s" %
                             (user_id, self.id))
            else:
                return False

        return True
621086
private function CheckPublished()
    {
        return PublishDateUtil::IsPublishedNow($this->article->GetPublish(), 
                $this->article->GetPublishFrom(), $this->article->GetPublishTo());
    }
1217248
public static function hasOwnership($app, $ownershipPostID)
    {
        if($ownershipPostID) {
            if(isPostType($app)) {
                $checkDB = DB::table($app)
                  ->where('postID', $ownershipPostID)
                  ->where('createdByUserID', Auth::user()->userID)
                  ->count();
            }else{
                $class = 'App\\Models\\'.$app;
                $object = new $class();
                $checkDB = DB::table($object->table)
                  ->where($object->getKeyName(), $ownershipPostID)
                  ->where('createdByUserID', Auth::user()->userID)
                  ->count();
            }


            return ($checkDB) ? true : false;
        }
    }
154606
private function __canAccessAlerts()
    {
        if ($this->Page instanceof AdministrationPage && self::isLoggedIn() && Symphony::Author()->isDeveloper()) {
            return true;
        }

        return false;
    }
318512
def published(self, for_user=None):
        
        if appsettings.FLUENT_BLOGS_FILTER_SITE_ID:
            qs = self.parent_site(settings.SITE_ID)
        else:
            qs = self

        if for_user is not None and for_user.is_staff:
            return qs

        return qs \
            .filter(status=self.model.PUBLISHED) \
            .filter(
                Q(publication_date__isnull=True) |
                Q(publication_date__lte=now())
            ).filter(
                Q(publication_end_date__isnull=True) |
                Q(publication_end_date__gte=now())
            )
200973
def check_owner_permission(payload, allow_user_owner):
    """"""
    for entity_type in ['users', 'groups']:
        for perm_type in ['add', 'remove']:
            for perms in payload.get(entity_type, {}).get(perm_type, {}).values():
                if 'owner' in perms:
                    if entity_type == 'users' and allow_user_owner:
                        continue

                    if entity_type == 'groups':
                        raise exceptions.ParseError("Owner permission cannot be assigned to a group")

                    raise exceptions.PermissionDenied("Only owners can grant/revoke owner permission")
325018
def check_share_permission(self, user_id):
        

        if _is_admin(user_id):
            return

        if int(self.created_by) == int(user_id):
            return

        for owner in self.owners:
            if owner.user_id == int(user_id):
                if owner.view == 'Y' and owner.share == 'Y':
                    break
        else:
            raise PermissionError("Permission denied. User %s does not have share"
                             " access on network %s" %
                             (user_id, self.id))
171799
def has_object_permission(self, request, view, obj):
        

        user = request.user

        if not user.is_superuser and not user.is_anonymous():
            valid = False
            try:
                ct = ContentType.objects.get_for_model(obj)
                fpm = FilterPermissionModel.objects.get(user=user,
                                                        content_type=ct)
                myq = QSerializer(base64=True).loads(fpm.filter)
                try:
                    myobj = obj.__class__.objects.filter(myq).distinct().get(pk=obj.pk)
                    if myobj:
                        valid = True
                except ObjectDoesNotExist:
                    valid = False
            except ObjectDoesNotExist:
                valid = True
            finally:
                return valid
        else:
            return True
773922
def check_write_permission(self, user_id, do_raise=True):
        
        return self.get_resource().check_write_permission(user_id, do_raise=do_raise)
79250
def lookup(self):
        
        print "%s by %s, size: %s, uploaded %s ago" % (self.name, self.author,
                                                       self.size, self.age)
1154586
def get_submission(self, submissionid, user_check=True):
        
        sub = self._database.submissions.find_one({'_id': ObjectId(submissionid)})
        if user_check and not self.user_is_submission_owner(sub):
            return None
        return sub
246678
def has_perm(self, user, perm, obj=None):
        """"""
        if not user.is_active:
            return False
        return perm in self.get_all_permissions(user, obj)
912194
def owner(self):
        """"""
        if self._writer is not None:
            return self.WRITER
        if self._readers:
            return self.READER
        return None
1132332
def has_permission(self, request):
        """"""
        if not self.object and not self.permission:
            return True

        if not self.permission:
            return request.user.has_perm('{}_{}'.format(
                self.model_permission,
                self.object.__class__.__name__.lower()), self.object
            )

        return request.user.has_perm(self.permission)
1048935
def is_published(self):
        """"""
        return self.status == Status.published and self.timestamp <= arrow.now()
785635
function onPublish( $contentObjectAttribute, $contentObject, $publishedNodes )
    {
        eZDebug::writeDebug( 'Start', __METHOD__ );
        $paex = $contentObjectAttribute->content();
        if ( !$paex instanceof eZPaEx )
        {
            return true;
        }

        // Update empty paex data from parent paex
        // NOTE: if the current user don't have permission to edit paex data, and is
        // creating a new object (publishing version 1), force paex object update
        // to get values set in parent
        if ( !$paex->canEdit() && $contentObject->attribute( 'current_version' ) == 1 )
            $paex->updateFromParent( true );
        else
            $paex->updateFromParent();

        eZDebug::writeDebug( 'End', __METHOD__ );
        return true;
    }