public function __construct(a\Asset $a)
 {
     if ($a == NULL) {
         throw new e\TestException("The asset is NULL.");
     }
     $this->asset = $a;
     $this->service = $a->getService();
     $this->cascade = new a\Cascade($this->service);
 }
 public function setAsset(Asset $asset)
 {
     $property = $this->getProperty();
     $property->referencedAssetId = $asset->getId();
     $property->referencedAssetPath = $asset->getPath();
     $property->referencedAssetType = $asset->getType();
     $asset = new \stdClass();
     $asset->{$p = $this->getPropertyName()} = $property;
     // edit asset
     $service = $this->getService();
     $service->edit($asset);
     if (!$service->isSuccessful()) {
         throw new e\EditingFailureException(S_SPAN . c\M::EDIT_ASSET_FAILURE . E_SPAN . $service->getMessage());
     }
     return $this->reloadProperty();
 }
 public function getFormat()
 {
     if (isset($this->getProperty()->formatId)) {
         return Asset::getAsset($this->getService(), XsltFormat::TYPE, $this->getProperty()->formatId);
     }
     return NULL;
 }
 public function getFormat()
 {
     if (isset($this->format_id) && $this->format_id != "" && isset($this->service)) {
         if (self::DEBUG) {
             u\DebugUtility::out(__FUNCTION__ . BR . "Type of format: " . $this->getType($this->format_id) . BR . "Format ID: " . $this->format_id);
         }
         return a\Asset::getAsset($this->service, $this->getType($this->format_id), $this->format_id);
     }
     return NULL;
 }
 public function getAsset(aohs\AssetOperationHandlerService $service)
 {
     if ($service == NULL) {
         throw new e\NullServiceException(c\M::NULL_SERVICE);
     }
     if (isset($this->id)) {
         return a\Asset::getAsset($service, $this->type, $this->id);
     } else {
         return a\Asset::getAsset($service, $this->type, $this->path->getPath(), $this->path->getSiteName());
     }
 }
 public function getParentContainer()
 {
     if ($this->getType() == c\T::SITE) {
         throw new e\WrongAssetTypeException(c\M::SITE_NO_PARENT_CONTAINER);
     }
     if ($this->getParentContainerId() != NULL) {
         $parent_id = $this->getParentContainerId();
         $parent_type = c\T::$type_parent_type_map[$this->getType()];
         return Asset::getAsset($this->getService(), $parent_type, $parent_id);
     }
     return NULL;
 }
 public function __construct(aohs\AssetOperationHandlerService $service, \stdClass $identifier)
 {
     parent::__construct($service, $identifier);
     if (isset($this->getProperty()->globalAbilities)) {
         $this->global_abilities = new p\GlobalAbilities($this->getProperty()->globalAbilities);
     } else {
         $this->global_abilities = NULL;
     }
     if (isset($this->getProperty()->siteAbilities)) {
         $this->site_abilities = new p\SiteAbilities($this->getProperty()->siteAbilities);
     } else {
         $this->site_abilities = NULL;
     }
 }
 public function __construct(\stdClass $cctl = NULL, aohs\AssetOperationHandlerService $service = NULL, $data1 = NULL, $data2 = NULL, $data3 = NULL)
 {
     if (isset($cctl)) {
         $this->content_type_id = $cctl->contentTypeId;
         $this->content_type_path = $cctl->contentTypePath;
         $this->page_configuration_id = $cctl->pageConfigurationId;
         $this->page_configuration_name = $cctl->pageConfigurationName;
         if (isset($service)) {
             $this->metadata_set = a\Asset::getAsset($service, a\ContentType::TYPE, $this->content_type_id)->getMetadataSet();
         }
         $this->connector_content_type_link_params = array();
         if (isset($cctl->connectorContentTypeLinkParams) && isset($cctl->connectorContentTypeLinkParams->connectorContentTypeLinkParam)) {
             $params = $cctl->connectorContentTypeLinkParams->connectorContentTypeLinkParam;
             if (!is_array($params)) {
                 $params = array($params);
             }
             foreach ($params as $param) {
                 $this->connector_content_type_link_params[] = new ConnectorContentTypeLinkParameter($param);
             }
         }
     }
 }
 public function getContentType()
 {
     $service = $this->getService();
     return Asset::getAsset($service, ContentType::TYPE, $this->getProperty()->contentTypeId);
 }
require_once 'cascade_ws_ns/auth_chanw.php';
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
$mode = 'all';
//$mode = 'display';
//$mode = 'dump';
//$mode = 'get';
//$mode = 'raw';
try {
    $id = "980a826b8b7f0856015997e424411695";
    // Connectors
    $cc = a\Asset::getAsset($service, a\ConnectorContainer::TYPE, $id);
    switch ($mode) {
        case 'all':
        case 'display':
            $cc->display();
            if ($mode != 'all') {
                break;
            }
        case 'dump':
            $cc->dump(true);
            if ($mode != 'all') {
                break;
            }
        case 'get':
            echo c\L::ID . $cc->getId() . BR . c\L::NAME . $cc->getName() . BR . c\L::PATH . $cc->getPath() . BR . c\L::PROPERTY_NAME . $cc->getPropertyName() . BR . c\L::SITE_NAME . $cc->getSiteName() . BR . c\L::TYPE . $cc->getType() . BR . "";
            $children = $cc->getChildren();
     echo E_PRE;
     echo BR . S_PRE;
     var_dump($ps->getPagePaths());
     echo E_PRE;
     if ($mode != 'all') {
         break;
     }
 case 'add':
     // reference
     $ps->addPage(a\Asset::getAsset($service, a\Page::TYPE, '08d27c2a8b7f08560139425c13e5ce17'))->addFile(a\Asset::getAsset($service, a\File::TYPE, '05ce824d8b7f08560139425c9aba7f6d'))->addFolder(a\Asset::getAsset($service, a\Folder::TYPE, 'b8bf838f8b7f0856002a5e11586fba90'))->addFolder(a\Asset::getAsset($service, a\Folder::TYPE, 'df9aa6628b7f085600adcd8159dd733a'))->edit();
     if ($mode != 'all') {
         break;
     }
 case 'remove':
     // test.css
     $ps->removeFile(a\Asset::getAsset($service, a\File::TYPE, '05ce824d8b7f08560139425c9aba7f6d'))->removeFolder(a\Asset::getAsset($service, a\Folder::TYPE, 'df9aa6628b7f085600adcd8159dd733a'))->edit();
     if ($mode != 'all') {
         break;
     }
 case 'set':
     // case 1: remove schedule
     //$ps->unsetScheduledPublishing()->edit();
     //$ps->setScheduledPublishing( false )->edit();
     // case 2: exception thrown, additional value is required
     //$ps->setScheduledPublishing( true )->edit();
     // case 3a: every Friday at 12 am
     //$ps->setScheduledPublishing( true, a\PublishSet::FRIDAY )->edit();
     // case 3b: every Monday at 6:30 pm
     //$ps->setDayOfWeek( a\PublishSet::MONDAY, '18:30:00.000' )->edit();
     // case 3c: every Tuesday at 3 am
     /*
     // case 7b: cron expression
     //$s->setCronExpression( "0 4 12 * * ?" )->edit();
     if ($mode != 'all') {
         break;
     }
 case 'assignment':
     $r = $cascade->getAsset(a\Role::TYPE, 50);
     // site publisher
     $s->addRole($r)->edit();
     $s->addUserToRole($r, $cascade->getAsset(a\User::TYPE, 'chanw'))->addUserToRole($r, $cascade->getAsset(a\User::TYPE, 'tuw'))->addGroupToRole($r, $cascade->getAsset(a\Group::TYPE, 'cru'))->edit();
     //$s->removeRole( $r )->edit();
     if ($mode != 'all') {
         break;
     }
 case 'set':
     $s->setUrl('http://www.upstate.edu/tuw-test')->setDefaultMetadataSet(a\Asset::getAsset($service, a\MetadataSet::TYPE, 'b893fd058b7f0856002a5e11185ff809'))->setCssFile(NULL)->setSiteAssetFactoryContainer(a\Asset::getAsset($service, a\AssetFactoryContainer::TYPE, '04af3e2e8b7f085600e28886d7e2221d'))->setStartingPage(a\Asset::getAsset($service, a\Page::TYPE, '04af1d7a8b7f085600e28886865346c3'))->setSendReportOnErrorOnly(true)->addUserToSendReport(a\Asset::getAsset($service, a\User::TYPE, 'tuw'))->addGroupToSendReport(a\Asset::getAsset($service, a\Group::TYPE, 'hemonc'))->setRecycleBinExpiration(a\Site::NEVER)->edit();
     if ($mode != 'all') {
         break;
     }
 case 'publish':
     //$s->publish();
     if ($mode != 'all') {
         break;
     }
 case 'asset-tree':
     echo S_PRE . u\XMLUtility::replaceBrackets($s->getRootAssetFactoryContainerAssetTree()->toXml()) . E_PRE;
     if ($mode != 'all') {
         break;
     }
 case 'raw':
     $s_std = $service->retrieve($service->createId(c\T::SITE, $id), c\P::SITE);
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
$mode = 'none';
//$mode = 'all';
//$mode = 'copy';
//$mode = 'display';
//$mode = 'dump';
//$mode = 'edit';
//$mode = 'getAudits';
//$mode = 'get';
//$mode = 'publishSubscribers';
try {
    $page_id = "824b63c68b7ffe830539acf09bc3135b";
    // test static method
    $page = a\Asset::getAsset($service, a\Page::TYPE, $page_id);
    //->dump();
    // static method can still be called through an object
    $folder = $page->getAsset($service, a\Folder::TYPE, "3890910f8b7ffe83164c93144ce01dbd")->dump();
    switch ($mode) {
        case 'all':
        case 'copy':
            $page->copy($cascade->getAsset(a\Folder::TYPE, "3890a3f88b7ffe83164c931457a2709c"), "test-asset");
            if ($mode != 'all') {
                break;
            }
        case 'display':
            $page->display();
            if ($mode != 'all') {
                break;
            }
 public function getPageConfigurationTemplate($name)
 {
     $this->checkPageConfiguration($name);
     $count = $this->page_configurations;
     for ($i = 0; $i < $count; $i++) {
         if ($this->page_configurations[$i]->getName() == $name) {
             $id = $this->page_configurations[$i]->getTemplateId();
             return Asset::getAsset($this->getService(), Template::TYPE, $id);
         }
     }
 }
 public function setInheritWorkflows($bool)
 {
     if (!c\BooleanValues::isBoolean($bool)) {
         throw new e\UnacceptableValueException(S_SPAN . "The value {$bool} must be a boolean." . E_SPAN);
     }
     // already set
     if ($this->inherit_workflows == $bool) {
         return $this;
     }
     if ($bool) {
         $this->inherit_workflows = $bool;
         $folder_id = $this->identifier->getId();
         $folder = a\Asset::getAsset($this->service, a\Folder::TYPE, $folder_id);
         $parent = $folder->getParentContainer();
         if (isset($parent)) {
             $parent_settings = $parent->getWorkflowSettings();
             $parent_wds = $parent_settings->getWorkflowDefinitions();
             if (is_array($parent_wds) && count($parent_wds) > 0) {
                 foreach ($parent_wds as $parent_wd) {
                     $this->inherited_workflow_definitions[] = $parent_wd;
                 }
             }
         }
     } else {
         $this->unsetInheritWorkflows();
     }
     return $this;
 }
 public function getTemplate()
 {
     if ($this->service == NULL) {
         throw new e\NullServiceException(S_SPAN . c\M::NULL_SERVICE . E_SPAN);
     }
     return a\Asset::getAsset($this->service, a\Template::TYPE, $this->template_id);
 }
 public function copy(Container $parent, $new_name)
 {
     if ($new_name == "") {
         throw new e\EmptyNameException(c\M::EMPTY_NAME);
     }
     $service = $this->getService();
     $self_identifier = $service->createId($this->getType(), $this->getId());
     $service->copy($self_identifier, $parent->getIdentifier(), $new_name, false);
     if ($service->isSuccessful()) {
         $parent->reloadProperty();
         // get info of new child
         $parent = $parent->getProperty();
         $children = $parent->children->child;
         $child_count = count($children);
         if ($child_count == 1) {
             $children = array($children);
         }
         // look for the new child
         foreach ($children as $child) {
             $child_path = $child->path->path;
             $child_path_array = explode('/', $child_path);
             if (in_array($new_name, $child_path_array)) {
                 $child_found = $child;
                 break;
             }
         }
         // get the digital id of child
         $child_id = $child_found->id;
         // return new block object
         return Asset::getAsset($service, $this->getType(), $child_id);
     } else {
         throw new e\CopyErrorException(c\M::COPY_ASSET_FAILURE . $service->getMessage());
     }
 }
require_once 'cascade_ws_ns/auth_chanw.php';
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
$mode = 'all';
//$mode = 'display';
//$mode = 'dump';
//$mode = 'get';
//$mode = 'raw';
try {
    //$id  = "fd276cfc8b7f08560159f3f0db454558"; // root
    $id = "54b505c28b7f085600ae2282a4b7ed71";
    // test
    $ctc = a\Asset::getAsset($service, a\ContentTypeContainer::TYPE, $id);
    switch ($mode) {
        case 'all':
        case 'display':
            $ctc->display();
            if ($mode != 'all') {
                break;
            }
        case 'dump':
            $ctc->dump(true);
            if ($mode != 'all') {
                break;
            }
        case 'get':
            echo c\L::ID . $ctc->getId() . BR . c\L::NAME . $ctc->getName() . R . c\L::PATH . $ctc->getPath() . BR . c\L::PROPERTY_NAME . $ctc->getPropertyName() . BR . c\L::SITE_NAME . $ctc->getSiteName() . BR . c\L::TYPE . $ctc->getType() . BR . "";
            $children = $ctc->getChildren();
 private function setAccess(a\Asset $a, $level)
 {
     $type = $a->getType();
     if ($type != c\T::USER && $type != c\T::GROUP) {
         throw new e\WrongAssetTypeException(c\M::ACCESS_TO_USERS_GROUPS);
     }
     if (!c\LevelValues::isLevel($level)) {
         throw new e\UnacceptableValueException("The level {$level} is unacceptable.");
     }
     $entry = $this->getEntry($a);
     // not exist
     if ($entry == NULL) {
         $entry_std = new \stdClass();
         $entry_std->level = $level;
         $entry_std->type = $a->getType();
         $entry_std->name = $a->getName();
         $this->acl_entries[] = new AclEntry($entry_std);
     } else {
         $entry->setLevel($level);
     }
 }
 public static function setMetadataSet(Cascade $target_cascade, Site $source_site, Site $target_site, Asset $source_asset, Asset $target_asset, $exception_thrown = true)
 {
     // get metadata set
     $source_ms = $source_asset->getMetadataSet();
     $source_ms_path = u\StringUtility::removeSiteNameFromPath($source_ms->getPath());
     $source_ms_site = $source_ms->getSiteName();
     $target_ms_site = $source_ms_site;
     if ($exception_thrown) {
         try {
             $ms = $target_cascade->getAsset(MetadataSet::TYPE, $source_ms_path, $target_ms_site);
             $target_asset->setMetadataSet($ms);
         } catch (\Exception $e) {
             $msg = "The metadata set {$source_ms_path} does not exist in {$target_ms_site}. ";
             throw new e\CascadeInstancesErrorException(S_SPAN . $msg . E_SPAN . $e);
         }
     } else {
         $ms = $target_cascade->getMetadataSet($source_ms_path, $target_ms_site);
         if (isset($ms)) {
             $target_asset->setMetadataSet($ms);
         }
     }
     // set metadata
     if (isset($ms)) {
         try {
             $m = $source_asset->getMetadata();
             $target_asset->setMetadata($m);
             $source_metadata = $source_asset->getMetadata();
             $target_metadata = $target_asset->getMetadata();
             $target_metadata->setAuthor($source_metadata->getAuthor())->setDisplayName($source_metadata->getDisplayName())->setEndDate($source_metadata->getEndDate())->setKeywords($source_metadata->getKeywords())->setMetaDescription($source_metadata->getMetaDescription())->setReviewDate($source_metadata->getReviewDate())->setStartDate($source_metadata->getStartDate())->setSummary($source_metadata->getSummary())->setTeaser($source_metadata->getTeaser())->setTitle($source_metadata->getTitle());
             $fields = $source_metadata->getDynamicFieldNames();
             $count = count($fields);
             if ($count > 0) {
                 foreach ($fields as $field) {
                     $target_metadata->setDynamicField($field, $source_metadata->getDynamicFieldValues($field));
                 }
             }
             $target_asset->edit();
         } catch (\Exception $e) {
             throw new e\CascadeInstancesErrorException($e . BR . S_SPAN . "Path: " . $source_asset->getPath() . E_SPAN);
         }
     }
 }
function setSitePermissions(a\Cascade $cascade, $new_name)
{
    // set group abilities
    $new_group = $cascade->getAsset(a\Group::TYPE, $new_name);
    $new_group->setWysiwygAllowFontFormatting(true)->setWysiwygAllowTextFormatting(true)->setWysiwygAllowImageInsertion(true)->setWysiwygAllowTableInsertion(true)->setWysiwygAllowFontAssignment(false)->setWysiwygAllowViewSource(false)->edit();
    // the web team designers
    $cwt = "CWT-Designers";
    $applied_to_children = true;
    $not_applied_to_children = false;
    $cascade_path = "/_cascade";
    $cascade_blocks_path = $cascade_path . "/blocks";
    $cascade_blocks_data_path = $cascade_blocks_path . "/data";
    $cascade_blocks_upstate_path = $cascade_blocks_path . "/upstate";
    $extra_path = "/_extra";
    $links_path = "/_links";
    $right_column_path = "/_right-column";
    $footer_contact_path = "/_footer-contact";
    $site_info_path = "/_site-info";
    $asset_factory_container_path = "/Upstate";
    $htaccess_path = "/tmp.htaccess";
    setAccessRightsForAssetForAllLevel($cascade, a\Folder::TYPE, c\T::ROOT_PATH, $new_name, c\T::READ, $applied_to_children);
    // step 1: Base Folder
    // cwt: write
    setAccessRightsForAsset($cascade, a\Folder::TYPE, c\T::ROOT_PATH, $new_name, a\Group::TYPE, $cwt, c\T::WRITE, $applied_to_children);
    // new group: write
    setAccessRightsForAsset($cascade, a\Folder::TYPE, c\T::ROOT_PATH, $new_name, a\Group::TYPE, $new_name, c\T::WRITE, $applied_to_children, c\T::READ);
    // step 2: _cascade and sub-folders
    // cwt: write
    setAccessRightsForAsset($cascade, a\Folder::TYPE, $cascade_path, $new_name, a\Group::TYPE, $cwt, c\T::WRITE, $applied_to_children);
    // new group: read, all: read
    setAccessRightsForAsset($cascade, a\Folder::TYPE, $cascade_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $applied_to_children, c\T::READ);
    // the blocks folder
    // all: none
    setAccessRightsForAssetForAllLevel($cascade, a\Folder::TYPE, $cascade_blocks_path, $new_name, c\T::NONE, $applied_to_children);
    // the data folder
    // cwt: write
    setAccessRightsForAsset($cascade, a\Folder::TYPE, $cascade_blocks_data_path, $new_name, a\Group::TYPE, $cwt, c\T::WRITE, $applied_to_children);
    // new group: read
    setAccessRightsForAsset($cascade, a\Folder::TYPE, $cascade_blocks_data_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $applied_to_children);
    // step 3:
    // _extra
    // no groups can access _extra
    removeAccessRightsFromAllGroupsForAsset($cascade, a\Folder::TYPE, $extra_path, $new_name, $applied_to_children);
    // _links
    // cwt: write, new group: read, all: none
    setAccessRightsForAsset($cascade, a\Folder::TYPE, $links_path, $new_name, a\Group::TYPE, $cwt, c\T::WRITE, $applied_to_children);
    setAccessRightsForAsset($cascade, a\Folder::TYPE, $links_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $applied_to_children, c\T::NONE);
    // step 4: 3 configuration blocks
    // new group: read, all: none
    setAccessRightsForAsset($cascade, a\DataBlock::TYPE, $right_column_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $not_applied_to_children, c\T::NONE);
    setAccessRightsForAsset($cascade, a\DataBlock::TYPE, $footer_contact_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $not_applied_to_children, c\T::NONE);
    setAccessRightsForAsset($cascade, a\DataBlock::TYPE, $site_info_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $not_applied_to_children, c\T::NONE);
    // step 5: Base Folder again
    // new group: read, all: read
    setAccessRightsForAsset($cascade, a\Folder::TYPE, c\T::ROOT_PATH, $new_name, a\Group::TYPE, $new_name, c\T::READ, $not_applied_to_children, c\T::READ);
    // step 6: asset factories
    setAvailableToGroupsForAssetFactoryContainer($cascade, $new_name);
    // step 7: tmp.htaccess
    $file = $cascade->getFile($htaccess_path, $new_name);
    if ($file != NULL) {
        $ari = $cascade->getAccessRights(a\File::TYPE, $htaccess_path, $new_name);
        $ari->addGroupReadAccess(a\Asset::getAsset($cascade->getService(), a\Group::TYPE, $cwt));
        $ari->addGroupReadAccess(a\Asset::getAsset($cascade->getService(), a\Group::TYPE, $new_name));
        $ari->setAllLevel(c\T::NONE);
        $cascade->setAccessRights($ari, $not_applied_to_children);
    }
}
                 // existing content type, new config
                 $tc->addContentTypeLink( 
                     a\Asset::getAsset( 
                         $service, 
                         a\ContentType::TYPE,
                         'dd46b9bc8b7f085600a0fcdc2fdf8b99' ), 
                     'Desktop' );
                 // new content type
                 $tc->addContentTypeLink( 
                     a\Asset::getAsset( 
                         $service, 
                         a\ContentType::TYPE,
                         'bd6f4eaa8b7f0856002a5e117e02a456' ), 
                     'Mobile' )->edit();
     */
     $tc->removeContentTypeLink(a\Asset::getAsset($service, a\ContentType::TYPE, 'bd6f4eaa8b7f0856002a5e117e02a456'))->edit();
     // case 1: both empty
     //$tc->setHashTags( '' )->setPrefix( '' )->edit();
     // case 2: tags only
     //$tc->setHashTags( 'this' )->setPrefix( '' )->edit();
     // case 3: prefix only
     //$tc->setHashTags( '' )->setPrefix( 'one' )->edit();
     // case 4:  both
     //$tc->setHashTags( 'all' )->setPrefix( 'two' )->edit();
     if ($mode != 'all') {
         break;
     }
 case 'raw':
     $tc_std = $service->retrieve($service->createId(c\T::TWITTERCONNECTOR, '03276c068b7f08560150c2965239b3ee'), c\P::TWITTERCONNECTOR);
     echo S_PRE;
     var_dump($tc_std);
 public function setBaseAsset(Asset $a = NULL)
 {
     if (isset($a)) {
         $type = $a->getType();
         if (u\StringUtility::startsWith(strtolower($type), 'block')) {
             $type = 'block';
         } else {
             if (u\StringUtility::startsWith(strtolower($type), 'format')) {
                 $type = 'format';
             }
         }
         $this->getProperty()->assetType = $type;
         $this->getProperty()->baseAssetId = $a->getId();
         $this->getProperty()->baseAssetPath = $a->getPath();
     } else {
         $this->getProperty()->assetType = File::TYPE;
         // dummpy type
         $this->getProperty()->baseAssetId = NULL;
         $this->getProperty()->baseAssetPath = NULL;
     }
     return $this;
 }
 public function setDynamicFieldValue($field, $values)
 {
     if (!is_array($values)) {
         $values = array($values);
     }
     $v_count = count($values);
     if ($this->metadata_set == NULL) {
         $this->metadata_set = a\Asset::getAsset($this->service, a\MetadataSet::TYPE, $this->metadata_set_id);
     }
     $df_def = $this->metadata_set->getDynamicMetadataFieldDefinition($field);
     $field_type = $df_def->getFieldType();
     $required = $df_def->getRequired();
     $df = $this->getDynamicField($field);
     // text can accept anything
     if ($field_type == c\T::TEXT && $v_count == 1) {
         $value = $values[0];
         if ($value == NULL) {
             // turn NULL to empty string
             $value = '';
         }
         if ($required && $value == '') {
             throw new e\RequiredFieldException(S_SPAN . "The {$field_type} requires non-empty value" . E_SPAN);
         }
         $v = new \stdClass();
         $v->value = $value;
         $df->setValue(array($v));
     } else {
         if (($field_type == c\T::RADIO || $field_type == c\T::DROPDOWN) && $v_count == 1) {
             $value = $values[0];
             // read first value
             if ($value == '') {
                 // turn empty string to NULL
                 $value = NULL;
             }
             if ($required && $value == NULL) {
                 // cannot be empty if required
                 throw new e\RequiredFieldException(S_SPAN . "The {$field_type} requires non-empty value." . E_SPAN);
             }
             $possible_values = $df_def->getPossibleValueStrings();
             // read from metadataSet
             if (!in_array($value, $possible_values) && isset($value)) {
                 // undefined value
                 throw new e\NoSuchValueException(S_SPAN . "The value {$value} does not exist." . E_SPAN);
             }
             $v = new \stdClass();
             if ($value != '') {
                 $v->value = $value;
             }
             $df->setValue(array($v));
         } else {
             if (($field_type == c\T::CHECKBOX || $field_type == c\T::MULTISELECT) && $v_count > 0) {
                 if (self::DEBUG) {
                     u\DebugUtility::out('Setting values for checkbox or multiselect');
                 }
                 if ($required && (in_array(NULL, $values) || in_array('', $values))) {
                     throw new e\RequiredFieldException(S_SPAN . "The {$field_type} requires non-empty value." . E_SPAN);
                 }
                 $possible_values = $df_def->getPossibleValueStrings();
                 foreach ($values as $value) {
                     if (self::DEBUG) {
                         u\DebugUtility::out("Value: {$value}");
                     }
                     if (!in_array($value, $possible_values) && isset($value)) {
                         throw new e\NoSuchValueException(S_SPAN . "The value {$value} does not exist." . E_SPAN);
                     }
                 }
                 $v_array = array();
                 foreach ($values as $value) {
                     $v = new \stdClass();
                     $v->value = $value;
                     $v_array[] = $v;
                 }
                 $df->setValue($v_array);
                 if (self::DEBUG && self::DUMP) {
                     u\DebugUtility::dump($df->toStdClass());
                 }
             }
         }
     }
     //if( self::DEBUG && self::DUMP ){ u\DebugUtility::dump( $this ); }
     return $this;
 }
Example #25
0
 public function leaveGroup(Group $g)
 {
     $g->removeUser(Asset::getAsset($this->getService(), User::TYPE, $this->getProperty()->username))->edit();
     return $this;
 }
 public function getPageConfigurationSet()
 {
     $service = $this->getService();
     return Asset::getAsset($service, PageConfigurationSet::TYPE, $this->getProperty()->pageConfigurationSetId);
 }
 private function getPath(Asset $parent = NULL, $name = "")
 {
     if ($parent == NULL || $parent->getPath() == "/") {
         $path = $name;
     } else {
         $path = $parent->getPath() . '/' . $name;
     }
     return $path;
 }
     if ($mode != 'all') {
         break;
     }
 case 'get':
     echo c\L::ID . $af->getId() . BR . c\L::NAME . $af->getName() . BR . c\L::PATH . $af->getPath() . BR . c\L::PROPERTY_NAME . $af->getPropertyName() . BR . c\L::SITE_NAME . $af->getSiteName() . BR . c\L::TYPE . $af->getType() . BR . "Allow subfolder placement: " . u\StringUtility::boolToString($af->getAllowSubfolderPlacement()) . BR . "Applicable groups: " . u\StringUtility::getCoalescedString($af->getApplicableGroups()) . BR . "Asset type: " . $af->getAssetType() . BR . "Base asset ID: " . u\StringUtility::getCoalescedString($af->getBaseAssetId()) . BR . "Base asset path: " . u\StringUtility::getCoalescedString($af->getBaseAssetPath()) . BR . "Base asset recycled: " . u\StringUtility::boolToString($af->getBaseAssetRecycled()) . BR . "Folder placement position: " . $af->getFolderPlacementPosition() . BR . "Overwrite: " . u\StringUtility::boolToString($af->getOverwrite()) . BR . c\L::PARENT_CONTAINER_ID . $af->getParentContainerId() . BR . c\L::PARENT_CONTAINER_PATH . $af->getParentContainerPath() . BR . "Placement folder ID: " . u\StringUtility::getCoalescedString($af->getPlacementFolderId()) . BR . "Placement folder path: " . u\StringUtility::getCoalescedString($af->getPlacementFolderPath()) . BR . "Placement folder recycled: " . u\StringUtility::boolToString($af->getPlacementFolderRecycled()) . BR . c\L::SITE_ID . $af->getSiteId() . BR . c\L::SITE_NAME . $af->getSiteName() . BR . "Workflow definition ID: " . u\StringUtility::getCoalescedString($af->getWorkflowDefinitionId()) . BR . "Workflow definition path: " . u\StringUtility::getCoalescedString($af->getWorkflowDefinitionPath()) . BR . "Workflow mode: " . $af->getWorkflowMode() . BR;
     if ($af->hasPlugin(a\AssetFactory::FILE_LIMIT_PLUGIN)) {
         u\DebugUtility::dump($af->getPlugin(a\AssetFactory::FILE_LIMIT_PLUGIN));
     }
     u\DebugUtility::dump($af->getPluginNames());
     u\DebugUtility::dump($af->getPluginStd());
     if ($mode != 'all') {
         break;
     }
 case 'set':
     $group_name = "cru";
     $group = a\Asset::getAsset($service, a\Group::TYPE, $group_name);
     $af->addGroup($group)->edit();
     if ($af->isApplicableToGroup($group)) {
         echo "Applicable to ", $group->getName(), BR;
     } else {
         echo "Not applicable to {$group_name}" . BR;
     }
     $af->removeGroup($group)->edit()->dump(true);
     if ($af->isApplicableToGroup($group)) {
         echo "Applicable to {$group_name}" . BR;
     } else {
         echo "Not applicable to {$group_name}" . BR;
     }
     $af->setAllowSubfolderPlacement(true)->setBaseAsset()->setFolderPlacementPosition(1)->setOverwrite(true)->setPlacementFolder($cascade->getFolder("images", "cascade-admin"))->setWorkflowMode(c\T::NONE)->edit()->dump(true);
     if ($mode != 'all') {
         break;
     if ($mode != 'all') {
         break;
     }
 case 'get':
     echo "ID: " . $fc->getId() . BR . "Name: " . $fc->getName() . BR . "Path: " . $fc->getPath() . BR . "Property name: " . $fc->getPropertyName() . BR . "Site name: " . $fc->getSiteName() . BR . "Type: " . $fc->getType() . BR . "";
     $ct_path = "_common:XML";
     if ($fc->hasContentType($ct_path)) {
         echo "The connector has content type: {$ct_path}." . BR;
     } else {
         echo "The connector does not " . "have content type: {$ct_path}." . BR;
     }
     if ($mode != 'all') {
         break;
     }
 case 'set':
     $fc->setDestination(a\Asset::getAsset($service, a\Destination::TYPE, '980c57e08b7f0856015997e42b380833'))->edit();
     echo $fc->getDestinationPath();
     /*
                 // existing content type, new config
                 $fc->addContentTypeLink( 
                     a\Asset::getAsset( 
                         $service, a\ContentType::TYPE,
                         'dd46b9bc8b7f085600a0fcdc2fdf8b99' ), 
                     'Desktop' );
                 // new content type
                 $fc->addContentTypeLink( 
                     a\Asset::getAsset( 
                         $service, a\ContentType::TYPE,
                         'bd6f4eaa8b7f0856002a5e117e02a456' ), 
                     'Mobile' )->edit();
     */
            //$d->setDayOfWeek( $d->getDaysOfWeek() )->edit();
            // case 6a: every 2 hours starting at 6:15 am
            /*
            $d->setScheduledPublishing( 
                true, NULL, 2, NULL, '06:15:00.000' )->edit();
            */
            // case 6b: every 4 hours
            //$d->setPublishIntervalHours( 4 )->edit();
            // case 7a: cron expression
            /*
            $d->setScheduledPublishing( 
                true, NULL, NULL, "0 0 12 * * ?" )->edit();
            */
            // case 7b: cron expression
            //$d->setCronExpression( "0 4 12 * * ?" )->edit();
            $d->addUserToSendReport(a\Asset::getAsset($service, a\User::TYPE, 'chanw'))->edit();
            if ($mode != 'all') {
                break;
            }
        case 'raw':
            $d = $service->retrieve($service->createId(c\T::DESTINATION, $id), c\P::DESTINATION);
            echo S_PRE;
            var_dump($d);
            echo E_PRE;
            if ($mode != 'all') {
                break;
            }
    }
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
}