コード例 #1
0
 /**
  * (non-PHPdoc)
  * @see Sabre_DAV_Auth_IBackend::authenticate()
  */
 public function authenticate(Sabre_DAV_Server $_server, $_realm)
 {
     if (Tinebase_Core::getUser() instanceof Tinebase_Model_FullUser) {
         return true;
     }
     return false;
 }
コード例 #2
0
 public function __construct()
 {
     $applications = is_object(Tinebase_Core::getUser()) ? Tinebase_Core::getUser()->getApplications() : new Tinebase_Record_RecordSet('Tinebase_Model_Application');
     parent::__construct('root', array(new \Sabre\DAV\SimpleCollection('principals', array(new Tinebase_WebDav_PrincipalCollection(new Tinebase_WebDav_PrincipalBackend(), Tinebase_WebDav_PrincipalBackend::PREFIX_USERS), new Tinebase_WebDav_PrincipalCollection(new Tinebase_WebDav_PrincipalBackend(), Tinebase_WebDav_PrincipalBackend::PREFIX_GROUPS), new Tinebase_WebDav_PrincipalCollection(new Tinebase_WebDav_PrincipalBackend(), Tinebase_WebDav_PrincipalBackend::PREFIX_INTELLIGROUPS)))));
     if ($applications->find('name', 'Calendar')) {
         $this->addChild(new Calendar_Frontend_WebDAV(\Sabre\CalDAV\Plugin::CALENDAR_ROOT, true));
     }
     if ($applications->find('name', 'Tasks')) {
         $this->addChild(new Tasks_Frontend_WebDAV('tasks', true));
     }
     if ($applications->find('name', 'Addressbook')) {
         $this->addChild(new Addressbook_Frontend_WebDAV(\Sabre\CardDAV\Plugin::ADDRESSBOOK_ROOT, true));
     }
     // main entry point for ownCloud
     if ($applications->find('name', 'Filemanager')) {
         $this->addChild(new \Sabre\DAV\SimpleCollection('remote.php', array(new Filemanager_Frontend_WebDAV('webdav'))));
     }
     // webdav tree
     $webDAVCollection = new \Sabre\DAV\SimpleCollection('webdav');
     foreach ($applications as $application) {
         $applicationClass = $application->name . '_Frontend_WebDAV';
         if (@class_exists($applicationClass)) {
             $webDAVCollection->addChild(new $applicationClass($application->name));
         }
     }
     $this->addChild($webDAVCollection);
 }
 /**
  * test testGetProperties method
  */
 public function testGetProperties()
 {
     $body = '<?xml version="1.0" encoding="utf-8"?>
              <propfind xmlns="DAV:">
                 <prop>
                     <default-alarm-vevent-date xmlns="urn:ietf:params:xml:ns:caldav"/>
                     <default-alarm-vevent-datetime xmlns="urn:ietf:params:xml:ns:caldav"/>
                     <default-alarm-vtodo-date xmlns="urn:ietf:params:xml:ns:caldav"/>
                     <default-alarm-vtodo-datetime xmlns="urn:ietf:params:xml:ns:caldav"/>
                 </prop>
              </propfind>';
     $request = new Sabre\HTTP\Request(array('REQUEST_METHOD' => 'PROPFIND', 'REQUEST_URI' => '/calendars/' . Tinebase_Core::getUser()->contact_id, 'HTTP_DEPTH' => '0'));
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
     //var_dump($this->response->body);
     $this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status);
     $responseDoc = new DOMDocument();
     $responseDoc->loadXML($this->response->body);
     //$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('cal', 'urn:ietf:params:xml:ns:caldav');
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/cal:default-alarm-vevent-datetime');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/cal:default-alarm-vevent-date');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/cal:default-alarm-vtodo-datetime');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/cal:default-alarm-vtodo-date');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
 }
コード例 #4
0
 protected function _onAfterExportRecords($result)
 {
     $user = Tinebase_Core::getUser();
     $this->_docTemplate->setValue('date', Tinebase_DateTime::now()->format('Y-m-d'));
     $this->_docTemplate->setValue('account_n_given', $user->accountFirstName);
     $this->_docTemplate->setValue('account_n_family', $user->accountLastName);
 }
コード例 #5
0
ファイル: SqlTest.php プロジェクト: rodrigofns/ExpressoLivre3
 public function testSearchEvents()
 {
     $from = '2009-04-03 00:00:00';
     $until = '2009-04-10 23:59:59';
     $events = new Tinebase_Record_RecordSet('Calendar_Model_Event', array(array('dtstart' => '2009-04-02 22:00:00', 'dtend' => '2009-04-02 23:59:59', 'summary' => 'non recur event ending before search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-02 23:30:00', 'dtend' => '2009-04-03 00:30:00', 'summary' => 'non recur event ending within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-06 12:00:00', 'dtend' => '2009-04-07 12:00:00', 'summary' => 'non recur event completly within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-10 23:30:00', 'dtend' => '2009-04-11 00:30:00', 'summary' => 'non recur event starting within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-11 00:00:00', 'dtend' => '2009-04-11 02:00:00', 'summary' => 'non recur event starting after search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-03-27 22:00:00', 'dtend' => '2009-03-27 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-02 23:59:59', 'summary' => 'recur event ending before search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-02 23:59:59', Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-03-27 22:00:00', 'dtend' => '2009-03-27 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-05 23:59:59', 'summary' => 'recur event ending within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-05 23:59:59', Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-03 22:00:00', 'dtend' => '2009-04-03 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-06 23:59:59', 'summary' => 'recur event completly within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-06 23:59:59', Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-03 22:00:00', 'dtend' => '2009-04-03 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-12 23:59:59', 'summary' => 'recur event starting within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-12 23:59:59', Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-11 00:00:00', 'dtend' => '2009-04-11 02:00:00', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-15 02:00:00', 'summary' => 'recur event starting after search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-15 02:00:00', Tinebase_Model_Grants::GRANT_READ => true)));
     foreach ($events as $event) {
         $persistentEvent = $this->_backend->create($event);
         $event->attendee->cal_event_id = $persistentEvent->getId();
         foreach ($event->attendee as $attender) {
             $this->_backend->createAttendee($attender);
         }
     }
     $filter = new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_testCalendar->getId()), array('field' => 'period', 'operator' => 'within', 'value' => array('from' => $from, 'until' => $until))));
     $eventsFound = $this->_backend->search($filter, new Tinebase_Model_Pagination());
     $eventsFoundIds = $eventsFound->getArrayOfIds();
     foreach ($events as $event) {
         $eventId = $event->getId();
         if (strpos($event->summary, '_not_') === false) {
             $this->assertTrue(in_array($eventId, $eventsFoundIds), 'The following event is missing in the search result :' . print_r($event->toArray(), true));
         } else {
             $this->assertFalse(in_array($eventId, $eventsFoundIds), 'The following event is in the search result, but should not be :' . print_r($event->toArray(), true));
         }
     }
     $expectedAttendee = $this->_getAttendee();
     foreach ($eventsFound as $fetchedEvent) {
         $this->_assertAttendee($expectedAttendee, $fetchedEvent->attendee);
     }
 }
 public function testExpandProperty()
 {
     $list = Tinebase_Group::getInstance()->getGroupById(Tinebase_Core::getUser()->accountPrimaryGroup);
     $body = '<?xml version="1.0" encoding="UTF-8"?>
             <A:expand-property xmlns:A="DAV:">
               <A:property name="expanded-group-member-set" namespace="http://calendarserver.org/ns/">
                 <A:property name="last-name" namespace="http://calendarserver.org/ns/"/>
                 <A:property name="principal-URL" namespace="DAV:"/>
                 <A:property name="calendar-user-type" namespace="urn:ietf:params:xml:ns:caldav"/>
                 <A:property name="calendar-user-address-set" namespace="urn:ietf:params:xml:ns:caldav"/>
                 <A:property name="first-name" namespace="http://calendarserver.org/ns/"/>
                 <A:property name="record-type" namespace="http://calendarserver.org/ns/"/>
                 <A:property name="displayname" namespace="DAV:"/>
               </A:property>
             </A:expand-property>';
     $request = new Sabre\HTTP\Request(array('REQUEST_METHOD' => 'REPORT', 'REQUEST_URI' => '/principals/groups/' . $list->list_id . '/'));
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
     $responseDoc = new DOMDocument();
     $responseDoc->loadXML($this->response->body);
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('cal', 'urn:ietf:params:xml:ns:caldav');
     $xpath->registerNamespace('cs', 'http://calendarserver.org/ns/');
     $nodes = $xpath->query('///cs:expanded-group-member-set/d:response/d:href[text()="/principals/groups/' . $list->list_id . '/"]');
     $this->assertEquals(1, $nodes->length, 'group itself (not shown by client) is missing');
     $nodes = $xpath->query('///cs:expanded-group-member-set/d:response/d:href[text()="/principals/intelligroups/' . $list->list_id . '/"]');
     $this->assertEquals(1, $nodes->length, 'intelligroup (to keep group itself) is missing');
     $nodes = $xpath->query('///cs:expanded-group-member-set/d:response/d:href[text()="/principals/users/' . Tinebase_Core::getUser()->contact_id . '/"]');
     $this->assertEquals(1, $nodes->length, 'user is missing');
 }
コード例 #7
0
 /**
  * update one phone
  *
  * @param Voipmanager_Model_Snom_Phone $_phone
  * @return Voipmanager_Model_Snom_Phone
  * @throws Voipmanager_Exception_Validation
  *
  * @todo do not overwrite update() -> use inspectBefore/After functions
  */
 public function update(Tinebase_Record_Interface $_phone)
 {
     $oldRecord = $this->get($_phone->getId());
     $rights = $this->_backend->getPhoneRights($_phone->getId());
     $currentAccountId = Tinebase_Core::getUser()->getId();
     $hasRight = false;
     foreach ($rights as $right) {
         if ($right->account_id == $currentAccountId) {
             // if  user has the right to dial and read the phone, he or she may edit the lines
             if ($right->dial_right && $right->read_right) {
                 $hasRight = true;
             }
         }
     }
     if (!$hasRight) {
         throw new Tinebase_Exception_AccessDenied('You are not allowed to edit this phone!');
     }
     // user is not allowed to add or remove lines
     $diff = $oldRecord->lines->diff($_phone->lines);
     if (count($diff->added) > 0 || count($diff->removed) > 0) {
         throw new Tinebase_Exception_AccessDenied('You are not allowed to add or remove lines of this phone!');
     }
     // user may just edit the lines and settings of the phone
     $oldRecord->lines = $_phone->lines;
     $oldRecord->settings = $_phone->settings;
     return parent::update($oldRecord);
 }
コード例 #8
0
ファイル: CliTest.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * Tears down the fixture
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     $currentUser = Tinebase_Core::getUser();
     if ($currentUser->accountLoginName !== $this->_testUser->accountLoginName) {
         Tinebase_Core::set(Tinebase_Core::USER, $this->_testUser);
     }
 }
コード例 #9
0
ファイル: Message.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * the constructor
  *
  * don't use the constructor. use the singleton
  */
 private function __construct()
 {
     $this->_modelName = 'Felamimail_Model_Message';
     $this->_doContainerACLChecks = FALSE;
     $this->_backend = Felamimail_Backend_Message::getInstance();
     $this->_currentAccount = Tinebase_Core::getUser();
 }
コード例 #10
0
 /**
  * process the XML file and add, change, delete or fetches data 
  *
  * @return resource
  */
 public function handle()
 {
     $defaultAccountId = Tinebase_Core::getPreference('Felamimail')->{Felamimail_Preference::DEFAULTACCOUNT};
     try {
         $this->_account = Felamimail_Controller_Account::getInstance()->get($defaultAccountId);
     } catch (Tinebase_Exception_NotFound $ten) {
         if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . " no email account configured");
         }
         throw new ActiveSync_Exception('no email account configured');
     }
     if (empty(Tinebase_Core::getUser()->accountEmailAddress)) {
         throw new ActiveSync_Exception('no email address set for current user');
     }
     $this->_saveInSent = isset($_GET['SaveInSent']) && (bool) $_GET['SaveInSent'] == 'T';
     if (!is_resource($this->_inputStream)) {
         $this->_inputStream = fopen("php://input", 'r');
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         $debugStream = fopen("php://temp", 'r+');
         stream_copy_to_stream($this->_inputStream, $debugStream);
         rewind($debugStream);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " email to send:" . stream_get_contents($debugStream));
         }
         // replace original stream wirh debug stream, as php://input can't be rewinded
         $this->_inputStream = $debugStream;
         rewind($this->_inputStream);
     }
     $this->_incomingMessage = new Zend_Mail_Message(array('file' => $this->_inputStream));
 }
コード例 #11
0
 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     $db = $_backend->getAdapter();
     // prepare value
     $value = $this->_value ? 1 : 0;
     if ($value) {
         // nothing to do -> show all contacts!
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Query all account contacts.');
         }
     } else {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Only query visible and enabled account contacts.');
         }
         if (Tinebase_Core::getUser() instanceof Tinebase_Model_FullUser) {
             $where = '/* is no user */ ' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'true', 'false') . ' OR /* is user */ (' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'false', 'true') . ' AND ' . $db->quoteInto($db->quoteIdentifier('accounts.status') . ' = ?', 'enabled') . " AND " . '(' . $db->quoteInto($db->quoteIdentifier('accounts.visibility') . ' = ?', 'displayed') . ' OR ' . $db->quoteInto($db->quoteIdentifier('accounts.id') . ' = ?', Tinebase_Core::getUser()->getId()) . ')' . ")";
         } else {
             $where = '/* is no user */ ' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'true', 'false') . ' OR /* is user */ (' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'false', 'true') . ' AND ' . $db->quoteInto($db->quoteIdentifier('accounts.status') . ' = ?', 'enabled') . " AND " . $db->quoteInto($db->quoteIdentifier('accounts.visibility') . ' = ?', 'displayed') . ")";
         }
         $_select->where($where);
         $select = $_select instanceof Zend_Db_Select ? $_select : $_select->getSelect();
         $select = Tinebase_Backend_Sql_Abstract::traitGroup($db, $_backend->getTablePrefix(), $select);
         $_select instanceof Zend_Db_Select ? $_select = $select : $_select->setSelect($select);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' contacts query ' . $_select->assemble());
         }
     }
 }
コード例 #12
0
 /**
  * @see Tinebase_WebDav_Collection_AbstractContainerTree::getChild()
  * @param string $name
  * @return Tinebase_WebDav_Container_Abstract|Tinebase_WebDav_Collection_AbstractContainerTree|Tinebase_Frontend_WebDAV_RecordCollection
  */
 public function getChild($name)
 {
     if (count($this->_getPathParts()) === 2 && $name == Addressbook_Frontend_CardDAV_AllContacts::NAME) {
         return new Addressbook_Frontend_CardDAV_AllContacts(Tinebase_Core::getUser());
     }
     return parent::getChild($name);
 }
コード例 #13
0
 /**
  * the constructor
  *
  * don't use the constructor. use the singleton 
  */
 private function __construct()
 {
     $this->_applicationName = 'Sales';
     $this->_backend = new Sales_Backend_Contract();
     $this->_modelName = 'Sales_Model_Contract';
     $this->_currentAccount = Tinebase_Core::getUser();
 }
コード例 #14
0
 /**
  * test testGetProperties method
  */
 public function testGetProperties()
 {
     $body = '<?xml version="1.0" encoding="utf-8"?>
              <propfind xmlns="DAV:">
                 <prop>
                     <getlastmodified xmlns="DAV:"/>
                     <getcontentlength xmlns="DAV:"/>
                     <resourcetype xmlns="DAV:"/>
                     <getetag xmlns="DAV:"/>
                     <id xmlns="http://owncloud.org/ns"/>
                 </prop>
              </propfind>';
     $request = new Sabre\HTTP\Request(array('REQUEST_METHOD' => 'PROPFIND', 'REQUEST_URI' => '/remote.php/webdav/' . Tinebase_Core::getUser()->accountDisplayName, 'HTTP_DEPTH' => '0'));
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
     //var_dump($this->response->body);
     $this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status);
     $responseDoc = new DOMDocument();
     $responseDoc->loadXML($this->response->body);
     //$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('owncloud', 'http://owncloud.org/ns');
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/owncloud:id');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
 }
 /**
  * @return void
  */
 public function testEmailsToAttendeeWithGroups()
 {
     if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP || Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
         $this->markTestSkipped('FIXME: Does not work with LDAP/AD backend');
     }
     $event = $this->_getEvent();
     $persistentEvent = Calendar_Controller_Event::getInstance()->create($event);
     $primaryGroup = Tinebase_Group::getInstance()->getGroupById(Tinebase_Core::getUser()->accountPrimaryGroup);
     $newAttendees = array(array('userType' => Calendar_Model_Attender::USERTYPE_USER, 'firstName' => $this->_originalTestUser->accountFirstName, 'lastName' => $this->_originalTestUser->accountLastName, 'partStat' => Calendar_Model_Attender::STATUS_TENTATIVE, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => $this->_originalTestUser->accountEmailAddress), array('userType' => Calendar_Model_Attender::USERTYPE_GROUP, 'displayName' => $primaryGroup->name, 'partStat' => Calendar_Model_Attender::STATUS_NEEDSACTION, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => '*****@*****.**'));
     Calendar_Model_Attender::emailsToAttendee($persistentEvent, $newAttendees, TRUE);
     $persistentEvent = Calendar_Controller_Event::getInstance()->update($persistentEvent);
     $attendees = clone $persistentEvent->attendee;
     Calendar_Model_Attender::resolveAttendee($attendees);
     $newAttendees = array();
     foreach ($attendees as $attendee) {
         $newAttendees[] = array('userType' => $attendee->user_type == 'group' ? Calendar_Model_Attender::USERTYPE_GROUP : Calendar_Model_Attender::USERTYPE_USER, 'partStat' => Calendar_Model_Attender::STATUS_TENTATIVE, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => $attendee->user_type == 'group' ? $attendee->user_id->getId() : $attendee->user_id->email, 'displayName' => $attendee->user_type == 'group' ? $attendee->user_id->name : $attendee->user_id->n_fileas);
     }
     Calendar_Model_Attender::emailsToAttendee($persistentEvent, $newAttendees, TRUE);
     $persistentEvent = Calendar_Controller_Event::getInstance()->update($persistentEvent);
     //         print_r($persistentEvent->attendee->toArray());
     // there must be more than 2 attendees the user, the group + the groupmembers
     $this->assertGreaterThan(2, count($persistentEvent->attendee));
     // current account must not be a groupmember
     $this->assertFalse(!!Calendar_Model_Attender::getAttendee($persistentEvent->attendee, new Calendar_Model_Attender(array('user_type' => Calendar_Model_Attender::USERTYPE_GROUPMEMBER, 'user_id' => $this->_originalTestUser->contact_id))), 'found user as groupmember');
     $this->assertEquals(Calendar_Model_Attender::STATUS_TENTATIVE, Calendar_Model_Attender::getOwnAttender($persistentEvent->attendee)->status);
 }
コード例 #16
0
 /**
  * the constructor
  *
  * don't use the constructor. use the singleton 
  */
 private function __construct()
 {
     $this->_applicationName = 'Timetracker';
     $this->_backend = new Timetracker_Backend_Timeaccount();
     $this->_modelName = 'Timetracker_Model_Timeaccount';
     $this->_currentAccount = Tinebase_Core::getUser();
     $this->_purgeRecords = FALSE;
 }
コード例 #17
0
ファイル: Task.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * the constructor
  *
  * don't use the constructor. use the singleton 
  */
 private function __construct()
 {
     $this->_applicationName = 'Tasks';
     $this->_modelName = 'Tasks_Model_Task';
     $this->_backend = Tasks_Backend_Factory::factory(Tasks_Backend_Factory::SQL);
     $this->_currentAccount = Tinebase_Core::getUser();
     $this->_recordAlarmField = 'due';
 }
コード例 #18
0
 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     if ($this->_value) {
         $filterData = array(array('field' => 'created_by', 'operator' => $this->_operator, 'value' => Tinebase_Core::getUser()->__get('accountId')));
         $filter = new Billing_Model_ReceiptFilter($filterData, 'AND');
         Tinebase_Backend_Sql_Filter_FilterGroup::appendFilters($_select, $filter, $_backend);
     }
 }
 public function testGetAllContactsMetaContainer()
 {
     $_SERVER['HTTP_USER_AGENT'] = 'Mac OS X/10.9 (13A603) AddressBook/1365';
     $collection = new Addressbook_Frontend_WebDAV(\Sabre\CardDAV\Plugin::ADDRESSBOOK_ROOT . '/' . Tinebase_Core::getUser()->contact_id, true);
     $children = $collection->getChildren();
     $this->assertCount(1, $children, 'there should be just one global container');
     $this->assertTrue($children[0] instanceof Addressbook_Frontend_CardDAV_AllContacts, 'wrong instance');
 }
コード例 #20
0
 /**
  * getDefaultId() - get default cache id
  * - use user id as default cache id
  * 
  * @return string
  */
 public function getDefaultId()
 {
     $result = NULL;
     if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) {
         $result = Tinebase_Core::getUser()->getId();
     }
     return $result;
 }
コード例 #21
0
ファイル: Tags.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * the constructor
  *
  * don't use the constructor. use the singleton 
  */
 private function __construct()
 {
     $this->_currentAccount = Tinebase_Core::getUser();
     $this->_applicationName = 'Admin';
     $this->_backend = Tinebase_Tags::getInstance();
     $this->_doContainerACLChecks = FALSE;
     $this->_omitModLog = TRUE;
     $this->_modelName = 'Tinebase_Model_FullTag';
 }
コード例 #22
0
 /**
  * returns registry data of PersistentFilter.
  *
  * @return array
  */
 public static function getAllPersistentFilters()
 {
     if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) {
         $obj = new Tinebase_Frontend_Json_PersistentFilter();
         // return only filters of activated apps
         $applicationIds = Tinebase_Application::getInstance()->getApplicationsByState(Tinebase_Application::ENABLED)->getArrayOfIds();
         return $obj->searchPersistentFilter(array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->getId()), array('field' => 'application_id', 'operator' => 'in', 'value' => $applicationIds)), NULL);
     }
 }
 /**
  * test import of a single container/calendar of current user
  */
 public function testImportCalendars()
 {
     $this->_getUit()->importAllCalendars();
     $importedCalendar = $this->_getImportCalendar();
     $this->assertEquals('calendar', $importedCalendar->name);
     $this->assertEquals('#711A76', $importedCalendar->color);
     $this->assertEquals('Calendar_Model_Event', $importedCalendar->model, print_r($importedCalendar->toArray(), true));
     $this->assertEquals(Tinebase_Core::getUser()->getId(), $importedCalendar->owner_id, print_r($importedCalendar->toArray(), true));
 }
コード例 #24
0
 /**
  * converts Tinebase_Record_Abstract to external format
  *
  * @param  Tinebase_Record_Abstract $_record
  * @return mixed
  */
 public function fromTine20Model(Tinebase_Record_Abstract $_record)
 {
     $jsonData = parent::fromTine20Model($_record);
     if (Tinebase_Core::getUser()->hasRight('Calendar', Calendar_Acl_Rights::MANAGE_RESOURCES)) {
         $jsonData['grants'] = Tinebase_Container::getInstance()->getGrantsOfContainer($_record->container_id, TRUE)->toArray();
         $jsonData['grants'] = Tinebase_Frontend_Json_Container::resolveAccounts($jsonData['grants']);
     }
     return $jsonData;
 }
コード例 #25
0
 /**
  * inspect update of one record (before update)
  *
  * @param   Tinebase_Record_Interface $_record      the update record
  * @param   Tinebase_Record_Interface $_oldRecord   the current persistent record
  * @return  void
  */
 protected function _inspectBeforeUpdate($_record, $_oldRecord)
 {
     if ($_record->number != $_oldRecord->number) {
         if (!Tinebase_Core::getUser()->hasRight('Sales', Sales_Acl_Rights::CHANGE_OC_NUMBER)) {
             throw new Sales_Exception_AlterOCNumberForbidden();
         }
         $this->_setNextNumber($_record);
     }
 }
コード例 #26
0
 /**
  * Renames the node
  * 
  * @throws Sabre\DAV\Exception\Forbidden
  * @param string $name The new name
  * @return void
  */
 public function setName($name)
 {
     self::checkForbiddenFile($name);
     if (!Tinebase_Core::getUser()->hasGrant($this->_getContainer(), Tinebase_Model_Grants::GRANT_EDIT)) {
         throw new Sabre\DAV\Exception\Forbidden('Forbidden to rename file: ' . $this->_path);
     }
     list($dirname, $basename) = Sabre\DAV\URLUtil::splitPath($this->_path);
     Tinebase_FileSystem::getInstance()->rename($this->_path, $dirname . '/' . $name);
 }
コード例 #27
0
 /**
  * test simple import from file into a not existing container
  * 
  *  - the calendar should be created
  */
 public function testSimpleImportIntoNewContainer()
 {
     $importer = new Calendar_Import_Ical(array('container_id' => 'unittest_not_existing'));
     $result = $importer->importFile(dirname(__FILE__) . '/files/simple.ics');
     $importedContainerId = Tinebase_Container::getInstance()->getContainerByName('Calendar', 'unittest_not_existing', Tinebase_Model_Container::TYPE_PERSONAL, Tinebase_Core::getUser()->getId())->getId();
     $events = Calendar_Controller_Event::getInstance()->search(new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $importedContainerId))), NULL);
     $this->assertEquals($importedContainerId, Tinebase_Container::getInstance()->getContainerById($importedContainerId)->getId());
     $this->assertEquals(6, $events->count(), 'events was not imported');
 }
 /**
  * resolves a record
  * 
  * @param string $value
  * @return array|string
  */
 protected function _resolveRecord($value)
 {
     if ($value === Addressbook_Model_Contact::CURRENTCONTACT) {
         $contact = Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::getUser()->getId(), TRUE)->toArray();
     } else {
         $contact = parent::_resolveRecord($value);
     }
     return $contact;
 }
コード例 #29
0
ファイル: SqlTest.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * As the backend does not depend on the container classes, we define
  * two static containers here.
  * Moreover we generate static initial datas for two tasks which act 
  * as our test rabits.
  */
 public function setUp()
 {
     $user = Tinebase_Core::getUser();
     $container = $user->getPersonalContainer('Tasks', $user, Tinebase_Model_Grants::GRANT_ADMIN);
     $this->container_id = $container[0]->getId();
     $this->_backend = new Tasks_Backend_Sql();
     $this->_testTask1 = new Tasks_Model_Task(array('container_id' => $this->container_id, 'created_by' => 6, 'creation_time' => '2009-03-31 17:35:00', 'is_deleted' => 0, 'deleted_time' => NULL, 'deleted_by' => NULL, 'percent' => 70, 'completed' => NULL, 'due' => '2009-04-30 17:35:00', 'description' => str_pad('', 1000, '.'), 'geo' => 0.2345, 'location' => 'here and there', 'organizer' => Tinebase_Core::getUser()->getId(), 'priority' => 2, 'summary' => 'our first test task', 'url' => 'http://www.testtask.com'));
     $this->_persistantTestTask1 = $this->_backend->create($this->_testTask1);
 }
コード例 #30
0
ファイル: Faq.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * the constructor
  *
  * don't use the constructor. use the singleton
  */
 private function __construct()
 {
     $this->_applicationName = 'SimpleFAQ';
     $this->_backend = new SimpleFAQ_Backend_Faq();
     $this->_modelName = 'SimpleFAQ_Model_Faq';
     $this->_currentAccount = Tinebase_Core::getUser();
     $this->_purgeRecords = FALSE;
     $this->_doContainerACLChecks = TRUE;
 }