Notify admins that a new admin has joined the network.

@param AnCommandContext $context The context parameter
774953
public function mailAdminsNewAdmin(AnCommandContext $context)
    {
        $person = $context->result;

        $this->mailAdmins(array(
            'subject' => AnTranslator::sprintf('COM-PEOPLE-MAIL-SUBJECT-NEW-ADMIN', $person->name),
            'template' => 'new_admin',
        ));
    }
193648
protected function _onEntityValidate(AnCommandContext $context)
    {
        if ($this->nodeA->id === $this->nodeB->id) {
            return false;
        }

        return true;
    }
582145
protected function _actionPost(AnCommandContext $context)
    {
        $action = $this->getItem() ? 'edit' : 'add';
        $result = $this->execute($action, $context);

        return $result;
    }
747823
protected function _actionAdd(AnCommandContext $context)
    {
        $entity = parent::_actionAdd($context);

        if ($entity->isPortraitable() && AnRequest::has('files.portrait')) {
            $file = AnRequest::get('files.portrait', 'raw');

            if ($this->bellowSizeLimit($file) && $file['error'] == 0) {
                $entity->setPortrait(array(
                   'url' => $file['tmp_name'],
                   'mimetype' => $file['type'],
                   )
               );
            }
        }

        return $entity;
    }
887652
protected function _actionEdit(AnCommandContext $context)
    {
        $data = $context->data;

        //don't overwrite these two
        unset($data->secret);
        unset($data->dbtype);

        $this->_entity->setData(AnConfig::unbox($data));

        if ($this->_entity->save()) {
            $this->setMessage('COM-SETTINGS-PROMPT-SUCCESS', 'success');
        }
    }
496023
protected function _actionVoteComment(AnCommandContext $context)
    {
        $this->getCommentController()->id($this->cid)->execute('vote', $context);
    }
418475
protected function _actionDelete(AnCommandContext $context)
    {
        $viewer = $this->_state->viewer;
        $person_id = $viewer->id;
        dispatch_plugin('user.onBeforeLogoutPerson', array('person' => $viewer));
        $this->getService('com:people.helper.person')->logout($viewer);
        dispatch_plugin('user.onAfterLogoutPerson', array('id' => $person_id));
        $context->response->setRedirect(route('index.php?'));
    }
1227318
protected function _actionVote($context)
    {
        $context->response->status = AnHttpResponse::CREATED;

        $this->getItem()->voteup(get_viewer());

        $notification = $this->_mixer->createNotification(array(
            'name' => 'voteup',
            'object' => $this->getItem(),
            'component' => $this->getItem()->component,
        ));

        $context->response->content = $this->_mixer->execute('getvoters', $context);
    }
1042163
protected function _actionRead(AnCommandContext $context)
    {
        if ($this->invitetoken) {

            $token = $this->getRepository()->find(array('value' => $this->invitetoken));
            $this->getToolbar('menubar')->setTitle(null);

            if (!$token || !isset($token->inviter)) {
                throw new LibBaseControllerExceptionNotFound('Token not found');
                return;
            }

            if ($this->viewer->guest()) {
                AnRequest::set('session.invite_token', $token->value);
            }

            $this->setItem($token);

        } else {
            $service = pick($this->service, 'facebook');
            $token = $this->getRepository()->getEntity()->reset();
            AnRequest::set('session.invite_token', $token->value);
            $this->getView()->value($token->value);
            return $this->getView()->display();
        }
    }
238662
protected function _afterEntityUpdate(AnCommandContext $context)
    {
        if (isset($this->_pending_files[$this->_mixer])) {
            $files = $this->_pending_files[$this->_mixer];

            foreach ($files as $filename => $data) {
                $this->_mixer->writeData($filename, $data);
            }

            unset($this->_pending_files[$this->_mixer]);
        }
    }
48252
protected function _actionDelete(AnCommandContext $context)
    {
        if ($session = $this->actor->sessions->find(array('api' => $this->getIdentifier()->name))) {
            $session->delete()->save();
        }
    }
1088446
protected function _actionAdd(AnCommandContext $context)
    {
        $data = $context->data;
        $email = $data->email;
        //an email
        $person = $this->getService('repos:people.person')
                      ->getQuery()
                      ->email($email)
                      ->where('IF(!@col(enabled),@col(activationCode) <> \'\',1)')
                      ->disableChain()
                      ->fetch();

        if ($person) {
            $person->requiresReactivation()->save();
            $this->getResponse()->status = AnHttpResponse::CREATED;
            $this->person = $person;
        } else {
            throw new LibBaseControllerExceptionNotFound('Email Not Found');
        }
    }
934408
protected function _afterEntityDelete(AnCommandContext $context)
    {
        $this->subscribee->getRepository()
                         ->getBehavior('subscribable')
                         ->resetStats(array($this->subscribee));
    }
1298166
public function authorizeSubscribePackage(AnCommandContext $context)
    {
        $viewer = $context->viewer;

        return !$viewer->hasSubscription(false) || $this->authorize('upgradepackage');
    }
1053322
protected function _actionProcess(AnCommandContext $context)
    {
        // run this no more than 1 minute
        //set_time_limit(60);

        $query = $this->getService('repos:notifications.notification')
                      ->getQuery(true)
                      ->status(ComNotificationsDomainEntityNotification::STATUS_NOT_SENT);

        if ($this->id) {
            $ids = (array) AnConfig::unbox($this->id);
            $query->id($ids);
        }

        $notifications = $query->fetchSet();

        $this->sendNotifications($notifications);
    }
1064928
protected function _authorizeRemoveAdmin(AnCommandContext $context)
    {
        if ($this->_entity->isAdministrable()) {
            return ($this->_entity->administratorIds->count() >= 2);
        }

        return false;
    }
243444
protected function _afterRepositoryDeletenodes(AnCommandContext $context)
    {
        parent::_afterRepositoryDeletenodes($context);

        $this->_getRepositoryForTable('todos_todos')
             ->update(array('open_status_change_by' => null),
                      array('node_id' => $context['node_ids']));
    }