public function setup() { parent::setup(); $GLOBALS['obm']['uid'] = 3; $this->mailObserver = new OBM_EventMailObserver(); OBM_EventFactory::getInstance()->attach($this->mailObserver); SMailer::set_default_transport(new Stato_StaticTransport()); OBM_Acl::initialize(); }
public function testPublicRights() { OBM_Acl::initialize(); $this->assertFalse(OBM_Acl::canAccess(2, 'cv', 1)); $this->assertFalse(OBM_Acl::canRead(2, 'cv', 1)); $this->assertFalse(OBM_Acl::canWrite(2, 'cv', 1)); $this->assertFalse(OBM_Acl::canAdmin(2, 'cv', 1)); OBM_Acl::setPublicRights('cv', 1, array('access' => 1, 'read' => 1, 'write' => 0)); $this->assertTrue(OBM_Acl::canAccess(2, 'cv', 1)); $this->assertTrue(OBM_Acl::canRead(2, 'cv', 1)); $this->assertFalse(OBM_Acl::canWrite(2, 'cv', 1)); $this->assertFalse(OBM_Acl::canAdmin(2, 'cv', 1)); OBM_Acl::allow(2, 'cv', 1, 'admin'); $this->assertTrue(OBM_Acl::canAccess(2, 'cv', 1)); $this->assertTrue(OBM_Acl::canRead(2, 'cv', 1)); $this->assertFalse(OBM_Acl::canWrite(2, 'cv', 1)); $this->assertTrue(OBM_Acl::canAdmin(2, 'cv', 1)); $this->assertEquals(OBM_Acl::getAllowedEntities(2, 'cv', 'read', null, 'title'), array(1 => 'CV Admin')); OBM_Acl::setPublicRights('cv', 1, array('access' => 1, 'read' => 1, 'write' => 0, 'admin' => 1)); $this->assertTrue(OBM_Acl::canAccess(3, 'cv', 1)); $this->assertTrue(OBM_Acl::canRead(3, 'cv', 1)); $this->assertFalse(OBM_Acl::canWrite(3, 'cv', 1)); $this->assertFalse(OBM_Acl::canAdmin(3, 'cv', 1)); $this->assertEquals(OBM_Acl::getPublicRights('cv', 1), array( 'access' => 1, 'read' => 1, 'write' => 0, 'admin' => 0 )); }
| as published by the Free Software Foundation; version 2 | | of the License. | | | | This program 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 General Public License for more details. | +-------------------------------------------------------------------------+ | http://www.obm.org | +-------------------------------------------------------------------------+ */ include_once 'CronJob.class.php'; global $obminclude; include_once "{$obminclude}/of/of_acl.php"; include_once "{$obminclude}/of/of_category.inc"; OBM_Acl::initialize(); define('MAX_FTP_ERRORS', 3); class SatelliteBackup extends CronJob { /** * @var Logger */ var $logger; function mustExecute($date) { $delta = 24 * 60; //every days $instant = 2 * 60 % $delta; //at 2:00 $min = (int) ($date / 60); return $min % $delta === $instant;
public function testVcalendarGetSingleEventByExtId(){ // lmartin should get the event he owns (the 4) $GLOBALS['obm']['uid'] = 9; $GLOBALS['obm']['domain_id'] = 3; OBM_Acl::initialize(); $writerOBM = new Vcalendar_Writer_OBM(); $eventData = $writerOBM->getEventByExtId("double"); $this->assertEquals(4, $eventData->Record["event_id"]); // ytouzet should get the event he has rights on (the 4) $GLOBALS['obm']['uid'] = 10; $writerOBM = new Vcalendar_Writer_OBM(); $eventData = $writerOBM->getEventByExtId("double"); $this->assertEquals(4, $eventData->Record["event_id"]); // adupont should get the event which he participates (the 3) $GLOBALS['obm']['uid'] = 8; $writerOBM = new Vcalendar_Writer_OBM(); $eventData = $writerOBM->getEventByExtId("double"); $this->assertEquals(3, $eventData->Record["event_id"]); // someone without write rights, not owner nor participant should get the first event with "double" ext_id $GLOBALS['obm']['uid'] = 11; $writerOBM = new Vcalendar_Writer_OBM(); $eventData = $writerOBM->getEventByExtId("double"); $this->assertEquals(2, $eventData->Record["event_id"]); // With a single event matching an ext id, getEventByExtId should return this single event $GLOBALS['obm']['uid'] = 9; $writerOBM = new Vcalendar_Writer_OBM(); $eventData = $writerOBM->getEventByExtId("single"); $this->assertEquals(5, $eventData->Record["event_id"]); }