public function testGet() { $broker = new APIBroker(AttributesAPITest::API); // Init set $set = new AttributeSet("set"); $attr = new Attribute("attr", 1); $attr->id = AttributesService::createAttribute($attr); $val1 = new AttributeValue("value1"); $val2 = new AttributeValue("value2"); $val1->id = AttributesService::createValue($val1, $attr->id); $val2->id = AttributesService::createValue($val2, $attr->id); $attr->addValue($val1); $attr->addValue($val2); $set->addAttribute($attr); $set->id = AttributesService::createSet($set); // Get it through API $result = $broker->run("get", array("id" => $set->id)); $this->assertEquals(APIResult::STATUS_CALL_OK, $result->status, "Result status check failed"); $content = $result->content; $this->assertNotNull($content, "Content is null"); $this->assertEquals($set->id, $content->id, "Set id mismatch"); $this->assertEquals($set->label, $content->label, "Set label mismatch"); $this->assertTrue(is_array($set->attributes), "Attributes is not an array"); $this->assertEquals(1, count($set->attributes), "Attribute count mismatch"); $readAttr = $content->attributes[0]; $this->assertEquals($attr->id, $readAttr->id, "Attribute id mismatch"); $this->assertEquals($attr->label, $readAttr->label, "Attribute label mismatch"); $this->assertEquals($attr->dispOrder, $readAttr->dispOrder, "Attribute display order mismatch"); $this->assertTrue(is_array($readAttr->values), "Values is not an array"); $this->assertEquals(2, count($readAttr->values)); $this->markTestIncomplete("Check values (order issue?)"); }
public function testConstruct() { $set = new AttributeSet("set"); $this->assertEquals("set", $set->label); $this->assertTrue(is_array($set->attributes)); $this->assertEquals(0, count($set->attributes)); $attr = new Attribute("attr", 1); $set->addAttribute($attr); $this->assertEquals("attr", $attr->label); $this->assertTrue(is_array($attr->values)); $this->assertEquals(0, count($attr->values)); $this->assertEquals(1, $attr->dispOrder); $this->assertEquals(1, count($set->attributes)); $val = new AttributeValue("Value"); $this->assertEquals("Value", $val->value); $attr->addValue($val); $this->assertEquals(1, count($attr->values)); }
public static function getListByPackage($pkg) { $db = Loader::db(); $list = array(); $r = $db->Execute('select asID from AttributeSets where pkgID = ? order by asID asc', array($pkg->getPackageID())); while ($row = $r->FetchRow()) { $list[] = AttributeSet::getByID($row['asID']); } $r->Close(); return $list; }
public function run() { $this->x = new SimpleXMLElement("<concrete5-cif></concrete5-cif>"); $this->x->addAttribute('version', '1.0'); // First, attribute categories AttributeKeyCategory::exportList($this->x); // attribute types AttributeType::exportList($this->x); // then block types BlockTypeList::exportList($this->x); // now attribute keys (including user) AttributeKey::exportList($this->x); // now attribute keys (including user) AttributeSet::exportList($this->x); // now theme PageTheme::exportList($this->x); // now packages PackageList::export($this->x); // permission access entity types PermissionAccessEntityType::exportList($this->x); // now task permissions PermissionKey::exportList($this->x); // workflow types WorkflowType::exportList($this->x); // now jobs Loader::model('job'); Job::exportList($this->x); // now single pages $singlepages = $this->x->addChild("singlepages"); $db = Loader::db(); $r = $db->Execute('select cID from Pages where cFilename is not null and cFilename <> "" and cID not in (select cID from Stacks) order by cID asc'); while ($row = $r->FetchRow()) { $pc = Page::getByID($row['cID'], 'RECENT'); $pc->export($singlepages); } // now page types CollectionType::exportList($this->x); // now stacks/global areas Loader::model('stack/list'); StackList::export($this->x); // now content pages $pages = $this->x->addChild("pages"); $db = Loader::db(); $r = $db->Execute('select Pages.cID from Pages left join ComposerDrafts on Pages.cID = ComposerDrafts.cID where ComposerDrafts.cID is null and cIsTemplate = 0 and cFilename is null or cFilename = "" order by cID asc'); while ($row = $r->FetchRow()) { $pc = Page::getByID($row['cID'], 'RECENT'); $pc->export($pages); } Loader::model("system/captcha/library"); SystemCaptchaLibrary::exportList($this->x); Config::exportList($this->x); }
private static function buildSet($dbSet, $pdo) { $set = AttributeSet::__build($dbSet['ID'], $dbSet['NAME']); $stmt = $pdo->prepare("SELECT * FROM ATTRIBUTEUSE " . "WHERE ATTRIBUTESET_ID = :id"); $stmt->bindParam(":id", $set->id); $stmt->execute(); while ($dbUse = $stmt->fetch()) { $stmtAttr = $pdo->prepare("SELECT * FROM ATTRIBUTE " . "WHERE ID = :id"); $stmtAttr->bindParam(":id", $dbUse['ATTRIBUTE_ID']); $stmtAttr->execute(); while ($dbAttr = $stmtAttr->fetch()) { $attribute = AttributesService::buildDBAttr($dbAttr, $pdo, 0); $attribute->dispOrder = $dbUse['LINENO']; $set->addAttribute($attribute); } } return $set; }
public function exportAll() { $this->x = $this->getXMLRoot(); // First, attribute categories AttributeKeyCategory::exportList($this->x); // attribute types AttributeType::exportList($this->x); // then block types BlockTypeList::exportList($this->x); // now attribute keys (including user) AttributeKey::exportList($this->x); // now attribute keys (including user) AttributeSet::exportList($this->x); // now theme PageTheme::exportList($this->x); // now packages PackageList::export($this->x); // permission access entity types PermissionAccessEntityType::exportList($this->x); // now task permissions PermissionKey::exportList($this->x); // workflow types WorkflowType::exportList($this->x); // now jobs Loader::model('job'); Job::exportList($this->x); // now single pages $singlepages = $this->x->addChild("singlepages"); $db = Loader::db(); $r = $db->Execute('select cID from Pages where cFilename is not null and cFilename <> "" and cID not in (select cID from Stacks) order by cID asc'); while ($row = $r->FetchRow()) { $pc = Page::getByID($row['cID'], 'RECENT'); $pc->export($singlepages); } // now page types CollectionType::exportList($this->x); // now stacks/global areas Loader::model('stack/list'); StackList::export($this->x); $this->exportPages($this->x); Loader::model("system/captcha/library"); SystemCaptchaLibrary::exportList($this->x); Config::exportList($this->x); }
public function getAttributeSets() { $db = Loader::db(); $sets = array(); $r = $db->Execute('select asID from AttributeSetKeys where akID = ?', $this->akID); while ($row = $r->FetchRow()) { $sets[] = AttributeSet::getByID($row['asID']); } return $sets; }
<?php defined('C5_EXECUTE') or die("Access Denied."); $canRead = false; $ch = Page::getByID($_REQUEST['cID']); $path = $ch->getCollectionPath(); if (strpos($path, '/dashboard') === 0) { $cp = new Permissions($ch); if ($cp->canViewPage()) { $canRead = true; } } if (!$canRead) { die(t("Access Denied.")); } // this should be cleaned up.... yeah $db = Loader::db(); // update order of collections Loader::model('user_attributes'); $uats = $_REQUEST['akID_' . $_REQUEST['asID']]; if (is_array($uats)) { $as = AttributeSet::getByID($_REQUEST['asID']); $as->updateAttributesDisplayOrder($uats); }
public static function exportList($xml) { $axml = $xml->addChild('attributesets'); $db = Loader::db(); $r = $db->Execute('select asID from AttributeSets order by asID asc'); $list = array(); while ($row = $r->FetchRow()) { $list[] = AttributeSet::getByID($row['asID']); } foreach ($list as $as) { $as->export($axml); } }
public function addSet($asHandle, $asName, $pkg = false) { if ($this->akCategoryAllowSets > AttributeKeyCategory::ASET_ALLOW_NONE) { $db = Loader::db(); $pkgID = 0; if (is_object($pkg)) { $pkgID = $pkg->getPackageID(); } $db->Execute('insert into AttributeSets (asHandle, asName, akCategoryID, pkgID) values (?, ?, ?, ?)', array($asHandle, $asName, $this->akCategoryID, $pkgID)); $id = $db->Insert_ID(); $as = AttributeSet::getByID($id); return $as; } }
protected function setUp() { // Attribute set $set = new AttributeSet("set"); $attr = new Attribute("attr", 1); $val = new AttributeValue("value"); $attr->id = AttributesService::createAttribute($attr); $val->id = AttributesService::createValue($val, $attr->id); $attr->addValue($val); $set->addAttribute($attr); $set->id = AttributesService::createSet($set); // Product, tax and category $taxCat = new TaxCat("Tax"); $tax = new Tax(null, "Tax", stdtimefstr("2001-01-01 00:00:00"), 0.1); $taxCat->addTax($tax); $taxCat->id = TaxesService::createCat($taxCat); $taxCat2 = new TaxCat("Tax2"); $tax2 = new Tax(null, "Tax2", stdtimefstr("2001-01-01 00:00:00"), 0.2); $taxCat2->addTax($tax2); $taxCat2->id = TaxesService::createCat($taxCat2); $pdo = PDOBuilder::getPDO(); $stmt = $pdo->prepare("INSERT INTO CATEGORIES (ID, NAME) " . "VALUES (:id, :name)"); $stmt->execute(array(":id" => "-1", ":name" => "Refill")); $cat = new Category(null, "Category", false, 1); $cat->id = CategoriesService::createCat($cat); $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, false, 0.5, $set->id); $prd->id = ProductsService::create($prd); $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 1, $taxCat2->id, true, false, 0.5, null); $prd2->id = ProductsService::create($prd2); $prdRefill = new Product("REFILL", "Refill", 1.0, "-1", null, 1, $taxCat->id, true, false); $prdRefill->id = ProductsService::create($prdRefill); // Tariff area $srvArea = new TariffAreasService(); $area = new TariffArea("area", 1); $area->addPrice($prd->id, 0.8); $area->id = $srvArea->create($area); $this->areaId = $area->id; // Customer $srvCust = new CustomersService(); $cust = new Customer(1, "Cust", "It's me", "card", null, null, 50.0, 10.0, 5.0, stdtimefstr("2012-01-01 00:00:00"), "It's", "me", "*****@*****.**", "012345", "23456", "11111", "Address1", "Address2", "59000", "City", "Region", "France", "Note", true); $cust->id = $srvCust->create($cust); $this->custId = $cust->id; // Location $locSrv = new LocationsService(); $loc = new Location("Location"); $loc->id = $locSrv->create($loc); $this->locationId = $loc->id; // Cash register $srvCashReg = new CashRegistersService(); $cashReg = new CashRegister("Cash", $loc->id, 1); $cashReg->id = $srvCashReg->create($cashReg); // Cash $srvCash = new CashesService(); $cash = $srvCash->add($cashReg->id); $cash->openDate = stdtimefstr("2000-02-02 02:02:02"); $srvCash->update($cash); $this->cashId = $cash->id; // User $srvUsers = new UsersService(); $user = new User("User", null, null, "0", true, false); $user->id = $srvUsers->create($user); // Currency $curr = new Currency("Eur", "€", ",", ".", "#,##0.00\$", 1, true, false); $srvCurr = new CurrenciesService(); $curr->id = $srvCurr->create($curr); // Discount profile $profSrv = new DiscountProfilesService(); $prof = new DiscountProfile("Profile", 0.1); $prof->id = $profSrv->create($prof); $this->discountProfilId = $prof->id; // Ticket $tkt1 = array("date" => stdtimefstr("2012-01-01 00:00:00"), "userId" => $user->id, "customerId" => null, "type" => Ticket::TYPE_SELL, "custCount" => 3, "tariffAreaId" => null, "discountRate" => 0.0, "discountProfileId" => null, "payments" => array(array("type" => "cash", "amount" => 10, "currencyId" => $curr->id, "currencyAmount" => 12)), "lines" => array(array("dispOrder" => 1, "productId" => $prd->id, "taxId" => $tax->id, "attributes" => null, "quantity" => 1.0, "price" => 10.0, "discountRate" => 0.0))); $jsAttr = array("attributeSetId" => $set->id, "values" => array(array("id" => $attr->id, "value" => "value"))); $tkt2 = array("date" => stdtimefstr("2012-01-01 00:00:00"), "userId" => $user->id, "customerId" => null, "type" => Ticket::TYPE_SELL, "custCount" => 3, "tariffAreaId" => null, "discountRate" => 0.25, "discountProfileId" => $prof->id, "payments" => array(array("type" => "cash", "amount" => 10, "currencyId" => $curr->id, "currencyAmount" => 12)), "lines" => array(array("dispOrder" => 1, "productId" => $prd->id, "taxId" => $tax->id, "attributes" => $jsAttr, "quantity" => 1.0, "price" => 10.0, "discountRate" => 0.25))); $this->jsTicket1 = json_encode($tkt1); $this->jsTicket2 = json_encode($tkt2); }
private function installAdditionalPageAttributes($pkg) { $bpa = AttributeSet::getByHandle('boilerplate_page_attributes'); // see install page attributes section for syntax }
public function edit($asID = false) { $as = AttributeSet::getByID($asID); if (is_object($as)) { $this->set('set', $as); } else { $this->redirect('/dashboard/system/attributes/sets'); } }
public function addSet($asHandle, $asName, $pkg = false, $asIsLocked = 1) { if ($this->akCategoryAllowSets > AttributeKeyCategory::ASET_ALLOW_NONE) { $db = Loader::db(); $pkgID = 0; if (is_object($pkg)) { $pkgID = $pkg->getPackageID(); } $sets = $db->GetOne('select count(asID) from AttributeSets where akCategoryID = ?', array($this->akCategoryID)); $asDisplayOrder = 0; if ($sets > 0) { $asDisplayOrder = $db->GetOne('select max(asDisplayOrder) from AttributeSets where akCategoryID = ?', array($this->akCategoryID)); $asDisplayOrder++; } $db->Execute('insert into AttributeSets (asHandle, asName, akCategoryID, asIsLocked, asDisplayOrder, pkgID) values (?, ?, ?, ?, ?,?)', array($asHandle, $asName, $this->akCategoryID, $asIsLocked, $asDisplayOrder, $pkgID)); $id = $db->Insert_ID(); $as = AttributeSet::getByID($id); return $as; } }
/** * Returns an array of package items (e.g. blocks, themes) */ public function getPackageItems() { $items = array(); Loader::model('single_page'); Loader::library('mail/importer'); Loader::model('job'); Loader::model('collection_types'); Loader::model('system/captcha/library'); Loader::model('system/antispam/library'); $items['attribute_categories'] = AttributeKeyCategory::getListByPackage($this); $items['attribute_keys'] = AttributeKey::getListByPackage($this); $items['attribute_sets'] = AttributeSet::getListByPackage($this); $items['page_types'] = CollectionType::getListByPackage($this); $items['mail_importers'] = MailImporter::getListByPackage($this); $items['configuration_values'] = Config::getListByPackage($this); $items['block_types'] = BlockTypeList::getByPackage($this); $items['page_themes'] = PageTheme::getListByPackage($this); $tp = new TaskPermissionList(); $items['task_permissions'] = $tp->populatePackagePermissions($this); $items['single_pages'] = SinglePage::getListByPackage($this); $items['attribute_types'] = AttributeType::getListByPackage($this); $items['captcha_libraries'] = SystemCaptchaLibrary::getListByPackage($this); $items['antispam_libraries'] = SystemAntispamLibrary::getListByPackage($this); $items['jobs'] = Job::getListByPackage($this); ksort($items); return $items; }
/** * Returns an array of package items (e.g. blocks, themes) */ public function getPackageItems() { $items = array(); Loader::model('single_page'); Loader::model('dashboard/homepage'); Loader::library('mail/importer'); Loader::model('job'); Loader::model('collection_types'); $items['attribute_categories'] = AttributeKeyCategory::getListByPackage($this); $items['attribute_keys'] = AttributeKey::getListByPackage($this); $items['attribute_sets'] = AttributeSet::getListByPackage($this); $items['page_types'] = CollectionType::getListByPackage($this); $items['mail_importers'] = MailImporter::getListByPackage($this); $items['dashboard_modules'] = DashboardHomepageView::getModules($this); $items['configuration_values'] = Config::getListByPackage($this); $items['block_types'] = BlockTypeList::getByPackage($this); $items['page_themes'] = PageTheme::getListByPackage($this); $tp = new TaskPermissionList(); $items['task_permissions'] = $tp->populatePackagePermissions($this); $items['single_pages'] = SinglePage::getListByPackage($this); $items['attribute_types'] = AttributeType::getListByPackage($this); $items['jobs'] = Job::getListByPackage($this); ksort($items); return $items; }
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $df = Loader::helper('form/date_time'); $form = Loader::helper('form'); $fp = FilePermissions::getGlobal(); $tp = new TaskPermission(); $set = AttributeSet::getByHandle('problog_additional_attributes'); $setAttribs = $set->getAttributeKeys(); $AJAXblogPost = URL::to('/problog/tools/post_blog'); ?> <link rel="stylesheet" type="text/css" href="<?php echo DIR_REL; ?> /concrete/css/redactor.css"></link> <link rel="stylesheet" type="text/css" href="<?php echo DIR_REL; ?> /concrete/css/select2.css"></link> <link rel="stylesheet" type="text/css" href="<?php echo DIR_REL; ?> /concrete/css/file-manager.css"></link> <script type="text/javascript" src="<?php echo DIR_REL; ?> /concrete/js/redactor.js"></script> <script type="text/javascript" src="<?php echo DIR_REL; ?>
protected function setUp() { // Attribute set $set = new AttributeSet("set"); $attr = new Attribute("attr", 1); $val = new AttributeValue("value"); $attr->id = AttributesService::createAttribute($attr); $val->id = AttributesService::createValue($val, $attr->id); $attr->addValue($val); $this->attr = $attr; $set->addAttribute($attr); $set->id = AttributesService::createSet($set); $this->attrSet = $set; // Product, tax and category $taxCat = new TaxCat("Tax"); $tax = new Tax(null, "Tax", stdtimefstr("2001-01-01 00:00:00"), 0.1); $taxCat->addTax($tax); $taxCat->id = TaxesService::createCat($taxCat); $taxCat2 = new TaxCat("Tax2"); $tax2 = new Tax(null, "Tax2", stdtimefstr("2001-01-01 00:00:00"), 0.2); $taxCat2->addTax($tax2); $taxCat2->id = TaxesService::createCat($taxCat2); $this->tax = $taxCat->taxes[0]; $this->tax2 = $taxCat2->taxes[0]; $pdo = PDOBuilder::getPDO(); $stmt = $pdo->prepare("INSERT INTO CATEGORIES (ID, NAME) " . "VALUES (:id, :name)"); $stmt->execute(array(":id" => "-1", ":name" => "Refill")); $cat = new Category(null, "Category", false, 1); $cat->id = CategoriesService::createCat($cat); $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, false, 0.5, $set->id); $prd->id = ProductsService::create($prd); $this->prd = $prd; $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 1, $taxCat2->id, true, false, 0.5, null); $prd2->id = ProductsService::create($prd2); $prdRefill = new Product("REFILL", "Refill", 1.0, "-1", null, 1, $taxCat->id, true, false); $prdRefill->id = ProductsService::create($prdRefill); $this->prd = $prd; $this->prd2 = $prd2; $this->prdRefill = $prdRefill; // Tariff area $srvArea = new TariffAreasService(); $area = new TariffArea("area", 1); $area->addPrice($this->prd->id, 0.8); $area->id = $srvArea->create($area); $this->area = $area; // Discount profile $srvProfile = new DiscountProfilesService(); $profile = new DiscountProfile("Discount profile", 1.0); $profile->id = $srvProfile->create($profile); $this->discountProfile = $profile; // Customer $srvCust = new CustomersService(); $cust = new Customer(1, "Cust", "It's me", "card", null, null, 50.0, 10.0, 5.0, stdtimefstr("2012-01-01 00:00:00"), "It's", "me", "*****@*****.**", "012345", "23456", "11111", "Address1", "Address2", "59000", "City", "Region", "France", "Note", true); $cust->id = $srvCust->create($cust); $this->customer = $cust; // Location $locSrv = new LocationsService(); $loc = new Location("Location"); $loc->id = $locSrv->create($loc); $this->location = $loc; // Cash $srvCashReg = new CashRegistersService(); $cashReg = new CashRegister("CashReg", $loc->id, 1); $cashReg->id = $srvCashReg->create($cashReg); $srvCash = new CashesService(); $cash = $srvCash->add($cashReg->id); $cash->openDate = stdtimefstr("2000-02-02 02:02:02"); $srvCash->update($cash); $this->cash = $cash; // User $srvUsers = new UsersService(); $user = new User("User", null, null, "0", true, false); $user->id = $srvUsers->create($user); $this->user = $user; // Currency $curr = new Currency("Eur", "€", ",", ".", "#,##0.00\$", 1, true, false); $srvCurr = new CurrenciesService(); $curr->id = $srvCurr->create($curr); $this->currency = $curr; }
/** * Returns an array of package items (e.g. blocks, themes) */ public function getPackageItems() { $items = array(); Loader::model('single_page'); Loader::library('mail/importer'); Loader::model('job'); Loader::model('collection_types'); Loader::model('system/captcha/library'); Loader::model('system/antispam/library'); $items['attribute_categories'] = AttributeKeyCategory::getListByPackage($this); $items['permission_categories'] = PermissionKeyCategory::getListByPackage($this); $items['permission_access_entity_types'] = PermissionAccessEntityType::getListByPackage($this); $items['attribute_keys'] = AttributeKey::getListByPackage($this); $items['attribute_sets'] = AttributeSet::getListByPackage($this); $items['group_sets'] = GroupSet::getListByPackage($this); $items['page_types'] = CollectionType::getListByPackage($this); $items['mail_importers'] = MailImporter::getListByPackage($this); $items['configuration_values'] = Config::getListByPackage($this); $items['block_types'] = BlockTypeList::getByPackage($this); $items['page_themes'] = PageTheme::getListByPackage($this); $items['permissions'] = PermissionKey::getListByPackage($this); $items['single_pages'] = SinglePage::getListByPackage($this); $items['attribute_types'] = AttributeType::getListByPackage($this); $items['captcha_libraries'] = SystemCaptchaLibrary::getListByPackage($this); $items['antispam_libraries'] = SystemAntispamLibrary::getListByPackage($this); $items['jobs'] = Job::getListByPackage($this); $items['workflow_types'] = WorkflowType::getListByPackage($this); ksort($items); return $items; }
/** @depends testCreateSet */ public function testDeleteSet() { $set = new AttributeSet("set"); $attr = new Attribute("attr", 1); $attrId = AttributesService::createAttribute($attr); $attr->id = $attrId; $set->addAttribute($attr); $id = AttributesService::createSet($set); $this->assertTrue(AttributesService::deleteSet($id), "Delete failed"); $pdo = PDOBuilder::getPDO(); $sql = "SELECT * FROM ATTRIBUTEUSE"; $stmt = $pdo->prepare($sql); $stmt->execute(); $row = $stmt->fetch(); $this->assertFalse($row, "Something was found in ATTRIBUTEUSE after delete"); $sql = "SELECT * FROM ATTRIBUTESET"; $stmt = $pdo->prepare($sql); $stmt->execute(); $row = $stmt->fetch(); $this->assertFalse($row, "Something was found in ATTRIBUTESET after delete"); }