当前位置: 首页>>代码示例>>PHP>>正文


PHP Permissions::canAddExpressEntries方法代码示例

本文整理汇总了PHP中Permissions::canAddExpressEntries方法的典型用法代码示例。如果您正苦于以下问题:PHP Permissions::canAddExpressEntries方法的具体用法?PHP Permissions::canAddExpressEntries怎么用?PHP Permissions::canAddExpressEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Permissions的用法示例。


在下文中一共展示了Permissions::canAddExpressEntries方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_entry

 public function create_entry($id = null, $owner_entry_id = null)
 {
     $r = $this->entityManager->getRepository('\\Concrete\\Core\\Entity\\Express\\Entity');
     $entity = $r->findOneById($id);
     if (!is_object($entity)) {
         $this->redirect('/dashboard/express/entries');
     }
     if ($owner_entry_id) {
         $r = $this->entityManager->getRepository('\\Concrete\\Core\\Entity\\Express\\Entry');
         $entry = $r->findOneById($owner_entry_id);
     }
     $permissions = new \Permissions($entity);
     if (!$permissions->canAddExpressEntries()) {
         throw new \Exception(t('You do not have access to add entries of this entity type.'));
     }
     $this->set('entity', $entity);
     $form = $entity->getDefaultEditForm();
     if (is_object($entry) && $entry->getEntity() == $entity->getOwnedBy()) {
         $form = new OwnedEntityForm($form, $entry);
         $this->set('backURL', $this->getViewEntryURL($entry));
     } else {
         $this->set('backURL', $this->getBackURL($entity));
     }
     $renderer = \Core::make('Concrete\\Core\\Express\\Form\\StandardFormRenderer', ['form' => $form]);
     $this->set('renderer', $renderer);
     $this->render('/dashboard/express/entries/create', false);
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:27,代码来源:DashboardExpressEntityPageController.php

示例2: view

 public function view($entity = null, $folder = null)
 {
     $r = $this->entityManager->getRepository('\\Concrete\\Core\\Entity\\Express\\Entity');
     if ($entity) {
         $entity = $r->findOneById($entity);
     }
     if (isset($entity) && is_object($entity)) {
         $this->entity = $entity;
         $this->set('entity', $entity);
         $this->renderList($folder);
         $permissions = new \Permissions($this->getEntity());
         if ($permissions->canAddExpressEntries()) {
             $header = new Header($entity, $this->getPageObject());
             $this->set('headerMenu', $header);
         }
     } else {
         $this->set('entities', $r->findPublicEntities());
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:19,代码来源:entries.php

示例3: submit

 public function submit($id = null)
 {
     $r = $this->entityManager->getRepository('\\Concrete\\Core\\Entity\\Express\\Entity');
     $entity = $r->findOneById($id);
     $r = $this->entityManager->getRepository('\\Concrete\\Core\\Entity\\Express\\Form');
     $form = $r->findOneById($this->request->request->get('express_form_id'));
     $entry = null;
     if ($this->request->request->has('entry_id')) {
         $entry = $this->entityManager->getRepository('Concrete\\Core\\Entity\\Express\\Entry')->findOneById($this->request->request->get('entry_id'));
     }
     if ($entry === null) {
         $permissions = new \Permissions($entity);
         if (!$permissions->canAddExpressEntries()) {
             $this->error->add(t('You do not have access to add entries of this entity type.'));
         }
     } else {
         $permissions = new \Permissions($entry);
         if (!$permissions->canEditExpressEntry()) {
             $this->error->add(t('You do not have access to edit entries of this entity type.'));
         }
     }
     if ($form !== null) {
         $validator = new Validator($this->error, $this->request);
         $validator->validate($form);
         if (!$this->error->has()) {
             $manager = new Manager($this->entityManager, $this->request);
             if ($entry === null) {
                 // create
                 $entry = $manager->addEntry($entity);
                 $manager->saveEntryAttributesForm($form, $entry);
                 $this->flash('success', tc('Express', 'New record %s added successfully.', $entity->getName()) . '<br />' . '<a class="btn btn-default" href="' . \URL::to(\Page::getCurrentPage(), 'view_entry', $entry->getID()) . '">' . t('View Record Here') . '</a>', true);
                 $this->redirect(\URL::to(\Page::getCurrentPage(), 'create_entry', $entity->getID()));
             } else {
                 // update
                 $manager->saveEntryAttributesForm($form, $entry);
                 $this->flash('success', t('%s updated successfully.', $entity->getName()));
                 $this->redirect($this->getBackURL($entity));
             }
         }
     } else {
         throw new \Exception(t('Invalid form.'));
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:43,代码来源:DashboardExpressEntriesPageController.php

示例4: action_submit

 public function action_submit($bID = null)
 {
     if ($this->bID == $bID) {
         $entityManager = \Core::make('database/orm')->entityManager();
         $form = $this->getFormEntity();
         if (is_object($form)) {
             $e = \Core::make('error');
             $validator = new Validator($e, $this->request);
             $validator->validate($form);
             if ($this->displayCaptcha) {
                 $captcha = \Core::make('helper/validation/captcha');
                 if (!$captcha->check()) {
                     $e->add(t('Incorrect captcha code.'));
                 }
             }
             $this->set('error', $e);
         }
         $entity = $form->getEntity();
         $permissions = new \Permissions($entity);
         if (!$permissions->canAddExpressEntries()) {
             $e->add(t('You do not have access to submit this form.'));
         }
         if (isset($e) && !$e->has()) {
             $manager = new Manager($entityManager, $this->request);
             $entry = $manager->addEntry($entity);
             $entry = $manager->saveEntryAttributesForm($form, $entry);
             $values = $entity->getAttributeKeyCategory()->getAttributeValues($entry);
             // Check antispam
             $antispam = \Core::make('helper/validation/antispam');
             $submittedData = '';
             foreach ($values as $value) {
                 $submittedData .= $value->getAttributeKey()->getAttributeKeyDisplayName() . ":\r\n";
                 $submittedData .= $value->getPlainTextValue() . "\r\n\r\n";
             }
             if (!$antispam->check($submittedData, 'form_block')) {
                 // Remove the entry and silently fail.
                 $entityManager->refresh($entry);
                 $entityManager->remove($entry);
                 $entityManager->flush();
                 $c = \Page::getCurrentPage();
                 $r = Redirect::page($c);
                 $r->setTargetUrl($r->getTargetUrl() . '#form' . $this->bID);
                 return $r;
             }
             if ($this->addFilesToSet) {
                 $set = Set::getByID($this->addFilesToSet);
                 if (is_object($set)) {
                     foreach ($values as $value) {
                         $value = $value->getValueObject();
                         if ($value instanceof FileProviderInterface) {
                             $files = $value->getFileObjects();
                             foreach ($files as $file) {
                                 $set->addFileToSet($file);
                             }
                         }
                     }
                 }
             }
             if ($this->notifyMeOnSubmission) {
                 if (\Config::get('concrete.email.form_block.address') && strstr(\Config::get('concrete.email.form_block.address'), '@')) {
                     $formFormEmailAddress = \Config::get('concrete.email.form_block.address');
                 } else {
                     $adminUserInfo = \UserInfo::getByID(USER_SUPER_ID);
                     $formFormEmailAddress = $adminUserInfo->getUserEmail();
                 }
                 $replyToEmailAddress = $formFormEmailAddress;
                 if ($this->replyToEmailControlID) {
                     $control = $entityManager->getRepository('Concrete\\Core\\Entity\\Express\\Control\\Control')->findOneById($this->replyToEmailControlID);
                     if (is_object($control)) {
                         $email = $entry->getAttribute($control->getAttributeKey());
                         if ($email) {
                             $replyToEmailAddress = $email;
                         }
                     }
                 }
                 $formName = $this->getFormEntity()->getEntity()->getName();
                 $mh = \Core::make('helper/mail');
                 $mh->to($this->recipientEmail);
                 $mh->from($formFormEmailAddress);
                 $mh->replyto($replyToEmailAddress);
                 $mh->addParameter('entity', $entity);
                 $mh->addParameter('formName', $formName);
                 $mh->addParameter('attributes', $values);
                 $mh->load('block_express_form_submission');
                 $mh->setSubject(t('Website Form Submission – %s', $formName));
                 $mh->sendMail();
             }
             if ($this->redirectCID > 0) {
                 $c = \Page::getByID($this->redirectCID);
                 if (is_object($c) && !$c->isError()) {
                     $r = Redirect::page($c);
                     $r->setTargetUrl($r->getTargetUrl() . '?form_success=1');
                     return $r;
                 }
             }
             $c = \Page::getCurrentPage();
             $url = \URL::to($c, 'form_success', $this->bID);
             $r = Redirect::to($url);
             $r->setTargetUrl($r->getTargetUrl() . '#form' . $this->bID);
             return $r;
//.........这里部分代码省略.........
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:101,代码来源:controller.php


注:本文中的Permissions::canAddExpressEntries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。