/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_CB_framework, $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); if ( ! $new ) { $_PLUGINS->trigger( 'gallery_onBeforeUpdateFolder', array( &$this ) ); } else { $_PLUGINS->trigger( 'gallery_onBeforeCreateFolder', array( &$this ) ); } $this->set( 'date', $this->get( 'date', $_CB_framework->getUTCDate() ) ); if ( ! parent::store( $updateNulls ) ) { return false; } if ( ! $new ) { $_PLUGINS->trigger( 'gallery_onAfterUpdateFolder', array( $this ) ); } else { $_PLUGINS->trigger( 'gallery_onAfterCreateFolder', array( $this ) ); } return true; }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_CB_framework, $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); $old = new self(); $this->set( 'date', $this->get( 'date', Application::Database()->getUtcDateTime() ) ); if ( isset( $_FILES['file']['tmp_name'] ) && ( ! empty( $_FILES['file']['tmp_name'] ) ) ) { $basePath = $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivefile'; $filePath = $basePath . '/' . (int) $this->group()->get( 'category' ) . '/' . (int) $this->group()->get( 'id' ); CBGroupJive::createDirectory( $basePath, $this->group()->get( 'category' ), $this->group()->get( 'id' ) ); $fileExtension = strtolower( preg_replace( '/[^-a-zA-Z0-9_]/', '', pathinfo( $_FILES['file']['name'], PATHINFO_EXTENSION ) ) ); $fileName = Get::clean( pathinfo( $_FILES['file']['name'], PATHINFO_FILENAME ), GetterInterface::STRING ) . '.' . $fileExtension; $fileId = uniqid(); $newFileName = $fileId . '.' . $fileExtension; if ( ! move_uploaded_file( $_FILES['file']['tmp_name'], $filePath . '/' . $newFileName ) ) { $this->setError( CBTxt::T( 'GROUP_FILE_UPLOAD_FAILED', 'The file [file] failed to upload!', array( '[file]' => $newFileName ) ) ); return false; } else { @chmod( $filePath . '/' . $newFileName, 0755 ); } if ( $this->get( 'file' ) && file_exists( $filePath . '/' . $this->get( 'file' ) ) ) { @unlink( $filePath . '/' . $this->get( 'file' ) ); } $this->set( 'file', $newFileName ); $this->set( 'filename', $fileName ); $params = $this->params(); $params->unsetEntry( 'name' ); $params->unsetEntry( 'extension' ); $params->unsetEntry( 'mimetype' ); $params->unsetEntry( 'filesize' ); $params->set( 'name', $this->name() ); $params->set( 'extension', $this->extension() ); $params->set( 'mimetype', $this->mimeType() ); $params->set( 'filesize', $this->size( true ) ); $this->set( 'params', $params->asJson() ); } elseif ( ! $this->get( 'filename' ) ) { $this->set( 'filename', $this->get( 'file' ) ); } if ( ! $new ) { $old->load( (int) $this->get( 'id' ) ); $_PLUGINS->trigger( 'gj_onBeforeUpdateFile', array( &$this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onBeforeCreateFile', array( &$this ) ); } if ( ! parent::store( $updateNulls ) ) { return false; } if ( $old->get( 'id' ) && $this->get( 'file' ) && ( $old->get( 'group' ) != $this->get( 'group' ) ) ) { $basePath = $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivefile'; $oldPath = $basePath . '/' . (int) $old->group()->get( 'category' ) . '/' . (int) $old->group()->get( 'id' ); $newPath = $basePath . '/' . (int) $this->group()->get( 'category' ) . '/' . (int) $this->group()->get( 'id' ); if ( is_dir( $oldPath ) ) { CBGroupJive::createDirectory( $basePath, $this->group()->get( 'category' ), $this->group()->get( 'id' ) ); if ( file_exists( $oldPath . '/' . $this->get( 'file' ) ) ) { @rename( $oldPath . '/' . $this->get( 'file' ), $newPath . '/' . $this->get( 'file' ) ); } } } if ( ! $new ) { $_PLUGINS->trigger( 'gj_onAfterUpdateFile', array( $this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onAfterCreateFile', array( $this ) ); } return true; }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); $old = new self(); $this->set( 'date', $this->get( 'date', Application::Database()->getUtcDateTime() ) ); if ( ! $new ) { $old->load( (int) $this->get( 'id' ) ); $_PLUGINS->trigger( 'gj_onBeforeUpdateVideo', array( &$this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onBeforeCreateVideo', array( &$this ) ); } if ( ! parent::store( $updateNulls ) ) { return false; } if ( ! $new ) { $_PLUGINS->trigger( 'gj_onAfterUpdateVideo', array( $this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onAfterCreateVideo', 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 bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_CB_framework, $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); $old = new self(); $this->set( 'type', preg_replace( '/[^-a-zA-Z0-9_.]/', '', $this->get( 'type' ) ) ); $this->set( 'subtype', preg_replace( '/[^-a-zA-Z0-9_.]/', '', $this->get( 'subtype' ) ) ); $this->set( 'date', $this->get( 'date', $_CB_framework->getUTCDate() ) ); if ( ! $new ) { $old->load( (int) $this->get( 'id' ) ); $_PLUGINS->trigger( 'activity_onBeforeUpdateComment', array( &$this, $old ) ); } else { $_PLUGINS->trigger( 'activity_onBeforeCreateComment', array( &$this ) ); } if ( ! parent::store( $updateNulls ) ) { return false; } if ( ! $new ) { $_PLUGINS->trigger( 'activity_onAfterUpdateComment', array( $this, $old ) ); } else { $_PLUGINS->trigger( 'activity_onAfterCreateComment', array( $this ) ); } return true; }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); $old = new self(); $this->set( 'date', $this->get( 'date', Application::Database()->getUtcDateTime() ) ); if ( ! $new ) { $old->load( (int) $this->get( 'id' ) ); $_PLUGINS->trigger( 'gj_onBeforeUpdateUser', array( &$this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onBeforeCreateUser', array( &$this ) ); } if ( ! parent::store( $updateNulls ) ) { return false; } // Promote to group owner if status is changed to owner: if ( $this->get( 'status' ) == 4 ) { $group = CBGroupJive::getGroup( $this->get( 'group' ) ); if ( $group->get( 'id' ) && ( $group->get( 'user_id' ) != $this->get( 'user_id' ) ) ) { $group->set( 'user_id', (int) $this->get( 'user_id' ) ); $group->store(); } } if ( ! $new ) { $_PLUGINS->trigger( 'gj_onAfterUpdateUser', array( $this, $old ) ); } else { static $params = null; if ( ! $params ) { $plugin = $_PLUGINS->getLoadedPlugin( 'user', 'cbgroupjive' ); $params = $_PLUGINS->getPluginParams( $plugin ); } // Set the default notifications: $notification = new NotificationTable(); $notification->load( array( 'user_id' => (int) $this->get( 'user_id' ), 'group' => (int) $this->get( 'group' ) ) ); $notification->set( 'user_id', (int) $this->get( 'user_id' ) ); $notification->set( 'group', (int) $this->get( 'group' ) ); $notifications = $notification->params(); $notifications->set( 'user_join', $params->get( 'notifications_default_user_join', 0 ) ); $notifications->set( 'user_leave', $params->get( 'notifications_default_user_leave', 0 ) ); $notifications->set( 'user_approve', $params->get( 'notifications_default_user_approve', 0 ) ); $notifications->set( 'user_cancel', $params->get( 'notifications_default_user_cancel', 0 ) ); $notifications->set( 'invite_accept', $params->get( 'notifications_default_invite_accept', 0 ) ); $notifications->set( 'invite_reject', $params->get( 'notifications_default_invite_reject', 0 ) ); $_PLUGINS->trigger( 'gj_onAfterCreateUser', array( $this, &$notifications ) ); $notification->set( 'params', $notifications->asJson() ); $notification->store(); } return true; }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); if ( ! parent::store( $updateNulls ) ) { return false; } return true; }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); $old = new self(); $this->set( 'code', $this->get( 'code', md5( uniqid() ) ) ); if ( ! $new ) { $old->load( (int) $this->get( 'id' ) ); $_PLUGINS->trigger( 'gj_onBeforeUpdateInvite', array( &$this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onBeforeCreateInvite', array( &$this ) ); } if ( ! parent::store( $updateNulls ) ) { return false; } if ( ! $new ) { $_PLUGINS->trigger( 'gj_onAfterUpdateInvite', array( $this, $old ) ); } else { $this->send(); $_PLUGINS->trigger( 'gj_onAfterCreateInvite', array( $this ) ); } return true; }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); if ( ! $new ) { $_PLUGINS->trigger( 'antispam_onBeforeUpdateAttempts', array( &$this ) ); } else { $_PLUGINS->trigger( 'antispam_onBeforeCreateAttempts', array( &$this ) ); } if ( ! parent::store( $updateNulls ) ) { return false; } if ( ! $new ) { $_PLUGINS->trigger( 'antispam_onAfterUpdateAttempts', array( $this ) ); } else { $_PLUGINS->trigger( 'antispam_onAfterCreateAttempts', array( $this ) ); } return true; }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_CB_framework, $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); $old = new self(); $this->set( 'date', $this->get( 'date', Application::Database()->getUtcDateTime() ) ); if ( isset( $_FILES['image']['tmp_name'] ) && ( ! empty( $_FILES['image']['tmp_name'] ) ) ) { static $params = null; if ( ! $params ) { $plugin = $_PLUGINS->getLoadedPlugin( 'user/plug_cbgroupjive/plugins', 'cbgroupjivephoto' ); $params = $_PLUGINS->getPluginParams( $plugin ); } $basePath = $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivephoto'; $filePath = $basePath . '/' . (int) $this->group()->get( 'category' ) . '/' . (int) $this->group()->get( 'id' ); CBGroupJive::createDirectory( $basePath, $this->group()->get( 'category' ), $this->group()->get( 'id' ) ); $resample = $params->get( 'groups_photo_resample', 1 ); $aspectRatio = $params->get( 'groups_photo_maintain_aspect_ratio', 1 ); $imageHeight = (int) $params->get( 'groups_photo_image_height', 640 ); if ( ! $imageHeight ) { $imageHeight = 640; } $imageWidth = (int) $params->get( 'groups_photo_image_width', 1280 ); if ( ! $imageWidth ) { $imageWidth = 1280; } $thumbHeight = (int) $params->get( 'groups_photo_thumbnail_height', 320 ); if ( ! $thumbHeight ) { $thumbHeight = 320; } $thumbWidth = (int) $params->get( 'groups_photo_thumbnail_width', 640 ); if ( ! $thumbWidth ) { $thumbWidth = 640; } $conversionType = (int) Application::Config()->get( 'conversiontype', 0 ); $imageSoftware = ( $conversionType == 5 ? 'gmagick' : ( $conversionType == 1 ? 'imagick' : 'gd' ) ); $fileExtension = strtolower( preg_replace( '/[^-a-zA-Z0-9_]/', '', pathinfo( $_FILES['image']['name'], PATHINFO_EXTENSION ) ) ); $fileName = Get::clean( pathinfo( $_FILES['image']['name'], PATHINFO_FILENAME ), GetterInterface::STRING ) . '.' . $fileExtension; $fileId = uniqid(); try { $image = new Image( $imageSoftware, $resample, $aspectRatio ); $image->setName( $fileId ); $image->setSource( $_FILES['image'] ); $image->setDestination( $filePath . '/' ); $image->processImage( $imageWidth, $imageHeight ); $newFileName = $image->getCleanFilename(); $image->setName( 'tn' . $fileId ); $image->processImage( $thumbWidth, $thumbHeight ); if ( $this->get( 'image' ) ) { if ( file_exists( $filePath . '/' . $this->get( 'image' ) ) ) { @unlink( $filePath . '/' . $this->get( 'image' ) ); } if ( file_exists( $filePath . '/tn' . $this->get( 'image' ) ) ) { @unlink( $filePath . '/tn' . $this->get( 'image' ) ); } } $this->set( 'image', $newFileName ); $this->set( 'filename', $fileName ); $params = $this->params(); $params->unsetEntry( 'name' ); $params->unsetEntry( 'extension' ); $params->unsetEntry( 'mimetype' ); $params->unsetEntry( 'filesize' ); $params->unsetEntry( 'filesize_thumbnail' ); $params->unsetEntry( 'height' ); $params->unsetEntry( 'width' ); $params->unsetEntry( 'height_thumbnail' ); $params->unsetEntry( 'width_thumbnail' ); $params->set( 'name', $this->name() ); $params->set( 'extension', $this->extension() ); $params->set( 'mimetype', $this->mimeType() ); $params->set( 'filesize', $this->size( true ) ); $params->set( 'filesize_thumbnail', $this->size( true, true ) ); $params->set( 'height', $this->height() ); $params->set( 'width', $this->width() ); $params->set( 'height_thumbnail', $this->height( true ) ); $params->set( 'width_thumbnail', $this->width( true ) ); $this->set( 'params', $params->asJson() ); } catch ( Exception $e ) { $this->setError( $e->getMessage() ); return false; } } elseif ( ! $this->get( 'filename' ) ) { $this->set( 'filename', $this->get( 'image' ) ); } if ( ! $new ) { $old->load( (int) $this->get( 'id' ) ); $_PLUGINS->trigger( 'gj_onBeforeUpdatePhoto', array( &$this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onBeforeCreatePhoto', array( &$this ) ); } if ( ! parent::store( $updateNulls ) ) { return false; } if ( $old->get( 'id' ) && $this->get( 'image' ) && ( $old->get( 'group' ) != $this->get( 'group' ) ) ) { $basePath = $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivephoto'; $oldPath = $basePath . '/' . (int) $old->group()->get( 'category' ) . '/' . (int) $old->group()->get( 'id' ); $newPath = $basePath . '/' . (int) $this->group()->get( 'category' ) . '/' . (int) $this->group()->get( 'id' ); if ( is_dir( $oldPath ) ) { CBGroupJive::createDirectory( $basePath, $this->group()->get( 'category' ), $this->group()->get( 'id' ) ); if ( file_exists( $oldPath . '/' . $this->get( 'image' ) ) ) { @rename( $oldPath . '/' . $this->get( 'image' ), $newPath . '/' . $this->get( 'image' ) ); } if ( file_exists( $oldPath . '/tn' . $this->get( 'image' ) ) ) { @rename( $oldPath . '/tn' . $this->get( 'image' ), $newPath . '/tn' . $this->get( 'image' ) ); } } } if ( ! $new ) { $_PLUGINS->trigger( 'gj_onAfterUpdatePhoto', array( $this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onAfterCreatePhoto', array( $this ) ); } return true; }