/** * @param TagTable[] $rows * @param Tags $stream * @param int $output 0: Normal, 1: Raw, 2: Inline, 3: Load , 4: Save * @param UserTable $user * @param UserTable $viewer * @param cbPluginHandler $plugin * @return null|string */ static public function showTags( $rows, $stream, $output, $user, $viewer, $plugin ) { global $_PLUGINS; CBActivity::loadHeaders( $output ); $sourceClean = htmlspecialchars( $stream->source() ); $tags = array(); $return = null; $_PLUGINS->trigger( 'activity_onBeforeDisplayTags', array( &$return, &$rows, $stream, $output ) ); if ( $rows ) foreach ( $rows as $row ) { $rowId = $sourceClean . 'Tag' . (int) $row->get( 'id' ); if ( is_numeric( $row->get( 'user' ) ) ) { $name = CBuser::getInstance( (int) $row->get( 'user' ), false )->getField( 'formatname', null, 'html', 'none', 'list', 0, true ); } else { $name = htmlspecialchars( $row->get( 'user' ) ); } if ( ! $name ) { continue; } $tags[] = '<span id="' . $rowId . '" class="streamTag">' . $name . '</span>'; } if ( $tags ) { $return .= ( ! in_array( $output, array( 1, 4 ) ) ? '<span class="' . $sourceClean . 'Tags streamTags">' : null ); if ( count( $tags ) > 2 ) { $tagOne = array_shift( $tags ); $tagTwo = array_shift( $tags ); $moreTooltip = cbTooltip( null, '<div class="streamTagRow">' . implode( '</div><div class="streamTagRow">', $tags ) . '</div>', null, 'auto', null, null, null, 'data-hascbtooltip="true" data-cbtooltip-position-my="bottom center" data-cbtooltip-position-at="top center" data-cbtooltip-open-event="click" data-cbtooltip-close-event="click unfocus" data-cbtooltip-button-hide="true"' ); $more = '<a href="javascript: void(0);"' . $moreTooltip . '>' . CBTxt::T( 'TAGS_MORE', '%%COUNT%% more', array( '%%COUNT%%' => count( $tags ) ) ) . '</a>'; $return .= CBTxt::T( 'TAGS_MORE_THAN_TWO', '[tag_1], [tag_2], and [more]', array( '[tag_1]' => $tagOne, '[tag_2]' => $tagTwo, '[more]' => $more ) ); } elseif ( count( $tags ) > 1 ) { $return .= CBTxt::T( 'TAGS_TWO', '[tag_1] and [tag_2]', array( '[tag_1]' => $tags[0], '[tag_2]' => $tags[1] ) ); } else { $return .= $tags[0]; } $return .= ( ! in_array( $output, array( 1, 4 ) ) ? '</span>' : null ); } $return .= CBActivity::reloadHeaders( $output ); $_PLUGINS->trigger( 'activity_onAfterDisplayTags', array( &$return, $rows, $stream, $output ) ); return $return; }
/** * @param ActivityTable $row * @param Activity $stream * @param int $output 0: Normal, 1: Raw, 2: Inline, 3: Load, 4: Save * @param UserTable $user * @param UserTable $viewer * @param cbPluginHandler $plugin * @return null|string */ static public function showAttachments( $row, $stream, $output, $user, $viewer, $plugin ) { global $_PLUGINS; if ( ! $stream->get( 'links', 1 ) ) { return null; } $links = $row->attachments(); $_PLUGINS->trigger( 'activity_onDisplayActivityAttachments', array( &$row, &$links, $stream, $output ) ); if ( ! $links ) { return null; } $cbModerator = CBActivity::isModerator( (int) $viewer->get( 'id' ) ); $isStatus = ( ( $row->get( 'type' ) == 'status' ) || ( $row->get( 'subtype' ) == 'status' ) ); $rowOwner = ( $viewer->get( 'id' ) == $row->get( 'user_id' ) ); $count = count( $links ); $return = '<div class="streamItemScroll">' . '<div class="streamItemScrollLeft' . ( $count > 1 ? null : ' hidden' ) . '">' . '<table>' . '<tr>' . '<td>' . '<span class="streamItemScrollLeftIcon fa fa-chevron-left"></span>' . '</td>' . '</tr>' . '</table>' . '</div>'; foreach ( $links as $i => $link ) { $hasMedia = ( ( $link['type'] == 'custom' ) || ( ( $link['type'] != 'url' ) && $link['media']['url'] ) || ( ( $link['type'] == 'url' ) && $link['media']['url'] && $link['thumbnail'] ) ); $return .= '<div class="activityContainerAttachment streamItemScrollContent ' . ( $link['type'] == 'url' ? 'streamMedia media' : 'streamPanel panel' ) . ( $i != 0 ? ' hidden' : null ) . '">'; if ( $hasMedia ) { $return .= '<div class="activityContainerAttachmentMedia ' . ( $link['type'] == 'url' ? 'streamMediaLeft media-left' : 'streamPanelBody panel-body' ) . ' text-center">'; switch ( $link['type'] ) { case 'custom': $return .= $link['media']['custom']; break; case 'video': $return .= '<video width="640" height="360" style="width: 100%; height: 100%;" src="' . htmlspecialchars( $link['media']['url'] ) . '" type="' . htmlspecialchars( $link['media']['mimetype'] ) . '" class="streamItemVideo" preload="none" controls></video>'; break; case 'audio': $return .= '<audio width="640" style="width: 100%;" src="' . htmlspecialchars( $link['media']['url'] ) . '" type="' . htmlspecialchars( $link['media']['mimetype'] ) . '" class="streamItemAudio" preload="none" controls></audio>'; break; case 'image': $return .= '<a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">' . '<img src="' . htmlspecialchars( $link['media']['url'] ) . '" class="img-responsive streamItemImage" />' . '</a>'; break; case 'url': default: $return .= '<a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">' . '<img src="' . htmlspecialchars( $link['media']['url'] ) . '" class="img-responsive streamItemImage" />' . '</a>'; break; } $return .= '</div>'; } if ( $link['title'] || $link['description'] || ( ( ! $link['internal'] ) && ( ( ! $link['title'] ) || $link['text'] ) ) || ( $count > 1 ) ) { $hypertext = ( $link['text'] ? CBTxt::T( $link['text'] ) : $link['url'] ); $return .= '<div class="streamPanelFooter streamItemDisplay activityContainerAttachmentInfo panel-footer' . ( $link['type'] == 'url' ? ' streamMediaBody media-body' : null ) . '">' . '<div class="cbMoreLess">' . '<div class="cbMoreLessContent">' . ( $link['title'] ? '<div><strong><a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">' . ( $isStatus ? htmlspecialchars( CBTxt::T( $link['title'] ) ) : CBTxt::T( $link['title'] ) ) . '</a></strong></div>' : null ) . ( $isStatus ? htmlspecialchars( CBTxt::T( $link['description'] ) ) : CBTxt::T( $link['description'] ) ) . '</div>' . '<div class="activityContainerAttachmentUrl small">' . ( ( ! $link['internal'] ) && ( ( ! $link['title'] ) || $link['text'] ) ? '<a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">' . ( $isStatus ? htmlspecialchars( $hypertext ) : $hypertext ) . '</a>' : null ) . ( $count > 1 ? '<div class="activityContainerAttachmentCount text-muted">' . ( $i + 1 ) . ' - ' . $count . '</div>' : null ) . '</div>' . '<div class="cbMoreLessOpen fade-edge hidden">' . '<a href="javascript: void(0);" class="cbMoreLessButton">' . CBTxt::T( 'See More' ) . '</a>' . '</div>' . '</div>' . '</div>'; } if ( $isStatus && ( $cbModerator || $rowOwner ) ) { $return .= '<div class="streamPanelFooter streamItemEdit activityContainerAttachmentInfo panel-footer' . ( $link['type'] == 'url' ? ' streamMediaBody media-body' : null ) . ' hidden">' . '<input type="text" id="' . $stream->id() . '_links_title_edit_' . (int) $row->get( 'id' ) . '_' . ( $i + 1 ) . '" name="links[' . $i . '][title]" value="' . htmlspecialchars( $link['title'] ) . '" class="streamInput streamInputLinkTitle form-control" placeholder="' . htmlspecialchars( CBTxt::T( 'Title' ) ) . '" />' . '<textarea id="' . $stream->id() . '_links_description_edit_' . (int) $row->get( 'id' ) . '_' . ( $i + 1 ) . '" name="links[' . $i . '][description]" rows="1" class="streamInput streamInputAutosize streamInputLinkDescription form-control" placeholder="' . htmlspecialchars( CBTxt::T( 'Description' ) ) . '">' . htmlspecialchars( $link['description'] ) . '</textarea>'; if ( $link['type'] == 'url' ) { $return .= '<div class="streamInput">' . '<label class="checkbox-inline">' . '<input type="checkbox" id="' . $stream->id() . '_links_thumbnail_edit_' . (int) $row->get( 'id' ) . '_' . ( $i + 1 ) . '" name="links[' . $i . '][thumbnail]" value="0"' . ( ! $link['thumbnail'] ? ' checked="checked"' : null ) . '> ' . CBTxt::T( 'Do not display thumbnail' ) . '</label>' . '</div>'; } $return .= '</div>'; } $return .= '</div>'; } $return .= '<div class="streamItemScrollRight' . ( $count > 1 ? null : ' hidden' ) . '">' . '<table>' . '<tr>' . '<td>' . '<span class="streamItemScrollRightIcon fa fa-chevron-right"></span>' . '</td>' . '</tr>' . '</table>' . '</div>' . '</div>'; return $return; }
/** * @return string */ public function icon() { global $_CB_framework; if ( Application::Cms()->getClientId() ) { CBActivity::getTemplate( 'twemoji', false, true, false ); } $icon = null; $emoteClass = 'streamIconEmote' . ucfirst( strtolower( preg_replace( '/[^-a-zA-Z0-9_]/', '', $this->get( 'value' ) ) ) ); if ( $this->get( 'icon' ) ) { $icon = '<img src="' . $_CB_framework->getCfg( 'live_site' ) . '/images/' . htmlspecialchars( $this->get( 'icon' ) ) . '" class="streamIconEmote ' . $emoteClass . ' img-responsive-inline" />'; } elseif ( $this->get( 'class' ) ) { $icon = '<span class="streamIconEmote ' . $emoteClass . ' ' . htmlspecialchars( $this->get( 'class' ) ) . '"></span>'; } return $icon; }
/** * @param CommentTable $row * @param Comments $stream * @param int $output 0: Normal, 1: Raw, 2: Inline, 3: Load, 4: Save * @param UserTable $user * @param UserTable $viewer * @param cbPluginHandler $plugin * @return null|string */ static public function showEdit( $row, $stream, $output, $user, $viewer, $plugin ) { global $_PLUGINS; $cbModerator = CBActivity::isModerator( (int) $viewer->get( 'id' ) ); $messageLimit = ( $cbModerator ? 0 : (int) $stream->get( 'message_limit', 400 ) ); $rowId = $stream->id() . '_edit_' . (int) $row->get( 'id' ); $editBody = null; $editFooter = null; $_PLUGINS->trigger( 'activity_onDisplayCommentEdit', array( &$row, &$editBody, &$editFooter, $stream, $output ) ); $return = '<div class="streamMediaBody streamItemEdit commentContainerContentEdit media-body text-small hidden">' . '<form action="' . $stream->endpoint( 'save', array( 'id' => (int) $row->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="' . $rowId . 'Form" id="' . $rowId . 'Form" class="cb_form streamItemForm form">' . '<textarea id="' . $stream->id() . '_message_edit_' . (int) $row->get( 'id' ) . '" name="message" rows="1" class="streamInput streamInputAutosize streamInputMessage form-control" placeholder="' . htmlspecialchars( ( $stream->get( 'type' ) == 'comment' ? CBTxt::T( 'Write a reply...' ) : CBTxt::T( 'Write a comment...' ) ) ) . '"' . ( $messageLimit ? ' data-cbactivity-input-limit="' . (int) $messageLimit . '" maxlength="' . (int) $messageLimit . '"' : null ) . '>' . htmlspecialchars( $row->get( 'message' ) ) . '</textarea>' . $editBody . '<div class="commentContainerFooter">' . '<div class="commentContainerFooterRow clearfix">' . '<div class="commentContainerFooterRowLeft pull-left">' . $editFooter . '</div>' . '<div class="commentContainerFooterRowRight pull-right text-right">' . '<button type="submit" class="commentButton commentButtonEditSave streamItemEditSave btn btn-primary btn-xs">' . CBTxt::T( 'Done Editing' ) . '</button>' . ' <button type="button" class="commentButton commentButtonEditCancel streamItemEditCancel btn btn-default btn-xs">' . CBTxt::T( 'Cancel' ) . '</button>' . '</div>' . '</div>' . '</div>' . '</form>' . '</div>'; return $return; }
/** * Accessor: * Returns a field in specified format * * @param FieldTable $field * @param UserTable $user * @param string $output 'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit' * @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'search' for searches * @param int $list_compare_types IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search * @return mixed */ public function getField( &$field, &$user, $output, $reason, $list_compare_types ) { $return = null; if ( $field->get( 'type' ) == 'comments' ) { $comments = new Comments( 'field', $user, (int) $field->params->get( 'field_comments_direction', 0 ) ); $comments->set( 'type', 'field' ); $comments->set( 'item', (int) $field->get( 'fieldid' ) ); $comments->set( 'parent', (int) $user->get( 'id' ) ); CBActivity::loadStreamDefaults( $comments, $field->params, 'field_comments_' ); $return = $comments->stream( false ); } else { $activity = new Activity( 'field', $user, (int) $field->params->get( 'field_activity_direction', 0 ) ); $activity->set( 'type', 'field' ); $activity->set( 'subtype', 'status' ); $activity->set( 'item', (int) $field->get( 'fieldid' ) ); $activity->set( 'parent', (int) $user->get( 'id' ) ); CBActivity::loadStreamDefaults( $activity, $field->params, 'field_activity_' ); $return = $activity->stream( false ); } if ( ! ( ( $output == 'html' ) && ( $reason == 'profile' ) ) ) { return null; } return $this->formatFieldValueLayout( $this->_formatFieldOutput( $field->get( 'name' ), $return, $output, false ), $reason, $field, $user ); }
/** * Replaces :EMOTE: with emote icons * * @return string */ public function emotes() { $this->parsed = strtr( $this->parsed, CBActivity::loadEmoteOptions( true ) ); return $this->parsed; }
/** * @return null|string */ public function location() { static $cache = array(); $locations = CBActivity::loadLocationOptions( true ); $id = $this->get( 'id' ); if ( ! isset( $cache[$id] ) ) { $location = $this->params()->subTree( 'location' ); $locationId = (int) $location->get( 'id', 0, GetterInterface::INT ); $locationTitle = null; $locationAddress = null; $return = null; if ( $locationId && isset( $locations[$locationId] ) ) { if ( $locations[$locationId]->get( 'published' ) ) { $locationTitle = ( $locations[$locationId]->get( 'title' ) != '' ? trim( CBTxt::T( $locations[$locationId]->get( 'title' ) ) ) : null ); $place = $location->get( 'place', null, GetterInterface::STRING ); if ( $place != '' ) { $address = $location->get( 'address', null, GetterInterface::STRING ); if ( $address != '' ) { $addressUrl = 'https://www.google.com/maps/place/' . urlencode( $address ); } else { $addressUrl = 'https://www.google.com/maps/search/' . urlencode( $place ); } $locationAddress = '<span class="activityLocation">' . '<a href="' . htmlspecialchars( $addressUrl ) . '" target="_blank" rel="nofollow">' . trim( htmlspecialchars( $place ) ) . '</a>' . '</span>'; } } if ( $locationAddress ) { $return = trim( CBTxt::T( 'ACTIVITY_STATUS_LOCATION', '[title] [location]', array( '[title]' => $locationTitle, '[location]' => $locationAddress ) ) ); } } $cache[$id] = $return; } return $cache[$id]; }
/** * Displays tags stream * * @param int $id * @param Tags $stream * @param int $output * @param bool $data * @param UserTable $user * @param UserTable $viewer */ private function showTags( $id, $stream, $output, $data, $user, $viewer ) { CBActivity::getTemplate( 'tags', false, false ); if ( $id ) { $stream->set( 'id', $id ); $rows = $stream->data(); } else { if ( $data ) { $count = $stream->data( true ); if ( ! $count ) { $rows = array(); } else { $rows = $stream->data(); } } else { $rows = array(); } } if ( $rows ) { CBActivity::preFetchUsers( $rows ); } echo HTML_cbactivityTags::showTags( $rows, $stream, $output, $user, $viewer, $this ); }
/** * @param cbautoactionsActionTable $trigger * @param UserTable $user * @return null|string */ public function execute( $trigger, $user ) { global $_CB_framework, $_CB_database; if ( ! $this->installed() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_NOT_INSTALLED', ':: Action [action] :: CB Activity is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } return null; } $return = null; foreach ( $trigger->getParams()->subTree( 'activity' ) as $row ) { /** @var ParamsInterface $row */ $mode = $row->get( 'mode', 'activity', GetterInterface::STRING ); $method = $row->get( 'method', 'create', GetterInterface::STRING ); $owner = $row->get( 'owner', null, GetterInterface::STRING ); if ( ! $owner ) { $owner = (int) $user->get( 'id' ); } else { $owner = (int) $trigger->getSubstituteString( $owner ); } $type = $trigger->getSubstituteString( $row->get( 'type', null, GetterInterface::STRING ) ); $subtype = $trigger->getSubstituteString( $row->get( 'subtype', null, GetterInterface::STRING ) ); $item = $trigger->getSubstituteString( $row->get( 'item', null, GetterInterface::STRING ) ); $parent = $trigger->getSubstituteString( $row->get( 'parent', null, GetterInterface::STRING ) ); if ( $mode == 'stream' ) { if ( $owner ) { $streamUser = CBuser::getUserDataInstance( (int) $owner ); } else { $streamUser = CBuser::getMyUserDataInstance(); } $source = $trigger->getSubstituteString( $row->get( 'source', null, GetterInterface::STRING ) ); $direction = (int) $row->get( 'direction', 0, GetterInterface::INT ); if ( $row->get( 'stream', 'activity', GetterInterface::STRING ) == 'comments' ) { $object = new Comments( $source, $streamUser, $direction ); CBActivity::loadStreamDefaults( $object, $row->subTree( 'comments_stream' ), 'comments_' ); } else { $object = new Activity( $source, $streamUser, $direction ); CBActivity::loadStreamDefaults( $object, $row->subTree( 'activity_stream' ), 'activity_' ); } if ( $type ) { $object->set( 'type', $type ); } if ( $subtype ) { $object->set( 'subtype', $subtype ); } if ( $item ) { $object->set( 'item', $item ); } if ( $parent ) { $object->set( 'parent', $parent ); } if ( $row->get( 'output', 'echo', GetterInterface::STRING ) == 'echo' ) { echo $object->stream( false ); } else { $return .= $object->stream( false ); } } elseif ( $method == 'delete' ) { $where = array(); if ( $owner ) { $where[] = $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $owner; } if ( $type ) { $where[] = $_CB_database->NameQuote( 'type' ) . ( strpos( $type, '%' ) !== false ? ' LIKE ' : ' = ' ) . $_CB_database->Quote( $type ); } if ( $item ) { $where[] = $_CB_database->NameQuote( 'item' ) . ' = ' . $_CB_database->Quote( $item ); } if ( $mode != 'hidden' ) { if ( $subtype ) { $where[] = $_CB_database->NameQuote( 'subtype' ) . ( strpos( $type, '%' ) !== false ? ' LIKE ' : ' = ' ) . $_CB_database->Quote( $subtype ); } if ( $parent ) { $where[] = $_CB_database->NameQuote( 'parent' ) . ' = ' . $_CB_database->Quote( $parent ); } } switch ( $mode ) { case 'hidden': $table = '#__comprofiler_plugin_activity_hidden'; $class = '\CB\Plugin\Activity\Table\HiddenTable'; break; case 'tag': $table = '#__comprofiler_plugin_activity_tags'; $class = '\CB\Plugin\Activity\Table\TagTable'; break; case 'comment': $table = '#__comprofiler_plugin_activity_comments'; $class = '\CB\Plugin\Activity\Table\CommentTable'; break; case 'activity': default: $table = '#__comprofiler_plugin_activity'; $class = '\CB\Plugin\Activity\Table\ActivityTable'; break; } $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( $table ) . ( $where ? "\n WHERE " . implode( "\n AND ", $where ) : null ); $_CB_database->setQuery( $query ); $objects = $_CB_database->loadObjectList( null, $class, array( $_CB_database ) ); /** @var TableInterface[] $objects */ foreach ( $objects as $object ) { $object->delete(); } } else { if ( ! $owner ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_NO_OWNER', ':: Action [action] :: CB Activity skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } if ( ! $type ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_NO_TYPE', ':: Action [action] :: CB Activity skipped due to missing type', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } switch ( $mode ) { case 'hidden': $object = new HiddenTable( $_CB_database ); break; case 'tag': $object = new TagTable( $_CB_database ); break; case 'comment': $object = new CommentTable( $_CB_database ); break; case 'activity': default: $object = new ActivityTable( $_CB_database ); break; } if ( $item ) { $load = array( 'user_id' => $owner, 'type' => $type, 'item' => $item ); if ( $mode != 'hidden' ) { if ( $subtype ) { $load['subtype'] = $subtype; } if ( $parent ) { $load['parent'] = $parent; } } $object->load( $load ); } $object->set( 'user_id', $owner ); if ( $type ) { $object->set( 'type', $type ); } if ( $mode != 'hidden' ) { if ( $subtype ) { $object->set( 'subtype', $subtype ); } if ( $parent ) { $object->set( 'parent', $parent ); } } if ( $item ) { $object->set( 'item', $item ); } if ( $mode == 'activity' ) { $title = $trigger->getSubstituteString( $row->get( 'title', null, GetterInterface::RAW ) ); if ( $title ) { $object->set( 'title', $title ); } $date = $trigger->getSubstituteString( $row->get( 'date', null, GetterInterface::STRING ) ); if ( $date ) { $object->set( 'date', $_CB_framework->getUTCDate( 'Y-m-d H:i:s', $date ) ); } $action = $row->subTree( 'action' ); $actionId = $action->get( 'id', null, GetterInterface::INT ); if ( $actionId ) { $actionMessage = $trigger->getSubstituteString( $action->get( 'message', null, GetterInterface::STRING ) ); if ( $actionMessage ) { $newAction = array( 'id' => $actionId, 'message' => $actionMessage, 'emote' => $action->get( 'emote', '', GetterInterface::STRING ) ); $object->params()->set( 'action', $newAction ); } } $location = $row->subTree( 'location' ); $locationId = $location->get( 'id', null, GetterInterface::INT ); if ( $locationId ) { $locationPlace = $trigger->getSubstituteString( $location->get( 'place', null, GetterInterface::STRING ) ); if ( $locationPlace ) { $newLocation = array( 'id' => $locationId, 'place' => $locationPlace, 'address' => $trigger->getSubstituteString( $location->get( 'address', null, GetterInterface::STRING ) ) ); $object->params()->set( 'location', $newLocation ); } } $newLinks = array(); foreach ( $row->subTree( 'links' ) as $link ) { /** @var ParamsInterface $link */ $linkType = $trigger->getSubstituteString( $link->get( 'type', null, GetterInterface::STRING ) ); $linkUrl = $trigger->getSubstituteString( $link->get( 'url', null, GetterInterface::STRING ) ); if ( ( ! $linkType ) || ( ! $linkUrl ) ) { continue; } $linkMedia = $link->subTree( 'media' ); $newLinks[] = array( 'url' => $linkUrl, 'text' => $trigger->getSubstituteString( $link->get( 'text', null, GetterInterface::STRING ) ), 'title' => $trigger->getSubstituteString( $link->get( 'title', null, GetterInterface::STRING ) ), 'description' => $trigger->getSubstituteString( $link->get( 'description', null, GetterInterface::RAW ) ), 'media' => array( 'url' => $trigger->getSubstituteString( $linkMedia->get( 'url', null, GetterInterface::STRING ) ), 'mimetype' => $trigger->getSubstituteString( $linkMedia->get( 'mimetype', null, GetterInterface::STRING ) ), 'extension' => $trigger->getSubstituteString( $linkMedia->get( 'extension', null, GetterInterface::STRING ) ), 'custom' => $trigger->getSubstituteString( $linkMedia->get( 'custom', null, GetterInterface::RAW ) ) ), 'type' => $linkType, 'thumbnail' => $link->get( 'thumbnail', 1, GetterInterface::INT ), 'internal' => $link->get( 'internal', 0, GetterInterface::INT ) ); } if ( $newLinks ) { $object->params()->set( 'links', $newLinks ); } $comments = $row->subTree( 'comments' ); $object->params()->set( 'comments', array( 'display' => (int) $comments->get( 'display', 1, GetterInterface::INT ), 'source' => (int) $comments->get( 'source', 1, GetterInterface::INT ) )); $tags = $row->subTree( 'tags' ); $object->params()->set( 'tags', array( 'display' => (int) $tags->get( 'display', 1, GetterInterface::INT ), 'source' => (int) $tags->get( 'source', 1, GetterInterface::INT ) )); $object->set( 'params', $object->params()->asJson() ); } elseif ( $mode == 'comment' ) { $tags = $row->subTree( 'replies' ); $object->params()->set( 'replies', array( 'display' => (int) $tags->get( 'display', 1, GetterInterface::INT ) )); $object->set( 'params', $object->params()->asJson() ); } if ( in_array( $mode, array( 'activity', 'comment' ) ) ) { $message = $trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false ); if ( $message ) { $object->set( 'message', $message ); } } if ( ! $object->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_CREATE_FAILED', ':: Action [action] :: CB Activity failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $object->getError() ) ) ); } continue; } } } return $return; }