Ejemplo n.º 1
0
 public function view($fID = 0)
 {
     if ($fID > 0) {
         $sessionFormID = $fID;
         Session::set('formifyFormID', $fID);
     } else {
         $sessionFormID = Session::get('formifyFormID');
     }
     $f = \Concrete\Package\Formify\Src\FormifyForm::get($sessionFormID);
     $this->set('f', $f);
     $userAttributes = UserKey::getList();
     $this->set('userAttributes', $userAttributes);
     $fsl = new FileSetList();
     $fsl->filterByType(FileSet::TYPE_PUBLIC);
     $fileSets = $fsl->getPage();
     $this->set('fileSets', $fileSets);
     if (!$f) {
         $this->redirect('/dashboard/formify/forms');
     }
     $html = Loader::helper('html');
     $this->addHeaderItem($html->css('formify.css', 'formify'));
     $this->addHeaderItem($html->css('fields.css', 'formify'));
     $this->addFooterItem($html->javascript('angular.min.js', 'formify'));
     $this->addFooterItem($html->javascript('ui-bootstrap-custom-tpls-0.13.0.min.js', 'formify'));
     $this->addFooterItem($html->javascript('formify.js', 'formify'));
     $this->addFooterItem($html->javascript('fields.js', 'formify'));
     $this->addFooterItem($html->javascript('controllers/fields.js', 'formify'));
 }
 public function publish(AttributeKey $ak, Package $pkg = null)
 {
     /** @var $category UserAttributeKeyCategoryInstance */
     $category = $ak->getCategory();
     $key = UserKey::add($ak->getType(), array('akHandle' => $ak->getHandle(), 'akName' => $ak->getName(), 'akIsInternal' => $ak->getIsInternal(), 'akIsSearchableIndexed' => $ak->getIsIndexed(), 'akIsSearchable' => $ak->getIsSearchable(), 'uakProfileDisplay' => $category->getDisplayedInProfile(), 'uakProfileEdit' => $category->getEditableInProfile(), 'uakProfileEditRequired' => $category->getRequiredInProfile(), 'uakRegisterEdit' => $category->getEditableInRegistration(), 'uakRegisterEditRequired' => $category->getRequiredInRegistration(), 'uakMemberListDisplay' => $category->getDisplayedInMemberList()), $pkg);
     return $key;
 }
 private function addUserAttributeKeys($pkg)
 {
     $att = UserAttributeKey::getByHandle("db_table_demo");
     if (!$att) {
         UserAttributeKey::add('db_table_demo', array('akHandle' => 'db_table_demo', 'akName' => t('Database Table Tutorial Demo'), 'akIsSearchable' => true), $pkg);
     }
 }
Ejemplo n.º 4
0
 public function sortUser()
 {
     $this->canAccess();
     $uats = $_REQUEST['akID'];
     if (is_array($uats)) {
         $uats = array_filter($uats, 'is_numeric');
     }
     if (count($uats)) {
         UserKey::updateAttributesDisplayOrder($uats);
     }
 }
 public function skipItem()
 {
     $key = false;
     switch ($this->object->getCategory()) {
         case 'collection':
             $key = CollectionKey::getByHandle($this->object->getHandle());
             break;
         case 'file':
             $key = FileKey::getByHandle($this->object->getHandle());
             break;
         case 'user':
             $key = UserKey::getByHandle($this->object->getHandle());
             break;
     }
     return is_object($key);
 }
 public function sort()
 {
     $this->canAccess();
     $uats = $_REQUEST['akID'];
     $asID = $_REQUEST['asID'];
     if (is_array($uats)) {
         $uats = array_filter($uats, 'is_numeric');
     }
     if (count($uats)) {
         if (is_numeric($asID) && $asID) {
             $as = Set::getByID($asID);
         }
         if ($as instanceof Set) {
             $as->updateAttributesDisplayOrder($uats);
         } else {
             UserKey::updateAttributesDisplayOrder($uats);
         }
     }
 }
Ejemplo n.º 7
0
 public function install()
 {
     $pkg = parent::install();
     //install our dashboard singlepages
     SinglePage::add('/dashboard/store/', $pkg);
     SinglePage::add('/dashboard/store/orders/', $pkg);
     SinglePage::add('/dashboard/store/products/', $pkg);
     SinglePage::add('/dashboard/store/products/attributes', $pkg);
     SinglePage::add('/dashboard/store/settings/', $pkg);
     //install our cart/checkout pages
     SinglePage::add('/cart/', $pkg);
     SinglePage::add('/checkout/', $pkg);
     SinglePage::add('/checkout/complete', $pkg);
     Page::getByPath('/cart/')->setAttribute('exclude_nav', 1);
     Page::getByPath('/checkout/')->setAttribute('exclude_nav', 1);
     Page::getByPath('/checkout/complete')->setAttribute('exclude_nav', 1);
     //install a default page to pushlish products under
     $productParentPage = Page::getByPath('/product-detail');
     if ($productParentPage->isError()) {
         $productParentPage = Page::getByID(1)->add(PageType::getByHandle('page'), array('cName' => t('Product Detail'), 'cHandle' => 'product-detail', 'pkgID' => $pkg->pkgID), PageTemplate::getByHandle('full'));
     }
     Page::getByPath('/product-detail')->setAttribute('exclude_nav', 1);
     $this->installStoreProductPageType($pkg);
     Config::save('vividstore.productPublishTarget', $productParentPage->getCollectionID());
     //install our blocks
     BlockTypeSet::add("vivid_store", "Store", $pkg);
     BlockType::installBlockTypeFromPackage('vivid_product_list', $pkg);
     BlockType::installBlockTypeFromPackage('vivid_utility_links', $pkg);
     BlockType::installBlockTypeFromPackage('vivid_product', $pkg);
     //install some default blocks for page type.
     $pageType = PageType::getByHandle('store_product');
     $template = $pageType->getPageTypeDefaultPageTemplateObject();
     $pageObj = $pageType->getPageTypePageTemplateDefaultPageObject($template);
     $bt = BlockType::getByHandle('vivid_product');
     $blocks = $pageObj->getBlocks('Main');
     if (count($blocks) < 1) {
         $data = array('productLocation' => 'page', 'showProductName' => 1, 'showProductDescription' => 1, 'showProductDetails' => 1, 'showProductPrice' => 1, 'showImage' => 1, 'showCartButton' => 1, 'showGroups' => 1);
         $pageObj->addBlock($bt, 'Main', $data);
     }
     //set our default currency configs
     Config::save('vividstore.symbol', '$');
     Config::save('vividstore.whole', '.');
     Config::save('vividstore.thousand', ',');
     //set defaults for shipping
     Config::save('vividstore.sizeUnit', 'in');
     Config::save('vividstore.weightUnit', 'l');
     //tax label
     $pkg->getconfig()->save('vividstore.taxName', t('Tax'));
     //user attributes for customers
     $uakc = AttributeKeyCategory::getByHandle('user');
     $uakc->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_MULTIPLE);
     //define attr group, and the different attribute types we'll use
     $custSet = $uakc->addSet('customer_info', t('Store Customer Info'), $pkg);
     $text = AttributeType::getByHandle('text');
     $address = AttributeType::getByHandle('address');
     //email
     $bFirstname = UserAttributeKey::getByHandle('email');
     if (!is_object($bFirstname)) {
         UserAttributeKey::add($text, array('akHandle' => 'email', 'akName' => t('Email'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => false, 'uakRegisterEdit' => false, 'uakProfileEditRequired' => false, 'akCheckedByDefault' => true, 'displayOrder' => '1'), $pkg)->setAttributeSet($custSet);
     }
     //billing first name
     $bFirstname = UserAttributeKey::getByHandle('billing_first_name');
     if (!is_object($bFirstname)) {
         UserAttributeKey::add($text, array('akHandle' => 'billing_first_name', 'akName' => t('Billing First Name'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => false, 'uakRegisterEdit' => false, 'uakProfileEditRequired' => false, 'akCheckedByDefault' => true, 'displayOrder' => '1'), $pkg)->setAttributeSet($custSet);
     }
     //billing last name
     $bLastname = UserAttributeKey::getByHandle('billing_last_name');
     if (!is_object($bLastname)) {
         UserAttributeKey::add($text, array('akHandle' => 'billing_last_name', 'akName' => t('Billing Last Name'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => false, 'uakRegisterEdit' => false, 'uakProfileEditRequired' => false, 'akCheckedByDefault' => true, 'displayOrder' => '2'), $pkg)->setAttributeSet($custSet);
     }
     //billing address
     $bAddress = UserAttributeKey::getByHandle('billing_address');
     if (!is_object($bAddress)) {
         UserAttributeKey::add($address, array('akHandle' => 'billing_address', 'akName' => t('Billing Address'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => false, 'uakRegisterEdit' => false, 'uakProfileEditRequired' => false, 'akCheckedByDefault' => true, 'displayOrder' => '3'), $pkg)->setAttributeSet($custSet);
     }
     //billing Phone
     $bPhone = UserAttributeKey::getByHandle('billing_phone');
     if (!is_object($bPhone)) {
         UserAttributeKey::add($text, array('akHandle' => 'billing_phone', 'akName' => t('Billing Phone'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => false, 'uakRegisterEdit' => false, 'uakProfileEditRequired' => false, 'akCheckedByDefault' => true, 'displayOrder' => '4'), $pkg)->setAttributeSet($custSet);
     }
     //shipping first name
     $sFirstname = UserAttributeKey::getByHandle('shipping_first_name');
     if (!is_object($sFirstname)) {
         UserAttributeKey::add($text, array('akHandle' => 'shipping_first_name', 'akName' => t('Shipping First Name'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => false, 'uakRegisterEdit' => false, 'uakProfileEditRequired' => false, 'akCheckedByDefault' => true, 'displayOrder' => '1'), $pkg)->setAttributeSet($custSet);
     }
     //shipping last name
     $bLastname = UserAttributeKey::getByHandle('shipping_last_name');
     if (!is_object($bLastname)) {
         UserAttributeKey::add($text, array('akHandle' => 'shipping_last_name', 'akName' => t('Shipping Last Name'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => false, 'uakRegisterEdit' => false, 'uakProfileEditRequired' => false, 'akCheckedByDefault' => true, 'displayOrder' => '2'), $pkg)->setAttributeSet($custSet);
     }
     //shipping address
     $sAddress = UserAttributeKey::getByHandle('shipping_address');
     if (!is_object($sAddress)) {
         UserAttributeKey::add($address, array('akHandle' => 'shipping_address', 'akName' => t('Shipping Address'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => false, 'uakRegisterEdit' => false, 'uakProfileEditRequired' => false, 'akCheckedByDefault' => true, 'displayOrder' => '3'), $pkg)->setAttributeSet($custSet);
     }
     //create user group
     $group = Group::getByName('Store Customer');
     if (!$group || $group->getGroupID() < 1) {
         $group = Group::add('Store Customer', t('Registered Customer in your store'));
     }
     //create custom attribute category for orders
     $oakc = AttributeKeyCategory::getByHandle('store_order');
     if (!is_object($oakc)) {
         $oakc = AttributeKeyCategory::add('store_order', AttributeKeyCategory::ASET_ALLOW_SINGLE, $pkg);
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('text'));
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('textarea'));
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('number'));
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('address'));
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('boolean'));
         $oakc->associateAttributeKeyType(AttributeType::getByHandle('date_time'));
         $orderCustSet = $oakc->addSet('order_customer', t('Store Customer Info'), $pkg);
     }
     $email = StoreOrderKey::getByHandle('email');
     if (!is_object($email)) {
         StoreOrderKey::add($text, array('akHandle' => 'email', 'akName' => t('Email')), $pkg)->setAttributeSet($orderCustSet);
     }
     $bFirstname = StoreOrderKey::getByHandle('billing_first_name');
     if (!is_object($bFirstname)) {
         StoreOrderKey::add($text, array('akHandle' => 'billing_first_name', 'akName' => t('Billing First Name')), $pkg)->setAttributeSet($orderCustSet);
     }
     $bLastname = StoreOrderKey::getByHandle('billing_last_name');
     if (!is_object($bLastname)) {
         StoreOrderKey::add($text, array('akHandle' => 'billing_last_name', 'akName' => t('Billing Last Name')), $pkg)->setAttributeSet($orderCustSet);
     }
     $bAddress = StoreOrderKey::getByHandle('billing_address');
     if (!is_object($bAddress)) {
         StoreOrderKey::add($address, array('akHandle' => 'billing_address', 'akName' => t('Billing Address')), $pkg)->setAttributeSet($orderCustSet);
     }
     $bPhone = StoreOrderKey::getByHandle('billing_phone');
     if (!is_object($bPhone)) {
         StoreOrderKey::add($text, array('akHandle' => 'billing_phone', 'akName' => t('Billing Phone')), $pkg)->setAttributeSet($orderCustSet);
     }
     $sFirstname = StoreOrderKey::getByHandle('shipping_first_name');
     if (!is_object($sFirstname)) {
         StoreOrderKey::add($text, array('akHandle' => 'shipping_first_name', 'akName' => t('Shipping First Name')), $pkg)->setAttributeSet($orderCustSet);
     }
     $sLastname = StoreOrderKey::getByHandle('shipping_last_name');
     if (!is_object($sLastname)) {
         StoreOrderKey::add($text, array('akHandle' => 'shipping_last_name', 'akName' => t('Shipping Last Name')), $pkg)->setAttributeSet($orderCustSet);
     }
     $sAddress = StoreOrderKey::getByHandle('shipping_address');
     if (!is_object($sAddress)) {
         StoreOrderKey::add($address, array('akHandle' => 'shipping_address', 'akName' => t('Shipping Address')), $pkg)->setAttributeSet($orderCustSet);
     }
     //create custom attribute category for products
     $pakc = AttributeKeyCategory::getByHandle('store_product');
     if (!is_object($pakc)) {
         $pakc = AttributeKeyCategory::add('store_product', AttributeKeyCategory::ASET_ALLOW_SINGLE, $pkg);
         $pakc->associateAttributeKeyType(AttributeType::getByHandle('text'));
         $pakc->associateAttributeKeyType(AttributeType::getByHandle('textarea'));
         $pakc->associateAttributeKeyType(AttributeType::getByHandle('number'));
         $pakc->associateAttributeKeyType(AttributeType::getByHandle('address'));
         $pakc->associateAttributeKeyType(AttributeType::getByHandle('boolean'));
         $pakc->associateAttributeKeyType(AttributeType::getByHandle('date_time'));
     }
     //install payment gateways
     PaymentMethod::add('auth_net', 'Authorize .NET', $pkg);
     PaymentMethod::add('invoice', 'Invoice', $pkg, null, true);
     PaymentMethod::add('paypal_standard', 'PayPal', $pkg);
     //create fileset to place digital downloads
     $fs = FileSet::getByName('Digital Downloads');
     if (!is_object($fs)) {
         FileSet::add("Digital Downloads");
     }
     Installer::addOrderStatusesToDatabase($pkg);
     Config::save('vividstore.cartOverlay', false);
 }
Ejemplo n.º 8
0
 public static function installUserAttribute($handle, $type, $pkg, $set, $data = null)
 {
     $attr = UserAttributeKey::getByHandle($handle);
     if (!is_object($attr)) {
         $name = Core::make("helper/text")->camelcase($handle);
         if (!$data) {
             $data = array('akHandle' => $handle, 'akName' => t($name), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => false, 'uakRegisterEdit' => false, 'uakProfileEditRequired' => false, 'akCheckedByDefault' => true);
         }
         UserAttributeKey::add($type, $data, $pkg)->setAttributeSet($set);
     }
 }
Ejemplo n.º 9
0
 /**
  * Filters keyword fields by keywords (including username, email and attributes).
  *
  * @param $keywords
  */
 public function filterByKeywords($keywords)
 {
     $expressions = [$this->query->expr()->like('u.uName', ':keywords'), $this->query->expr()->like('u.uEmail', ':keywords')];
     $keys = \Concrete\Core\Attribute\Key\UserKey::getSearchableIndexedList();
     foreach ($keys as $ak) {
         $cnt = $ak->getController();
         $expressions[] = $cnt->searchKeywords($keywords, $this->query);
     }
     $expr = $this->query->expr();
     $this->query->andWhere(call_user_func_array([$expr, 'orX'], $expressions));
     $this->query->setParameter('keywords', '%' . $keywords . '%');
 }
Ejemplo n.º 10
0
 public function delete($akID = null)
 {
     $key = UserKey::getByID($akID);
     $this->executeDelete($key, \URL::to('/dashboard/users/attributes', 'view'));
 }
Ejemplo n.º 11
0
 public function renderUserField($handle)
 {
     $u = new User();
     $ui = UserInfo::getByID($u->getUserID());
     $fieldValue = false;
     $field = AttributeUserKey::getByHandle($handle);
     if ($u->isLoggedIn()) {
         $fieldValue = $ui->getAttributeValueObject($field);
     }
     print $field->render('form', $fieldValue, true);
 }
Ejemplo n.º 12
0
 public function setPropertiesFromArray($arr)
 {
     return parent::setPropertiesFromArray($arr);
 }
Ejemplo n.º 13
0
 /**
  * @param string|\Concrete\Core\Entity\Attribute\Key\UserKey $ak
  * @param bool $createIfNotExists
  * @return bool|UserValue
  */
 public function getAttributeValueObject($ak, $createIfNotExists = false)
 {
     if (!is_object($ak)) {
         $ak = UserKey::getByHandle($ak);
     }
     $value = false;
     if (is_object($ak)) {
         $value = $this->getObjectAttributeCategory()->getAttributeValue($ak, $this->entity);
     }
     if ($value) {
         return $value;
     } elseif ($createIfNotExists) {
         $attributeValue = new UserValue();
         $attributeValue->setUser($this->entity);
         $attributeValue->setAttributeKey($ak);
         return $attributeValue;
     }
     return false;
 }
Ejemplo n.º 14
0
 public function install_pb_user_attributes($pkg)
 {
     $euku = AttributeKeyCategory::getByHandle('user');
     $euku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_MULTIPLE);
     $uset = $euku->addSet('author_info', t('Author Info'), $pkg);
     $texta = AttributeType::getByHandle('textarea');
     $sbbio = UserAttributeKey::getByHandle('user_bio');
     if (!is_object($sbbio)) {
         UserAttributeKey::add($texta, array('akHandle' => 'user_bio', 'akName' => t('About the author'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => true, 'uakRegisterEdit' => true, 'uakProfileEditRequired' => true, 'akCheckedByDefault' => true, 'displayOrder' => '3'), $pkg)->setAttributeSet($uset);
     }
     $textt = AttributeType::getByHandle('text');
     $sbname = UserAttributeKey::getByHandle('first_name');
     if (!is_object($sbname)) {
         UserAttributeKey::add($textt, array('akHandle' => 'first_name', 'akName' => t('First Name'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => true, 'uakRegisterEdit' => true, 'uakProfileEditRequired' => true, 'akCheckedByDefault' => true, 'displayOrder' => '1'), $pkg)->setAttributeSet($uset);
     }
     $sblname = UserAttributeKey::getByHandle('last_name');
     if (!is_object($sblname)) {
         UserAttributeKey::add($textt, array('akHandle' => 'last_name', 'akName' => t('Last Name'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => true, 'uakRegisterEdit' => true, 'uakProfileEditRequired' => true, 'akCheckedByDefault' => true, 'displayOrder' => '2'), $pkg)->setAttributeSet($uset);
     }
     /**
      *  To Do:  rework and add back at later date.
      *  Permissions can be manual for the time being.
      */
     //        $group = Group::getByName('ProBlog Editor');
     //        if (!$group || $group->getGroupID() < 1) {
     //            $group = Group::add('ProBlog Editor','Can create and edit Blog posts');
     //        }
     //
     //        $pk = PermissionKey::getByHandle('problog_post');
     //        if (!$pk || $pk->getPermissionKeyID() < 1) {
     //            $pk = AdminPermissionKey::add('admin','problog_post',t('Create Blog Posts'),t('User can use ProBlog frontend features.'),true,false,$pkg);
     //        }
     //
     //        $pe = GroupPermissionAccessEntity::getOrCreate($group);
     //
     //        $pa = AdminPermissionAccess::create($pk);
     //
     //        $pka = new PermissionAssignment();
     //        $pka->setPermissionKeyObject($pk);
     //        $pka->assignPermissionAccess($pa);
     //
     //        $pa->addListItem($pe, false, 10);
     //
     //        $agroup = Group::getByName('ProBlog Approver');
     //        if (!$agroup || $group->getGroupID() < 1) {
     //            $agroup = Group::add('ProBlog Approver','Can Approve Blog posts');
     //        }
     //
     //        $apk = PermissionKey::getByHandle('problog_approve');
     //        if (!$apk || $apk->getPermissionKeyID() < 1) {
     //            $apk = AdminPermissionKey::add('admin','problog_approve',t('Approve Blog Posts'),t('User can Approve ProBlog posts.'),true,false,$pkg);
     //        }
     //
     //        $ape = GroupPermissionAccessEntity::getOrCreate($agroup);
     //
     //        $apa = AdminPermissionAccess::create($apk);
     //
     //        $apka = new PermissionAssignment();
     //        $apka->setPermissionKeyObject($apk);
     //        $apka->assignPermissionAccess($apa);
     //
     //        $apa->addListItem($ape, false, 10); //add approver
     //        $pa->addListItem($ape, false, 10); //append approver to edit
 }