mirror of
https://github.com/owncloudarchive/contacts.git
synced 2024-12-01 13:24:10 +01:00
ported getUser
This commit is contained in:
parent
26930d0d83
commit
a3dc9e8b2a
@ -31,7 +31,7 @@ if(is_null($categories)) {
|
|||||||
|
|
||||||
debug(print_r($categories, true));
|
debug(print_r($categories, true));
|
||||||
|
|
||||||
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
|
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
|
||||||
if(count($addressbooks) == 0) {
|
if(count($addressbooks) == 0) {
|
||||||
bailOut(OC_Contacts_App::$l10n->t('No address books found.'));
|
bailOut(OC_Contacts_App::$l10n->t('No address books found.'));
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ function debug($msg) {
|
|||||||
OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
|
OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
|
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
|
||||||
if(count($addressbooks) == 0) {
|
if(count($addressbooks) == 0) {
|
||||||
bailOut(OC_Contacts_App::$l10n->t('No address books found.'));
|
bailOut(OC_Contacts_App::$l10n->t('No address books found.'));
|
||||||
}
|
}
|
||||||
|
2
ajax/contacts.php
Normal file → Executable file
2
ajax/contacts.php
Normal file → Executable file
@ -10,7 +10,7 @@
|
|||||||
OC_JSON::checkLoggedIn();
|
OC_JSON::checkLoggedIn();
|
||||||
OC_JSON::checkAppEnabled('contacts');
|
OC_JSON::checkAppEnabled('contacts');
|
||||||
|
|
||||||
$ids = OC_Contacts_Addressbook::activeIds(OC_User::getUser());
|
$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
|
||||||
$contacts = OC_Contacts_VCard::all($ids);
|
$contacts = OC_Contacts_VCard::all($ids);
|
||||||
$tmpl = new OC_TEMPLATE("contacts", "part.contacts");
|
$tmpl = new OC_TEMPLATE("contacts", "part.contacts");
|
||||||
$tmpl->assign('contacts', $contacts);
|
$tmpl->assign('contacts', $contacts);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
OC_JSON::checkLoggedIn();
|
OC_JSON::checkLoggedIn();
|
||||||
OC_JSON::checkAppEnabled('contacts');
|
OC_JSON::checkAppEnabled('contacts');
|
||||||
|
|
||||||
$userid = OC_User::getUser();
|
$userid = OCP\USER::getUser();
|
||||||
$name = trim(strip_tags($_POST['name']));
|
$name = trim(strip_tags($_POST['name']));
|
||||||
if(!$name) {
|
if(!$name) {
|
||||||
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.'))));
|
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.'))));
|
||||||
|
@ -33,7 +33,7 @@ if($id) {
|
|||||||
$tmpl->assign('name',$name);
|
$tmpl->assign('name',$name);
|
||||||
$tmpl->assign('id',$id);
|
$tmpl->assign('id',$id);
|
||||||
} else {
|
} else {
|
||||||
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
|
$addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
|
||||||
$tmpl->assign('addressbooks', $addressbooks);
|
$tmpl->assign('addressbooks', $addressbooks);
|
||||||
}
|
}
|
||||||
$tmpl->printpage();
|
$tmpl->printpage();
|
||||||
|
@ -30,7 +30,7 @@ if(!$file) {
|
|||||||
}
|
}
|
||||||
error_log('File: '.$file);
|
error_log('File: '.$file);
|
||||||
if(isset($_POST['method']) && $_POST['method'] == 'new'){
|
if(isset($_POST['method']) && $_POST['method'] == 'new'){
|
||||||
$id = OC_Contacts_Addressbook::add(OC_User::getUser(), $_POST['addressbookname']);
|
$id = OC_Contacts_Addressbook::add(OCP\USER::getUser(), $_POST['addressbookname']);
|
||||||
OC_Contacts_Addressbook::setActive($id, 1);
|
OC_Contacts_Addressbook::setActive($id, 1);
|
||||||
}else{
|
}else{
|
||||||
$id = $_POST['id'];
|
$id = $_POST['id'];
|
||||||
|
4
index.php
Normal file → Executable file
4
index.php
Normal file → Executable file
@ -13,10 +13,10 @@ OC_Util::checkLoggedIn();
|
|||||||
OC_Util::checkAppEnabled('contacts');
|
OC_Util::checkAppEnabled('contacts');
|
||||||
|
|
||||||
// Get active address books. This creates a default one if none exists.
|
// Get active address books. This creates a default one if none exists.
|
||||||
$ids = OC_Contacts_Addressbook::activeIds(OC_User::getUser());
|
$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
|
||||||
$contacts = OC_Contacts_VCard::all($ids);
|
$contacts = OC_Contacts_VCard::all($ids);
|
||||||
|
|
||||||
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
|
$addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
|
||||||
|
|
||||||
// Load the files we need
|
// Load the files we need
|
||||||
OC_App::setActiveNavigationEntry( 'contacts_index' );
|
OC_App::setActiveNavigationEntry( 'contacts_index' );
|
||||||
|
@ -166,7 +166,7 @@ class OC_Contacts_Addressbook{
|
|||||||
*/
|
*/
|
||||||
public static function activeIds($uid = null){
|
public static function activeIds($uid = null){
|
||||||
if(is_null($uid)){
|
if(is_null($uid)){
|
||||||
$uid = OC_User::getUser();
|
$uid = OCP\USER::getUser();
|
||||||
}
|
}
|
||||||
$prefbooks = OC_Preferences::getValue($uid,'contacts','openaddressbooks',null);
|
$prefbooks = OC_Preferences::getValue($uid,'contacts','openaddressbooks',null);
|
||||||
if(!$prefbooks){
|
if(!$prefbooks){
|
||||||
@ -235,7 +235,7 @@ class OC_Contacts_Addressbook{
|
|||||||
$openaddressbooks = self::cleanArray($openaddressbooks, false);
|
$openaddressbooks = self::cleanArray($openaddressbooks, false);
|
||||||
sort($openaddressbooks, SORT_NUMERIC);
|
sort($openaddressbooks, SORT_NUMERIC);
|
||||||
// FIXME: I alway end up with a ';' prepending when imploding the array..?
|
// FIXME: I alway end up with a ';' prepending when imploding the array..?
|
||||||
OC_Preferences::setValue(OC_User::getUser(),'contacts','openaddressbooks',implode(';', $openaddressbooks));
|
OC_Preferences::setValue(OCP\USER::getUser(),'contacts','openaddressbooks',implode(';', $openaddressbooks));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,13 @@ class OC_Contacts_App {
|
|||||||
|
|
||||||
public static function getAddressbook($id) {
|
public static function getAddressbook($id) {
|
||||||
$addressbook = OC_Contacts_Addressbook::find( $id );
|
$addressbook = OC_Contacts_Addressbook::find( $id );
|
||||||
if( $addressbook === false || $addressbook['userid'] != OC_User::getUser()) {
|
if( $addressbook === false || $addressbook['userid'] != OCP\USER::getUser()) {
|
||||||
if ($addressbook === false) {
|
if ($addressbook === false) {
|
||||||
OCP\Util::writeLog('contacts', 'Addressbook not found: '. $id, OCP\Util::ERROR);
|
OCP\Util::writeLog('contacts', 'Addressbook not found: '. $id, OCP\Util::ERROR);
|
||||||
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.'))));
|
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.'))));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
OCP\Util::writeLog('contacts', 'Addressbook('.$id.') is not from '.OC_User::getUser(), OCP\Util::ERROR);
|
OCP\Util::writeLog('contacts', 'Addressbook('.$id.') is not from '.OCP\USER::getUser(), OCP\Util::ERROR);
|
||||||
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.'))));
|
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.'))));
|
||||||
}
|
}
|
||||||
exit();
|
exit();
|
||||||
@ -145,7 +145,7 @@ class OC_Contacts_App {
|
|||||||
*/
|
*/
|
||||||
public static function scanCategories($vccontacts = null) {
|
public static function scanCategories($vccontacts = null) {
|
||||||
if (is_null($vccontacts)) {
|
if (is_null($vccontacts)) {
|
||||||
$vcaddressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
|
$vcaddressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
|
||||||
if(count($vcaddressbooks) > 0) {
|
if(count($vcaddressbooks) > 0) {
|
||||||
$vcaddressbookids = array();
|
$vcaddressbookids = array();
|
||||||
foreach($vcaddressbooks as $vcaddressbook) {
|
foreach($vcaddressbooks as $vcaddressbook) {
|
||||||
|
2
lib/hooks.php
Normal file → Executable file
2
lib/hooks.php
Normal file → Executable file
@ -41,7 +41,7 @@ class OC_Contacts_Hooks{
|
|||||||
|
|
||||||
static public function getCalenderSources($parameters) {
|
static public function getCalenderSources($parameters) {
|
||||||
$base_url = OC_Helper::linkTo('calendar', 'ajax/events.php').'?calendar_id=';
|
$base_url = OC_Helper::linkTo('calendar', 'ajax/events.php').'?calendar_id=';
|
||||||
foreach(OC_Contacts_Addressbook::all(OC_User::getUser()) as $addressbook) {
|
foreach(OC_Contacts_Addressbook::all(OCP\USER::getUser()) as $addressbook) {
|
||||||
$parameters['sources'][] =
|
$parameters['sources'][] =
|
||||||
array(
|
array(
|
||||||
'url' => $base_url.'birthday_'. $addressbook['id'],
|
'url' => $base_url.'birthday_'. $addressbook['id'],
|
||||||
|
2
lib/search.php
Normal file → Executable file
2
lib/search.php
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
class OC_Search_Provider_Contacts extends OC_Search_Provider{
|
class OC_Search_Provider_Contacts extends OC_Search_Provider{
|
||||||
function search($query){
|
function search($query){
|
||||||
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser(), 1);
|
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1);
|
||||||
// if(count($calendars)==0 || !OC_App::isEnabled('contacts')){
|
// if(count($calendars)==0 || !OC_App::isEnabled('contacts')){
|
||||||
// //return false;
|
// //return false;
|
||||||
// }
|
// }
|
||||||
|
2
templates/index.php
Normal file → Executable file
2
templates/index.php
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var totalurl = '<?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/addressbooks';
|
var totalurl = '<?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/addressbooks';
|
||||||
var categories = <?php echo json_encode($_['categories']); ?>;
|
var categories = <?php echo json_encode($_['categories']); ?>;
|
||||||
var lang = '<?php echo OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang', 'en'); ?>';
|
var lang = '<?php echo OC_Preferences::getValue(OCP\USER::getUser(), 'core', 'lang', 'en'); ?>';
|
||||||
</script>
|
</script>
|
||||||
<!-- div id="controls">
|
<!-- div id="controls">
|
||||||
<form>
|
<form>
|
||||||
|
2
templates/part.chooseaddressbook.php
Normal file → Executable file
2
templates/part.chooseaddressbook.php
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
<div id="chooseaddressbook_dialog" title="<?php echo $l->t("Configure Address Books"); ?>">
|
<div id="chooseaddressbook_dialog" title="<?php echo $l->t("Configure Address Books"); ?>">
|
||||||
<table width="100%" style="border: 0;">
|
<table width="100%" style="border: 0;">
|
||||||
<?php
|
<?php
|
||||||
$option_addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
|
$option_addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
|
||||||
for($i = 0; $i < count($option_addressbooks); $i++){
|
for($i = 0; $i < count($option_addressbooks); $i++){
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields');
|
$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields');
|
||||||
|
2
templates/part.chooseaddressbook.rowfields.php
Normal file → Executable file
2
templates/part.chooseaddressbook.rowfields.php
Normal file → Executable file
@ -2,4 +2,4 @@
|
|||||||
// FIXME: Make this readable.
|
// FIXME: Make this readable.
|
||||||
echo "<td width=\"20px\"><input id=\"active_" . $_['addressbook']["id"] . "\" type=\"checkbox\" onClick=\"Contacts.UI.Addressbooks.activation(this, " . $_['addressbook']["id"] . ")\"" . (OC_Contacts_Addressbook::isActive($_['addressbook']["id"]) ? ' checked="checked"' : '') . "></td>";
|
echo "<td width=\"20px\"><input id=\"active_" . $_['addressbook']["id"] . "\" type=\"checkbox\" onClick=\"Contacts.UI.Addressbooks.activation(this, " . $_['addressbook']["id"] . ")\"" . (OC_Contacts_Addressbook::isActive($_['addressbook']["id"]) ? ' checked="checked"' : '') . "></td>";
|
||||||
echo "<td><label for=\"active_" . $_['addressbook']["id"] . "\">" . htmlspecialchars($_['addressbook']["displayname"]) . "</label></td>";
|
echo "<td><label for=\"active_" . $_['addressbook']["id"] . "\">" . htmlspecialchars($_['addressbook']["displayname"]) . "</label></td>";
|
||||||
echo "<td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.showCardDAVUrl('" . OC_User::getUser() . "', '" . rawurlencode($_['addressbook']["uri"]) . "');\" title=\"" . $l->t("CardDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?bookid=" . $_['addressbook']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Contacts.UI.Addressbooks.editAddressbook(this, " . $_['addressbook']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.Addressbooks.deleteAddressbook(this, '" . $_['addressbook']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>";
|
echo "<td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.showCardDAVUrl('" . OCP\USER::getUser() . "', '" . rawurlencode($_['addressbook']["uri"]) . "');\" title=\"" . $l->t("CardDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?bookid=" . $_['addressbook']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Contacts.UI.Addressbooks.editAddressbook(this, " . $_['addressbook']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.Addressbooks.deleteAddressbook(this, '" . $_['addressbook']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>";
|
||||||
|
2
templates/part.import.php
Normal file → Executable file
2
templates/part.import.php
Normal file → Executable file
@ -6,7 +6,7 @@
|
|||||||
<p style="text-align:center;"><b><?php echo $l->t('Please choose the addressbook'); ?></b>
|
<p style="text-align:center;"><b><?php echo $l->t('Please choose the addressbook'); ?></b>
|
||||||
<select style="width:100%;" id="contacts" name="contacts">
|
<select style="width:100%;" id="contacts" name="contacts">
|
||||||
<?php
|
<?php
|
||||||
$contacts_options = OC_Contacts_Addressbook::all(OC_User::getUser());
|
$contacts_options = OC_Contacts_Addressbook::all(OCP\USER::getUser());
|
||||||
$contacts_options[] = array('id'=>'newaddressbook', 'displayname'=>$l->t('create a new addressbook'));
|
$contacts_options[] = array('id'=>'newaddressbook', 'displayname'=>$l->t('create a new addressbook'));
|
||||||
echo html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname'));
|
echo html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname'));
|
||||||
?>
|
?>
|
||||||
|
2
templates/part.importaddressbook.php
Normal file → Executable file
2
templates/part.importaddressbook.php
Normal file → Executable file
@ -13,7 +13,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<select id="book" name="book" class="float">
|
<select id="book" name="book" class="float">
|
||||||
<?php
|
<?php
|
||||||
$contacts_options = OC_Contacts_Addressbook::all(OC_User::getUser());
|
$contacts_options = OC_Contacts_Addressbook::all(OCP\USER::getUser());
|
||||||
echo html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname'));
|
echo html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname'));
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
2
templates/settings.php
Normal file → Executable file
2
templates/settings.php
Normal file → Executable file
@ -6,7 +6,7 @@
|
|||||||
<dt><?php echo $l->t('Primary address (Kontact et al)'); ?></dt>
|
<dt><?php echo $l->t('Primary address (Kontact et al)'); ?></dt>
|
||||||
<dd><code><?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/</code></dd>
|
<dd><code><?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/</code></dd>
|
||||||
<dt><?php echo $l->t('iOS/OS X'); ?></dt>
|
<dt><?php echo $l->t('iOS/OS X'); ?></dt>
|
||||||
<dd><code><?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/principals/<?php echo OC_User::getUser(); ?></code>/</dd>
|
<dd><code><?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/principals/<?php echo OCP\USER::getUser(); ?></code>/</dd>
|
||||||
</dl>
|
</dl>
|
||||||
Powered by <a href="http://geonames.org/" target="_blank">geonames.org webservice</a>
|
Powered by <a href="http://geonames.org/" target="_blank">geonames.org webservice</a>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
Loading…
Reference in New Issue
Block a user