Пример #1
0
 public function getNews()
 {
     if (!$this->itembusinesslayer) {
         $this->getNewsapi();
     }
     $lastId = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_newsreader_lastItemId", 0);
     $items = $this->itembusinesslayer->findAllNew(0, \OCA\News\Db\FeedType::SUBSCRIPTIONS, 0, false, $this->user);
     $items = array_reverse($items);
     $newsitemfound = false;
     $itemcount = 0;
     foreach ($items as $item) {
         $itemdata = $item->toAPI();
         $itemcount++;
         // if the last newsitem was the las showen item => this is the next
         if ($newsitemfound) {
             OCP\Config::setUserValue($this->user, "ocDashboard", "ocDashboard_newsreader_lastItemId", $itemdata['id']);
             $itemdata["count"] = count($items);
             $itemdata["actual"] = $itemcount;
             return $itemdata;
         }
         // if newsitem is the last one
         if ($itemdata['id'] == $lastId) {
             $newsitemfound = true;
         }
     }
     if (reset($items)) {
         $itemdata = reset($items)->toAPI();
         OCP\Config::setUserValue($this->user, "ocDashboard", "ocDashboard_newsreader_lastItemId", $itemdata['id']);
         $itemdata["count"] = count($items);
         $itemdata["actual"] = 1;
         return $itemdata;
     } else {
         return null;
     }
 }
Пример #2
0
 private function updateEmail($dn)
 {
     $email = null;
     if (!empty($this->ldapEmailAttribute)) {
         $aEmail = OC_LDAP::readAttribute($dn, $this->ldapEmailAttribute);
         if ($aEmail && count($aEmail) > 0) {
             $email = $aEmail[0];
         }
         if (!is_null($email)) {
             OCP\Config::setUserValue(OC_LDAP::dn2username($dn), 'settings', 'email', $email);
         }
     }
 }
Пример #3
0
function handleStoreSettings($root, $order)
{
    if (!OC_Filesystem::file_exists($root)) {
        OCP\JSON::error(array('cause' => 'No such file or directory'));
        return;
    }
    if (!OC_Filesystem::is_dir($root)) {
        OCP\JSON::error(array('cause' => $root . ' is not a directory'));
        return;
    }
    $current_root = OCP\Config::getUserValue(OCP\USER::getUser(), 'gallery', 'root', '/');
    $root = trim($root);
    $root = rtrim($root, '/') . '/';
    $rescan = $current_root == $root ? 'no' : 'yes';
    OCP\Config::setUserValue(OCP\USER::getUser(), 'gallery', 'root', $root);
    OCP\Config::setUserValue(OCP\USER::getUser(), 'gallery', 'order', $order);
    OCP\JSON::success(array('rescan' => $rescan));
}
Пример #4
0
<?php

/**
 * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
if (isset($_POST["firstday"])) {
    OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'firstday', $_POST["firstday"]);
    OCP\JSON::success();
} else {
    OCP\JSON::error();
}
Пример #5
0
    $arguments['album'] = 0;
}
if (!isset($arguments['search'])) {
    $arguments['search'] = '';
}
session_write_close();
OC_MEDIA_COLLECTION::$uid = OCP\USER::getUser();
if ($arguments['action']) {
    switch ($arguments['action']) {
        case 'delete':
            $path = $arguments['path'];
            OC_MEDIA_COLLECTION::deleteSongByPath($path);
            $paths = explode(PATH_SEPARATOR, OCP\Config::getUserValue(OCP\USER::getUser(), 'media', 'paths', ''));
            if (array_search($path, $paths) !== false) {
                unset($paths[array_search($path, $paths)]);
                OCP\Config::setUserValue(OCP\USER::getUser(), 'media', 'paths', implode(PATH_SEPARATOR, $paths));
            }
        case 'get_collection':
            $data = array();
            $data['artists'] = OC_MEDIA_COLLECTION::getArtists();
            $data['albums'] = OC_MEDIA_COLLECTION::getAlbums();
            $data['songs'] = OC_MEDIA_COLLECTION::getSongs();
            OCP\JSON::encodedPrint($data);
            break;
        case 'scan':
            OCP\DB::beginTransaction();
            set_time_limit(0);
            //recursive scan can take a while
            $eventSource = new OC_EventSource();
            OC_MEDIA_SCANNER::scanCollection($eventSource);
            $eventSource->close();
Пример #6
0
<?php

/**
 * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
if (isset($_POST["timeformat"])) {
    OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]);
    OCP\JSON::success();
} else {
    OCP\JSON::error();
}
Пример #7
0
<?php

OCP\Util::addStyle('tattoo', 'settings');
// die($_POST['tattooWallpaper']);
if (isset($_POST['tattooSetWallpaper']) && isset($_POST['tattooWallpaper'])) {
    OCP\Config::setUserValue(OCP\User::getUser(), 'tattoo', 'wallpaper', $_POST['tattooWallpaper']);
    OCP\Config::setUserValue(OCP\User::getUser(), 'tattoo', 'lastModified', gmdate('D, d M Y H:i:s') . ' GMT');
}
$wallpaper = OCP\Config::getUserValue(OCP\User::getUser(), 'tattoo', 'wallpaper', 'none');
$tmpl = new OCP\Template('tattoo', 'settings');
$tmpl->assign('tattooSelectedWallpaper', $wallpaper);
return $tmpl->fetchPage();
<?php

/**
 * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
if (array_key_exists('timezonedetection', $_POST) && $_POST['timezonedetection'] == 'on') {
    OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection', 'true');
} else {
    OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection', 'false');
}
OCP\JSON::success();
Пример #9
0
/**
 * ownCloud - RainLoop mail plugin
 *
 * @author RainLoop Team
 * @copyright 2015 RainLoop Team
 *
 * https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('rainloop');
OCP\JSON::callCheck();
$sEmail = '';
$sLogin = '';
if (isset($_POST['appname'], $_POST['rainloop-password'], $_POST['rainloop-email']) && 'rainloop' === $_POST['appname']) {
    $sUser = OCP\User::getUser();
    $sPostEmail = $_POST['rainloop-email'];
    OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-email', $sPostEmail);
    $sPass = $_POST['rainloop-password'];
    if ('******' !== $sPass && '' !== $sPass) {
        include_once OC_App::getAppPath('rainloop') . '/lib/RainLoopHelper.php';
        OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-password', OC_RainLoop_Helper::encodePassword($sPass, md5($sPostEmail)));
    }
    $sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', '');
} else {
    sleep(1);
    OC_JSON::error(array('Message' => 'Invalid argument(s)', 'Email' => $sEmail));
    return false;
}
sleep(1);
OCP\JSON::success(array('Message' => 'Saved successfully', 'Email' => $sEmail));
return true;
Пример #10
0
 /**
  * Stores information about trusted/untrusted site for given user
  *
  * @param string $id user identity URL
  * @param string $site site URL
  * @param mixed $trusted trust data from extension or just a boolean value
  */
 public function addSite($id, $site, $trusted)
 {
     $username = $this->getUsernameFromId($id);
     $data = OCP\Config::getUserValue($username, 'user_openid_provider', 'trusted_sites');
     $sites = array();
     if (!empty($data)) {
         $sites = unserialize($data);
     }
     if ($trusted === null) {
         unset($sites[$site]);
     } else {
         $sites[$site] = $trusted;
     }
     $data = serialize($sites);
     OCP\Config::setUserValue($username, 'user_openid_provider', 'trusted_sites', $data);
 }
Пример #11
0
 * 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 Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
/**
 * @brief Set user preference.
 * @param $key
 * @param $value
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
require_once 'loghandler.php';
$key = isset($_POST['key']) ? $_POST['key'] : null;
$value = isset($_POST['value']) ? $_POST['value'] : null;
if (is_null($key)) {
    bailOut(OCA\Contacts\App::$l10n->t('Key is not set for: ' . $value));
}
if (is_null($value)) {
    bailOut(OCA\Contacts\App::$l10n->t('Value is not set for: ' . $key));
}
if (OCP\Config::setUserValue(OCP\USER::getUser(), 'contacts', $key, $value)) {
    OCP\JSON::success(array('data' => array('key' => $key, 'value' => $value)));
} else {
    bailOut(OCA\Contacts\App::$l10n->t('Could not set preference: ' . $key . ':' . $value));
}
Пример #12
0
*
* 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 Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('activity');
OCP\JSON::callCheck();
$notify_email = $notify_stream = array();
$l = OCP\Util::getL10N('activity');
$data = new \OCA\Activity\Data(\OC::$server->getActivityManager());
$types = $data->getNotificationTypes($l);
foreach ($types as $type => $desc) {
    OCP\Config::setUserValue(OCP\User::getUser(), 'activity', 'notify_email_' . $type, !empty($_POST[$type . '_email']));
    OCP\Config::setUserValue(OCP\User::getUser(), 'activity', 'notify_stream_' . $type, !empty($_POST[$type . '_stream']));
}
$email_batch_time = 3600;
if ($_POST['notify_setting_batchtime'] == \OCA\Activity\UserSettings::EMAIL_SEND_DAILY) {
    $email_batch_time = 3600 * 24;
}
if ($_POST['notify_setting_batchtime'] == \OCA\Activity\UserSettings::EMAIL_SEND_WEEKLY) {
    $email_batch_time = 3600 * 24 * 7;
}
OCP\Config::setUserValue(OCP\User::getUser(), 'activity', 'notify_setting_batchtime', $email_batch_time);
OCP\Config::setUserValue(OCP\User::getUser(), 'activity', 'notify_setting_self', !empty($_POST['notify_setting_self']));
OC_JSON::success(array("data" => array("message" => $l->t('Your settings have been updated.'))));
Пример #13
0
<?php

/*
 * with respect to core/ajax/appconfig.php by Robin Appelman
 * @author Florian Steffens
 */
OCP\JSON::callCheck();
$action = isset($_POST['action']) ? $_POST['action'] : $_GET['action'];
$user = OCP\User::getUser();
$result = false;
switch ($action) {
    case 'setValue':
        $result = OCP\Config::setUserValue($user, $_POST['app'], $_POST['key'], $_POST['value']);
        break;
        /*	case 'getValue':
        		$result=OC_Appconfig::getValue($_GET['app'], $_GET['key'], $_GET['defaultValue']);
        		break;
        	case 'getApps':
        		$result=OC_Appconfig::getApps();
        		break;
        	case 'getKeys':
        		$result=OC_Appconfig::getKeys($_GET['app']);
        		break;
        	case 'hasKey':
        		$result=OC_Appconfig::hasKey($_GET['app'], $_GET['key']);
        		break;
        	case 'deleteKey':
        		$result=OC_Appconfig::deleteKey($_POST['app'], $_POST['key']);
        		break;
        	case 'deleteApp':
        		$result=OC_Appconfig::deleteApp($_POST['app']);
Пример #14
0
* Copyright (c) 2012 - Alessandro Cosentino <*****@*****.**>
*
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file
*
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('news');
OCP\JSON::callCheck();
session_write_close();
require_once OC_App::getAppPath('news') . '/lib/feedtypes.php';
require_once OC_App::getAppPath('news') . '/controllers/controller.php';
require_once OC_App::getAppPath('news') . '/controllers/news.controller.php';
$userid = OCP\USER::getUser();
$feedId = (int) $_POST['id'];
$feedType = (int) $_POST['type'];
OCP\Config::setUserValue(OCP\USER::getUser(), 'news', 'lastViewedFeed', $feedId);
OCP\Config::setUserValue(OCP\USER::getUser(), 'news', 'lastViewedFeedType', $feedType);
$showAll = OCP\Config::getUserValue(OCP\USER::getUser(), 'news', 'showAll');
$newsController = new OCA\News\NewsController();
$items = $newsController->getItems($feedType, $feedId, $showAll);
$unreadItemCount = $newsController->getItemUnreadCount($feedType, $feedId);
$l = OC_L10N::get('news');
$itemsTpl = new OCP\Template("news", "part.items");
$itemsTpl->assign('lastViewedFeedId', $feedId);
$itemsTpl->assign('lastViewedFeedType', $feedType);
$itemsTpl->assign('items', $items, false);
$feedItems = $itemsTpl->fetchPage();
$itemMapper = new OCA\News\ItemMapper();
OCP\JSON::success(array('data' => array('message' => $l->t('Feed loaded!'), 'feedItems' => $feedItems, 'unreadItemCount' => $unreadItemCount)));
Пример #15
0
<?php

OCP\JSON::checkLoggedIn();
if (isset($_POST["flag"])) {
    $flag = (bool) $_POST["flag"];
} else {
    OCP\JSON::error(array("message" => "Missing flag argument"));
}
try {
    OCP\Config::setUserValue(OCP\User::getUser(), 'notify', 'autorefresh', $flag);
    OCP\JSON::success();
} catch (Exception $e) {
    OCP\JSON::error(array("message" => $e->getMessage()));
}
* 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 Affero General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
OCP\JSON::checkAppEnabled('conversations');
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$room = isset($_REQUEST['room']) ? $_REQUEST['room'] : false;
// TODO: remove room argument!
if ($room) {
    // store room as user default
    OCP\Config::setUserValue(OC_User::getUser(), 'conversations', 'activeRoom', $room);
    // read the next 30 items for the endless scrolling
    // get the page that is requested. Needed for endless scrolling
    $count = 5;
    $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 0;
    $from_id = isset($_REQUEST['from_id']) ? intval($_REQUEST['from_id']) : null;
    // load room
    $tmpl = new OCP\Template('conversations', 'part.conversation');
    $tmpl->assign('conversation', OC_Conversations::getConversation(false, $page * $count, $count, $from_id));
    if (isset($_REQUEST['print_tmpl'])) {
        // print for infinite scroll
        $tmpl->printPage();
    } else {
        // return json for submit or polling
        $conversation = $tmpl->fetchPage();
        OCP\JSON::success(array('data' => array('conversation' => $conversation)));
Пример #17
0
 public static function changePassword($aParams)
 {
     if (isset($aParams['uid'], $aParams['password'])) {
         $sUser = $aParams['uid'];
         $sEmail = $sUser;
         $sPassword = $aParams['password'];
         OCP\Util::writeLog('rainloop', 'rainloop|login: Setting new RainLoop password for ' . $sEmail, OCP\Util::DEBUG);
         OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-autologin-password', self::encodePassword($sPassword, md5($sEmail)));
         OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-password', self::encodePassword($sPassword, md5($sEmail)));
         return true;
     }
     return false;
 }
Пример #18
0
<?php

/**
 * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
OCP\JSON::callCheck();
$view = $_POST['v'];
switch ($view) {
    case 'agendaWeek':
    case 'month':
    case 'agendaDay':
        break;
    default:
        OCP\JSON::error(array('message' => 'unexpected parameter: ' . $view));
        exit;
}
OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'currentview', $view);
OCP\JSON::success();
Пример #19
0
<?php

/**
* ownCloud - media plugin
*
* @author Robin Appelman
* @copyright 2010 Robin Appelman icewind1991@gmail.com
* 
* 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/>.
* 
*/
header('Content-type: text/html; charset=UTF-8');
//no apps or filesystem
$RUNTIME_NOAPPS = true;
$RUNTIME_NOSETUPFS = true;
OCP\JSON::checkAppEnabled('media');
$autoUpdate = (isset($_GET['autoupdate']) and $_GET['autoupdate'] == 'true');
OCP\Config::setUserValue(OCP\USER::getUser(), 'media', 'autoupdate', (int) $autoUpdate);
OCP\JSON::success(array('data' => $autoUpdate));
 public static function changePassword($aParams)
 {
     if (isset($aParams['uid'], $aParams['password'])) {
         $sUser = $aParams['uid'];
         $sEmail = $sUser;
         $sPassword = $aParams['password'];
         $sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', ''));
         $sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', ''));
         if ('' !== $sUrl && '' !== $sPath) {
             OCP\Util::writeLog('rainloop', 'rainloop|login: Setting new RainLoop password for ' . $sEmail, OCP\Util::DEBUG);
             $sPassword = self::encodePassword($sPassword, md5($sEmail));
             return OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-password', $sPassword);
         }
     }
     return false;
 }
Пример #21
0
	switch ( $_SERVER['REQUEST_METHOD'] )
	{
		case 'POST':
			// detect provided preferences
			$data = array();
			foreach (array_keys($_POST) as $key)
			{
				if ( isset(OC_Shorty_Type::$PREFERENCE[$key]) ) // ignore unknown preference keys
				{
					$type = OC_Shorty_Type::$PREFERENCE[$key];
					$data[$key] = OC_Shorty_Type::req_argument ( $key, $type, FALSE );
				}
			}
			// store settings
			foreach ( $data as $key=>$val )
				OCP\Config::setUserValue( OCP\User::getUser(), 'shorty', $key, $val );
			// swallow any accidential output generated by php notices and stuff to preserve a clean JSON reply structure
			OC_Shorty_Tools::ob_control ( FALSE );
			OCP\Util::writeLog( 'shorty', sprintf("Preference '%s' saved",implode(',',array_keys($data))), OCP\Util::DEBUG );
			OCP\JSON::success (
				array (
					'data'    => $data,
					'level'   => 'debug',
 					'message' => OC_Shorty_L10n::t("Preference '%s' saved",implode(',',array_keys($data)))
				)
			);
			break;

		case 'GET':
			// detect requested preferences
			foreach (array_keys($_GET) as $key)
Пример #22
0
	public static function setRoomTime( $room=false, $lastmsg=false ) {		
		$userId = OC_User::getUser();
		$room = ( $room ) ? $room : self::getRoom();
		$time = time();

		$rtype = explode(":", $room);
		$rtype = $rtype[0];		

		/*
		if ( ! $lastmsg ) {
			$query = OCP\DB::prepare("SELECT id FROM *PREFIX*conversations WHERE room = ? ORDER BY id DESC", 1, 0);
			$lastmsg = $query->execute( array($room) )->fetch();
			$lastmsg = ( !$lastmsg ) ? 0 : $lastmsg['id'];
		}		
		*/

		$conf = OCP\Config::getUserValue( $userId, 'conversations', 'conf', false );
		$conf = ( ! $conf ) ? array() : unserialize( $conf );
		//$conf['rooms'][$room]['lastmsg'] = $lastmsg;
		$conf['rooms'][$room]['wtime'] = $time;

		OCP\Config::setUserValue( $userId, 'conversations', 'conf', serialize($conf));	

		if ( $rtype == "group" ) {
			$gconf = OCP\Config::getAppValue( 'conversations', 'conf', false );
			$gconf = ( ! $gconf ) ? array() : unserialize( $gconf );
			//$gconf['rooms'][$room]['lastmsg'] = $lastmsg;
			$gconf['rooms'][$room]['wtime'] = $time;
			OCP\Config::setAppValue( 'conversations', 'conf', serialize($gconf) );
		}			
	}
Пример #23
0
         throw new Exception("Missing key in ajax method.");
     }
     if (!array_key_exists($_POST['key'], $validPreferences)) {
         throw new Exception("Unknown key in ajax method.");
     }
     // check for a valid value
     if (!array_key_exists('value', $_POST)) {
         throw new Exception("Missing value in ajax method.");
     }
     if (!$validPreferences[$_POST['key']]['validate']($_POST['value'])) {
         throw new Exception("Unknown type of value in ajax method.");
     }
     // normalize value
     $value = $validPreferences[$_POST['key']]['normalize']($_POST['value'], 0);
     // store preference
     OCP\Config::setUserValue(OCP\User::getUser(), 'fluxx_compensator', $_POST['key'], $value);
     // return success
     OCP\JSON::success(array('value' => $value));
     break;
 case 'GET':
     // check if a valid key has been specified
     if (!array_key_exists('key', $_GET)) {
         throw new Exception("Missing key in ajax method.");
     }
     if (!array_key_exists($_GET['key'], $validPreferences)) {
         throw new Exception("Unknown key in ajax method.");
     }
     // check for a valid default value
     if (!array_key_exists('value', $_GET)) {
         throw new Exception("Missing value in ajax method.");
     }
Пример #24
0
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
/**
 * @brief Index vCard properties for easier searching
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
require_once 'loghandler.php';
$addressbooks = OCA\Contacts\Addressbook::all(OCP\USER::getUser());
$ids = array();
foreach ($addressbooks as $addressbook) {
    $ids[] = $addressbook['id'];
}
$user = OCP\User::getUser();
session_write_close();
$start = 0;
$batchsize = 10;
while ($contacts = OCA\Contacts\VCard::all($ids, $start, $batchsize)) {
    OCP\Util::writeLog('contacts', 'Indexing contacts: ' . $batchsize . ' starting from ' . $start, OCP\Util::DEBUG);
    foreach ($contacts as $contact) {
        $vcard = OC_VObject::parse($contact['carddata']);
        OCA\Contacts\App::updateDBProperties($contact['id'], $vcard);
    }
    $start += $batchsize;
}
OCP\Config::setUserValue($user, 'contacts', 'contacts_indexed', 'yes');
Пример #25
0
<?php

/**
 * Copyright (c) 2011 Bart Visscher <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
// Init owncloud
$l = OCP\Util::getL10N('calendar');
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
OCP\JSON::callCheck();
// Get data
if (isset($_POST['defaultalarms'])) {
    $defaultalarms = $_POST['defaultalarms'];
    $match = preg_match('/^(?:display){0,1}?\\b\\|?(?:email){0,1}?\\b\\|?(?:webhook){0,1}?\\b$/i', $defaultalarms);
    if ($match === 1 or empty($defaultalarms)) {
        OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'defaultalarms', strtoupper($defaultalarms));
        OCP\JSON::success(array('data' => array('message' => $l->t('Default reminders changed'))));
    } else {
        OCP\JSON::error(array('data' => array('message' => $l->t('Invalid request'))));
    }
} else {
    OCP\JSON::error(array('data' => array('message' => $l->t('Invalid request'))));
}
Пример #26
0
 /**
  * @brief Activates an addressbook
  * @param integer $id
  * @param integer $name
  * @return boolean
  */
 public static function setActive($id, $active = true)
 {
     // Need these ones for checking uri
     //$addressbook = self::find($id);
     if (is_null($id)) {
         $id = 0;
     }
     $openaddressbooks = self::activeIds();
     if ($active) {
         if (!in_array($id, $openaddressbooks)) {
             $openaddressbooks[] = $id;
         }
     } else {
         if (in_array($id, $openaddressbooks)) {
             unset($openaddressbooks[array_search($id, $openaddressbooks)]);
         }
     }
     // NOTE: Ugly hack...
     $openaddressbooks = self::cleanArray($openaddressbooks, false);
     sort($openaddressbooks, SORT_NUMERIC);
     // FIXME: I alway end up with a ';' prepending when imploding the array..?
     OCP\Config::setUserValue(OCP\USER::getUser(), 'contacts', 'openaddressbooks', implode(';', $openaddressbooks));
     return true;
 }
Пример #27
0
foreach ($calendars as $calendar) {
    $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar);
}
$eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_rw', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'true');
$eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_r', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false');
OCP\Util::emitHook('OC_Calendar', 'getSources', array('sources' => &$eventSources));
$categories = OC_Calendar_App::getCategoryOptions();
//Fix currentview for fullcalendar
if (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview") {
    OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "agendaWeek");
}
if (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview") {
    OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "month");
}
if (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "listview") {
    OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "list");
}
OCP\Util::addscript('3rdparty/fullcalendar', 'fullcalendar');
OCP\Util::addStyle('3rdparty/fullcalendar', 'fullcalendar');
OCP\Util::addscript('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
if (OCP\Config::getUserValue(OCP\USER::getUser(), "calendar", "timezone") == null || OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection') == 'true') {
    OCP\Util::addscript('calendar', 'geo');
}
OCP\Util::addscript('calendar', 'calendar');
OCP\Util::addStyle('calendar', 'style');
OCP\Util::addscript('', 'jquery.multiselect');
OCP\Util::addStyle('', 'jquery.multiselect');
OCP\Util::addscript('contacts', 'jquery.multi-autocomplete');
OCP\Util::addscript('', 'oc-vcategories');
OCP\App::setActiveNavigationEntry('calendar_index');
Пример #28
0
<?php

/**
* ownCloud - News app
*
* @author Bernhard Posselt
* Copyright (c) 2012 - Bernhard Posselt <*****@*****.**>
* 
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file
* 
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('news');
OCP\JSON::callCheck();
session_write_close();
if (isset($_POST['showAll'])) {
    if ($_POST['showAll'] === 'false') {
        $showAll = false;
    } else {
        $showAll = true;
    }
    OCP\Config::setUserValue(OCP\USER::getUser(), 'news', 'showAll', $showAll);
}
OCP\JSON::success();
Пример #29
0
<?php

/**
 * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
OCP\JSON::callCheck();
$l = OCP\Util::getL10N('calendar');
$lat = $_POST['lat'];
$lng = $_POST['lng'];
$timezone = OC_Geo::timezone($lat, $lng);
if ($timezone == OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone')) {
    OCP\JSON::success();
    exit;
}
OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezone', $timezone);
$message = array('message' => $l->t('New Timezone:') . $timezone);
OCP\JSON::success($message);
Пример #30
0
<?php

OCP\User::checkLoggedIn();
OCP\JSON::callCheck();
$user = OCP\User::getUser();
$options = OCP\Config::getUserValue($user, 'ojsxc', 'options');
$options = json_decode($options, true);
foreach ($_POST as $key => $val) {
    $options[$key] = $val;
}
echo OCP\Config::setUserValue($user, 'ojsxc', 'options', json_encode($options));