/** * Returns the URL for an article * * @param Table $row * @param boolean $htmlspecialchars * @param string $type 'article', 'section' or 'category' * @return string URL */ public static function getUrl($row, $htmlspecialchars = true, $type = 'article') { global $_CB_framework; /** @noinspection PhpIncludeInspection */ require_once $_CB_framework->getCfg('absolute_path') . '/components/com_k2/helpers/route.php'; $categorySlug = $row->get('category') . ($row->get('category_alias') ? ':' . $row->get('category_alias') : null); $articleSlug = $row->get('id') . ($row->get('alias') ? ':' . $row->get('alias') : null); switch ($type) { case 'section': /** @noinspection PhpUndefinedClassInspection */ $url = K2HelperRoute::getCategoryRoute($row->get('parent')); break; case 'category': /** @noinspection PhpUndefinedClassInspection */ $url = K2HelperRoute::getCategoryRoute($categorySlug); break; case 'article': default: /** @noinspection PhpUndefinedClassInspection */ $url = K2HelperRoute::getItemRoute($articleSlug, $categorySlug); break; } if (!stristr($url, 'Itemid')) { $url = $_CB_framework->getCfg('live_site') . '/' . $url; } else { $url = JRoute::_($url, false); } if ($url) { if ($htmlspecialchars) { $url = htmlspecialchars($url); } } return $url; }
/** * @param null|int $id * @return bool */ public function delete( $id = null ) { global $_CB_database, $_PLUGINS; $_PLUGINS->trigger( 'gallery_onBeforeDeleteFolder', array( &$this ) ); if ( $this->get( 'id' ) ) { $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_gallery_items' ) . "\n WHERE " . $_CB_database->NameQuote( 'folder' ) . " = " . (int) $this->get( 'id' ); $_CB_database->setQuery( $query ); $items = $_CB_database->loadObjectList( null, 'cbgalleryItemTable', array( $_CB_database ) ); /** @var cbgalleryItemTable[] $items */ foreach ( $items as $item ) { $item->delete(); } } if ( ! parent::delete( $id ) ) { return false; } $_PLUGINS->trigger( 'gallery_onAfterDeleteFolder', array( $this ) ); return true; }
/** * @param null|int $id * @return bool */ public function delete( $id = null ) { global $_PLUGINS; $_PLUGINS->trigger( 'gj_onBeforeDeleteVideo', array( &$this ) ); if ( ! parent::delete( $id ) ) { return false; } $_PLUGINS->trigger( 'gj_onAfterDeleteVideo', array( $this ) ); return true; }
/** * @param null|int $id * @return bool */ public function delete( $id = null ) { global $_CB_framework, $_PLUGINS; $_PLUGINS->trigger( 'gj_onBeforeDeleteFile', array( &$this ) ); if ( ! parent::delete( $id ) ) { return false; } if ( $this->get( 'file' ) ) { $basePath = $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivefile'; $filePath = $basePath . '/' . (int) $this->group()->get( 'category' ) . '/' . (int) $this->group()->get( 'id' ); if ( file_exists( $filePath . '/' . $this->get( 'file' ) ) ) { @unlink( $filePath . '/' . $this->get( 'file' ) ); } } $_PLUGINS->trigger( 'gj_onAfterDeleteFile', array( $this ) ); return true; }
/** * @param null|int $id * @return bool */ public function delete( $id = null ) { global $_PLUGINS; $_PLUGINS->trigger( 'activity_onBeforeDeleteComment', array( &$this ) ); if ( ! parent::delete( $id ) ) { return false; } // Deletes activity about this comment: $query = 'SELECT *' . "\n FROM " . $this->getDbo()->NameQuote( '#__comprofiler_plugin_activity' ) . "\n WHERE " . $this->getDbo()->NameQuote( 'type' ) . " = " . $this->getDbo()->Quote( 'activity' ) . "\n AND " . $this->getDbo()->NameQuote( 'subtype' ) . " = " . $this->getDbo()->Quote( 'comment' ) . "\n AND " . $this->getDbo()->NameQuote( 'item' ) . " = " . (int) $this->get( 'id' ); $this->getDbo()->setQuery( $query ); $activities = $this->getDbo()->loadObjectList( null, '\CB\Plugin\Activity\Table\ActivityTable', array( $this->getDbo() ) ); /** @var ActivityTable[] $activities */ foreach ( $activities as $activity ) { $activity->delete(); } // Deletes comment replies: $query = 'SELECT *' . "\n FROM " . $this->getDbo()->NameQuote( '#__comprofiler_plugin_activity_comments' ) . "\n WHERE " . $this->getDbo()->NameQuote( 'type' ) . " = " . $this->getDbo()->Quote( 'comment' ) . "\n AND " . $this->getDbo()->NameQuote( 'item' ) . " = " . (int) $this->get( 'id' ); $this->getDbo()->setQuery( $query ); $replies = $this->getDbo()->loadObjectList( null, '\CB\Plugin\Activity\Table\CommentTable', array( $this->getDbo() ) ); /** @var CommentTable[] $replies */ foreach ( $replies as $reply ) { $reply->delete(); } $_PLUGINS->trigger( 'activity_onAfterDeleteComment', array( $this ) ); return true; }
function plug_cbgallery_install() { global $_CB_framework, $_CB_database; $plugin = new PluginTable(); if ( $plugin->load( array( 'element' => 'cb.profilegallery' ) ) ) { $path = $_CB_framework->getCfg( 'absolute_path' ); $indexPath = $path . '/components/com_comprofiler/plugin/user/plug_cbgallery/index.html'; $oldFilesPath = $path . '/images/comprofiler/plug_profilegallery'; $newFilesPath = $path . '/images/comprofiler/plug_cbgallery'; $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plug_profilegallery' ); $_CB_database->setQuery( $query ); $rows = $_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( $_CB_database, '#__comprofiler_plug_profilegallery', 'id' ) ); /** @var $rows Table[] */ foreach ( $rows as $row ) { $oldFilePath = $oldFilesPath . '/' . (int) $row->get( 'userid' ); if ( in_array( $row->get( 'pgitemtype' ), array( 'jpg', 'jpeg', 'gif', 'png' ) ) ) { $type = 'photos'; } else { $type = 'files'; } $newFilePath = $newFilesPath . '/' . (int) $row->get( 'userid' ) . '/' . $type; if ( ( ! file_exists( $oldFilePath . '/' . $row->get( 'pgitemfilename' ) ) ) || ( ( $type == 'photos' ) && ( ! file_exists( $oldFilePath . '/tn' . $row->get( 'pgitemfilename' ) ) ) ) ) { continue; } $cleanFileName = str_replace( 'pg_', '', pathinfo( $row->get( 'pgitemfilename' ), PATHINFO_FILENAME ) ); $newFileName = uniqid( $cleanFileName . '_' ) . '.' . strtolower( pathinfo( $row->get( 'pgitemfilename' ), PATHINFO_EXTENSION ) ); if ( cbReadDirectory( $newFilePath, '^' . preg_quote( $cleanFileName ) ) ) { $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_gallery_items' ) . "\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $row->get( 'userid' ) . "\n AND " . $_CB_database->NameQuote( 'value' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $cleanFileName, true ) . '%', false ); $_CB_database->setQuery( $query ); if ( $_CB_database->loadResult() ) { continue; } } if ( ! is_dir( $newFilesPath ) ) { $oldMask = @umask( 0 ); if ( @mkdir( $newFilesPath, 0755, true ) ) { @umask( $oldMask ); @chmod( $newFilesPath, 0755 ); if ( ! file_exists( $newFilesPath . '/index.html' ) ) { @copy( $indexPath, $newFilesPath . '/index.html' ); @chmod( $newFilesPath . '/index.html', 0755 ); } } else { @umask( $oldMask ); } } if ( ! file_exists( $newFilesPath . '/.htaccess' ) ) { file_put_contents( $newFilesPath . '/.htaccess', 'deny from all' ); } if ( ! is_dir( $newFilePath ) ) { $oldMask = @umask( 0 ); if ( @mkdir( $newFilePath, 0755, true ) ) { @umask( $oldMask ); @chmod( $newFilePath, 0755 ); if ( ! file_exists( $newFilePath . '/index.html' ) ) { @copy( $indexPath, $newFilePath . '/index.html' ); @chmod( $newFilePath . '/index.html', 0755 ); } } else { @umask( $oldMask ); } } if ( ! @copy( $oldFilePath . '/' . $row->get( 'pgitemfilename' ), $newFilePath . '/' . $newFileName ) ) { continue; } else { @chmod( $newFilePath . '/' . $newFileName, 0755 ); } if ( $type == 'photos' ) { if ( ! @copy( $oldFilePath . '/tn' . $row->get( 'pgitemfilename' ), $newFilePath . '/tn' . $newFileName ) ) { continue; } else { @chmod( $newFilePath . '/tn' . $newFileName, 0755 ); } } $item = new Table( null, '#__comprofiler_plugin_gallery_items', 'id' ); $item->set( 'user_id', (int) $row->get( 'userid' ) ); $item->set( 'type', $type ); $item->set( 'value', $newFileName ); $item->set( 'folder', 0 ); $item->set( 'title', $row->get( 'pgitemtitle' ) ); $item->set( 'description', $row->get( 'pgitemdescription' ) ); $item->set( 'date', $row->get( 'pgitemdate' ) ); $item->set( 'published', ( $row->get( 'pgitemapproved', 0 ) ? (int) $row->get( 'pgitempublished', 0 ) : -1 ) ); if ( ! $item->store() ) { @unlink( $newFilePath . '/' . $newFileName ); if ( $type == 'photos' ) { @unlink( $newFilePath . '/tn' . $newFileName ); } } } $field = new FieldTable(); if ( $field->load( array( 'name' => 'cb_pgtotalquotaitems' ) ) ) { $field->set( 'type', 'integer' ); $field->set( 'tabid', 11 ); $field->set( 'pluginid', 1 ); $field->set( 'readonly', 1 ); $field->set( 'calculated', 0 ); $field->set( 'sys', 0 ); $field->store(); } $gallery = new PluginTable(); if ( $gallery->load( array( 'element' => 'cbgallery' ) ) ) { $galleryParams = new Registry( $gallery->params ); $galleryParams->set( 'photos_item_limit', 'cb_pgtotalquotaitems' ); $galleryParams->set( 'files_item_limit', 'cb_pgtotalquotaitems' ); $gallery->set( 'params', $galleryParams->asJson() ); $gallery->store(); } ob_start(); $plgInstaller = new cbInstallerPlugin(); $plgInstaller->uninstall( $plugin->id, 'com_comprofiler' ); ob_end_clean(); } }
/** * @param Table $trigger * @param Registry $params */ public static function usergroup( &$trigger, &$params ) { $usergroupCount = substr_count( $trigger->get( 'params' ), 'usergroup_mode' ); if ( $usergroupCount ) { $newParams = array(); $newParams['usergroup'] = array(); $paramsMap = array( 'usergroup_mode' => 'mode', 'usergroup_parent' => 'parent', 'usergroup_title' => 'title', 'usergroup_add' => 'add', 'usergroup_groups' => 'groups' ); for ( $i = 0, $n = $usergroupCount; $i < $n; $i++ ) { if ( $i == 0 ) { $i = null; } $usergroup = array(); foreach ( $paramsMap as $old => $new ) { $usergroup[$new] = $trigger->get( 'params' )->get( $old . $i, null, GetterInterface::RAW ); } $newParams['usergroup'][] = $usergroup; } $params->load( $newParams ); } }
/** * @param null|int $id * @return bool */ public function delete( $id = null ) { global $_PLUGINS; //$_PLUGINS->trigger( 'invites_onBeforeDeleteInvite', array( &$this ) ); if ( ! parent::delete( $id ) ) { return false; } //$_PLUGINS->trigger( 'invites_onAfterDeleteInvite', array( $this ) ); return true; }
/** * @param null|int $id * @return bool */ public function delete( $id = null ) { global $_PLUGINS; $_PLUGINS->trigger( 'gj_onBeforeDeleteUser', array( &$this ) ); if ( ! parent::delete( $id ) ) { return false; } static $params = null; if ( ! $params ) { $plugin = $_PLUGINS->getLoadedPlugin( 'user', 'cbgroupjive' ); $params = $_PLUGINS->getPluginParams( $plugin ); } if ( ( ! CBGroupJive::isModerator( $this->get( 'user_id' ) ) ) && $params->get( 'groups_delete', 1 ) ) { // Delete this users group invites (to and from): $query = 'SELECT *' . "\n FROM " . $this->getDbo()->NameQuote( '#__groupjive_invites' ) . "\n WHERE " . $this->getDbo()->NameQuote( 'group' ) . " = " . (int) $this->get( 'group' ) . "\n AND ( " . $this->getDbo()->NameQuote( 'user_id' ) . " = " . (int) $this->get( 'user_id' ) . "\n OR " . $this->getDbo()->NameQuote( 'user' ) . " = " . (int) $this->get( 'user_id' ) . " )"; $this->getDbo()->setQuery( $query ); $invites = $this->getDbo()->loadObjectList( null, '\CB\Plugin\GroupJive\Table\InviteTable', array( $this->getDbo() ) ); /** @var InviteTable[] $invites */ foreach ( $invites as $invite ) { $invite->delete(); } // Delete this users group notifications: $notification = new NotificationTable(); $notification->load( array( 'user_id' => (int) $this->get( 'user_id' ), 'group' => (int) $this->get( 'group' ) ) ); if ( $notification->get( 'id' ) ) { $notification->delete(); } } $_PLUGINS->trigger( 'gj_onAfterDeleteUser', array( $this ) ); return true; }
/** * get or set the kunena post object * * @param \KunenaForumMessage|null $post * @return \KunenaForumMessage|null */ public function post( $post = null ) { if ( $post !== null ) { $this->_post = $post; $data = array(); foreach ( $this->_post as $k => $v ) { switch ( $k ) { case 'userid': $k = 'user_id'; break; case 'catid': $k = 'category'; break; case 'time': $k = 'date'; $v = Application::Date( $v, 'UTC' )->format( 'Y-m-d H:i:s' ); break; case 'hold': $k = 'published'; $v = ( $v == 0 ? 1 : 0 ); break; } $data[$k] = $v; } parent::bind( $data ); } return $this->_post; }
/** * Sets parameters for this editor * * @param cbObject|Table $object The data object * @return void */ public function setAllParams($object) { $array = array(); $isStorage = $object instanceof TableInterface || $object instanceof comprofilerDBTable; if ($isStorage) { $keys = $object->getPublicProperties(); foreach ($keys as $k) { $array[$k] = $object->{$k}; } } else { $array = (array) $object; } $registry = new Registry($array); if ($isStorage) { $registry->setStorage($object); } $this->registryEditController->setRegistry($registry); }
/** * @param null|int $id * @return bool */ public function delete( $id = null ) { global $_PLUGINS; $_PLUGINS->trigger( 'gj_onBeforeDeleteWall', array( &$this ) ); if ( ! parent::delete( $id ) ) { return false; } // Delete replies to this post: $query = 'SELECT *' . "\n FROM " . $this->getDbo()->NameQuote( '#__groupjive_plugin_wall' ) . "\n WHERE " . $this->getDbo()->NameQuote( 'reply' ) . " = " . (int) $this->get( 'id' ); $this->getDbo()->setQuery( $query ); $posts = $this->getDbo()->loadObjectList( null, '\CB\Plugin\GroupJiveWall\Table\WallTable', array( $this->getDbo() ) ); /** @var WallTable[] $posts */ foreach ( $posts as $post ) { $post->delete(); } $_PLUGINS->trigger( 'gj_onAfterDeleteWall', array( $this ) ); return true; }
/** * @param null|int $id * @return bool */ public function delete( $id = null ) { global $_PLUGINS; $_PLUGINS->trigger( 'gj_onBeforeDeleteEvent', array( &$this ) ); if ( ! parent::delete( $id ) ) { return false; } // Delete attendance to this event: $query = 'SELECT *' . "\n FROM " . $this->getDbo()->NameQuote( '#__groupjive_plugin_events_attendance' ) . "\n WHERE " . $this->getDbo()->NameQuote( 'event' ) . " = " . (int) $this->get( 'id' ); $this->getDbo()->setQuery( $query ); $users = $this->getDbo()->loadObjectList( null, '\CB\Plugin\GroupJiveEvents\Table\AttendanceTable', array( $this->getDbo() ) ); /** @var AttendanceTable[] $users */ foreach ( $users as $user ) { $user->delete(); } $_PLUGINS->trigger( 'gj_onAfterDeleteEvent', array( $this ) ); return true; }
/** * get or set the kunena category object * * @param \KunenaForumCategory|null $category * @return \KunenaForumCategory|null */ public function category( $category = null ) { if ( $category !== null ) { $this->_category = $category; $data = array(); foreach ( $this->_category as $k => $v ) { if ( $k == 'parent_id' ) { $k = 'parent'; } $data[$k] = $v; } parent::bind( $data ); } return $this->_category; }