Пример #1
0
 /**
  * @brief Adds a card
  * @param $aid integer Addressbook id
  * @param $card OC_VObject  vCard file
  * @param $uri string the uri of the card, default based on the UID
  * @param $isChecked boolean If the vCard should be checked for validity and version.
  * @return insertid on success or false.
  */
 public static function add($aid, OC_VObject $card, $uri = null, $isChecked = false)
 {
     if (is_null($card)) {
         OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR);
         return null;
     }
     $addressbook = OC_Contacts_Addressbook::find($aid);
     if ($addressbook['userid'] != OCP\User::getUser()) {
         $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $aid);
         if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_CREATE)) {
             throw new Exception(OC_Contacts_App::$l10n->t('You do not have the permissions to add contacts to this addressbook.'));
         }
     }
     if (!$isChecked) {
         OC_Contacts_App::loadCategoriesFromVCard($card);
         self::updateValuesFromAdd($aid, $card);
     }
     $card->setString('VERSION', '3.0');
     // Add product ID is missing.
     $prodid = trim($card->getAsString('PRODID'));
     if (!$prodid) {
         $appinfo = OCP\App::getAppInfo('contacts');
         $appversion = OCP\App::getAppVersion('contacts');
         $prodid = '-//ownCloud//NONSGML ' . $appinfo['name'] . ' ' . $appversion . '//EN';
         $card->setString('PRODID', $prodid);
     }
     $fn = $card->getAsString('FN');
     if (empty($fn)) {
         $fn = '';
     }
     if (!$uri) {
         $uid = $card->getAsString('UID');
         $uri = $uid . '.vcf';
     }
     $data = $card->serialize();
     $stmt = OCP\DB::prepare('INSERT INTO `*PREFIX*contacts_cards` (`addressbookid`,`fullname`,`carddata`,`uri`,`lastmodified`) VALUES(?,?,?,?,?)');
     try {
         $result = $stmt->execute(array($aid, $fn, $data, $uri, time()));
     } catch (Exception $e) {
         OCP\Util::writeLog('contacts', __METHOD__ . ', exception: ' . $e->getMessage(), OCP\Util::ERROR);
         OCP\Util::writeLog('contacts', __METHOD__ . ', aid: ' . $aid . ' uri' . $uri, OCP\Util::DEBUG);
         return false;
     }
     $newid = OCP\DB::insertid('*PREFIX*contacts_cards');
     OC_Contacts_Addressbook::touch($aid);
     OC_Hook::emit('OC_Contacts_VCard', 'post_createVCard', $newid);
     return $newid;
 }
Пример #2
0
 /**
  * @brief Adds a card
  * @param integer $aid Addressbook id
  * @param OC_VObject $card  vCard file
  * @param string $uri the uri of the card, default based on the UID
  * @return insertid on success or null if no card.
  */
 public static function add($aid, OC_VObject $card, $uri = null, $isnew = false)
 {
     if (is_null($card)) {
         OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR);
         return null;
     }
     if (!$isnew) {
         OC_Contacts_App::loadCategoriesFromVCard($card);
         self::updateValuesFromAdd($aid, $card);
     }
     $card->setString('VERSION', '3.0');
     // Add product ID is missing.
     $prodid = trim($card->getAsString('PRODID'));
     if (!$prodid) {
         $appinfo = OCP\App::getAppInfo('contacts');
         $appversion = OCP\App::getAppVersion('contacts');
         $prodid = '-//ownCloud//NONSGML ' . $appinfo['name'] . ' ' . $appversion . '//EN';
         $card->setString('PRODID', $prodid);
     }
     $fn = $card->getAsString('FN');
     if (empty($fn)) {
         $fn = '';
     }
     if (!$uri) {
         $uid = $card->getAsString('UID');
         $uri = $uid . '.vcf';
     }
     $data = $card->serialize();
     $stmt = OCP\DB::prepare('INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)');
     $result = $stmt->execute(array($aid, $fn, $data, $uri, time()));
     $newid = OCP\DB::insertid('*PREFIX*contacts_cards');
     OC_Contacts_Addressbook::touch($aid);
     return $newid;
 }
Пример #3
0
<?php

OCP\Util::addScript('notify', 'personalSettings');
OCP\Util::addStyle('notify', 'personalSettings');
$tmpl = new OCP\Template('notify', 'personalSettings');
$notificationClasses = OC_Notify::getClasses();
$classes = array();
foreach ($notificationClasses as $c) {
    //$l = OC_L10N::get($c['appid'], null); //TODO: put this into notify.php
    $appInfo = OCP\App::getAppInfo($c['appid']);
    $classes[$c['id']] = array('blocked' => $c['blocked'], 'summary' => $c['summary'], 'name' => $c['name'], 'appName' => $appInfo['name'], 'appid' => $c['appid']);
}
$tmpl->assign('classes', $classes);
return $tmpl->fetchPage();