Пример #1
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     \OCP\Util::addscript('core', 'tags');
     \OCP\Util::addStyle($this->appName, 'style');
     \OCP\Util::addStyle($this->appName, 'jquery.Jcrop');
     \OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/animation');
     \OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/fontello');
     \OCP\Util::addStyle($this->appName, '3rdparty/jquery.webui-popover');
     \OCP\Util::addscript($this->appName, 'app');
     \OCP\Util::addscript($this->appName, '3rdparty/jquery.webui-popover');
     \OCP\Util::addscript($this->appName, 'settings');
     \OCP\Util::addscript($this->appName, 'loader');
     \OCP\Util::addscript($this->appName, 'jquery.scrollTo.min');
     \OCP\Util::addscript($this->appName, 'jquery.nicescroll.min');
     \OCP\Util::addscript('files', 'jquery.fileupload');
     \OCP\Util::addscript($this->appName, 'jquery.Jcrop');
     $iosSupport = $this->configInfo->getUserValue($this->userId, $this->appName, 'iossupport');
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $addressbooks = Addressbook::all($this->userId);
     if (count($addressbooks) == 0) {
         Addressbook::addDefault($this->userId);
         $addressbooks = Addressbook::all($this->userId);
     }
     //ContactsApp::addingDummyContacts(50);
     $params = ['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'iossupport' => $iosSupport, 'addressbooks' => $addressbooks];
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedImageDomain('*');
     $csp->addAllowedFrameDomain('*');
     $response = new TemplateResponse($this->appName, 'index');
     $response->setContentSecurityPolicy($csp);
     $response->setParams($params);
     return $response;
 }
Пример #2
0
 /**
  * @brief Get a unique name of the item for the specified user
  * @param string Item
  * @param string|false User the item is being shared with
  * @param array|null List of similar item names already existing as shared items
  * @return string Target name
  *
  * This function needs to verify that the user does not already have an item with this name.
  * If it does generate a new name e.g. name_#
  */
 public function generateTarget($itemSource, $shareWith, $exclude = null)
 {
     $addressbook = AddrBook::find($itemSource);
     $user_addressbooks = array();
     foreach (AddrBook::all($shareWith) as $user_addressbook) {
         $user_addressbooks[] = $user_addressbook['displayname'];
     }
     $name = $addressbook['displayname'];
     $suffix = '';
     while (in_array($name . $suffix, $user_addressbooks)) {
         $suffix++;
     }
     return $name . $suffix;
 }
Пример #3
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     $iosSupport = $this->configInfo->getUserValue($this->userId, $this->appName, 'iossupport');
     $activeView = $this->configInfo->getUserValue($this->userId, $this->appName, 'view', 'listview');
     $lastSelectedBook = $this->configInfo->getUserValue($this->userId, $this->appName, 'currentbook', 0);
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $addressbooks = Addressbook::all($this->userId);
     if (count($addressbooks) == 0) {
         Addressbook::addDefault($this->userId);
         $addressbooks = Addressbook::all($this->userId);
     }
     //ContactsApp::addingDummyContacts(1000);
     $params = ['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'iossupport' => $iosSupport, 'addressbooks' => $addressbooks, 'activeView' => $activeView, 'lastSelectedBook' => $lastSelectedBook];
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedImageDomain('*');
     $csp->addAllowedFrameDomain('*');
     $response = new TemplateResponse($this->appName, 'index');
     $response->setContentSecurityPolicy($csp);
     $response->setParams($params);
     return $response;
 }
Пример #4
0
 /**
  * @brief Get the last modification time.
  * @param OC_VObject|Sabre\VObject\Component|integer|null $contact
  * @returns DateTime | null
  */
 public static function lastModified($contact = null)
 {
     if (is_null($contact)) {
         $addressBooks = Addressbook::all(\OCP\User::getUser());
         $lastModified = 0;
         foreach ($addressBooks as $addressBook) {
             if (isset($addressBook['ctag']) and (int) $addressBook['ctag'] > $lastModified) {
                 $lastModified = $addressBook['ctag'];
             }
         }
         return new \DateTime('@' . $lastModified);
     } else {
         if (is_numeric($contact)) {
             $card = VCard::find($contact, array('lastmodified'));
             return $card ? new \DateTime('@' . $card['lastmodified']) : null;
         } elseif ($contact instanceof VObject\Component\VCard || $contact instanceof VObject\Component) {
             return isset($contact->REV) ? \DateTime::createFromFormat(\DateTime::W3C, $contact->REV) : null;
         }
     }
 }
    /**
     * @NoAdminRequired
     */
    public function getAddressBooks()
    {
        $active_addressbooks = array();
        $active_addressbooks = Addressbook::all($this->userId);
        if (count($active_addressbooks) === 0) {
            Addressbook::addDefault($this->userId);
            $active_addressbooks = Addressbook::all($this->userId);
        }
        $countCardsAddressbooks = Addressbook::getCountCardsAddressbook($this->userId);
        $contacts_addressbook = array();
        $ids = array();
        foreach ($active_addressbooks as $addressbook) {
            $ids[] = $addressbook['id'];
        }
        $idActiveAddressbook = $ids[0];
        $mySharees = ContactsApp::getAddressbookSharees();
        $bShareApi = \OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes');
        $output = '';
        foreach ($active_addressbooks as $addressbookInfo) {
            $activeClass = '';
            $checked = '';
            $rightsOutput = '';
            $share = (string) $this->l10n->t('Share Addressbook');
            $bShared = false;
            if ($addressbookInfo['active']) {
                $checked = 'checked="checked"';
            }
            if ($idActiveAddressbook === $addressbookInfo['id']) {
                $activeClass = 'isActiveABook';
            }
            $sync = '';
            //Ios syncs only one Addressbook
            if ($this->configInfo->getUserValue($this->userId, $this->appName, 'syncaddrbook') === $addressbookInfo['uri']) {
                $sync = ' <i class="ioc ioc-info toolTip" title="' . $this->l10n->t('Is active sync Book on Mac/ IOS') . '"></i> ';
            }
            if (is_array($mySharees) && array_key_exists($addressbookInfo['id'], $mySharees) && $mySharees[$addressbookInfo['id']]['myShare']) {
                $share = '<b>' . (string) $this->l10n->t('Shared with') . '</b><br>' . $mySharees[$addressbookInfo['id']]['shareTypeDescr'];
                $bShared = true;
            }
            $displayName = '<span  class="groupname">' . $addressbookInfo['displayname'] . $sync . '</span>';
            if ($addressbookInfo['userid'] !== $this->userId) {
                $rightsOutput = ContactsApp::permissionReader($addressbookInfo['permissions']);
                $displayName = '<span class="toolTip groupname" title="' . $notice . '(' . $rightsOutput . ')">' . $addressbookInfo['displayname'] . ' (' . (string) $this->l10n->t('by') . ' ' . $addressbookInfo['userid'] . ')</span>';
            }
            $checkBox = '<input class="regular-checkbox isActiveAddressbook" data-id="' . $addressbookInfo['id'] . '" style="float:left;" id="edit_active_' . $addressbookInfo['id'] . '" type="checkbox" ' . $checked . ' /><label style="float:left;margin-top:4px;margin-right:5px;" for="edit_active_' . $addressbookInfo['id'] . '"></label>';
            $shareLink = '';
            if ($addressbookInfo['permissions'] & \OCP\PERMISSION_SHARE && $bShareApi === 'yes') {
                $addCss = '';
                if ($bShared === true) {
                    $addCss = 'opacity:1';
                }
                $shareLink = '<a href="#" class="share icon-share toolTip" 
			  	data-item-type="' . ContactsApp::SHAREADDRESSBOOK . '" 
			    data-item="' . ContactsApp::SHAREADDRESSBOOKPREFIX . $addressbookInfo['id'] . '" 
			    data-link="false"
			    data-title="' . $addressbookInfo['displayname'] . '"
				data-possible-permissions="' . $addressbookInfo['permissions'] . '"
				title="' . $share . '"
				style="position:absolute;float:right;right:22px;margin-top:-6px;display:block;height:30px;width:30px;' . $addCss . '"
				>
				</a>';
            }
            $output .= '<li class="dropcontainerAddressBook ' . $activeClass . '" data-adrbid="' . $addressbookInfo['id'] . '"  data-perm="' . $addressbookInfo['permissions'] . '">' . $checkBox . $displayName . $shareLink . '<span class="groupcounter">' . $countCardsAddressbooks[$addressbookInfo['id']] . '</span></li>';
        }
        return $output;
    }
Пример #6
0
 public static function getBirthdayEvents($params)
 {
     if (\OCP\Config::getUserValue(\OCP\USER::getUser(), 'calendarplus', 'calendar_birthday_' . \OCP\USER::getUser())) {
         $name = $params['calendar_id'];
         if (strpos($name, 'birthday_') != 0) {
             return;
         }
         $info = explode('_', $name);
         $aid = $info[1];
         $aDefNArray = array('0' => 'fname', '1' => 'lname', '3' => 'title', '4' => '');
         foreach (Addressbook::all($aid) as $addressbook) {
             foreach (VCard::all($addressbook['id']) as $contact) {
                 try {
                     $vcard = VObject\Reader::read($contact['carddata']);
                 } catch (Exception $e) {
                     continue;
                 }
                 $birthday = $vcard->BDAY;
                 if ((string) $birthday) {
                     $details = VCard::structureContact($vcard);
                     $BirthdayTemp = new \DateTime($birthday);
                     $checkForm = $BirthdayTemp->format('d-m-Y');
                     $temp = explode('-', $checkForm);
                     $getAge = self::getAge($temp[2], $temp[1], $temp[0]);
                     //$getAge=$BirthdayTemp->format('d-m-Y');
                     $title = isset($vcard->FN) ? strtr($vcard->FN->getValue(), array('\\,' => ',', '\\;' => ';')) : '';
                     $sNameOutput = '';
                     if (isset($details['N'][0]['value']) && count($details['N'][0]['value']) > 0) {
                         foreach ($details['N'][0]['value'] as $key => $val) {
                             if ($val != '') {
                                 $aNameOutput[$aDefNArray[$key]] = $val;
                             }
                         }
                         //$sNameOutput=isset($aNameOutput['title'])?$aNameOutput['title'].' ':'';
                         $sNameOutput .= isset($aNameOutput['lname']) ? $aNameOutput['lname'] . ' ' : '';
                         $sNameOutput .= isset($aNameOutput['fname']) ? $aNameOutput['fname'] . ' ' : '';
                         unset($aNameOutput);
                     }
                     if ($sNameOutput == '') {
                         $sNameOutput = $title;
                     }
                     $sTitle1 = (string) App::$l10n->t('%1$s (%2$s)', array($sNameOutput, $getAge));
                     $aktYear = $BirthdayTemp->format('d-m');
                     $aktYear = $aktYear . date('-Y');
                     $start = new \DateTime($aktYear);
                     $end = new \DateTime($aktYear . ' +1 day');
                     $vcalendar = new VObject\Component\VCalendar();
                     $vevent = $vcalendar->createComponent('VEVENT');
                     $vevent->add('DTSTART');
                     $vevent->DTSTART->setDateTime($start);
                     $vevent->DTSTART['VALUE'] = 'date';
                     $vevent->add('DTEND');
                     $vevent->DTEND->setDateTime($end);
                     $vevent->DTEND['VALUE'] = 'date';
                     $vevent->{'SUMMARY'} = (string) $sTitle1;
                     $vevent->{'UID'} = substr(md5(rand() . time()), 0, 10);
                     // DESCRIPTION?
                     $aktYear1 = $BirthdayTemp->format('-m-d');
                     $aktYear1 = date('Y') . $aktYear1;
                     $params['events'][] = array('id' => 0, 'vevent' => $vevent, 'repeating' => true, 'calendarid' => $params['calendar_id'], 'privat' => false, 'bday' => true, 'shared' => false, 'isalarm' => false, 'summary' => $sTitle1, 'start' => $aktYear1, 'allDay' => true, 'startlist' => $aktYear1, 'editable' => false, 'className' => 'birthdayevent', 'startEditable ' => false, 'durationEditable ' => false);
                 }
             }
         }
     }
     return true;
 }
Пример #7
0
 /**
  * @NoAdminRequired
  */
 public function getContactCards()
 {
     $grpId = $this->params('grpid');
     $addrbookId = intval($this->params('ardbid'));
     $grpId = isset($grpId) ? $grpId : 'all';
     if ($addrbookId == 0) {
         $active_addressbooks = Addressbook::all($this->userId);
         $ids = array();
         foreach ($active_addressbooks as $addressbook) {
             $ids[] = $addressbook['id'];
         }
         $addrbookId = $ids[0];
     }
     $this->configInfo->setUserValue($this->userId, $this->appName, 'currentbook', $addrbookId);
     $cardslist = ContactsApp::renderOutput($addrbookId, $grpId);
     return $cardslist;
 }
Пример #8
0
    /**
     * @NoAdminRequired
     */
    public function getAddressBooks()
    {
        $active_addressbooks = array();
        $active_addressbooks = Addressbook::all($this->userId, false);
        if (count($active_addressbooks) === 0) {
            Addressbook::addDefault($this->userId);
            $active_addressbooks = Addressbook::all($this->userId, false);
        }
        $countCardsAddressbooks = Addressbook::getCountCardsAddressbook($this->userId);
        $contacts_addressbook = array();
        $ids = array();
        foreach ($active_addressbooks as $addressbook) {
            $ids[] = $addressbook['id'];
        }
        $idActiveAddressbook = $ids[0];
        $mySharees = ContactsApp::getAddressbookSharees();
        $bShareApi = \OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes');
        $output = '';
        foreach ($active_addressbooks as $addressbookInfo) {
            $activeClass = '';
            $checked = '';
            $rightsOutput = '';
            $share = (string) $this->l10n->t('Share Addressbook');
            $bShared = false;
            /*
            			if($addressbookInfo['active']){
            				 $checked = 'checked="checked"';
            			}*/
            if ($idActiveAddressbook === $addressbookInfo['id']) {
                $activeClass = 'isActiveABook';
            }
            $sync = '';
            //Ios syncs only one Addressbook
            if ($this->configInfo->getUserValue($this->userId, $this->appName, 'syncaddrbook') === $addressbookInfo['uri']) {
                $sync = ' <i class="ioc ioc-info toolTip" title="' . $this->l10n->t('Is active sync Book on Mac/ IOS') . '"></i> ';
            }
            if (is_array($mySharees) && array_key_exists($addressbookInfo['id'], $mySharees) && $mySharees[$addressbookInfo['id']]['myShare']) {
                $share = '<b>' . (string) $this->l10n->t('Shared with') . '</b><br>' . $mySharees[$addressbookInfo['id']]['shareTypeDescr'];
                $bShared = true;
            }
            $inActive = $addressbookInfo['active'] == 1 ? 'groupname' : 'groupinactive';
            $displayName = '<span  class="' . $inActive . '">' . $addressbookInfo['displayname'] . $sync . '</span>';
            if ($addressbookInfo['userid'] !== $this->userId) {
                $rightsOutput = ContactsApp::permissionReader($addressbookInfo['permissions']);
                $displayName = '<span class="toolTip groupname" title="' . $notice . '(' . $rightsOutput . ')">' . $addressbookInfo['displayname'] . ' (' . (string) $this->l10n->t('by') . ' ' . $addressbookInfo['userid'] . ')</span>';
            }
            //$checkBox='<input class="regular-checkbox isActiveAddressbook" data-id="'.$addressbookInfo['id'].'" style="float:left;" id="edit_active_'.$addressbookInfo['id'].'" type="checkbox" '.$checked.' /><label style="float:left;margin-top:4px;margin-right:5px;" for="edit_active_'.$addressbookInfo['id'].'"></label>';
            $shareLink = '';
            if ($addressbookInfo['permissions'] & \OCP\PERMISSION_SHARE && $bShareApi === 'yes') {
                $addCss = '';
                if ($bShared === true) {
                    $addCss = 'opacity:1';
                }
                $shareLink = '<a href="#" class="share icon-share toolTip" 
			  	data-item-type="' . ContactsApp::SHAREADDRESSBOOK . '" 
			    data-item="' . ContactsApp::SHAREADDRESSBOOKPREFIX . $addressbookInfo['id'] . '" 
			    data-link="false"
			    data-title="' . $addressbookInfo['displayname'] . '"
				data-possible-permissions="' . $addressbookInfo['permissions'] . '"
				title="' . $share . '"
				style="position:absolute;float:right;right:42px;margin-top:-6px;display:block;height:30px;width:30px;' . $addCss . '"
				>
				</a>';
            }
            $addrbookuri = $addressbookInfo['uri'];
            if ($addressbookInfo['userid'] !== $this->userId) {
                $addrbookuri = $addressbookInfo['uri'] . '_shared_by_' . $addressbookInfo['userid'];
            }
            $actionAddr = '';
            $checkBox = '';
            if ($addressbookInfo['userid'] === $this->userId) {
                $actionAddr = '<li class="ioc ioc-edit"></li><li class="ioc ioc-delete"></li>';
                $checked = $addressbookInfo['active'] == 1 ? ' checked="checked"' : '';
                $checkBox = '<input class="regular-checkbox isActiveAddressbook" data-id="' . $addressbookInfo['id'] . '" style="float:left;" id="active_aid_' . $addressbookInfo['id'] . '" type="checkbox" ' . $checked . ' /><label style="float:left;margin-left:8px;top:5px;" for="active_aid_' . $addressbookInfo['id'] . '"></label>';
            }
            $urlDl = \OC::$server->getURLGenerator()->linkToRoute($this->appName . '.export.exportContacts') . '?bookid=' . $addressbookInfo['id'];
            $downloadLink = '<a class="icon-download" style="margin-top:-6px;" href="' . $urlDl . '" title="' . $this->l10n->t('Download') . '"></a>';
            $addMenu = '<span style="position:absolute;float:right;right:20px;" class="app-navigation-entry-utils-menu-button"><button></button>
						  <span class="app-navigation-entry-menu" data-adrbid="' . $addressbookInfo['id'] . '">
							  <ul>
							  <li>' . $checkBox . '</li>
							  <li><i class="ioc ioc-globe"></i></li>
							  <li>' . $downloadLink . '</li>
							  ' . $actionAddr . '
							  </ul>
						  </span>
					  </span>';
            $output .= '<li class="dropcontainerAddressBook ' . $activeClass . '" data-adrbid="' . $addressbookInfo['id'] . '"  data-perm="' . $addressbookInfo['permissions'] . '" data-url="' . $addrbookuri . '" data-name="' . $addressbookInfo['displayname'] . '">' . $displayName . $shareLink . $addMenu . '<span class="groupcounter">' . $countCardsAddressbooks[$addressbookInfo['id']] . '</span></li>';
        }
        $output .= '<li class="app-navigation-entry-edit addrclone" id="addr-clone" data-addr="">
				<input type="text" name="adrbookname" id="adrbookname" value="" placeholder="' . $this->l10n->t('Displayname') . '" />
				<input type="text" name="carddavuri" readonly="readonly" value="" />
				<button class="icon-checkmark"></button>
			</li>	';
        return $output;
    }