Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions lib/allconfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*
*/

namespace OC;

/**
* Class to combine all the configuration options ownCloud offers
*/
class AllConfig implements \OCP\IConfig {
/**
* Sets a new system wide value
* @param string $key the key of the value, under which will be saved
* @param string $value the value that should be stored
* @todo need a use case for this
*/
// public function setSystemValue($key, $value) {
// \OCP\Config::setSystemValue($key, $value);
// }

/**
* Looks up a system wide defined value
* @param string $key the key of the value, under which it was saved
* @return string the saved value
*/
public function getSystemValue($key) {
return \OCP\Config::getSystemValue($key, '');
}


/**
* Writes a new app wide value
* @param string $appName the appName that we want to store the value under
* @param string $key the key of the value, under which will be saved
* @param string $value the value that should be stored
*/
public function setAppValue($appName, $key, $value) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't match the interface declaration = null is missing

\OCP\Config::setAppValue($appName, $key, $value);
}

/**
* Looks up an app wide defined value
* @param string $appName the appName that we stored the value under
* @param string $key the key of the value, under which it was saved
* @return string the saved value
*/
public function getAppValue($appName, $key) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't match the interface declaration = null is missing

return \OCP\Config::getAppValue($appName, $key, '');
}


/**
* Set a user defined value
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we want to store the value under
* @param string $key the key under which the value is being stored
* @param string $value the value that you want to store
*/
public function setUserValue($userId, $appName, $key, $value) {
\OCP\Config::setUserValue($userId, $appName, $key, $value);
}

/**
* Shortcut for getting a user defined value
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we stored the value under
* @param string $key the key under which the value is being stored
*/
public function getUserValue($userId, $appName, $key){
return \OCP\Config::getUserValue($userId, $appName, $key);
}
}
31 changes: 12 additions & 19 deletions lib/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
* upgrading and removing apps.
*/
class OC_App{
static private $activeapp = '';
static private $navigation = array();
static private $settingsForms = array();
static private $adminForms = array();
static private $personalForms = array();
Expand Down Expand Up @@ -271,7 +269,7 @@ public static function disable( $app ) {

/**
* @brief adds an entry to the navigation
* @param string $data array containing the data
* @param array $data array containing the data
* @return bool
*
* This function adds a new entry to the navigation visible to users. $data
Expand All @@ -287,11 +285,7 @@ public static function disable( $app ) {
* the navigation. Lower values come first.
*/
public static function addNavigationEntry( $data ) {
$data['active']=false;
if(!isset($data['icon'])) {
$data['icon']='';
}
OC_App::$navigation[] = $data;
OC::$server->getNavigationManager()->add($data);
return true;
}

Expand All @@ -305,25 +299,22 @@ public static function addNavigationEntry( $data ) {
* highlighting the current position of the user.
*/
public static function setActiveNavigationEntry( $id ) {
// load all the apps, to make sure we have all the navigation entries
self::loadApps();
self::$activeapp = $id;
OC::$server->getNavigationManager()->setActiveEntry($id);
return true;
}

/**
* @brief Get the navigation entries for the $app
* @param string $app app
* @return array of the $data added with addNavigationEntry
*
* Warning: destroys the existing entries
*/
public static function getAppNavigationEntries($app) {
if(is_file(self::getAppPath($app).'/appinfo/app.php')) {
$save = self::$navigation;
self::$navigation = array();
OC::$server->getNavigationManager()->clear();
require $app.'/appinfo/app.php';
$app_entries = self::$navigation;
self::$navigation = $save;
return $app_entries;
return OC::$server->getNavigationManager()->getAll();
}
return array();
}
Expand All @@ -336,7 +327,7 @@ public static function getAppNavigationEntries($app) {
* setActiveNavigationEntry
*/
public static function getActiveNavigationEntry() {
return self::$activeapp;
return OC::$server->getNavigationManager()->getActiveEntry();
}

/**
Expand Down Expand Up @@ -419,8 +410,9 @@ public static function getSettingsNavigation() {

// This is private as well. It simply works, so don't ask for more details
private static function proceedNavigation( $list ) {
$activeapp = OC::$server->getNavigationManager()->getActiveEntry();
foreach( $list as &$naventry ) {
if( $naventry['id'] == self::$activeapp ) {
if( $naventry['id'] == $activeapp ) {
$naventry['active'] = true;
}
else{
Expand Down Expand Up @@ -572,7 +564,8 @@ public static function getAppInfo($appid, $path=false) {
* - active: boolean, signals if the user is on this navigation entry
*/
public static function getNavigation() {
$navigation = self::proceedNavigation( self::$navigation );
$entries = OC::$server->getNavigationManager()->getAll();
$navigation = self::proceedNavigation( $entries );
return $navigation;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/db/connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\Common\EventManager;

class Connection extends \Doctrine\DBAL\Connection {
class Connection extends \Doctrine\DBAL\Connection implements \OCP\IDBConnection {
/**
* @var string $tablePrefix
*/
Expand Down
64 changes: 64 additions & 0 deletions lib/navigationmanager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*
*/

namespace OC;

/**
* Manages the ownCloud navigation
*/
class NavigationManager implements \OCP\INavigationManager {
protected $entries = array();
protected $activeEntry;

/**
* Creates a new navigation entry
* @param array $entry containing: id, name, order, icon and href key
*/
public function add(array $entry) {
$entry['active'] = false;
if(!isset($entry['icon'])) {
$entry['icon'] = '';
}
$this->entries[] = $entry;
}

/**
* @brief returns all the added Menu entries
* @return array of the added entries
*/
public function getAll() {
return $this->entries;
}

/**
* @brief removes all the entries
*/
public function clear() {
$this->entries = array();
}

/**
* Sets the current navigation entry of the currently running app
* @param string $id of the app entry to activate (from added $entry)
*/
public function setActiveEntry($id) {
$this->activeEntry = $id;
}

/**
* @brief gets the active Menu entry
* @return string id or empty string
*
* This function returns the id of the active navigation entry (set by
* setActiveEntry
*/
public function getActiveEntry() {
return $this->activeEntry;
}
}
16 changes: 8 additions & 8 deletions lib/public/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
*/
class App {
/**
* @brief Makes owncloud aware of this app
* @brief Makes ownCloud aware of this app
* @brief This call is deprecated and not necessary to use.
* @param $data array with all information
* @returns true/false
* @returns boolean
*
* @deprecated this method is deprecated
* Do not call it anymore
Expand All @@ -52,7 +52,7 @@ public static function register( $data ) {
/**
* @brief adds an entry to the navigation
* @param $data array containing the data
* @returns true/false
* @returns boolean
*
* This function adds a new entry to the navigation visible to users. $data
* is an associative array.
Expand All @@ -72,8 +72,8 @@ public static function addNavigationEntry( $data ) {

/**
* @brief marks a navigation entry as active
* @param $id id of the entry
* @returns true/false
* @param $id string id of the entry
* @returns boolean
*
* This function sets a navigation entry as active and removes the 'active'
* property from all other entries. The templates can use this for
Expand Down Expand Up @@ -104,7 +104,7 @@ public static function registerAdmin( $app, $page ) {
/**
* @brief Read app metadata from the info.xml file
* @param string $app id of the app or the path of the info.xml file
* @param boolean path (optional)
* @param boolean $path (optional)
* @returns array
*/
public static function getAppInfo( $app, $path=false ) {
Expand All @@ -114,7 +114,7 @@ public static function getAppInfo( $app, $path=false ) {
/**
* @brief checks whether or not an app is enabled
* @param $app app
* @returns true/false
* @returns boolean
*
* This function checks whether or not an app is enabled.
*/
Expand All @@ -133,7 +133,7 @@ public static function checkAppEnabled( $app ) {
/**
* @brief Get the last version of the app, either from appinfo/version or from appinfo/info.xml
* @param $app app
* @returns true/false
* @returns boolean
*/
public static function getAppVersion( $app ) {
return \OC_App::getAppVersion( $app );
Expand Down
65 changes: 65 additions & 0 deletions lib/public/iconfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*
*/

namespace OCP;

/**
* Access to all the configuration options ownCloud offers
*/
interface IConfig {
/**
* Sets a new system wide value
* @param string $key the key of the value, under which will be saved
* @param string $value the value that should be stored
* @todo need a use case for this
*/
// public function setSystemValue($key, $value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm - if there is a getSystemValue() why not a setSystemValue()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want apps to write into config.php? is not really the place to store app values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm - where did my comments go?

Well accessing config.php has some sec issues as well like getting access to the password salt, database credentials ...


/**
* Looks up a system wide defined value
* @param string $key the key of the value, under which it was saved
* @return string the saved value
*/
public function getSystemValue($key);


/**
* Writes a new app wide value
* @param string $appName the appName that we want to store the value under
* @param string $key the key of the value, under which will be saved
* @param string $value the value that should be stored
*/
public function setAppValue($appName, $key, $value);

/**
* Looks up an app wide defined value
* @param string $appName the appName that we stored the value under
* @param string $key the key of the value, under which it was saved
* @return string the saved value
*/
public function getAppValue($appName, $key);


/**
* Set a user defined value
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we want to store the value under
* @param string $key the key under which the value is being stored
* @param string $value the value that you want to store
*/
public function setUserValue($userId, $appName, $key, $value);

/**
* Shortcut for getting a user defined value
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we stored the value under
* @param string $key the key under which the value is being stored
*/
public function getUserValue($userId, $appName, $key);
}
Loading