Sets a notification setting.

@param AnCommandContext $context Context parameter
191092
protected function _actionPost(AnCommandContext $context)
    {
        $data = $context->data;

        $viewer = get_viewer();

        $setting = $this->getService('repos:notifications.setting')->findOrAddNew(array(
            'person' => $viewer,
            'actor' => $this->actor,
        ));

        $setting->setValue('posts', null, $data->email);

        $setting->save();
    }
403943
public function setContext($context)
    {
        $contexts = array(self::CONTEXT_CREDITCARD, self::CONTEXT_TOKEN);
        if (!in_array($context, $contexts)) {
            throw new RuntimeException(
                sprintf("Invalid validation context '%s'", $context)
            );
        }

        $this->context = $context;
    }
883066
protected function _afterEntityInsert(AnCommandContext $context)
    {
        $this->set->setValue('photo_count', $this->set->photos->reset()->getTotal());
    }
517543
public function notice($message, array $context = [])
    {
        $this->log(Doozr_Logging_Constant::NOTICE, $message, $context);

        return $this;
    }
481709
public function notifyMentioned(AnCommandContext $context)
    {
        $entity = $this->getItem();
        $subscribers = array();

        foreach ($this->_newly_mentioned as $username) {
            $person = $this->getService('repos:people.person')->find(array('username' => $username));

            if ($person && $person->authorize('mention')) {
                $subscribers[] = $person->id;
            }
        }

        if (count($subscribers) == 0) {
            return;
        }

        if ($entity instanceof ComBaseDomainEntityComment) {
            $parentIdentifier = $entity->parent->getIdentifier()->name;
            $parentController = $this->getService('com:'.AnInflector::pluralize($parentIdentifier).'.controller.'.$parentIdentifier);

            if ($parentController->isNotifier() && $entity->parent->isSubscribable()) {
                $data = array(
                    'name' => 'actor_mention_comment',
                    'object' => $entity,
                    'comment' => $entity,
                    'component' => $entity->parent->component,
                    'subscribers' => $subscribers,
                );

                $parentController->createNotification($data);
            }
        } else {
            $data = array(
                'name' => 'actor_mention',
                'object' => $entity,
                'component' => $entity->component,
                'subscribers' => $subscribers,
            );

            $notification = $this->_mixer->createNotification($data);
        }
    }
122264
public function setContexts($contexts)
    {
        if ($contexts) {
            foreach ((array) $contexts as $name => $value) {
                $this->getContext()->set($name, $value);
            }
        }
    }
92623
protected function _actionRead(AnCommandContext $context)
    {
        $this->getService('repos:subscriptions.package');
        $this->setItem($this->actor->subscription);
    }
660211
protected function _actionAdd($context)
    {
        $data = $context->data;

        $entity = parent::_actionAdd($context);

        //if a person posting a message on his profile
        //or if a target is not actor then it can't be a private message
        if (get_viewer()->eql($this->actor) || !is_person($this->actor)) {
            unset($data->private);
        }

        //if a private message then
        //set the privacy to subject/target
        if ($data->private) {
            $entity->setAccess(array($this->actor->id, get_viewer()->id));
        }

        //create a notification for the subscribers and
        //the post owner as well
        if ($entity->owner->isSubscribable()) {
            //create a notification and pass the owner
            $notification = $this->createNotification(array(
                'name' => 'note_add',
                'object' => $entity,
                'subscribers' => array($entity->owner->subscriberIds->toArray(), $entity->owner),
            ))->setType('post', array('new_post' => true));
        }

        if (!empty($data['channels'])) {
            $this->shareObject(array(
                'object' => $entity,
                'sharers' => $data['channels']
            ));
        }

        return $entity;
    }
427147
protected function _afterEntityInsert(AnCommandContext $context)
    {
        $this->administrable->getRepository()
                            ->getBehavior('administrable')
                            ->resetStats(array(
                              $this->administrable,
                              $this->administrator, ));
    }
1071764
public function sendToUser($notification, $context, $user, $data)
    {
        $subject = $notification->format($notification->Title, $context, $user, $data);

        if (Config::inst()->get(SystemNotification::class, 'html_notifications')) {
            $message = $notification->format(
                $notification->NotificationContent(),
                $context,
                $user,
                $data
            );
        } else {
            $message = $notification->format(
                nl2br($notification->NotificationContent()),
                $context,
                $user,
                $data
            );
        }

        if ($template = $notification->getTemplate()) {
            $templateData = $notification->getTemplateData($context, $user, $data);
            $templateData->setField('Body', $message);
            try {
                $body = $templateData->renderWith($template);
            } catch (Exception $e) {
                $body = $message;
            }
        } else {
            $body = $message;
        }

        $from = $this->config()->get('send_notifications_from');
        $to = $user->Email;
        if (!$to && method_exists($user, 'getEmailAddress')) {
            $to = $user->getEmailAddress();
        }

        if (!$from || !$to) {
            return;
        }
        // send
        try {
            $email = new Email($from, $to, $subject);
            $email->setBody($body);
            $this->extend('onBeforeSendToUser', $email);
            $email->send();
        } catch (\Swift_SwiftException $e) {
            if ($this->logger) {
                if ($to !== 'admin') {
                    $this->logger->warning("Failed sending email to $to");    
                }
            }
        }
    }
496023
protected function _actionVoteComment(AnCommandContext $context)
    {
        $this->getCommentController()->id($this->cid)->execute('vote', $context);
    }
652699
protected function _actionGetcount(AnCommandContext $context)
    {
        $count = $this->actor->numOfNewNotifications();
        return $this->getView()->newNotifications($count)->display();
    }
1204995
public function mailInvoice(AnCommandContext $context)
    {
        if ($this->getItem()) {

            $mails[] = array(
                'to' => $this->getItem()->person->email,
                'subject' => AnTranslator::_('COM-SUBSCRIPTIONS-CONFIRMATION-MESSAGE-SUBJECT'),
                'template' => 'invoice',
            );

            $this->mail($mails);
        }
    }
907212
public void setContext(DisplayContext context) {
        if (context.type() == DisplayContext.Type.CAPITALIZATION) {
            capitalizationSetting = context;
        }
    }
747486
public function setContext(Context $context)
    {
        $this->context = $context;

        if (empty($this->parameters['secret'])) {
            $this->parameters['secret'] = $context->getSecret();
        }

        return $this;
    }
857021
public function alert($message, array $context = [])
    {
        $this->checkInitialized();

        foreach ($this->loggers as $logger) {
            $logger->alert($message, $context);
        }
    }
911885
protected function _actionEdit(AnCommandContext $context)
    {
        $data = $context->data;

        dispatch_plugin('user.onBeforeEditPerson', array('data' => $context->data));

        //dont' set the usertype yet, until we find the conditions are met
        $usertype = null;

        if ($data->usertype) {
            $usertype = $data->usertype;
            unset($context->data->usertype);
        }

        if ($data->password) {
            $_SESSION['reset_password_prompt'] = 0;
        }

        $person = parent::_actionEdit($context);

        //add the validations here
        $this->getRepository()
        ->getValidator()
        ->addValidation('givenName', 'required')
        ->addValidation('familyName', 'required')
        ->addValidation('username', 'uniqueness')
        ->addValidation('email', 'uniqueness');

        if ($person->validate() === false) {
            throw new AnErrorException($person->getErrors(), AnHttpResponse::BAD_REQUEST);
        }

        //now check to see if usertype can be set, otherwise the value is unchanged
        if (in_array($usertype, $this->_allowed_user_types) && $person->authorize('changeUsertype')) {
            $person->usertype = $usertype;
        }

        $person->timestamp();

        dispatch_plugin('user.onAfterEditPerson', array('person' => $person));

        $this->setMessage('LIB-AN-PROMPT-UPDATE-SUCCESS', 'success');

        $edit = ($data->password && $data->username) ? 'account' : $this->_request->edit;
        $url = sprintf($person->getURL(false)."&get=settings&edit=%s", $edit);
        $context->response->setRedirect(route($url));

        return $person;
    }