/**
  * Revokes a User Right
  * 
  * @param string $user_id
  * @param string $right
  * @return boolean
  */
 public static function revoke_right($user_id, $right)
 {
     $error = new argent_error();
     $db = new argent_database();
     if (!self::object_exists($user_id)) {
         $error->add('1013', 'Invalid user account', $user_id, 'argent_uauth');
     }
     $right_id = self::right_exists($right);
     if (!$right_id) {
         $error->add('1042', 'Invalid user right', $right, 'argent_uauth');
     }
     if (!self::user_has_right($right, $user_id)) {
         return true;
     }
     return $user_right = argent_meta::unrelate($user_id, $right_id, 'user_right');
 }
 public static function find_related($primary_object_id = null, $secondary_object_id = null, $relationship = null, $include_reverse = false)
 {
     $error = new argent_error();
     $db = new argent_database();
     if ($primary_object_id != null && !argent_meta::object_registered($primary_object_id)) {
         $error->add('1038', 'Object does not exist', $primary_object_id, 'argent_uauth');
     }
     if ($secondary_object_id != null && !argent_meta::object_registered($secondary_object_id)) {
         $error->add('1038', 'Object does not exist', $secondary_object_id, 'argent_uauth');
     }
     if (!is_string($relationship) && $relationship != null) {
         $error->add('1050', 'Invalid data type: expecting STRING', $relationship, 'argent_meta');
     }
     if ($error->has_errors()) {
         return $error;
     }
     $sql = "\r\n                    SELECT\r\n                        *\r\n                    FROM\r\n                        `ua_relationships`\r\n                    WHERE\r\n                        ";
     if ($primary_object_id != null || $secondary_object_id != null) {
         $sql .= "\r\n                        (\r\n                        ";
     }
     if ($primary_object_id != null) {
         $sql .= "`primary_object_id` = '{$db->escape_value($primary_object_id)}'";
     }
     if ($primary_object_id != null && $secondary_object_id != null) {
         $sql .= "\r\n                    AND\r\n                    ";
     }
     if ($secondary_object_id != null) {
         $sql .= "\r\n                        `secondary_object_id` = '{$db->escape_value($secondary_object_id)}'\r\n                      ";
     }
     if ($primary_object_id != null || $secondary_object_id != null) {
         $sql .= "\r\n                        )\r\n                    ";
     }
     if ($include_reverse) {
         $sql .= "\r\n                        OR\r\n                          ";
         if ($primary_object_id != null || $secondary_object_id != null) {
             $sql .= "\r\n                            (\r\n                            ";
         }
         if ($secondary_object_id != null) {
             $sql .= "`primary_object_id` = '{$db->escape_value($secondary_object_id)}'";
         }
         if ($primary_object_id != null && $secondary_object_id != null) {
             $sql .= "\r\n                        AND\r\n                        ";
         }
         if ($primary_object_id != null) {
             $sql .= "\r\n                            `secondary_object_id` = '{$db->escape_value($primary_object_id)}'\r\n                          ";
         }
         if ($primary_object_id != null || $secondary_object_id != null) {
             $sql .= "\r\n                            )\r\n                        ";
         }
     }
     if ($relationship != null && ($primary_object_id != null || $secondary_object_id != null)) {
         $sql .= "\r\n                    AND\r\n                    ";
     }
     if ($relationship != null) {
         $sql .= "\r\n                        `relationship` = '{$db->escape_value($relationship)}'\r\n                    ";
     }
     $relationship_data = $db->returntable($sql);
     return $relationship_data;
 }