public function testHas_access_to_module() { foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { $base_ids = []; foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); $base_ids[] = $base_id; } self::$object->revoke_access_from_bases($base_ids); self::$object->revoke_unused_sbas_rights(); } if (self::$object->is_admin()) { $this->assertTrue(self::$object->has_access_to_module('admin')); } else { $this->assertFalse(self::$object->has_access_to_module('admin')); } $this->assertFalse(self::$object->has_access_to_module('thesaurus')); $this->assertFalse(self::$object->has_access_to_module('upload')); $this->assertFalse(self::$object->has_access_to_module('report')); $found = false; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); $base_ids[] = $base_id; self::$object->update_rights_to_base($base_id, ['canreport' => true]); $found = true; break; } if ($found) { break; } } $this->assertTrue(self::$object->has_access_to_module('report')); $this->assertFalse(self::$object->has_access_to_module('thesaurus')); $this->assertFalse(self::$object->has_access_to_module('upload')); foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { self::$object->update_rights_to_sbas($databox->get_sbas_id(), ['bas_modif_th' => true]); $found = true; } $this->assertTrue(self::$object->has_access_to_module('report')); $this->assertTrue(self::$object->has_access_to_module('thesaurus')); $this->assertFalse(self::$object->has_access_to_module('upload')); $found = false; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); $base_ids[] = $base_id; self::$object->update_rights_to_base($base_id, ['canaddrecord' => true]); $found = true; break; } if ($found) { break; } } $this->assertTrue(self::$object->has_access_to_module('report')); $this->assertTrue(self::$object->has_access_to_module('thesaurus')); $this->assertTrue(self::$object->has_access_to_module('upload')); }
/** * Пользователь - создатель документа * * @param integer $user_id * @return boolean */ public function is_creator($user_id = NULL) { if ($this->_is_authored === TRUE) { if ($user_id === NULL) { $user_id = Auth::get_id(); } $created_by_id = (int) Arr::get($this->system_fields(), 'created_by_id'); return ACL::is_admin($user_id) or $created_by_id == (int) $user_id; } return TRUE; }
/** * Пользователь - создатель раздела * * @param integer $user_id * @return boolean */ public function is_creator($user_id = NULL) { if ($user_id === NULL) { $user_id = Auth::get_id(); } return ACL::is_admin($user_id) or $this->_created_by_id == (int) $user_id; }