示例#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
 /**
  * @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;
 }
    /**
     * @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;
    }
    /**
     * @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;
    }