コード例 #1
0
ファイル: mime.image.php プロジェクト: kailIII/liberty
/**
 * mime_image_update update file information in the database if there were changes.
 *
 * @param array $pStoreRow File data needed to update details in the database
 * @access public
 * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
 */
function mime_image_update(&$pStoreRow, $pParams = NULL)
{
    global $gThumbSizes, $gBitSystem;
    $ret = TRUE;
    // this will set the correct pluign guid, even if we let default handle the store process
    $pStoreRow['attachment_plugin_guid'] = PLUGIN_MIME_GUID_IMAGE;
    // if storing works, we process the image
    if (!empty($pStoreRow['upload']) && ($ret = mime_default_update($pStoreRow))) {
        if (!mime_image_store_exif_data($pStoreRow)) {
            // if it all goes t**s up, we'll know why
            $pStoreRow['errors'] = $pStoreRow['log'];
            $ret = FALSE;
        }
    } elseif ($gBitSystem->isFeatureActive('mime_image_panoramas') && !empty($pParams['preference']['is_panorama']) && empty($pStoreRow['thumbnail_url']['panorama'])) {
        if (!mime_image_create_panorama($pStoreRow)) {
            $ret = FALSE;
        }
    } elseif (empty($pParams['preference']['is_panorama']) && !empty($pStoreRow['thumbnail_url']['panorama'])) {
        // we remove the panorama setting in the database and the panorama thumb
        if (LibertyAttachable::validateStoragePath(STORAGE_PKG_PATH . $pStoreRow['thumbnail_url']['panorama'])) {
            @unlink(STORAGE_PKG_PATH . $pStoreRow['thumbnail_url']['panorama']);
        }
    }
    return $ret;
}
コード例 #2
0
ファイル: LibertyAttachable.php プロジェクト: kailIII/liberty
 /**
  * TODO: This code is old and is not used by any package in the bitweaver CVS anymore.
  * We will clean up this code as soon as we migrated all legacy code
  */
 function store(&$pParamHash)
 {
     //deprecated( "This method has been replaced by a method in LibertyMime. Please try to migrate your code." );
     global $gLibertySystem, $gBitSystem, $gBitUser;
     $this->mDb->StartTrans();
     if (LibertyAttachable::verify($pParamHash) && (isset($pParamHash['skip_content_store']) || LibertyContent::store($pParamHash))) {
         if (!empty($pParamHash['STORAGE']) && count($pParamHash['STORAGE'])) {
             foreach (array_keys($pParamHash['STORAGE']) as $guid) {
                 $storeRows =& $pParamHash['STORAGE'][$guid];
                 // short hand variable assignment
                 // If it is empty then nothing more to do. Avoid error in foreach.
                 if (empty($storeRows)) {
                     continue;
                 }
                 foreach ($storeRows as $key => $value) {
                     $storeRow =& $pParamHash['STORAGE'][$guid][$key];
                     $storeRow['plugin_guid'] = $guid;
                     if (!@BitBase::verifyId($pParamHash['content_id'])) {
                         $storeRow['content_id'] = NULL;
                     } else {
                         $storeRow['content_id'] = $pParamHash['content_id'];
                         // copy in content_id
                     }
                     if (!empty($pParamHash['user_id'])) {
                         $storeRow['user_id'] = $pParamHash['user_id'];
                         // copy in the user_id
                     } else {
                         $storeRow['user_id'] = $gBitUser->mUserId;
                     }
                     // do we have a verify function for this storage type, and do things verify?
                     $verifyFunc = $gLibertySystem->getPluginFunction($guid, 'verify_function');
                     if ($verifyFunc && $verifyFunc($storeRow)) {
                         // For backwards compatibility with a single upload.
                         if (@BitBase::verifyId($pParamHash['attachment_id'])) {
                             $storeRow['upload']['attachment_id'] = $storeRow['attachment_id'] = $pParamHash['attachment_id'];
                         } else {
                             if (!isset($storeRow['skip_insert'])) {
                                 if (defined('LINKED_ATTACHMENTS') && @BitBase::verifyId($pParamHash['content_id'])) {
                                     $storeRow['upload']['attachment_id'] = $storeRow['attachment_id'] = $pParamHash['content_id'];
                                 } else {
                                     $storeRow['upload']['attachment_id'] = $storeRow['attachment_id'] = defined('LINKED_ATTACHMENTS') ? $this->mDb->GenID('liberty_content_id_seq') : $this->mDb->GenID('liberty_attachments_id_seq');
                                 }
                             }
                         }
                         // if we have uploaded a file, we can take care of that generically
                         if (!empty($storeRow['upload']) && is_array($storeRow['upload']) && !empty($storeRow['upload']['size'])) {
                             if (empty($storeRow['upload']['type'])) {
                                 $ext = substr($storeRow['upload']['name'], strrpos($storeRow['upload']['name'], '.') + 1);
                                 $storeRow['upload']['type'] = $gBitSystem->lookupMimeType($ext);
                             }
                             $storeRow['upload']['dest_branch'] = $this->getStorageBranch($storeRow['attachment_id'], $storeRow['user_id'], $this->getStorageSubDirName());
                             if (!empty($pParamHash['thumbnail_sizes'])) {
                                 $storeRow['upload']['thumbnail_sizes'] = $pParamHash['thumbnail_sizes'];
                             }
                             $storagePath = liberty_process_upload($storeRow['upload']);
                             // We're gonna store to local file system & liberty_files table
                             if (empty($storagePath)) {
                                 $this->mErrors['file'] = tra("Could not store file") . ": " . $storeRow['upload']['name'] . '.';
                                 $storeRow['attachment_id'] = NULL;
                                 $storeRow['upload']['attachment_id'] = NULL;
                             } else {
                                 $storeRow['upload']['dest_file_path'] = $storagePath;
                             }
                         }
                         if (@BitBase::verifyId($storeRow['attachment_id']) && ($storeFunc = $gLibertySystem->getPluginFunction($storeRow['plugin_guid'], 'store_function'))) {
                             $this->mStorage = $storeFunc($storeRow);
                         }
                         // don't insert if we already have an entry with this attachment_id
                         if (@BitBase::verifyId($storeRow['attachment_id']) && !isset($storeRow['skip_insert']) && !LibertyMime::loadAttachment($storeRow['attachment_id'])) {
                             $sql = "INSERT INTO `" . BIT_DB_PREFIX . "liberty_attachments` ( `content_id`, `attachment_id`, `attachment_plugin_guid`, `foreign_id`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )";
                             $rs = $this->mDb->query($sql, array($storeRow['content_id'], $storeRow['attachment_id'], $storeRow['plugin_guid'], (int) $storeRow['foreign_id'], $storeRow['user_id']));
                         }
                     }
                 }
             }
         }
         // set the primary attachment id
         $this->setPrimaryAttachment($pParamHash['liberty_attachments']['primary'], $pParamHash['content_id'], empty($pParamHash['liberty_attachments']['auto_primary']) || $pParamHash['liberty_attachments']['auto_primary'] ? TRUE : FALSE);
     }
     $this->mDb->CompleteTrans();
     return count($this->mErrors) == 0;
 }
コード例 #3
0
ファイル: BitMapper.php プロジェクト: bitweaver/mapper
 function BitMapper()
 {
     LibertyAttachable::LibertyAttachable();
     $this->loadSettings();
 }
コード例 #4
0
ファイル: BitForumTopic.php プロジェクト: bitweaver/forums
 /**
  * This function removes a bitforum entry
  **/
 function expunge()
 {
     $ret = FALSE;
     if ($this->isValid()) {
         $this->mDb->StartTrans();
         $query = "DELETE FROM `" . BIT_DB_PREFIX . "bitforums` WHERE `content_id` = ?";
         $result = $this->mDb->query($query, array($this->mContentId));
         if (LibertyAttachable::expunge()) {
             $ret = TRUE;
             $this->mDb->CompleteTrans();
         } else {
             $this->mDb->RollbackTrans();
         }
     }
     return $ret;
 }
コード例 #5
0
ファイル: BitNlpg.php プロジェクト: bitweaver/nlpg
 /**
  * Load the data from the database
  * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  **/
 function load($pContentId = NULL, $pPluginParams = NULL)
 {
     global $gBitSystem;
     if ($this->verifyId($this->mNlpgId) || $this->verifyId($this->mContentId)) {
         // LibertyContent::load()assumes you have joined already, and will not execute any sql!
         // This is a significant performance optimization
         $lookupColumn = $this->verifyId($this->mNlpgId) ? 'nlpg_id' : 'content_id';
         $bindVars = array();
         $selectSql = '';
         $joinSql = '';
         $whereSql = '';
         array_push($bindVars, $lookupId = @BitBase::verifyId($this->mNlpgId) ? $this->mNlpgId : $this->mContentId);
         $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
         $query = "SELECT n.*, lc.*, " . "uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name, " . "uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name " . "{$selectSql} " . "FROM `" . BIT_DB_PREFIX . "nlpg_metadata` n " . "INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = n.`content_id` ) {$joinSql}" . "LEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )" . "LEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON( uuc.`user_id` = lc.`user_id` )" . "WHERE e.`{$lookupColumn}`=? {$whereSql}";
         $result = false;
         // $this->mDb->query( $query, $bindVars );
         if ($result && $result->numRows()) {
             $this->mInfo = $result->fields;
             $this->mContentId = $result->fields['content_id'];
             $this->mNlpgId = $result->fields['nlpg_id'];
             $this->mInfo['creator'] = isset($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user'];
             $this->mInfo['editor'] = isset($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user'];
             $this->mInfo['display_url'] = $this->getDisplayUrl();
             $this->mInfo['parsed_data'] = $this->parseData($this->mInfo['data'], $this->mInfo['format_guid']);
             $prefChecks = array('show_start_time', 'show_end_time');
             foreach ($prefChecks as $key => $var) {
                 if ($this->getPreference($var) == 'on') {
                     $this->mInfo[$var] = 1;
                 } else {
                     $this->mInfo[$var] = 0;
                 }
             }
             LibertyAttachable::load();
         }
     }
     return count($this->mInfo);
 }
コード例 #6
0
ファイル: PackagerBase.php プロジェクト: bitweaver/packager
 function getStoragePath($pSubDir = NULL)
 {
     return LibertyAttachable::getStoragePath($pSubDir, NULL, PACKAGER_PKG_NAME);
 }
コード例 #7
0
ファイル: index.php プロジェクト: bitweaver/cascader
    $gBitSystem->storeConfig('cascader_style', NULL);
}
// create a css file based on the user specifications
if (!empty($_REQUEST['create_style'])) {
    $cascaderCss = $gCascader->createHeader();
    $cascaderCss .= $gCascader->createCss($_REQUEST['cascader']);
    if ($cssUrl = $gCascader->writeCss($cascaderCss)) {
        $feedback['success'] = tra("The css file was stored to") . ": " . $cssUrl;
    } else {
        $feedback['error'] = tra("There was a problem storing your custom css file.");
    }
    $gBitSystem->storeConfig('cascader_style', $cssUrl);
}
// apply an existing style
if (!empty($_REQUEST['apply_style'])) {
    $gBitSystem->storeConfig('cascader_style', LibertyAttachable::getStorageUrl() . $_REQUEST['apply_style']);
}
// unset the custom style color settings
if (!empty($_REQUEST['clear_style'])) {
    $gBitSystem->storeConfig('cascader_style', NULL);
}
// remove a style file
if (!empty($_REQUEST['remove_style'])) {
    if ($gCascader->expunge($_REQUEST['remove_style'])) {
        // remove the config entry if we're removing the css file we're currently using
        if (preg_match("/" . $_REQUEST['remove_style'] . "\$/", $gBitSystem->getConfig('cascader_style'))) {
            $gBitSystem->storeConfig('cascader_style', NULL);
        }
        $feedback['success'] = tra("The css file was successfully removed from your system");
    }
}
コード例 #8
0
ファイル: Cascader.php プロジェクト: bitweaver/cascader
 /**
  * remove a specific css file
  *
  * @param array $pStyleName Name of the file
  * @access public
  * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function expunge($pStyleName)
 {
     $path = LibertyAttachable::getStoragePath();
     if (is_file($path . $pStyleName)) {
         unlink($path . $pStyleName);
         return TRUE;
     }
     return FALSE;
 }