Esempio n. 1
0
 /**
  * Writes the privilege to the DB unless the privilege member is still null (in which
  * case the inherited default will kick in). In all other cases the type will have
  * already populated storage->object with a temporary object in set_value().
  */
 function convert_to_storage()
 {
     if ($this->privilege) {
         $object = $this->storage->object;
         // If we have sufficient privileges, we set all privilege accordingly.
         // otherwise we log this and exit silently.
         if ($object->can_do('midgard:privileges')) {
             $this->privilege->store();
         } else {
             debug_add("Could not synchronize privilege of field {$this->name}, access was denied, midgard:privileges is needed here.", MIDCOM_LOG_WARN);
         }
     }
 }
Esempio n. 2
0
 /**
  * @dataProvider providerStoreArray
  */
 public function testStoreArray($input, $output)
 {
     midcom::get('auth')->request_sudo('midcom.core');
     $privilege = new midcom_core_privilege($input);
     $stat = $privilege->store();
     $this->assertEquals($output['stat'], $stat, midcom_connection::get_error_string());
     foreach ($output as $field => $value) {
         if ($field == 'stat') {
             continue;
         }
         $this->assertEquals($value, $privilege->{$field}, 'Difference in field ' . $field);
     }
     $stat = $privilege->drop();
     $this->assertTrue($stat);
     midcom::get('auth')->drop_sudo();
 }