Beispiel #1
0
 *
 */
OCP\App::checkAppEnabled('storagecharts2');
$l = new OC_L10N('storagecharts2');
OC::$CLASSPATH['OC_DLStCharts'] = OC_App::getAppPath('storagecharts2') . "/lib/db.class.php";
OC::$CLASSPATH['OC_DLStChartsLoader'] = OC_App::getAppPath('storagecharts2') . "/lib/loader.class.php";
OCP\App::addNavigationEntry(array('id' => 'storagecharts2_index', 'order' => 60, 'href' => OCP\Util::linkTo('storagecharts2', 'index.php'), 'icon' => OCP\Util::imagePath('storagecharts2', 'app.svg'), 'name' => $l->t('Usage')));
OCP\App::registerPersonal('storagecharts2', 'settings');
// Get storage value for logged in user
$data_dir = OCP\Config::getSystemValue('datadirectory', '');
if (OCP\User::getUser() && strlen($data_dir) != 0) {
    $fs = OCP\Files::getStorage('files');
    // workaround to detect OC version
    $ocVersion = @reset(OCP\Util::getVersion());
    // OC 5
    if ($ocVersion < 6) {
        OCP\Util::writeLog('storagecharts2', 'Running on OwnCloud 5', OCP\Util::DEBUG);
        $used = OC_DLStCharts::getTotalDataSize(OC::$CONFIG_DATADIRECTORY);
        // OC 6 or greater
    } else {
        $datadir = OC_Config::getValue('datadirectory') . '/' . OCP\User::getUser();
        OCP\Util::writeLog('storagecharts2', 'Running on OwnCloud ' . $ocVersion, OCP\Util::DEBUG);
        $used = OC_DLStCharts::getTotalDataSize($datadir);
    }
    // omit errors in desktop client ...
    if (method_exists($fs, 'free_space')) {
        OCP\Util::writeLog('storagecharts2', 'Calculating available space in oc << 8 for client', OCP\Util::DEBUG);
        $total = OC_DLStCharts::getTotalDataSize($data_dir) + $fs->free_space();
        OC_DLStCharts::update($used, $total);
    }
}
Beispiel #2
0
*
* @author Xavier Beurois
* @copyright 2012 Xavier Beurois www.djazz-lab.net
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either 
* version 3 of the License, or any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
OC_Util::checkAppEnabled('storage_charts');
OC::$CLASSPATH['OC_DLStCharts'] = "apps/storage_charts/lib/db.class.php";
OC::$CLASSPATH['OC_DLStChartsLoader'] = "apps/storage_charts/lib/loader.class.php";
$l = new OC_L10N('storage_charts', OC_L10N::findLanguage(array('en', 'fr')));
OC_App::register(array('order' => 60, 'id' => 'storage_charts', 'name' => 'Storage Charts'));
OC_App::addNavigationEntry(array('id' => 'storage_charts', 'order' => 60, 'href' => OC_Helper::linkTo('storage_charts', 'charts.php'), 'icon' => OC_Helper::imagePath('storage_charts', 'chart.png'), 'name' => 'DL Charts'));
OC_App::registerPersonal('storage_charts', 'settings');
$data_dir = OC_Config::getValue('datadirectory', '');
if (OC_User::getUser() && strlen($data_dir) != 0) {
    $used = OC_DLStCharts::getTotalDataSize(OC::$CONFIG_DATADIRECTORY);
    $total = OC_DLStCharts::getTotalDataSize($data_dir) + OC_Filesystem::free_space();
    OC_DLStCharts::update($used, $total);
}